Skip to content

Commit

Permalink
Update EthereumAPIs to prysmaticlabs/ethereumapis#137 (#5622)
Browse files Browse the repository at this point in the history
* Update EthereumAPIs to prysmaticlabs/ethereumapis#137 and implement validator index return field
  • Loading branch information
prestonvanloon authored Apr 25, 2020
1 parent 5fbf38c commit 8a9c960
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
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 = "4685995df20b6d7a926fb98778c940e380db33ee",
commit = "1c66911b2ef3c1a290abb2156bcecb33ac32725f",
importpath = "github.com/prysmaticlabs/ethereumapis",
)

Expand Down
2 changes: 2 additions & 0 deletions beacon-chain/rpc/beacon/assignments.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func (bs *Server) ListValidatorAssignments(
AttesterSlot: comAssignment.AttesterSlot,
ProposerSlots: proposerIndexToSlots[index],
PublicKey: pubkey[:],
ValidatorIndex: index,
}
res = append(res, assign)
}
Expand Down Expand Up @@ -256,6 +257,7 @@ func (bs *Server) listValidatorAssignmentsUsingOldArchival(
AttesterSlot: comAssignment.AttesterSlot,
ProposerSlots: proposerIndexToSlots[index],
PublicKey: pubkey[:],
ValidatorIndex: index,
}
res = append(res, assign)
}
Expand Down
5 changes: 5 additions & 0 deletions beacon-chain/rpc/beacon/assignments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_NoArchive(t *testing.
AttesterSlot: committeeAssignments[index].AttesterSlot,
ProposerSlots: proposerIndexToSlots[index],
PublicKey: val.PublicKey,
ValidatorIndex: index,
})
}
if !reflect.DeepEqual(res.Assignments, wanted) {
Expand Down Expand Up @@ -348,6 +349,7 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_FromArchive(t *testin
AttesterSlot: committeeAssignments[index].AttesterSlot,
ProposerSlots: proposerIndexToSlots[index],
PublicKey: val.PublicKey,
ValidatorIndex: index,
})
}

Expand Down Expand Up @@ -437,6 +439,7 @@ func TestServer_ListAssignments_FilterPubkeysIndices_NoPagination(t *testing.T)
AttesterSlot: committeeAssignments[index].AttesterSlot,
ProposerSlots: proposerIndexToSlots[index],
PublicKey: val.PublicKey,
ValidatorIndex: index,
})
}

Expand Down Expand Up @@ -520,6 +523,7 @@ func TestServer_ListAssignments_CanFilterPubkeysIndices_WithPagination(t *testin
AttesterSlot: committeeAssignments[index].AttesterSlot,
ProposerSlots: proposerIndexToSlots[index],
PublicKey: val.PublicKey,
ValidatorIndex: index,
})
}

Expand Down Expand Up @@ -555,6 +559,7 @@ func TestServer_ListAssignments_CanFilterPubkeysIndices_WithPagination(t *testin
AttesterSlot: cAssignments[index].AttesterSlot,
ProposerSlots: proposerIndexToSlots[index],
PublicKey: val.PublicKey,
ValidatorIndex: index,
})
}

Expand Down
8 changes: 5 additions & 3 deletions beacon-chain/rpc/beacon/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,11 @@ func (bs *Server) GetValidatorQueue(
}

return &ethpb.ValidatorQueue{
ChurnLimit: churnLimit,
ActivationPublicKeys: activationQueueKeys,
ExitPublicKeys: exitQueueKeys,
ChurnLimit: churnLimit,
ActivationPublicKeys: activationQueueKeys,
ExitPublicKeys: exitQueueKeys,
ActivationValidatorIndices: activationQ,
ExitValidatorIndices: exitQueueIndices,
}, nil
}

Expand Down
8 changes: 8 additions & 0 deletions beacon-chain/rpc/beacon/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,10 @@ func TestServer_GetValidatorQueue_PendingActivation(t *testing.T) {
if !reflect.DeepEqual(res.ActivationPublicKeys, wanted) {
t.Errorf("Wanted %v, received %v", wanted, res.ActivationPublicKeys)
}
wantedActiveIndices := []uint64{2, 1, 0}
if !reflect.DeepEqual(res.ActivationValidatorIndices, wantedActiveIndices) {
t.Errorf("wanted %v, received %v", wantedActiveIndices, res.ActivationValidatorIndices)
}
}

func TestServer_GetValidatorQueue_ExitedValidatorLeavesQueue(t *testing.T) {
Expand Down Expand Up @@ -1487,6 +1491,10 @@ func TestServer_GetValidatorQueue_ExitedValidatorLeavesQueue(t *testing.T) {
if !reflect.DeepEqual(res.ExitPublicKeys, wanted) {
t.Errorf("Wanted %v, received %v", wanted, res.ExitPublicKeys)
}
wantedExitIndices := []uint64{1}
if !reflect.DeepEqual(res.ExitValidatorIndices, wantedExitIndices) {
t.Errorf("wanted %v, received %v", wantedExitIndices, res.ExitValidatorIndices)
}

// Now, we move the state.slot past the exit epoch of the validator, and now
// the validator should no longer exist in the queue.
Expand Down

0 comments on commit 8a9c960

Please sign in to comment.