mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
core/txpool: address comment from bosul
This commit is contained in:
parent
e8015716c5
commit
91a3fee39c
3 changed files with 13 additions and 35 deletions
|
|
@ -94,11 +94,6 @@ const (
|
||||||
// storeVersion is the current slotter layout used for the billy.Database
|
// storeVersion is the current slotter layout used for the billy.Database
|
||||||
// store.
|
// store.
|
||||||
storeVersion = 1
|
storeVersion = 1
|
||||||
|
|
||||||
// conversionTimeWindow defines the period after the Osaka fork during which
|
|
||||||
// the pool will still accept and convert legacy blob transactions. After this
|
|
||||||
// window, all legacy blob transactions will be rejected.
|
|
||||||
conversionTimeWindow = time.Hour * 2
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// blobTxMeta is the minimal subset of types.BlobTx necessary to validate and
|
// blobTxMeta is the minimal subset of types.BlobTx necessary to validate and
|
||||||
|
|
@ -1451,37 +1446,15 @@ func (p *BlobPool) AvailableBlobs(vhashes []common.Hash) int {
|
||||||
return available
|
return available
|
||||||
}
|
}
|
||||||
|
|
||||||
// preCheck performs the static validation upon the provided tx.
|
|
||||||
//
|
|
||||||
// This function is pure static and lock free.
|
|
||||||
func (p *BlobPool) preCheck(tx *types.Transaction) error {
|
|
||||||
var (
|
|
||||||
head = p.head.Load()
|
|
||||||
version = types.BlobSidecarVersion0
|
|
||||||
)
|
|
||||||
if p.chain.Config().IsOsaka(head.Number, head.Time) {
|
|
||||||
version = types.BlobSidecarVersion1
|
|
||||||
}
|
|
||||||
// Validate the transaction statically at first to avoid unnecessary
|
|
||||||
// conversion. This step doesn't require lock protection.
|
|
||||||
if err := p.ValidateTxBasics(tx); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if tx.BlobTxSidecar().Version != version {
|
|
||||||
return fmt.Errorf("sidecar version is not supported, got: %d, want: %d", tx.BlobTxSidecar().Version, version)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add inserts a set of blob transactions into the pool if they pass validation (both
|
// Add inserts a set of blob transactions into the pool if they pass validation (both
|
||||||
// consensus validity and pool restrictions).
|
// consensus validity and pool restrictions).
|
||||||
func (p *BlobPool) Add(txs []*types.Transaction, sync bool) []error {
|
func (p *BlobPool) Add(txs []*types.Transaction, sync bool) []error {
|
||||||
var (
|
var (
|
||||||
errs []error = make([]error, len(txs))
|
errs = make([]error, len(txs))
|
||||||
adds = make([]*types.Transaction, 0, len(txs))
|
adds = make([]*types.Transaction, 0, len(txs))
|
||||||
)
|
)
|
||||||
for i, tx := range txs {
|
for i, tx := range txs {
|
||||||
if errs[i] = p.preCheck(tx); errs[i] != nil {
|
if errs[i] = p.ValidateTxBasics(tx); errs[i] != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if errs[i] = p.add(tx); errs[i] == nil {
|
if errs[i] = p.add(tx); errs[i] == nil {
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,6 @@ type testBlockChain struct {
|
||||||
blockTime *uint64
|
blockTime *uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bc *testBlockChain) setHeadTime(time uint64) {
|
|
||||||
bc.blockTime = &time
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bc *testBlockChain) Config() *params.ChainConfig {
|
func (bc *testBlockChain) Config() *params.ChainConfig {
|
||||||
return bc.config
|
return bc.config
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
|
||||||
return fmt.Errorf("%w: gas %v, minimum needed %v", core.ErrIntrinsicGas, tx.Gas(), intrGas)
|
return fmt.Errorf("%w: gas %v, minimum needed %v", core.ErrIntrinsicGas, tx.Gas(), intrGas)
|
||||||
}
|
}
|
||||||
// Ensure the transaction can cover floor data gas.
|
// Ensure the transaction can cover floor data gas.
|
||||||
if opts.Config.IsPrague(head.Number, head.Time) {
|
if rules.IsPrague {
|
||||||
floorDataGas, err := core.FloorDataGas(tx.Data())
|
floorDataGas, err := core.FloorDataGas(tx.Data())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -160,6 +160,15 @@ func validateBlobTx(tx *types.Transaction, head *types.Header, opts *ValidationO
|
||||||
if sidecar == nil {
|
if sidecar == nil {
|
||||||
return errors.New("missing sidecar in blob transaction")
|
return errors.New("missing sidecar in blob transaction")
|
||||||
}
|
}
|
||||||
|
// Ensure the sidecar is constructed with the correct version, consistent
|
||||||
|
// with the current fork.
|
||||||
|
version := types.BlobSidecarVersion0
|
||||||
|
if opts.Config.IsOsaka(head.Number, head.Time) {
|
||||||
|
version = types.BlobSidecarVersion1
|
||||||
|
}
|
||||||
|
if sidecar.Version != version {
|
||||||
|
return fmt.Errorf("unexpected sidecar version, want: %d, got: %d", version, sidecar.Version)
|
||||||
|
}
|
||||||
// Ensure the blob fee cap satisfies the minimum blob gas price
|
// Ensure the blob fee cap satisfies the minimum blob gas price
|
||||||
if tx.BlobGasFeeCapIntCmp(blobTxMinBlobGasPrice) < 0 {
|
if tx.BlobGasFeeCapIntCmp(blobTxMinBlobGasPrice) < 0 {
|
||||||
return fmt.Errorf("%w: blob fee cap %v, minimum needed %v", ErrTxGasPriceTooLow, tx.BlobGasFeeCap(), blobTxMinBlobGasPrice)
|
return fmt.Errorf("%w: blob fee cap %v, minimum needed %v", ErrTxGasPriceTooLow, tx.BlobGasFeeCap(), blobTxMinBlobGasPrice)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue