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
Command to fetch validator statuses + MultipleValidatorStatus #5784
Command to fetch validator statuses + MultipleValidatorStatus #5784
Conversation
91ce0fc
to
fdc668b
Compare
fdc668b
to
3c357a1
Compare
5ea8600
to
1294fdf
Compare
3e9e770
to
7b7efef
Compare
validator/accounts/status.go
Outdated
} | ||
|
||
req := ðpb.ValidatorStatusRequest{ | ||
PublicKey: pubKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if we have N keys then it's N requests to the beacon node. Can we batch this to just 1 request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Right now it's like this so I can avoid compile errors.
I'm waiting for prysmaticlabs/ethereumapis#148 to get merged. Once the API for ValidatorStatus is updated, we'll batch public keys into slices of at most C keys. So we'll make k=N/C requests.
And after receiving the responses from the node, we'll run a k-way merge sort and then print the results.
3bc7daf
to
2ab3a6b
Compare
2ab3a6b
to
9635895
Compare
6a4f56f
to
8096b80
Compare
8096b80
to
74c315b
Compare
Codecov Report
@@ Coverage Diff @@
## master #5784 +/- ##
=======================================
Coverage 59.60% 59.60%
=======================================
Files 315 315
Lines 26570 26570
=======================================
Hits 15836 15836
Misses 8590 8590
Partials 2144 2144 |
dc8e385
to
f7237cf
Compare
…validator-client-account-statuses
f7237cf
to
a1463a1
Compare
validator/accounts/status.go
Outdated
grpc.WithStatsHandler(&ocgrpc.ClientHandler{}), | ||
grpc.WithBlock(), | ||
grpc.WithTimeout( | ||
10 * time.Second /* Block for 10 seconds to see if we can connect to beacon node */), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecated: use DialContext instead of Dial and context.WithTimeout instead. Will be supported throughout 1.x.
…validator-client-account-statuses
…m/michaelhly/prysm into validator-client-account-statuses
PTAL @terencechain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm. Thanks Michael!
beacon-chain/rpc/validator/status.go
Outdated
filtered := make(map[[48]byte]bool) | ||
filtered[[48]byte{}] = true // Filter out keys with all zeros. | ||
// Filter out duplicate public keys. | ||
for _, pubKey := range req.GetPublicKeys() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to copy here, you can access the field directly
beacon-chain/rpc/validator/status.go
Outdated
} | ||
} | ||
// Convert indices to public keys. | ||
for _, idx := range req.GetIndices() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same over here
validator/accounts/status.go
Outdated
|
||
// MaxRequestLimit specifies the max concurrent grpc requests allowed | ||
// to fetch account statuses. | ||
const MaxRequestLimit = 5 // XXX: Should create flag to make parameter configurable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the XXX
comment, or open up an issue in the repo for this as a todo. We use
TODO(#Num)
where Num
represents the issue number.
validator/accounts/status.go
Outdated
|
||
// MaxRequestKeys specifies the max amount of public keys allowed | ||
// in a single grpc request, when fetching account statuses. | ||
const MaxRequestKeys = 2000 // XXX: This is an arbitrary number. Used to limit time complexity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here remove XXX
validator/accounts/status.go
Outdated
maxCallRecvMsgSize int, | ||
grpcRetries uint, | ||
grpcHeaders []string) error { | ||
dialOpts, err := constructDialOptions(maxCallRecvMsgSize, withCert, grpcHeaders, grpcRetries) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you not construct the GRPC client in this command, this should be done on the outside of the method.
validator/accounts/status.go
Outdated
errorChannel := make(chan error, MaxRequestLimit) | ||
statusChannel := make(chan []ValidatorStatusMetadata, MaxRequestLimit) | ||
// Launch routines to fetch statuses. | ||
i, numBatches := 0, 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use scatter from mputils
for parallelized requests.
https://github.com/prysmaticlabs/prysm/blob/master/shared/mputil/scatter.go#L21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nisdas do you think that is going to help here? This isn't doing any computation really, just fetching the requests from the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly because it looks like its doing a lot of repeat work which is done by Scatter
, its also just splitting up the requests into separate goroutines using a fixed request size.
validator/accounts/status.go
Outdated
errorChannel := make(chan error, MaxRequestLimit) | ||
statusChannel := make(chan []ValidatorStatusMetadata, MaxRequestLimit) | ||
// Launch routines to fetch statuses. | ||
i, numBatches := 0, 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nisdas do you think that is going to help here? This isn't doing any computation really, just fetching the requests from the server.
validator/accounts/status.go
Outdated
"Eth1DepositBlockNumber": fieldToString(m.Eth1DepositBlockNumber), | ||
"PositionInActivationQueue": fieldToString(m.PositionInActivationQueue), | ||
}, | ||
).Infof("Status=%v\n PublicKey=0x%s\n", m.Status, hex.EncodeToString(key)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pubkey should be above under logrus.Fields
. You should be only logging the status here, with the status being an enum type, you can simple represent it using %s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
What type of PR is this?
What does this PR do? Why is it needed?
Add
validator accounts status
command to fetch validator statuses from the Beacon Node.Which issues(s) does this PR fix?
Resolves #5578
Other notes for review
Summary of changes:
beacon_node_validator_service_mock.go
status
command for the validator clientTODO:
Runtime Demos:
Connected to syncing node
Node offline
Connected to synced node
https://gist.github.com/michaelhly/cc00d4329974582abcbbbb19dbed66a0