Skip to content

Conversation

@mmsqe
Copy link
Contributor

@mmsqe mmsqe commented Jun 24, 2025

Description

  • to avoid tx must have at least one signer error when set positive mempool.max-txs
  • upstream the fix of repeated tx sender recovery is wastful
  • upstream the decouple of sender address verification from execution
  • for test info

Closes: #217


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

Reviewers Checklist

All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.

I have...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • confirmed all author checklist items have been addressed
  • confirmed that this PR does not change production code
  • reviewed content
  • tested instructions (if applicable)
  • confirmed all CI checks have passed

@mmsqe mmsqe changed the title Problem: diff mempool max-txs trigger apphash mismatch fix: use PriorityMempool with signer extractor to prevent missing signers error in tx execution Jun 25, 2025
@mmsqe mmsqe marked this pull request as ready for review June 25, 2025 00:22
txData evmtypes.TxData,
from sdktypes.AccAddress,
) error {
if from != nil {
Copy link
Contributor Author

@mmsqe mmsqe Jun 30, 2025

Choose a reason for hiding this comment

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

@Vvaradinov We need signer recovery and extractor to make PriorityMempool work

Copy link
Member

@vladjdk vladjdk left a comment

Choose a reason for hiding this comment

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

My understanding of this PR is that we're moving the VRS signer extraction from the antehandler to the JSON-RPC. I think that's a good idea overall. I have a few small nits regarding the changes in that domain.

However, when it came to using the priority mempool, I couldn't actually get it to work properly. I'm still getting the same errors that I would get using the default mempool.

I don't mind using the priority nonce as an interim to this proposal, because the mempool doesn't hold transactions, and only sorts them, so there's no risk of p2p layer spam.

However, since it seems to behave the same way as the noop mempool with batched transactions, I don't really see a difference in setting it over noop in this case.

To be clear, I agree with the rest of the PR.

[ (gogoproto.moretags) = "rlp:\"-\"", (amino.dont_omitempty) = true ];
// from is the ethereum signer address in hex format. This address value is
// checked against the address derived from the signature (V, R, S) using the
string deprecated_from = 4 [ deprecated = true ];
Copy link
Member

Choose a reason for hiding this comment

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

For V1, we're going to be using new protos, with the assumption that the first version is a fresh start. Let's just keep using this field and remove the deprecated tag.

Copy link
Member

Choose a reason for hiding this comment

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

I thought about this again, and the audited version of the code will still have the string version of from. Looks like we're going to still have to support this/deprecate it since this PR won't yet be in effect for the audited release. Apologies for my mistake here!

}

// GetSenderLegacy fallbacks to old behavior if From is empty, should be used by json-rpc
func (msg *MsgEthereumTx) GetSenderLegacy(chainID *big.Int) (common.Address, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Could we rename this from GetSenderLegacy to GetSenderFromSignature? Legacy implies that this is an old method that shouldn't be used. As far as I understand, it injects the sender bytes into the msg.From and should always be used by the JSON-RPC before it hits the antehandler.


// GetSender convert the From field to common.Address
// From should always be set, which is validated in ValidateBasic
func (msg *MsgEthereumTx) GetSender() common.Address {
Copy link
Member

Choose a reason for hiding this comment

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

Like the below comment, let's rename this to GetSenderFromMsg, which will make it clear that msg.From cannot be nil

}

m, err := msg.AsMessage(msgSigner, baseFee)
m, err := msg.AsMessage(baseFee)
Copy link
Member

Choose a reason for hiding this comment

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

Rename msg to signedMsg here


handler := baseapp.NewDefaultProposalHandler(mempool, app)
var mpool mempool.Mempool
if maxTxs := cast.ToInt(appOpts.Get(server.FlagMempoolMaxTxs)); maxTxs >= 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I'm testing this with a Foundry script that uses transaction batching on this branch, and it seems like this is still failing to process out-of-order nonces.

Getting these errors:

- server returned an error response: error code -32000: invalid nonce; got 24, expected 23: invalid sequence: invalid sequence

Afaik, this PR is supposed to somewhat mitigate that. Is that not the case, or am I doing something wrong here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mind share the script? but we use different senders for priority test.

Copy link
Member

Choose a reason for hiding this comment

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

Anything that batch submits transactions using Forge would successfully replicate. Example: https://gist.github.com/vladjdk/cef7503d2dfe4c44eb3dbb1183947ec8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, since need specify nonce from same sender to avoid out of order in priority mempool, I could try sender nonce mempool later.

Copy link
Contributor

Choose a reason for hiding this comment

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

PriorityNonceMempool don't handle out of order nonce, it only handles priority.

Copy link
Member

@vladjdk vladjdk Jul 15, 2025

Choose a reason for hiding this comment

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

@yihuang based on the ADR it should order by nonce:

The follow rules are strictly observed while iterating the mempool to select transactions:

  1. For a given sender their txs must be selected in nonce order.
  2. A transaction with a higher priority is always selected before a transaction with a lower priority except when to do so would violate sender-nonce order.

Based on a quick look of the code, it looks like it orders by sender and nonce as a secondary key:
https://github.com/cosmos/cosmos-sdk/blob/main/types/mempool/priority_nonce.go#L241-L276.

@mmsqe sounds good. Priority nonce, however, should function the same as a sender nonce with an added priority dimension.

Copy link
Contributor

@yihuang yihuang Jul 15, 2025

Choose a reason for hiding this comment

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

@vladjdk

the problem is check-tx state, if the txs comes in the order of nonces, the check-tx logic can run on the same check-tx state. but if out of order, the check-tx logic will fail and they won't get into mempool in the first place.

@Vvaradinov
Copy link

Vvaradinov commented Jul 8, 2025

For the purpose we are using PriorityNonceMempool the signer extraction part works fine with the changes from this PR. I do still see the same issues as @vladjdk mentioned but it would be good to have this as interim supported since we are using this mempool over no-op and would prefer it to keep Babylon specific transactions prioritized over anything else.

Copy link
Member

@vladjdk vladjdk left a comment

Choose a reason for hiding this comment

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

Few more comments to resolve.

@aljo242
Copy link
Contributor

aljo242 commented Jul 21, 2025

@vladjdk to revist

Copy link
Member

@vladjdk vladjdk left a comment

Choose a reason for hiding this comment

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

Lgtm. thanks!

@vladjdk
Copy link
Member

vladjdk commented Jul 24, 2025

Will merge when you fix the lints, tests and fix the merge conflict.

@mmsqe mmsqe requested a review from a team as a code owner July 25, 2025 01:34
@mmsqe mmsqe requested a review from a team as a code owner July 25, 2025 01:34
@vladjdk vladjdk added this pull request to the merge queue Jul 25, 2025
Merged via the queue into cosmos:main with commit 2934281 Jul 25, 2025
17 of 19 checks passed
@skosito
Copy link

skosito commented Jul 28, 2025

@mmsqe sorry for ping, i am curious is this issue that I opened in cosmos-sdk valid? cosmos/cosmos-sdk#24848

it seemed once i checked that this extractor is not used in proposal handler, so my question is does priority nonce mempool work like this?

EDIT: it seems like it is fixed here https://github.com/cosmos/cosmos-sdk/pull/25012/files

Vvaradinov added a commit to babylonlabs-io/babylon that referenced this pull request Aug 21, 2025
…e priority nonce mempool (#1430)

This PR updates the evm to the latest commit hash that included the
priority nonce mempool cosmos/evm#245. This adds
the mandatory signer extractor to the mempool configuration.

Additional changes in our testnet command, cosmos evm version and other
configurations are needed.
mergify bot pushed a commit to babylonlabs-io/babylon that referenced this pull request Aug 21, 2025
…e priority nonce mempool (#1430)

This PR updates the evm to the latest commit hash that included the
priority nonce mempool cosmos/evm#245. This adds
the mandatory signer extractor to the mempool configuration.

Additional changes in our testnet command, cosmos evm version and other
configurations are needed.

(cherry picked from commit dac5bad)
Vvaradinov added a commit to babylonlabs-io/babylon that referenced this pull request Aug 21, 2025
…e priority nonce mempool (backport #1430) (#1575)

This PR updates the evm to the latest commit hash that included the
priority nonce mempool cosmos/evm#245. This adds
the mandatory signer extractor to the mempool configuration.

Additional changes in our testnet command, cosmos evm version and other
configurations are needed. <hr>This is an automatic backport of pull
request #1430 done by [Mergify](https://mergify.com).

Co-authored-by: Vladislav Varadinov <[email protected]>
zsystm pushed a commit to zsystm/evm that referenced this pull request Nov 2, 2025
…ners error in tx execution (cosmos#245)

* Problem: diff mempool max-txs trigger apphash mismatch

add test

* upstream repeated tx sender recovery is wastful cosmos#227

* sender address verification is not decoupled from execution cosmos#358

* fix main lint

* Apply suggestions from code review

* Problem: EVMChainID is not aligned in tests

* lint

* fix test

* align cfg

* eth signer not accurate in state machine cosmos#470

* keep deprecated

* Update config.go

---------

Co-authored-by: Alex | Interchain Labs <[email protected]>
Co-authored-by: Vlad J <[email protected]>
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.

PriorityNonceMempool missing Ethereum signature signer extractor.

6 participants