mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-12 15:03:45 +00:00
core: fail fast on transaction error in parallel block execution (#35465)
This commit is contained in:
parent
a235d28192
commit
8e77ddbaa0
1 changed files with 7 additions and 4 deletions
|
|
@ -283,10 +283,8 @@ func (p *StateProcessor) executeTransactionsParallel(block *types.Block, parentR
|
||||||
if workers > len(txs) {
|
if workers > len(txs) {
|
||||||
workers = len(txs)
|
workers = len(txs)
|
||||||
}
|
}
|
||||||
var (
|
var cursor atomic.Int64
|
||||||
cursor atomic.Int64
|
group, gctx := errgroup.WithContext(context.Background())
|
||||||
group errgroup.Group
|
|
||||||
)
|
|
||||||
for w := 0; w < workers; w++ {
|
for w := 0; w < workers; w++ {
|
||||||
group.Go(func() error {
|
group.Go(func() error {
|
||||||
context := NewEVMBlockContext(header, p.chain, nil)
|
context := NewEVMBlockContext(header, p.chain, nil)
|
||||||
|
|
@ -300,6 +298,11 @@ func (p *StateProcessor) executeTransactionsParallel(block *types.Block, parentR
|
||||||
defer evm.Release()
|
defer evm.Release()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
select {
|
||||||
|
case <-gctx.Done():
|
||||||
|
return gctx.Err()
|
||||||
|
default:
|
||||||
|
}
|
||||||
i := int(cursor.Add(1)) - 1
|
i := int(cursor.Add(1)) - 1
|
||||||
if i >= len(txs) {
|
if i >= len(txs) {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue