Skip to content

Commit e9c9e18

Browse files
committed
Add request hash to header for builder: executable data to block
1 parent 55efccb commit e9c9e18

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

changelog/tt_add_block_hash.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Added
2+
3+
- Add request hash to header for builder: executable data to block

testing/middleware/builder/builder.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func (p *Builder) handleHeaderRequest(w http.ResponseWriter, req *http.Request)
376376
}
377377
d, err := signing.ComputeDomain(params.BeaconConfig().DomainApplicationBuilder,
378378
nil, /* fork version */
379-
nil /* genesis val root */)
379+
nil /* genesis val root */)
380380
if err != nil {
381381
p.cfg.logger.WithError(err).Error("Could not compute the domain")
382382
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -454,7 +454,7 @@ func (p *Builder) handleHeaderRequestCapella(w http.ResponseWriter) {
454454
}
455455
d, err := signing.ComputeDomain(params.BeaconConfig().DomainApplicationBuilder,
456456
nil, /* fork version */
457-
nil /* genesis val root */)
457+
nil /* genesis val root */)
458458
if err != nil {
459459
p.cfg.logger.WithError(err).Error("Could not compute the domain")
460460
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -540,7 +540,7 @@ func (p *Builder) handleHeaderRequestDeneb(w http.ResponseWriter) {
540540
}
541541
d, err := signing.ComputeDomain(params.BeaconConfig().DomainApplicationBuilder,
542542
nil, /* fork version */
543-
nil /* genesis val root */)
543+
nil /* genesis val root */)
544544
if err != nil {
545545
p.cfg.logger.WithError(err).Error("Could not compute the domain")
546546
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -674,7 +674,7 @@ func (p *Builder) handleHeaderRequestElectra(w http.ResponseWriter) {
674674
}
675675
d, err := signing.ComputeDomain(params.BeaconConfig().DomainApplicationBuilder,
676676
nil, /* fork version */
677-
nil /* genesis val root */)
677+
nil /* genesis val root */)
678678
if err != nil {
679679
p.cfg.logger.WithError(err).Error("Could not compute the domain")
680680
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -955,15 +955,15 @@ func unmarshalRPCObject(b []byte) (*jsonRPCObject, error) {
955955
}
956956

957957
func modifyExecutionPayload(execPayload engine.ExecutableData, fees *big.Int, prevBeaconRoot []byte, requests [][]byte) (*engine.ExecutionPayloadEnvelope, error) {
958-
modifiedBlock, err := executableDataToBlock(execPayload, prevBeaconRoot)
958+
modifiedBlock, err := executableDataToBlock(execPayload, prevBeaconRoot, requests)
959959
if err != nil {
960960
return &engine.ExecutionPayloadEnvelope{}, err
961961
}
962962
return engine.BlockToExecutableData(modifiedBlock, fees, nil /*blobs*/, requests /*requests*/), nil
963963
}
964964

965965
// This modifies the provided payload to imprint the builder's extra data
966-
func executableDataToBlock(params engine.ExecutableData, prevBeaconRoot []byte) (*gethTypes.Block, error) {
966+
func executableDataToBlock(params engine.ExecutableData, prevBeaconRoot []byte, requests [][]byte) (*gethTypes.Block, error) {
967967
txs, err := decodeTransactions(params.Transactions)
968968
if err != nil {
969969
return nil, err
@@ -977,6 +977,12 @@ func executableDataToBlock(params engine.ExecutableData, prevBeaconRoot []byte)
977977
withdrawalsRoot = &h
978978
}
979979

980+
var requestsHash *common.Hash
981+
if requests != nil {
982+
h := gethTypes.CalcRequestsHash(requests)
983+
requestsHash = &h
984+
}
985+
980986
header := &gethTypes.Header{
981987
ParentHash: params.ParentHash,
982988
UncleHash: gethTypes.EmptyUncleHash,
@@ -996,7 +1002,9 @@ func executableDataToBlock(params engine.ExecutableData, prevBeaconRoot []byte)
9961002
WithdrawalsHash: withdrawalsRoot,
9971003
BlobGasUsed: params.BlobGasUsed,
9981004
ExcessBlobGas: params.ExcessBlobGas,
1005+
RequestsHash: requestsHash,
9991006
}
1007+
10001008
if prevBeaconRoot != nil {
10011009
pRoot := common.Hash(prevBeaconRoot)
10021010
header.ParentBeaconRoot = &pRoot

0 commit comments

Comments
 (0)