mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
core/txpool/blobpool: adjust slot size for cell proof transactions
This commit is contained in:
parent
8deb682a35
commit
f246a99698
3 changed files with 22 additions and 17 deletions
|
|
@ -55,6 +55,11 @@ const (
|
||||||
// tiny overflows causing all txs to move a shelf higher, wasting disk space.
|
// tiny overflows causing all txs to move a shelf higher, wasting disk space.
|
||||||
txAvgSize = 4 * 1024
|
txAvgSize = 4 * 1024
|
||||||
|
|
||||||
|
// txBlobOverhead is an approximation of the overhead that an additional blob
|
||||||
|
// has on transaction size. This is added to the slotter to avoid
|
||||||
|
// tiny overflows causing all txs to move a shelf higher, wasting disk space.
|
||||||
|
txBlobOverhead = 2048
|
||||||
|
|
||||||
// txMaxSize is the maximum size a single transaction can have, outside
|
// txMaxSize is the maximum size a single transaction can have, outside
|
||||||
// the included blobs. Since blob transactions are pulled instead of pushed,
|
// the included blobs. Since blob transactions are pulled instead of pushed,
|
||||||
// and only a small metadata is kept in ram, the rest is on disk, there is
|
// and only a small metadata is kept in ram, the rest is on disk, there is
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@ package blobpool
|
||||||
// of resources, but it makes stress testing with junk transactions simpler.
|
// of resources, but it makes stress testing with junk transactions simpler.
|
||||||
func newSlotter(maxBlobsPerTransaction int) func() (uint32, bool) {
|
func newSlotter(maxBlobsPerTransaction int) func() (uint32, bool) {
|
||||||
slotsize := uint32(txAvgSize)
|
slotsize := uint32(txAvgSize)
|
||||||
slotsize -= uint32(blobSize) // underflows, it's ok, will overflow back in the first return
|
slotsize -= uint32(blobSize) + txBlobOverhead // underflows, it's ok, will overflow back in the first return
|
||||||
|
|
||||||
return func() (size uint32, done bool) {
|
return func() (size uint32, done bool) {
|
||||||
slotsize += blobSize
|
slotsize += blobSize + txBlobOverhead
|
||||||
finished := slotsize > uint32(maxBlobsPerTransaction)*blobSize+txMaxSize
|
finished := slotsize > uint32(maxBlobsPerTransaction)*blobSize+txMaxSize
|
||||||
|
|
||||||
return slotsize, finished
|
return slotsize, finished
|
||||||
|
|
|
||||||
|
|
@ -33,21 +33,21 @@ func TestNewSlotter(t *testing.T) {
|
||||||
}
|
}
|
||||||
// Compare the database shelves to the expected ones
|
// Compare the database shelves to the expected ones
|
||||||
want := []uint32{
|
want := []uint32{
|
||||||
0*blobSize + txAvgSize, // 0 blob + some expected tx infos
|
0*blobSize + 0*txBlobOverhead + txAvgSize, // 0 blob + some expected tx infos
|
||||||
1*blobSize + txAvgSize, // 1 blob + some expected tx infos
|
1*blobSize + 1*txBlobOverhead + txAvgSize, // 1 blob + some expected tx infos
|
||||||
2*blobSize + txAvgSize, // 2 blob + some expected tx infos (could be fewer blobs and more tx data)
|
2*blobSize + 2*txBlobOverhead + txAvgSize, // 2 blob + some expected tx infos (could be fewer blobs and more tx data)
|
||||||
3*blobSize + txAvgSize, // 3 blob + some expected tx infos (could be fewer blobs and more tx data)
|
3*blobSize + 3*txBlobOverhead + txAvgSize, // 3 blob + some expected tx infos (could be fewer blobs and more tx data)
|
||||||
4*blobSize + txAvgSize, // 4 blob + some expected tx infos (could be fewer blobs and more tx data)
|
4*blobSize + 4*txBlobOverhead + txAvgSize, // 4 blob + some expected tx infos (could be fewer blobs and more tx data)
|
||||||
5*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
5*blobSize + 5*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
||||||
6*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
6*blobSize + 6*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
||||||
7*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
7*blobSize + 7*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
||||||
8*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
8*blobSize + 8*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
||||||
9*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
9*blobSize + 9*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
||||||
10*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
10*blobSize + 10*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
||||||
11*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
11*blobSize + 11*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
||||||
12*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
12*blobSize + 12*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
||||||
13*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
13*blobSize + 13*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
|
||||||
14*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos >= 4 blobs + max tx metadata size
|
14*blobSize + 14*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos >= 4 blobs + max tx metadata size
|
||||||
}
|
}
|
||||||
if len(shelves) != len(want) {
|
if len(shelves) != len(want) {
|
||||||
t.Errorf("shelves count mismatch: have %d, want %d", len(shelves), len(want))
|
t.Errorf("shelves count mismatch: have %d, want %d", len(shelves), len(want))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue