-
Notifications
You must be signed in to change notification settings - Fork 397
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
Time.Now()
always return initial UNIX time
#2348
Comments
Time.Now()
always return 0Time.Now()
always return initial UNIX time
In case of a main() run with Lines 945 to 957 in a1ab6a1
calls... gno/gnovm/stdlibs/time/time.go Lines 10 to 17 in a1ab6a1
where the machine is set, but Are there counterindications to not want the actual timestamps here? If we do, we probably want to reduce the precision of the returned timestamps, because of side-channels vulns like meltdown, as divulging precise timing information could be used to create a more effective attack model. |
cc @thehowl |
@MikaelVallenet is going to take up a larger refactor of |
I'll close this in favour of #851, as I think this issue adds little additional context to that anyway. |
Description
Found this while checking #2076
When you call
time.Now()
, it should return the elapsed time sinceUTC January 1, 1970 00:00:00
. However, when you call this function and print the time as shown below, it outputs the value1970-01-01 00:00:00 +0000 UTC m=+0.000000001
. It seems that instead of the elapsed time from that point, it is printing that point in time itself.When you run the code below, it prints the current time in the format
YYYY-MM-DD HH-MM-SS
, and you can see the initial UNIX time is displayed.Currently, there are two version of
time.Now()
: one that is a ported version of the Go standard library and another that is handled by native binding. I'm not sure which one is actually being called, but I think the latter implmentation will be executed.The function implemented with native binding calculates the time using the
Timestamp
andTimestampNano
fields ofExecContext
. I suspect that these fields might be storing a value of0
, causing all times to be output as the UNIX epoch time.gno/gnovm/stdlibs/std/context.go
Lines 10 to 22 in a1ab6a1
gno/gnovm/stdlibs/time/time.go
Lines 10 to 17 in a1ab6a1
The text was updated successfully, but these errors were encountered: