attestantio / go-eth2-client

Apache License 2.0
102 stars 59 forks source link

Is it correct ssz-max? #98

Closed GalRogozinski closed 4 months ago

GalRogozinski commented 5 months ago

https://github.com/attestantio/go-eth2-client/blob/21f7dd480fed933d8e0b1c88cee67da721c80eb2/spec/phase0/attestation.go#L30

The size here is expressed in bytes, but I believe we have a 2048 bitmap. So shouldn't it be 2048/8 = 256?

mcdee commented 4 months ago

I took a look at this, https://github.com/ferranbt/fastssz/blob/be958d20c2b3837b8a1ea2174f5bcab45af5b198/hasher.go#L203 seems to suggest that the max size is in bits rather than bytes, and the functions at https://github.com/ferranbt/fastssz/blob/be958d20c2b3837b8a1ea2174f5bcab45af5b198/encode_test.go#L55 also talk about max size being in bits. https://github.com/ferranbt/fastssz/blob/main/spectests/structs.go also has tags listing the max size as 2048. So I think it's a case that max size isn't always in bytes, and in this case it's the maximum number of bits in the bitlist (minus the demarcation byte(s)).