Skip to content

Commit 9cffd0f

Browse files
committed
fix: Address merge issues and add missing tracer methods.
1 parent 2de360e commit 9cffd0f

5 files changed

Lines changed: 9 additions & 146 deletions

File tree

core/txpool/txpool.go

Lines changed: 2 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,7 @@ type TxPool struct {
274274
signer types.Signer
275275
mu sync.RWMutex
276276

277-
txFeed event.Feed
278277
dropTxFeed event.Feed
279-
scope event.SubscriptionScope
280-
signer types.Signer
281-
mu sync.RWMutex
282278
istanbul atomic.Bool // Fork indicator whether we are in the istanbul stage.
283279
eip2718 atomic.Bool // Fork indicator whether we are using EIP-2718 type transactions.
284280
eip1559 atomic.Bool // Fork indicator whether we are using EIP-1559 type transactions.
@@ -457,10 +453,7 @@ func (pool *TxPool) loop() {
457453
for _, tx = range list {
458454
toRemove = append(toRemove, tx.Hash())
459455
}
460-
pool.dropTxFeed.Send(DropTxsEvent{
461-
Txs: list,
462-
Reason: dropOld,
463-
})
456+
464457
queuedEvictionMeter.Mark(int64(len(list)))
465458
}
466459
}
@@ -514,12 +507,6 @@ func (pool *TxPool) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subsc
514507
return pool.scope.Track(pool.txFeed.Subscribe(ch))
515508
}
516509

517-
// SubscribeDropTxsEvent registers a subscription of DropTxsEvent and
518-
// starts sending event to the given channel.
519-
func (pool *TxPool) SubscribeDropTxsEvent(ch chan<- DropTxsEvent) event.Subscription {
520-
return pool.scope.Track(pool.dropTxFeed.Subscribe(ch))
521-
}
522-
523510
// GasPrice returns the current gas price enforced by the transaction pool.
524511
func (pool *TxPool) GasPrice() *big.Int {
525512
pool.gasPriceMu.RLock()
@@ -562,10 +549,6 @@ func (pool *TxPool) SetGasPrice(price *big.Int) {
562549
}
563550

564551
pool.priced.Removed(len(drop))
565-
pool.dropTxFeed.Send(DropTxsEvent{
566-
Txs: drop,
567-
Reason: dropGasPriceUpdated,
568-
})
569552
}
570553

571554
log.Info("Transaction pool price threshold updated", "price", price)
@@ -1001,10 +984,6 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
1001984
dropped := pool.removeTx(tx.Hash(), false)
1002985
pool.changesSinceReorg += dropped
1003986
}
1004-
pool.dropTxFeed.Send(DropTxsEvent{
1005-
Txs: drop,
1006-
Reason: dropUnderpriced,
1007-
})
1008987
}
1009988

1010989
// Try to replace an existing transaction in the pending pool
@@ -1026,11 +1005,6 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
10261005
pool.all.Remove(old.Hash())
10271006
pool.priced.Removed(1)
10281007
pendingReplaceMeter.Mark(1)
1029-
pool.dropTxFeed.Send(DropTxsEvent{
1030-
Txs: []*types.Transaction{old},
1031-
Reason: dropReplaced,
1032-
Replacement: tx,
1033-
})
10341008
}
10351009

10361010
pool.all.Add(tx, isLocal)
@@ -1106,10 +1080,6 @@ func (pool *TxPool) enqueueTx(hash common.Hash, tx *types.Transaction, local boo
11061080
pool.all.Remove(old.Hash())
11071081
pool.priced.Removed(1)
11081082
queuedReplaceMeter.Mark(1)
1109-
pool.dropTxFeed.Send(DropTxsEvent{
1110-
Txs: []*types.Transaction{old},
1111-
Reason: dropReplaced,
1112-
})
11131083
} else {
11141084
// Nothing was replaced, bump the queued counter
11151085
queuedGauge.Inc(1)
@@ -1187,10 +1157,6 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
11871157
pool.all.Remove(old.Hash())
11881158
pool.priced.Removed(1)
11891159
pendingReplaceMeter.Mark(1)
1190-
pool.dropTxFeed.Send(DropTxsEvent{
1191-
Txs: []*types.Transaction{old},
1192-
Reason: dropReplaced,
1193-
})
11941160
} else {
11951161
// Nothing was replaced, bump the pending counter
11961162
pendingGauge.Inc(1)
@@ -1526,10 +1492,6 @@ func (pool *TxPool) removeTx(hash common.Hash, outofbound bool) int {
15261492

15271493
// Reduce the pending counter
15281494
pendingGauge.Dec(int64(1 + len(invalids)))
1529-
pool.dropTxFeed.Send(DropTxsEvent{
1530-
Txs: invalids,
1531-
Reason: dropUnexecutable,
1532-
})
15331495

15341496
return 1 + len(invalids)
15351497
}
@@ -1985,11 +1947,6 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) []*types.Trans
19851947

19861948
log.Trace("Removed old queued transactions", "count", forwardsLen)
19871949

1988-
pool.dropTxFeed.Send(DropTxsEvent{
1989-
Txs: forwards,
1990-
Reason: dropLowNonce,
1991-
})
1992-
19931950
// Drop all transactions that are too costly (low balance or out of gas)
19941951
balance.SetFromBig(pool.currentState.GetBalance(addr))
19951952

@@ -2003,10 +1960,6 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) []*types.Trans
20031960

20041961
log.Trace("Removed unpayable queued transactions", "count", dropsLen)
20051962
queuedNofundsMeter.Mark(int64(dropsLen))
2006-
pool.dropTxFeed.Send(DropTxsEvent{
2007-
Txs: drops,
2008-
Reason: dropUnpayable,
2009-
})
20101963

20111964
// Gather all executable transactions and promote them
20121965
readies = list.Ready(pool.pendingNonces.get(addr))
@@ -2035,10 +1988,6 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) []*types.Trans
20351988
}
20361989

20371990
queuedRateLimitMeter.Mark(int64(capsLen))
2038-
pool.dropTxFeed.Send(DropTxsEvent{
2039-
Txs: caps,
2040-
Reason: dropAccountCap,
2041-
})
20421991
}
20431992

20441993
// Mark all the items dropped as removed
@@ -2160,11 +2109,6 @@ func (pool *TxPool) truncatePending() {
21602109
log.Trace("Removed fairness-exceeding pending transaction", "hash", hash)
21612110
}
21622111

2163-
pool.dropTxFeed.Send(DropTxsEvent{
2164-
Txs: caps,
2165-
Reason: dropAccountCap,
2166-
})
2167-
21682112
pool.priced.Removed(capsLen)
21692113
pendingGauge.Dec(int64(capsLen))
21702114

@@ -2205,11 +2149,6 @@ func (pool *TxPool) truncatePending() {
22052149
log.Trace("Removed fairness-exceeding pending transaction", "hash", hash)
22062150
}
22072151

2208-
pool.dropTxFeed.Send(DropTxsEvent{
2209-
Txs: caps,
2210-
Reason: dropAccountCap,
2211-
})
2212-
22132152
pool.priced.Removed(capsLen)
22142153

22152154
pendingGauge.Dec(int64(capsLen))
@@ -2280,10 +2219,6 @@ func (pool *TxPool) truncateQueue() {
22802219
for _, tx = range listFlatten {
22812220
pool.removeTx(tx.Hash(), true)
22822221
}
2283-
pool.dropTxFeed.Send(DropTxsEvent{
2284-
Txs: txs,
2285-
Reason: dropTruncating,
2286-
})
22872222

22882223
drop -= size
22892224
queuedRateLimitMeter.Mark(int64(size))
@@ -2301,12 +2236,6 @@ func (pool *TxPool) truncateQueue() {
23012236
pool.removeTx(txs[i].Hash(), true)
23022237

23032238
drop--
2304-
2305-
queuedRateLimitMeter.Mark(1)
2306-
pool.dropTxFeed.Send(DropTxsEvent{
2307-
Txs: []*types.Transaction{txs[i]},
2308-
Reason: dropTruncating,
2309-
})
23102239
}
23112240
}
23122241
}
@@ -2349,10 +2278,7 @@ func (pool *TxPool) demoteUnexecutables() {
23492278
pool.all.Remove(hash)
23502279
log.Trace("Removed old pending transaction", "hash", hash)
23512280
}
2352-
pool.dropTxFeed.Send(DropTxsEvent{
2353-
Txs: olds,
2354-
Reason: dropLowNonce,
2355-
})
2281+
23562282
// Drop all transactions that are too costly (low balance or out of gas), and queue any invalids back for later
23572283
balance.SetFromBig(pool.currentState.GetBalance(addr))
23582284
drops, invalids := list.Filter(balance, pool.currentMaxGas.Load())
@@ -2366,10 +2292,6 @@ func (pool *TxPool) demoteUnexecutables() {
23662292

23672293
pool.all.Remove(hash)
23682294
}
2369-
pool.dropTxFeed.Send(DropTxsEvent{
2370-
Txs: drops,
2371-
Reason: dropUnpayable,
2372-
})
23732295

23742296
pendingNofundsMeter.Mark(int64(dropsLen))
23752297

eth/dropped_tx_subscription.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

eth/filters/dropped_tx_subscription.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
package filters
22

33
import (
4-
"context"
5-
"time"
6-
74
"github.com/ethereum/go-ethereum/common/hexutil"
8-
"github.com/ethereum/go-ethereum/core"
95
"github.com/ethereum/go-ethereum/core/types"
106
"github.com/ethereum/go-ethereum/internal/ethapi"
11-
"github.com/ethereum/go-ethereum/rpc"
127
)
138

149
type dropNotification struct {
@@ -69,41 +64,3 @@ func newRPCPendingTransaction(tx *types.Transaction) *ethapi.RPCTransaction {
6964
}
7065
return result
7166
}
72-
73-
// DroppedTransactions send a notification each time a transaction is dropped from the mempool
74-
func (api *PublicFilterAPI) DroppedTransactions(ctx context.Context) (*rpc.Subscription, error) {
75-
notifier, supported := rpc.NotifierFromContext(ctx)
76-
if !supported {
77-
return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported
78-
}
79-
80-
rpcSub := notifier.CreateSubscription()
81-
82-
go func() {
83-
dropped := make(chan core.DropTxsEvent)
84-
droppedSub := api.backend.SubscribeDropTxsEvent(dropped)
85-
86-
for {
87-
select {
88-
case d := <-dropped:
89-
for _, tx := range d.Txs {
90-
notification := &dropNotification{
91-
Tx: newRPCPendingTransaction(tx),
92-
Reason: d.Reason,
93-
Replacement: newRPCPendingTransaction(d.Replacement),
94-
Time: time.Now().UnixNano(),
95-
}
96-
notifier.Notify(rpcSub.ID, notification)
97-
}
98-
case <-rpcSub.Err():
99-
droppedSub.Unsubscribe()
100-
return
101-
case <-notifier.Closed():
102-
droppedSub.Unsubscribe()
103-
return
104-
}
105-
}
106-
}()
107-
108-
return rpcSub, nil
109-
}

eth/tracers/call_tracer.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ package tracers
33
import (
44
"fmt"
55
"math/big"
6+
"time"
67

78
"github.com/ethereum/go-ethereum/common"
89
"github.com/ethereum/go-ethereum/common/hexutil"
910
"github.com/ethereum/go-ethereum/core/state"
1011
"github.com/ethereum/go-ethereum/core/vm"
1112

12-
"time"
13-
1413
"github.com/ethereum/go-ethereum/log"
1514

1615
"github.com/holiman/uint256"
@@ -73,9 +72,9 @@ func (tracer *CallTracer) CaptureStart(evm *vm.EVM, from common.Address, to comm
7372
Calls: []*call{},
7473
}}
7574
}
76-
func (tracer *CallTracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) {
75+
func (tracer *CallTracer) CaptureEnd(output []byte, gasUsed uint64, err error) {
7776
tracer.callStack[tracer.i()].GasUsed = hexutil.Uint64(gasUsed)
78-
tracer.callStack[tracer.i()].Time = fmt.Sprintf("%v", t)
77+
tracer.callStack[tracer.i()].Time = fmt.Sprintf("%v", time.Since(tracer.callStack[tracer.i()].startTime))
7978
tracer.callStack[tracer.i()].Output = hexutil.Bytes(output)
8079
}
8180

@@ -200,3 +199,7 @@ func (tracer *CallTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64
200199
func (tracer *CallTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
201200
}
202201
func (tracer *CallTracer) CaptureExit(output []byte, gasUsed uint64, err error) {}
202+
203+
func (tracer *CallTracer) CaptureTxStart(_ uint64) {}
204+
205+
func (tracer *CallTracer) CaptureTxEnd(_ uint64) {}

internal/ethapi/backend.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ type Backend interface {
8484
TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
8585
TxPoolContentFrom(addr common.Address) (types.Transactions, types.Transactions)
8686
SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
87-
SubscribeDropTxsEvent(chan<- core.DropTxsEvent) event.Subscription
88-
8987
ChainConfig() *params.ChainConfig
9088
Engine() consensus.Engine
9189

0 commit comments

Comments
 (0)