-
Notifications
You must be signed in to change notification settings - Fork 196
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
feat(store,world): replace ephemeral
tables with offchain
tables
#1558
Conversation
🦋 Changeset detectedLatest commit: 3a803cc The changes in this PR will be included in the next version bump. This PR includes changesets to release 29 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
205d4ea
to
d01d954
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so glad to get rid of all the ephemeral specific stuff, this feels a lot cleaner!
but I am surprised gas went up across the board
// Early return if the table is an offchain table | ||
if (tableId.getType() == RESOURCE_OFFCHAIN_TABLE) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we support splicing for offchain tables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do for static fields! Since splicing for static fields doesn't require reading anything from storage, can just support it for static fields without any further changes. For dynamic fields it's not supported because it would require reading the dynamic field's length from storage (but it's not stored in storage), see #1558 (comment)
Codegen doesn't render the dynamic field methods for offchain tables, but does render all other ones, so much more "real" tables than before with ephemeral
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohh I see, I was thinking about push/pop but that's a dynamic field thing 👌
it's because we're doing an additional check in all store methods to early return if it's an offchain table, and that check costs 200 gas |
packages/store/src/StoreCore.sol
Outdated
// Splicing dynamic data is not supported for offchain tables, because it | ||
// requires reading the previous encoded lengths from storage | ||
if (tableId.getType() == RESOURCE_OFFCHAIN_TABLE) { | ||
revert IStoreErrors.StoreCore_InvalidResourceType(string(bytes.concat(RESOURCE_OFFCHAIN_TABLE))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: no support for dynamic splice
19ca3b2
to
5213b7b
Compare
.changeset/small-chicken-repair.md
Outdated
|
||
```diff | ||
- EphemeralTable.emitEphemeral(value); | ||
+ OffchainTable.setRecord(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be OffchainTable.set(key, value)
?
f618a62
to
7529b93
Compare
Co-authored-by: Kevin Ingersoll <[email protected]>
76c2fbc
to
3a803cc
Compare
Fixes #1123
Replacement for #1496 (since we changed the approach)