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

fix nonce too low #67

Merged
merged 1 commit into from
Sep 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
11 changes: 7 additions & 4 deletions ethtxmanager/ethtxmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ type Client struct {
ctx context.Context
cancel context.CancelFunc

cfg Config
etherman ethermanInterface
storage storageInterface
from common.Address
cfg Config
etherman ethermanInterface
storage storageInterface
from common.Address
nonceMutex sync.Mutex
}

type pending struct {
Expand Down Expand Up @@ -154,6 +155,8 @@ func pendingL1Txs(URL string, from common.Address, httpHeaders map[string]string

// getTxNonce get the nonce for the given account
func (c *Client) getTxNonce(ctx context.Context, from common.Address) (uint64, error) {
c.nonceMutex.Lock()
defer c.nonceMutex.Unlock()
// Get created transactions from the database for the given account
createdTxs, err := c.storage.GetByStatus(ctx, []MonitoredTxStatus{MonitoredTxStatusCreated})
if err != nil {
Expand Down
Loading