-
Notifications
You must be signed in to change notification settings - Fork 385
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: support metadata for genesis txs #2941
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2941 +/- ##
==========================================
+ Coverage 63.32% 63.36% +0.03%
==========================================
Files 548 548
Lines 78511 78600 +89
==========================================
+ Hits 49719 49805 +86
- Misses 25438 25441 +3
Partials 3354 3354
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Amazing! I've made some additional modifications to |
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.
I personally like this solution; it's simple and elegant :)
Tested and approved 👏 🚀
Blocks are essential for maintaining a chain history. A TxMetadata or tx-export format isn't necessary to run a chain; it's merely an intermediary format we chose because it made sense (as an intermediary format). It allows us to create genesis from an export. Since this format is not used by the chain in real-time and does not synchronize the chain, we should design it in a way that we believe is most effective for us and for tools. In my opinion, a tx-export format or TxWithMetadata should either include the missing metadata or link to the block metadata in some way. Let's strive to find the best compromise regarding size and other factors. When we establish this new format, we should not view it as an exception for Regarding struct embedding and Amino, that's unfortunate. Currently, I prefer not to create an interface but to define TxMetadata as the format we want for the tx-exports tool as well, an official new type defined in the |
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.
LGTM
- [x] depends on #2941 resolve #1509 This PR addresses the timestamp issue on gnodev by implementing the `MetadataTX` changes from #2941. Timestamps will now be correctly handled for `Reload` and `import`/`export`. For `Reset`, the timestamp will be updated to the current time. cc @zivkovicmilos @thehowl #### ~TODOs~ - [x] test replays (I've only tested it manually) <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Signed-off-by: gfanton <[email protected]>
- [x] depends on gnolang#2941 resolve gnolang#1509 This PR addresses the timestamp issue on gnodev by implementing the `MetadataTX` changes from gnolang#2941. Timestamps will now be correctly handled for `Reload` and `import`/`export`. For `Reset`, the timestamp will be updated to the current time. cc @zivkovicmilos @thehowl #### ~TODOs~ - [x] test replays (I've only tested it manually) <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Signed-off-by: gfanton <[email protected]>
Description
This PR introduces metadata support for genesis transactions (such as timestamps), in the form of a new Gno genesis state that's easily generate-able.
Shoutout to @clockworkgr for sanity checking the idea, and providing insights that ultimately led to this PR materializing.
BREAKING CHANGE
The
GnoGenesisState
is now modified, and all functionality that references it (ex.gnogenesis
,tx-archive
) will need to adapt.What we wanted to accomplish
The Portal Loop does not save "time" information upon restarting (from block 0). This means that any transaction that resulted in a Realm / Package calling
time.Now()
will get differing results when these same transactions are "replayed" as part of the loop (in the genesis state).We wanted to somehow preserve this timestamp information when the transactions (from a previous loop), are executed as part of the genesis building process.
For example:
time.Now()
, which returns time T, and saves it somewhere (Realm state)It is worth noting that this functionality is something we want in
gnodev
, so simple helpers on the Realms to update the timestamps wouldn't work.What this PR does
I've tried to follow a couple of principles when working on this PR:
I'm not a huge fan of execution hooks, so the solution proposed in this PR doesn't rely on any hook mechanism. Not going with the hook approach also significantly decreases the complexity and preserves readability.
The base of this solution is enabling execution context modification, with minimal / no API changes.
Having functionality like this, we can tailor the context during critical segments such as genesis generation, and we're not just limited to timestamps (which is the primary use-case).
We also introduce a new type of
AppState
, calledMetadataGenesisState
, where metadata is associated with the transactions. We hide the actualAppState
implementation behind an interface, so existing tools and flows don't break, and work as normal.What this PR doesn't do
There is more work to be done if this PR is merged:
tx-archive
for supporting exporting txs with metadata. Should be straightforward to dognoland genesis
commands to support the newMetadataGenesisState
. It is also straightforward, but definitely a bit of workRelated PRs and issues:
cc @moul @thehowl @jeronimoalbi @ilgooz
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description