Skip to content
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

fix(gnodev): timestamp issue on reload #2943

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

gfanton
Copy link
Member

@gfanton gfanton commented Oct 13, 2024

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

  • test replays (I've only tested it manually)
Contributors' checklist...
  • 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, if any. More info here.

@github-actions github-actions bot added 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Oct 13, 2024
Copy link

codecov bot commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 93.54839% with 2 lines in your changes missing coverage. Please review.

Project coverage is 63.79%. Comparing base (1e2929b) to head (9d0e1ad).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
contribs/gnodev/pkg/dev/node.go 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2943      +/-   ##
==========================================
- Coverage   63.81%   63.79%   -0.03%     
==========================================
  Files         549      549              
  Lines       78833    78844      +11     
==========================================
- Hits        50308    50298      -10     
- Misses      25136    25154      +18     
- Partials     3389     3392       +3     
Flag Coverage Δ
contribs/gnofaucet 14.82% <ø> (-0.95%) ⬇️
gno.land 73.70% <ø> (ø)
gnovm 67.94% <ø> (ø)
misc/genstd 79.72% <ø> (ø)
tm2 62.39% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

zivkovicmilos added a commit that referenced this pull request Nov 4, 2024
## 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:
- Portal Loop chain is on block 100
- tx A results in a call to `time.Now()`, which returns time T, and
saves it somewhere (Realm state)
- the Portal Loop restarts, and uses all the transactions it encountered
in the past iteration as genesis txs
- the genesis is generated by executing the transactions
- when tx A is re-executed (this time as part of the genesis block),
**it should return time T, as with the original execution context**

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:
- don't break backwards compatibility
- don't modify critical APIs such as the SDK ABCI, but preserve
existing, working, functionality in its original form
- don't add another layer to the complexity pancake
- don't implement a solution that looks (and works) like a hack

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`, called
`MetadataGenesisState`, where metadata is associated with the
transactions. We hide the actual `AppState` 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:
- we need to add support to `tx-archive` for supporting exporting txs
with metadata. Should be straightforward to do
- the portal loop also needs to be restarted with this new "mode"
enabled
- we need to add support to existing `gnoland genesis` commands to
support the new `MetadataGenesisState`. It is also straightforward, but
definitely a bit of work
- if we want support for something like this in gnodev, the export /
import code of gnodev also needs to be modified to support the new
genesis state type (cc @gfanton)
	- #2943

Related PRs and issues:
- #2751
- #2744 

cc @moul @thehowl @jeronimoalbi @ilgooz 

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] 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>

---------

Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
@gfanton gfanton marked this pull request as ready for review November 13, 2024 09:14
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
@Kouteki Kouteki changed the title fix(gnodev): timstamps issue on reload fix(gnodev): timestamp issue on reload Nov 13, 2024
@Kouteki Kouteki added the in focus Core team is prioritizing this work label Nov 13, 2024
Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean 💯

contribs/gnodev/pkg/dev/node_test.go Show resolved Hide resolved
@zivkovicmilos
Copy link
Member

Codecov making the CI fail because this is on a fork 🤦‍♂️

@Kouteki Kouteki removed the request for review from thehowl November 18, 2024 03:21
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
This reverts commit ff5ab28.

Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in focus Core team is prioritizing this work 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related
Projects
Status: In Progress
Status: In Review
Development

Successfully merging this pull request may close these issues.

gnodev time.Now() values are not preserved on reload
3 participants