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
pull/30284/head
psogv0308 4 months ago committed by GitHub
parent d3dae66e59
commit ebe31dfd5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      core/types/withdrawal.go
  2. 1
      eth/downloader/queue.go

@ -18,6 +18,7 @@ package types
import (
"bytes"
"reflect"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
@ -48,6 +49,12 @@ type Withdrawals []*Withdrawal
// Len returns the length of s.
func (s Withdrawals) Len() int { return len(s) }
var withdrawalSize = int(reflect.TypeOf(Withdrawal{}).Size())
func (s Withdrawals) Size() int {
return withdrawalSize * len(s)
}
// EncodeIndex encodes the i'th withdrawal to w. Note that this does not check for errors
// because we assume that *Withdrawal will only ever contain valid withdrawals that were either
// constructed by decoding or via public API in this package.

@ -385,6 +385,7 @@ func (q *queue) Results(block bool) []*fetchResult {
for _, tx := range result.Transactions {
size += common.StorageSize(tx.Size())
}
size += common.StorageSize(result.Withdrawals.Size())
q.resultSize = common.StorageSize(blockCacheSizeWeight)*size +
(1-common.StorageSize(blockCacheSizeWeight))*q.resultSize
}

Loading…
Cancel
Save