mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Use Custom SSZ for P2P Types (#7436)
* checkpoint progress * add roundtrip tests * change all * remove error response * clean up * Update beacon-chain/sync/error_test.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * gaz * fix tests * fmt * gaz * change back * fix again * clean up * deep source * fix all tests * add gaz * fix tests Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
@@ -44,6 +44,7 @@ go_library(
|
||||
"//beacon-chain/p2p/peers:go_default_library",
|
||||
"//beacon-chain/p2p/peers/peerdata:go_default_library",
|
||||
"//beacon-chain/p2p/peers/scorers:go_default_library",
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared:go_default_library",
|
||||
"//shared/featureconfig:go_default_library",
|
||||
@@ -118,6 +119,7 @@ go_test(
|
||||
"//beacon-chain/p2p/peers:go_default_library",
|
||||
"//beacon-chain/p2p/peers/scorers:go_default_library",
|
||||
"//beacon-chain/p2p/testing:go_default_library",
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/testing:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
|
||||
@@ -46,8 +46,10 @@ func TestService_Broadcast(t *testing.T) {
|
||||
genesisValidatorsRoot: bytesutil.PadTo([]byte{'A'}, 32),
|
||||
}
|
||||
|
||||
msg := &testpb.TestSimpleMessage{
|
||||
Bar: 55,
|
||||
msg := &pb.Fork{
|
||||
Epoch: 55,
|
||||
CurrentVersion: []byte("fooo"),
|
||||
PreviousVersion: []byte("barr"),
|
||||
}
|
||||
|
||||
topic := "/eth2/%x/testing"
|
||||
@@ -75,7 +77,7 @@ func TestService_Broadcast(t *testing.T) {
|
||||
incomingMessage, err := sub.Next(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
result := &testpb.TestSimpleMessage{}
|
||||
result := &pb.Fork{}
|
||||
require.NoError(t, p.Encoding().DecodeGossip(incomingMessage.Data, result))
|
||||
if !proto.Equal(result, msg) {
|
||||
tt.Errorf("Did not receive expected message, got %+v, wanted %+v", result, msg)
|
||||
|
||||
@@ -20,7 +20,6 @@ go_library(
|
||||
"@com_github_gogo_protobuf//proto:go_default_library",
|
||||
"@com_github_golang_snappy//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -34,7 +33,6 @@ go_test(
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/testing:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil:go_default_library",
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/golang/snappy"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/go-ssz"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
@@ -35,7 +34,7 @@ func (e SszNetworkEncoder) doEncode(msg interface{}) ([]byte, error) {
|
||||
if v, ok := msg.(fastssz.Marshaler); ok {
|
||||
return v.MarshalSSZ()
|
||||
}
|
||||
return ssz.Marshal(msg)
|
||||
return nil, errors.Errorf("non-supported type: %T", msg)
|
||||
}
|
||||
|
||||
// EncodeGossip the proto gossip message to the io.Writer.
|
||||
@@ -83,7 +82,7 @@ func (e SszNetworkEncoder) doDecode(b []byte, to interface{}) error {
|
||||
if v, ok := to.(fastssz.Unmarshaler); ok {
|
||||
return v.UnmarshalSSZ(b)
|
||||
}
|
||||
return ssz.Unmarshal(b, to)
|
||||
return errors.Errorf("non-supported type: %T", to)
|
||||
}
|
||||
|
||||
// DecodeGossip decodes the bytes to the protobuf gossip message provided.
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
testpb "github.com/prysmaticlabs/prysm/proto/testing"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -26,7 +25,7 @@ func TestSszNetworkEncoder_RoundTrip(t *testing.T) {
|
||||
|
||||
func TestSszNetworkEncoder_FailsSnappyLength(t *testing.T) {
|
||||
e := &encoder.SszNetworkEncoder{}
|
||||
att := &testpb.TestSimpleMessage{}
|
||||
att := &pb.Fork{}
|
||||
data := make([]byte, 32)
|
||||
binary.PutUvarint(data, encoder.MaxGossipSize+32)
|
||||
err := e.DecodeGossip(data, att)
|
||||
@@ -35,13 +34,14 @@ func TestSszNetworkEncoder_FailsSnappyLength(t *testing.T) {
|
||||
|
||||
func testRoundTripWithLength(t *testing.T, e *encoder.SszNetworkEncoder) {
|
||||
buf := new(bytes.Buffer)
|
||||
msg := &testpb.TestSimpleMessage{
|
||||
Foo: []byte("fooooo"),
|
||||
Bar: 9001,
|
||||
msg := &pb.Fork{
|
||||
PreviousVersion: []byte("fooo"),
|
||||
CurrentVersion: []byte("barr"),
|
||||
Epoch: 9001,
|
||||
}
|
||||
_, err := e.EncodeWithMaxLength(buf, msg)
|
||||
require.NoError(t, err)
|
||||
decoded := &testpb.TestSimpleMessage{}
|
||||
decoded := &pb.Fork{}
|
||||
require.NoError(t, e.DecodeWithMaxLength(buf, decoded))
|
||||
if !proto.Equal(decoded, msg) {
|
||||
t.Logf("decoded=%+v\n", decoded)
|
||||
@@ -51,13 +51,14 @@ func testRoundTripWithLength(t *testing.T, e *encoder.SszNetworkEncoder) {
|
||||
|
||||
func testRoundTripWithGossip(t *testing.T, e *encoder.SszNetworkEncoder) {
|
||||
buf := new(bytes.Buffer)
|
||||
msg := &testpb.TestSimpleMessage{
|
||||
Foo: []byte("fooooo"),
|
||||
Bar: 9001,
|
||||
msg := &pb.Fork{
|
||||
PreviousVersion: []byte("fooo"),
|
||||
CurrentVersion: []byte("barr"),
|
||||
Epoch: 9001,
|
||||
}
|
||||
_, err := e.EncodeGossip(buf, msg)
|
||||
require.NoError(t, err)
|
||||
decoded := &testpb.TestSimpleMessage{}
|
||||
decoded := &pb.Fork{}
|
||||
require.NoError(t, e.DecodeGossip(buf.Bytes(), decoded))
|
||||
if !proto.Equal(decoded, msg) {
|
||||
t.Logf("decoded=%+v\n", decoded)
|
||||
@@ -67,9 +68,10 @@ func testRoundTripWithGossip(t *testing.T, e *encoder.SszNetworkEncoder) {
|
||||
|
||||
func TestSszNetworkEncoder_EncodeWithMaxLength(t *testing.T) {
|
||||
buf := new(bytes.Buffer)
|
||||
msg := &testpb.TestSimpleMessage{
|
||||
Foo: []byte("fooooo"),
|
||||
Bar: 9001,
|
||||
msg := &pb.Fork{
|
||||
PreviousVersion: []byte("fooo"),
|
||||
CurrentVersion: []byte("barr"),
|
||||
Epoch: 9001,
|
||||
}
|
||||
e := &encoder.SszNetworkEncoder{}
|
||||
params.SetupTestConfigCleanup(t)
|
||||
@@ -83,9 +85,10 @@ func TestSszNetworkEncoder_EncodeWithMaxLength(t *testing.T) {
|
||||
|
||||
func TestSszNetworkEncoder_DecodeWithMaxLength(t *testing.T) {
|
||||
buf := new(bytes.Buffer)
|
||||
msg := &testpb.TestSimpleMessage{
|
||||
Foo: []byte("fooooo"),
|
||||
Bar: 4242,
|
||||
msg := &pb.Fork{
|
||||
PreviousVersion: []byte("fooo"),
|
||||
CurrentVersion: []byte("barr"),
|
||||
Epoch: 4242,
|
||||
}
|
||||
e := &encoder.SszNetworkEncoder{}
|
||||
params.SetupTestConfigCleanup(t)
|
||||
@@ -95,7 +98,7 @@ func TestSszNetworkEncoder_DecodeWithMaxLength(t *testing.T) {
|
||||
params.OverrideBeaconNetworkConfig(c)
|
||||
_, err := e.EncodeGossip(buf, msg)
|
||||
require.NoError(t, err)
|
||||
decoded := &testpb.TestSimpleMessage{}
|
||||
decoded := &pb.Fork{}
|
||||
err = e.DecodeWithMaxLength(buf, decoded)
|
||||
wanted := fmt.Sprintf("goes over the provided max limit of %d", maxChunkSize)
|
||||
assert.ErrorContains(t, wanted, err)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
)
|
||||
|
||||
@@ -28,10 +29,10 @@ const (
|
||||
// RPCTopicMappings map the base message type to the rpc request.
|
||||
var RPCTopicMappings = map[string]interface{}{
|
||||
RPCStatusTopic: new(pb.Status),
|
||||
RPCGoodByeTopic: new(uint64),
|
||||
RPCGoodByeTopic: new(types.SSZUint64),
|
||||
RPCBlocksByRangeTopic: new(pb.BeaconBlocksByRangeRequest),
|
||||
RPCBlocksByRootTopic: [][32]byte{},
|
||||
RPCPingTopic: new(uint64),
|
||||
RPCBlocksByRootTopic: new(types.BeaconBlockByRootsReq),
|
||||
RPCPingTopic: new(types.SSZUint64),
|
||||
RPCMetaDataTopic: new(interface{}),
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package p2p
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
)
|
||||
@@ -14,5 +15,5 @@ func TestVerifyRPCMappings(t *testing.T) {
|
||||
assert.NoError(t, VerifyTopicMapping(RPCMetaDataTopic, new(interface{})), "Failed to verify metadata rpc topic")
|
||||
assert.NotNil(t, VerifyTopicMapping(RPCStatusTopic, new([]byte)), "Incorrect message type verified for metadata rpc topic")
|
||||
|
||||
assert.NoError(t, VerifyTopicMapping(RPCBlocksByRootTopic, [][32]byte{}), "Failed to verify blocks by root rpc topic")
|
||||
assert.NoError(t, VerifyTopicMapping(RPCBlocksByRootTopic, new(types.BeaconBlockByRootsReq)), "Failed to verify blocks by root rpc topic")
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
testp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
testpb "github.com/prysmaticlabs/prysm/proto/testing"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -25,21 +26,22 @@ func TestService_Send(t *testing.T) {
|
||||
cfg: &Config{},
|
||||
}
|
||||
|
||||
msg := &testpb.TestSimpleMessage{
|
||||
Foo: []byte("hello"),
|
||||
Bar: 55,
|
||||
msg := &pb.Fork{
|
||||
CurrentVersion: []byte("fooo"),
|
||||
PreviousVersion: []byte("barr"),
|
||||
Epoch: 55,
|
||||
}
|
||||
|
||||
// Register external listener which will repeat the message back.
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
topic := "/testing/1"
|
||||
RPCTopicMappings[topic] = new(testpb.TestSimpleMessage)
|
||||
RPCTopicMappings[topic] = new(pb.Fork)
|
||||
defer func() {
|
||||
delete(RPCTopicMappings, topic)
|
||||
}()
|
||||
p2.SetStreamHandler(topic+"/ssz_snappy", func(stream network.Stream) {
|
||||
rcvd := &testpb.TestSimpleMessage{}
|
||||
rcvd := &pb.Fork{}
|
||||
require.NoError(t, svc.Encoding().DecodeWithMaxLength(stream, rcvd))
|
||||
_, err := svc.Encoding().EncodeWithMaxLength(stream, rcvd)
|
||||
require.NoError(t, err)
|
||||
@@ -52,7 +54,7 @@ func TestService_Send(t *testing.T) {
|
||||
|
||||
testutil.WaitTimeout(&wg, 1*time.Second)
|
||||
|
||||
rcvd := &testpb.TestSimpleMessage{}
|
||||
rcvd := &pb.Fork{}
|
||||
require.NoError(t, svc.Encoding().DecodeWithMaxLength(stream, rcvd))
|
||||
if !proto.Equal(rcvd, msg) {
|
||||
t.Errorf("Expected identical message to be received. got %v want %v", rcvd, msg)
|
||||
|
||||
25
beacon-chain/p2p/types/BUILD.bazel
Normal file
25
beacon-chain/p2p/types/BUILD.bazel
Normal file
@@ -0,0 +1,25 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_test")
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["types.go"],
|
||||
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types",
|
||||
visibility = ["//beacon-chain:__subpackages__"],
|
||||
deps = [
|
||||
"//shared/params:go_default_library",
|
||||
"@com_github_ferranbt_fastssz//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["types_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
"//shared/testutil/require:go_default_library",
|
||||
],
|
||||
)
|
||||
139
beacon-chain/p2p/types/types.go
Normal file
139
beacon-chain/p2p/types/types.go
Normal file
@@ -0,0 +1,139 @@
|
||||
// Package types contains all the respective p2p types that are required for sync
|
||||
// but cannot be represented as a protobuf schema. This package also contains those
|
||||
// types associated fast ssz methods.
|
||||
package types
|
||||
|
||||
import (
|
||||
ssz "github.com/ferranbt/fastssz"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
// SSZUint64 is a uint64 type that satisfies the fast-ssz interface.
|
||||
type SSZUint64 uint64
|
||||
|
||||
const rootLength = 32
|
||||
|
||||
const maxErrorLength = 256
|
||||
|
||||
// MarshalSSZTo marshals the uint64 with the provided byte slice.
|
||||
func (s *SSZUint64) MarshalSSZTo(dst []byte) ([]byte, error) {
|
||||
marshalledObj, err := s.MarshalSSZ()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return append(dst, marshalledObj...), nil
|
||||
}
|
||||
|
||||
// MarshalSSZ Marshals the uint64 type into the serialized object.
|
||||
func (s *SSZUint64) MarshalSSZ() ([]byte, error) {
|
||||
marshalledObj := ssz.MarshalUint64([]byte{}, uint64(*s))
|
||||
return marshalledObj, nil
|
||||
}
|
||||
|
||||
// SizeSSZ returns the size of the serialized representation.
|
||||
func (s *SSZUint64) SizeSSZ() int {
|
||||
return 8
|
||||
}
|
||||
|
||||
// UnmarshalSSZ unmarshals the provided bytes buffer into the
|
||||
// uint64 object.
|
||||
func (s *SSZUint64) UnmarshalSSZ(buf []byte) error {
|
||||
if len(buf) != s.SizeSSZ() {
|
||||
return errors.Errorf("expected buffer with length of %d but received length %d", s.SizeSSZ(), len(buf))
|
||||
}
|
||||
*s = SSZUint64(ssz.UnmarshallUint64(buf))
|
||||
return nil
|
||||
}
|
||||
|
||||
// BeaconBlockByRootsReq specifies the block by roots request type.
|
||||
type BeaconBlockByRootsReq [][rootLength]byte
|
||||
|
||||
// MarshalSSZTo marshals the block by roots request with the provided byte slice.
|
||||
func (s *BeaconBlockByRootsReq) MarshalSSZTo(dst []byte) ([]byte, error) {
|
||||
marshalledObj, err := s.MarshalSSZ()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return append(dst, marshalledObj...), nil
|
||||
}
|
||||
|
||||
// MarshalSSZ Marshals the block by roots request type into the serialized object.
|
||||
func (s *BeaconBlockByRootsReq) MarshalSSZ() ([]byte, error) {
|
||||
if len(*s) > int(params.BeaconNetworkConfig().MaxRequestBlocks) {
|
||||
return nil, errors.Errorf("beacon block by roots request exceeds max size: %d > %d", len(*s), params.BeaconNetworkConfig().MaxRequestBlocks)
|
||||
}
|
||||
buf := make([]byte, 0, s.SizeSSZ())
|
||||
for _, r := range *s {
|
||||
buf = append(buf, r[:]...)
|
||||
}
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
// SizeSSZ returns the size of the serialized representation.
|
||||
func (s *BeaconBlockByRootsReq) SizeSSZ() int {
|
||||
return len(*s) * rootLength
|
||||
}
|
||||
|
||||
// UnmarshalSSZ unmarshals the provided bytes buffer into the
|
||||
// block by roots request object.
|
||||
func (s *BeaconBlockByRootsReq) UnmarshalSSZ(buf []byte) error {
|
||||
bufLen := len(buf)
|
||||
maxLength := int(params.BeaconNetworkConfig().MaxRequestBlocks * rootLength)
|
||||
if bufLen > maxLength {
|
||||
return errors.Errorf("expected buffer with length of upto %d but received length %d", maxLength, bufLen)
|
||||
}
|
||||
if bufLen%rootLength != 0 {
|
||||
return ssz.ErrIncorrectByteSize
|
||||
}
|
||||
numOfRoots := bufLen / rootLength
|
||||
roots := make([][rootLength]byte, 0, numOfRoots)
|
||||
for i := 0; i < numOfRoots; i++ {
|
||||
var rt [rootLength]byte
|
||||
copy(rt[:], buf[i*rootLength:(i+1)*rootLength])
|
||||
roots = append(roots, rt)
|
||||
}
|
||||
*s = roots
|
||||
return nil
|
||||
}
|
||||
|
||||
// ErrorMessage describes the error message type.
|
||||
type ErrorMessage []byte
|
||||
|
||||
// MarshalSSZTo marshals the error message with the provided byte slice.
|
||||
func (s *ErrorMessage) MarshalSSZTo(dst []byte) ([]byte, error) {
|
||||
marshalledObj, err := s.MarshalSSZ()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return append(dst, marshalledObj...), nil
|
||||
}
|
||||
|
||||
// MarshalSSZ Marshals the error message into the serialized object.
|
||||
func (s *ErrorMessage) MarshalSSZ() ([]byte, error) {
|
||||
if len(*s) > maxErrorLength {
|
||||
return nil, errors.Errorf("error message exceeds max size: %d > %d", len(*s), maxErrorLength)
|
||||
}
|
||||
buf := make([]byte, s.SizeSSZ())
|
||||
copy(buf, *s)
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
// SizeSSZ returns the size of the serialized representation.
|
||||
func (s *ErrorMessage) SizeSSZ() int {
|
||||
return len(*s)
|
||||
}
|
||||
|
||||
// UnmarshalSSZ unmarshals the provided bytes buffer into the
|
||||
// error message object.
|
||||
func (s *ErrorMessage) UnmarshalSSZ(buf []byte) error {
|
||||
bufLen := len(buf)
|
||||
maxLength := maxErrorLength
|
||||
if bufLen > maxLength {
|
||||
return errors.Errorf("expected buffer with length of upto %d but received length %d", maxLength, bufLen)
|
||||
}
|
||||
errMsg := make([]byte, bufLen)
|
||||
copy(errMsg, buf)
|
||||
*s = errMsg
|
||||
return nil
|
||||
}
|
||||
91
beacon-chain/p2p/types/types_test.go
Normal file
91
beacon-chain/p2p/types/types_test.go
Normal file
@@ -0,0 +1,91 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
|
||||
func TestSSZUint64_Limit(t *testing.T) {
|
||||
sszType := SSZUint64(0)
|
||||
serializedObj := [7]byte{}
|
||||
require.ErrorContains(t, "expected buffer with length", sszType.UnmarshalSSZ(serializedObj[:]))
|
||||
}
|
||||
|
||||
func TestBeaconBlockByRootsReq_Limit(t *testing.T) {
|
||||
fixedRoots := make([][32]byte, 0)
|
||||
for i := uint64(0); i < params.BeaconNetworkConfig().MaxRequestBlocks+100; i++ {
|
||||
fixedRoots = append(fixedRoots, [32]byte{byte(i)})
|
||||
}
|
||||
req := BeaconBlockByRootsReq(fixedRoots)
|
||||
|
||||
_, err := req.MarshalSSZ()
|
||||
require.ErrorContains(t, "beacon block by roots request exceeds max size", err)
|
||||
|
||||
buf := make([]byte, 0)
|
||||
for _, rt := range fixedRoots {
|
||||
buf = append(buf, rt[:]...)
|
||||
}
|
||||
req2 := BeaconBlockByRootsReq(nil)
|
||||
require.ErrorContains(t, "expected buffer with length of upto", req2.UnmarshalSSZ(buf))
|
||||
}
|
||||
|
||||
func TestErrorResponse_Limit(t *testing.T) {
|
||||
errorMessage := make([]byte, 0)
|
||||
// Provide a message of size 6400 bytes.
|
||||
for i := uint64(0); i < 200; i++ {
|
||||
byteArr := [32]byte{byte(i)}
|
||||
errorMessage = append(errorMessage, byteArr[:]...)
|
||||
}
|
||||
errMsg := ErrorMessage{}
|
||||
require.ErrorContains(t, "expected buffer with length of upto", errMsg.UnmarshalSSZ(errorMessage))
|
||||
}
|
||||
|
||||
func TestRoundTripSerialization(t *testing.T) {
|
||||
roundTripTestSSZUint64(t)
|
||||
roundTripTestBlocksByRootReq(t)
|
||||
roundTripTestErrorMessage(t)
|
||||
}
|
||||
|
||||
func roundTripTestSSZUint64(t *testing.T) {
|
||||
fixedVal := uint64(8)
|
||||
sszVal := SSZUint64(fixedVal)
|
||||
|
||||
marshalledObj, err := sszVal.MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
newVal := SSZUint64(0)
|
||||
|
||||
err = newVal.UnmarshalSSZ(marshalledObj)
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, fixedVal, uint64(newVal))
|
||||
}
|
||||
|
||||
func roundTripTestBlocksByRootReq(t *testing.T) {
|
||||
fixedRoots := make([][32]byte, 0)
|
||||
for i := 0; i < 200; i++ {
|
||||
fixedRoots = append(fixedRoots, [32]byte{byte(i)})
|
||||
}
|
||||
req := BeaconBlockByRootsReq(fixedRoots)
|
||||
|
||||
marshalledObj, err := req.MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
newVal := BeaconBlockByRootsReq(nil)
|
||||
|
||||
require.NoError(t, newVal.UnmarshalSSZ(marshalledObj))
|
||||
assert.DeepEqual(t, [][32]byte(newVal), fixedRoots)
|
||||
}
|
||||
|
||||
func roundTripTestErrorMessage(t *testing.T) {
|
||||
errMsg := []byte{'e', 'r', 'r', 'o', 'r'}
|
||||
sszErr := make(ErrorMessage, len(errMsg))
|
||||
copy(sszErr, errMsg)
|
||||
|
||||
marshalledObj, err := sszErr.MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
newVal := ErrorMessage(nil)
|
||||
|
||||
require.NoError(t, newVal.UnmarshalSSZ(marshalledObj))
|
||||
assert.DeepEqual(t, []byte(newVal), errMsg)
|
||||
}
|
||||
@@ -61,6 +61,7 @@ go_library(
|
||||
"//beacon-chain/p2p:go_default_library",
|
||||
"//beacon-chain/p2p/encoder:go_default_library",
|
||||
"//beacon-chain/p2p/peers:go_default_library",
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
@@ -144,11 +145,11 @@ go_test(
|
||||
"//beacon-chain/p2p/encoder:go_default_library",
|
||||
"//beacon-chain/p2p/peers:go_default_library",
|
||||
"//beacon-chain/p2p/testing:go_default_library",
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//beacon-chain/sync/initial-sync/testing:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/testing:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
"//shared/bls:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
@@ -53,14 +53,12 @@ func ReadStatusCode(stream network.Stream, encoding encoder.NetworkEncoding) (ui
|
||||
|
||||
// Set response deadline, when reading error message.
|
||||
SetStreamReadDeadline(stream, params.BeaconNetworkConfig().RespTimeout)
|
||||
msg := &pb.ErrorResponse{
|
||||
Message: []byte{},
|
||||
}
|
||||
msg := &types.ErrorMessage{}
|
||||
if err := encoding.DecodeWithMaxLength(stream, msg); err != nil {
|
||||
return 0, "", err
|
||||
}
|
||||
|
||||
return b[0], string(msg.Message), nil
|
||||
return b[0], string(*msg), nil
|
||||
}
|
||||
|
||||
func writeErrorResponseToStream(responseCode byte, reason string, stream libp2pcore.Stream, encoder p2p.EncodingProvider) {
|
||||
@@ -74,10 +72,8 @@ func writeErrorResponseToStream(responseCode byte, reason string, stream libp2pc
|
||||
|
||||
func createErrorResponse(code byte, reason string, encoder p2p.EncodingProvider) ([]byte, error) {
|
||||
buf := bytes.NewBuffer([]byte{code})
|
||||
resp := &pb.ErrorResponse{
|
||||
Message: []byte(reason),
|
||||
}
|
||||
if _, err := encoder.Encoding().EncodeWithMaxLength(buf, resp); err != nil {
|
||||
errMsg := types.ErrorMessage(reason)
|
||||
if _, err := encoder.Encoding().EncodeWithMaxLength(buf, &errMsg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -96,14 +92,12 @@ func readStatusCodeNoDeadline(stream network.Stream, encoding encoder.NetworkEnc
|
||||
return 0, "", nil
|
||||
}
|
||||
|
||||
msg := &pb.ErrorResponse{
|
||||
Message: []byte{},
|
||||
}
|
||||
msg := &types.ErrorMessage{}
|
||||
if err := encoding.DecodeWithMaxLength(stream, msg); err != nil {
|
||||
return 0, "", err
|
||||
}
|
||||
|
||||
return b[0], string(msg.Message), nil
|
||||
return b[0], string(*msg), nil
|
||||
}
|
||||
|
||||
// only returns true for errors that are valid (no resets or expectedEOF errors).
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
@@ -22,7 +22,7 @@ func TestRegularSync_generateErrorResponse(t *testing.T) {
|
||||
_, err = buf.Read(b)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, responseCodeServerError, b[0], "The first byte was not the status code")
|
||||
msg := &pb.ErrorResponse{}
|
||||
msg := &types.ErrorMessage{}
|
||||
require.NoError(t, r.p2p.Encoding().DecodeWithMaxLength(buf, msg))
|
||||
assert.Equal(t, "something bad happened", string(msg.Message), "Received the wrong message")
|
||||
assert.Equal(t, "something bad happened", string(*msg), "Received the wrong message")
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ go_test(
|
||||
"//beacon-chain/p2p:go_default_library",
|
||||
"//beacon-chain/p2p/peers:go_default_library",
|
||||
"//beacon-chain/p2p/testing:go_default_library",
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateutil:go_default_library",
|
||||
"//beacon-chain/sync:go_default_library",
|
||||
@@ -115,6 +116,7 @@ go_test(
|
||||
"//beacon-chain/p2p/peers:go_default_library",
|
||||
"//beacon-chain/p2p/peers/scorers:go_default_library",
|
||||
"//beacon-chain/p2p/testing:go_default_library",
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//beacon-chain/sync:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/flags"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
||||
p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
||||
p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@@ -182,7 +183,8 @@ func connectPeer(t *testing.T, host *p2pt.TestP2P, datum *peerData, peerStatus *
|
||||
if len(sliceutil.IntersectionUint64(datum.failureSlots, requestedBlocks)) > 0 {
|
||||
_, err := stream.Write([]byte{0x01})
|
||||
assert.NoError(t, err)
|
||||
_, err = p.Encoding().EncodeWithMaxLength(stream, "bad")
|
||||
msg := types.ErrorMessage("bad")
|
||||
_, err = p.Encoding().EncodeWithMaxLength(stream, &msg)
|
||||
assert.NoError(t, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"github.com/prysmaticlabs/go-ssz"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/go-ssz"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/rand"
|
||||
@@ -168,11 +168,11 @@ func (s *Service) sendBatchRootRequest(ctx context.Context, roots [][32]byte, ra
|
||||
// all the requested blocks, we randomly select another peer.
|
||||
pid := bestPeers[randGen.Int()%len(bestPeers)]
|
||||
for i := 0; i < numOfTries; i++ {
|
||||
req := roots
|
||||
req := types.BeaconBlockByRootsReq(roots)
|
||||
if len(roots) > int(params.BeaconNetworkConfig().MaxRequestBlocks) {
|
||||
req = roots[:params.BeaconNetworkConfig().MaxRequestBlocks]
|
||||
}
|
||||
if err := s.sendRecentBeaconBlocksRequest(ctx, req, pid); err != nil {
|
||||
if err := s.sendRecentBeaconBlocksRequest(ctx, &req, pid); err != nil {
|
||||
traceutil.AnnotateError(span, err)
|
||||
log.Debugf("Could not send recent block request: %v", err)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
dbtest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
||||
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/rand"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -371,15 +372,15 @@ func TestService_BatchRootRequest(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Send in duplicated roots to also test deduplicaton.
|
||||
sentRoots := [][32]byte{b2Root, b2Root, b3Root, b3Root, b4Root, b5Root}
|
||||
expectedRoots := [][32]byte{b2Root, b3Root, b4Root, b5Root}
|
||||
sentRoots := p2pTypes.BeaconBlockByRootsReq{b2Root, b2Root, b3Root, b3Root, b4Root, b5Root}
|
||||
expectedRoots := p2pTypes.BeaconBlockByRootsReq{b2Root, b3Root, b4Root, b5Root}
|
||||
|
||||
pcl := protocol.ID("/eth2/beacon_chain/req/beacon_blocks_by_root/1/ssz_snappy")
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
defer wg.Done()
|
||||
var out [][32]byte
|
||||
var out p2pTypes.BeaconBlockByRootsReq
|
||||
assert.NoError(t, p2.Encoding().DecodeWithMaxLength(stream, &out))
|
||||
assert.DeepEqual(t, expectedRoots, out, "Did not receive expected message")
|
||||
response := []*ethpb.SignedBeaconBlock{b2, b3, b4, b5}
|
||||
|
||||
@@ -9,12 +9,13 @@ import (
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
// sendRecentBeaconBlocksRequest sends a recent beacon blocks request to a peer to get
|
||||
// those corresponding blocks from that peer.
|
||||
func (s *Service) sendRecentBeaconBlocksRequest(ctx context.Context, blockRoots [][32]byte, id peer.ID) error {
|
||||
func (s *Service) sendRecentBeaconBlocksRequest(ctx context.Context, blockRoots *types.BeaconBlockByRootsReq, id peer.ID) error {
|
||||
ctx, cancel := context.WithTimeout(ctx, respTimeout)
|
||||
defer cancel()
|
||||
|
||||
@@ -27,7 +28,7 @@ func (s *Service) sendRecentBeaconBlocksRequest(ctx context.Context, blockRoots
|
||||
log.WithError(err).Debugf("Failed to reset stream with protocol %s", stream.Protocol())
|
||||
}
|
||||
}()
|
||||
for i := 0; i < len(blockRoots); i++ {
|
||||
for i := 0; i < len(*blockRoots); i++ {
|
||||
isFirstChunk := i == 0
|
||||
blk, err := ReadChunkedBlock(stream, s.p2p, isFirstChunk)
|
||||
if err == io.EOF {
|
||||
@@ -66,10 +67,11 @@ func (s *Service) beaconBlocksRootRPCHandler(ctx context.Context, msg interface{
|
||||
SetRPCStreamDeadlines(stream)
|
||||
log := log.WithField("handler", "beacon_blocks_by_root")
|
||||
|
||||
blockRoots, ok := msg.([][32]byte)
|
||||
rawMsg, ok := msg.(*types.BeaconBlockByRootsReq)
|
||||
if !ok {
|
||||
return errors.New("message is not type [][32]byte")
|
||||
return errors.New("message is not type BeaconBlockByRootsReq")
|
||||
}
|
||||
blockRoots := *rawMsg
|
||||
if err := s.rateLimiter.validateRequest(stream, uint64(len(blockRoots))); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
db "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -32,7 +33,7 @@ func TestRecentBeaconBlocksRPCHandler_ReturnsBlocks(t *testing.T) {
|
||||
assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected")
|
||||
d, _ := db.SetupDB(t)
|
||||
|
||||
var blkRoots [][32]byte
|
||||
var blkRoots p2pTypes.BeaconBlockByRootsReq
|
||||
// Populate the database with blocks that would match the request.
|
||||
for i := 1; i < 11; i++ {
|
||||
blk := testutil.NewBeaconBlock()
|
||||
@@ -55,7 +56,7 @@ func TestRecentBeaconBlocksRPCHandler_ReturnsBlocks(t *testing.T) {
|
||||
for i := range blkRoots {
|
||||
expectSuccess(t, stream)
|
||||
res := testutil.NewBeaconBlock()
|
||||
assert.NoError(t, r.p2p.Encoding().DecodeWithMaxLength(stream, &res))
|
||||
assert.NoError(t, r.p2p.Encoding().DecodeWithMaxLength(stream, res))
|
||||
if res.Block.Slot != uint64(i+1) {
|
||||
t.Errorf("Received unexpected block slot %d but wanted %d", res.Block.Slot, i+1)
|
||||
}
|
||||
@@ -64,7 +65,7 @@ func TestRecentBeaconBlocksRPCHandler_ReturnsBlocks(t *testing.T) {
|
||||
|
||||
stream1, err := p1.BHost.NewStream(context.Background(), p2.BHost.ID(), pcl)
|
||||
require.NoError(t, err)
|
||||
err = r.beaconBlocksRootRPCHandler(context.Background(), blkRoots, stream1)
|
||||
err = r.beaconBlocksRootRPCHandler(context.Background(), &blkRoots, stream1)
|
||||
assert.NoError(t, err)
|
||||
|
||||
if testutil.WaitTimeout(&wg, 1*time.Second) {
|
||||
@@ -95,7 +96,7 @@ func TestRecentBeaconBlocks_RPCRequestSent(t *testing.T) {
|
||||
Root: blockBRoot[:],
|
||||
}
|
||||
|
||||
expectedRoots := [][32]byte{blockBRoot, blockARoot}
|
||||
expectedRoots := p2pTypes.BeaconBlockByRootsReq{blockBRoot, blockARoot}
|
||||
|
||||
r := &Service{
|
||||
p2p: p1,
|
||||
@@ -119,9 +120,9 @@ func TestRecentBeaconBlocks_RPCRequestSent(t *testing.T) {
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
defer wg.Done()
|
||||
var out [][32]byte
|
||||
assert.NoError(t, p2.Encoding().DecodeWithMaxLength(stream, &out))
|
||||
assert.DeepEqual(t, expectedRoots, out, "Did not receive expected message")
|
||||
out := new(p2pTypes.BeaconBlockByRootsReq)
|
||||
assert.NoError(t, p2.Encoding().DecodeWithMaxLength(stream, out))
|
||||
assert.DeepEqual(t, &expectedRoots, out, "Did not receive expected message")
|
||||
response := []*ethpb.SignedBeaconBlock{blockB, blockA}
|
||||
for _, blk := range response {
|
||||
_, err := stream.Write([]byte{responseCodeSuccess})
|
||||
@@ -133,7 +134,7 @@ func TestRecentBeaconBlocks_RPCRequestSent(t *testing.T) {
|
||||
})
|
||||
|
||||
p1.Connect(p2)
|
||||
require.NoError(t, r.sendRecentBeaconBlocksRequest(context.Background(), expectedRoots, p2.PeerID()))
|
||||
require.NoError(t, r.sendRecentBeaconBlocksRequest(context.Background(), &expectedRoots, p2.PeerID()))
|
||||
|
||||
if testutil.WaitTimeout(&wg, 1*time.Second) {
|
||||
t.Fatal("Did not receive stream within 1 sec")
|
||||
@@ -161,7 +162,7 @@ func TestRecentBeaconBlocksRPCHandler_HandleZeroBlocks(t *testing.T) {
|
||||
|
||||
stream1, err := p1.BHost.NewStream(context.Background(), p2.BHost.ID(), pcl)
|
||||
require.NoError(t, err)
|
||||
err = r.beaconBlocksRootRPCHandler(context.Background(), [][32]byte{}, stream1)
|
||||
err = r.beaconBlocksRootRPCHandler(context.Background(), &p2pTypes.BeaconBlockByRootsReq{}, stream1)
|
||||
assert.ErrorContains(t, "no block roots provided", err)
|
||||
if testutil.WaitTimeout(&wg, 1*time.Second) {
|
||||
t.Fatal("Did not receive stream within 1 sec")
|
||||
|
||||
@@ -10,16 +10,17 @@ import (
|
||||
"github.com/libp2p/go-libp2p-core/mux"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
codeClientShutdown uint64 = iota
|
||||
codeClientShutdown types.SSZUint64 = iota
|
||||
codeWrongNetwork
|
||||
codeGenericError
|
||||
)
|
||||
|
||||
var goodByes = map[uint64]string{
|
||||
var goodByes = map[types.SSZUint64]string{
|
||||
codeClientShutdown: "client shutdown",
|
||||
codeWrongNetwork: "irrelevant network",
|
||||
codeGenericError: "fault/error",
|
||||
@@ -38,7 +39,7 @@ func (s *Service) goodbyeRPCHandler(_ context.Context, msg interface{}, stream l
|
||||
}()
|
||||
SetRPCStreamDeadlines(stream)
|
||||
|
||||
m, ok := msg.(*uint64)
|
||||
m, ok := msg.(*types.SSZUint64)
|
||||
if !ok {
|
||||
return fmt.Errorf("wrong message type for goodbye, got %T, wanted *uint64", msg)
|
||||
}
|
||||
@@ -52,7 +53,7 @@ func (s *Service) goodbyeRPCHandler(_ context.Context, msg interface{}, stream l
|
||||
return s.p2p.Disconnect(stream.Conn().RemotePeer())
|
||||
}
|
||||
|
||||
func (s *Service) sendGoodByeAndDisconnect(ctx context.Context, code uint64, id peer.ID) error {
|
||||
func (s *Service) sendGoodByeAndDisconnect(ctx context.Context, code types.SSZUint64, id peer.ID) error {
|
||||
if err := s.sendGoodByeMessage(ctx, code, id); err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"error": err,
|
||||
@@ -62,7 +63,7 @@ func (s *Service) sendGoodByeAndDisconnect(ctx context.Context, code uint64, id
|
||||
return s.p2p.Disconnect(id)
|
||||
}
|
||||
|
||||
func (s *Service) sendGoodByeMessage(ctx context.Context, code uint64, id peer.ID) error {
|
||||
func (s *Service) sendGoodByeMessage(ctx context.Context, code types.SSZUint64, id peer.ID) error {
|
||||
ctx, cancel := context.WithTimeout(ctx, respTimeout)
|
||||
defer cancel()
|
||||
|
||||
@@ -80,7 +81,7 @@ func (s *Service) sendGoodByeMessage(ctx context.Context, code uint64, id peer.I
|
||||
return nil
|
||||
}
|
||||
|
||||
func goodbyeMessage(num uint64) string {
|
||||
func goodbyeMessage(num types.SSZUint64) string {
|
||||
reason, ok := goodByes[num]
|
||||
if ok {
|
||||
return reason
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
db "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -80,7 +80,7 @@ func TestSendGoodbye_SendsMessage(t *testing.T) {
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
defer wg.Done()
|
||||
out := new(uint64)
|
||||
out := new(p2pTypes.SSZUint64)
|
||||
assert.NoError(t, r.p2p.Encoding().DecodeWithMaxLength(stream, out))
|
||||
assert.Equal(t, failureCode, *out)
|
||||
assert.NoError(t, stream.Close())
|
||||
@@ -122,7 +122,7 @@ func TestSendGoodbye_DisconnectWithPeer(t *testing.T) {
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
defer wg.Done()
|
||||
out := new(uint64)
|
||||
out := new(p2pTypes.SSZUint64)
|
||||
assert.NoError(t, r.p2p.Encoding().DecodeWithMaxLength(stream, out))
|
||||
assert.Equal(t, failureCode, *out)
|
||||
assert.NoError(t, stream.Close())
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/libp2p/go-libp2p-core/mux"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
"github.com/prysmaticlabs/prysm/shared/timeutils"
|
||||
)
|
||||
|
||||
@@ -18,7 +19,7 @@ import (
|
||||
func (s *Service) pingHandler(_ context.Context, msg interface{}, stream libp2pcore.Stream) error {
|
||||
SetRPCStreamDeadlines(stream)
|
||||
|
||||
m, ok := msg.(*uint64)
|
||||
m, ok := msg.(*types.SSZUint64)
|
||||
if !ok {
|
||||
if err := stream.Close(); err != nil {
|
||||
log.WithError(err).Debug("Failed to close stream")
|
||||
@@ -47,7 +48,8 @@ func (s *Service) pingHandler(_ context.Context, msg interface{}, stream libp2pc
|
||||
}
|
||||
return err
|
||||
}
|
||||
if _, err := s.p2p.Encoding().EncodeWithMaxLength(stream, s.p2p.MetadataSeq()); err != nil {
|
||||
sq := types.SSZUint64(s.p2p.MetadataSeq())
|
||||
if _, err := s.p2p.Encoding().EncodeWithMaxLength(stream, &sq); err != nil {
|
||||
if err := stream.Close(); err != nil {
|
||||
log.WithError(err).Debug("Failed to close stream")
|
||||
}
|
||||
@@ -90,7 +92,7 @@ func (s *Service) sendPingRequest(ctx context.Context, id peer.ID) error {
|
||||
ctx, cancel := context.WithTimeout(ctx, respTimeout)
|
||||
defer cancel()
|
||||
|
||||
metadataSeq := s.p2p.MetadataSeq()
|
||||
metadataSeq := types.SSZUint64(s.p2p.MetadataSeq())
|
||||
stream, err := s.p2p.Send(ctx, &metadataSeq, p2p.RPCPingTopic, id)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -113,7 +115,7 @@ func (s *Service) sendPingRequest(ctx context.Context, id peer.ID) error {
|
||||
s.p2p.Peers().Scorers().BadResponsesScorer().Increment(stream.Conn().RemotePeer())
|
||||
return errors.New(errMsg)
|
||||
}
|
||||
msg := new(uint64)
|
||||
msg := new(types.SSZUint64)
|
||||
if err := s.p2p.Encoding().DecodeWithMaxLength(stream, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -139,7 +141,7 @@ func (s *Service) sendPingRequest(ctx context.Context, id peer.ID) error {
|
||||
}
|
||||
|
||||
// validates the peer's sequence number.
|
||||
func (s *Service) validateSequenceNum(seq uint64, id peer.ID) (bool, error) {
|
||||
func (s *Service) validateSequenceNum(seq types.SSZUint64, id peer.ID) (bool, error) {
|
||||
md, err := s.p2p.Peers().Metadata(id)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -148,8 +150,8 @@ func (s *Service) validateSequenceNum(seq uint64, id peer.ID) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
// Return error on invalid sequence number.
|
||||
if md.SeqNumber > seq {
|
||||
if md.SeqNumber > uint64(seq) {
|
||||
return false, errInvalidSequenceNum
|
||||
}
|
||||
return md.SeqNumber == seq, nil
|
||||
return md.SeqNumber == uint64(seq), nil
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
|
||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
db "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -54,13 +54,13 @@ func TestPingRPCHandler_ReceivesPing(t *testing.T) {
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
defer wg.Done()
|
||||
expectSuccess(t, stream)
|
||||
out := new(uint64)
|
||||
out := new(p2pTypes.SSZUint64)
|
||||
assert.NoError(t, r.p2p.Encoding().DecodeWithMaxLength(stream, out))
|
||||
assert.Equal(t, uint64(2), *out)
|
||||
assert.Equal(t, uint64(2), uint64(*out))
|
||||
})
|
||||
stream1, err := p1.BHost.NewStream(context.Background(), p2.BHost.ID(), pcl)
|
||||
require.NoError(t, err)
|
||||
seqNumber := uint64(2)
|
||||
seqNumber := p2pTypes.SSZUint64(2)
|
||||
|
||||
assert.NoError(t, r.pingHandler(context.Background(), &seqNumber, stream1))
|
||||
|
||||
@@ -117,9 +117,9 @@ func TestPingRPCHandler_SendsPing(t *testing.T) {
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
defer wg.Done()
|
||||
out := new(uint64)
|
||||
out := new(p2pTypes.SSZUint64)
|
||||
assert.NoError(t, r2.p2p.Encoding().DecodeWithMaxLength(stream, out))
|
||||
assert.Equal(t, uint64(2), *out)
|
||||
assert.Equal(t, uint64(2), uint64(*out))
|
||||
assert.NoError(t, r2.pingHandler(context.Background(), out, stream))
|
||||
})
|
||||
|
||||
@@ -180,7 +180,8 @@ func TestPingRPCHandler_BadSequenceNumber(t *testing.T) {
|
||||
stream1, err := p1.BHost.NewStream(context.Background(), p2.BHost.ID(), pcl)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.ErrorContains(t, seqError, r.pingHandler(context.Background(), &p2.LocalMetadata.SeqNumber, stream1))
|
||||
wantedSeq := p2pTypes.SSZUint64(p2.LocalMetadata.SeqNumber)
|
||||
assert.ErrorContains(t, seqError, r.pingHandler(context.Background(), &wantedSeq, stream1))
|
||||
|
||||
if testutil.WaitTimeout(&wg, 1*time.Second) {
|
||||
t.Fatal("Did not receive stream within 1 sec")
|
||||
|
||||
@@ -7,10 +7,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
|
||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
@@ -19,6 +18,7 @@ import (
|
||||
testingDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
||||
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
@@ -76,7 +76,7 @@ func TestStatusRPCHandler_Disconnects_OnForkVersionMismatch(t *testing.T) {
|
||||
wg2.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl2, func(stream network.Stream) {
|
||||
defer wg2.Done()
|
||||
msg := new(uint64)
|
||||
msg := new(p2pTypes.SSZUint64)
|
||||
assert.NoError(t, r.p2p.Encoding().DecodeWithMaxLength(stream, msg))
|
||||
assert.Equal(t, codeWrongNetwork, *msg)
|
||||
assert.NoError(t, stream.Close())
|
||||
@@ -324,9 +324,9 @@ func TestHandshakeHandlers_Roundtrip(t *testing.T) {
|
||||
wg2.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
defer wg2.Done()
|
||||
out := new(uint64)
|
||||
out := new(p2pTypes.SSZUint64)
|
||||
assert.NoError(t, r.p2p.Encoding().DecodeWithMaxLength(stream, out))
|
||||
assert.Equal(t, uint64(2), *out)
|
||||
assert.Equal(t, uint64(2), uint64(*out))
|
||||
assert.NoError(t, r2.pingHandler(context.Background(), out, stream))
|
||||
assert.NoError(t, stream.Close())
|
||||
})
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
prysmP2P "github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
|
||||
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/testing"
|
||||
p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
@@ -57,25 +57,25 @@ func TestRegisterRPC_ReceivesValidMessage(t *testing.T) {
|
||||
wg.Add(1)
|
||||
topic := "/testing/foobar/1"
|
||||
handler := func(ctx context.Context, msg interface{}, stream libp2pcore.Stream) error {
|
||||
m, ok := msg.(*pb.TestSimpleMessage)
|
||||
m, ok := msg.(*p2ppb.Fork)
|
||||
if !ok {
|
||||
t.Error("Object is not of type *pb.TestSimpleMessage")
|
||||
}
|
||||
if !bytes.Equal(m.Foo, []byte("foo")) {
|
||||
if !bytes.Equal(m.CurrentVersion, []byte("fooo")) {
|
||||
t.Errorf("Unexpected incoming message: %+v", m)
|
||||
}
|
||||
wg.Done()
|
||||
|
||||
return nil
|
||||
}
|
||||
prysmP2P.RPCTopicMappings[topic] = new(pb.TestSimpleMessage)
|
||||
prysmP2P.RPCTopicMappings[topic] = new(p2ppb.Fork)
|
||||
// Cleanup Topic mappings
|
||||
defer func() {
|
||||
delete(prysmP2P.RPCTopicMappings, topic)
|
||||
}()
|
||||
r.registerRPC(topic, handler)
|
||||
|
||||
p2p.ReceiveRPC(topic, &pb.TestSimpleMessage{Foo: []byte("foo")})
|
||||
p2p.ReceiveRPC(topic, &p2ppb.Fork{CurrentVersion: []byte("fooo"), PreviousVersion: []byte("barr")})
|
||||
|
||||
if testutil.WaitTimeout(&wg, time.Second) {
|
||||
t.Fatal("Did not receive RPC in 1 second")
|
||||
|
||||
@@ -26,8 +26,6 @@ ssz_gen_marshal(
|
||||
],
|
||||
objs = [
|
||||
"BeaconBlocksByRangeRequest",
|
||||
"BeaconBlocksByRootRequest",
|
||||
"ErrorResponse",
|
||||
"ENRForkID",
|
||||
"MetaData",
|
||||
"Fork",
|
||||
|
||||
@@ -6,6 +6,357 @@ import (
|
||||
v1alpha1 "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
)
|
||||
|
||||
// MarshalSSZ ssz marshals the Status object
|
||||
func (s *Status) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(s)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the Status object to a target array
|
||||
func (s *Status) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'ForkDigest'
|
||||
if len(s.ForkDigest) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.ForkDigest...)
|
||||
|
||||
// Field (1) 'FinalizedRoot'
|
||||
if len(s.FinalizedRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.FinalizedRoot...)
|
||||
|
||||
// Field (2) 'FinalizedEpoch'
|
||||
dst = ssz.MarshalUint64(dst, s.FinalizedEpoch)
|
||||
|
||||
// Field (3) 'HeadRoot'
|
||||
if len(s.HeadRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.HeadRoot...)
|
||||
|
||||
// Field (4) 'HeadSlot'
|
||||
dst = ssz.MarshalUint64(dst, s.HeadSlot)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the Status object
|
||||
func (s *Status) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 84 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'ForkDigest'
|
||||
if cap(s.ForkDigest) == 0 {
|
||||
s.ForkDigest = make([]byte, 0, len(buf[0:4]))
|
||||
}
|
||||
s.ForkDigest = append(s.ForkDigest, buf[0:4]...)
|
||||
|
||||
// Field (1) 'FinalizedRoot'
|
||||
if cap(s.FinalizedRoot) == 0 {
|
||||
s.FinalizedRoot = make([]byte, 0, len(buf[4:36]))
|
||||
}
|
||||
s.FinalizedRoot = append(s.FinalizedRoot, buf[4:36]...)
|
||||
|
||||
// Field (2) 'FinalizedEpoch'
|
||||
s.FinalizedEpoch = ssz.UnmarshallUint64(buf[36:44])
|
||||
|
||||
// Field (3) 'HeadRoot'
|
||||
if cap(s.HeadRoot) == 0 {
|
||||
s.HeadRoot = make([]byte, 0, len(buf[44:76]))
|
||||
}
|
||||
s.HeadRoot = append(s.HeadRoot, buf[44:76]...)
|
||||
|
||||
// Field (4) 'HeadSlot'
|
||||
s.HeadSlot = ssz.UnmarshallUint64(buf[76:84])
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the Status object
|
||||
func (s *Status) SizeSSZ() (size int) {
|
||||
size = 84
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the Status object
|
||||
func (s *Status) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(s)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the Status object with a hasher
|
||||
func (s *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'ForkDigest'
|
||||
if len(s.ForkDigest) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.ForkDigest)
|
||||
|
||||
// Field (1) 'FinalizedRoot'
|
||||
if len(s.FinalizedRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.FinalizedRoot)
|
||||
|
||||
// Field (2) 'FinalizedEpoch'
|
||||
hh.PutUint64(s.FinalizedEpoch)
|
||||
|
||||
// Field (3) 'HeadRoot'
|
||||
if len(s.HeadRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.HeadRoot)
|
||||
|
||||
// Field (4) 'HeadSlot'
|
||||
hh.PutUint64(s.HeadSlot)
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the BeaconBlocksByRangeRequest object
|
||||
func (b *BeaconBlocksByRangeRequest) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(b)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the BeaconBlocksByRangeRequest object to a target array
|
||||
func (b *BeaconBlocksByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'StartSlot'
|
||||
dst = ssz.MarshalUint64(dst, b.StartSlot)
|
||||
|
||||
// Field (1) 'Count'
|
||||
dst = ssz.MarshalUint64(dst, b.Count)
|
||||
|
||||
// Field (2) 'Step'
|
||||
dst = ssz.MarshalUint64(dst, b.Step)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the BeaconBlocksByRangeRequest object
|
||||
func (b *BeaconBlocksByRangeRequest) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 24 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'StartSlot'
|
||||
b.StartSlot = ssz.UnmarshallUint64(buf[0:8])
|
||||
|
||||
// Field (1) 'Count'
|
||||
b.Count = ssz.UnmarshallUint64(buf[8:16])
|
||||
|
||||
// Field (2) 'Step'
|
||||
b.Step = ssz.UnmarshallUint64(buf[16:24])
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlocksByRangeRequest object
|
||||
func (b *BeaconBlocksByRangeRequest) SizeSSZ() (size int) {
|
||||
size = 24
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the BeaconBlocksByRangeRequest object
|
||||
func (b *BeaconBlocksByRangeRequest) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(b)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the BeaconBlocksByRangeRequest object with a hasher
|
||||
func (b *BeaconBlocksByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'StartSlot'
|
||||
hh.PutUint64(b.StartSlot)
|
||||
|
||||
// Field (1) 'Count'
|
||||
hh.PutUint64(b.Count)
|
||||
|
||||
// Field (2) 'Step'
|
||||
hh.PutUint64(b.Step)
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the ENRForkID object
|
||||
func (e *ENRForkID) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(e)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the ENRForkID object to a target array
|
||||
func (e *ENRForkID) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'CurrentForkDigest'
|
||||
if len(e.CurrentForkDigest) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.CurrentForkDigest...)
|
||||
|
||||
// Field (1) 'NextForkVersion'
|
||||
if len(e.NextForkVersion) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.NextForkVersion...)
|
||||
|
||||
// Field (2) 'NextForkEpoch'
|
||||
dst = ssz.MarshalUint64(dst, e.NextForkEpoch)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the ENRForkID object
|
||||
func (e *ENRForkID) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 16 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'CurrentForkDigest'
|
||||
if cap(e.CurrentForkDigest) == 0 {
|
||||
e.CurrentForkDigest = make([]byte, 0, len(buf[0:4]))
|
||||
}
|
||||
e.CurrentForkDigest = append(e.CurrentForkDigest, buf[0:4]...)
|
||||
|
||||
// Field (1) 'NextForkVersion'
|
||||
if cap(e.NextForkVersion) == 0 {
|
||||
e.NextForkVersion = make([]byte, 0, len(buf[4:8]))
|
||||
}
|
||||
e.NextForkVersion = append(e.NextForkVersion, buf[4:8]...)
|
||||
|
||||
// Field (2) 'NextForkEpoch'
|
||||
e.NextForkEpoch = ssz.UnmarshallUint64(buf[8:16])
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the ENRForkID object
|
||||
func (e *ENRForkID) SizeSSZ() (size int) {
|
||||
size = 16
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the ENRForkID object
|
||||
func (e *ENRForkID) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(e)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the ENRForkID object with a hasher
|
||||
func (e *ENRForkID) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'CurrentForkDigest'
|
||||
if len(e.CurrentForkDigest) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.CurrentForkDigest)
|
||||
|
||||
// Field (1) 'NextForkVersion'
|
||||
if len(e.NextForkVersion) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.NextForkVersion)
|
||||
|
||||
// Field (2) 'NextForkEpoch'
|
||||
hh.PutUint64(e.NextForkEpoch)
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the MetaData object
|
||||
func (m *MetaData) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(m)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the MetaData object to a target array
|
||||
func (m *MetaData) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'SeqNumber'
|
||||
dst = ssz.MarshalUint64(dst, m.SeqNumber)
|
||||
|
||||
// Field (1) 'Attnets'
|
||||
if len(m.Attnets) != 8 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, m.Attnets...)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the MetaData object
|
||||
func (m *MetaData) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 16 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'SeqNumber'
|
||||
m.SeqNumber = ssz.UnmarshallUint64(buf[0:8])
|
||||
|
||||
// Field (1) 'Attnets'
|
||||
if cap(m.Attnets) == 0 {
|
||||
m.Attnets = make([]byte, 0, len(buf[8:16]))
|
||||
}
|
||||
m.Attnets = append(m.Attnets, buf[8:16]...)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the MetaData object
|
||||
func (m *MetaData) SizeSSZ() (size int) {
|
||||
size = 16
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the MetaData object
|
||||
func (m *MetaData) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(m)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the MetaData object with a hasher
|
||||
func (m *MetaData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'SeqNumber'
|
||||
hh.PutUint64(m.SeqNumber)
|
||||
|
||||
// Field (1) 'Attnets'
|
||||
if len(m.Attnets) != 8 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(m.Attnets)
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the BeaconState object
|
||||
func (b *BeaconState) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(b)
|
||||
@@ -1257,438 +1608,3 @@ func (f *ForkData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the Status object
|
||||
func (s *Status) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(s)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the Status object to a target array
|
||||
func (s *Status) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'ForkDigest'
|
||||
if len(s.ForkDigest) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.ForkDigest...)
|
||||
|
||||
// Field (1) 'FinalizedRoot'
|
||||
if len(s.FinalizedRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.FinalizedRoot...)
|
||||
|
||||
// Field (2) 'FinalizedEpoch'
|
||||
dst = ssz.MarshalUint64(dst, s.FinalizedEpoch)
|
||||
|
||||
// Field (3) 'HeadRoot'
|
||||
if len(s.HeadRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.HeadRoot...)
|
||||
|
||||
// Field (4) 'HeadSlot'
|
||||
dst = ssz.MarshalUint64(dst, s.HeadSlot)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the Status object
|
||||
func (s *Status) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 84 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'ForkDigest'
|
||||
if cap(s.ForkDigest) == 0 {
|
||||
s.ForkDigest = make([]byte, 0, len(buf[0:4]))
|
||||
}
|
||||
s.ForkDigest = append(s.ForkDigest, buf[0:4]...)
|
||||
|
||||
// Field (1) 'FinalizedRoot'
|
||||
if cap(s.FinalizedRoot) == 0 {
|
||||
s.FinalizedRoot = make([]byte, 0, len(buf[4:36]))
|
||||
}
|
||||
s.FinalizedRoot = append(s.FinalizedRoot, buf[4:36]...)
|
||||
|
||||
// Field (2) 'FinalizedEpoch'
|
||||
s.FinalizedEpoch = ssz.UnmarshallUint64(buf[36:44])
|
||||
|
||||
// Field (3) 'HeadRoot'
|
||||
if cap(s.HeadRoot) == 0 {
|
||||
s.HeadRoot = make([]byte, 0, len(buf[44:76]))
|
||||
}
|
||||
s.HeadRoot = append(s.HeadRoot, buf[44:76]...)
|
||||
|
||||
// Field (4) 'HeadSlot'
|
||||
s.HeadSlot = ssz.UnmarshallUint64(buf[76:84])
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the Status object
|
||||
func (s *Status) SizeSSZ() (size int) {
|
||||
size = 84
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the Status object
|
||||
func (s *Status) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(s)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the Status object with a hasher
|
||||
func (s *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'ForkDigest'
|
||||
if len(s.ForkDigest) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.ForkDigest)
|
||||
|
||||
// Field (1) 'FinalizedRoot'
|
||||
if len(s.FinalizedRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.FinalizedRoot)
|
||||
|
||||
// Field (2) 'FinalizedEpoch'
|
||||
hh.PutUint64(s.FinalizedEpoch)
|
||||
|
||||
// Field (3) 'HeadRoot'
|
||||
if len(s.HeadRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.HeadRoot)
|
||||
|
||||
// Field (4) 'HeadSlot'
|
||||
hh.PutUint64(s.HeadSlot)
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the BeaconBlocksByRangeRequest object
|
||||
func (b *BeaconBlocksByRangeRequest) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(b)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the BeaconBlocksByRangeRequest object to a target array
|
||||
func (b *BeaconBlocksByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'StartSlot'
|
||||
dst = ssz.MarshalUint64(dst, b.StartSlot)
|
||||
|
||||
// Field (1) 'Count'
|
||||
dst = ssz.MarshalUint64(dst, b.Count)
|
||||
|
||||
// Field (2) 'Step'
|
||||
dst = ssz.MarshalUint64(dst, b.Step)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the BeaconBlocksByRangeRequest object
|
||||
func (b *BeaconBlocksByRangeRequest) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 24 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'StartSlot'
|
||||
b.StartSlot = ssz.UnmarshallUint64(buf[0:8])
|
||||
|
||||
// Field (1) 'Count'
|
||||
b.Count = ssz.UnmarshallUint64(buf[8:16])
|
||||
|
||||
// Field (2) 'Step'
|
||||
b.Step = ssz.UnmarshallUint64(buf[16:24])
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlocksByRangeRequest object
|
||||
func (b *BeaconBlocksByRangeRequest) SizeSSZ() (size int) {
|
||||
size = 24
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the BeaconBlocksByRangeRequest object
|
||||
func (b *BeaconBlocksByRangeRequest) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(b)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the BeaconBlocksByRangeRequest object with a hasher
|
||||
func (b *BeaconBlocksByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'StartSlot'
|
||||
hh.PutUint64(b.StartSlot)
|
||||
|
||||
// Field (1) 'Count'
|
||||
hh.PutUint64(b.Count)
|
||||
|
||||
// Field (2) 'Step'
|
||||
hh.PutUint64(b.Step)
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the ErrorResponse object
|
||||
func (e *ErrorResponse) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(e)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the ErrorResponse object to a target array
|
||||
func (e *ErrorResponse) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
offset := int(4)
|
||||
|
||||
// Offset (0) 'Message'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
offset += len(e.Message)
|
||||
|
||||
// Field (0) 'Message'
|
||||
if len(e.Message) > 256 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.Message...)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the ErrorResponse object
|
||||
func (e *ErrorResponse) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size < 4 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
tail := buf
|
||||
var o0 uint64
|
||||
|
||||
// Offset (0) 'Message'
|
||||
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
// Field (0) 'Message'
|
||||
{
|
||||
buf = tail[o0:]
|
||||
if len(buf) > 256 {
|
||||
return ssz.ErrBytesLength
|
||||
}
|
||||
if cap(e.Message) == 0 {
|
||||
e.Message = make([]byte, 0, len(buf))
|
||||
}
|
||||
e.Message = append(e.Message, buf...)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the ErrorResponse object
|
||||
func (e *ErrorResponse) SizeSSZ() (size int) {
|
||||
size = 4
|
||||
|
||||
// Field (0) 'Message'
|
||||
size += len(e.Message)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the ErrorResponse object
|
||||
func (e *ErrorResponse) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(e)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the ErrorResponse object with a hasher
|
||||
func (e *ErrorResponse) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'Message'
|
||||
if len(e.Message) > 256 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.Message)
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the ENRForkID object
|
||||
func (e *ENRForkID) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(e)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the ENRForkID object to a target array
|
||||
func (e *ENRForkID) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'CurrentForkDigest'
|
||||
if len(e.CurrentForkDigest) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.CurrentForkDigest...)
|
||||
|
||||
// Field (1) 'NextForkVersion'
|
||||
if len(e.NextForkVersion) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.NextForkVersion...)
|
||||
|
||||
// Field (2) 'NextForkEpoch'
|
||||
dst = ssz.MarshalUint64(dst, e.NextForkEpoch)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the ENRForkID object
|
||||
func (e *ENRForkID) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 16 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'CurrentForkDigest'
|
||||
if cap(e.CurrentForkDigest) == 0 {
|
||||
e.CurrentForkDigest = make([]byte, 0, len(buf[0:4]))
|
||||
}
|
||||
e.CurrentForkDigest = append(e.CurrentForkDigest, buf[0:4]...)
|
||||
|
||||
// Field (1) 'NextForkVersion'
|
||||
if cap(e.NextForkVersion) == 0 {
|
||||
e.NextForkVersion = make([]byte, 0, len(buf[4:8]))
|
||||
}
|
||||
e.NextForkVersion = append(e.NextForkVersion, buf[4:8]...)
|
||||
|
||||
// Field (2) 'NextForkEpoch'
|
||||
e.NextForkEpoch = ssz.UnmarshallUint64(buf[8:16])
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the ENRForkID object
|
||||
func (e *ENRForkID) SizeSSZ() (size int) {
|
||||
size = 16
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the ENRForkID object
|
||||
func (e *ENRForkID) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(e)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the ENRForkID object with a hasher
|
||||
func (e *ENRForkID) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'CurrentForkDigest'
|
||||
if len(e.CurrentForkDigest) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.CurrentForkDigest)
|
||||
|
||||
// Field (1) 'NextForkVersion'
|
||||
if len(e.NextForkVersion) != 4 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.NextForkVersion)
|
||||
|
||||
// Field (2) 'NextForkEpoch'
|
||||
hh.PutUint64(e.NextForkEpoch)
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the MetaData object
|
||||
func (m *MetaData) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(m)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the MetaData object to a target array
|
||||
func (m *MetaData) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'SeqNumber'
|
||||
dst = ssz.MarshalUint64(dst, m.SeqNumber)
|
||||
|
||||
// Field (1) 'Attnets'
|
||||
if len(m.Attnets) != 8 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, m.Attnets...)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the MetaData object
|
||||
func (m *MetaData) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 16 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'SeqNumber'
|
||||
m.SeqNumber = ssz.UnmarshallUint64(buf[0:8])
|
||||
|
||||
// Field (1) 'Attnets'
|
||||
if cap(m.Attnets) == 0 {
|
||||
m.Attnets = make([]byte, 0, len(buf[8:16]))
|
||||
}
|
||||
m.Attnets = append(m.Attnets, buf[8:16]...)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the MetaData object
|
||||
func (m *MetaData) SizeSSZ() (size int) {
|
||||
size = 16
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the MetaData object
|
||||
func (m *MetaData) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(m)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the MetaData object with a hasher
|
||||
func (m *MetaData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'SeqNumber'
|
||||
hh.PutUint64(m.SeqNumber)
|
||||
|
||||
// Field (1) 'Attnets'
|
||||
if len(m.Attnets) != 8 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(m.Attnets)
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
256
proto/beacon/p2p/v1/messages.pb.go
generated
256
proto/beacon/p2p/v1/messages.pb.go
generated
@@ -167,53 +167,6 @@ func (m *BeaconBlocksByRangeRequest) GetStep() uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
type ErrorResponse struct {
|
||||
Message []byte `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty" ssz-max:"256"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *ErrorResponse) Reset() { *m = ErrorResponse{} }
|
||||
func (m *ErrorResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*ErrorResponse) ProtoMessage() {}
|
||||
func (*ErrorResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_a1d590cda035b632, []int{2}
|
||||
}
|
||||
func (m *ErrorResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *ErrorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_ErrorResponse.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *ErrorResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ErrorResponse.Merge(m, src)
|
||||
}
|
||||
func (m *ErrorResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *ErrorResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ErrorResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ErrorResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *ErrorResponse) GetMessage() []byte {
|
||||
if m != nil {
|
||||
return m.Message
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ENRForkID struct {
|
||||
CurrentForkDigest []byte `protobuf:"bytes,1,opt,name=current_fork_digest,json=currentForkDigest,proto3" json:"current_fork_digest,omitempty" ssz-size:"4"`
|
||||
NextForkVersion []byte `protobuf:"bytes,2,opt,name=next_fork_version,json=nextForkVersion,proto3" json:"next_fork_version,omitempty" ssz-size:"4"`
|
||||
@@ -227,7 +180,7 @@ func (m *ENRForkID) Reset() { *m = ENRForkID{} }
|
||||
func (m *ENRForkID) String() string { return proto.CompactTextString(m) }
|
||||
func (*ENRForkID) ProtoMessage() {}
|
||||
func (*ENRForkID) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_a1d590cda035b632, []int{3}
|
||||
return fileDescriptor_a1d590cda035b632, []int{2}
|
||||
}
|
||||
func (m *ENRForkID) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@@ -289,7 +242,7 @@ func (m *MetaData) Reset() { *m = MetaData{} }
|
||||
func (m *MetaData) String() string { return proto.CompactTextString(m) }
|
||||
func (*MetaData) ProtoMessage() {}
|
||||
func (*MetaData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_a1d590cda035b632, []int{4}
|
||||
return fileDescriptor_a1d590cda035b632, []int{3}
|
||||
}
|
||||
func (m *MetaData) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@@ -335,7 +288,6 @@ func (m *MetaData) GetAttnets() github_com_prysmaticlabs_go_bitfield.Bitvector64
|
||||
func init() {
|
||||
proto.RegisterType((*Status)(nil), "ethereum.beacon.p2p.v1.Status")
|
||||
proto.RegisterType((*BeaconBlocksByRangeRequest)(nil), "ethereum.beacon.p2p.v1.BeaconBlocksByRangeRequest")
|
||||
proto.RegisterType((*ErrorResponse)(nil), "ethereum.beacon.p2p.v1.ErrorResponse")
|
||||
proto.RegisterType((*ENRForkID)(nil), "ethereum.beacon.p2p.v1.ENRForkID")
|
||||
proto.RegisterType((*MetaData)(nil), "ethereum.beacon.p2p.v1.MetaData")
|
||||
}
|
||||
@@ -345,40 +297,38 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_a1d590cda035b632 = []byte{
|
||||
// 524 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcf, 0x6e, 0xd3, 0x40,
|
||||
0x10, 0xc6, 0x65, 0x48, 0xff, 0x2d, 0x0d, 0x21, 0x0b, 0x42, 0x51, 0x11, 0x49, 0xb5, 0x07, 0xa8,
|
||||
0x84, 0x62, 0x93, 0xb4, 0x54, 0x55, 0xd5, 0x03, 0xb2, 0x92, 0x4a, 0x1c, 0xe8, 0x61, 0x2b, 0x71,
|
||||
0x24, 0x5a, 0x3b, 0x13, 0xc7, 0x8a, 0xed, 0x75, 0x76, 0xc7, 0x51, 0x9b, 0x37, 0xe0, 0x79, 0x78,
|
||||
0x09, 0x8e, 0x3c, 0x41, 0x84, 0x72, 0xe5, 0xd6, 0x23, 0x27, 0xe4, 0xb5, 0x93, 0x14, 0x21, 0x24,
|
||||
0x6e, 0xbb, 0xb3, 0xbf, 0xef, 0xd3, 0xcc, 0x7c, 0x4b, 0x58, 0xaa, 0x24, 0x4a, 0xc7, 0x03, 0xe1,
|
||||
0xcb, 0xc4, 0x49, 0xbb, 0xa9, 0x33, 0xeb, 0x38, 0x31, 0x68, 0x2d, 0x02, 0xd0, 0xb6, 0x79, 0xa4,
|
||||
0xcf, 0x01, 0xc7, 0xa0, 0x20, 0x8b, 0xed, 0x02, 0xb3, 0xd3, 0x6e, 0x6a, 0xcf, 0x3a, 0x07, 0xed,
|
||||
0x20, 0xc4, 0x71, 0xe6, 0xd9, 0xbe, 0x8c, 0x9d, 0x40, 0x06, 0xd2, 0x31, 0xb8, 0x97, 0x8d, 0xcc,
|
||||
0xad, 0x30, 0xce, 0x4f, 0x85, 0x0d, 0xfb, 0x69, 0x91, 0xed, 0x6b, 0x14, 0x98, 0x69, 0xda, 0x21,
|
||||
0x8f, 0x46, 0x52, 0x4d, 0x06, 0xc3, 0x30, 0x00, 0x8d, 0x0d, 0xeb, 0xd0, 0x3a, 0xda, 0x77, 0x9f,
|
||||
0xdc, 0x2d, 0x5a, 0xfb, 0x5a, 0xcf, 0xdb, 0x3a, 0x9c, 0xc3, 0x39, 0x3b, 0x61, 0x9c, 0xe4, 0x50,
|
||||
0xcf, 0x30, 0xf4, 0x8c, 0x3c, 0x1e, 0x85, 0x89, 0x88, 0xc2, 0x39, 0x0c, 0x07, 0x4a, 0x4a, 0x6c,
|
||||
0x3c, 0x30, 0xaa, 0xfa, 0xdd, 0xa2, 0x55, 0xdd, 0xa8, 0x8e, 0xbb, 0x8c, 0x57, 0xd7, 0x20, 0x97,
|
||||
0x12, 0xe9, 0x6b, 0x52, 0xdb, 0x28, 0x21, 0x95, 0xfe, 0xb8, 0xf1, 0xf0, 0xd0, 0x3a, 0xaa, 0xf0,
|
||||
0x8d, 0x61, 0x3f, 0xaf, 0x52, 0x9b, 0xec, 0x8d, 0x41, 0x94, 0xee, 0x95, 0x7f, 0xb9, 0xef, 0xe6,
|
||||
0x8c, 0x31, 0x7e, 0x51, 0xf2, 0x3a, 0x92, 0xd8, 0xd8, 0x32, 0x96, 0xe6, 0xf1, 0x3a, 0x92, 0xc8,
|
||||
0x80, 0x1c, 0xb8, 0x66, 0x5b, 0x6e, 0x24, 0xfd, 0x89, 0x76, 0x6f, 0xb9, 0x48, 0x02, 0xe0, 0x30,
|
||||
0xcd, 0xf2, 0x69, 0x5e, 0x12, 0xa2, 0x51, 0x28, 0x2c, 0xb4, 0x96, 0xd1, 0xee, 0x99, 0x4a, 0x2e,
|
||||
0xa6, 0xcf, 0xc8, 0x96, 0x2f, 0xb3, 0xa4, 0x98, 0xb1, 0xc2, 0x8b, 0x0b, 0xa5, 0xa4, 0xa2, 0x11,
|
||||
0xd2, 0xb2, 0x7b, 0x73, 0x66, 0x17, 0xa4, 0xda, 0x57, 0x4a, 0x2a, 0x0e, 0x3a, 0x95, 0x89, 0x06,
|
||||
0xfa, 0x86, 0xec, 0x94, 0xf1, 0x95, 0x6b, 0x5d, 0x8f, 0x10, 0x8b, 0x9b, 0x73, 0xd6, 0x7d, 0x77,
|
||||
0xca, 0xf8, 0x8a, 0x60, 0x5f, 0x2d, 0xb2, 0xd7, 0xbf, 0xe2, 0x97, 0x52, 0x4d, 0x3e, 0xf4, 0xe8,
|
||||
0x7b, 0xf2, 0xd4, 0xcf, 0x94, 0x82, 0x04, 0x07, 0xff, 0x93, 0x4e, 0xbd, 0x84, 0x2f, 0x37, 0x21,
|
||||
0x5d, 0x90, 0x7a, 0x02, 0x37, 0xa5, 0x7c, 0x06, 0x4a, 0x87, 0x32, 0x29, 0x73, 0xfa, 0x5b, 0x5f,
|
||||
0xcb, 0xd1, 0x5c, 0xfc, 0xa9, 0x00, 0xe9, 0x2b, 0x52, 0xdb, 0xa8, 0xef, 0x07, 0x55, 0x5d, 0x91,
|
||||
0x26, 0x27, 0xf6, 0xc5, 0x22, 0xbb, 0x1f, 0x01, 0x45, 0x4f, 0xa0, 0x30, 0x9b, 0x84, 0xe9, 0x20,
|
||||
0xc9, 0x62, 0x0f, 0xd4, 0x7a, 0x93, 0x30, 0xbd, 0x32, 0x05, 0xfa, 0x99, 0xec, 0x08, 0xc4, 0x04,
|
||||
0x50, 0x97, 0x7d, 0xf4, 0xfe, 0xec, 0xe3, 0x8c, 0xfd, 0x5a, 0xb4, 0xde, 0xde, 0xfb, 0xc8, 0xa9,
|
||||
0xba, 0xd5, 0xb1, 0xc0, 0xd0, 0x8f, 0x84, 0xa7, 0x9d, 0x40, 0xb6, 0xbd, 0x10, 0x47, 0x21, 0x44,
|
||||
0x43, 0xdb, 0x0d, 0x71, 0x06, 0x3e, 0x4a, 0x75, 0x7a, 0xc2, 0x57, 0xa6, 0xee, 0xfe, 0xb7, 0x65,
|
||||
0xd3, 0xfa, 0xbe, 0x6c, 0x5a, 0x3f, 0x96, 0x4d, 0xcb, 0xdb, 0x36, 0x3f, 0xfd, 0xf8, 0x77, 0x00,
|
||||
0x00, 0x00, 0xff, 0xff, 0x6d, 0xdc, 0x81, 0x9b, 0x56, 0x03, 0x00, 0x00,
|
||||
// 489 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcd, 0x6e, 0xd3, 0x40,
|
||||
0x14, 0x85, 0x65, 0x48, 0x4b, 0x33, 0x24, 0x84, 0x0c, 0x08, 0x45, 0x45, 0x24, 0x95, 0x17, 0xd0,
|
||||
0x4d, 0x6c, 0x92, 0x56, 0xa8, 0x42, 0x2c, 0x90, 0x95, 0x56, 0x62, 0x41, 0x17, 0xae, 0xc4, 0x92,
|
||||
0x68, 0xec, 0xdc, 0x38, 0xa3, 0x38, 0xbe, 0xce, 0xcc, 0x75, 0x44, 0xf3, 0x06, 0x3c, 0x0f, 0x2f,
|
||||
0xc1, 0x92, 0x27, 0x88, 0x50, 0xb6, 0xec, 0xba, 0x64, 0x85, 0x3c, 0x76, 0xeb, 0x22, 0x84, 0xd4,
|
||||
0xdd, 0xfc, 0x7c, 0xdf, 0xd1, 0x9d, 0xa3, 0x61, 0x76, 0xaa, 0x90, 0xd0, 0x0d, 0x40, 0x84, 0x98,
|
||||
0xb8, 0xe9, 0x30, 0x75, 0x57, 0x03, 0x77, 0x01, 0x5a, 0x8b, 0x08, 0xb4, 0x63, 0x2e, 0xf9, 0x33,
|
||||
0xa0, 0x19, 0x28, 0xc8, 0x16, 0x4e, 0x81, 0x39, 0xe9, 0x30, 0x75, 0x56, 0x83, 0xfd, 0x7e, 0x24,
|
||||
0x69, 0x96, 0x05, 0x4e, 0x88, 0x0b, 0x37, 0xc2, 0x08, 0x5d, 0x83, 0x07, 0xd9, 0xd4, 0xec, 0x8a,
|
||||
0xe0, 0x7c, 0x55, 0xc4, 0xd8, 0xbf, 0x2c, 0xb6, 0x7b, 0x41, 0x82, 0x32, 0xcd, 0x07, 0xec, 0xe1,
|
||||
0x14, 0xd5, 0x7c, 0x3c, 0x91, 0x11, 0x68, 0xea, 0x58, 0x07, 0xd6, 0x61, 0xc3, 0x7b, 0x7c, 0xb5,
|
||||
0xe9, 0x35, 0xb4, 0x5e, 0xf7, 0xb5, 0x5c, 0xc3, 0x5b, 0xfb, 0xd8, 0xf6, 0x59, 0x0e, 0x8d, 0x0c,
|
||||
0xc3, 0x4f, 0xd8, 0xa3, 0xa9, 0x4c, 0x44, 0x2c, 0xd7, 0x30, 0x19, 0x2b, 0x44, 0xea, 0xdc, 0x33,
|
||||
0x56, 0xfb, 0x6a, 0xd3, 0x6b, 0x56, 0xd6, 0xd1, 0xd0, 0xf6, 0x9b, 0x37, 0xa0, 0x8f, 0x48, 0xfc,
|
||||
0x15, 0x6b, 0x55, 0x26, 0xa4, 0x18, 0xce, 0x3a, 0xf7, 0x0f, 0xac, 0xc3, 0x9a, 0x5f, 0x05, 0x9e,
|
||||
0xe6, 0xa7, 0xdc, 0x61, 0xf5, 0x19, 0x88, 0x32, 0xbd, 0xf6, 0xbf, 0xf4, 0xbd, 0x9c, 0x31, 0xc1,
|
||||
0xcf, 0x4b, 0x5e, 0xc7, 0x48, 0x9d, 0x1d, 0x13, 0x69, 0x2e, 0x2f, 0x62, 0x24, 0x1b, 0xd8, 0xbe,
|
||||
0x67, 0xda, 0xf2, 0x62, 0x0c, 0xe7, 0xda, 0xbb, 0xf4, 0x45, 0x12, 0x81, 0x0f, 0xcb, 0x2c, 0x7f,
|
||||
0xcd, 0x0b, 0xc6, 0x34, 0x09, 0x45, 0x85, 0x6b, 0x19, 0xb7, 0x6e, 0x4e, 0x72, 0x99, 0x3f, 0x65,
|
||||
0x3b, 0x21, 0x66, 0x49, 0xf1, 0xc6, 0x9a, 0x5f, 0x6c, 0x38, 0x67, 0x35, 0x4d, 0x90, 0x96, 0xd3,
|
||||
0x9b, 0xb5, 0xfd, 0xcd, 0x62, 0xf5, 0xd3, 0x73, 0xff, 0x0c, 0xd5, 0xfc, 0xc3, 0x88, 0xbf, 0x67,
|
||||
0x4f, 0xc2, 0x4c, 0x29, 0x48, 0x68, 0x7c, 0x97, 0x7e, 0xdb, 0x25, 0x7c, 0x56, 0xd5, 0xfc, 0x8e,
|
||||
0xb5, 0x13, 0xf8, 0x52, 0xea, 0x2b, 0x50, 0x5a, 0x62, 0x52, 0x36, 0xfd, 0xaf, 0xdf, 0xca, 0xd1,
|
||||
0x5c, 0xfe, 0x54, 0x80, 0xfc, 0x25, 0x6b, 0x55, 0xf6, 0xed, 0xaa, 0x9b, 0xd7, 0xa4, 0x69, 0xda,
|
||||
0xfe, 0x6a, 0xb1, 0xbd, 0x8f, 0x40, 0x62, 0x24, 0x48, 0x98, 0x2e, 0x60, 0x39, 0x4e, 0xb2, 0x45,
|
||||
0x00, 0xea, 0xa6, 0x0b, 0x58, 0x9e, 0x9b, 0x03, 0xfe, 0x99, 0x3d, 0x10, 0x44, 0x09, 0x90, 0x2e,
|
||||
0xe7, 0x18, 0xfd, 0x3d, 0xc7, 0x89, 0xfd, 0x7b, 0xd3, 0x7b, 0x7d, 0xeb, 0x2b, 0xa6, 0xea, 0x52,
|
||||
0x2f, 0x04, 0xc9, 0x30, 0x16, 0x81, 0x76, 0x23, 0xec, 0x07, 0x92, 0xa6, 0x12, 0xe2, 0x89, 0xe3,
|
||||
0x49, 0x5a, 0x41, 0x48, 0xa8, 0xde, 0x1c, 0xfb, 0xd7, 0xa1, 0x5e, 0xe3, 0xfb, 0xb6, 0x6b, 0xfd,
|
||||
0xd8, 0x76, 0xad, 0x9f, 0xdb, 0xae, 0x15, 0xec, 0x9a, 0xbf, 0x7a, 0xf4, 0x27, 0x00, 0x00, 0xff,
|
||||
0xff, 0xf7, 0x8d, 0xaf, 0xcc, 0x18, 0x03, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Status) Marshal() (dAtA []byte, err error) {
|
||||
@@ -481,40 +431,6 @@ func (m *BeaconBlocksByRangeRequest) MarshalToSizedBuffer(dAtA []byte) (int, err
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *ErrorResponse) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *ErrorResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *ErrorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.XXX_unrecognized != nil {
|
||||
i -= len(m.XXX_unrecognized)
|
||||
copy(dAtA[i:], m.XXX_unrecognized)
|
||||
}
|
||||
if len(m.Message) > 0 {
|
||||
i -= len(m.Message)
|
||||
copy(dAtA[i:], m.Message)
|
||||
i = encodeVarintMessages(dAtA, i, uint64(len(m.Message)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *ENRForkID) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
@@ -662,22 +578,6 @@ func (m *BeaconBlocksByRangeRequest) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *ErrorResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Message)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovMessages(uint64(l))
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
n += len(m.XXX_unrecognized)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *ENRForkID) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
@@ -1031,94 +931,6 @@ func (m *BeaconBlocksByRangeRequest) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *ErrorResponse) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowMessages
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: ErrorResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: ErrorResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowMessages
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthMessages
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthMessages
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Message = append(m.Message[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Message == nil {
|
||||
m.Message = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipMessages(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthMessages
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthMessages
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *ENRForkID) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
||||
@@ -18,10 +18,6 @@ message BeaconBlocksByRangeRequest {
|
||||
uint64 step = 3;
|
||||
}
|
||||
|
||||
message ErrorResponse {
|
||||
bytes message = 1 [(gogoproto.moretags) = "ssz-max:\"256\""];
|
||||
}
|
||||
|
||||
message ENRForkID {
|
||||
bytes current_fork_digest = 1 [(gogoproto.moretags) = "ssz-size:\"4\""];
|
||||
bytes next_fork_version = 2 [(gogoproto.moretags) = "ssz-size:\"4\""];
|
||||
|
||||
Reference in New Issue
Block a user