-
Notifications
You must be signed in to change notification settings - Fork 20k
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
Conversation
core/types/gen_tx_json.go
Outdated
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:"-"` |
There was a problem hiding this comment.
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?
core/types/transaction.go
Outdated
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:"-"` |
There was a problem hiding this comment.
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?
core/types/gen_tx_json.go
Outdated
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:"-"` |
There was a problem hiding this comment.
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?
core/types/gen_tx_json.go
Outdated
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:"-"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, will remove
2345b8a
to
aafd64d
Compare
@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"` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR uses
gencodec:"required"
instead ofoptional:"true"
, following an upstream change in gencodec. It also adds the hash to marshaled headers.Fixes #13858.