@@ -87,8 +87,9 @@ type blobTxMeta struct {
87
87
hash common.Hash // Transaction hash to maintain the lookup table
88
88
vhashes []common.Hash // Blob versioned hashes to maintain the lookup table
89
89
90
- id uint64 // Storage ID in the pool's persistent store
91
- size uint32 // Byte size in the pool's persistent store
90
+ id uint64 // Storage ID in the pool's persistent store
91
+ storageSize uint32 // Byte size in the pool's persistent store
92
+ size uint64 // RLP-encoded size of transaction including the attached blob
92
93
93
94
nonce uint64 // Needed to prioritize inclusion order within an account
94
95
costCap * uint256.Int // Needed to validate cumulative balance sufficiency
@@ -108,19 +109,20 @@ type blobTxMeta struct {
108
109
109
110
// newBlobTxMeta retrieves the indexed metadata fields from a blob transaction
110
111
// and assembles a helper struct to track in memory.
111
- func newBlobTxMeta (id uint64 , size uint32 , tx * types.Transaction ) * blobTxMeta {
112
+ func newBlobTxMeta (id uint64 , size uint64 , storageSize uint32 , tx * types.Transaction ) * blobTxMeta {
112
113
meta := & blobTxMeta {
113
- hash : tx .Hash (),
114
- vhashes : tx .BlobHashes (),
115
- id : id ,
116
- size : size ,
117
- nonce : tx .Nonce (),
118
- costCap : uint256 .MustFromBig (tx .Cost ()),
119
- execTipCap : uint256 .MustFromBig (tx .GasTipCap ()),
120
- execFeeCap : uint256 .MustFromBig (tx .GasFeeCap ()),
121
- blobFeeCap : uint256 .MustFromBig (tx .BlobGasFeeCap ()),
122
- execGas : tx .Gas (),
123
- blobGas : tx .BlobGas (),
114
+ hash : tx .Hash (),
115
+ vhashes : tx .BlobHashes (),
116
+ id : id ,
117
+ storageSize : storageSize ,
118
+ size : size ,
119
+ nonce : tx .Nonce (),
120
+ costCap : uint256 .MustFromBig (tx .Cost ()),
121
+ execTipCap : uint256 .MustFromBig (tx .GasTipCap ()),
122
+ execFeeCap : uint256 .MustFromBig (tx .GasFeeCap ()),
123
+ blobFeeCap : uint256 .MustFromBig (tx .BlobGasFeeCap ()),
124
+ execGas : tx .Gas (),
125
+ blobGas : tx .BlobGas (),
124
126
}
125
127
meta .basefeeJumps = dynamicFeeJumps (meta .execFeeCap )
126
128
meta .blobfeeJumps = dynamicFeeJumps (meta .blobFeeCap )
@@ -480,7 +482,7 @@ func (p *BlobPool) parseTransaction(id uint64, size uint32, blob []byte) error {
480
482
return errors .New ("missing blob sidecar" )
481
483
}
482
484
483
- meta := newBlobTxMeta (id , size , tx )
485
+ meta := newBlobTxMeta (id , tx . Size (), size , tx )
484
486
if p .lookup .exists (meta .hash ) {
485
487
// This path is only possible after a crash, where deleted items are not
486
488
// removed via the normal shutdown-startup procedure and thus may get
@@ -507,7 +509,7 @@ func (p *BlobPool) parseTransaction(id uint64, size uint32, blob []byte) error {
507
509
p .spent [sender ] = new (uint256.Int ).Add (p .spent [sender ], meta .costCap )
508
510
509
511
p .lookup .track (meta )
510
- p .stored += uint64 (meta .size )
512
+ p .stored += uint64 (meta .storageSize )
511
513
return nil
512
514
}
513
515
@@ -539,7 +541,7 @@ func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint6
539
541
ids = append (ids , txs [i ].id )
540
542
nonces = append (nonces , txs [i ].nonce )
541
543
542
- p .stored -= uint64 (txs [i ].size )
544
+ p .stored -= uint64 (txs [i ].storageSize )
543
545
p .lookup .untrack (txs [i ])
544
546
545
547
// Included transactions blobs need to be moved to the limbo
@@ -580,7 +582,7 @@ func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint6
580
582
nonces = append (nonces , txs [0 ].nonce )
581
583
582
584
p .spent [addr ] = new (uint256.Int ).Sub (p .spent [addr ], txs [0 ].costCap )
583
- p .stored -= uint64 (txs [0 ].size )
585
+ p .stored -= uint64 (txs [0 ].storageSize )
584
586
p .lookup .untrack (txs [0 ])
585
587
586
588
// Included transactions blobs need to be moved to the limbo
@@ -636,7 +638,7 @@ func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint6
636
638
dropRepeatedMeter .Mark (1 )
637
639
638
640
p .spent [addr ] = new (uint256.Int ).Sub (p .spent [addr ], txs [i ].costCap )
639
- p .stored -= uint64 (txs [i ].size )
641
+ p .stored -= uint64 (txs [i ].storageSize )
640
642
p .lookup .untrack (txs [i ])
641
643
642
644
if err := p .store .Delete (id ); err != nil {
@@ -658,7 +660,7 @@ func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint6
658
660
nonces = append (nonces , txs [j ].nonce )
659
661
660
662
p .spent [addr ] = new (uint256.Int ).Sub (p .spent [addr ], txs [j ].costCap )
661
- p .stored -= uint64 (txs [j ].size )
663
+ p .stored -= uint64 (txs [j ].storageSize )
662
664
p .lookup .untrack (txs [j ])
663
665
}
664
666
txs = txs [:i ]
@@ -696,7 +698,7 @@ func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint6
696
698
nonces = append (nonces , last .nonce )
697
699
698
700
p .spent [addr ] = new (uint256.Int ).Sub (p .spent [addr ], last .costCap )
699
- p .stored -= uint64 (last .size )
701
+ p .stored -= uint64 (last .storageSize )
700
702
p .lookup .untrack (last )
701
703
}
702
704
if len (txs ) == 0 {
@@ -736,7 +738,7 @@ func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint6
736
738
nonces = append (nonces , last .nonce )
737
739
738
740
p .spent [addr ] = new (uint256.Int ).Sub (p .spent [addr ], last .costCap )
739
- p .stored -= uint64 (last .size )
741
+ p .stored -= uint64 (last .storageSize )
740
742
p .lookup .untrack (last )
741
743
}
742
744
p .index [addr ] = txs
@@ -1002,7 +1004,7 @@ func (p *BlobPool) reinject(addr common.Address, txhash common.Hash) error {
1002
1004
}
1003
1005
1004
1006
// Update the indices and metrics
1005
- meta := newBlobTxMeta (id , p .store .Size (id ), tx )
1007
+ meta := newBlobTxMeta (id , tx . Size (), p .store .Size (id ), tx )
1006
1008
if _ , ok := p .index [addr ]; ! ok {
1007
1009
if err := p .reserve (addr , true ); err != nil {
1008
1010
log .Warn ("Failed to reserve account for blob pool" , "tx" , tx .Hash (), "from" , addr , "err" , err )
@@ -1016,7 +1018,7 @@ func (p *BlobPool) reinject(addr common.Address, txhash common.Hash) error {
1016
1018
p .spent [addr ] = new (uint256.Int ).Add (p .spent [addr ], meta .costCap )
1017
1019
}
1018
1020
p .lookup .track (meta )
1019
- p .stored += uint64 (meta .size )
1021
+ p .stored += uint64 (meta .storageSize )
1020
1022
return nil
1021
1023
}
1022
1024
@@ -1041,7 +1043,7 @@ func (p *BlobPool) SetGasTip(tip *big.Int) {
1041
1043
nonces = []uint64 {tx .nonce }
1042
1044
)
1043
1045
p .spent [addr ] = new (uint256.Int ).Sub (p .spent [addr ], txs [i ].costCap )
1044
- p .stored -= uint64 (tx .size )
1046
+ p .stored -= uint64 (tx .storageSize )
1045
1047
p .lookup .untrack (tx )
1046
1048
txs [i ] = nil
1047
1049
@@ -1051,7 +1053,7 @@ func (p *BlobPool) SetGasTip(tip *big.Int) {
1051
1053
nonces = append (nonces , tx .nonce )
1052
1054
1053
1055
p .spent [addr ] = new (uint256.Int ).Sub (p .spent [addr ], tx .costCap )
1054
- p .stored -= uint64 (tx .size )
1056
+ p .stored -= uint64 (tx .storageSize )
1055
1057
p .lookup .untrack (tx )
1056
1058
txs [i + 1 + j ] = nil
1057
1059
}
@@ -1236,6 +1238,25 @@ func (p *BlobPool) GetRLP(hash common.Hash) []byte {
1236
1238
return p .getRLP (hash )
1237
1239
}
1238
1240
1241
+ // GetMetadata returns the transaction type and transaction size with the
1242
+ // given transaction hash.
1243
+ //
1244
+ // The size refers the length of the 'rlp encoding' of a blob transaction
1245
+ // including the attached blobs.
1246
+ func (p * BlobPool ) GetMetadata (hash common.Hash ) * txpool.TxMetadata {
1247
+ p .lock .RLock ()
1248
+ defer p .lock .RUnlock ()
1249
+
1250
+ size , ok := p .lookup .sizeOfTx (hash )
1251
+ if ! ok {
1252
+ return nil
1253
+ }
1254
+ return & txpool.TxMetadata {
1255
+ Type : types .BlobTxType ,
1256
+ Size : size ,
1257
+ }
1258
+ }
1259
+
1239
1260
// GetBlobs returns a number of blobs are proofs for the given versioned hashes.
1240
1261
// This is a utility method for the engine API, enabling consensus clients to
1241
1262
// retrieve blobs from the pools directly instead of the network.
@@ -1375,7 +1396,7 @@ func (p *BlobPool) add(tx *types.Transaction) (err error) {
1375
1396
if err != nil {
1376
1397
return err
1377
1398
}
1378
- meta := newBlobTxMeta (id , p .store .Size (id ), tx )
1399
+ meta := newBlobTxMeta (id , tx . Size (), p .store .Size (id ), tx )
1379
1400
1380
1401
var (
1381
1402
next = p .state .GetNonce (from )
@@ -1403,7 +1424,7 @@ func (p *BlobPool) add(tx *types.Transaction) (err error) {
1403
1424
1404
1425
p .lookup .untrack (prev )
1405
1426
p .lookup .track (meta )
1406
- p .stored += uint64 (meta .size ) - uint64 (prev .size )
1427
+ p .stored += uint64 (meta .storageSize ) - uint64 (prev .storageSize )
1407
1428
} else {
1408
1429
// Transaction extends previously scheduled ones
1409
1430
p .index [from ] = append (p .index [from ], meta )
@@ -1413,7 +1434,7 @@ func (p *BlobPool) add(tx *types.Transaction) (err error) {
1413
1434
}
1414
1435
p .spent [from ] = new (uint256.Int ).Add (p .spent [from ], meta .costCap )
1415
1436
p .lookup .track (meta )
1416
- p .stored += uint64 (meta .size )
1437
+ p .stored += uint64 (meta .storageSize )
1417
1438
}
1418
1439
// Recompute the rolling eviction fields. In case of a replacement, this will
1419
1440
// recompute all subsequent fields. In case of an append, this will only do
@@ -1500,7 +1521,7 @@ func (p *BlobPool) drop() {
1500
1521
p .index [from ] = txs
1501
1522
p .spent [from ] = new (uint256.Int ).Sub (p .spent [from ], drop .costCap )
1502
1523
}
1503
- p .stored -= uint64 (drop .size )
1524
+ p .stored -= uint64 (drop .storageSize )
1504
1525
p .lookup .untrack (drop )
1505
1526
1506
1527
// Remove the transaction from the pool's eviction heap:
0 commit comments