Skip to content

Conversation

@realbigsean
Copy link
Member

Issue Addressed

#1419

Proposed Changes

Creates a --graffiti cli flag in the validator client. If the flag is set, it overrides graffiti in the beacon node.

Additional Info

@AgeManning
Copy link
Member

Curious about your thoughts on this.

As you know the VC asks for a beacon block from the BN. The BN can set the graffiti and that will be the default for block when the VC asks to produce a block.

I was thinking potentially a simpler approach would be like this.
VC -> Give me block -> BN (asks for block from BN)
VC <- Block with default graffiti <- BN (BN sends block with default grafiti - No code modifications on the BN side).
VC Modifies graffiti field of block and signs (we just change a single field on the block before signing)
VC -> Signed Block -> BN (Sends the signed block with the VC graffiti to the BN to propagate).

I think there would be very minimal code changes and hence complexity in this approach.

What do you think?

@realbigsean
Copy link
Member Author

Yea that would definitely cut down the code changes, it's a little janky the way I have it. I was trying to avoid modifying the block after producing it though. Was thinking we'd want to keep the relationship more strictly BN --> produce block. VC --> sign block. But if it's not worth the complexity I can update it, just let me know.

@AgeManning
Copy link
Member

AgeManning commented Jul 31, 2020

Yeah fair point.

@michaelsproul - What logic do you think we should go with here?

@michaelsproul
Copy link
Member

Hmm, I can see benefits to both approaches but I'm in favour of keeping it simple and letting the validator client modify the graffiti. It makes sense that the VC has "control" over what it signs, including mutating the block if it wants to.

Thanks @realbigsean for fixing this pain point ☺️

@realbigsean realbigsean marked this pull request as draft July 31, 2020 03:52
@realbigsean
Copy link
Member Author

Ok, I updated this, but am getting some errors. I'm seeing this log in the beacon node:

Jul 31 03:50:25.411 WARN Invalid block from local validator outcome: StateRootMismatch { block: 0xa0a253636feb79e41b5e218d70adb52df04e597f42682409e94632e72fd2c75b, local: 0xd6858efd8c8fc021127024f570e707b858339af9dd4d2e25f09fcf05696c1908 }, service: http

and this log in the validator client:

Jul 31 03:50:25.412 CRIT Published block was invalid slot: 12, message: The SignedBeaconBlock could not be processed and has not been published: StateRootMismatch { block: 0xa0a253636feb79e41b5e218d70adb52df04e597f42682409e94632e72fd2c75b, local: 0xd6858efd8c8fc021127024f570e707b858339af9dd4d2e25f09fcf05696c1908 }, service: block

I'm not too familiar with how the state root's calculated. But if it incorporates the graffiti, it seems like the beacon node isn't able to validate the signed block correctly because it has a different idea of what the state is.

@michaelsproul
Copy link
Member

Ah, you're totally right. Let's stick with your original approach, recalculating the state root is expensive. Sorry I didn't think of this before

@realbigsean
Copy link
Member Author

ok cool, updated it back 👍

@realbigsean realbigsean marked this pull request as ready for review July 31, 2020 04:34
Comment on lines 230 to 234
// If graffiti has been set in the validator client, overwrite any graffiti sent from the beacon node.
if let Some(graffiti) = self.graffiti {
block.body.graffiti = graffiti;
}

Copy link
Member

Choose a reason for hiding this comment

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

This still seems to be doing things the mutating way, something might have gone awry during the reverting process?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, messed something up trying to revert. Removed this, thanks.

@AgeManning
Copy link
Member

Another thing we need to concern ourselves is following the eth2 API spec. The VC <-> BN API is supposed to be standardised so we can't ad-hoc modify that API.

As it turns out, the new spec requires the graffiti field. However it's not an Option, but rather a String.

It might be best to conform to the API's here to save us the hassle in the future. See here:
https://ethereum.github.io/eth2.0-APIs/#/Validator/produceBlock

@realbigsean
Copy link
Member Author

As it turns out, the new spec requires the graffiti field. However it's not an Option, but rather a String.

Yea so the graffiti is an Option as it's being passed into the produce_block method here: https://github.com/realbigsean/lighthouse/blob/graffiti-cli-option-in-vc/common/remote_beacon_node/src/lib.rs#L316

but in the actual GET request, it's a String query param that may or may not be included:

https://github.com/realbigsean/lighthouse/blob/graffiti-cli-option-in-vc/common/remote_beacon_node/src/lib.rs#L327

Which is in line with the API (the graffiti param is the only of the three not required). There are a couple of other things about this endpoint that are not in line with the API though, like the name is "block" rather than "blocks" and "slot" is a query param rather than a path param, but I'm guessing those would be out of scope for this PR?

@AgeManning
Copy link
Member

Yep perfect!

Yeah we need to do one big PR to bring us in line with the API specs.

This looks good to me. I'll await @michaelsproul final approval before merging. Thanks!

Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

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

LGTM

Are we merging post-Medalla launch?

@AgeManning
Copy link
Member

Would like to run this on the testnet first

@AgeManning
Copy link
Member

This looks fine to me. Lets get it in to prevent PR upkeep.

bors r+

bors bot pushed a commit that referenced this pull request Aug 11, 2020
## Issue Addressed

#1419

## Proposed Changes

Creates a `--graffiti` cli flag in the validator client. If the flag is set, it overrides graffiti in the beacon node. 

## Additional Info
@bors
Copy link

bors bot commented Aug 11, 2020

@bors bors bot changed the title Add graffiti cli flag to the validator client. [Merged by Bors] - Add graffiti cli flag to the validator client. Aug 11, 2020
@bors bors bot closed this Aug 11, 2020
paulhauner pushed a commit that referenced this pull request Aug 12, 2020
## Issue Addressed

#1419

## Proposed Changes

Creates a `--graffiti` cli flag in the validator client. If the flag is set, it overrides graffiti in the beacon node. 

## Additional Info
@realbigsean realbigsean deleted the graffiti-cli-option-in-vc branch August 25, 2020 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants