Allow NewPayloadV2 for pre-Shanghai blocks (#6604)

This is a fix for
[withdrawal-devnet-3](https://forkmon.withdrawal-devnet-3.ethpandaops.io/).
The problem was that CL calls `NewPayloadV2` for pre-Shanghai blocks
with `nil` withdrawals, which is OK, but that `nil` was erroneously
converted into an empty array, causing block hash mismatch.
This commit is contained in:
Andrew Ashikhmin 2023-01-17 17:26:44 +01:00 committed by GitHub
parent a6f75bddf1
commit 7fb5cecce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -663,17 +663,12 @@ func (s *EthBackendServer) engineForkChoiceUpdated(ctx context.Context, reqForkc
// payload IDs start from 1 (0 signifies null)
s.payloadId++
var withdrawals []*types.Withdrawal
if reqWithdrawals != nil {
withdrawals = ConvertWithdrawalsFromRpc(reqWithdrawals)
}
param := core.BlockBuilderParameters{
ParentHash: forkChoice.HeadBlockHash,
Timestamp: payloadAttributes.Timestamp,
PrevRandao: gointerfaces.ConvertH256ToHash(payloadAttributes.PrevRandao),
SuggestedFeeRecipient: gointerfaces.ConvertH160toAddress(payloadAttributes.SuggestedFeeRecipient),
Withdrawals: withdrawals,
Withdrawals: ConvertWithdrawalsFromRpc(reqWithdrawals),
PayloadId: s.payloadId,
}
@ -718,6 +713,9 @@ func (s *EthBackendServer) SubscribeLogs(server remote.ETHBACKEND_SubscribeLogsS
}
func ConvertWithdrawalsFromRpc(in []*types2.Withdrawal) []*types.Withdrawal {
if in == nil {
return nil
}
out := make([]*types.Withdrawal, 0, len(in))
for _, w := range in {
out = append(out, &types.Withdrawal{
@ -731,6 +729,9 @@ func ConvertWithdrawalsFromRpc(in []*types2.Withdrawal) []*types.Withdrawal {
}
func ConvertWithdrawalsToRpc(in []*types.Withdrawal) []*types2.Withdrawal {
if in == nil {
return nil
}
out := make([]*types2.Withdrawal, 0, len(in))
for _, w := range in {
out = append(out, &types2.Withdrawal{