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

[Merged by Bors] - Standard beacon api updates #1831

Closed

Conversation

realbigsean
Copy link
Member

@realbigsean realbigsean commented Oct 26, 2020

Issue Addressed

Resolves #1809
Resolves #1824
Resolves #1818
Resolves #1828 (hopefully)

Proposed Changes

  • add validator_index to the proposer duties endpoint
  • add the ability to query for historical proposer duties
  • StateId deserialization now fails with a 400 warp rejection
  • add the validator_balances endpoint
  • update the aggregate_and_proofs endpoint to accept an array
  • updates the attester duties endpoint from a GET to a POST
  • reduces the number of times we query for proposer duties from once per slot per validator to only once per slot

@realbigsean realbigsean marked this pull request as ready for review October 29, 2020 22:52
…dard-beacon-api-updates

� Conflicts:
�	beacon_node/http_api/src/lib.rs
�	common/eth2/src/lib.rs
@realbigsean realbigsean added the ready-for-review The code is ready for review label Oct 29, 2020
@realbigsean realbigsean mentioned this pull request Nov 3, 2020
39 tasks
Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, I'm sure users will be stoked to have this. Sorry for taking so long to do the review.

No functional issues, just some style/efficiency comments.

beacon_node/http_api/src/lib.rs Show resolved Hide resolved
beacon_node/http_api/src/lib.rs Outdated Show resolved Hide resolved
beacon_node/http_api/src/lib.rs Outdated Show resolved Hide resolved
beacon_node/http_api/src/lib.rs Outdated Show resolved Hide resolved
beacon_node/http_api/src/lib.rs Outdated Show resolved Hide resolved
common/eth2/src/lib.rs Outdated Show resolved Hide resolved
common/eth2/src/lib.rs Outdated Show resolved Hide resolved
pubkey: PublicKey,
) -> Result<ValidatorDuty, String> {
let pubkey_bytes = PublicKeyBytes::from(&pubkey);
mut known_pubkeys: Vec<(PublicKey, u64)>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an alternate pattern, feel free to ignore if you like.

Instead of known_pubkeys and unknown_pubkeys, just have a pubkeys: &[(PublicKey, Option<u64>)]. Then, before the for loop on L64, define an indices = Vec::with_capacity(pubkeys.len()) and push into it whenever you discover a validator index.

This removes known_pubkeys from this function and the caller, replacing it with indicies which is in this function only. It also removes an iteration on L85.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I added this in, but needed an additional way to track the pubkeys of the validator indices we query for. They become necessary when creating empty duties for validators we query for but get no results for. Let me know what you think.

vec![]
};
.into_iter()
.map(|data| (data.validator_index, data))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the feeling that if we mapped into a ValidatorDuty here, instead of on L114, we could avoid the proposal_slots_by_index map.

It's really not a big deal at all, I just thought I'd mention it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to get rid of the attester_duties_by_slot map, but now need to use the pubkey returned by the query for the duty as opposed to the pubkey we have locally. Not that they should be different, but there's an extra deserialization.

I also mapped the result of this query to validator indices to compare with indices we queried for so we can create any remaining empty duties. Let me know if this is along the lines you were thinking.. the codes still a bit ugly, but I'm not really sure how to clean it up further

@paulhauner paulhauner added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels Nov 5, 2020
@realbigsean realbigsean removed the waiting-on-author The reviewer has suggested changes and awaits thier implementation. label Nov 8, 2020
@realbigsean realbigsean added the ready-for-review The code is ready for review label Nov 8, 2020
@paulhauner paulhauner added the A0 label Nov 9, 2020
Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for addressing those comments!

I have a few more ones around log consistency and I also have a suggestion commit for the duties endpoint.

beacon_node/http_api/src/lib.rs Outdated Show resolved Hide resolved
beacon_node/http_api/src/lib.rs Outdated Show resolved Hide resolved
beacon_node/http_api/src/lib.rs Outdated Show resolved Hide resolved
beacon_node/http_api/src/lib.rs Outdated Show resolved Hide resolved
beacon_node/http_api/src/lib.rs Outdated Show resolved Hide resolved
beacon_node/http_api/src/lib.rs Outdated Show resolved Hide resolved
validator_client/src/validator_duty.rs Outdated Show resolved Hide resolved
Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I've been running this on our Medalla nodes overnight and attestation participation is looking great!

bors r+

@paulhauner paulhauner added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Nov 9, 2020
bors bot pushed a commit that referenced this pull request Nov 9, 2020
## Issue Addressed

Resolves #1809 
Resolves #1824
Resolves #1818
Resolves #1828 (hopefully)

## Proposed Changes

- add `validator_index` to the proposer duties endpoint
- add the ability to query for historical proposer duties
- `StateId` deserialization now fails with a 400 warp rejection
- add the `validator_balances` endpoint
- update the `aggregate_and_proofs` endpoint to accept an array
- updates the attester duties endpoint from a `GET` to a `POST`
- reduces the number of times we query for proposer duties from once per slot per validator to only once per slot 


Co-authored-by: realbigsean <seananderson33@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
@bors bors bot changed the title Standard beacon api updates [Merged by Bors] - Standard beacon api updates Nov 10, 2020
@bors bors bot closed this Nov 10, 2020
@realbigsean realbigsean deleted the standard-beacon-api-updates branch November 21, 2023 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A0 ready-for-merge This PR is ready to merge.
Projects
None yet
2 participants