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

feat(pectra): Use EIP-7865 encoding for execution_requests #107

Closed
Show file tree
Hide file tree
Changes from 1 commit
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
28 changes: 1 addition & 27 deletions examples/electra/signed_blinded_beacon_block.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,33 +188,7 @@
"blob_kzg_commitments": [
"0xa94170080872584e54a1cf092d845703b13907f2e6b3b1c0ad573b910530499e3bcd48c6378846b80d2bfa58c81cf3d5"
],
"execution_requests": {
"deposits": [
{
"pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
"withdrawal_credentials": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"amount": "1",
"signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505",
"index": "1",
}
],
"withdrawals": [
{
"source_address": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
"validator_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
"amount": "1",
}
],
"consolidations": [
{
"source_address": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
"source_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
"target_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
}
]
}
}
},
"execution_requests": [ "0x00_TODO_DEPOSITS", "0x01_TODO_WITHDRAWLS", "0x02_TODO_CONSOLIDATIONS"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use the example value in ethereum/execution-apis#607 .

Copy link
Author

Choose a reason for hiding this comment

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

Perfect, updated in 7955984 as well, thanks again!

"signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505"
}
}
26 changes: 1 addition & 25 deletions examples/electra/signed_builder_bid.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,7 @@
"blob_kzg_commitments": [
"0xa94170080872584e54a1cf092d845703b13907f2e6b3b1c0ad573b910530499e3bcd48c6378846b80d2bfa58c81cf3d5"
],
"execution_requests": {
"deposits": [
{
"pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
"withdrawal_credentials": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"amount": "1",
"signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505",
"index": "1",
}
],
"withdrawals": [
{
"source_address": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
"validator_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
"amount": "1",
}
],
"consolidations": [
{
"source_address": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
"source_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
"target_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
}
]
},
"execution_requests": [ "0x00_TODO_DEPOSITS", "0x01_TODO_WITHDRAWLS", "0x02_TODO_CONSOLIDATIONS"],
"value": "1",
"pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a"
},
Expand Down
29 changes: 27 additions & 2 deletions specs/electra/builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Note: `SignedBuilderBid` is updated indirectly.
class BuilderBid(Container):
header: ExecutionPayloadHeader
blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]
execution_requests: ExecutionRequests # [New in Electra]
execution_requests: OpaqueExecutionRequests # [New in Electra]
value: uint256
pubkey: BLSPubkey
```
Expand All @@ -41,7 +41,32 @@ class BlindedBeaconBlockBody(Container):
execution_payload_header: ExecutionPayloadHeader
bls_to_execution_changes: List[SignedBLSToExecutionChange, MAX_BLS_TO_EXECUTION_CHANGES]
blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]
execution_requests: ExecutionRequests # [New in Electra]
execution_requests: OpaqueExecutionRequests # [New in Electra]
```

### New Containers

### `OpaqueExecutionRequests`

```python
class OpaqueExecutionRequests(List[Bitvector]):
Copy link
Member

Choose a reason for hiding this comment

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

those are not really opaque, just ssz encoded and 1-byte prefixed, anyone can decode the requests and read the data

Copy link
Author

Choose a reason for hiding this comment

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

They're "semantically" opaque, EIP-7865 stipulates that each request type is allowed to decide its own encoding, it's just a coincidence that the current three are all SSZ in the same way that all EIP-2718 txs are currently RLP.

A requests object consists of a request_type prepended to an opaque byte array request_data. The request_data contains zero or more encoded request objects.

Each request type will defines its own requests object with its own request_data format.

Copy link
Member

Choose a reason for hiding this comment

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

I guess if the same wording is used on the engine-api side this is fine

pass
```

`OpaqueExecutionRequests` is simply a "type alias" for a `List[Bitvector]`, this type follows the encoding of execution
requests as explained in EIP-7865. Specifically for Electra, the list should contain three elements, one for
each of the type-prefixed and byte-encoded `Deposit`, `Withdrawal` and `Consolidation` request lists.

Note that while each `Bitvector` appears as an arbitrary-length byte sequence, technically each entry is bound
by the encoded length of each request type and the maximum amount of each request type allowed in a block.

## Building

Builders provide bids as they have in prior forks, with the addition of execution requests.

### Execution Requests

The actual payloads for each request type are generated as side-effects of block-building, see EIP-6110 for
`Deposit`, EIP-7002 for `Withdrawal` and EIP-7251 for `Consolidation` requests.

[execution-payload-and-blobs-bundle-deneb]: ../deneb/builder.md#executionpayloadandblobsbundle
8 changes: 6 additions & 2 deletions types/electra/bid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ Electra:
maxItems: 4096
description: "the `KZGCommitment`s for the associated blobs for this `header`"
execution_requests:
$ref: "../../beacon-apis/types/electra/execution_requests.yaml#/Electra/ExecutionRequests"
description: "`ExecutionRequests` to include in block proposal."
type: array
items:
$ref: '../../beacon-apis/types/primitive.yaml#/Bitvector'

Choose a reason for hiding this comment

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

I am not sure if the Bitvector is a good semantic representation for the opaque field, although technically, it could work.

I would consider adding a Bytes primitive type (similar to Bytes32) but unbounded in length.

Keen to have people weight in on this before committing to it.

Copy link
Author

Choose a reason for hiding this comment

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

Funny when writing this up I originally used Bytes only to go look up the actual primitives and realize it didn't exist. :). So ya I'd be in favor of that change as well. I assume that'd be a separate PR on https://github.com/ethereum/beacon-apis/ ?

Choose a reason for hiding this comment

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

I believe so. It looks like builder-specs is importing beacon-api as a git submodule and referring to the types defined there.

Copy link
Author

Choose a reason for hiding this comment

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

Ok cool I just sent ethereum/beacon-APIs#484 I guess if this is accepted I can update the submodule in this PR and point to that. Thanks for the suggestion!

Copy link
Member

Choose a reason for hiding this comment

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

I would consider adding a Bytes primitive type (similar to Bytes32) but unbounded in length.

you can't have unbounded ssz types

minItems: 3
Copy link
Contributor

Choose a reason for hiding this comment

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

minItems should be 0 in case all of the requests (deposit, withdrawal and consolidation) are empty

Copy link
Author

Choose a reason for hiding this comment

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

Oh right I was still thinking pre- ethereum/execution-apis#599, updated in 7955984 thanks!

maxItems: 3
description: "EIP-7685 encoded `ExecutionRequests` to include in block proposal."
- $ref: '../bellatrix/bid.yaml#/Bellatrix/BuilderBidCommon'

SignedBuilderBid:
Expand Down