You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I've been looking into the Header RLP enc/dec.
My understanding is that RLP encoding is code generated and located here, and the as far as decoder goes, there is no special logic (ie. since every field of the Header struct is RLP decodable so is the whole struct).
This is to say if eg. BlobGas "exists", and even if BaseFee and WithdrawalHash are nil this header will be properly Encoded, but per my tests, it won't be decoded.
"WithWithdrawalHash" fails because header.BaseFee is initially nil but it is decoded as 0, and while it might sound like bikeshedding, but 0 != nil
"WithBlobGasFields" will fail with the following error Failed to decode header: rlp: input string too short for common.Hash, decoding into (types.Header).WithdrawalsHash
Questions
My questions are:
Are my test correct (I think they are, I don't see any obvious bugs)
Assuming they are, is this expected behaviour?
If yes, how come/why? I would assume that if header was managed to be encoded successfully that it can be decoded as well
The text was updated successfully, but these errors were encountered:
This code is created by rlpgen. Let me explain why it works this way:
Go structs are encoded as RLP lists. In package rlp, we have the concept of 'optional fields'. These fields can only be at the tail end of the struct. If an optional field is set, all preceding optional fields must also be encoded into the output to ensure the output list has the correct length. These preceding fields must be encoded even if they are zero-valued.
In types.Header, optional fields are used for attributes that have been added in hard forks. During block processing, the ordering of these fields is verified. Thus, even if it was theoretically possible to create a block header that has a BlobGasUsed but no BaseFee, such headers are invalid under the rules of Ethereum consensus, and will not exist in practice.
Hello, I've been looking into the Header RLP enc/dec.
My understanding is that RLP encoding is code generated and located here, and the as far as decoder goes, there is no special logic (ie. since every field of the Header struct is RLP decodable so is the whole struct).
Encoding logic
Per encoding logic, we have this
This is to say if eg.
BlobGas
"exists", and even ifBaseFee
andWithdrawalHash
arenil
this header will be properlyEncoded
, but per my tests, it won't be decoded.Tests
Here both test cases will fail:
header.BaseFee
is initiallynil
but it is decoded as0
, and while it might sound like bikeshedding, but0 != nil
Failed to decode header: rlp: input string too short for common.Hash, decoding into (types.Header).WithdrawalsHash
Questions
My questions are:
The text was updated successfully, but these errors were encountered: