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

Specify when clients can serve block and sidecars in byRoot RPC methods #3551

Merged
merged 18 commits into from
Dec 4, 2023

Conversation

tbenr
Copy link
Contributor

@tbenr tbenr commented Nov 16, 2023

Based on conversation in #3547.

Allow clients to respond with blocks and blobs as soon as they pass gossip validation.

Blocks:
The idea is to have it a possibility (MAY) in Phase0 but to be an encouraged (SHOULD) behaviour from Deneb. This to allow mixed client approach: some could add it from Deneb only, other could have it enabled for all forks.

The second rule (SHOULD NOT) is to prevent clients continue serving blocks that turn out to be invalid during state transition.

Blob sidecar:
Similar to blocks: they SHOULD be served as soon as they pass gossip validation rules, even before the corresponding block is received. But as soon as block is received, If it fails gossip rules or state transition, the associated blob sidecars have to stop being served (together with the block itself).

fixes #3547

@mkalinin
Copy link
Collaborator

block import failed but due to data unavailability so block and sidecars i have so far are actually good and can be server

This might be ambiguous. Does it mean that the decision to serve a block depends on the attestation boundary? When does a client run an on_block in the case when not all blobs are received?

@tbenr
Copy link
Contributor Author

tbenr commented Nov 17, 2023

This might be ambiguous. Does it mean that the decision to serve a block depends on the attestation boundary? When does a client run an on_block in the case when not all blobs are received?

I'm referring to the second, when on_block fails for data not fully available.

In actual client implementations, we could have block import failing for that reason before receiving a response from the EL (this is not the case in TEKU, where we fail that way when everything else has been validated successfully).

We could add a sentence like:
clients MAY continue serving blocks\sidecars failing ``on_block`` only when blocks\sidecars have been fully processed and the failure reason is due to data unavailable (some sidecars are missing, but the available one have been fully verified against block)."
We can find a better way of expressing it, it is just to show the point.

@mkalinin
Copy link
Collaborator

We can find a better way of expressing it, it is just to show the point.

Ah, sorry, got confused but I see the point now. Then we should include that into Deneb p2p-interface as in the proposed change the spec doesn’t make any note about a block without fully available blobs.

@tbenr
Copy link
Contributor Author

tbenr commented Nov 22, 2023

Ah, sorry, got confused but I see the point now. Then we should include that into Deneb p2p-interface as in the proposed change the spec doesn’t make any note about a block without fully available blobs.

Added, but the problem with that detail is that, if we strictly follow how on_block has been specified, assert is_data_available(hash_tree_root(block), block.body.blob_kzg_commitments) comes before the state transition. So technically is_data_available can fail due to unavailable blobs without having fully validated the block.

@tbenr
Copy link
Contributor Author

tbenr commented Nov 29, 2023

@mkalinin I'm thinking about a different phrasing like:

Clients MUST respond with blocks from their view of the current fork choice, from most recent slot back to latest finalized slot.

Additionally, clients SHOULD include blocks that passed gossip rules but have not yet processed by ``fork_choice.on_block``.

Clients MAY continue serving blocks failed ``fork_choice.on_block`` if and only if the failure reason is due to missing blobs. (i.e. some sidecars are missing but the available ones have been fully verified against the fully validated block).

(Similarly for SidecarsByRoot)

This clarifies what is supposed to be served, but I don't have the history of why it wasn't made explicit from the beginning.

@djrtwo
Copy link
Contributor

djrtwo commented Nov 29, 2023

@tbenr -- what do you think about the difference between passing on_block vs just the state transition function? I'm thinking that on_block is by default too restrictive as the MUST filter

Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

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

ah damn, I just realized I never submitted my review from last week

here you go!

specs/deneb/p2p-interface.md Outdated Show resolved Hide resolved
specs/deneb/p2p-interface.md Outdated Show resolved Hide resolved
specs/deneb/p2p-interface.md Outdated Show resolved Hide resolved
specs/deneb/p2p-interface.md Outdated Show resolved Hide resolved
specs/deneb/p2p-interface.md Outdated Show resolved Hide resolved
specs/phase0/p2p-interface.md Outdated Show resolved Hide resolved
specs/phase0/p2p-interface.md Outdated Show resolved Hide resolved
@hwwhww hwwhww mentioned this pull request Nov 29, 2023
4 tasks
@mkalinin
Copy link
Collaborator

@djrtwo made a good call on referring to the state_transition instead of on_block. Checks run by the on_block on top of the state_transition:

  1. a block is a descendant of the most recent finalized root — this is checked by the gossip rules, so this check is implied in our case
  2. is_data_available returns true

The spec can say SHOULD NOT serve blocks for which one of the following conditions is not satisfied:

  • state_transition(block) succeeds
  • kzg proofs of available blobs are valid with respect to blob_kzg_commitments in the block

SHOULD NOT would give a room for implementations to start serving a block after it passes gossip validation but additional checks aren’t yet executed.

@djrtwo
Copy link
Contributor

djrtwo commented Nov 30, 2023

Doing a final review

@tbenr can you rebase this to dev? It has a number of strange commits like you forked prior to most recent

tbenr and others added 12 commits November 30, 2023 15:20
Co-authored-by: Mikhail Kalinin <noblesse.knight@gmail.com>
Co-authored-by: Mikhail Kalinin <noblesse.knight@gmail.com>
Co-authored-by: Mikhail Kalinin <noblesse.knight@gmail.com>
Co-authored-by: danny <dannyjryan@gmail.com>
Co-authored-by: danny <dannyjryan@gmail.com>
@tbenr tbenr force-pushed the specify_rpc_by_root_elegibility branch from 589d0ac to bdac932 Compare November 30, 2023 14:20
@tbenr
Copy link
Contributor Author

tbenr commented Nov 30, 2023

@mkalinin @djrtwo I added
Clients MUST NOT respond with sidecars related to blocks that fail gossip validation rules.

To explicitly drop sidecars when the corresponding blocks arrive late and fail gossip rules.

Copy link
Collaborator

@mkalinin mkalinin left a comment

Choose a reason for hiding this comment

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

I think we can merge after addressing a couple of small things

tbenr and others added 2 commits December 1, 2023 08:28
Co-authored-by: Mikhail Kalinin <noblesse.knight@gmail.com>
Co-authored-by: Mikhail Kalinin <noblesse.knight@gmail.com>
Copy link
Collaborator

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

Note for implementers: In Lodestar today the flow to query blocks by root is:

  • Receive block ReqResp response
  • Run state transition on block
  • Import to fork-choice / db
    now block is available to other ReqResp requesters

I think the requesting logic will have to be modified to:

  • Receive block ReqResp response
  • Run gossip validation rules
    Make block available to other ReqResp requesters
  • Run state transition on block
  • Import to fork-choice / db

@@ -300,6 +303,11 @@ Clients MUST support requesting sidecars since `minimum_request_epoch`, where `m
Clients MUST respond with at least one sidecar, if they have it.
Clients MAY limit the number of blocks and sidecars in the response.

Clients SHOULD include a sidecar in the response as soon as it passes the gossip validation rules.
Clients MUST NOT respond with sidecars that fails gossip validation rules.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be explicit? This is the default for all gossip topics wrt other responses and general processing, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me this explicitly states that client must not try to serve this before completing the validation, and if validation fails it must not be considered when serving the RPC call.
So there are no assumptions on clients internal RPC and gossip processing.
I agree that probably for most of current clients (teku for sure) this is true by default.

Is there somewhere a general statement that says "messages must pass gossip validation rules before being considered by any mean by the client"?

Copy link
Contributor

Choose a reason for hiding this comment

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

There is not other than the fact that gossipsub generally is gating messages from the application layer on these conditions. Not opposed to a general note if it's warranted, but I don't think we need to call out for each specific instance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair, let's remove it from here.

specs/deneb/p2p-interface.md Outdated Show resolved Hide resolved
tbenr and others added 2 commits December 1, 2023 17:29
@@ -856,6 +856,9 @@ Clients MUST support requesting blocks since the latest finalized epoch.
Clients MUST respond with at least one block, if they have it.
Clients MAY limit the number of blocks in the response.

Clients MAY include a block in the response as soon as it passes the gossip validation rules.
Clients SHOULD NOT respond with blocks that fail beacon chain state transition.
Copy link
Contributor

Choose a reason for hiding this comment

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

we can still have this post deneb as well as all clients are verifying blocks without waiting for all blobs to show up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Deneb updates the first rule but leaves this one unchanged

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good, it would have been good to enumerate the rules so as to be super clear, but nevertheless lgtm

@@ -300,6 +303,10 @@ Clients MUST support requesting sidecars since `minimum_request_epoch`, where `m
Clients MUST respond with at least one sidecar, if they have it.
Clients MAY limit the number of blocks and sidecars in the response.

Clients SHOULD include a sidecar in the response as soon as it passes the gossip validation rules.
Clients SHOULD NOT respond with sidecars related to blocks that fail gossip validation rules.
Clients SHOULD NOT include sidecars related to blocks that fail `state_transition(block)`.
Copy link
Collaborator

@mkalinin mkalinin Dec 4, 2023

Choose a reason for hiding this comment

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

Suggested change
Clients SHOULD NOT include sidecars related to blocks that fail `state_transition(block)`.
Clients SHOULD NOT include sidecars related to blocks that fail beacon chain state transition.

Copy link
Contributor

Choose a reason for hiding this comment

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

why do we wanna have this removed? seems reasonable to me

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, that was due to my misread, updated the suggestion!

specs/deneb/p2p-interface.md Show resolved Hide resolved
specs/phase0/p2p-interface.md Outdated Show resolved Hide resolved
specs/deneb/p2p-interface.md Outdated Show resolved Hide resolved
@hwwhww hwwhww added phase0 Deneb was called: eip-4844 labels Dec 4, 2023
@hwwhww hwwhww merged commit 06fe616 into ethereum:dev Dec 4, 2023
26 checks passed
@tbenr tbenr deleted the specify_rpc_by_root_elegibility branch December 4, 2023 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serving blocks and blob_sidecars in RPC byRoot right after they passed gossip validation
6 participants