mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
78a25f99c3
* Update fastssz * Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz * fmt * gaz * Merge refs/heads/master into update-fssz * goimports * Merge refs/heads/master into update-fssz * Merge refs/heads/master into update-fssz * Merge refs/heads/master into update-fssz * Merge refs/heads/master into update-fssz * Merge refs/heads/master into update-fssz * Fix * fix ethereumapis * fix again * kafka * fix gen file * fix compute signing root * gofmt * checkpoint progress * progress * checkpoint * progress * Fix build * checkpoint * helpers * Another test fixed * gaz * another test fix * gofmt * some fixes * Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz * fix one test * Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz * fill empty checkpoint roots * more padding * more padding * Fix //beacon-chain/rpc/debug:go_default_test * fix //beacon-chain/core/state:go_default_test * fix //beacon-chain/core/state:go_default_test * fix some htr errors * fix //slasher/rpc:go_default_test * Progress on //beacon-chain/core/blocks:go_default_test * Progress on //beacon-chain/core/blocks:go_default_test * Progress on //beacon-chain/core/blocks:go_default_test * fix //slasher/db/kv:go_default_test * progress * fix //beacon-chain/sync/initial-sync:go_raceon_test * gofmt and gaz * fix one more test, taking a break * Fix //beacon-chain/core/blocks:go_default_test * Complete beacon-chain/powchain * Do most of beacon-chain/rpc/beacon/ * Do most of beacon-chain/blockchain * fix //beacon-chain/operations/attestations/kv:go_default_test * Fix //beacon-chain/cache/depositcache:go_default_test * Fix //slasher/detection:go_default_test * Progress * fix //beacon-chain/rpc/validator:go_default_test * gofmt * fix //validator/client:go_default_test * fix * fix //beacon-chain/blockchain:go_raceoff_test * fix //beacon-chain/rpc/beacon:go_default_test * fix 1 of 4 shards in //beacon-chain/sync:go_default_test * Fix //beacon-chain/sync:go_default_test and gofmt * prevent panic * fix //beacon-chain/state/stategen:go_default_test * fix * Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz * fix most tests * Self review, go mod tidy, run regen scripts * fix slasher * Update ethereumapis * disable spawn strategy override * Merge refs/heads/master into update-fssz * Merge refs/heads/master into update-fssz * Remove extra line in imports * Remove extra line in imports * Gofmt * PR feedback from @nisdas
87 lines
2.4 KiB
Go
87 lines
2.4 KiB
Go
package fuzz
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/libp2p/go-libp2p"
|
|
"github.com/libp2p/go-libp2p-core/host"
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
"github.com/pkg/errors"
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
|
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
var p *p2p.Service
|
|
var h host.Host
|
|
|
|
func init() {
|
|
logrus.SetLevel(logrus.PanicLevel)
|
|
|
|
var err error
|
|
p, err = p2p.NewService(&p2p.Config{
|
|
NoDiscovery: true,
|
|
})
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "could not create new p2p service"))
|
|
}
|
|
|
|
h, err = libp2p.New(context.Background())
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "could not create new libp2p host"))
|
|
}
|
|
|
|
info := peer.AddrInfo{
|
|
ID: h.ID(),
|
|
Addrs: h.Addrs(),
|
|
}
|
|
if err := p.Connect(info); err != nil {
|
|
panic(errors.Wrap(err, "could not connect to peer"))
|
|
}
|
|
sync.NewRegularSync(&sync.Config{
|
|
P2P: p,
|
|
DB: nil,
|
|
AttPool: nil,
|
|
ExitPool: nil,
|
|
SlashingPool: nil,
|
|
Chain: &mock.ChainService{
|
|
Root: bytesutil.PadTo([]byte("root"), 32),
|
|
FinalizedCheckPoint: ðpb.Checkpoint{Epoch: 4, Root: make([]byte, 32)},
|
|
Fork: &pb.Fork{CurrentVersion: []byte("foo")},
|
|
},
|
|
StateNotifier: (&mock.ChainService{}).StateNotifier(),
|
|
AttestationNotifier: (&mock.ChainService{}).OperationNotifier(),
|
|
InitialSync: &mockSync.Sync{IsSyncing: false},
|
|
StateSummaryCache: cache.NewStateSummaryCache(),
|
|
BlockNotifier: nil,
|
|
})
|
|
}
|
|
|
|
// BeaconFuzzP2PRPCStatus implements libfuzzer and beacon fuzz interface.
|
|
func BeaconFuzzP2PRPCStatus(b []byte) {
|
|
s, err := h.NewStream(context.Background(), p.PeerID(), "/eth2/beacon_chain/req/status/1/ssz_snappy")
|
|
if err != nil {
|
|
// libp2p ¯\_(ツ)_/¯
|
|
if strings.Contains(err.Error(), "stream reset") || strings.Contains(err.Error(), "connection reset by peer") || strings.Contains(err.Error(), "max dial attempts exceeded") {
|
|
return
|
|
}
|
|
panic(errors.Wrap(err, "failed to open stream"))
|
|
}
|
|
if s == nil {
|
|
panic("nil stream")
|
|
}
|
|
defer func() {
|
|
err := s.Close()
|
|
_ = err
|
|
}()
|
|
_, err = s.Write(b)
|
|
_ = err
|
|
}
|