ferranbt / fastssz

Fast Ethereum2.0 SSZ encoder/decoder
MIT License
74 stars 44 forks source link

Support for nested `List` #40

Closed terencechain closed 3 years ago

terencechain commented 3 years ago

We'll need to support nested List for the upcoming merge milestone. Referencing the spec below, transactions in BeaconBlockBody is a nested List which I don't think we have ever had it before. Can we please add support this?

OpaqueTransaction: ByteList[MAX_BYTES_PER_OPAQUE_TRANSACTION]
transactions: List[OpaqueTransaction, MAX_EXECUTION_TRANSACTIONS]

https://github.com/ethereum/eth2.0-specs/blob/dev/specs/merge/beacon-chain.md#executionpayload

cc @ferranbt

ferranbt commented 3 years ago

Would not this be something like [MAX_EXECUTION_TRANSACTIONS][MAX_BYTES_PER_OPAQUE_TRANSACTION]byte which is already supported?

rauljordan commented 3 years ago

it would be something like ssz-max: MAX_EXECUTION_TRANSACTIONS, MAX_BYTES_PER_OPAQUE_TRANSACTION then. Does fastssz support this format for the tag?

rauljordan commented 3 years ago

Doesn't seem like

type Transactions struct {
    Opaque [][]byte `json:"opaque" ssz-size"?,?" ssz-max:"2048,2048"`
}

is supported as we get: failed to encode Transactions: [][]byte expects a ssz-size tag

rauljordan commented 3 years ago

Opened https://github.com/ferranbt/fastssz/pull/41/files, lemme know if this makes sense @ferranbt