Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure Beacon Chain RPC Servers Into Subpackages #3975

Merged
merged 71 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
b3714e8
Update seed domains (#3872)
terencechain Oct 29, 2019
8eebd52
Remove Transfers (#3870)
terencechain Oct 29, 2019
b6645d6
Remove active index roots and compact committee roots (#3869)
terencechain Oct 30, 2019
cf169c8
Update inclusion reward (#3886)
terencechain Oct 30, 2019
6294037
Alter proposer selection logic (#3884)
terencechain Oct 30, 2019
d2f4b2b
Fix early committee bias (#3888)
terencechain Oct 30, 2019
c864627
Remove shards and committees (#3896)
terencechain Oct 31, 2019
2c88364
Epoch spec tests v0.9 (#3907)
terencechain Oct 31, 2019
acbc400
Block spec test v0.9 (#3905)
terencechain Nov 1, 2019
59f528f
Update deposit contract (#3906)
mcdee Nov 2, 2019
9bc9b91
Proto spec tests v0.9 (#3908)
terencechain Nov 2, 2019
2b87f39
Unskip block util tests (#3910)
terencechain Nov 2, 2019
064e963
Slot processing spec test V0.9 (#3912)
terencechain Nov 4, 2019
5d2f142
Unskip minimal spec test for finalization (#3920)
terencechain Nov 4, 2019
842a5ac
Remove outdated interop tests (#3922)
terencechain Nov 4, 2019
4e22ca2
Update validator to use proposer slot (#3919)
terencechain Nov 5, 2019
8617344
Fix committee assignment (#3931)
terencechain Nov 5, 2019
b20fc61
Replace shard with committee index (#3930)
terencechain Nov 5, 2019
03f2cb0
Conflict
terencechain Nov 6, 2019
6806e33
Conflict
terencechain Nov 6, 2019
a35da60
Clean up (#3933)
terencechain Nov 6, 2019
d5c2e0c
Remove shard filter in db (#3936)
terencechain Nov 6, 2019
4dab4c0
Merge branch 'master' into v0.9
terencechain Nov 6, 2019
53c4c18
Merge branch 'master' into v0.9
rauljordan Nov 6, 2019
45a88bb
Remove lightouse compatibility test (#3939)
terencechain Nov 6, 2019
a2814d6
Merge branch 'master' of https://github.com/prysmaticlabs/prysm into …
terencechain Nov 6, 2019
d27bd4e
Merge branch 'master' of github.com:prysmaticlabs/prysm into v0.9
prestonvanloon Nov 6, 2019
29b6d18
Merge branch 'master' of https://github.com/prysmaticlabs/prysm into …
terencechain Nov 6, 2019
4b4a761
Merge branch 'v0.9' of https://github.com/prysmaticlabs/prysm into v0.9
terencechain Nov 6, 2019
bb64762
Update Committee Cache for v0.9 (#3948)
terencechain Nov 7, 2019
1b1476b
Merge branch 'master' into v0.9
terencechain Nov 7, 2019
e6a487e
Merge branch 'master' of https://github.com/prysmaticlabs/prysm into …
terencechain Nov 8, 2019
ddd4149
Conflict
terencechain Nov 8, 2019
b925684
Safeguard against nil head state
terencechain Nov 8, 2019
bbe9908
address edge case
nisdas Nov 8, 2019
6bec964
add test
nisdas Nov 8, 2019
29237a5
Merge remote-tracking branch 'origin/syncRejectionFix' into v0.9
terencechain Nov 8, 2019
166dc3b
Fixed TestRoundRobinSync by doubling the epochs
terencechain Nov 8, 2019
ad1daa1
Merge branch 'master' of https://github.com/prysmaticlabs/prysm into …
terencechain Nov 8, 2019
df3f012
Unskip TestProtoCompatability (#3958)
terencechain Nov 8, 2019
ceddcf4
Fix minimal config (#3959)
prestonvanloon Nov 8, 2019
0438c52
Simplify verify att time (#3961)
terencechain Nov 9, 2019
e5ff555
Merge branch 'master' into v0.9
prestonvanloon Nov 10, 2019
4376e01
update readme for deposit contract, regen bindings for vyper 0.1.0b12…
prestonvanloon Nov 10, 2019
11cc97e
Check nil base state (#3964)
prestonvanloon Nov 10, 2019
4f2a781
Copy Block When Receiving it From Sync (#3966)
nisdas Nov 11, 2019
e2467ef
Change logging of Bitfield (#3956)
nisdas Nov 11, 2019
393e9b7
Merge branch 'master' into v0.9
rauljordan Nov 11, 2019
828046e
Unskip Beacon Server Test (#3962)
nisdas Nov 11, 2019
fce0fb4
Merge branch 'v0.9' of github.com:prysmaticlabs/prysm into v0.9
rauljordan Nov 11, 2019
d22319c
Merge branch 'master' into v0.9
prestonvanloon Nov 11, 2019
15a3da0
Merge branch 'v0.9' of github.com:prysmaticlabs/prysm into v0.9
rauljordan Nov 11, 2019
88893da
attester server split into subpackage
rauljordan Nov 11, 2019
780a130
attester impl split up successfully
rauljordan Nov 11, 2019
47d0b96
validator cleaned up
rauljordan Nov 11, 2019
16489aa
all packages isolated
rauljordan Nov 11, 2019
42a89b3
master sync
rauljordan Nov 11, 2019
70ab2c8
include proposer
rauljordan Nov 11, 2019
2beddda
proper naming
rauljordan Nov 11, 2019
386e90b
test fix
rauljordan Nov 11, 2019
018f2c6
proper viz
rauljordan Nov 11, 2019
f028119
naming
rauljordan Nov 11, 2019
1392f11
resolved timeout due to config values
rauljordan Nov 12, 2019
e9d3b05
init use minimal
rauljordan Nov 12, 2019
629320d
added all subfiles
rauljordan Nov 12, 2019
64a256c
subfile split and gazelle
rauljordan Nov 12, 2019
7526b5b
shards
rauljordan Nov 12, 2019
c5d1879
validator folder
rauljordan Nov 12, 2019
adf1dda
cleanup val
rauljordan Nov 12, 2019
a17b4ed
shay feedback
rauljordan Nov 12, 2019
89a7dcd
confs
rauljordan Nov 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 7 additions & 64 deletions beacon-chain/rpc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,108 +2,51 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"attester_server.go",
"beacon_chain_server.go",
"node_server.go",
"proposer_server.go",
"service.go",
"validator_server.go",
],
srcs = ["service.go"],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/blockchain:go_default_library",
"//beacon-chain/cache:go_default_library",
"//beacon-chain/cache/depositcache:go_default_library",
"//beacon-chain/core/blocks:go_default_library",
"//beacon-chain/core/epoch:go_default_library",
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/core/state:go_default_library",
"//beacon-chain/core/state/interop:go_default_library",
"//beacon-chain/core/validators:go_default_library",
"//beacon-chain/db:go_default_library",
"//beacon-chain/db/filters:go_default_library",
"//beacon-chain/operations:go_default_library",
"//beacon-chain/p2p:go_default_library",
"//beacon-chain/powchain:go_default_library",
"//beacon-chain/rpc/attester:go_default_library",
"//beacon-chain/rpc/beacon:go_default_library",
"//beacon-chain/rpc/node:go_default_library",
"//beacon-chain/rpc/proposer:go_default_library",
"//beacon-chain/rpc/validator:go_default_library",
"//beacon-chain/sync:go_default_library",
"//proto/beacon/p2p/v1:go_default_library",
"//proto/beacon/rpc/v1:go_default_library",
"//proto/eth/v1alpha1:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/hashutil:go_default_library",
"//shared/pagination:go_default_library",
"//shared/params:go_default_library",
"//shared/traceutil:go_default_library",
"//shared/trieutil:go_default_library",
"//shared/version:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library",
"@com_github_grpc_ecosystem_go_grpc_middleware//recovery:go_default_library",
"@com_github_grpc_ecosystem_go_grpc_middleware//tracing/opentracing:go_default_library",
"@com_github_grpc_ecosystem_go_grpc_prometheus//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@io_opencensus_go//plugin/ocgrpc:go_default_library",
"@io_opencensus_go//trace:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//credentials:go_default_library",
"@org_golang_google_grpc//reflection:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
],
)

go_test(
name = "go_default_test",
size = "medium",
srcs = [
"attester_server_test.go",
"beacon_chain_server_test.go",
"node_server_test.go",
"proposer_server_test.go",
"service_test.go",
"validator_server_test.go",
],
srcs = ["service_test.go"],
embed = [":go_default_library"],
deps = [
"//beacon-chain/blockchain/testing:go_default_library",
"//beacon-chain/cache:go_default_library",
"//beacon-chain/cache/depositcache:go_default_library",
"//beacon-chain/core/blocks:go_default_library",
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/core/state:go_default_library",
"//beacon-chain/db:go_default_library",
"//beacon-chain/db/testing:go_default_library",
"//beacon-chain/operations/testing:go_default_library",
"//beacon-chain/p2p/testing:go_default_library",
"//beacon-chain/powchain/testing:go_default_library",
"//beacon-chain/rpc/testing:go_default_library",
"//beacon-chain/sync/initial-sync/testing:go_default_library",
"//proto/beacon/p2p/v1:go_default_library",
"//proto/beacon/rpc/v1:go_default_library",
"//proto/eth/v1alpha1:go_default_library",
"//shared/bls:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/event:go_default_library",
"//shared/featureconfig:go_default_library",
"//shared/hashutil:go_default_library",
"//shared/params:go_default_library",
"//shared/testutil:go_default_library",
"//shared/trieutil:go_default_library",
"//shared/version:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//reflection:go_default_library",
],
)
49 changes: 49 additions & 0 deletions beacon-chain/rpc/attester/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = ["attester_server.go"],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/attester",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/blockchain:go_default_library",
"//beacon-chain/cache:go_default_library",
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/core/state:go_default_library",
"//beacon-chain/db:go_default_library",
"//beacon-chain/operations:go_default_library",
"//beacon-chain/p2p:go_default_library",
"//beacon-chain/sync:go_default_library",
"//proto/beacon/rpc/v1:go_default_library",
"//proto/eth/v1alpha1:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@io_opencensus_go//trace:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = ["attester_server_test.go"],
embed = [":go_default_library"],
deps = [
"//beacon-chain/blockchain/testing:go_default_library",
"//beacon-chain/cache:go_default_library",
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/db/testing:go_default_library",
"//beacon-chain/operations/testing:go_default_library",
"//beacon-chain/p2p/testing:go_default_library",
"//beacon-chain/sync/initial-sync/testing:go_default_library",
"//proto/beacon/p2p/v1:go_default_library",
"//proto/beacon/rpc/v1:go_default_library",
"//proto/eth/v1alpha1:go_default_library",
"//shared/featureconfig:go_default_library",
"//shared/params:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
],
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package rpc
package attester

import (
"context"
Expand All @@ -16,26 +16,33 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/sync"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

// AttesterServer defines a server implementation of the gRPC Attester service,
var log logrus.FieldLogger

func init() {
log = logrus.WithField("prefix", "rpc/attester")
}

// Server defines a server implementation of the gRPC Attester service,
// providing RPC methods for validators acting as attesters to broadcast votes on beacon blocks.
type AttesterServer struct {
p2p p2p.Broadcaster
beaconDB db.Database
operationsHandler operations.Handler
attReceiver blockchain.AttestationReceiver
headFetcher blockchain.HeadFetcher
attestationCache *cache.AttestationCache
syncChecker sync.Checker
type Server struct {
P2p p2p.Broadcaster
BeaconDB db.Database
OperationsHandler operations.Handler
AttReceiver blockchain.AttestationReceiver
HeadFetcher blockchain.HeadFetcher
AttestationCache *cache.AttestationCache
SyncChecker sync.Checker
}

// SubmitAttestation is a function called by an attester in a sharding validator to vote
// on a block via an attestation object as defined in the Ethereum Serenity specification.
func (as *AttesterServer) SubmitAttestation(ctx context.Context, att *ethpb.Attestation) (*pb.AttestResponse, error) {
func (as *Server) SubmitAttestation(ctx context.Context, att *ethpb.Attestation) (*pb.AttestResponse, error) {
root, err := ssz.HashTreeRoot(att.Data)
if err != nil {
return nil, errors.Wrap(err, "failed to hash tree root attestation")
Expand All @@ -44,11 +51,11 @@ func (as *AttesterServer) SubmitAttestation(ctx context.Context, att *ethpb.Atte
go func() {
ctx = trace.NewContext(context.Background(), trace.FromContext(ctx))
attCopy := proto.Clone(att).(*ethpb.Attestation)
if err := as.attReceiver.ReceiveAttestation(ctx, att); err != nil {
if err := as.AttReceiver.ReceiveAttestation(ctx, att); err != nil {
log.WithError(err).Error("could not receive attestation in chain service")
return
}
if err := as.operationsHandler.HandleAttestation(ctx, attCopy); err != nil {
if err := as.OperationsHandler.HandleAttestation(ctx, attCopy); err != nil {
log.WithError(err).Error("could not handle attestation in operations service")
return
}
Expand All @@ -59,19 +66,19 @@ func (as *AttesterServer) SubmitAttestation(ctx context.Context, att *ethpb.Atte

// RequestAttestation requests that the beacon node produce an IndexedAttestation,
// with a blank signature field, which the validator will then sign.
func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.AttestationRequest) (*ethpb.AttestationData, error) {
func (as *Server) RequestAttestation(ctx context.Context, req *pb.AttestationRequest) (*ethpb.AttestationData, error) {
ctx, span := trace.StartSpan(ctx, "AttesterServer.RequestAttestation")
defer span.End()
span.AddAttributes(
trace.Int64Attribute("slot", int64(req.Slot)),
trace.Int64Attribute("committeeIndex", int64(req.CommitteeIndex)),
)

if as.syncChecker.Syncing() {
if as.SyncChecker.Syncing() {
return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond")
}

res, err := as.attestationCache.Get(ctx, req)
res, err := as.AttestationCache.Get(ctx, req)
if err != nil {
return nil, err
}
Expand All @@ -80,9 +87,9 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest
return res, nil
}

if err := as.attestationCache.MarkInProgress(req); err != nil {
if err := as.AttestationCache.MarkInProgress(req); err != nil {
if err == cache.ErrAlreadyInProgress {
res, err := as.attestationCache.Get(ctx, req)
res, err := as.AttestationCache.Get(ctx, req)
if err != nil {
return nil, err
}
Expand All @@ -95,17 +102,25 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest
return nil, err
}
defer func() {
if err := as.attestationCache.MarkNotInProgress(req); err != nil {
if err := as.AttestationCache.MarkNotInProgress(req); err != nil {
log.WithError(err).Error("Failed to mark cache not in progress")
}
}()

headState := as.headFetcher.HeadState()
headRoot := as.headFetcher.HeadRoot()
headState := as.HeadFetcher.HeadState()
headRoot := as.HeadFetcher.HeadRoot()

// Safe guard against head state is nil in chain service. This should not happen.
if headState == nil {
headState, err = as.BeaconDB.HeadState(ctx)
if err != nil {
return nil, err
}
}

// Safe guard against head state is nil in chain service. This should not happen.
if headState == nil {
headState, err = as.beaconDB.HeadState(ctx)
headState, err = as.BeaconDB.HeadState(ctx)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -139,7 +154,7 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest
},
}

if err := as.attestationCache.Put(ctx, req, res); err != nil {
if err := as.AttestationCache.Put(ctx, req, res); err != nil {
return nil, err
}

Expand Down
Loading