ethereum / beacon_chain

MIT License
209 stars 65 forks source link

ssz intX type is actually uint #112

Closed darrenlangley closed 5 years ago

darrenlangley commented 5 years ago

Hi all,

I noticed that ssz (https://github.com/ethereum/beacon_chain/blob/master/ssz/ssz.py) treats the type intX more like a uint rather than an int.

This works fine when signed int usually go between -128 to 128:

typ = 'int8'
value = 255
print(serialize(value, typ))

Also this errors with overflow:

typ = 'int8'
value = -1
print(serialize(value, typ))

If this is expected than cool, although it is a bit confusing calling it int rather than uint.

djrtwo commented 5 years ago

This lack of clarity has come up a few times over the past week. I believe we should probably support uint vs int explicitly.

mratsim commented 5 years ago

I was thinking about that but was holding off creating an issue while waiting for a first draft of the spec in https://github.com/ethereum/eth2.0-specs so that we could discussed it there.

Edit: PR https://github.com/ethereum/beacon_chain/pull/114