CIP-112: Fix Block Headers custom Field Serde

CIP Title Author Status Type Created
112 Fix Block Headers custom Field Serde Peilun Li (@peilun-conflux) Draft Spec Breaking 2023-05-08

Simple Summary

Fix the incorrect encoding and decoding implementation of the custom field of block headers.

Abstract

Currently, in the block header RLP encoding, each element in the custom list is appended to the RLP list as raw bytes, where its RLP-encoded data should be appended instead. Decoding such an field as raw bytes may result in a different custom field from the encoded data.

Motivation

We should encode and decode the custom field as expected so that the correct data can be extracted.

Specification

Each element of the custom field would be appended to the block header RLP list normally, which means its RLP-encoded data are appended. And decoding will also treat each element as RLP-encoded bytes.

Rationale

Nothing needs to explain.

Backwards Compatibility

This changes the block header encoding and decoding in P2P transmission, so it’s protocol breaking.

Test Cases

TBA

Implementation

N/A

Security Considerations

This fix will be enabled with a hardfork, so all upgraded nodes should encode/decode the block headers with the same rule.

Copyright

Copyright and related rights waived via CC0.

3 Likes