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

core/types: fix discrepancy in receipt.EffectiveGasPrice json encoding tags #27114

Merged
merged 6 commits into from
Apr 26, 2023

Conversation

roberto-bayardo
Copy link
Contributor

@roberto-bayardo roberto-bayardo commented Apr 18, 2023

the execution api spec suggests receipt.EffectiveGasPrice should be required, but it's currently not tagged as required in its receipt.go schema. Further, the field is tagged as 'omitempty' in the generated code even though it's not tagged as such in the schema.

This PR leaves the field as untagged in the receipt.go schema for backwards compatibility, adds a comment clarifying it's still technically required, removes the omitempty discrepancy in the generated code, and adds/updates test cases to codify the untagged behavior of the field.

Alternatives considered:

  • tag as required in schema + generated code. Dismissed due to backwards compatilbity concerns as it could break interop w/ older servers that do not require the field.

  • tag as omitempty in both schema + generated code. I don't have a strong reason yet to exclude this alternative, though I don't have a reason to prefer it either.

@roberto-bayardo
Copy link
Contributor Author

cc @fjl

@fjl
Copy link
Contributor

fjl commented Apr 19, 2023

I don't like adding required for this field because it will break decoder compatibility with older servers that do not have the field set.

@roberto-bayardo
Copy link
Contributor Author

I don't like adding required for this field because it will break decoder compatibility with older servers that do not have the field set.

Makes sense. Would leaving it as neither required nor omit empty make most sense then? That's how it was in the schema before, but the generated code still had omit empty for reasons I don't entirely understand.

@roberto-bayardo
Copy link
Contributor Author

roberto-bayardo commented Apr 19, 2023

Hmm. I dropped the required tag from the schema, replacing with a comment. But the regenerated gen_receipt_json.go didn't change (other than the tag disappearing). Let me confirm it will not throw errors if the field is missing.

[edit] code didn't change because I had a typo in the tag originally ("gencode" instead of "gencodec" 🤦).

Have confirmed that leaving it as neither required nor omitempty results in a generated parser that is tolerant of the missing field, but always puts it in the output.

Alternative would be to just explicitly tag it as omitempty in the schema and leave the comment around having it this way for backwards compatibility. This way there's no more discrepancy between the schema in receipt.go and the generated code.

@roberto-bayardo roberto-bayardo changed the title change EffectiveGasPrice to required in receipt json per spec fix discrepancy in receipt.EffectiveGasPrice json encoding tags Apr 20, 2023
@roberto-bayardo
Copy link
Contributor Author

This PR now leaves the field as untagged in the receipt.go schema for backwards compatibility, but adds a comment clarifying it's still technically required, removes the omitempty discrepancy in the generated code, and adds/updates test cases to codify the untagged behavior of the field.

Updated the PR description accordingly, and also provided a list of the alternatives considered (tag as required, tag as omitempty).

update schema to clarify while it's required we
don't tag it as such for backwards compatibility.
Update tests which were treating it as omit empty.
cmd/evm/t8n_test.go Outdated Show resolved Hide resolved
cmd/evm/t8n_test.go Outdated Show resolved Hide resolved
cmd/evm/t8n_test.go Outdated Show resolved Hide resolved
cmd/evm/t8n_test.go Outdated Show resolved Hide resolved
@holiman holiman changed the title fix discrepancy in receipt.EffectiveGasPrice json encoding tags core/types: fix discrepancy in receipt.EffectiveGasPrice json encoding tags Apr 25, 2023
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@holiman holiman added this to the 1.11.7 milestone Apr 26, 2023
@holiman holiman merged commit f8aa623 into ethereum:master Apr 26, 2023
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 6, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 10, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 21, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 27, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 17, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 18, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 29, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 30, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 31, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 31, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 1, 2024
wanwiset25 pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request Nov 13, 2024
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.

6 participants