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

WIP: Finish Relay Verification #93

Closed
wants to merge 0 commits into from

Conversation

PatStiles
Copy link

@PatStiles PatStiles commented Mar 10, 2023

resolves #45

Copy link
Owner

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

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

excellent! minor naming feedback and one ask while we are touching this code

mev-relay-rs/src/service.rs Outdated Show resolved Hide resolved
mev-relay-rs/src/relay.rs Outdated Show resolved Hide resolved
mev-relay-rs/src/relay.rs Outdated Show resolved Hide resolved
@PatStiles PatStiles changed the title verify block sig using true block genesis root WIP: Finish Relay Verification Mar 12, 2023
Copy link
Owner

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

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

nice work!

I left some comments / suggestions but generally this is moving in the right direction :)

If we want to work on all of the validations in this set of files, I think it bears having some more direction / design work which I'd need to go do.... I'd suggest moving that to another issue where we can work on each of the validations

For now, I'd just keep the update to the using the genesis_validators_root in validate_signed_block -- feel free to make a new PR w/ just those changes or remove the others from this one

and in the meantime I can circle around to adding some more of my thinking for handling the rest of the validations

@@ -62,22 +74,30 @@ fn validate_signed_block(
signed_block: &mut SignedBlindedBeaconBlock,
public_key: &BlsPublicKey,
local_payload: &mut ExecutionPayload,
current_slot: Slot,
genesis_validators_root: Root,

Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change

@@ -132,6 +157,10 @@ impl Relay {
self.load_full_validator_set().await;
}

pub fn get_current_slot(&self) -> u64 {
return self.state.lock().current_slot;
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
return self.state.lock().current_slot;
self.state.lock().current_slot

@@ -239,6 +240,13 @@ impl ExecutionPayload {
Self::Capella(payload) => payload.gas_limit,
}
}

pub fn fee_recipient(&self) -> &ByteVector<20> {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pub fn fee_recipient(&self) -> &ByteVector<20> {
pub fn fee_recipient(&self) -> &ExecutionAddress {

builder: NullBuilder,
validator_registry,
context,
//TODO: Can we rely on the future to poll and update this upon initialization instead of initializing it?
Copy link
Owner

Choose a reason for hiding this comment

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

?

Comment on lines 63 to 68
if execution_payload.fee_recipient() != &preferences.fee_recipient {
return Err(
Error::UnknownFeeRecipient(preferences.public_key.to_owned(),
ExecutionAddress::try_from(execution_payload.fee_recipient().to_owned()).unwrap())
)
}
Copy link
Owner

Choose a reason for hiding this comment

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

the general pattern we are seeing is that builders will include a payment transaction but set themselves as the fee_recipient of the block

so as written, this validation would fail for most(all?) mainnet blocks

I'd suggest just leaving it out for now...

@@ -132,6 +157,10 @@ impl Relay {
self.load_full_validator_set().await;
}

pub fn get_current_slot(&self) -> u64 {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pub fn get_current_slot(&self) -> u64 {
fn get_current_slot(&self) -> Slot {

}

// verify proposer_index is correct
// -> Isn't this checked by successfully returning the publickey?
Copy link
Owner

Choose a reason for hiding this comment

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

so for a given valid bid, it will sit on a particular fork of the chain, and it is possible for the proposer index to differ across the same slot in this case

so the intention here was to get our local view of the proposer and verify this bid was for the right validator

Comment on lines 92 to 94
if slot < current_slot || slot > current_slot + PROPOSAL_TOLERANCE_DELAY {
return Err(Error::UnknownBlock);
}
Copy link
Owner

Choose a reason for hiding this comment

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

if a bid comes in at the end of the slot we could get to a case where the bid races our update of time

if anything I'd rather convert the current slot to a timestamp and allow for some propagation tolerance, idk 500ms, to enforce any time deadlines here

@@ -160,7 +190,8 @@ impl BlindedBlockProvider for Relay {
}

async fn fetch_best_bid(&self, bid_request: &BidRequest) -> Result<SignedBuilderBid, Error> {
validate_bid_request(bid_request)?;
let is_registered_public_key = self.validator_registry.get_validator_index(&bid_request.public_key);
Copy link
Owner

Choose a reason for hiding this comment

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

if you just want to pass in a boolean here, I'd suggest this:

Suggested change
let is_registered_public_key = self.validator_registry.get_validator_index(&bid_request.public_key);
let is_registered_public_key = self.validator_registry.get_validator_index(&bid_request.public_key).is_some();

Comment on lines 33 to 35
if bid_request.slot < current_slot || bid_request.slot > current_slot + PROPOSAL_TOLERANCE_DELAY {
return Err(Error::UnknownBid);
}
Copy link
Owner

Choose a reason for hiding this comment

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

same thing here on the timing...

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.

relay: finish signature verification
2 participants