Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

concurrency fix #1802

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions go/enclave/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"math/big"
"strings"
"sync"

// unsafe package imported in order to link to a private function in go-ethereum.
// This allows us to validate transactions against the tx pool rules.
Expand All @@ -28,6 +29,7 @@ type TxPool struct {
Chain *ethchainadapter.EthChainAdapter
gasTip *big.Int
running bool
stateMutex sync.Mutex
logger gethlog.Logger
}

Expand All @@ -41,6 +43,7 @@ func NewTxPool(blockchain *ethchainadapter.EthChainAdapter, gasTip *big.Int, log
txPoolConfig: txPoolConfig,
legacyPool: legacyPool,
gasTip: gasTip,
stateMutex: sync.Mutex{},
logger: logger,
}, nil
}
Expand Down Expand Up @@ -96,6 +99,8 @@ func (t *TxPool) Validate(tx *common.L2Tx) error {
return err
}

t.stateMutex.Lock()
defer t.stateMutex.Unlock()
// validate against the state. Things like nonce, balance, etc
return validateTx(t.legacyPool, tx, false)
}
Expand Down
Loading