ethereum2.0 - SSZ

in #ethereum5 years ago (edited)

안녕하세요, 이더리움 코드보는 SigmoiD입니다.
오늘은 이더리움 2.0 / 세레니티를 누가 어디서 무엇을 개발하는지 SSZ를 토픽으로 잡고 찾아봤습니다.

ewasm토픽은 여기:https://steemit.com/ethereum/@sigmoid/ethereum2-0-ewasm

먼저 SSZ는 비탁릭 뷰테린이 최초 제안한 RLP를 대체하는 serialization 방식입니다.
Simple SerialiZation의 약자로, 0x800000 + len(data) + data로 심플하게 구현하자는 목적을 가지고 제안되었고,
ethereum2.0의 shard체인 beacon chain의 serialize 기본 방식으로 채택되었습니다.

아래 링크에서 제공되는 샘플을 보실수 있습니다.
https://github.com/ethereum/research/tree/master/py_ssz

The spec:

encode(string) = enc3b(len(string)) + string

Where enc3b(x) encodes x as three bytes, in big-endian format

encode(list) = enc3b(8388608 + sum(len([encode(x) for x in list]))) + \
               b''.join([encode(x) for x in list])

And that's it!

Examples:

 cow -> \x00\x00\x03cow
[dog, horse] -> \x80\x00\x0e\x00\x00\x03dog\x00\x00\x05horse

enc3b의 8388608은 hexary로 0x800000이고, [dog,hose]는 [800003+'d'+'o'+'g' , 800005+'h'+'o'+'r'+'s'+'e'] 이니까, 총길이가 (3+3)+(3+5) = 0xe(14)가 되고요, 최종적으로 80 00 0e + 800003+'d'+'o'+'g' + 800005+'h'+'o'+'r'+'s'+'e' 가 되는 것이죠. (참 쉽죠?)

ethereum 2.0에서 ssz 스펙과 구현현황은 아래의 링크에서 확인할 수 있습니다.
https://github.com/ethereum/eth2.0-specs/blob/master/specs/simple-serialize.md

https://github.com/prysmaticlabs/prysm/tree/master/shared/ssz
세레니티 go구현체를 만드는 prysmaticlabs의 프로젝트에서 구현/유지/보수중에 있네요.
(Prysm: Go implementation of Ethereum 2.0 - casper & sharding)

퀵하게 cpp 버전을 한번 만들어 봤는데, 제대로 기여한번 해볼까요?
https://github.com/NAKsir-melody/cpp_ssz

이더리움 연구에 도움이 되시길 바랍니다^^

Coin Marketplace

STEEM 0.27
TRX 0.13
JST 0.032
BTC 60953.94
ETH 2920.49
USDT 1.00
SBD 3.57