gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + gno.land: a blockchain for timeless code and fair open-source.
https://gno.land/
Other
901 stars 378 forks source link

Gnodev: The time.Now() timestamp is incorrect #2960

Open thinhnx-var opened 1 month ago

thinhnx-var commented 1 month ago

Gnodev timestamp time.Now() incorrect.

Description

Not happens with test4, portal loop. Localchain is not tested. I make a transaction with gnokey to gnodev in-memory node, the timestamp time.Now() is incorrect. It will always recognize the timestamp of the previous command as the start time of current command. I tried with default macOS / iterm terminal, with ohmyzsh and p10k extension.

Your environment

Steps to reproduce

  1. Put time.Now() debug in realms / package. Like ufmt.Println("request at: ", time.Now())
  2. Start gnodev
  3. Make a gnokey call to function. Lets say the time is 1:00:00 now
  4. Wait for about 10 seconds. (Do nothing)
  5. Make a gnokey call to function again.

Expected behaviour

The log should be request at: 1:00:10 <- now

Actual behaviour

The log shows that request at: 1:00:00 <- time of previous command

Proposed solution

I do not really know where the problem is, maybe come from my terminal or the way the timestamp freeze. Let see if anyone has same issues.

Ref image I tested with gnodev - using zsh shell -> date and LogTime return the time.Now(). image

jefft0 commented 1 month ago

I can't reproduce the error. I'm using gnodev and I modified r/demo/boards to include the seconds in the timestamp. I use gnokey to make two "CreateThread" transactions. Here is the render. The timestamps are 1:36:01pm and 1:36:08pm

test1 - @test1, 2024-10-16 1:36:01pm UTC [x] (0 replies) (0 reposts)
testing - @test1, 2024-10-16 1:36:08pm UTC [x] (0 replies) (0 reposts)

(Be careful not to reload gnodev. There is the known bug that this resets all the timestamps to the same value.)

thinhnx-var commented 1 month ago

@jefft0 I just tried again with r/demo/boards and other realms and still have same issue. So maybe the problem comes from ohmyzsh or p10k extension on my terminal.

Let me disable them and try again. If the issue is from terminal / env, I will close this topic soon.

Thank for fast response sir 🙏

thinhnx-var commented 1 month ago

after disabling extension and use pure mac terminal, I still face the issue. Let me know if anyone has same issue while I try to figure it out :pray:

MalekLahbib commented 1 month ago

From what I remember, @leohhhn told me that gnodev doesn't create another block if there's not a new transaction, and time.Now() changes if a new block is created. I had exactly the same problem when I was doing tests on a realm.

thehowl commented 1 month ago

cc @gfanton

maybe related #1510