Skip to content

Commit

Permalink
Merge branch 'master' into pCli
Browse files Browse the repository at this point in the history
  • Loading branch information
nisdas authored Apr 27, 2020
2 parents 1b460d6 + eb5513f commit a6241a3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ go_repository(

go_repository(
name = "com_github_prysmaticlabs_ethereumapis",
commit = "1c66911b2ef3c1a290abb2156bcecb33ac32725f",
commit = "ba9042096e9fc49606279513d3e24e5e8cdbd5a0",
importpath = "github.com/prysmaticlabs/ethereumapis",
)

Expand Down
1 change: 1 addition & 0 deletions beacon-chain/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ func (b *BeaconNode) registerRPCService(ctx *cli.Context) error {
BlockReceiver: chainService,
AttestationReceiver: chainService,
GenesisTimeFetcher: chainService,
GenesisFetcher: chainService,
AttestationsPool: b.attestationPool,
ExitPool: b.exitPool,
SlashingsPool: b.slashingsPool,
Expand Down
2 changes: 2 additions & 0 deletions beacon-chain/rpc/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ go_test(
"//beacon-chain/db/testing:go_default_library",
"//beacon-chain/p2p/testing:go_default_library",
"//beacon-chain/sync/initial-sync/testing:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/testutil:go_default_library",
"//shared/version:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
Expand Down
3 changes: 3 additions & 0 deletions beacon-chain/rpc/node/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Server struct {
BeaconDB db.ReadOnlyDatabase
PeersFetcher p2p.PeersProvider
GenesisTimeFetcher blockchain.TimeFetcher
GenesisFetcher blockchain.GenesisFetcher
}

// GetSyncStatus checks the current network sync status of the node.
Expand All @@ -47,9 +48,11 @@ func (ns *Server) GetGenesis(ctx context.Context, _ *ptypes.Empty) (*ethpb.Genes
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not convert genesis time to proto: %v", err)
}
genValRoot := ns.GenesisFetcher.GenesisValidatorRoot()
return &ethpb.Genesis{
GenesisTime: gt,
DepositContractAddress: contractAddr,
GenesisValidatorsRoot: genValRoot[:],
}, nil
}

Expand Down
11 changes: 11 additions & 0 deletions beacon-chain/rpc/node/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
mockP2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/version"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
Expand Down Expand Up @@ -48,9 +50,15 @@ func TestNodeServer_GetGenesis(t *testing.T) {
if err := db.SaveDepositContractAddress(ctx, addr); err != nil {
t.Fatal(err)
}
st := testutil.NewBeaconState()
genValRoot := bytesutil.ToBytes32([]byte("I am root"))
ns := &Server{
BeaconDB: db,
GenesisTimeFetcher: &mock.ChainService{Genesis: time.Unix(0, 0)},
GenesisFetcher: &mock.ChainService{
State: st,
ValidatorsRoot: genValRoot,
},
}
res, err := ns.GetGenesis(context.Background(), &ptypes.Empty{})
if err != nil {
Expand All @@ -66,6 +74,9 @@ func TestNodeServer_GetGenesis(t *testing.T) {
if !res.GenesisTime.Equal(pUnix) {
t.Errorf("Wanted GenesisTime() = %v, received %v", pUnix, res.GenesisTime)
}
if !bytes.Equal(genValRoot[:], res.GenesisValidatorsRoot) {
t.Errorf("Wanted GenesisValidatorsRoot = %v, received %v", genValRoot, res.GenesisValidatorsRoot)
}
}

func TestNodeServer_GetVersion(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions beacon-chain/rpc/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type Service struct {
finalizationFetcher blockchain.FinalizationFetcher
participationFetcher blockchain.ParticipationFetcher
genesisTimeFetcher blockchain.TimeFetcher
genesisFetcher blockchain.GenesisFetcher
attestationReceiver blockchain.AttestationReceiver
blockReceiver blockchain.BlockReceiver
powChainService powchain.Chain
Expand Down Expand Up @@ -108,6 +109,7 @@ type Config struct {
POWChainService powchain.Chain
ChainStartFetcher powchain.ChainStartFetcher
GenesisTimeFetcher blockchain.TimeFetcher
GenesisFetcher blockchain.GenesisFetcher
MockEth1Votes bool
AttestationsPool attestations.Pool
ExitPool *voluntaryexits.Pool
Expand Down Expand Up @@ -138,6 +140,7 @@ func NewService(ctx context.Context, cfg *Config) *Service {
finalizationFetcher: cfg.FinalizationFetcher,
participationFetcher: cfg.ParticipationFetcher,
genesisTimeFetcher: cfg.GenesisTimeFetcher,
genesisFetcher: cfg.GenesisFetcher,
attestationReceiver: cfg.AttestationReceiver,
blockReceiver: cfg.BlockReceiver,
p2p: cfg.Broadcaster,
Expand Down Expand Up @@ -241,6 +244,7 @@ func (s *Service) Start() {
SyncChecker: s.syncService,
GenesisTimeFetcher: s.genesisTimeFetcher,
PeersFetcher: s.peersFetcher,
GenesisFetcher: s.genesisFetcher,
}
beaconChainServer := &beacon.Server{
Ctx: s.ctx,
Expand Down

0 comments on commit a6241a3

Please sign in to comment.