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: properly encode/decode started_at_ms in QueryTrace object #1591

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

KolbyML
Copy link
Member

@KolbyML KolbyML commented Nov 27, 2024

What was wrong?

fixes the second part of ethereum/portal-network-specs#352

We were exposing the implementation details of SystemTime for the started_at_ms when encoding the QueryTrace object. This doesn't comply with our Json-RPC spec.

As started_at_ms is supposed to be encoded as a milisecond timestamp.
Json only allows for u64's which will last us for millions of years.

for example this is what we are currently returning before this fix

"startedAtMs": {
    "secs_since_epoch": 1730857625,
    "nanos_since_epoch": 447534202
}

but the result is supposed to be like

"startedAtMs": 1730857625000,

How was it fixed?

  • updating the returned type for started_at_ms to a u64
  • adding a test to make sure things don't break in the future

Copy link
Member

@ogenev ogenev left a comment

Choose a reason for hiding this comment

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

LGTM 👍

let json_tracer: Value = json!(&tracer);
assert_eq!(json_tracer["startedAtMs"], tracer.started_at_ms);

// Manually set the started_at_ms to 5 so we can test it.
Copy link
Member

Choose a reason for hiding this comment

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

It seems the second part of the test makes the first part redundant. I would set the started_at_ms to 5 in the first part of the test and test it directly.

@KolbyML KolbyML merged commit f03fe8b into ethereum:master Nov 27, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants