Add proof version back

This commit is contained in:
Francis Li 2025-03-26 08:42:37 -07:00
parent df2a3c8782
commit 607ee3b450
No known key found for this signature in database
GPG key ID: 39F1A72C987F3F88
2 changed files with 13 additions and 0 deletions

View file

@ -35,6 +35,7 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
ExecutionWitness *types.ExecutionWitness `json:"executionWitness,omitempty"`
ProofVersion *uint8 `json:"proofVersion"`
}
var enc ExecutableData
enc.ParentHash = e.ParentHash
@ -60,6 +61,7 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
enc.BlobGasUsed = (*hexutil.Uint64)(e.BlobGasUsed)
enc.ExcessBlobGas = (*hexutil.Uint64)(e.ExcessBlobGas)
enc.ExecutionWitness = e.ExecutionWitness
enc.ProofVersion = e.ProofVersion
return json.Marshal(&enc)
}
@ -84,6 +86,7 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
ExecutionWitness *types.ExecutionWitness `json:"executionWitness,omitempty"`
ProofVersion *uint8 `json:"proofVersion"`
}
var dec ExecutableData
if err := json.Unmarshal(input, &dec); err != nil {
@ -160,5 +163,8 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
if dec.ExecutionWitness != nil {
e.ExecutionWitness = dec.ExecutionWitness
}
if dec.ProofVersion != nil {
e.ProofVersion = dec.ProofVersion
}
return nil
}

View file

@ -77,6 +77,7 @@ type ExecutableData struct {
BlobGasUsed *uint64 `json:"blobGasUsed"`
ExcessBlobGas *uint64 `json:"excessBlobGas"`
ExecutionWitness *types.ExecutionWitness `json:"executionWitness,omitempty"`
ProofVersion *uint8 `json:"proofVersion"`
}
// JSON type overrides for executableData.
@ -306,6 +307,11 @@ func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.H
// BlockToExecutableData constructs the ExecutableData structure by filling the
// fields from the given block. It assumes the given block is post-merge block.
func BlockToExecutableData(block *types.Block, fees *big.Int, sidecars []*types.BlobTxSidecar, requests [][]byte) *ExecutionPayloadEnvelope {
proofVersion := uint8(0)
// TODO: could be more strict
if len(sidecars) > 0 && len(sidecars[0].Proofs) != len(sidecars[0].Blobs) {
proofVersion = 1
}
data := &ExecutableData{
BlockHash: block.Hash(),
ParentHash: block.ParentHash(),
@ -325,6 +331,7 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, sidecars []*types.
BlobGasUsed: block.BlobGasUsed(),
ExcessBlobGas: block.ExcessBlobGas(),
ExecutionWitness: block.ExecutionWitness(),
ProofVersion: &proofVersion,
}
// Add blobs.