Add request hash to header for builder: executable data to block (#14955)

* Add request hash to header for builder: executable data to block

* go fmt
This commit is contained in:
terence
2025-02-18 21:18:18 -08:00
committed by GitHub
parent 55efccb07f
commit 4d5dddd302
2 changed files with 13 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
### Added
- Add request hash to header for builder: executable data to block

View File

@@ -955,7 +955,7 @@ func unmarshalRPCObject(b []byte) (*jsonRPCObject, error) {
}
func modifyExecutionPayload(execPayload engine.ExecutableData, fees *big.Int, prevBeaconRoot []byte, requests [][]byte) (*engine.ExecutionPayloadEnvelope, error) {
modifiedBlock, err := executableDataToBlock(execPayload, prevBeaconRoot)
modifiedBlock, err := executableDataToBlock(execPayload, prevBeaconRoot, requests)
if err != nil {
return &engine.ExecutionPayloadEnvelope{}, err
}
@@ -963,7 +963,7 @@ func modifyExecutionPayload(execPayload engine.ExecutableData, fees *big.Int, pr
}
// This modifies the provided payload to imprint the builder's extra data
func executableDataToBlock(params engine.ExecutableData, prevBeaconRoot []byte) (*gethTypes.Block, error) {
func executableDataToBlock(params engine.ExecutableData, prevBeaconRoot []byte, requests [][]byte) (*gethTypes.Block, error) {
txs, err := decodeTransactions(params.Transactions)
if err != nil {
return nil, err
@@ -977,6 +977,12 @@ func executableDataToBlock(params engine.ExecutableData, prevBeaconRoot []byte)
withdrawalsRoot = &h
}
var requestsHash *common.Hash
if requests != nil {
h := gethTypes.CalcRequestsHash(requests)
requestsHash = &h
}
header := &gethTypes.Header{
ParentHash: params.ParentHash,
UncleHash: gethTypes.EmptyUncleHash,
@@ -996,7 +1002,9 @@ func executableDataToBlock(params engine.ExecutableData, prevBeaconRoot []byte)
WithdrawalsHash: withdrawalsRoot,
BlobGasUsed: params.BlobGasUsed,
ExcessBlobGas: params.ExcessBlobGas,
RequestsHash: requestsHash,
}
if prevBeaconRoot != nil {
pRoot := common.Hash(prevBeaconRoot)
header.ParentBeaconRoot = &pRoot