Skip to content

Commit

Permalink
rename from invalid to excludedFromBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
bharath-123 committed May 10, 2024
1 parent 5dd4e44 commit d2fc307
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
10 changes: 5 additions & 5 deletions core/txpool/blobpool/blobpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,11 @@ func New(config Config, chain BlockChain) *BlobPool {
}
}

func (p *BlobPool) SetAstriaOrdered(types.Transactions) {}
func (p *BlobPool) ClearAstriaOrdered() {}
func (p *BlobPool) UpdateAstriaInvalid(*types.Transaction) {}
func (p *BlobPool) AstriaInvalid() *types.Transactions { return &types.Transactions{} }
func (p *BlobPool) AstriaOrdered() *types.Transactions { return &types.Transactions{} }
func (p *BlobPool) SetAstriaOrdered(types.Transactions) {}
func (p *BlobPool) ClearAstriaOrdered() {}
func (p *BlobPool) UpdateAstriaExcludedFromBlock(*types.Transaction) {}
func (p *BlobPool) AstriaExcludedFromBlock() *types.Transactions { return &types.Transactions{} }
func (p *BlobPool) AstriaOrdered() *types.Transactions { return &types.Transactions{} }

// Filter returns whether the given transaction can be consumed by the blob pool.
func (p *BlobPool) Filter(tx *types.Transaction) bool {
Expand Down
36 changes: 18 additions & 18 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ var (
reheapTimer = metrics.NewRegisteredTimer("txpool/reheap", nil)

// Metrics related to the astria ordered txs
astriaValidMeter = metrics.GetOrRegisterMeter("astria/txpool/valid", nil)
astriaInvalidMeter = metrics.GetOrRegisterMeter("astria/txpool/invalid", nil)
astriaRequestedMeter = metrics.GetOrRegisterMeter("astria/txpool/requested", nil)
astriaValidMeter = metrics.GetOrRegisterMeter("astria/txpool/valid", nil)
astriaExcludedFromBlockMeter = metrics.GetOrRegisterMeter("astria/txpool/excludedFromBlock", nil)
astriaRequestedMeter = metrics.GetOrRegisterMeter("astria/txpool/requested", nil)
)

// BlockChain defines the minimal set of methods needed to back a tx pool with
Expand Down Expand Up @@ -280,24 +280,24 @@ func New(config Config, chain BlockChain) *LegacyPool {
}

type astriaOrdered struct {
valid types.Transactions
invalid types.Transactions
pool *LegacyPool
valid types.Transactions
excludedFromBlock types.Transactions
pool *LegacyPool
}

func newAstriaOrdered(valid types.Transactions, pool *LegacyPool) *astriaOrdered {
astriaValidMeter.Mark(int64(len(valid)))

return &astriaOrdered{
valid: valid,
invalid: types.Transactions{},
pool: pool,
valid: valid,
excludedFromBlock: types.Transactions{},
pool: pool,
}
}

func (ao *astriaOrdered) clear() {
ao.valid = types.Transactions{}
ao.invalid = types.Transactions{}
ao.excludedFromBlock = types.Transactions{}
}

func (pool *LegacyPool) SetAstriaOrdered(txs types.Transactions) {
Expand All @@ -317,29 +317,29 @@ func (pool *LegacyPool) SetAstriaOrdered(txs types.Transactions) {
pool.astria = newAstriaOrdered(valid, pool)
}

func (pool *LegacyPool) UpdateAstriaInvalid(tx *types.Transaction) {
if pool.astria.invalid == nil {
pool.astria.invalid = types.Transactions{tx}
func (pool *LegacyPool) UpdateAstriaExcludedFromBlock(tx *types.Transaction) {
if pool.astria.excludedFromBlock == nil {
pool.astria.excludedFromBlock = types.Transactions{tx}
return
}

pool.astria.invalid = append(pool.astria.invalid, tx)
pool.astria.excludedFromBlock = append(pool.astria.excludedFromBlock, tx)
}

func (pool *LegacyPool) AstriaInvalid() *types.Transactions {
func (pool *LegacyPool) AstriaExcludedFromBlock() *types.Transactions {
if pool.astria == nil {
return &types.Transactions{}
}
return &pool.astria.invalid
return &pool.astria.excludedFromBlock
}

func (pool *LegacyPool) ClearAstriaOrdered() {
if pool.astria == nil {
return
}

astriaInvalidMeter.Mark(int64(len(pool.astria.invalid)))
for _, tx := range pool.astria.invalid {
astriaExcludedFromBlockMeter.Mark(int64(len(pool.astria.excludedFromBlock)))
for _, tx := range pool.astria.excludedFromBlock {
pool.removeTx(tx.Hash(), false, true)
}

Expand Down
4 changes: 2 additions & 2 deletions core/txpool/subpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ type SubPool interface {

SetAstriaOrdered(types.Transactions)
ClearAstriaOrdered()
UpdateAstriaInvalid(tx *types.Transaction)
AstriaInvalid() *types.Transactions
UpdateAstriaExcludedFromBlock(tx *types.Transaction)
AstriaExcludedFromBlock() *types.Transactions
AstriaOrdered() *types.Transactions
}
8 changes: 4 additions & 4 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,17 @@ func (p *TxPool) ClearAstriaOrdered() {
}
}

func (p *TxPool) UpdateAstriaInvalid(tx *types.Transaction) {
func (p *TxPool) UpdateAstriaExcludedFromBlock(tx *types.Transaction) {
for _, subpool := range p.subpools {
subpool.UpdateAstriaInvalid(tx)
subpool.UpdateAstriaExcludedFromBlock(tx)
}
}

func (p *TxPool) AstriaInvalid() *types.Transactions {
func (p *TxPool) AstriaExcludedFromBlock() *types.Transactions {
txs := types.Transactions{}

for _, subpool := range p.subpools {
subpoolTxs := subpool.AstriaInvalid()
subpoolTxs := subpool.AstriaExcludedFromBlock()
txs = append(txs, *subpoolTxs...)
}

Expand Down
2 changes: 1 addition & 1 deletion miner/payload_building_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestBuildPayload(t *testing.T) {

// Ensure invalid transactions are stored
if len(tt.invalidTxs) > 0 {
invalidTxs := b.TxPool().AstriaInvalid()
invalidTxs := b.TxPool().AstriaExcludedFromBlock()
txDifference := types.TxDifference(*invalidTxs, signedInvalidTxs)
if txDifference.Len() != 0 {
t.Fatalf("Unexpected invalid transactions in astria invalid transactions: %v", txDifference)
Expand Down
6 changes: 3 additions & 3 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ func (w *worker) commitAstriaTransactions(env *environment, txs *types.Transacti
if env.gasPool.Gas() < params.TxGas {
log.Trace("Not enough gas for further transactions", "have", env.gasPool, "want", params.TxGas)
// remove txs from the mempool if they are too big for this block
w.eth.TxPool().UpdateAstriaInvalid(tx)
w.eth.TxPool().UpdateAstriaExcludedFromBlock(tx)
break
}

Expand All @@ -823,7 +823,7 @@ func (w *worker) commitAstriaTransactions(env *environment, txs *types.Transacti
// phase, start ignoring the sender until we do.
if tx.Protected() && !w.chainConfig.IsEIP155(env.header.Number) {
log.Trace("Ignoring reply protected transaction", "hash", tx.Hash(), "eip155", w.chainConfig.EIP155Block)
w.eth.TxPool().UpdateAstriaInvalid(tx)
w.eth.TxPool().UpdateAstriaExcludedFromBlock(tx)
continue
}
// Start executing the transaction
Expand Down Expand Up @@ -859,7 +859,7 @@ func (w *worker) commitAstriaTransactions(env *environment, txs *types.Transacti
}
if err != nil {
log.Trace("Marking transaction as invalid", "hash", tx.Hash(), "err", err)
w.eth.TxPool().UpdateAstriaInvalid(tx)
w.eth.TxPool().UpdateAstriaExcludedFromBlock(tx)
}
}
if !w.isRunning() && len(coalescedLogs) > 0 {
Expand Down

0 comments on commit d2fc307

Please sign in to comment.