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

Mempool: handle not-executable transactions related to guardians #6628

Merged
merged 9 commits into from
Nov 28, 2024

Conversation

andreibancioiu
Copy link
Collaborator

@andreibancioiu andreibancioiu commented Nov 24, 2024

Reasoning behind the pull request

Proposed changes

Testing procedure

  • Standard testing
  • Send not-executable transactions (related to guardians). Inspect the logs and assert they aren't selected.

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@andreibancioiu andreibancioiu self-assigned this Nov 24, 2024
@@ -288,7 +288,7 @@ func (txProc *baseTxProcessor) checkGuardedAccountUnguardedTxPermission(tx *tran
return nil
}

func (txProc *baseTxProcessor) verifyGuardian(tx *transaction.Transaction, account state.UserAccountHandler) error {
func (txProc *baseTxProcessor) VerifyGuardian(tx *transaction.Transaction, account state.UserAccountHandler) error {
Copy link
Collaborator Author

@andreibancioiu andreibancioiu Nov 27, 2024

Choose a reason for hiding this comment

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

We now export this function (design workaround).

Copy link
Contributor

Choose a reason for hiding this comment

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

We not?

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 now (updated message above)

@@ -1417,7 +1411,12 @@ func (txs *transactions) computeSortedTxs(
sortedTransactionsProvider := createSortedTransactionsProvider(txShardPool)
log.Debug("computeSortedTxs.GetSortedTransactions")

sortedTxs := sortedTransactionsProvider.GetSortedTransactions(txs.accountStateProvider)
session, err := newSelectionSession(txs.basePreProcess.accounts, txs.txProcessor)
Copy link
Collaborator Author

@andreibancioiu andreibancioiu Nov 27, 2024

Choose a reason for hiding this comment

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

This is intended. I've moved the instantiation here (and renamed the provider to session) - in the future, we can add an additional memoization mechanism within the session (hold the loaded account in a map). Once the selection ends, the session is simply dropped.

// Will be called by mempool during transaction selection.
func (session *selectionSession) IsBadlyGuarded(tx data.TransactionHandler) bool {
address := tx.GetSndAddr()
account, err := session.accountsAdapter.GetExistingAccount(address)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the near future, we'll add a memoization mechanism here (at a higher level than the accounts adapter cache).

@andreibancioiu andreibancioiu marked this pull request as ready for review November 27, 2024 08:01
process/block/preprocess/selectionSession.go Show resolved Hide resolved
@@ -288,7 +288,7 @@ func (txProc *baseTxProcessor) checkGuardedAccountUnguardedTxPermission(tx *tran
return nil
}

func (txProc *baseTxProcessor) verifyGuardian(tx *transaction.Transaction, account state.UserAccountHandler) error {
func (txProc *baseTxProcessor) VerifyGuardian(tx *transaction.Transaction, account state.UserAccountHandler) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

We not?

@@ -102,7 +102,7 @@ func (inTx *InterceptedTransaction) CheckMaxGasPrice() error {

// VerifyGuardian calls the un-exported method verifyGuardian
func (txProc *txProcessor) VerifyGuardian(tx *transaction.Transaction, account state.UserAccountHandler) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no need for this export now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, removed (actually, by mistake, I did a bad recursive call).

Base automatically changed from MX-16107-no-more-notify to feat/mempool November 27, 2024 17:15
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

Attention: Patch coverage is 79.54545% with 9 lines in your changes missing coverage. Please review.

Please upload report for BASE (feat/mempool@e04679e). Learn more about missing BASE report.

Files with missing lines Patch % Lines
process/block/preprocess/selectionSession.go 82.85% 3 Missing and 3 partials ⚠️
process/block/preprocess/transactions.go 50.00% 1 Missing and 1 partial ⚠️
...ess/block/preprocess/sortedTransactionsProvider.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##             feat/mempool    #6628   +/-   ##
===============================================
  Coverage                ?   78.68%           
===============================================
  Files                   ?      754           
  Lines                   ?    99291           
  Branches                ?        0           
===============================================
  Hits                    ?    78127           
  Misses                  ?    15891           
  Partials                ?     5273           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@andreibancioiu andreibancioiu merged commit 960b81e into feat/mempool Nov 28, 2024
7 checks passed
@andreibancioiu andreibancioiu deleted the MX-16179-guardians branch November 28, 2024 11:03
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.

3 participants