-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Modify ListValidatorAssignments
to use new state service
#5365
Merged
Merged
Changes from all commits
Commits
Show all changes
497 commits
Select commit
Hold shift + click to select a range
6844df5
Fixed rest of non spec tests
terencechain e1b66f1
Fixed a bug proposer index wasn't included
terencechain 88f787c
gaz
terencechain 0664b8a
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into v0.11
rauljordan ec61457
Updated eth1 data voting period to epoch based
terencechain 6f39dcc
Fixed failed tests
terencechain 4f2f4f0
fix bug
nisdas 4c1f7fe
fix error
nisdas dc9fd93
Fixed more misc tests
terencechain 2e6d0d4
Add new SignedAggregateAndProof to pass spec test
terencechain 7aee6cc
Update minimalConfig.PersistentCommitteePeriod
terencechain aec3f80
allow to rebuild trie
nisdas 1dc141c
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into v0.11
rauljordan 4b378db
Skip e2e tests
terencechain aff5587
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into v0.11
terencechain 4f83b45
Align aggregator action with v0.11 (#5146)
terencechain ecd4b76
Remove Head Root from Beacon Block by Range Request (#5165)
nisdas 7e5ea6c
Merge branch 'master' of https://github.com/prysmaticlabs/geth-shardi…
nisdas 3a5b86b
add back herumi's library
nisdas fb637d8
Update ethapi in workspace, started fixing test. Hand off to Nishant
terencechain 4a1e814
fix build
nisdas b5feb9c
All tests passing
terencechain a528184
Align finalized slot check with v0.11 (#5166)
terencechain 5e5be15
Merge branch 'master' into v0.11
rauljordan 527c15e
Add DoS resistance for v0.11 (#5158)
terencechain c2f6e95
Add Fork Digest Helper (#5173)
nisdas 2a5b756
Extend DoS prevention to rest of operation objects (#5174)
terencechain 1a2ebfe
Add remote keymanager (#5133)
mcdee ba30d42
Add Snappy Framing to the Encoder (#5172)
nisdas b6590ad
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into v0.11
rauljordan 1223cb0
Move Subnet Functionality to its Own File (#5179)
rauljordan af95421
Sync with master
terencechain f9acd78
Verify proposer signature in sync (#5206)
terencechain a1728c6
Fix Signed Attestation In Sync (#5207)
nisdas 810012d
Add Eth2 Fork ENR Functionality (#5181)
rauljordan be88b28
Verify aggregator signature in sync (#5208)
terencechain ec2a100
Add Fork Digest For Gossip Topics (#5191)
nisdas b2375ae
Fix Incorrect Attester Slashing Method (#5229)
nisdas fd7b4a5
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into v0.11
rauljordan 4600877
Remove keystore keymanager from validator (#5236)
mcdee 9cee65a
fix broadcaster
nisdas e1c3a00
update metrics with fork digest for p2p (#5251)
rauljordan 6821531
Fix incorrect domain type comments (#5250)
mcdee 6163339
resolve conflicts
rauljordan 293901f
fix broken broadcast test
rauljordan 43297a6
fix tests
rauljordan 76cf84d
include protocol suffix
rauljordan 679d44f
fix confs
rauljordan b0b8574
lint
rauljordan c55c964
fix test
rauljordan d2d931f
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into v0.11
rauljordan 32680a4
Merge branch 'master' of github.com:prysmaticlabs/prysm into v0.11
terencechain ae1b4aa
resolve broken slasher test'
rauljordan 359035d
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into v0.11
terencechain dbb4d02
Merge branch 'master' into v0.11
rauljordan d9fad84
fix config override
rauljordan 7d17c9a
Remove deprecated parameters (#5249)
mcdee 12d0d25
Avoid div by zero in extreme balance case (#5273)
terencechain 47e5a2c
Revert "Remove deprecated parameters (#5249)" (#5276)
terencechain 9998b97
Verify block proposer index before gossip (#5274)
terencechain d15c12f
Add in Proposer Index to Custom HTR (#5269)
nisdas 6e84806
Resolve Flakey P2P Tests (#5285)
rauljordan ca81ef6
Merge branch 'master' into v0.11
prestonvanloon b47f456
release resources correctly (#5287)
nisdas 16d8114
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] a8d32d5
Enable NOISE Handshake by Default v0.11 (#5272)
rauljordan 2ebc856
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 939179c
new ports
rauljordan 52cefdf
fix broken build
rauljordan 29fc5a5
Make `new-state-mgmt` canonical (#5289)
terencechain 8f3c4d8
Merge branch 'master' into v0.11
rauljordan b7c7b8a
resolve flakeyness
rauljordan d6ed9db
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] e75abe8
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 9804bcb
Detect Proposer Slashing Implementation (#5139)
shayzluf 04c17c5
Merge branch 'master' of https://github.com/prysmaticlabs/geth-shardi…
nisdas 15e4696
Add Metadata And Ping RPC methods (#5271)
nisdas a1bc7be
Merge branch 'master' of https://github.com/prysmaticlabs/geth-shardi…
nisdas bbcd895
Updates for remote keymanager (#5260)
mcdee 0600b11
Merge branch 'spec-v0.11' of github.com:prysmaticlabs/prysm into v0.11
terencechain 7ce68fd
Merge remote-tracking branch 'origin' into v0.11
terencechain 8d6aed9
Update to slash by slot instead of epoch (#5297)
shayzluf 005bfa7
Sync with master
terencechain c1946f8
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into v0.11
terencechain 579a4e1
Update proposer protection to v0.11 (#5292)
0xKiwi 7f0911f
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] a0c62b1
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 1b8db88
Implement `SubscribeCommitteeSubnet` method (#5299)
terencechain bcc53dc
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 96af0e8
resolve confs
rauljordan 963d11a
Validator subscribe subnet to next epoch (#5312)
terencechain e5aef16
Revert "Revert "Remove deprecated parameters (#5249)" (#5276)" (#5277)
terencechain e60ea19
Aggregate on demand for v0.11 (#5302)
terencechain 3d99e69
Refactor Dynamic Subscriptions (#5318)
nisdas a0cafff
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 35a6df7
Fix listindexed attestations and detect historic attestations (#5321)
shayzluf 91b19b9
Add check for slot == 0 (#5322)
terencechain 894508f
Change attester protection to return default if DB is empty (#5323)
0xKiwi 7e84e42
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 5ec3706
fix it (#5326)
nisdas 899175d
V0.11 run time fixes to use interop config (#5324)
terencechain 0f6e3fb
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 9bb52b1
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 1e4fe6d
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 74cca27
Nil Checks in Process Attestation v0.11 (#5331)
rauljordan c853805
Validator batch subscribe subnets (#5332)
terencechain b422889
Validator smarter subscribe (#5334)
terencechain 7456c1c
Fix incorrect proposer index calculation (#5336)
terencechain 9e4612e
enhance error
prestonvanloon e4e620d
enhance error
prestonvanloon 7b9ecaa
Update P2P Service to Handle Local Metadata (#5319)
nisdas 6f262b5
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into v0.11
prestonvanloon 1dfa485
Revert "Revert "Revert "Remove deprecated parameters (#5249)" (#5276)…
prestonvanloon 2ed1dee
Wait for Genesis Event to Start P2P (#5303)
rauljordan 13bb6c0
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] a943cbb
Avoid duplicated aggregation request (#5346)
terencechain a1d4dd4
Fix Validate For Metadata (#5348)
nisdas f0bb84e
Multiple Proposer Slots Allowed Per Epoch for Validators (#5344)
rauljordan 0549fa4
Networking Fixes (#5349)
nisdas 54830f1
More efficient aggregation on demand (#5354)
terencechain e02f4f4
Return Nil Error if Pre-Genesis in P2P Service Healthz Check (#5355)
rauljordan 0f87842
STarting
terencechain 70ac7b8
Release DiscoveryV5 for Testnet Restart (#5357)
nisdas 57ecba3
Fix Overflow in Status Check (#5361)
nisdas c3f4a0a
Update assignments
terencechain e02db8e
Genesis short circuit
terencechain dde7fe2
Fixed tests
terencechain 2d1118f
Merge branch 'master' of github.com:prysmaticlabs/prysm into v0.11
prestonvanloon 9cf22ac
fix after merge
prestonvanloon c709b5d
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 97df02f
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 19070da
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 4256321
Make Mainnet Config Default, No More Demo Config (#5367)
rauljordan 201bf2a
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 31b6fc7
Use FastSSZ Marshal/Unmarshal for DB Encodings in v0.11.1 (#5351)
rauljordan 7cad4f7
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 45ebbb6
Reconnect slasher streams on beacon node shutdown (#5376)
shayzluf 6cd24bf
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 50c8dd5
Merge branch 'master' into v0.11
rauljordan b848836
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 8744680
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] a414646
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 4203c9f
Amend Faucet to Offer 32.5 ETH for v0.11 (#5378)
rauljordan b211abc
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 9f9c679
unskip exec transition test
rauljordan c023f39
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 2aa8f4c
Revert "Enable NOISE Handshake by Default v0.11 (#5272)" (#5381)
prestonvanloon 79cd3a5
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] ffa21c0
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] b23926c
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 07cfbba
use string for deposit flag
prestonvanloon 9014d8f
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 87e684a
Update Bootnode to v0.11 (#5387)
nisdas 2e00a0c
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 7c094b7
Fixed conflict
terencechain 54e22f3
Merge branch 'master' of github.com:prysmaticlabs/prysm into v0.11
prestonvanloon 4de55e6
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] b749086
build fix
prestonvanloon c552bcd
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 7334c19
fix flaky test
prestonvanloon d2c0515
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] d2bb481
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 1b5d766
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] c3da4c5
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into fix-list-…
terencechain 202be26
Fixed more conflicts
terencechain 6350e69
Merge branch 'fix-list-validator-assignments' of github.com:prysmatic…
terencechain 5bc8756
Unskip E2E for V0.11 (#5386)
0xKiwi 29dd409
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] c2a83cc
Merge branch 'master' of https://github.com/prysmaticlabs/prysm into …
0xKiwi 48b588b
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 1e1a3c4
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] d0b217c
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 99e0dfa
Merge branch 'master' of github.com:prysmaticlabs/prysm into v0.11
prestonvanloon b66d1de
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 7a5284e
Update beacon-chain/p2p/broadcaster_test.go
rauljordan d99d78b
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 382cb68
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into fix-list-…
terencechain 7f632a4
Fixed test
terencechain b7daa6f
Merge branch 'fix-list-validator-assignments' of github.com:prysmatic…
terencechain 6016053
Merge refs/heads/master into v0.11
prylabs-bulldozer[bot] 93149e1
Merge branch 'v0.11' into fix-list-validator-assignments
terencechain 31facab
Pass E2E Tests for v0.11 and Enable Attestation Subnets By Default (#…
rauljordan 5c171d8
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 338034b
Update README.md
terencechain 25cacb4
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 0157379
Apply suggestions from code review
terencechain 4dac82e
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] d5b1e84
Update beacon-chain/p2p/config.go
terencechain 3acf23e
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 5ea1c43
Update shared/keystore/deposit_input.go
terencechain f9209f0
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] c24535f
Update tools/faucet/server.go
terencechain 2d5d44b
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] fcc5f71
Update beacon-chain/p2p/service.go
terencechain 026cbbd
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] f4b369a
Update shared/benchutil/pregen_test.go
terencechain dd2ca0c
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] fb7941b
Update shared/benchutil/pregen_test.go
terencechain 0115d0c
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 7b83fd6
Update proto/beacon/p2p/v1/BUILD.bazel
terencechain 1ca2c57
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 4644568
Update shared/benchutil/pregen_test.go
terencechain 2addb8d
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 335ee20
Update shared/bls/spectest/aggregate_verify_test.go
rauljordan 10f2ab2
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] b3c0166
Addressed feedback. All test passing
terencechain 105f15c
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into v0.11
terencechain 9751d16
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 1e19c7f
Update beacon-chain/core/blocks/block_operations_fuzz_test.go
terencechain 0c4e902
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] f695932
Update beacon-chain/core/blocks/block_operations_test.go
terencechain 1a93001
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] b435a4a
Update shared/testutil/helpers.go
terencechain c99ca81
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] de7195c
Update beacon-chain/core/helpers/signing_root.go
terencechain dc107ec
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 0a64620
Resolve Misc v0.11 Items (Raul) (#5414)
rauljordan 8067d84
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 0ea2bbb
Revert keymanager changes (#5416)
prestonvanloon c774325
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 3f882af
Update BLS and limit visibility (#5415)
prestonvanloon f32c434
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 95e44ba
Fix eth1data test and fix order of ops (#5413)
0xKiwi 0350c0c
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] a4f47b9
use multiaddr builder (#5419)
nisdas d179aa6
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] da28c1f
Unskip benchutil and minor v0.11 fixes (#5417)
0xKiwi c979731
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 2e1ebc9
Networking Fixes (#5421)
nisdas 011aadb
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] f7a2aa5
Update ethereum APIs with latest master
prestonvanloon 5d528f1
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 6722667
Error handling for v0.11 tests (#5428)
terencechain 26c0c1a
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 3500f91
Sync with master
terencechain d6985d0
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 7d132ea
Rm old aggregate_test.go
terencechain 8191008
Merge refs/heads/v0.11 into fix-list-validator-assignments
prylabs-bulldozer[bot] 5ee7b61
Merge branch 'master' into fix-list-validator-assignments
terencechain 597e4fc
Fixed conflicts
terencechain 6305661
Merge refs/heads/master into fix-list-validator-assignments
prylabs-bulldozer[bot] e53505f
Merge refs/heads/master into fix-list-validator-assignments
prylabs-bulldozer[bot] 99a6fee
Merge refs/heads/master into fix-list-validator-assignments
prylabs-bulldozer[bot] a59e38d
Merge refs/heads/master into fix-list-validator-assignments
prylabs-bulldozer[bot] c954e7a
Merge refs/heads/master into fix-list-validator-assignments
prylabs-bulldozer[bot] 199fc80
Merge refs/heads/master into fix-list-validator-assignments
prylabs-bulldozer[bot] add4144
Merge refs/heads/master into fix-list-validator-assignments
prylabs-bulldozer[bot] f13175c
Merge refs/heads/master into fix-list-validator-assignments
prylabs-bulldozer[bot] f874b93
Merge refs/heads/master into fix-list-validator-assignments
prylabs-bulldozer[bot] 526f98a
Merge refs/heads/master into fix-list-validator-assignments
prylabs-bulldozer[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,11 @@ import ( | |
"context" | ||
"strconv" | ||
|
||
"github.com/pkg/errors" | ||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" | ||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" | ||
"github.com/prysmaticlabs/prysm/beacon-chain/flags" | ||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" | ||
"github.com/prysmaticlabs/prysm/shared/bytesutil" | ||
"github.com/prysmaticlabs/prysm/shared/hashutil" | ||
"github.com/prysmaticlabs/prysm/shared/pagination" | ||
"github.com/prysmaticlabs/prysm/shared/params" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
@@ -32,14 +28,9 @@ func (bs *Server) ListValidatorAssignments( | |
} | ||
|
||
var res []*ethpb.ValidatorAssignments_CommitteeAssignment | ||
headState, err := bs.HeadFetcher.HeadState(ctx) | ||
if err != nil { | ||
return nil, status.Error(codes.Internal, "Could not get head state") | ||
} | ||
filtered := map[uint64]bool{} // track filtered validators to prevent duplication in the response. | ||
filteredIndices := make([]uint64, 0) | ||
requestedEpoch := helpers.CurrentEpoch(headState) | ||
|
||
var requestedEpoch uint64 | ||
switch q := req.QueryFilter.(type) { | ||
case *ethpb.ListValidatorAssignmentsRequest_Genesis: | ||
if q.Genesis { | ||
|
@@ -49,18 +40,24 @@ func (bs *Server) ListValidatorAssignments( | |
requestedEpoch = q.Epoch | ||
} | ||
|
||
if requestedEpoch > helpers.CurrentEpoch(headState) { | ||
currentEpoch := helpers.SlotToEpoch(bs.GenesisTimeFetcher.CurrentSlot()) | ||
if requestedEpoch > currentEpoch { | ||
return nil, status.Errorf( | ||
codes.InvalidArgument, | ||
"Cannot retrieve information about an epoch in the future, current epoch %d, requesting %d", | ||
helpers.CurrentEpoch(headState), | ||
currentEpoch, | ||
requestedEpoch, | ||
) | ||
} | ||
|
||
requestedState, err := bs.StateGen.StateBySlot(ctx, helpers.StartSlot(requestedEpoch)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just use this over here ?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User has option to choose to request an arbitrary slot that's less than current slot. See L39 case *ethpb.ListValidatorAssignmentsRequest_Epoch:
requestedEpoch = q.Epoch
} |
||
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "Could not retrieve archived state for epoch %d: %v", requestedEpoch, err) | ||
} | ||
|
||
// Filter out assignments by public keys. | ||
for _, pubKey := range req.PublicKeys { | ||
index, ok := headState.ValidatorIndexByPubkey(bytesutil.ToBytes48(pubKey)) | ||
index, ok := requestedState.ValidatorIndexByPubkey(bytesutil.ToBytes48(pubKey)) | ||
if !ok { | ||
return nil, status.Errorf(codes.NotFound, "Could not find validator index for public key %#x", pubKey) | ||
} | ||
|
@@ -75,7 +72,7 @@ func (bs *Server) ListValidatorAssignments( | |
} | ||
} | ||
|
||
activeIndices, err := helpers.ActiveValidatorIndices(headState, requestedEpoch) | ||
activeIndices, err := helpers.ActiveValidatorIndices(requestedState, requestedEpoch) | ||
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "Could not retrieve active validator indices: %v", err) | ||
} | ||
|
@@ -96,53 +93,21 @@ func (bs *Server) ListValidatorAssignments( | |
return nil, status.Errorf(codes.Internal, "Could not paginate results: %v", err) | ||
} | ||
|
||
shouldFetchFromArchive := requestedEpoch < bs.FinalizationFetcher.FinalizedCheckpt().Epoch | ||
|
||
// initialize all committee related data. | ||
// Initialize all committee related data. | ||
committeeAssignments := map[uint64]*helpers.CommitteeAssignmentContainer{} | ||
proposerIndexToSlots := make(map[uint64][]uint64) | ||
archivedInfo := &pb.ArchivedCommitteeInfo{} | ||
archivedBalances := make([]uint64, 0) | ||
archivedAssignments := make(map[uint64]*ethpb.ValidatorAssignments_CommitteeAssignment) | ||
|
||
if shouldFetchFromArchive { | ||
archivedInfo, archivedBalances, err = bs.archivedCommitteeData(ctx, requestedEpoch) | ||
if err != nil { | ||
return nil, err | ||
} | ||
archivedAssignments, err = archivedValidatorCommittee( | ||
requestedEpoch, | ||
archivedInfo, | ||
activeIndices, | ||
archivedBalances, | ||
) | ||
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "Could not retrieve archived assignment for epoch %d: %v", requestedEpoch, err) | ||
} | ||
} else { | ||
committeeAssignments, proposerIndexToSlots, err = helpers.CommitteeAssignments(headState, requestedEpoch) | ||
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "Could not compute committee assignments: %v", err) | ||
} | ||
committeeAssignments, proposerIndexToSlots, err = helpers.CommitteeAssignments(requestedState, requestedEpoch) | ||
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "Could not compute committee assignments: %v", err) | ||
} | ||
|
||
for _, index := range filteredIndices[start:end] { | ||
if int(index) >= headState.NumValidators() { | ||
if int(index) >= requestedState.NumValidators() { | ||
return nil, status.Errorf(codes.OutOfRange, "Validator index %d >= validator count %d", | ||
index, headState.NumValidators()) | ||
} | ||
if shouldFetchFromArchive { | ||
assignment, ok := archivedAssignments[index] | ||
if !ok { | ||
return nil, status.Errorf(codes.Internal, "Could not get archived committee assignment for index %d", index) | ||
} | ||
pubkey := headState.PubkeyAtIndex(index) | ||
assignment.PublicKey = pubkey[:] | ||
res = append(res, assignment) | ||
continue | ||
index, requestedState.NumValidators()) | ||
} | ||
comAssignment := committeeAssignments[index] | ||
pubkey := headState.PubkeyAtIndex(index) | ||
pubkey := requestedState.PubkeyAtIndex(index) | ||
assign := ðpb.ValidatorAssignments_CommitteeAssignment{ | ||
BeaconCommittees: comAssignment.Committee, | ||
CommitteeIndex: comAssignment.CommitteeIndex, | ||
|
@@ -160,93 +125,3 @@ func (bs *Server) ListValidatorAssignments( | |
TotalSize: int32(len(filteredIndices)), | ||
}, nil | ||
} | ||
|
||
// Computes validator assignments for an epoch and validator index using archived committee | ||
// information, archived balances, and a set of active validators. | ||
func archivedValidatorCommittee( | ||
epoch uint64, | ||
archivedInfo *pb.ArchivedCommitteeInfo, | ||
activeIndices []uint64, | ||
archivedBalances []uint64, | ||
) (map[uint64]*ethpb.ValidatorAssignments_CommitteeAssignment, error) { | ||
proposerSeed := bytesutil.ToBytes32(archivedInfo.ProposerSeed) | ||
attesterSeed := bytesutil.ToBytes32(archivedInfo.AttesterSeed) | ||
|
||
startSlot := helpers.StartSlot(epoch) | ||
proposerIndexToSlots := make(map[uint64][]uint64) | ||
activeVals := make([]*ethpb.Validator, len(archivedBalances)) | ||
for i, bal := range archivedBalances { | ||
activeVals[i] = ðpb.Validator{EffectiveBalance: bal} | ||
} | ||
|
||
for slot := startSlot; slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { | ||
seedWithSlot := append(proposerSeed[:], bytesutil.Bytes8(slot)...) | ||
seedWithSlotHash := hashutil.Hash(seedWithSlot) | ||
i, err := helpers.ComputeProposerIndex(activeVals, activeIndices, seedWithSlotHash) | ||
if err != nil { | ||
return nil, errors.Wrapf(err, "could not check proposer at slot %d", slot) | ||
} | ||
proposerIndexToSlots[i] = append(proposerIndexToSlots[i], slot) | ||
} | ||
|
||
assignmentMap := make(map[uint64]*ethpb.ValidatorAssignments_CommitteeAssignment) | ||
for slot := startSlot; slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { | ||
var countAtSlot = uint64(len(activeIndices)) / params.BeaconConfig().SlotsPerEpoch / params.BeaconConfig().TargetCommitteeSize | ||
if countAtSlot > params.BeaconConfig().MaxCommitteesPerSlot { | ||
countAtSlot = params.BeaconConfig().MaxCommitteesPerSlot | ||
} | ||
if countAtSlot == 0 { | ||
countAtSlot = 1 | ||
} | ||
for i := uint64(0); i < countAtSlot; i++ { | ||
committee, err := helpers.BeaconCommittee(activeIndices, attesterSeed, slot, i) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "could not compute committee") | ||
} | ||
for _, index := range committee { | ||
assignmentMap[index] = ðpb.ValidatorAssignments_CommitteeAssignment{ | ||
BeaconCommittees: committee, | ||
CommitteeIndex: i, | ||
AttesterSlot: slot, | ||
ProposerSlots: proposerIndexToSlots[index], | ||
} | ||
} | ||
} | ||
} | ||
return assignmentMap, nil | ||
} | ||
|
||
func (bs *Server) archivedCommitteeData(ctx context.Context, requestedEpoch uint64) (*pb.ArchivedCommitteeInfo, | ||
[]uint64, error) { | ||
archivedInfo, err := bs.BeaconDB.ArchivedCommitteeInfo(ctx, requestedEpoch) | ||
if err != nil { | ||
return nil, nil, status.Errorf( | ||
codes.Internal, | ||
"Could not retrieve archived committee info for epoch %d", | ||
requestedEpoch, | ||
) | ||
} | ||
if archivedInfo == nil { | ||
return nil, nil, status.Errorf( | ||
codes.NotFound, | ||
"Could not retrieve data for epoch %d, perhaps --archive in the running beacon node is disabled", | ||
requestedEpoch, | ||
) | ||
} | ||
archivedBalances, err := bs.BeaconDB.ArchivedBalances(ctx, requestedEpoch) | ||
if err != nil { | ||
return nil, nil, status.Errorf( | ||
codes.Internal, | ||
"Could not retrieve archived balances for epoch %d", | ||
requestedEpoch, | ||
) | ||
} | ||
if archivedBalances == nil { | ||
return nil, nil, status.Errorf( | ||
codes.NotFound, | ||
"Could not retrieve data for epoch %d, perhaps --archive in the running beacon node is disabled", | ||
requestedEpoch, | ||
) | ||
} | ||
return archivedInfo, archivedBalances, nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Using time to detect what epoch is current instead of the head?
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.
Correct, that's what I updated to. See below 👇