-
Notifications
You must be signed in to change notification settings - Fork 799
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] - Disallow attesting to optimistic head #3140
Conversation
6b4e441
to
8be59d6
Compare
8be59d6
to
0c714e9
Compare
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.
Just had one comment, looking good though!
.get_block_execution_status(&beacon_block_root) | ||
.map_or(true, |execution_status| execution_status.is_not_verified()) | ||
{ | ||
None |
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.
I'm sort of thinking we should handle errors here like in produce_unaggregated_attestation
, otherwise the HTTP API will return "missing aggregate" which would be a bit misleading
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.
Great point, I've added that. I also jigged around with the naming too. All the meaningful changes are in bc8f220.
All comments addressed, thanks @realbigsean. I will merge after an approval (or change request) :) |
/// Returns `true` if the block: | ||
/// | ||
/// - Has execution enabled, AND | ||
/// - Hash a valid payload |
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.
/// - Hash a valid payload | |
/// - Has a valid payload |
@@ -127,6 +127,17 @@ pub enum PayloadVerificationStatus { | |||
Irrelevant, | |||
} | |||
|
|||
impl PayloadVerificationStatus { | |||
/// Returns `true` if the payload was optimistically imported. | |||
pub fn is_optimistic(&self) -> bool { |
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.
I'm wondering if PayloadVerificationStatus::NotVerified
should be renamed to PayloadVerificationStatus::Optimistic
as well to make this mapping very clear. I could understand if we want to keep the concept of "optimism" constrained to fork choice though. What are your thoughts?
This method can also be used in block_verification.rs
L1168 by the way
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.
Great suggestions, will do both.
beacon_node/http_api/src/lib.rs
Outdated
.map_err(|_e| { | ||
warp_utils::reject::custom_bad_request( | ||
"unable to fetch aggregate".to_string(), | ||
) | ||
})? |
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.
This error's swallowed
.map_err(|_e| { | |
warp_utils::reject::custom_bad_request( | |
"unable to fetch aggregate".to_string(), | |
) | |
})? | |
.map_err(|e| { | |
warp_utils::reject::custom_bad_request(format!( | |
"unable to fetch aggregate: {e:?}" | |
)) | |
})? |
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.
Nice catch, thank you!
Thanks for the comments, apologies for the sloppy mistakes! I've addressed all comments and fixed the merge conflict :) |
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.
Awesome! LGTM
I'm blocking this on the v2.2.1 release (#3149) |
bors r+ |
## Issue Addressed NA ## Proposed Changes Disallow the production of attestations and retrieval of unaggregated attestations when they reference an optimistic head. Add tests to this end. I also moved `BeaconChain::produce_unaggregated_attestation_for_block` to the `BeaconChainHarness`. It was only being used during tests, so it's nice to stop pretending it's production code. I also needed something that could produce attestations to optimistic blocks in order to simulate scenarios where the justified checkpoint is determined invalid (if no one would attest to an optimistic block, we could never justify it and then flip it to invalid). ## Additional Info - ~~Blocked on #3126~~
## Issue Addressed NA ## Proposed Changes Disallow the production of attestations and retrieval of unaggregated attestations when they reference an optimistic head. Add tests to this end. I also moved `BeaconChain::produce_unaggregated_attestation_for_block` to the `BeaconChainHarness`. It was only being used during tests, so it's nice to stop pretending it's production code. I also needed something that could produce attestations to optimistic blocks in order to simulate scenarios where the justified checkpoint is determined invalid (if no one would attest to an optimistic block, we could never justify it and then flip it to invalid). ## Additional Info - ~~Blocked on sigp#3126~~
Issue Addressed
NA
Proposed Changes
Disallow the production of attestations and retrieval of unaggregated attestations when they reference an optimistic head. Add tests to this end.
I also moved
BeaconChain::produce_unaggregated_attestation_for_block
to theBeaconChainHarness
. It was only being used during tests, so it's nice to stop pretending it's production code. I also needed something that could produce attestations to optimistic blocks in order to simulate scenarios where the justified checkpoint is determined invalid (if no one would attest to an optimistic block, we could never justify it and then flip it to invalid).Additional Info
Blocked on [Merged by Bors] - Ensure VALID response from fcU updates protoarray #3126