@ -541,7 +541,7 @@ func (api *ConsensusAPI) NewPayloadV1(params engine.ExecutableData) (engine.Payl
if params . Withdrawals != nil {
if params . Withdrawals != nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "withdrawals not supported in V1" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "withdrawals not supported in V1" ) )
}
}
return api . newPayload ( params , nil , nil , false )
return api . newPayload ( params , nil , nil , nil , false )
}
}
// NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
// NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
@ -564,7 +564,7 @@ func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.Payl
if params . BlobGasUsed != nil {
if params . BlobGasUsed != nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "non-nil blobGasUsed pre-cancun" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "non-nil blobGasUsed pre-cancun" ) )
}
}
return api . newPayload ( params , nil , nil , false )
return api . newPayload ( params , nil , nil , nil , false )
}
}
// NewPayloadV3 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
// NewPayloadV3 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
@ -589,12 +589,12 @@ func (api *ConsensusAPI) NewPayloadV3(params engine.ExecutableData, versionedHas
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Cancun {
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Cancun {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "newPayloadV3 must only be called for cancun payloads" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "newPayloadV3 must only be called for cancun payloads" ) )
}
}
return api . newPayload ( params , versionedHashes , beaconRoot , false )
return api . newPayload ( params , versionedHashes , beaconRoot , nil , false )
}
}
// NewPayloadV4 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
// NewPayloadV4 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
// NewPayloadV4 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
// NewPayloadV4 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
func ( api * ConsensusAPI ) NewPayloadV4 ( params engine . ExecutableData , versionedHashes [ ] common . Hash , beaconRoot * common . Hash ) ( engine . PayloadStatusV1 , error ) {
func ( api * ConsensusAPI ) NewPayloadV4 ( params engine . ExecutableData , versionedHashes [ ] common . Hash , beaconRoot * common . Hash , requests [ ] [ ] byte ) ( engine . PayloadStatusV1 , error ) {
if params . Withdrawals == nil {
if params . Withdrawals == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil withdrawals post-shanghai" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil withdrawals post-shanghai" ) )
}
}
@ -604,9 +604,6 @@ func (api *ConsensusAPI) NewPayloadV4(params engine.ExecutableData, versionedHas
if params . BlobGasUsed == nil {
if params . BlobGasUsed == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil blobGasUsed post-cancun" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil blobGasUsed post-cancun" ) )
}
}
if params . Deposits == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil deposits post-prague" ) )
}
if versionedHashes == nil {
if versionedHashes == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil versionedHashes post-cancun" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil versionedHashes post-cancun" ) )
@ -614,11 +611,14 @@ func (api *ConsensusAPI) NewPayloadV4(params engine.ExecutableData, versionedHas
if beaconRoot == nil {
if beaconRoot == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil beaconRoot post-cancun" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil beaconRoot post-cancun" ) )
}
}
if requests == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil executionRequests post-prague" ) )
}
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Prague {
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Prague {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "newPayloadV4 must only be called for prague payloads" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "newPayloadV4 must only be called for prague payloads" ) )
}
}
return api . newPayload ( params , versionedHashes , beaconRoot , false )
return api . newPayload ( params , versionedHashes , beaconRoot , requests , false )
}
}
// NewPayloadWithWitnessV1 is analogous to NewPayloadV1, only it also generates
// NewPayloadWithWitnessV1 is analogous to NewPayloadV1, only it also generates
@ -627,7 +627,7 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV1(params engine.ExecutableData) (
if params . Withdrawals != nil {
if params . Withdrawals != nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "withdrawals not supported in V1" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "withdrawals not supported in V1" ) )
}
}
return api . newPayload ( params , nil , nil , true )
return api . newPayload ( params , nil , nil , nil , true )
}
}
// NewPayloadWithWitnessV2 is analogous to NewPayloadV2, only it also generates
// NewPayloadWithWitnessV2 is analogous to NewPayloadV2, only it also generates
@ -651,7 +651,7 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV2(params engine.ExecutableData) (
if params . BlobGasUsed != nil {
if params . BlobGasUsed != nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "non-nil blobGasUsed pre-cancun" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "non-nil blobGasUsed pre-cancun" ) )
}
}
return api . newPayload ( params , nil , nil , true )
return api . newPayload ( params , nil , nil , nil , true )
}
}
// NewPayloadWithWitnessV3 is analogous to NewPayloadV3, only it also generates
// NewPayloadWithWitnessV3 is analogous to NewPayloadV3, only it also generates
@ -677,12 +677,12 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV3(params engine.ExecutableData, v
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Cancun {
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Cancun {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "newPayloadWithWitnessV3 must only be called for cancun payloads" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "newPayloadWithWitnessV3 must only be called for cancun payloads" ) )
}
}
return api . newPayload ( params , versionedHashes , beaconRoot , true )
return api . newPayload ( params , versionedHashes , beaconRoot , nil , true )
}
}
// NewPayloadWithWitnessV4 is analogous to NewPayloadV4, only it also generates
// NewPayloadWithWitnessV4 is analogous to NewPayloadV4, only it also generates
// and returns a stateless witness after running the payload.
// and returns a stateless witness after running the payload.
func ( api * ConsensusAPI ) NewPayloadWithWitnessV4 ( params engine . ExecutableData , versionedHashes [ ] common . Hash , beaconRoot * common . Hash ) ( engine . PayloadStatusV1 , error ) {
func ( api * ConsensusAPI ) NewPayloadWithWitnessV4 ( params engine . ExecutableData , versionedHashes [ ] common . Hash , beaconRoot * common . Hash , requests [ ] [ ] byte ) ( engine . PayloadStatusV1 , error ) {
if params . Withdrawals == nil {
if params . Withdrawals == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil withdrawals post-shanghai" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil withdrawals post-shanghai" ) )
}
}
@ -692,9 +692,6 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV4(params engine.ExecutableData, v
if params . BlobGasUsed == nil {
if params . BlobGasUsed == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil blobGasUsed post-cancun" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil blobGasUsed post-cancun" ) )
}
}
if params . Deposits == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil deposits post-prague" ) )
}
if versionedHashes == nil {
if versionedHashes == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil versionedHashes post-cancun" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil versionedHashes post-cancun" ) )
@ -702,11 +699,14 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV4(params engine.ExecutableData, v
if beaconRoot == nil {
if beaconRoot == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil beaconRoot post-cancun" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil beaconRoot post-cancun" ) )
}
}
if requests == nil {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil executionRequests post-prague" ) )
}
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Prague {
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Prague {
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "newPayloadWithWitnessV4 must only be called for prague payloads" ) )
return engine . PayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "newPayloadWithWitnessV4 must only be called for prague payloads" ) )
}
}
return api . newPayload ( params , versionedHashes , beaconRoot , true )
return api . newPayload ( params , versionedHashes , beaconRoot , requests , true )
}
}
// ExecuteStatelessPayloadV1 is analogous to NewPayloadV1, only it operates in
// ExecuteStatelessPayloadV1 is analogous to NewPayloadV1, only it operates in
@ -715,7 +715,7 @@ func (api *ConsensusAPI) ExecuteStatelessPayloadV1(params engine.ExecutableData,
if params . Withdrawals != nil {
if params . Withdrawals != nil {
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "withdrawals not supported in V1" ) )
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "withdrawals not supported in V1" ) )
}
}
return api . executeStatelessPayload ( params , nil , nil , opaqueWitness )
return api . executeStatelessPayload ( params , nil , nil , nil , opaqueWitness )
}
}
// ExecuteStatelessPayloadV2 is analogous to NewPayloadV2, only it operates in
// ExecuteStatelessPayloadV2 is analogous to NewPayloadV2, only it operates in
@ -739,7 +739,7 @@ func (api *ConsensusAPI) ExecuteStatelessPayloadV2(params engine.ExecutableData,
if params . BlobGasUsed != nil {
if params . BlobGasUsed != nil {
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "non-nil blobGasUsed pre-cancun" ) )
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "non-nil blobGasUsed pre-cancun" ) )
}
}
return api . executeStatelessPayload ( params , nil , nil , opaqueWitness )
return api . executeStatelessPayload ( params , nil , nil , nil , opaqueWitness )
}
}
// ExecuteStatelessPayloadV3 is analogous to NewPayloadV3, only it operates in
// ExecuteStatelessPayloadV3 is analogous to NewPayloadV3, only it operates in
@ -765,12 +765,12 @@ func (api *ConsensusAPI) ExecuteStatelessPayloadV3(params engine.ExecutableData,
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Cancun {
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Cancun {
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "executeStatelessPayloadV3 must only be called for cancun payloads" ) )
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "executeStatelessPayloadV3 must only be called for cancun payloads" ) )
}
}
return api . executeStatelessPayload ( params , versionedHashes , beaconRoot , opaqueWitness )
return api . executeStatelessPayload ( params , versionedHashes , beaconRoot , nil , opaqueWitness )
}
}
// ExecuteStatelessPayloadV4 is analogous to NewPayloadV4, only it operates in
// ExecuteStatelessPayloadV4 is analogous to NewPayloadV4, only it operates in
// a stateless mode on top of a provided witness instead of the local database.
// a stateless mode on top of a provided witness instead of the local database.
func ( api * ConsensusAPI ) ExecuteStatelessPayloadV4 ( params engine . ExecutableData , versionedHashes [ ] common . Hash , beaconRoot * common . Hash , opaqueWitness hexutil . Bytes ) ( engine . StatelessPayloadStatusV1 , error ) {
func ( api * ConsensusAPI ) ExecuteStatelessPayloadV4 ( params engine . ExecutableData , versionedHashes [ ] common . Hash , beaconRoot * common . Hash , requests [ ] [ ] byte , opaqueWitness hexutil . Bytes ) ( engine . StatelessPayloadStatusV1 , error ) {
if params . Withdrawals == nil {
if params . Withdrawals == nil {
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil withdrawals post-shanghai" ) )
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil withdrawals post-shanghai" ) )
}
}
@ -780,9 +780,6 @@ func (api *ConsensusAPI) ExecuteStatelessPayloadV4(params engine.ExecutableData,
if params . BlobGasUsed == nil {
if params . BlobGasUsed == nil {
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil blobGasUsed post-cancun" ) )
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil blobGasUsed post-cancun" ) )
}
}
if params . Deposits == nil {
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil deposits post-prague" ) )
}
if versionedHashes == nil {
if versionedHashes == nil {
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil versionedHashes post-cancun" ) )
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil versionedHashes post-cancun" ) )
@ -790,14 +787,17 @@ func (api *ConsensusAPI) ExecuteStatelessPayloadV4(params engine.ExecutableData,
if beaconRoot == nil {
if beaconRoot == nil {
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil beaconRoot post-cancun" ) )
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil beaconRoot post-cancun" ) )
}
}
if requests == nil {
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . InvalidParams . With ( errors . New ( "nil executionRequests post-prague" ) )
}
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Prague {
if api . eth . BlockChain ( ) . Config ( ) . LatestFork ( params . Timestamp ) != forks . Prague {
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "executeStatelessPayloadV4 must only be called for prague payloads" ) )
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID } , engine . UnsupportedFork . With ( errors . New ( "executeStatelessPayloadV4 must only be called for prague payloads" ) )
}
}
return api . executeStatelessPayload ( params , versionedHashes , beaconRoot , opaqueWitness )
return api . executeStatelessPayload ( params , versionedHashes , beaconRoot , requests , opaqueWitness )
}
}
func ( api * ConsensusAPI ) newPayload ( params engine . ExecutableData , versionedHashes [ ] common . Hash , beaconRoot * common . Hash , witness bool ) ( engine . PayloadStatusV1 , error ) {
func ( api * ConsensusAPI ) newPayload ( params engine . ExecutableData , versionedHashes [ ] common . Hash , beaconRoot * common . Hash , requests [ ] [ ] byte , witness bool ) ( engine . PayloadStatusV1 , error ) {
// The locking here is, strictly, not required. Without these locks, this can happen:
// The locking here is, strictly, not required. Without these locks, this can happen:
//
//
// 1. NewPayload( execdata-N ) is invoked from the CL. It goes all the way down to
// 1. NewPayload( execdata-N ) is invoked from the CL. It goes all the way down to
@ -815,7 +815,7 @@ func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashe
defer api . newPayloadLock . Unlock ( )
defer api . newPayloadLock . Unlock ( )
log . Trace ( "Engine API request received" , "method" , "NewPayload" , "number" , params . Number , "hash" , params . BlockHash )
log . Trace ( "Engine API request received" , "method" , "NewPayload" , "number" , params . Number , "hash" , params . BlockHash )
block , err := engine . ExecutableDataToBlock ( params , versionedHashes , beaconRoot )
block , err := engine . ExecutableDataToBlock ( params , versionedHashes , beaconRoot , requests )
if err != nil {
if err != nil {
bgu := "nil"
bgu := "nil"
if params . BlobGasUsed != nil {
if params . BlobGasUsed != nil {
@ -842,8 +842,8 @@ func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashe
"params.ExcessBlobGas" , ebg ,
"params.ExcessBlobGas" , ebg ,
"len(params.Transactions)" , len ( params . Transactions ) ,
"len(params.Transactions)" , len ( params . Transactions ) ,
"len(params.Withdrawals)" , len ( params . Withdrawals ) ,
"len(params.Withdrawals)" , len ( params . Withdrawals ) ,
"len(params.Deposits)" , len ( params . Deposits ) ,
"beaconRoot" , beaconRoot ,
"beaconRoot" , beaconRoot ,
"len(requests)" , len ( requests ) ,
"error" , err )
"error" , err )
return api . invalid ( err , nil ) , nil
return api . invalid ( err , nil ) , nil
}
}
@ -927,10 +927,10 @@ func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashe
return engine . PayloadStatusV1 { Status : engine . VALID , Witness : ow , LatestValidHash : & hash } , nil
return engine . PayloadStatusV1 { Status : engine . VALID , Witness : ow , LatestValidHash : & hash } , nil
}
}
func ( api * ConsensusAPI ) executeStatelessPayload ( params engine . ExecutableData , versionedHashes [ ] common . Hash , beaconRoot * common . Hash , opaqueWitness hexutil . Bytes ) ( engine . StatelessPayloadStatusV1 , error ) {
func ( api * ConsensusAPI ) executeStatelessPayload ( params engine . ExecutableData , versionedHashes [ ] common . Hash , beaconRoot * common . Hash , requests [ ] [ ] byte , opaqueWitness hexutil . Bytes ) ( engine . StatelessPayloadStatusV1 , error ) {
log . Trace ( "Engine API request received" , "method" , "ExecuteStatelessPayload" , "number" , params . Number , "hash" , params . BlockHash )
log . Trace ( "Engine API request received" , "method" , "ExecuteStatelessPayload" , "number" , params . Number , "hash" , params . BlockHash )
block , err := engine . ExecutableDataToBlockNoHash ( params , versionedHashes , beaconRoot )
block , err := engine . ExecutableDataToBlockNoHash ( params , versionedHashes , beaconRoot , requests )
if err != nil {
if err != nil {
bgu := "nil"
bgu := "nil"
if params . BlobGasUsed != nil {
if params . BlobGasUsed != nil {
@ -957,8 +957,8 @@ func (api *ConsensusAPI) executeStatelessPayload(params engine.ExecutableData, v
"params.ExcessBlobGas" , ebg ,
"params.ExcessBlobGas" , ebg ,
"len(params.Transactions)" , len ( params . Transactions ) ,
"len(params.Transactions)" , len ( params . Transactions ) ,
"len(params.Withdrawals)" , len ( params . Withdrawals ) ,
"len(params.Withdrawals)" , len ( params . Withdrawals ) ,
"len(params.Deposits)" , len ( params . Deposits ) ,
"beaconRoot" , beaconRoot ,
"beaconRoot" , beaconRoot ,
"len(requests)" , len ( requests ) ,
"error" , err )
"error" , err )
errorMsg := err . Error ( )
errorMsg := err . Error ( )
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID , ValidationError : & errorMsg } , nil
return engine . StatelessPayloadStatusV1 { Status : engine . INVALID , ValidationError : & errorMsg } , nil
@ -1185,13 +1185,7 @@ func (api *ConsensusAPI) GetPayloadBodiesByHashV1(hashes []common.Hash) []*engin
bodies := make ( [ ] * engine . ExecutionPayloadBody , len ( hashes ) )
bodies := make ( [ ] * engine . ExecutionPayloadBody , len ( hashes ) )
for i , hash := range hashes {
for i , hash := range hashes {
block := api . eth . BlockChain ( ) . GetBlockByHash ( hash )
block := api . eth . BlockChain ( ) . GetBlockByHash ( hash )
body := getBody ( block )
bodies [ i ] = getBody ( block )
if body != nil {
// Nil out the V2 values, clients should know to not request V1 objects
// after Prague.
body . Deposits = nil
}
bodies [ i ] = body
}
}
return bodies
return bodies
}
}
@ -1210,18 +1204,7 @@ func (api *ConsensusAPI) GetPayloadBodiesByHashV2(hashes []common.Hash) []*engin
// GetPayloadBodiesByRangeV1 implements engine_getPayloadBodiesByRangeV1 which allows for retrieval of a range
// GetPayloadBodiesByRangeV1 implements engine_getPayloadBodiesByRangeV1 which allows for retrieval of a range
// of block bodies by the engine api.
// of block bodies by the engine api.
func ( api * ConsensusAPI ) GetPayloadBodiesByRangeV1 ( start , count hexutil . Uint64 ) ( [ ] * engine . ExecutionPayloadBody , error ) {
func ( api * ConsensusAPI ) GetPayloadBodiesByRangeV1 ( start , count hexutil . Uint64 ) ( [ ] * engine . ExecutionPayloadBody , error ) {
bodies , err := api . getBodiesByRange ( start , count )
return api . getBodiesByRange ( start , count )
if err != nil {
return nil , err
}
// Nil out the V2 values, clients should know to not request V1 objects
// after Prague.
for i := range bodies {
if bodies [ i ] != nil {
bodies [ i ] . Deposits = nil
}
}
return bodies , nil
}
}
// GetPayloadBodiesByRangeV2 implements engine_getPayloadBodiesByRangeV1 which allows for retrieval of a range
// GetPayloadBodiesByRangeV2 implements engine_getPayloadBodiesByRangeV1 which allows for retrieval of a range
@ -1256,36 +1239,18 @@ func getBody(block *types.Block) *engine.ExecutionPayloadBody {
return nil
return nil
}
}
var (
var result engine . ExecutionPayloadBody
body = block . Body ( )
txs = make ( [ ] hexutil . Bytes , len ( body . Transactions ) )
withdrawals = body . Withdrawals
depositRequests types . Deposits
)
for j , tx := range body . Transactions {
result . TransactionData = make ( [ ] hexutil . Bytes , len ( block . Transactions ( ) ) )
txs [ j ] , _ = tx . MarshalBinary ( )
for j , tx := range block . Transactions ( ) {
result . TransactionData [ j ] , _ = tx . MarshalBinary ( )
}
}
// Post-shanghai withdrawals MUST be set to empty slice instead of nil
// Post-shanghai withdrawals MUST be set to empty slice instead of nil
if withdrawals == nil && block . Header ( ) . WithdrawalsHash != nil {
result . Withdrawals = block . Withdrawals ( )
withdrawals = make ( [ ] * types . Withdrawal , 0 )
if block . Withdrawals ( ) == nil && block . Header ( ) . WithdrawalsHash != nil {
result . Withdrawals = [ ] * types . Withdrawal { }
}
}
if block . Header ( ) . RequestsHash != nil {
return & result
// TODO: this isn't future proof because we can't determine if a request
// type has activated yet or if there are just no requests of that type from
// only the block.
for _ , req := range block . Requests ( ) {
if d , ok := req . Inner ( ) . ( * types . Deposit ) ; ok {
depositRequests = append ( depositRequests , d )
}
}
}
return & engine . ExecutionPayloadBody {
TransactionData : txs ,
Withdrawals : withdrawals ,
Deposits : depositRequests ,
}
}
}