diff --git a/beacon-chain/node/node.go b/beacon-chain/node/node.go index cc879627f178..4709b9699686 100644 --- a/beacon-chain/node/node.go +++ b/beacon-chain/node/node.go @@ -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, diff --git a/beacon-chain/p2p/BUILD.bazel b/beacon-chain/p2p/BUILD.bazel index b0c2c8d0c8c4..5b15a220513f 100644 --- a/beacon-chain/p2p/BUILD.bazel +++ b/beacon-chain/p2p/BUILD.bazel @@ -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", diff --git a/beacon-chain/p2p/config.go b/beacon-chain/p2p/config.go index f6c3f88b227d..c325b6e68f52 100644 --- a/beacon-chain/p2p/config.go +++ b/beacon-chain/p2p/config.go @@ -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 diff --git a/beacon-chain/p2p/discovery_test.go b/beacon-chain/p2p/discovery_test.go index 8f6605ee9912..053beec25262 100644 --- a/beacon-chain/p2p/discovery_test.go +++ b/beacon-chain/p2p/discovery_test.go @@ -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 { diff --git a/beacon-chain/p2p/fork_test.go b/beacon-chain/p2p/fork_test.go index 8fb291d94c1b..dc4846773d67 100644 --- a/beacon-chain/p2p/fork_test.go +++ b/beacon-chain/p2p/fork_test.go @@ -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) @@ -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 { diff --git a/beacon-chain/p2p/service.go b/beacon-chain/p2p/service.go index 77948b6e97b0..1578d336a5f3 100644 --- a/beacon-chain/p2p/service.go +++ b/beacon-chain/p2p/service.go @@ -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{}) @@ -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 @@ -95,7 +93,6 @@ func NewService(cfg *Config) (*Service, error) { } s := &Service{ - beaconDB: cfg.BeaconDB, ctx: ctx, stateNotifier: cfg.StateNotifier, cancel: cancel, @@ -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 diff --git a/beacon-chain/p2p/service_test.go b/beacon-chain/p2p/service_test.go index d3ca30e7ec1f..e20e63f64e66 100644 --- a/beacon-chain/p2p/service_test.go +++ b/beacon-chain/p2p/service_test.go @@ -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 { @@ -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 { diff --git a/beacon-chain/p2p/subnets_test.go b/beacon-chain/p2p/subnets_test.go index 205238a6b5e6..ca3236de72d9 100644 --- a/beacon-chain/p2p/subnets_test.go +++ b/beacon-chain/p2p/subnets_test.go @@ -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", diff --git a/beacon-chain/sync/subscriber_handlers.go b/beacon-chain/sync/subscriber_handlers.go index 55600994b014..6bf5c596d5db 100644 --- a/beacon-chain/sync/subscriber_handlers.go +++ b/beacon-chain/sync/subscriber_handlers.go @@ -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" @@ -37,8 +37,6 @@ 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 @@ -46,7 +44,10 @@ func (r *Service) attesterSlashingSubscriber(ctx context.Context, msg proto.Mess 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 } @@ -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 { @@ -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 } diff --git a/third_party/herumi/bls_eth_go_binary_serialization_alloc_fix.patch b/third_party/herumi/bls_eth_go_binary_serialization_alloc_fix.patch deleted file mode 100644 index 202fcdc85469..000000000000 --- a/third_party/herumi/bls_eth_go_binary_serialization_alloc_fix.patch +++ /dev/null @@ -1,49 +0,0 @@ -diff --git a/bls/bls.go b/bls/bls.go -index bc3b607..f6fa95f 100644 ---- a/bls/bls.go -+++ b/bls/bls.go -@@ -157,7 +157,7 @@ type SecretKey struct { - - // Serialize -- - func (sec *SecretKey) Serialize() []byte { -- buf := make([]byte, 2048) -+ buf := make([]byte, 32) - // #nosec - n := C.blsSecretKeySerialize(unsafe.Pointer(&buf[0]), C.mclSize(len(buf)), &sec.v) - if n == 0 { -@@ -354,7 +354,7 @@ func (keys PublicKeys) JSON() string { - - // Serialize -- - func (pub *PublicKey) Serialize() []byte { -- buf := make([]byte, 2048) -+ buf := make([]byte, 48) - // #nosec - n := C.blsPublicKeySerialize(unsafe.Pointer(&buf[0]), C.mclSize(len(buf)), &pub.v) - if n == 0 { -@@ -452,7 +452,7 @@ type Sign struct { - - // Serialize -- - func (sig *Sign) Serialize() []byte { -- buf := make([]byte, 2048) -+ buf := make([]byte, 96) - // #nosec - n := C.blsSignatureSerialize(unsafe.Pointer(&buf[0]), C.mclSize(len(buf)), &sig.v) - if n == 0 { -@@ -665,7 +665,7 @@ func (sig *Sign) VerifyHashWithDomain(pub *PublicKey, hashWithDomain []byte) boo - - // SerializeUncompressed -- - func (pub *PublicKey) SerializeUncompressed() []byte { -- buf := make([]byte, 2048) -+ buf := make([]byte, 96) - // #nosec - n := C.blsPublicKeySerializeUncompressed(unsafe.Pointer(&buf[0]), C.mclSize(len(buf)), &pub.v) - if n == 0 { -@@ -676,7 +676,7 @@ func (pub *PublicKey) SerializeUncompressed() []byte { - - // SerializeUncompressed -- - func (sig *Sign) SerializeUncompressed() []byte { -- buf := make([]byte, 2048) -+ buf := make([]byte, 192) - // #nosec - n := C.blsSignatureSerializeUncompressed(unsafe.Pointer(&buf[0]), C.mclSize(len(buf)), &sig.v) - if n == 0 { diff --git a/tools/faucet/server.go b/tools/faucet/server.go index 0470e5a2780f..aed1730b057c 100644 --- a/tools/faucet/server.go +++ b/tools/faucet/server.go @@ -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 @@ -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,