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

Add bid proofs to the builder bid response #51

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions apis/builder/header.v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
get:
operationId: "getHeaderV2"
Copy link
Member

Choose a reason for hiding this comment

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

I really don't like this VX post-fix notation. At minimum, we should rehome the api at a v2 root. I think actually prefer just expanding the existing types with optional fields.

summary: Get an execution payload header along with the payout proof to the bid
description: |
Requests a builder node to produce a valid execution payload header, which
can be integrated into a blinded beacon block and signed.

Builder must immediately return the header that is able to pay the
proposer's registered `fee_recipient` the most. If the builder is unaware
of `parent_hash`, it must error. If `pubkey` does not match the builder's
expected proposer `pubkey` for `slot`, it must error. If the builder has
not received a validator registration associated with `pubkey`, it must
error.

When possible, the builder must return a header with `gas_limit` equal to
proposer's registered value. If this isn't possible due to the large
difference between `parent.gas_limit` and the preferred `gas_limit`, the
builder must return a header that moves `gas_limit` the maximum amount
allowed under the rules of consensus (currently `parent.gas_limit +/-
parent.gas_limit / 1024`).
tags:
- Builder
parameters:
- name: slot
in: path
required: true
description: The slot for which the block should be proposed.
schema:
$ref: "../../builder-oapi.yaml#/components/schemas/Uint64"
- name: parent_hash
in: path
required: true
description: Hash of execution layer block the proposer will build on.
schema:
$ref: "../../builder-oapi.yaml#/components/schemas/Root"
- name: pubkey
in: path
required: true
description: The validator's BLS public key.
schema:
$ref: "../../builder-oapi.yaml#/components/schemas/Pubkey"
responses:
"200":
description: Success response.
content:
application/json:
schema:
title: GetHeaderResponse
type: object
properties:
version:
type: string
enum: [ bellatrix ]
example: "bellatrix"
data:
oneOf:
- $ref: "../../builder-oapi.yaml#/components/schemas/Bellatrix.SignedBuilderBidV2"
proof:
oneOf:
- $ref: "../../builder-oapi.yaml#/components/schemas/BidProof"
examples:
bellatrix:
$ref: "../../builder-oapi.yaml#/components/examples/Bellatrix.SignedBuilderBidV2"
"204":
description: No header is available.
"400":
description: Error response.
content:
application/json:
schema:
$ref: "../../builder-oapi.yaml#/components/schemas/ErrorMessage"
examples:
InvalidRequest:
value:
code: 400
message: "Unknown hash: missing parent hash"
"500":
$ref: "../../builder-oapi.yaml#/components/responses/InternalError"
1 change: 1 addition & 0 deletions apis/builder/header.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ get:
builder must return a header that moves `gas_limit` the maximum amount
allowed under the rules of consensus (currently `parent.gas_limit +/-
parent.gas_limit / 1024`).
deprecated: true
tags:
- Builder
parameters:
Expand Down
29 changes: 29 additions & 0 deletions examples/bellatrix/signed_builder_bid_v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"value": {
"version": "bellatrix",
"data": {
"message": {
"header": {
"parent_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"fee_recipient": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
"state_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"receipts_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"prev_randao": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"block_number": "1",
"gas_limit": "1",
"gas_used": "1",
"timestamp": "1",
"extra_data": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"base_fee_per_gas": "1",
"block_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"transactions_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"
},
"value": "1",
"pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
"fee_recipient": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
},
"signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505"
}
}
}
12 changes: 11 additions & 1 deletion specs/builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
| - | - |
| `DOMAIN_APPLICATION_BUILDER` | `DomainType('0x00000001')` |

### Execution proof

| Name | Value |
| - | - |
| `MAX_EXECUTION_PROOF_DEPTH` | 64 |
| `MAX_BRANCH_SIZE` | `17` |

## Containers

Consider the following definitions supplementary to the definitions in
Expand Down Expand Up @@ -72,10 +79,13 @@ Bellatrix).
##### `BuilderBid`

```python
class BuilderBid(Container):
class BuilderBidV2(Container):
header: ExecutionPayloadHeader
value: uint256
pubkey: BLSPubkey
fee_recipient: ExecutionAddress
# RLP encoded size of list of max 17 32bytes branches is 564 bytes
proof: List[ByteList[564], MAX_EXECUTION_PROOF_DEPTH]
```

##### `SignedBuilderBid`
Expand Down
27 changes: 27 additions & 0 deletions types/bellatrix/bid.v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Bellatrix:
BuilderBidV2:
type: object
description: "The `BuilderBidV2` object from the Builder API spec."
properties:
header:
$ref: "../../beacon-apis/types/bellatrix/execution_payload.yaml#/Bellatrix/ExecutionPayloadHeader"
description: "`ExecutionPayloadHeader` to use in block proposal."
value:
$ref: "../../beacon-apis/types/primitive.yaml#/Uint256"
description: "Payment in wei that will be paid to the `fee_recipient` account."
pubkey:
$ref: "../../beacon-apis/types/primitive.yaml#/Pubkey"
description: "BLS public key of builder."
# Builder should return where its paying out the bid to
fee_recipient:
$ref: '../../beacon-apis/types/primitive.yaml#/ExecutionAddress'
description: "The address the bid will be paid to, as registered previously with builder"

SignedBuilderBidV2:
type: object
description: "The `SignedBuilderBidV2` object from the Builder API spec."
properties:
message:
$ref: "#/Bellatrix/BuilderBidV2"
signature:
$ref: "../../beacon-apis/types/primitive.yaml#/Signature"
26 changes: 26 additions & 0 deletions types/proof.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ProofNode:
type: string
description: "An rlp encoded hex string representing a node in merkle proof branch"
example: "0xdf820023db808080c620841920682380c4208219208080808080808080808080"
# RLP encoded size of list of max 17 32bytes branches is 564 bytes
pattern: "^0x[a-fA-F0-9]{0,1128}$"

ProofNodes:
type: array
items:
allOf:
Copy link
Member

Choose a reason for hiding this comment

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

is allOf necessary here?

- $ref: "#/ProofNode"
maxItems: 64

BidProof:
type: object
description: "The merkle proof of the `fee_recipient` account post the corresponding `BuilderBidV2` promised payout"
properties:
address:
$ref: '../../beacon-apis/types/primitive.yaml#/ExecutionAddress'
description: "The account address for which proof has been generated, should match `fee_recipient` of `BuilderBidV2`"
balance:
$ref: "../../beacon-apis/types/primitive.yaml#/Uint256"
description: "Post balance in gwei of the account (corresponding to the `stateRoot` of the `header` returned by `BuilderBidV2`)"
nodes:
$ref: "#/ProofNodes"