Remove `{.rlpInline.}` which was never really implemented

For a long time this caused invalid RLP parsing of `NewBlock` messages in the
`eth` protocol.

The `rlpInline` pragma was accepted but had no effect.  We could implemented
it, but it doesn't seem worth doing, with tests etc, as there's only one user
which has been fixed another way.

With `NewBlock`, whenever a peer sent us `NewBlock`, we'd get an RLP decoding
error, and disconnected the peer thinking it was the peer's error.

These messages are sent often by good peers, so whenever we connected to a
really good peer, we'd end up disconnecting within a minute due to this.  This
went unnoticed for years, as we stayed connected to old peers which have no new
blocks, and we weren't looking at peer quality, disconnect reasons or real-time
blockchain updates anyway.

Signed-off-by: Jamie Lokier <jamie@shareable.org>
This commit is contained in:
Jamie Lokier 2021-07-28 01:55:58 +01:00 committed by zah
parent 50c0c5f123
commit 5234e30f8b
3 changed files with 5 additions and 10 deletions

View File

@ -122,11 +122,9 @@ var bytes = encode(t1)
var t2 = bytes.decode(Transaction)
```
By default, sub-fields within objects are wrapped in RLP lists. You can avoid this
behavior by adding the custom pragma `rlpInline` on a particular field. In rare
circumstances, you may need to serialize the same field type differently depending
on the enclosing object type. You can use the `rlpCustomSerialization` pragma to
achieve this.
In rare circumstances, you may need to serialize the same field type
differently depending on the enclosing object type. You can use the
`rlpCustomSerialization` pragma to achieve this.
### Contributing / Testing

View File

@ -23,7 +23,8 @@ type
NewBlockAnnounce* = object
header*: BlockHeader
body* {.rlpInline.}: BlockBody
txs*: seq[Transaction]
uncles*: seq[BlockHeader]
PeerState = ref object
initialized*: bool

View File

@ -4,10 +4,6 @@ template rlpIgnore* {.pragma.}
## Specifies that a certain field should be ignored for the purposes
## of RLP serialization
template rlpInline* {.pragma.}
## This can be specified on a record field in order to avoid the
## default behavior of wrapping the record in a RLP list.
template rlpCustomSerialization* {.pragma.}
## This pragma can be applied to a record field to enable the
## use of custom `read` and `append` overloads that also take