Skip to content

Commit 91a3fee

Browse files
committed
core/txpool: address comment from bosul
1 parent e801571 commit 91a3fee

File tree

3 files changed

+13
-35
lines changed

3 files changed

+13
-35
lines changed

core/txpool/blobpool/blobpool.go

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ const (
9494
// storeVersion is the current slotter layout used for the billy.Database
9595
// store.
9696
storeVersion = 1
97-
98-
// conversionTimeWindow defines the period after the Osaka fork during which
99-
// the pool will still accept and convert legacy blob transactions. After this
100-
// window, all legacy blob transactions will be rejected.
101-
conversionTimeWindow = time.Hour * 2
10297
)
10398

10499
// blobTxMeta is the minimal subset of types.BlobTx necessary to validate and
@@ -1451,37 +1446,15 @@ func (p *BlobPool) AvailableBlobs(vhashes []common.Hash) int {
14511446
return available
14521447
}
14531448

1454-
// preCheck performs the static validation upon the provided tx.
1455-
//
1456-
// This function is pure static and lock free.
1457-
func (p *BlobPool) preCheck(tx *types.Transaction) error {
1458-
var (
1459-
head = p.head.Load()
1460-
version = types.BlobSidecarVersion0
1461-
)
1462-
if p.chain.Config().IsOsaka(head.Number, head.Time) {
1463-
version = types.BlobSidecarVersion1
1464-
}
1465-
// Validate the transaction statically at first to avoid unnecessary
1466-
// conversion. This step doesn't require lock protection.
1467-
if err := p.ValidateTxBasics(tx); err != nil {
1468-
return err
1469-
}
1470-
if tx.BlobTxSidecar().Version != version {
1471-
return fmt.Errorf("sidecar version is not supported, got: %d, want: %d", tx.BlobTxSidecar().Version, version)
1472-
}
1473-
return nil
1474-
}
1475-
14761449
// Add inserts a set of blob transactions into the pool if they pass validation (both
14771450
// consensus validity and pool restrictions).
14781451
func (p *BlobPool) Add(txs []*types.Transaction, sync bool) []error {
14791452
var (
1480-
errs []error = make([]error, len(txs))
1481-
adds = make([]*types.Transaction, 0, len(txs))
1453+
errs = make([]error, len(txs))
1454+
adds = make([]*types.Transaction, 0, len(txs))
14821455
)
14831456
for i, tx := range txs {
1484-
if errs[i] = p.preCheck(tx); errs[i] != nil {
1457+
if errs[i] = p.ValidateTxBasics(tx); errs[i] != nil {
14851458
continue
14861459
}
14871460
if errs[i] = p.add(tx); errs[i] == nil {

core/txpool/blobpool/blobpool_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ type testBlockChain struct {
9292
blockTime *uint64
9393
}
9494

95-
func (bc *testBlockChain) setHeadTime(time uint64) {
96-
bc.blockTime = &time
97-
}
98-
9995
func (bc *testBlockChain) Config() *params.ChainConfig {
10096
return bc.config
10197
}

core/txpool/validation.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
130130
return fmt.Errorf("%w: gas %v, minimum needed %v", core.ErrIntrinsicGas, tx.Gas(), intrGas)
131131
}
132132
// Ensure the transaction can cover floor data gas.
133-
if opts.Config.IsPrague(head.Number, head.Time) {
133+
if rules.IsPrague {
134134
floorDataGas, err := core.FloorDataGas(tx.Data())
135135
if err != nil {
136136
return err
@@ -160,6 +160,15 @@ func validateBlobTx(tx *types.Transaction, head *types.Header, opts *ValidationO
160160
if sidecar == nil {
161161
return errors.New("missing sidecar in blob transaction")
162162
}
163+
// Ensure the sidecar is constructed with the correct version, consistent
164+
// with the current fork.
165+
version := types.BlobSidecarVersion0
166+
if opts.Config.IsOsaka(head.Number, head.Time) {
167+
version = types.BlobSidecarVersion1
168+
}
169+
if sidecar.Version != version {
170+
return fmt.Errorf("unexpected sidecar version, want: %d, got: %d", version, sidecar.Version)
171+
}
163172
// Ensure the blob fee cap satisfies the minimum blob gas price
164173
if tx.BlobGasFeeCapIntCmp(blobTxMinBlobGasPrice) < 0 {
165174
return fmt.Errorf("%w: blob fee cap %v, minimum needed %v", ErrTxGasPriceTooLow, tx.BlobGasFeeCap(), blobTxMinBlobGasPrice)

0 commit comments

Comments
 (0)