mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 22:56:43 +00:00
fix flaky catalyst tests by giving enough time for the pool to reset to the newly-inserted test chain before continuing the test case
This commit is contained in:
parent
098b362c9a
commit
95948b60d4
2 changed files with 16 additions and 18 deletions
|
|
@ -978,6 +978,7 @@ func (pool *LegacyPool) Add(txs []*types.Transaction, sync bool) []error {
|
||||||
pool.requestPromoteExecutables(req)
|
pool.requestPromoteExecutables(req)
|
||||||
if sync {
|
if sync {
|
||||||
<-req.done
|
<-req.done
|
||||||
|
fmt.Printf("added %x\n", txs[0].Hash())
|
||||||
}
|
}
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
@ -1204,6 +1205,7 @@ func (pool *LegacyPool) scheduleReorgLoop() {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case req := <-pool.reqResetCh:
|
case req := <-pool.reqResetCh:
|
||||||
|
fmt.Printf("request reset to %d\n", req.newHead.Number)
|
||||||
// Reset request: update head if request is already pending.
|
// Reset request: update head if request is already pending.
|
||||||
if reset == nil {
|
if reset == nil {
|
||||||
reset = req
|
reset = req
|
||||||
|
|
@ -1215,17 +1217,7 @@ func (pool *LegacyPool) scheduleReorgLoop() {
|
||||||
//pool.reorgDoneCh <- nextDone
|
//pool.reorgDoneCh <- nextDone
|
||||||
|
|
||||||
case req := <-pool.reqPromoteCh:
|
case req := <-pool.reqPromoteCh:
|
||||||
select {
|
fmt.Println("request promote")
|
||||||
case tx := <-pool.queueTxEventCh:
|
|
||||||
// Queue up the event, but don't schedule a reorg. It's up to the caller to
|
|
||||||
// request one later if they want the events sent.
|
|
||||||
addr, _ := types.Sender(pool.signer, tx)
|
|
||||||
if _, ok := queuedEvents[addr]; !ok {
|
|
||||||
queuedEvents[addr] = NewSortedMap()
|
|
||||||
}
|
|
||||||
queuedEvents[addr].Put(tx)
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
// Promote request: update address set if request is already pending.
|
// Promote request: update address set if request is already pending.
|
||||||
if dirtyAccounts == nil {
|
if dirtyAccounts == nil {
|
||||||
dirtyAccounts = req.set
|
dirtyAccounts = req.set
|
||||||
|
|
@ -1246,24 +1238,18 @@ func (pool *LegacyPool) scheduleReorgLoop() {
|
||||||
queuedEvents[addr].Put(tx)
|
queuedEvents[addr].Put(tx)
|
||||||
|
|
||||||
case <-curDone:
|
case <-curDone:
|
||||||
fmt.Println("reorg done")
|
|
||||||
for _, ch := range curDones {
|
for _, ch := range curDones {
|
||||||
fmt.Println(ch)
|
|
||||||
close(ch)
|
close(ch)
|
||||||
}
|
}
|
||||||
fmt.Println("end reorg done")
|
|
||||||
curDone = nil
|
curDone = nil
|
||||||
|
|
||||||
case <-pool.reorgShutdownCh:
|
case <-pool.reorgShutdownCh:
|
||||||
// Wait for current run to finish.
|
// Wait for current run to finish.
|
||||||
if curDone != nil {
|
if curDone != nil {
|
||||||
fmt.Println("shutdown reorg done")
|
|
||||||
<-curDone
|
<-curDone
|
||||||
for _, ch := range curDones {
|
for _, ch := range curDones {
|
||||||
fmt.Println(ch)
|
|
||||||
close(ch)
|
close(ch)
|
||||||
}
|
}
|
||||||
fmt.Println("end reorg done")
|
|
||||||
}
|
}
|
||||||
close(nextDone)
|
close(nextDone)
|
||||||
return
|
return
|
||||||
|
|
@ -1324,6 +1310,7 @@ func (pool *LegacyPool) runReorg(done chan struct{}, reset *txpoolResetRequest,
|
||||||
for addr, list := range pool.pending {
|
for addr, list := range pool.pending {
|
||||||
highestPending := list.LastElement()
|
highestPending := list.LastElement()
|
||||||
nonces[addr] = highestPending.Nonce() + 1
|
nonces[addr] = highestPending.Nonce() + 1
|
||||||
|
fmt.Printf("set pending nonce %x <- %d\n", addr, highestPending.Nonce()+1)
|
||||||
}
|
}
|
||||||
pool.pendingNonces.setAll(nonces)
|
pool.pendingNonces.setAll(nonces)
|
||||||
}
|
}
|
||||||
|
|
@ -1465,6 +1452,7 @@ func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.T
|
||||||
if list == nil {
|
if list == nil {
|
||||||
continue // Just in case someone calls with a non existing account
|
continue // Just in case someone calls with a non existing account
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop all transactions that are deemed too old (low nonce)
|
// Drop all transactions that are deemed too old (low nonce)
|
||||||
forwards := list.Forward(pool.currentState.GetNonce(addr))
|
forwards := list.Forward(pool.currentState.GetNonce(addr))
|
||||||
for _, tx := range forwards {
|
for _, tx := range forwards {
|
||||||
|
|
@ -1479,14 +1467,23 @@ func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.T
|
||||||
log.Trace("Removed unpayable queued transactions", "count", len(drops))
|
log.Trace("Removed unpayable queued transactions", "count", len(drops))
|
||||||
queuedNofundsMeter.Mark(int64(len(drops)))
|
queuedNofundsMeter.Mark(int64(len(drops)))
|
||||||
|
|
||||||
|
fmt.Printf("pending nonce of %x is %d\n", addr, pool.pendingNonces.get(addr))
|
||||||
|
fmt.Printf("in-state nonce of %x is %d\n", addr, pool.currentState.GetNonce(addr))
|
||||||
// Gather all executable transactions and promote them
|
// Gather all executable transactions and promote them
|
||||||
readies := list.Ready(pool.pendingNonces.get(addr))
|
readies := list.Ready(pool.pendingNonces.get(addr))
|
||||||
|
fmt.Println(len(readies))
|
||||||
|
|
||||||
for _, tx := range readies {
|
for _, tx := range readies {
|
||||||
hash := tx.Hash()
|
hash := tx.Hash()
|
||||||
if pool.promoteTx(addr, hash, tx) {
|
if pool.promoteTx(addr, hash, tx) {
|
||||||
promoted = append(promoted, tx)
|
promoted = append(promoted, tx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fmt.Println(len(promoted))
|
||||||
|
if len(promoted) > 0 {
|
||||||
|
fmt.Println(promoted[0].Hash())
|
||||||
|
fmt.Println(promoted[0].Nonce())
|
||||||
|
}
|
||||||
log.Trace("Promoted queued transactions", "count", len(promoted))
|
log.Trace("Promoted queued transactions", "count", len(promoted))
|
||||||
queuedGauge.Dec(int64(len(readies)))
|
queuedGauge.Dec(int64(len(readies)))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ func assembleWithTransactions(api *ConsensusAPI, parentHash common.Hash, params
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if have, want := len(execData.Transactions), want; have != want {
|
if have, want := len(execData.Transactions), want; have != want {
|
||||||
err = fmt.Errorf("invalid number of transactions, have %d want %d", have, want)
|
err = fmt.Errorf("block %d: invalid number of transactions, have %d want %d", execData.Number, have, want)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return execData, nil
|
return execData, nil
|
||||||
|
|
@ -448,6 +448,7 @@ func startEthService(t *testing.T, genesis *core.Genesis, blocks []*types.Block)
|
||||||
n.Close()
|
n.Close()
|
||||||
t.Fatal("can't import test blocks:", err)
|
t.Fatal("can't import test blocks:", err)
|
||||||
}
|
}
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
ethservice.SetSynced()
|
ethservice.SetSynced()
|
||||||
return n, ethservice
|
return n, ethservice
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue