-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: params.ChainConfig
extra payload can use root JSON
#8
Conversation
100a1eb
to
0c14c32
Compare
} | ||
|
||
// MarshalJSON implements the [json.Marshaler] interface. | ||
func (c *ChainConfig) MarshalJSON() ([]byte, error) { |
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.
I noticed in a couple cases that MarshalJSON()
being defined on the value vs. pointer makes a difference.
Since it is only a couple instances so far I switched the uses to &
to move on, but perhaps this should be defined on the value to avoid invoking the default MarshalJSON when the receiver is non-pointer.
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.
Interesting! Do you remember where this was, so I can take a look before I merge this? I defined it on the pointer because that's what tends to be carried around, e.g. in vm.EVM
.
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.
I'm going to leave it as defined on the pointer for now. In the geth code base there are only two instances where a non-pointer ChainConfig
is used (note that most of the results are either new(ChainConfig)
or immediately address the value with &
).
This is in contrast to the 65 files with a *ChainConfig
.
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.
The *ChainConfig instances will still work if the receiver is value. We can leave it as is for now.
Sorry about pushing the refactor in a9250c6 after your review; I didn't realise that you'd already approved. The code is functionally identical and much simpler, plus there are no changes to the tests so I'll continue to merge it. |
Why this should be merged
Adds support for backwards compatibility with JSON format of
ava-labs/{subnet-evm,coreth}/params.ChainConfig
.How this works
The
params.Extras.ReuseJSONRoot bool
flag is added to allow the end user to signal the need for backwards compatibility. This isn't the default because of the need for multi-pass (un)marshalling.For extra payload:
ReuseJSONRoot == false
=>ReuseJSONRoot == true
=>How this was tested
Unit tests for JSON (un)marshalling for all cases; i.e when:
extra
field to be exported with thejson: "extra"
tag; and