diff --git a/pkg/network/peer.go b/pkg/network/peer.go index b52410792..18554f10d 100644 --- a/pkg/network/peer.go +++ b/pkg/network/peer.go @@ -81,15 +81,15 @@ func (p *Peer) SetConnStatus(cs ConnectionStatus) { func (p *Peer) Bytes() ([]byte, error) { byteBuffer := stream.NewByteBuffer() - if err := stream.WriteObjectWithSize(byteBuffer, p.ID, serializer.UInt16ByteSize, func(id peer.ID) ([]byte, error) { + if err := stream.WriteObjectWithSize(byteBuffer, p.ID, serializer.SeriLengthPrefixTypeAsUint16, func(id peer.ID) ([]byte, error) { return []byte(id), nil }); err != nil { return nil, ierrors.Wrap(err, "failed to write peer ID") } - if err := stream.WriteCollection(byteBuffer, serializer.OneByte, func() (elementsCount int, err error) { + if err := stream.WriteCollection(byteBuffer, serializer.SeriLengthPrefixTypeAsByte, func() (elementsCount int, err error) { for _, addr := range p.PeerAddresses { - if err = stream.WriteObjectWithSize(byteBuffer, addr, serializer.UInt16ByteSize, func(m multiaddr.Multiaddr) ([]byte, error) { + if err = stream.WriteObjectWithSize(byteBuffer, addr, serializer.SeriLengthPrefixTypeAsUint16, func(m multiaddr.Multiaddr) ([]byte, error) { return m.Bytes(), nil }); err != nil { return 0, ierrors.Wrap(err, "failed to write peer address") @@ -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") @@ -133,8 +133,8 @@ 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) { + if err = stream.ReadCollection(byteReader, serializer.SeriLengthPrefixTypeAsByte, func(i 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") diff --git a/pkg/network/protocols/core/protocol.go b/pkg/network/protocols/core/protocol.go index b19b168a0..6aa663abc 100644 --- a/pkg/network/protocols/core/protocol.go +++ b/pkg/network/protocols/core/protocol.go @@ -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) } } diff --git a/tools/docker-network/run.sh b/tools/docker-network/run.sh index 323a6bdbb..87697914f 100755 --- a/tools/docker-network/run.sh +++ b/tools/docker-network/run.sh @@ -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 .