2020-05-07 13:13:45 +00:00
|
|
|
package initialsync
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-05-10 14:47:05 +00:00
|
|
|
"fmt"
|
2020-05-07 13:13:45 +00:00
|
|
|
"io/ioutil"
|
2020-05-10 14:47:05 +00:00
|
|
|
"sync"
|
2020-05-07 13:13:45 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2020-05-10 14:47:05 +00:00
|
|
|
"github.com/ethereum/go-ethereum/p2p/enr"
|
|
|
|
"github.com/libp2p/go-libp2p-core/network"
|
2020-08-13 08:42:21 +00:00
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
2021-02-16 07:45:34 +00:00
|
|
|
types "github.com/prysmaticlabs/eth2-types"
|
2020-05-07 13:13:45 +00:00
|
|
|
mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
|
|
|
dbtest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
2020-05-10 14:47:05 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
2020-05-07 13:13:45 +00:00
|
|
|
p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
2020-11-05 07:27:46 +00:00
|
|
|
p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
2020-05-10 14:47:05 +00:00
|
|
|
beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
2021-03-02 19:36:03 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
|
2021-09-15 01:18:39 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/config/features"
|
2021-09-21 19:59:25 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
2021-09-16 17:05:58 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/container/slice"
|
2021-09-15 22:55:11 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/crypto/hash"
|
2021-09-23 15:23:37 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
|
2021-12-07 17:52:39 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
2021-07-21 21:34:07 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
2021-09-23 18:53:46 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/testing/assert"
|
|
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
|
|
"github.com/prysmaticlabs/prysm/testing/util"
|
2021-09-15 00:09:04 +00:00
|
|
|
prysmTime "github.com/prysmaticlabs/prysm/time"
|
2021-10-01 20:17:57 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/time/slots"
|
2020-05-07 13:13:45 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
type testCache struct {
|
|
|
|
sync.RWMutex
|
2021-02-16 07:45:34 +00:00
|
|
|
rootCache map[types.Slot][32]byte
|
|
|
|
parentSlotCache map[types.Slot]types.Slot
|
2020-05-07 13:13:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var cache = &testCache{}
|
|
|
|
|
|
|
|
type peerData struct {
|
2021-02-16 07:45:34 +00:00
|
|
|
blocks []types.Slot // slots that peer has blocks
|
2021-02-09 10:05:22 +00:00
|
|
|
finalizedEpoch types.Epoch
|
2021-02-16 07:45:34 +00:00
|
|
|
headSlot types.Slot
|
|
|
|
failureSlots []types.Slot // slots at which the peer will return an error
|
2020-05-07 13:13:45 +00:00
|
|
|
forkedPeer bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
2020-12-04 16:10:07 +00:00
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
|
|
logrus.SetOutput(ioutil.Discard)
|
2020-05-18 18:59:03 +00:00
|
|
|
|
2021-09-15 01:18:39 +00:00
|
|
|
resetCfg := features.InitWithReset(&features.Flags{
|
2020-12-04 16:10:07 +00:00
|
|
|
EnablePeerScorer: true,
|
|
|
|
})
|
|
|
|
defer resetCfg()
|
2020-05-18 18:59:03 +00:00
|
|
|
|
2020-12-04 16:10:07 +00:00
|
|
|
resetFlags := flags.Get()
|
|
|
|
flags.Init(&flags.GlobalFlags{
|
|
|
|
BlockBatchLimit: 64,
|
|
|
|
BlockBatchLimitBurstFactor: 10,
|
|
|
|
})
|
|
|
|
defer func() {
|
|
|
|
flags.Init(resetFlags)
|
|
|
|
}()
|
2020-11-10 14:56:47 +00:00
|
|
|
|
2020-12-04 16:10:07 +00:00
|
|
|
m.Run()
|
2020-05-07 13:13:45 +00:00
|
|
|
}
|
|
|
|
|
2021-02-16 07:45:34 +00:00
|
|
|
func initializeTestServices(t *testing.T, slots []types.Slot, peers []*peerData) (*mock.ChainService, *p2pt.TestP2P, db.Database) {
|
|
|
|
cache.initializeRootCache(slots, t)
|
2020-12-16 16:56:21 +00:00
|
|
|
beaconDB := dbtest.SetupDB(t)
|
2020-05-07 13:13:45 +00:00
|
|
|
|
|
|
|
p := p2pt.NewTestP2P(t)
|
|
|
|
connectPeers(t, p, peers, p.Peers())
|
|
|
|
cache.RLock()
|
|
|
|
genesisRoot := cache.rootCache[0]
|
|
|
|
cache.RUnlock()
|
|
|
|
|
2021-09-23 18:53:46 +00:00
|
|
|
err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(util.NewBeaconBlock()))
|
2020-07-15 04:41:11 +00:00
|
|
|
require.NoError(t, err)
|
2020-05-07 13:13:45 +00:00
|
|
|
|
2021-09-23 18:53:46 +00:00
|
|
|
st, err := util.NewBeaconState()
|
2021-02-08 20:00:09 +00:00
|
|
|
require.NoError(t, err)
|
2020-05-07 13:13:45 +00:00
|
|
|
|
|
|
|
return &mock.ChainService{
|
|
|
|
State: st,
|
|
|
|
Root: genesisRoot[:],
|
|
|
|
DB: beaconDB,
|
2021-12-07 17:52:39 +00:00
|
|
|
FinalizedCheckPoint: ðpb.Checkpoint{
|
2020-08-16 17:51:14 +00:00
|
|
|
Epoch: 0,
|
|
|
|
},
|
2021-09-03 16:00:56 +00:00
|
|
|
Genesis: time.Now(),
|
|
|
|
ValidatorsRoot: [32]byte{},
|
2020-05-07 13:13:45 +00:00
|
|
|
}, p, beaconDB
|
|
|
|
}
|
|
|
|
|
|
|
|
// makeGenesisTime where now is the current slot.
|
2021-02-16 07:45:34 +00:00
|
|
|
func makeGenesisTime(currentSlot types.Slot) time.Time {
|
2021-09-15 00:09:04 +00:00
|
|
|
return prysmTime.Now().Add(-1 * time.Second * time.Duration(currentSlot) * time.Duration(params.BeaconConfig().SecondsPerSlot))
|
2020-05-07 13:13:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// sanity test on helper function
|
|
|
|
func TestMakeGenesisTime(t *testing.T) {
|
2021-02-16 07:45:34 +00:00
|
|
|
currentSlot := types.Slot(64)
|
2020-05-07 13:13:45 +00:00
|
|
|
gt := makeGenesisTime(currentSlot)
|
2021-10-01 20:17:57 +00:00
|
|
|
require.Equal(t, currentSlot, slots.Since(gt))
|
2020-05-07 13:13:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// helper function for sequences of block slots
|
2021-02-16 07:45:34 +00:00
|
|
|
func makeSequence(start, end types.Slot) []types.Slot {
|
2020-05-07 13:13:45 +00:00
|
|
|
if end < start {
|
|
|
|
panic("cannot make sequence where end is before start")
|
|
|
|
}
|
2021-02-16 07:45:34 +00:00
|
|
|
seq := make([]types.Slot, 0, end-start+1)
|
2020-05-07 13:13:45 +00:00
|
|
|
for i := start; i <= end; i++ {
|
|
|
|
seq = append(seq, i)
|
|
|
|
}
|
|
|
|
return seq
|
|
|
|
}
|
|
|
|
|
2021-02-16 07:45:34 +00:00
|
|
|
func (c *testCache) initializeRootCache(reqSlots []types.Slot, t *testing.T) {
|
2020-05-07 13:13:45 +00:00
|
|
|
c.Lock()
|
|
|
|
defer c.Unlock()
|
|
|
|
|
2021-02-16 07:45:34 +00:00
|
|
|
c.rootCache = make(map[types.Slot][32]byte)
|
|
|
|
c.parentSlotCache = make(map[types.Slot]types.Slot)
|
|
|
|
parentSlot := types.Slot(0)
|
2020-08-27 18:13:32 +00:00
|
|
|
|
2021-09-23 18:53:46 +00:00
|
|
|
genesisBlock := util.NewBeaconBlock().Block
|
2020-08-27 18:13:32 +00:00
|
|
|
genesisRoot, err := genesisBlock.HashTreeRoot()
|
2020-07-15 04:41:11 +00:00
|
|
|
require.NoError(t, err)
|
2020-05-07 13:13:45 +00:00
|
|
|
c.rootCache[0] = genesisRoot
|
|
|
|
parentRoot := genesisRoot
|
|
|
|
for _, slot := range reqSlots {
|
2021-09-23 18:53:46 +00:00
|
|
|
currentBlock := util.NewBeaconBlock().Block
|
2020-08-27 18:13:32 +00:00
|
|
|
currentBlock.Slot = slot
|
|
|
|
currentBlock.ParentRoot = parentRoot[:]
|
|
|
|
parentRoot, err = currentBlock.HashTreeRoot()
|
2020-07-15 04:41:11 +00:00
|
|
|
require.NoError(t, err)
|
2020-05-07 13:13:45 +00:00
|
|
|
c.rootCache[slot] = parentRoot
|
|
|
|
c.parentSlotCache[slot] = parentSlot
|
|
|
|
parentSlot = slot
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// sanity test on helper function
|
|
|
|
func TestMakeSequence(t *testing.T) {
|
|
|
|
got := makeSequence(3, 5)
|
2021-02-16 07:45:34 +00:00
|
|
|
want := []types.Slot{3, 4, 5}
|
2020-07-15 04:41:11 +00:00
|
|
|
require.DeepEqual(t, want, got)
|
2020-05-07 13:13:45 +00:00
|
|
|
}
|
2020-05-10 14:47:05 +00:00
|
|
|
|
|
|
|
// Connect peers with local host. This method sets up peer statuses and the appropriate handlers
|
|
|
|
// for each test peer.
|
|
|
|
func connectPeers(t *testing.T, host *p2pt.TestP2P, data []*peerData, peerStatus *peers.Status) {
|
|
|
|
for _, d := range data {
|
2020-08-13 08:42:21 +00:00
|
|
|
connectPeer(t, host, d, peerStatus)
|
|
|
|
}
|
|
|
|
}
|
2020-05-10 14:47:05 +00:00
|
|
|
|
2020-08-13 08:42:21 +00:00
|
|
|
// connectPeer connects a peer to a local host.
|
|
|
|
func connectPeer(t *testing.T, host *p2pt.TestP2P, datum *peerData, peerStatus *peers.Status) peer.ID {
|
|
|
|
const topic = "/eth2/beacon_chain/req/beacon_blocks_by_range/1/ssz_snappy"
|
|
|
|
p := p2pt.NewTestP2P(t)
|
|
|
|
p.SetStreamHandler(topic, func(stream network.Stream) {
|
|
|
|
defer func() {
|
2020-08-25 15:23:06 +00:00
|
|
|
assert.NoError(t, stream.Close())
|
2020-08-13 08:42:21 +00:00
|
|
|
}()
|
2020-05-10 14:47:05 +00:00
|
|
|
|
2021-12-07 17:52:39 +00:00
|
|
|
req := ðpb.BeaconBlocksByRangeRequest{}
|
2020-08-13 08:42:21 +00:00
|
|
|
assert.NoError(t, p.Encoding().DecodeWithMaxLength(stream, req))
|
|
|
|
|
2021-02-16 07:45:34 +00:00
|
|
|
requestedBlocks := makeSequence(req.StartSlot, req.StartSlot.Add((req.Count-1)*req.Step))
|
2020-08-13 08:42:21 +00:00
|
|
|
|
|
|
|
// Expected failure range
|
2021-09-16 17:05:58 +00:00
|
|
|
if len(slice.IntersectionSlot(datum.failureSlots, requestedBlocks)) > 0 {
|
2020-08-25 15:23:06 +00:00
|
|
|
_, err := stream.Write([]byte{0x01})
|
|
|
|
assert.NoError(t, err)
|
2020-12-14 22:22:55 +00:00
|
|
|
msg := p2pTypes.ErrorMessage("bad")
|
2020-10-14 07:55:28 +00:00
|
|
|
_, err = p.Encoding().EncodeWithMaxLength(stream, &msg)
|
2020-08-25 15:23:06 +00:00
|
|
|
assert.NoError(t, err)
|
2020-08-13 08:42:21 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Determine the correct subset of blocks to return as dictated by the test scenario.
|
2021-09-16 17:05:58 +00:00
|
|
|
slots := slice.IntersectionSlot(datum.blocks, requestedBlocks)
|
2020-05-10 14:47:05 +00:00
|
|
|
|
2021-12-07 17:52:39 +00:00
|
|
|
ret := make([]*ethpb.SignedBeaconBlock, 0)
|
2021-02-16 07:45:34 +00:00
|
|
|
for _, slot := range slots {
|
|
|
|
if (slot - req.StartSlot).Mod(req.Step) != 0 {
|
2020-08-13 08:42:21 +00:00
|
|
|
continue
|
2020-05-10 14:47:05 +00:00
|
|
|
}
|
2020-08-13 08:42:21 +00:00
|
|
|
cache.RLock()
|
|
|
|
parentRoot := cache.rootCache[cache.parentSlotCache[slot]]
|
|
|
|
cache.RUnlock()
|
2021-09-23 18:53:46 +00:00
|
|
|
blk := util.NewBeaconBlock()
|
2020-08-27 18:13:32 +00:00
|
|
|
blk.Block.Slot = slot
|
|
|
|
blk.Block.ParentRoot = parentRoot[:]
|
2020-08-13 08:42:21 +00:00
|
|
|
// If forked peer, give a different parent root.
|
|
|
|
if datum.forkedPeer {
|
2021-09-15 22:55:11 +00:00
|
|
|
newRoot := hash.Hash(parentRoot[:])
|
2020-08-13 08:42:21 +00:00
|
|
|
blk.Block.ParentRoot = newRoot[:]
|
|
|
|
}
|
|
|
|
ret = append(ret, blk)
|
2020-08-27 18:13:32 +00:00
|
|
|
currRoot, err := blk.Block.HashTreeRoot()
|
2020-08-13 08:42:21 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
logrus.Tracef("block with slot %d , signing root %#x and parent root %#x", slot, currRoot, parentRoot)
|
|
|
|
}
|
|
|
|
|
|
|
|
if uint64(len(ret)) > req.Count {
|
|
|
|
ret = ret[:req.Count]
|
|
|
|
}
|
|
|
|
|
2021-09-03 16:00:56 +00:00
|
|
|
mChain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
|
2020-08-13 08:42:21 +00:00
|
|
|
for i := 0; i < len(ret); i++ {
|
2021-09-03 16:00:56 +00:00
|
|
|
assert.NoError(t, beaconsync.WriteBlockChunk(stream, mChain, p.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(ret[i])))
|
2020-08-13 08:42:21 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
p.Connect(host)
|
|
|
|
|
|
|
|
peerStatus.Add(new(enr.Record), p.PeerID(), nil, network.DirOutbound)
|
|
|
|
peerStatus.SetConnectionState(p.PeerID(), peers.PeerConnected)
|
2021-12-07 17:52:39 +00:00
|
|
|
peerStatus.SetChainState(p.PeerID(), ðpb.Status{
|
2020-08-13 08:42:21 +00:00
|
|
|
ForkDigest: params.BeaconConfig().GenesisForkVersion,
|
|
|
|
FinalizedRoot: []byte(fmt.Sprintf("finalized_root %d", datum.finalizedEpoch)),
|
|
|
|
FinalizedEpoch: datum.finalizedEpoch,
|
2020-08-27 18:13:32 +00:00
|
|
|
HeadRoot: bytesutil.PadTo([]byte("head_root"), 32),
|
2020-08-13 08:42:21 +00:00
|
|
|
HeadSlot: datum.headSlot,
|
|
|
|
})
|
|
|
|
|
|
|
|
return p.PeerID()
|
2020-05-10 14:47:05 +00:00
|
|
|
}
|
2020-11-05 07:27:46 +00:00
|
|
|
|
|
|
|
// extendBlockSequence extends block chain sequentially (creating genesis block, if necessary).
|
2021-12-07 17:52:39 +00:00
|
|
|
func extendBlockSequence(t *testing.T, inSeq []*ethpb.SignedBeaconBlock, size int) []*ethpb.SignedBeaconBlock {
|
2020-11-05 07:27:46 +00:00
|
|
|
// Start from the original sequence.
|
2021-12-07 17:52:39 +00:00
|
|
|
outSeq := make([]*ethpb.SignedBeaconBlock, len(inSeq)+size)
|
2020-11-05 07:27:46 +00:00
|
|
|
copy(outSeq, inSeq)
|
|
|
|
|
|
|
|
// See if genesis block needs to be created.
|
|
|
|
startSlot := len(inSeq)
|
|
|
|
if len(inSeq) == 0 {
|
2021-09-23 18:53:46 +00:00
|
|
|
outSeq[0] = util.NewBeaconBlock()
|
|
|
|
outSeq[0].Block.StateRoot = util.Random32Bytes(t)
|
2020-11-05 07:27:46 +00:00
|
|
|
startSlot++
|
|
|
|
outSeq = append(outSeq, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extend block chain sequentially.
|
|
|
|
for slot := startSlot; slot < len(outSeq); slot++ {
|
2021-09-23 18:53:46 +00:00
|
|
|
outSeq[slot] = util.NewBeaconBlock()
|
2021-02-16 07:45:34 +00:00
|
|
|
outSeq[slot].Block.Slot = types.Slot(slot)
|
2020-11-05 07:27:46 +00:00
|
|
|
parentRoot, err := outSeq[slot-1].Block.HashTreeRoot()
|
|
|
|
require.NoError(t, err)
|
|
|
|
outSeq[slot].Block.ParentRoot = parentRoot[:]
|
|
|
|
// Make sure that blocks having the same slot number, produce different hashes.
|
|
|
|
// That way different branches/forks will have different blocks for the same slots.
|
2021-09-23 18:53:46 +00:00
|
|
|
outSeq[slot].Block.StateRoot = util.Random32Bytes(t)
|
2020-11-05 07:27:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return outSeq
|
|
|
|
}
|
|
|
|
|
|
|
|
// connectPeerHavingBlocks connect host with a peer having provided blocks.
|
|
|
|
func connectPeerHavingBlocks(
|
2021-12-07 17:52:39 +00:00
|
|
|
t *testing.T, host *p2pt.TestP2P, blocks []*ethpb.SignedBeaconBlock, finalizedSlot types.Slot,
|
2020-11-05 07:27:46 +00:00
|
|
|
peerStatus *peers.Status,
|
|
|
|
) peer.ID {
|
|
|
|
p := p2pt.NewTestP2P(t)
|
|
|
|
|
|
|
|
p.SetStreamHandler("/eth2/beacon_chain/req/beacon_blocks_by_range/1/ssz_snappy", func(stream network.Stream) {
|
|
|
|
defer func() {
|
2020-12-14 17:22:25 +00:00
|
|
|
_err := stream.Close()
|
|
|
|
_ = _err
|
2020-11-05 07:27:46 +00:00
|
|
|
}()
|
|
|
|
|
2021-12-07 17:52:39 +00:00
|
|
|
req := ðpb.BeaconBlocksByRangeRequest{}
|
2020-11-05 07:27:46 +00:00
|
|
|
assert.NoError(t, p.Encoding().DecodeWithMaxLength(stream, req))
|
|
|
|
|
2021-02-16 07:45:34 +00:00
|
|
|
for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) {
|
|
|
|
if uint64(i) >= uint64(len(blocks)) {
|
2020-11-05 07:27:46 +00:00
|
|
|
break
|
|
|
|
}
|
2021-09-03 16:00:56 +00:00
|
|
|
chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
|
|
|
|
require.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blocks[i])))
|
2020-11-05 07:27:46 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
p.SetStreamHandler("/eth2/beacon_chain/req/beacon_blocks_by_root/1/ssz_snappy", func(stream network.Stream) {
|
|
|
|
defer func() {
|
2020-12-14 17:22:25 +00:00
|
|
|
_err := stream.Close()
|
|
|
|
_ = _err
|
2020-11-05 07:27:46 +00:00
|
|
|
}()
|
|
|
|
|
|
|
|
req := new(p2pTypes.BeaconBlockByRootsReq)
|
|
|
|
assert.NoError(t, p.Encoding().DecodeWithMaxLength(stream, req))
|
|
|
|
if len(*req) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
for _, expectedRoot := range *req {
|
|
|
|
for _, blk := range blocks {
|
|
|
|
if root, err := blk.Block.HashTreeRoot(); err == nil && expectedRoot == root {
|
|
|
|
log.Printf("Found blocks_by_root: %#x for slot: %v", root, blk.Block.Slot)
|
|
|
|
_, err := stream.Write([]byte{0x00})
|
|
|
|
assert.NoError(t, err, "Failed to write to stream")
|
|
|
|
_, err = p.Encoding().EncodeWithMaxLength(stream, blk)
|
|
|
|
assert.NoError(t, err, "Could not send response back")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
p.Connect(host)
|
|
|
|
|
2021-10-01 20:17:57 +00:00
|
|
|
finalizedEpoch := slots.ToEpoch(finalizedSlot)
|
2020-11-05 07:27:46 +00:00
|
|
|
headRoot, err := blocks[len(blocks)-1].Block.HashTreeRoot()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
peerStatus.Add(new(enr.Record), p.PeerID(), nil, network.DirOutbound)
|
|
|
|
peerStatus.SetConnectionState(p.PeerID(), peers.PeerConnected)
|
2021-12-07 17:52:39 +00:00
|
|
|
peerStatus.SetChainState(p.PeerID(), ðpb.Status{
|
2020-11-05 07:27:46 +00:00
|
|
|
ForkDigest: params.BeaconConfig().GenesisForkVersion,
|
|
|
|
FinalizedRoot: []byte(fmt.Sprintf("finalized_root %d", finalizedEpoch)),
|
|
|
|
FinalizedEpoch: finalizedEpoch,
|
|
|
|
HeadRoot: headRoot[:],
|
|
|
|
HeadSlot: blocks[len(blocks)-1].Block.Slot,
|
|
|
|
})
|
|
|
|
|
|
|
|
return p.PeerID()
|
|
|
|
}
|