Skip to content

Commit

Permalink
Resolve Misc v0.11 Items (Raul) (#5414)
Browse files Browse the repository at this point in the history
* address all comments

* set faucet

* nishant feedback

* Update beacon-chain/p2p/service.go

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
rauljordan and prylabs-bulldozer[bot] authored Apr 14, 2020
1 parent de7195c commit 0a64620
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 84 deletions.
1 change: 0 additions & 1 deletion beacon-chain/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ func (b *BeaconNode) registerP2P(ctx *cli.Context) error {
}

svc, err := p2p.NewService(&p2p.Config{
BeaconDB: b.db,
NoDiscovery: ctx.Bool(cmd.NoDiscovery.Name),
StaticPeers: sliceutil.SplitCommaSeparated(ctx.StringSlice(cmd.StaticPeers.Name)),
BootstrapNodeAddr: bootnodeAddrs,
Expand Down
1 change: 0 additions & 1 deletion beacon-chain/p2p/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ go_library(
"//beacon-chain/core/feed:go_default_library",
"//beacon-chain/core/feed/state:go_default_library",
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/db:go_default_library",
"//beacon-chain/p2p/connmgr:go_default_library",
"//beacon-chain/p2p/encoder:go_default_library",
"//beacon-chain/p2p/peers:go_default_library",
Expand Down
2 changes: 0 additions & 2 deletions beacon-chain/p2p/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package p2p

import (
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
"github.com/prysmaticlabs/prysm/beacon-chain/db"
)

// Config for the p2p service. These parameters are set from application level flags
// to initialize the p2p service.
type Config struct {
BeaconDB db.ReadOnlyDatabase
NoDiscovery bool
EnableUPnP bool
DisableDiscv5 bool
Expand Down
1 change: 0 additions & 1 deletion beacon-chain/p2p/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ func TestStaticPeering_PeersAreAdded(t *testing.T) {
cfg.TCPPort = 14500
cfg.UDPPort = 14501
cfg.StaticPeers = staticPeers
cfg.BeaconDB = db
cfg.StateNotifier = &mock.MockStateNotifier{}
s, err := NewService(cfg)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions beacon-chain/p2p/fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func TestStartDiscv5_DifferentForkDigests(t *testing.T) {
// bootnode given all nodes provided by discv5 will have different fork digests.
cfg.UDPPort = 14000
cfg.TCPPort = 14001
cfg.BeaconDB = db
s, err := NewService(cfg)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -176,7 +175,6 @@ func TestStartDiscv5_SameForkDigests_DifferentNextForkData(t *testing.T) {
// bootnode given all nodes provided by discv5 will have different fork digests.
cfg.UDPPort = 14000
cfg.TCPPort = 14001
cfg.BeaconDB = db
params.OverrideBeaconConfig(originalBeaconConfig)
s, err := NewService(cfg)
if err != nil {
Expand Down
21 changes: 4 additions & 17 deletions beacon-chain/p2p/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@ import (
ma "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/sirupsen/logrus"
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed"
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/db"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/runutil"
"github.com/prysmaticlabs/prysm/shared/sliceutil"
"github.com/sirupsen/logrus"
)

var _ = shared.Service(&Service{})
Expand Down Expand Up @@ -70,7 +69,6 @@ type Service struct {
exclusionList *ristretto.Cache
metaData *pb.MetaData
pubsub *pubsub.PubSub
beaconDB db.ReadOnlyDatabase
dv5Listener Listener
startupErr error
stateNotifier statefeed.Notifier
Expand All @@ -95,7 +93,6 @@ func NewService(cfg *Config) (*Service, error) {
}

s := &Service{
beaconDB: cfg.BeaconDB,
ctx: ctx,
stateNotifier: cfg.StateNotifier,
cancel: cancel,
Expand Down Expand Up @@ -176,18 +173,8 @@ func (s *Service) Start() {
}

// Waits until the state is initialized via an event feed.
// Check if we have a genesis time / genesis state
// used for fork-related data when connecting peers.
genesisState, err := s.beaconDB.GenesisState(s.ctx)
if err != nil {
log.WithError(err).Error("Could not read genesis state")
}
if genesisState != nil {
s.genesisTime = time.Unix(int64(genesisState.GenesisTime()), 0)
s.genesisValidatorsRoot = genesisState.GenesisValidatorRoot()
} else {
s.awaitStateInitialized()
}
// Used for fork-related data when connecting peers.
s.awaitStateInitialized()
s.isPreGenesis = false

var peersToWatch []string
Expand Down
2 changes: 0 additions & 2 deletions beacon-chain/p2p/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func TestService_Start_OnlyStartsOnce(t *testing.T) {
TCPPort: 2000,
UDPPort: 2000,
Encoding: "ssz",
BeaconDB: db,
}
s, err := NewService(cfg)
if err != nil {
Expand Down Expand Up @@ -211,7 +210,6 @@ func TestListenForNewNodes(t *testing.T) {

cfg.UDPPort = 14000
cfg.TCPPort = 14001
cfg.BeaconDB = db

s, err := NewService(cfg)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion beacon-chain/p2p/subnets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func TestStartDiscV5_DiscoverPeersWithSubnets(t *testing.T) {
// Make one service on port 3001.
port = 4000
cfg := &Config{
BeaconDB: db,
BootstrapNodeAddr: []string{bootNode.String()},
Discv5BootStrapAddr: []string{bootNode.String()},
Encoding: "ssz",
Expand Down
16 changes: 9 additions & 7 deletions beacon-chain/sync/subscriber_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package sync

import (
"context"
"errors"
"fmt"

"github.com/gogo/protobuf/proto"
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
Expand Down Expand Up @@ -37,16 +37,17 @@ func (r *Service) attesterSlashingSubscriber(ctx context.Context, msg proto.Mess
}
// Do some nil checks to prevent easy DoS'ing of this handler.
if as != nil && as.Attestation_1 != nil && as.Attestation_1.Data != nil {
r.setAttesterSlashingIndicesSeen(as.Attestation_1.AttestingIndices, as.Attestation_2.AttestingIndices)

s, err := r.db.State(ctx, bytesutil.ToBytes32(as.Attestation_1.Data.BeaconBlockRoot))
if err != nil {
return err
}
if s == nil {
return fmt.Errorf("no state found for block root %#x", as.Attestation_1.Data.BeaconBlockRoot)
}
return r.slashingPool.InsertAttesterSlashing(ctx, s, as)
if err := r.slashingPool.InsertAttesterSlashing(ctx, s, as); err != nil {
return errors.Wrap(err, "could not insert attester slashing into pool")
}
r.setAttesterSlashingIndicesSeen(as.Attestation_1.AttestingIndices, as.Attestation_2.AttestingIndices)
}
return nil
}
Expand All @@ -58,8 +59,6 @@ func (r *Service) proposerSlashingSubscriber(ctx context.Context, msg proto.Mess
}
// Do some nil checks to prevent easy DoS'ing of this handler.
if ps.Header_1 != nil && ps.Header_1.Header != nil {
r.setProposerSlashingIndexSeen(ps.Header_1.Header.ProposerIndex)

root, err := ssz.HashTreeRoot(ps.Header_1.Header)
s, err := r.db.State(ctx, root)
if err != nil {
Expand All @@ -68,7 +67,10 @@ func (r *Service) proposerSlashingSubscriber(ctx context.Context, msg proto.Mess
if s == nil {
return fmt.Errorf("no state found for block root %#x", root)
}
return r.slashingPool.InsertProposerSlashing(ctx, s, ps)
if err := r.slashingPool.InsertProposerSlashing(ctx, s, ps); err != nil {
return errors.Wrap(err, "could not insert proposer slashing into pool")
}
r.setProposerSlashingIndexSeen(ps.Header_1.Header.ProposerIndex)
}
return nil
}
49 changes: 0 additions & 49 deletions third_party/herumi/bls_eth_go_binary_serialization_alloc_fix.patch

This file was deleted.

10 changes: 9 additions & 1 deletion tools/faucet/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

const ipLimit = 5

var fundingAmount = big.NewInt(32.5 * params.Ether)
var fundingAmount *big.Int
var funded = make(map[string]bool)
var ipCounter = make(map[string]int)
var fundingLock sync.Mutex
Expand All @@ -38,6 +38,14 @@ type faucetServer struct {
minScore float64
}

func init() {
var ok bool
fundingAmount, ok = new(big.Int).SetString("32500000000000000000", 10)
if !ok {
log.Fatal("could not set funding amount")
}
}

func newFaucetServer(
r recaptcha.Recaptcha,
rpcPath string,
Expand Down

0 comments on commit 0a64620

Please sign in to comment.