2023-01-25 17:32:25 +03:00
|
|
|
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
|
|
|
|
2023-02-06 18:37:58 +03:00
|
|
|
package engine
|
2023-01-25 17:32:25 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"errors"
|
|
|
|
"math/big"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = (*executionPayloadEnvelopeMarshaling)(nil)
|
|
|
|
|
|
|
|
// MarshalJSON marshals as JSON.
|
|
|
|
func (e ExecutionPayloadEnvelope) MarshalJSON() ([]byte, error) {
|
|
|
|
type ExecutionPayloadEnvelope struct {
|
|
|
|
ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"`
|
|
|
|
BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"`
|
2023-07-18 10:44:16 +03:00
|
|
|
BlobsBundle *BlobsBundleV1 `json:"blobsBundle"`
|
2024-10-09 13:24:58 +03:00
|
|
|
Requests []hexutil.Bytes `json:"executionRequests"`
|
2023-09-04 16:26:13 +03:00
|
|
|
Override bool `json:"shouldOverrideBuilder"`
|
2024-10-15 11:51:20 +03:00
|
|
|
Witness *hexutil.Bytes `json:"witness,omitempty"`
|
2023-01-25 17:32:25 +03:00
|
|
|
}
|
|
|
|
var enc ExecutionPayloadEnvelope
|
|
|
|
enc.ExecutionPayload = e.ExecutionPayload
|
|
|
|
enc.BlockValue = (*hexutil.Big)(e.BlockValue)
|
2023-07-18 10:44:16 +03:00
|
|
|
enc.BlobsBundle = e.BlobsBundle
|
2024-10-09 13:24:58 +03:00
|
|
|
if e.Requests != nil {
|
|
|
|
enc.Requests = make([]hexutil.Bytes, len(e.Requests))
|
|
|
|
for k, v := range e.Requests {
|
|
|
|
enc.Requests[k] = v
|
|
|
|
}
|
|
|
|
}
|
2023-09-04 16:26:13 +03:00
|
|
|
enc.Override = e.Override
|
beacon, core, eth, miner: integrate witnesses into production Geth (#30069)
This PR integrates witness-enabled block production, witness-creating
payload execution and stateless cross-validation into the `engine` API.
The purpose of the PR is to enable the following use-cases (for API
details, please see next section):
- Cross validating locally created blocks:
- Call `forkchoiceUpdatedWithWitness` instead of `forkchoiceUpdated` to
trigger witness creation too.
- Call `getPayload` as before to retrieve the new block and also the
above created witness.
- Call `executeStatelessPayload` against another client to
cross-validate the block.
- Cross validating locally processed blocks:
- Call `newPayloadWithWitness` instead of `newPayload` to trigger
witness creation too.
- Call `executeStatelessPayload` against another client to
cross-validate the block.
- Block production for stateless clients (local or MEV builders):
- Call `forkchoiceUpdatedWithWitness` instead of `forkchoiceUpdated` to
trigger witness creation too.
- Call `getPayload` as before to retrieve the new block and also the
above created witness.
- Propagate witnesses across the consensus libp2p network for stateless
Ethereum.
- Stateless validator validation:
- Call `executeStatelessPayload` with the propagated witness to
statelessly validate the block.
*Note, the various `WithWitness` methods could also *just be* an
additional boolean flag on the base methods, but this PR wanted to keep
the methods separate until a final consensus is reached on how to
integrate in production.*
---
The following `engine` API types are introduced:
```go
// StatelessPayloadStatusV1 is the result of a stateless payload execution.
type StatelessPayloadStatusV1 struct {
Status string `json:"status"`
StateRoot common.Hash `json:"stateRoot"`
ReceiptsRoot common.Hash `json:"receiptsRoot"`
ValidationError *string `json:"validationError"`
}
```
- Add `forkchoiceUpdatedWithWitnessV1,2,3` with same params and returns
as `forkchoiceUpdatedV1,2,3`, but triggering a stateless witness
building if block production is requested.
- Extend `getPayloadV2,3` to return `executionPayloadEnvelope` with an
additional `witness` field of type `bytes` iff created via
`forkchoiceUpdatedWithWitnessV2,3`.
- Add `newPayloadWithWitnessV1,2,3,4` with same params and returns as
`newPayloadV1,2,3,4`, but triggering a stateless witness creation during
payload execution to allow cross validating it.
- Extend `payloadStatusV1` with a `witness` field of type `bytes` if
returned by `newPayloadWithWitnessV1,2,3,4`.
- Add `executeStatelessPayloadV1,2,3,4` with same base params as
`newPayloadV1,2,3,4` and one more additional param (`witness`) of type
`bytes`. The method returns `statelessPayloadStatusV1`, which mirrors
`payloadStatusV1` but replaces `latestValidHash` with `stateRoot` and
`receiptRoot`.
2024-09-20 16:43:42 +03:00
|
|
|
enc.Witness = e.Witness
|
2023-01-25 17:32:25 +03:00
|
|
|
return json.Marshal(&enc)
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON unmarshals from JSON.
|
|
|
|
func (e *ExecutionPayloadEnvelope) UnmarshalJSON(input []byte) error {
|
|
|
|
type ExecutionPayloadEnvelope struct {
|
|
|
|
ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"`
|
|
|
|
BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"`
|
2023-07-18 10:44:16 +03:00
|
|
|
BlobsBundle *BlobsBundleV1 `json:"blobsBundle"`
|
2024-10-09 13:24:58 +03:00
|
|
|
Requests []hexutil.Bytes `json:"executionRequests"`
|
2023-09-04 16:26:13 +03:00
|
|
|
Override *bool `json:"shouldOverrideBuilder"`
|
2024-10-15 11:51:20 +03:00
|
|
|
Witness *hexutil.Bytes `json:"witness,omitempty"`
|
2023-01-25 17:32:25 +03:00
|
|
|
}
|
|
|
|
var dec ExecutionPayloadEnvelope
|
|
|
|
if err := json.Unmarshal(input, &dec); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if dec.ExecutionPayload == nil {
|
|
|
|
return errors.New("missing required field 'executionPayload' for ExecutionPayloadEnvelope")
|
|
|
|
}
|
|
|
|
e.ExecutionPayload = dec.ExecutionPayload
|
|
|
|
if dec.BlockValue == nil {
|
|
|
|
return errors.New("missing required field 'blockValue' for ExecutionPayloadEnvelope")
|
|
|
|
}
|
|
|
|
e.BlockValue = (*big.Int)(dec.BlockValue)
|
2023-07-18 10:44:16 +03:00
|
|
|
if dec.BlobsBundle != nil {
|
|
|
|
e.BlobsBundle = dec.BlobsBundle
|
|
|
|
}
|
2024-10-09 13:24:58 +03:00
|
|
|
if dec.Requests != nil {
|
|
|
|
e.Requests = make([][]byte, len(dec.Requests))
|
|
|
|
for k, v := range dec.Requests {
|
|
|
|
e.Requests[k] = v
|
|
|
|
}
|
|
|
|
}
|
2023-09-04 16:26:13 +03:00
|
|
|
if dec.Override != nil {
|
|
|
|
e.Override = *dec.Override
|
|
|
|
}
|
beacon, core, eth, miner: integrate witnesses into production Geth (#30069)
This PR integrates witness-enabled block production, witness-creating
payload execution and stateless cross-validation into the `engine` API.
The purpose of the PR is to enable the following use-cases (for API
details, please see next section):
- Cross validating locally created blocks:
- Call `forkchoiceUpdatedWithWitness` instead of `forkchoiceUpdated` to
trigger witness creation too.
- Call `getPayload` as before to retrieve the new block and also the
above created witness.
- Call `executeStatelessPayload` against another client to
cross-validate the block.
- Cross validating locally processed blocks:
- Call `newPayloadWithWitness` instead of `newPayload` to trigger
witness creation too.
- Call `executeStatelessPayload` against another client to
cross-validate the block.
- Block production for stateless clients (local or MEV builders):
- Call `forkchoiceUpdatedWithWitness` instead of `forkchoiceUpdated` to
trigger witness creation too.
- Call `getPayload` as before to retrieve the new block and also the
above created witness.
- Propagate witnesses across the consensus libp2p network for stateless
Ethereum.
- Stateless validator validation:
- Call `executeStatelessPayload` with the propagated witness to
statelessly validate the block.
*Note, the various `WithWitness` methods could also *just be* an
additional boolean flag on the base methods, but this PR wanted to keep
the methods separate until a final consensus is reached on how to
integrate in production.*
---
The following `engine` API types are introduced:
```go
// StatelessPayloadStatusV1 is the result of a stateless payload execution.
type StatelessPayloadStatusV1 struct {
Status string `json:"status"`
StateRoot common.Hash `json:"stateRoot"`
ReceiptsRoot common.Hash `json:"receiptsRoot"`
ValidationError *string `json:"validationError"`
}
```
- Add `forkchoiceUpdatedWithWitnessV1,2,3` with same params and returns
as `forkchoiceUpdatedV1,2,3`, but triggering a stateless witness
building if block production is requested.
- Extend `getPayloadV2,3` to return `executionPayloadEnvelope` with an
additional `witness` field of type `bytes` iff created via
`forkchoiceUpdatedWithWitnessV2,3`.
- Add `newPayloadWithWitnessV1,2,3,4` with same params and returns as
`newPayloadV1,2,3,4`, but triggering a stateless witness creation during
payload execution to allow cross validating it.
- Extend `payloadStatusV1` with a `witness` field of type `bytes` if
returned by `newPayloadWithWitnessV1,2,3,4`.
- Add `executeStatelessPayloadV1,2,3,4` with same base params as
`newPayloadV1,2,3,4` and one more additional param (`witness`) of type
`bytes`. The method returns `statelessPayloadStatusV1`, which mirrors
`payloadStatusV1` but replaces `latestValidHash` with `stateRoot` and
`receiptRoot`.
2024-09-20 16:43:42 +03:00
|
|
|
if dec.Witness != nil {
|
|
|
|
e.Witness = dec.Witness
|
|
|
|
}
|
2023-01-25 17:32:25 +03:00
|
|
|
return nil
|
|
|
|
}
|