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

Block rewards API endpoint #12020

Merged
merged 56 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
e4c68a9
in progress
rkapka Feb 6, 2023
a5c71fa
block rewards
rkapka Feb 16, 2023
d68bfea
calculate rewards
rkapka Feb 20, 2023
5e54368
Merge branch '__develop' into block-rewards
rkapka Feb 20, 2023
e645cea
remove file
rkapka Feb 20, 2023
3d4d380
revert precompute changes
rkapka Feb 20, 2023
41c5886
use replayer
rkapka Feb 21, 2023
6279b59
rename import
rkapka Feb 21, 2023
f781ca5
tests
rkapka Feb 21, 2023
5b3ddb1
Merge branch '__develop' into block-rewards
rkapka Feb 21, 2023
470996d
fix gateway tests
rkapka Feb 21, 2023
8269bc8
fix test
rkapka Feb 23, 2023
99196cf
Merge branch 'develop' into block-rewards
rkapka Feb 23, 2023
e68ba20
gzl
rkapka Feb 23, 2023
14bf9be
Merge branch '__develop' into block-rewards
rkapka Mar 1, 2023
95989cf
tests in progress
rkapka Mar 1, 2023
6e5c6bc
simplify tests
rkapka Mar 1, 2023
b305969
correct tests
rkapka Mar 1, 2023
7d20017
make router an option
rkapka Mar 2, 2023
89a00a2
mock
rkapka Mar 3, 2023
8af14db
test in progress
rkapka Mar 16, 2023
9bac92a
complete test
rkapka Mar 20, 2023
e33f79a
Merge branch '__develop' into block-rewards
rkapka Mar 20, 2023
9cd5c2b
gzl
rkapka Mar 20, 2023
0d649e7
import fix
rkapka Mar 20, 2023
dc717a3
import fix once more
rkapka Mar 20, 2023
eb4a48e
remove unused function
rkapka Mar 21, 2023
dd00547
fix all tests
rkapka Mar 21, 2023
53c8367
bzl
rkapka Mar 21, 2023
79a9265
Merge branch '__develop' into block-rewards
rkapka Mar 21, 2023
104f21e
Merge branch 'develop' into block-rewards
rkapka Mar 21, 2023
075b00a
handle err
rkapka Mar 21, 2023
ea22caf
review feedback
rkapka Mar 22, 2023
b1ab585
move state fetcher to lookup package
rkapka Mar 22, 2023
28c16ef
rename types
rkapka Mar 22, 2023
5296367
rename files
rkapka Mar 22, 2023
4d49ad8
move blockfetcher to lookup package
rkapka Mar 22, 2023
a1d973a
rename types
rkapka Mar 22, 2023
9788b21
rename files
rkapka Mar 22, 2023
09c1b19
Merge branch 'develop' into block-rewards
rkapka Mar 22, 2023
589b6e0
rename fields
rkapka Mar 22, 2023
6d4f32b
rename http to writer
rkapka Mar 22, 2023
5da7972
Merge branch 'develop' into block-rewards
terencechain Mar 24, 2023
afc3170
Kasey's feedback
rkapka Mar 24, 2023
9ab0111
Merge branch '__develop' into block-rewards
rkapka Mar 24, 2023
d2393a4
Merge remote-tracking branch 'origin/block-rewards' into block-rewards
rkapka Mar 24, 2023
613985d
Merge branch 'develop' into block-rewards
rkapka Mar 24, 2023
534367b
deepsource issues
rkapka Mar 24, 2023
3aca925
Merge refs/heads/develop into block-rewards
prylabs-bulldozer[bot] Mar 24, 2023
09b4533
Merge refs/heads/develop into block-rewards
prylabs-bulldozer[bot] Mar 27, 2023
ca85533
Merge refs/heads/develop into block-rewards
prylabs-bulldozer[bot] Mar 28, 2023
a101ef2
register endpoint
rkapka Mar 28, 2023
874fb41
initialize blocker
rkapka Mar 28, 2023
96aef48
Merge branch 'develop' into block-rewards
rkapka Mar 28, 2023
b0064fb
test fix
rkapka Mar 28, 2023
f17430a
test fix
rkapka Mar 28, 2023
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
7 changes: 4 additions & 3 deletions api/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@ type Gateway struct {
func New(ctx context.Context, opts ...Option) (*Gateway, error) {
g := &Gateway{
ctx: ctx,
cfg: &config{
router: mux.NewRouter(),
},
cfg: &config{},
}
for _, opt := range opts {
if err := opt(g); err != nil {
return nil, err
}
}
if g.cfg.router == nil {
g.cfg.router = mux.NewRouter()
}
return g, nil
}

Expand Down
5 changes: 0 additions & 5 deletions api/gateway/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import (

type Option func(g *Gateway) error

func (g *Gateway) SetRouter(r *mux.Router) *Gateway {
g.cfg.router = r
return g
}

func WithPbHandlers(handlers []*PbMux) Option {
return func(g *Gateway) error {
g.cfg.pbHandlers = handlers
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ go_library(
"//runtime/prereqs:go_default_library",
"//runtime/version:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
"@com_github_gorilla_mux//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prysmaticlabs_fastssz//:go_default_library",
Expand Down
12 changes: 8 additions & 4 deletions beacon-chain/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"syscall"

"github.com/ethereum/go-ethereum/common"
"github.com/gorilla/mux"
"github.com/pkg/errors"
apigateway "github.com/prysmaticlabs/prysm/v4/api/gateway"
"github.com/prysmaticlabs/prysm/v4/async/event"
Expand Down Expand Up @@ -253,12 +254,13 @@ func New(cliCtx *cli.Context, opts ...Option) (*BeaconNode, error) {
}

log.Debugln("Registering RPC Service")
if err := beacon.registerRPCService(); err != nil {
router := mux.NewRouter()
if err := beacon.registerRPCService(router); err != nil {
return nil, err
}

log.Debugln("Registering GRPC Gateway Service")
if err := beacon.registerGRPCGateway(); err != nil {
if err := beacon.registerGRPCGateway(router); err != nil {
return nil, err
}

Expand Down Expand Up @@ -734,7 +736,7 @@ func (b *BeaconNode) registerSlasherService() error {
return b.services.RegisterService(slasherSrv)
}

func (b *BeaconNode) registerRPCService() error {
func (b *BeaconNode) registerRPCService(router *mux.Router) error {
var chainService *blockchain.Service
if err := b.services.FetchService(&chainService); err != nil {
return err
Expand Down Expand Up @@ -830,6 +832,7 @@ func (b *BeaconNode) registerRPCService() error {
MaxMsgSize: maxMsgSize,
ProposerIdsCache: b.proposerIdsCache,
BlockBuilder: b.fetchBuilderService(),
Router: router,
})

return b.services.RegisterService(rpcService)
Expand Down Expand Up @@ -858,7 +861,7 @@ func (b *BeaconNode) registerPrometheusService(_ *cli.Context) error {
return b.services.RegisterService(service)
}

func (b *BeaconNode) registerGRPCGateway() error {
func (b *BeaconNode) registerGRPCGateway(router *mux.Router) error {
if b.cliCtx.Bool(flags.DisableGRPCGateway.Name) {
return nil
}
Expand All @@ -884,6 +887,7 @@ func (b *BeaconNode) registerGRPCGateway() error {
}

opts := []apigateway.Option{
apigateway.WithRouter(router),
apigateway.WithGatewayAddr(gatewayAddress),
apigateway.WithRemoteAddr(selfAddress),
apigateway.WithPbHandlers(muxs),
Expand Down
5 changes: 4 additions & 1 deletion beacon-chain/rpc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ go_library(
"//beacon-chain/rpc/eth/debug:go_default_library",
"//beacon-chain/rpc/eth/events:go_default_library",
"//beacon-chain/rpc/eth/node:go_default_library",
"//beacon-chain/rpc/eth/rewards:go_default_library",
"//beacon-chain/rpc/eth/validator:go_default_library",
"//beacon-chain/rpc/lookup:go_default_library",
"//beacon-chain/rpc/prysm/v1alpha1/beacon:go_default_library",
"//beacon-chain/rpc/prysm/v1alpha1/debug:go_default_library",
"//beacon-chain/rpc/prysm/v1alpha1/node:go_default_library",
"//beacon-chain/rpc/prysm/v1alpha1/validator:go_default_library",
"//beacon-chain/rpc/statefetcher:go_default_library",
"//beacon-chain/slasher:go_default_library",
"//beacon-chain/state/stategen:go_default_library",
"//beacon-chain/sync:go_default_library",
Expand All @@ -43,6 +44,7 @@ go_library(
"//monitoring/tracing:go_default_library",
"//proto/eth/service:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"@com_github_gorilla_mux//: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",
Expand All @@ -68,6 +70,7 @@ go_test(
"//beacon-chain/sync/initial-sync/testing:go_default_library",
"//testing/assert:go_default_library",
"//testing/require:go_default_library",
"@com_github_gorilla_mux//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
],
Expand Down
6 changes: 2 additions & 4 deletions beacon-chain/rpc/eth/beacon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ go_library(
"//beacon-chain/operations/voluntaryexits:go_default_library",
"//beacon-chain/p2p:go_default_library",
"//beacon-chain/rpc/eth/helpers:go_default_library",
"//beacon-chain/rpc/lookup:go_default_library",
"//beacon-chain/rpc/prysm/v1alpha1/validator:go_default_library",
"//beacon-chain/rpc/statefetcher:go_default_library",
"//beacon-chain/state:go_default_library",
"//beacon-chain/state/state-native:go_default_library",
"//beacon-chain/state/stategen:go_default_library",
Expand Down Expand Up @@ -92,7 +92,6 @@ go_test(
"//beacon-chain/core/transition:go_default_library",
"//beacon-chain/db:go_default_library",
"//beacon-chain/db/testing:go_default_library",
"//beacon-chain/execution/testing:go_default_library",
"//beacon-chain/operations/attestations:go_default_library",
"//beacon-chain/operations/blstoexec:go_default_library",
"//beacon-chain/operations/blstoexec/mock:go_default_library",
Expand All @@ -101,12 +100,11 @@ go_test(
"//beacon-chain/operations/voluntaryexits/mock:go_default_library",
"//beacon-chain/p2p/testing:go_default_library",
"//beacon-chain/rpc/eth/helpers:go_default_library",
"//beacon-chain/rpc/lookup:go_default_library",
"//beacon-chain/rpc/prysm/v1alpha1/validator:go_default_library",
"//beacon-chain/rpc/statefetcher:go_default_library",
"//beacon-chain/rpc/testutil:go_default_library",
"//beacon-chain/state:go_default_library",
"//beacon-chain/state/state-native:go_default_library",
"//config/features:go_default_library",
"//config/params:go_default_library",
"//consensus-types/blocks:go_default_library",
"//consensus-types/interfaces:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions beacon-chain/rpc/eth/beacon/blinded_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (bs *Server) GetBlindedBlock(ctx context.Context, req *ethpbv1.BlockRequest
ctx, span := trace.StartSpan(ctx, "beacon.GetBlindedBlock")
defer span.End()

blk, err := bs.blockFromBlockID(ctx, req.BlockId)
blk, err := bs.Blocker.Block(ctx, req.BlockId)
err = handleGetBlockError(blk, err)
if err != nil {
return nil, err
Expand Down Expand Up @@ -80,7 +80,7 @@ func (bs *Server) GetBlindedBlockSSZ(ctx context.Context, req *ethpbv1.BlockRequ
ctx, span := trace.StartSpan(ctx, "beacon.GetBlindedBlockSSZ")
defer span.End()

blk, err := bs.blockFromBlockID(ctx, req.BlockId)
blk, err := bs.Blocker.Block(ctx, req.BlockId)
err = handleGetBlockError(blk, err)
if err != nil {
return nil, err
Expand Down
Loading