Skip to content

Commit

Permalink
Fix bug with wrong serializer.SeriLengthPrefixType
Browse files Browse the repository at this point in the history
  • Loading branch information
jonastheis committed Nov 6, 2023
1 parent 9cfc673 commit 44b9e68
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/network/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func peerFromBytes(bytes []byte) (*Peer, error) {
var err error
byteReader := stream.NewByteReader(bytes)

if p.ID, err = stream.ReadObjectWithSize(byteReader, serializer.UInt16ByteSize, func(bytes []byte) (peer.ID, int, error) {
if p.ID, err = stream.ReadObjectWithSize(byteReader, serializer.SeriLengthPrefixTypeAsUint16, func(bytes []byte) (peer.ID, int, error) {
id, err := peer.IDFromBytes(bytes)
if err != nil {
return "", 0, ierrors.Wrap(err, "failed to parse peerID")
Expand All @@ -134,7 +134,7 @@ func peerFromBytes(bytes []byte) (*Peer, error) {
p.SetConnStatus(ConnStatusDisconnected)

if err = stream.ReadCollection(byteReader, serializer.OneByte, func(i int) error {
addr, err := stream.ReadObjectWithSize(byteReader, serializer.UInt16ByteSize, func(bytes []byte) (multiaddr.Multiaddr, int, error) {
addr, err := stream.ReadObjectWithSize(byteReader, serializer.SeriLengthPrefixTypeAsUint16, func(bytes []byte) (multiaddr.Multiaddr, int, error) {
m, err := multiaddr.NewMultiaddrBytes(bytes)
if err != nil {
return nil, 0, ierrors.Wrap(err, "failed to parse peer address")
Expand Down
4 changes: 2 additions & 2 deletions pkg/network/protocols/core/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ func (p *Protocol) SendSlotCommitment(cm *model.Commitment, to ...peer.ID) {
func (p *Protocol) SendAttestations(cm *model.Commitment, attestations []*iotago.Attestation, merkleProof *merklehasher.Proof[iotago.Identifier], to ...peer.ID) {
byteBuffer := stream.NewByteBuffer()

if err := stream.WriteCollection(byteBuffer, serializer.UInt32ByteSize, func() (elementsCount int, err error) {
if err := stream.WriteCollection(byteBuffer, serializer.SeriLengthPrefixTypeAsUint32, func() (elementsCount int, err error) {
for _, att := range attestations {
if err = stream.WriteObjectWithSize(byteBuffer, att, serializer.UInt16ByteSize, (*iotago.Attestation).Bytes); err != nil {
if err = stream.WriteObjectWithSize(byteBuffer, att, serializer.SeriLengthPrefixTypeAsUint16, (*iotago.Attestation).Bytes); err != nil {
return 0, ierrors.Wrapf(err, "failed to write attestation %v", att)
}
}
Expand Down
2 changes: 1 addition & 1 deletion tools/docker-network/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ docker run --rm \
-e GOCACHE="/go-cache" \
-e GOMODCACHE="/go-mod-cache" \
-w "/workspace/tools/genesis-snapshot" \
golang:1.21 go run -tags=rocksdb . --config docker --seed 7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih
golang:1.21-bookworm go run -tags=rocksdb . --config docker --seed 7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih

# Move and set permissions for the .snapshot file
mv -f ../genesis-snapshot/*.snapshot .
Expand Down

0 comments on commit 44b9e68

Please sign in to comment.