ethereum / beacon_chain

MIT License
211 stars 65 forks source link

Simpleserialize reports length zero #92

Closed paulhauner closed 6 years ago

paulhauner commented 6 years ago

Here is the output of simpleserialize (ssz) when serializing a zero value.

>>> ssz.serialize(0, 'int32')
b'\x00\x00\x00\x00'

I think the output should either be:

  1. b'\x00\x00\x01\x00'
  2. b'\x00\x00\x00'

Option (2) is shorter, but I prefer (1) because it's simpler to implement and more consistent.

I could go either way at this stage.

djrtwo commented 6 years ago

I'm missing something. What is wrong with the current output?

paulhauner commented 6 years ago

b'\x00\x00\x00\x00' is invalid because there are 3x length bytes and 1x data bytes (4 bytes) however the length bytes read 0.

So it's saying "the length of this thing is zero" however that's wrong because there is a byte following it.

Therefore I expect: b'\x00\x00\x01\x00' which says "there's one byte here" and when you read it you find it equals zero.

Does that help?

paulhauner commented 6 years ago

Alrighty, turns out this was a misunderstanding -- I was getting my wires crossed between the implementations.

I'm going to close this as it's not relevant anymore.