-
Notifications
You must be signed in to change notification settings - Fork 202
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
Replace ephemeral
tables with offchain
tables
#1123
Comments
There's a few use cases to think about:
|
A couple thoughts:
|
I agree that offchain tables is a superset of ephemerals/events in terms of usefulness, the only downside is it's more complicated
I don't think we need to protect the user here, it's already easy to corrupt onchain data if you circumvent codegened libs and intentionally incorrectly call Store directly |
Can you elaborate on this / give an example for how to corrupt onchain data via external Store methods? For root systems it's of course possible to emit whatever event to make the onchain state diverge from the indexer state, and this is fine because only the root owner (usually the initial deployer of the World) can register root systems. The more important piece is that it should not be possible to make the onchain state diverge from the indexer state when writing data via the external Store methods, and in my mind this is currently true: whatever bytes data is provided to the methods is written to storage and emitted in events, and the indexer updates its state in the same way as the onchain state was updated. Every bytes value is "valid" in the sense that it can be interpreted as some type, and the interpretation is the same onchain and on the indexer. (Whether the value is semantically correct is a different question, but at least the value should be the same onchain and the indexer.) |
If we wanted to support all table methods (including I feel like the cleanest solution that would still fit most use cases is to only support These ephemeral tables would mostly solve the offchain table use case. For the separate use case of "custom events" we could add a separate solution: an optional root module that allows users to register custom events (each event type can be registered once, is bound to a namespace and can only be emitted by systems in that namespace). This would even allow for things like token interfaces to be implemented directly on the World contract, rather than of the workaround of an interface proxy (note that there could only be one of these interfaces per World since each event can only be registered once). |
true, I suppose I don't see the divergence as a fundamentally different problem - if the contract deployer wants to scam the user, they can. And devs who use generated libs wouldn't stumble onto this problem in the first place. But for devs who do complicated stuff with
I think a root system can already just emit events that will be emitted by World because they're delegatecalled |
I think the main thing we should avoid is the possibility for diverging state on vanilla Worlds without root systems (= it shouldn't be possible to have diverging state by using the permissionless external Store methods)
I should clarify - the proposed root module adds the ability for anyone (not just the root namespace owner) to register a custom event, which can then be emitted by systems in the namespace for which the event was registered (not just root systems) by calling a method on the World. |
Specific proposed changes to ephemeral tables:
|
I like the naming suggestions! I feel like in terms of indexing, it might be worth having the separate events (or a boolean on the events) so that we don't have to look up the table registration/definition to determine if it's an offchain only table. Although the sync stack currently combines these/treats them as a single event, that was just me being lazy. I think there are decent use cases for knowing when a table is offchain only. cc @Kooshaba @yonadaaa |
ephemeral
tables with offchain
tables
Todos:
StoreEphemeralRecord
->StoreEvent
MyEvent.emit
instead ofMyEvent.emitEphemeral
The text was updated successfully, but these errors were encountered: