Skip to content

rlp.Decode fails to decode certain structs that encode without error #26069

@roberto-bayardo

Description

@roberto-bayardo

System information

Geth version: all
CL client & version: all
OS & Version: all

Expected behaviour

rlp.Encode should return error when trying to encode a struct whose output will result in errors when decoding.

Actual behaviour

I've found at least two cases demonstrating the issue:

(1) A struct with a pointer to a (non-optional, non-nil tagged) byte array encodes without error even when the pointer value is nil, but decoding that output results in error.

(2) A struct with more than one optional-tagged pointer encodes without error when one optional pointer is nil while a later one is non-nil, but decoding that output results in error.

Steps to reproduce the behaviour

See the test cases I added in the branch below. Two of the encoding tests corresponding to the cases above should probably return error but don't.

https://github.com/ethereum/go-ethereum/compare/master...roberto-bayardo:go-ethereum:rlp-bug?expand=1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions