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

Txmv2 #15467

Merged
merged 91 commits into from
Jan 17, 2025
Merged

Txmv2 #15467

merged 91 commits into from
Jan 17, 2025

Conversation

dimriou
Copy link
Collaborator

@dimriou dimriou commented Nov 29, 2024

This PR introduces a new experimental version of the Transaction Manager. Not all of the existing features are implemented, and they will be rolled out in future PRs. Currently, OEV is using this TXMv2 because of its properties.

@dimriou dimriou marked this pull request as ready for review January 14, 2025 17:27
@dimriou dimriou requested review from a team as code owners January 14, 2025 17:27
Copy link
Contributor

@prashantkumar1982 prashantkumar1982 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few comments

tx.LastBroadcastAt = nil // Mark reorged transaction as if it wasn't broadcasted before
unconfirmedTransactionIDs = append(unconfirmedTransactionIDs, tx.ID)
m.UnconfirmedTransactions[*tx.Nonce] = tx
delete(m.ConfirmedTransactions, *tx.Nonce)
}
}

if len(m.ConfirmedTransactions) >= maxQueuedTransactions {
if len(m.ConfirmedTransactions) > maxQueuedTransactions {
prunedTxIDs := m.pruneConfirmedTransactions()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to prune Confirmed Txs?
The maxQueuedTransactions setting meant to apply only to unstarted txs in txmv1.
Is this a new config for txmv2? Also, why is it set hard-coded to 250?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a way to prevent the queues from growing indefinitely (all queues), otherwise they could end up using the entire memory, resulting in the node crashing. maxQueuedTransactions will eventually be replaced by the existing config we have MaxQueued once I implement the persistence storage. To figure out the optimal value memory-wise I'd have to run extensive tests, so for now, it was easier to start with a hard-coded value that we use in most of our cases just to be on the safe side.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, as long as TXM v2 is not widely use, we are good.
But I know CCIP uses their own MaxQueued values, and expect only unstarted Txs to get pruned.

if err != nil {
t.lggr.Errorw("Error when fetching initial pending nonce", "address", address, "err", err)
t.lggr.Errorw("Error when fetching initial nonce", "address", address, "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be warn level. Same for below

ctxWithTimeout, cancel := context.WithTimeout(ctx, pendingNonceDefaultTimeout)
defer cancel()
for {
pendingNonce, err = t.client.PendingNonceAt(ctxWithTimeout, address)
pendingNonce, err := t.client.PendingNonceAt(ctxWithTimeout, address)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is called repeatedly within broadcastLoop(), it would be efficient if we check here first if nonce is already set for this address. If yes, then return early.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional. Nonce won't have been stored unless the TXM has restarted, in which case we actually do want to overwrite the nonce.

@dimriou dimriou added this pull request to the merge queue Jan 17, 2025
Merged via the queue into develop with commit 436b684 Jan 17, 2025
172 of 173 checks passed
@dimriou dimriou deleted the txmv2 branch January 17, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants