ethereum / portal-network-specs

Official repository for specifications for the Portal Network
316 stars 85 forks source link

Add post-shanghai body encoding scheme #211

Closed njgheorghita closed 1 year ago

njgheorghita commented 1 year ago

Update spec to accommodate for post-shanghai encoded block bodies

Fixes #200

njgheorghita commented 1 year ago

Did you implement this the same way as Transactions are currently done? That is, having the RLP encoded Withdrawal as an SSZ ByteList in a Withdrawals SSZ List?

@kdeme Would it be better to encode the rlp encoded withdrawal as an ssz vector rather than ssz bytelist? the withdrawals are a fixed size (whereas txs are variable sized), so I'm not sure if the variable-sized bytelist is the right choice in this scenario?

kdeme commented 1 year ago

Would it be better to encode the rlp encoded withdrawal as an ssz vector rather than ssz bytelist? the withdrawals are a fixed size (whereas txs are variable sized), so I'm not sure if the variable-sized bytelist is the right choice in this scenario?

We can't actually do that, MAX_WITHDRAWAL_COUNT is a max. A block can also have less/no withdrawals. The consensus specs also have it as a list: https://github.com/ethereum/consensus-specs/blob/f7352d18cfb91c58b1addb4ea509aedd6e32165c/specs/capella/beacon-chain.md#executionpayload

edit: My bad, misread it. You are talking about the rlp encoded bytestring. Yeah, that would be possible.

njgheorghita commented 1 year ago

Copying over from discord for posterity... we cannot encode a withdrawal as an ssz fixed-length vector, since an rlp encoded withdrawal is actually variable length, as the prefixed empty bytes on u64 types are truncated.