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] - Add API version headers and map_fork_name! #2745

Closed
wants to merge 1 commit into from

Conversation

michaelsproul
Copy link
Member

@michaelsproul michaelsproul commented Oct 25, 2021

Proposed Changes

  • Add the Eth-Consensus-Version header to the HTTP API for the block and state endpoints. This is part of the v2.1.0 API that was recently released: Add version header for ssz responses ethereum/beacon-APIs#170
  • Add tests for the above. I refactored the eth2 crate's helper functions to make this more straight-forward, and introduced some new mixin traits that I think greatly improve readability and flexibility.
  • Add a new map_with_fork! macro which is useful for decoding a superstruct type without naming all its variants. It is now used for SSZ-decoding BeaconBlock and BeaconState, and for JSON-decoding SignedBeaconBlock in the API.

Additional Info

The map_with_fork! changes will conflict with the Merge changes, but when resolving the conflict the changes from this branch should be preferred (it is no longer necessary to enumerate every fork). The merge fork will need to be added to map_fork_name_with.

@michaelsproul michaelsproul added the ready-for-review The code is ready for review label Oct 25, 2021
Copy link
Member

@realbigsean realbigsean left a comment

Choose a reason for hiding this comment

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

Looks good to me. Love the mixins and map_for_fork! looks like it will come in handy too.

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.

Very tidy! LGTM!

@paulhauner paulhauner added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Oct 28, 2021
@michaelsproul
Copy link
Member Author

Thank you both!

bors r+

bors bot pushed a commit that referenced this pull request Oct 28, 2021
## Proposed Changes

* Add the `Eth-Consensus-Version` header to the HTTP API for the block and state endpoints. This is part of the v2.1.0 API that was recently released: ethereum/beacon-APIs#170
* Add tests for the above. I refactored the `eth2` crate's helper functions to make this more straight-forward, and introduced some new mixin traits that I think greatly improve readability and flexibility.
* Add a new `map_with_fork!` macro which is useful for decoding a superstruct type without naming all its variants. It is now used for SSZ-decoding `BeaconBlock` and `BeaconState`, and for JSON-decoding `SignedBeaconBlock` in the API.

## Additional Info

The `map_with_fork!` changes will conflict with the Merge changes, but when resolving the conflict the changes from this branch should be preferred (it is no longer necessary to enumerate every fork). The merge fork _will_  need to be added to `map_fork_name_with`.
@bors bors bot changed the title Add API version headers and map_fork_name! [Merged by Bors] - Add API version headers and map_fork_name! Oct 28, 2021
@bors bors bot closed this Oct 28, 2021
@michaelsproul michaelsproul deleted the api-fork-header branch October 28, 2021 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants