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

feat: loop through all txs before returning the tx set to consensus #1113

Merged
merged 3 commits into from
Oct 17, 2023

Conversation

cmwaters
Copy link
Contributor

Description

This modifies the behavior of the ReapMaxBytesMaxGas method called by consensus. Prior we would return the tx set the moment the first tx was greater than the limit. Now instead of breaking we continue through all txs. This means that a large tx doesn't block smaller less priority transactions from getting through.

PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use
    unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments

evan-forbes
evan-forbes previously approved these changes Oct 13, 2023
rootulp
rootulp previously approved these changes Oct 13, 2023
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

LGTM! Do we want a test for the situation where the mempool has: [bigTx, smallTx] where bigTx would exceed maxBytes?

I infer that before this PR neither would be reaped. After this PR the bigTx would be skipped and the smallTx would be reaped.

@cmwaters
Copy link
Contributor Author

LGTM! Do we want a test for the situation where the mempool has: [bigTx, smallTx] where bigTx would exceed maxBytes?

I infer that before this PR neither would be reaped. After this PR the bigTx would be skipped and the smallTx would be reaped.

Yeah good idea. I'll add a test for that

Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

👍

// smaller low priority tx with different sender
smallTx := []byte(fmt.Sprintf("sender-2-1=%X=1", smallPrefix))
require.NoError(t, txmp.CheckTx(bigTx, nil, mempool.TxInfo{SenderID: 1}))
require.NoError(t, txmp.CheckTx(smallTx, nil, mempool.TxInfo{SenderID: 1}))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it impacts the results of the test but is this line supposed to have a different SenderID?

Suggested change
require.NoError(t, txmp.CheckTx(smallTx, nil, mempool.TxInfo{SenderID: 1}))
require.NoError(t, txmp.CheckTx(smallTx, nil, mempool.TxInfo{SenderID: 2}))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no the sender can be the same. It's okay for the txs to be sent by the same peer. You might be confusing it with sender in CheckTx

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry I don't follow. Is this line referencing the sender in CheckTx?

// smaller low priority tx with different sender
smallTx := []byte(fmt.Sprintf("sender-2-1=%X=1", smallPrefix))
require.NoError(t, txmp.CheckTx(bigTx, nil, mempool.TxInfo{SenderID: 1}))
require.NoError(t, txmp.CheckTx(smallTx, nil, mempool.TxInfo{SenderID: 1}))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
require.NoError(t, txmp.CheckTx(smallTx, nil, mempool.TxInfo{SenderID: 1}))
require.NoError(t, txmp.CheckTx(smallTx, nil, mempool.TxInfo{SenderID: 2}))

@cmwaters cmwaters merged commit 793ece9 into main Oct 17, 2023
15 checks passed
@cmwaters cmwaters deleted the cal/reap-txs branch October 17, 2023 16:05
mergify bot pushed a commit that referenced this pull request Oct 17, 2023
…1113)

## Description

This modifies the behavior of the `ReapMaxBytesMaxGas` method called by
consensus. Prior we would return the tx set the moment the first tx was
greater than the limit. Now instead of breaking we continue through all
txs. This means that a large tx doesn't block smaller less priority
transactions from getting through.

(cherry picked from commit 793ece9)
@zmanian
Copy link
Contributor

zmanian commented Oct 22, 2023

Apparently at some point the behavior of the CosmosSDK changed again and it now allows transactions transactions with ascending sequence numbers into the mempool.

This behavior change is going to result in annoying behavior where the block proposer will now start proposing sequences out of order under congestion.

@zmanian
Copy link
Contributor

zmanian commented Oct 22, 2023

I don't think this PR is a good idea.

@evan-forbes
Copy link
Member

evan-forbes commented Oct 23, 2023

Apparently at some point the behavior of the CosmosSDK changed again and it now allows transactions transactions with ascending sequence numbers into the mempool.

thanks this is definitely something I'll look into.

This behavior change is going to result in annoying behavior where the block proposer will now start proposing sequences out of order under congestion.

fwiw since all PFB transactions included in a block must be valid, proposers filter invalid txs out. Which results in a perhaps equally unwanted behavior, where if the txs' are out of order, the higher sequence will be dropped that block and the lower sequence will be included. However the lower sequenced tx will be included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants