Skip to content

Commit 0200238

Browse files
core/txpool/blobpool: adjust slot size for cell proof transactions
1 parent 823030c commit 0200238

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

core/txpool/blobpool/blobpool.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ const (
5454
// tiny overflows causing all txs to move a shelf higher, wasting disk space.
5555
txAvgSize = 4 * 1024
5656

57+
// txBlobOverhead is an approximation of the overhead that an additional blob
58+
// has on transaction size. This is added to the slotter to avoid
59+
// tiny overflows causing all txs to move a shelf higher, wasting disk space.
60+
txBlobOverhead = 2048
61+
5762
// txMaxSize is the maximum size a single transaction can have, outside
5863
// the included blobs. Since blob transactions are pulled instead of pushed,
5964
// and only a small metadata is kept in ram, the rest is on disk, there is

core/txpool/blobpool/slotter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ package blobpool
2727
// of resources, but it makes stress testing with junk transactions simpler.
2828
func newSlotter(maxBlobsPerTransaction int) func() (uint32, bool) {
2929
slotsize := uint32(txAvgSize)
30-
slotsize -= uint32(blobSize) // underflows, it's ok, will overflow back in the first return
30+
slotsize -= uint32(blobSize) + txBlobOverhead // underflows, it's ok, will overflow back in the first return
3131

3232
return func() (size uint32, done bool) {
33-
slotsize += blobSize
33+
slotsize += blobSize + txBlobOverhead
3434
finished := slotsize > uint32(maxBlobsPerTransaction)*blobSize+txMaxSize
3535

3636
return slotsize, finished

core/txpool/blobpool/slotter_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ func TestNewSlotter(t *testing.T) {
3333
}
3434
// Compare the database shelves to the expected ones
3535
want := []uint32{
36-
0*blobSize + txAvgSize, // 0 blob + some expected tx infos
37-
1*blobSize + txAvgSize, // 1 blob + some expected tx infos
38-
2*blobSize + txAvgSize, // 2 blob + some expected tx infos (could be fewer blobs and more tx data)
39-
3*blobSize + txAvgSize, // 3 blob + some expected tx infos (could be fewer blobs and more tx data)
40-
4*blobSize + txAvgSize, // 4 blob + some expected tx infos (could be fewer blobs and more tx data)
41-
5*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
42-
6*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
43-
7*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
44-
8*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
45-
9*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
46-
10*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
47-
11*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
48-
12*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
49-
13*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
50-
14*blobSize + txAvgSize, // 1-6 blobs + unexpectedly large tx infos >= 4 blobs + max tx metadata size
36+
0*blobSize + 0*txBlobOverhead + txAvgSize, // 0 blob + some expected tx infos
37+
1*blobSize + 1*txBlobOverhead + txAvgSize, // 1 blob + some expected tx infos
38+
2*blobSize + 2*txBlobOverhead + txAvgSize, // 2 blob + some expected tx infos (could be fewer blobs and more tx data)
39+
3*blobSize + 3*txBlobOverhead + txAvgSize, // 3 blob + some expected tx infos (could be fewer blobs and more tx data)
40+
4*blobSize + 4*txBlobOverhead + txAvgSize, // 4 blob + some expected tx infos (could be fewer blobs and more tx data)
41+
5*blobSize + 5*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
42+
6*blobSize + 6*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
43+
7*blobSize + 7*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
44+
8*blobSize + 8*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
45+
9*blobSize + 9*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
46+
10*blobSize + 10*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
47+
11*blobSize + 11*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
48+
12*blobSize + 12*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
49+
13*blobSize + 13*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos < 4 blobs + max tx metadata size
50+
14*blobSize + 14*txBlobOverhead + txAvgSize, // 1-6 blobs + unexpectedly large tx infos >= 4 blobs + max tx metadata size
5151
}
5252
if len(shelves) != len(want) {
5353
t.Errorf("shelves count mismatch: have %d, want %d", len(shelves), len(want))

0 commit comments

Comments
 (0)