Skip to content

Commit ebe31df

Browse files
authored
eth/downloader, core/types: take withdrawals-size into account in downloader queue (#30276)
Fixes a slight miscalculation in the downloader queue, which was not accurately taking block withdrawals into account when calculating the size of the items in the queue
1 parent d3dae66 commit ebe31df

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

core/types/withdrawal.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package types
1818

1919
import (
2020
"bytes"
21+
"reflect"
2122

2223
"github.com/ethereum/go-ethereum/common"
2324
"github.com/ethereum/go-ethereum/common/hexutil"
@@ -48,6 +49,12 @@ type Withdrawals []*Withdrawal
4849
// Len returns the length of s.
4950
func (s Withdrawals) Len() int { return len(s) }
5051

52+
var withdrawalSize = int(reflect.TypeOf(Withdrawal{}).Size())
53+
54+
func (s Withdrawals) Size() int {
55+
return withdrawalSize * len(s)
56+
}
57+
5158
// EncodeIndex encodes the i'th withdrawal to w. Note that this does not check for errors
5259
// because we assume that *Withdrawal will only ever contain valid withdrawals that were either
5360
// constructed by decoding or via public API in this package.

eth/downloader/queue.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ func (q *queue) Results(block bool) []*fetchResult {
385385
for _, tx := range result.Transactions {
386386
size += common.StorageSize(tx.Size())
387387
}
388+
size += common.StorageSize(result.Withdrawals.Size())
388389
q.resultSize = common.StorageSize(blockCacheSizeWeight)*size +
389390
(1-common.StorageSize(blockCacheSizeWeight))*q.resultSize
390391
}

0 commit comments

Comments
 (0)