Bump ugorji/go/codec and remove codecgen - #547
Conversation
|
There was a problem hiding this comment.
🟡 Changes recommended
TxType.MarshalJSON can panic on a nil receiver, which is plausible when invoked via interface-based marshaling (e.g., through go/codec).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates the project’s JSON serialization path for EVM block/transaction intermediate types by upgrading github.com/ugorji/go/codec and removing the previously checked-in codecgen output, relying on non-generated behavior instead.
Changes:
- Bump
github.com/ugorji/go/codecfromv1.2.12tov1.3.2. - Remove
codecgenusage: delete generatedinternal_types_codecgen.go, remove the//go:generate codecgen ...directive, and drop thecodecgenMakefile target. - Add
TxType.MarshalJSONto ensurego/codeccan use the custom JSON unmarshaller/serialization behavior forTxType.
File summaries
| File | Description |
|---|---|
| pkg/types/blocks/transactions.go | Adds TxType.MarshalJSON alongside the existing custom UnmarshalJSON. |
| pkg/types/blocks/internal_types_codecgen.go | Removes generated codecgen implementation. |
| pkg/types/blocks/block.go | Removes //go:generate codecgen ... directive. |
| Makefile | Removes codecgen install target and from generate dependencies. |
| go.mod / go.sum | Updates github.com/ugorji/go/codec dependency version and sums. |
Review details
- Files reviewed: 5/6 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| func (txt *TxType) MarshalJSON() ([]byte, error) { | ||
| // go/codec requires both Marshaler and Unmarshaler to be implemented in order to use either of them: | ||
| // https://github.com/ugorji/go/blob/master/codec/decode.go#L1853:L1854 | ||
| return json.Marshal(hexutil.Uint64(*txt)) | ||
| } |
Summary
codecgenin https://github.com/ugorji/go/releases/tag/codec%2Fv1.3.0, removing the generated files andcodecgentarget in Makefilejson.UnmarshalerifMarshaleris implemented as well, therefore adding a(txt *TxType) MarshalJSON()implementation that will make the encoder respect the already-existing(txt *TxType) UnmarshalJSON(data []byte)Benchmarks
chainlink-evm/pkg/types/block_json_benchmark_test.go
Line 73 in 6bd5cdd
Before
After