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, core/types: regenerate JSON marshaling, add "hash" to headers #13868

Merged
merged 4 commits into from
Apr 6, 2017

Conversation

fjl
Copy link
Contributor

@fjl fjl commented Apr 5, 2017

This PR uses gencodec:"required" instead of optional:"true", following an upstream change in gencodec. It also adds the hash to marshaled headers.

Fixes #13858.

@fjl fjl requested a review from bas-vk April 5, 2017 12:06
@mention-bot
Copy link

@fjl, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bas-vk to be a potential reviewer.

@karalabe karalabe added this to the 1.6.0 milestone Apr 5, 2017
Payload hexutil.Bytes `json:"input" gencodec:"required"`
V *hexutil.Big `json:"v" gencodec:"required"`
R *hexutil.Big `json:"r" gencodec:"required"`
S *hexutil.Big `json:"s" gencodec:"required"`
Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"`
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this optional:"yes" disappear?

S *big.Int `json:"s"`
V *big.Int `json:"v" gencodec:"required"`
R *big.Int `json:"r" gencodec:"required"`
S *big.Int `json:"s" gencodec:"required"`

// This is only used when marshaling to JSON.
Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"`
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this optional:"yes" disappear?

Payload hexutil.Bytes `json:"input" gencodec:"required"`
V *hexutil.Big `json:"v" gencodec:"required"`
R *hexutil.Big `json:"r" gencodec:"required"`
S *hexutil.Big `json:"s" gencodec:"required"`
Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"`
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this optional:"yes" disappear?

Payload hexutil.Bytes `json:"input" gencodec:"required"`
V *hexutil.Big `json:"v" gencodec:"required"`
R *hexutil.Big `json:"r" gencodec:"required"`
S *hexutil.Big `json:"s" gencodec:"required"`
Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, will remove

@fjl
Copy link
Contributor Author

fjl commented Apr 5, 2017

@karalabe PTAL

Time *hexutil.Big `json:"timestamp" gencodec:"required"`
Extra hexutil.Bytes `json:"extraData" gencodec:"required"`
MixDigest common.Hash `json:"mixHash" gencodec:"required"`
Nonce BlockNonce `json:"nonce" gencodec:"required"`
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason why all the gencodec:"required" tags are preserved within the generated code? As I understand it correctly, these fields are used to signal to the unmarshal that a missing field should cause an error. However that is "hard coded" in the generated unmarshal method, so I don't see why we'd need to preserve the tags in the generated code too.

Copy link
Contributor Author

@fjl fjl Apr 6, 2017

Choose a reason for hiding this comment

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

All tag strings are copied over into the intermediate marshaling type. gencodec parses the tag using package reflect and doesn't know anything about the format. Removing the tags would mean that gencodec needs to construct a new tag with the gencodec:"..." part removed. Feel free to open a PR that does this if the extra tags bother you, but there is zero benefit :)

Copy link
Member

Choose a reason for hiding this comment

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

Well, since you put it that way. LGTM 👍 :D

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

LGTM

@karalabe karalabe merged commit 3d8de95 into ethereum:master Apr 6, 2017
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.

3 participants