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: completely handle fees and transferred balances within "detectWillFeeExceedBalance()" #6637

Merged
merged 8 commits into from
Nov 28, 2024

Conversation

andreibancioiu
Copy link
Collaborator

@andreibancioiu andreibancioiu commented Nov 26, 2024

Reasoning behind the pull request

Proposed changes

  • Handle consumed balance mx-chain-storage-go#59
  • Inform selection about the value transferred within a transaction, so that it can stop selecting transactions from a sender that consumes all the balance (no more balance remaining for fees).

Testing procedure

  • Standard testing
  • Craft sequences of transactions that also hold not-executable ones (balance consumed by the first of them).

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 26, 2024
return nil
}

if function != core.BuiltInFunctionMultiESDTNFTTransfer {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Superfluous (somehow)?

@andreibancioiu andreibancioiu marked this pull request as ready for review November 27, 2024 08:31
AdoAdoAdo
AdoAdoAdo previously approved these changes Nov 28, 2024

accumulatedNativeValue := big.NewInt(0)

for _, transfer := range esdtTransfers.ESDTTransfers {
Copy link
Contributor

Choose a reason for hiding this comment

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

does this add a negligible overhead? A lot of transactions are with MultiESDTNFTTransfer
can the entire method be parallelized?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very good question, will benchmark ASAP 🙌

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

// NOTE: 20% is also due to the require() / assert() calls.
// 0.012993s (TestBenchmarkSelectionSession_GetTransferredValue/numTransactions_=_5_000)
// 0.024580s (TestBenchmarkSelectionSession_GetTransferredValue/numTransactions_=_10_000)
// 0.048808s (TestBenchmarkSelectionSession_GetTransferredValue/numTransactions_=_20_000)

Thus, if we select ~10k, about 20 milliseconds (a bit much) will be spent in GetTransferredValue(). The selection duration is capped, though. There is still room for optimization.

We can move the call to GetTransferredValue() to the moment the transaction is added to the pool (additions are concurrent, also).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

MX-16211

Base automatically changed from MX-16179-guardians to feat/mempool November 28, 2024 11:03
@andreibancioiu andreibancioiu dismissed AdoAdoAdo’s stale review November 28, 2024 11:03

The base branch was changed.

// 2. proposer will have those 3 transactions in its pools and will propose a block
// 3. another node will be able to sync the proposed block (and request - receive) the 2 transactions that
// will end up in the block (one valid and one invalid)
// 4. the non-executable transaction will be removed from the proposer's pool
// 4. the non-executable transaction will not be immediately removed from the proposer's pool. See MX-16200.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

MX-16200

@AdoAdoAdo AdoAdoAdo merged commit 03e21bf into feat/mempool Nov 28, 2024
5 checks passed
@AdoAdoAdo AdoAdoAdo deleted the MX-16160-consumed-balance branch November 28, 2024 15:13
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