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

Problem: slow VerifyEthSig on large number of messages #518

Closed
wants to merge 1 commit into from

Conversation

mmsqe
Copy link
Collaborator

@mmsqe mmsqe commented Aug 27, 2024

Closes: #XXX

Description


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

Comment on lines +35 to +47
go func(msg proto.Message) {
msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)
if !ok {
errChan <- errorsmod.Wrapf(errortypes.ErrUnknownRequest, "invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil))
return
}

if err := msgEthTx.VerifySender(signer); err != nil {
return errorsmod.Wrapf(errortypes.ErrorInvalidSigner, "signature verification failed: %s", err.Error())
err := msgEthTx.VerifySender(signer)
if err != nil {
err = errorsmod.Wrapf(errortypes.ErrorInvalidSigner, "signature verification failed: %s", err.Error())
}
errChan <- err
}(msg)

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
Copy link

codecov bot commented Aug 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.60%. Comparing base (fe3f4fd) to head (cc65ddb).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #518      +/-   ##
===========================================
+ Coverage    61.57%   61.60%   +0.03%     
===========================================
  Files          128      128              
  Lines         9512     9520       +8     
===========================================
+ Hits          5857     5865       +8     
  Misses        3115     3115              
  Partials       540      540              
Files with missing lines Coverage Δ
app/ante/sigverify.go 100.00% <100.00%> (ø)

@@ -29,16 +30,26 @@ import (
// Failure in RecheckTx will prevent tx to be included into block, especially when CheckTx succeed, in which case user
// won't see the error message.
func VerifyEthSig(tx sdk.Tx, signer ethtypes.Signer) error {
errChan := make(chan error, len(tx.GetMsgs()))
for _, msg := range tx.GetMsgs() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yihuang could reduce from 2s to 0.2s for 3k msgs when parallel

Copy link
Collaborator

Choose a reason for hiding this comment

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

Only for large batch tx?

Copy link
Collaborator

@yihuang yihuang Aug 27, 2024

Choose a reason for hiding this comment

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

Can you do this conditionally, so we can avoid extra overhead for normal cases where tx has single msg.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should be same for small batch, but I only filter out when CheckTx > 1s

Copy link
Collaborator

@yihuang yihuang Aug 27, 2024

Choose a reason for hiding this comment

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

I mean at least for tx that has a single msg, this change is pure overhead, no benifit.

@@ -29,16 +30,26 @@ import (
// Failure in RecheckTx will prevent tx to be included into block, especially when CheckTx succeed, in which case user
// won't see the error message.
func VerifyEthSig(tx sdk.Tx, signer ethtypes.Signer) error {
errChan := make(chan error, len(tx.GetMsgs()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

use errgroup?

@mmsqe mmsqe closed this Sep 4, 2024
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.

2 participants