Skip to content

Commit

Permalink
issue with stress test fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
jwasinger committed Sep 24, 2021
1 parent 86d1779 commit 59c3bb9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
28 changes: 18 additions & 10 deletions miner/collator.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,22 @@ func (bs *collatorBlockState) AddTransactions(txs types.Transactions) (error, ty

for _, tx := range txs {
if bs.gasPool.Gas() < params.TxGas {
return ErrGasLimitReached, nil
retErr = ErrGasLimitReached
break
}

// Check whether the tx is replay protected. If we're not in the EIP155 hf
// phase, start ignoring the sender until we do.
if tx.Protected() && !bs.env.worker.chainConfig.IsEIP155(bs.header.Number) {
return ErrTxTypeNotSupported, nil
retErr = ErrTxTypeNotSupported
break
}

// TODO can this error also be returned by commitTransaction below?
_, err := tx.EffectiveGasTip(bs.header.BaseFee)
if err != nil {
return ErrGasFeeCapTooLow, nil
retErr = ErrGasFeeCapTooLow
break
}

snapshot := bs.state.Snapshot()
Expand All @@ -306,20 +309,25 @@ func (bs *collatorBlockState) AddTransactions(txs types.Transactions) (error, ty
retErr = ErrStrange
}

bs.logs = bs.logs[:len(bs.logs)-tcount]
bs.state.RevertToSnapshot(bs.snapshots[len(bs.snapshots)-(tcount+1)])
bs.snapshots = bs.snapshots[:len(bs.snapshots)-(tcount+1)]

return retErr, nil
break
} else {
bs.logs = append(bs.logs, txLogs...)
tcount++
}
}

retReceipts := bs.receipts[bs.tcount:]
bs.tcount += tcount
var retReceipts []*types.Receipt

if retErr != nil {
bs.logs = bs.logs[:len(bs.logs)-tcount]
bs.state.RevertToSnapshot(bs.snapshots[len(bs.snapshots)-(tcount+1)])
bs.snapshots = bs.snapshots[:len(bs.snapshots)-(tcount+1)]

return retErr, nil
} else {
retReceipts = bs.receipts[bs.tcount:]
bs.tcount += tcount
}
return nil, retReceipts
}

Expand Down
7 changes: 0 additions & 7 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ type worker struct {

// Subscriptions
mux *event.TypeMux
txsCh chan core.NewTxsEvent
txsSub event.Subscription
chainHeadCh chan core.ChainHeadEvent
chainHeadSub event.Subscription
chainSideCh chan core.ChainSideEvent
Expand Down Expand Up @@ -224,7 +222,6 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, collator Collato
remoteUncles: make(map[common.Hash]*types.Block),
unconfirmed: newUnconfirmedBlocks(eth.BlockChain(), sealingLogAtDepth),
pendingTasks: make(map[common.Hash]*task),
txsCh: make(chan core.NewTxsEvent, txChanSize),
chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize),
chainSideCh: make(chan core.ChainSideEvent, chainSideChanSize),
newWorkCh: make(chan *newWorkReq),
Expand All @@ -244,7 +241,6 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, collator Collato
}

// Subscribe NewTxsEvent for tx pool
worker.txsSub = eth.TxPool().SubscribeNewTxsEvent(worker.txsCh)
// Subscribe events for blockchain
worker.chainHeadSub = eth.BlockChain().SubscribeChainHeadEvent(worker.chainHeadCh)
worker.chainSideSub = eth.BlockChain().SubscribeChainSideEvent(worker.chainSideCh)
Expand Down Expand Up @@ -412,7 +408,6 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
// the received event. It can support two modes: automatically generate task and
// submit it or return task according to given parameters for various proposes.
func (w *worker) mainLoop() {
defer w.txsSub.Unsubscribe()
defer w.chainHeadSub.Unsubscribe()
defer w.chainSideSub.Unsubscribe()

Expand Down Expand Up @@ -475,8 +470,6 @@ func (w *worker) mainLoop() {
// System stopped
case <-w.exitCh:
return
case <-w.txsSub.Err():
return
case <-w.chainHeadSub.Err():
return
case <-w.chainSideSub.Err():
Expand Down

0 comments on commit 59c3bb9

Please sign in to comment.