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

imp(ante): MonoAnteHandler for EVM transactions #2028

Merged
merged 31 commits into from
Nov 27, 2023

Conversation

fedekunze
Copy link
Contributor

Description


Closes #XXX

app/ante/evm/mono.go Fixed Show fixed Hide fixed
return ctx, errorsmod.Wrapf(errortypes.ErrUnknownRequest, "invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil))
}

txIdx := uint64(i) // nosec: G701

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion Error

Potential integer overflow by integer type conversion
Copy link

codecov bot commented Nov 10, 2023

Codecov Report

Merging #2028 (0b57976) into main (84ca6b3) will decrease coverage by 0.25%.
The diff coverage is 67.14%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2028      +/-   ##
==========================================
- Coverage   70.42%   70.17%   -0.25%     
==========================================
  Files         344      353       +9     
  Lines       25655    25948     +293     
==========================================
+ Hits        18067    18210     +143     
- Misses       6654     6792     +138     
- Partials      934      946      +12     
Files Coverage Δ
app/ante/cosmos.go 100.00% <100.00%> (ø)
app/ante/evm/01_setup_ctx.go 100.00% <100.00%> (ø)
app/ante/evm/03_global_fee.go 100.00% <100.00%> (ø)
app/ante/evm/05_signature_verification.go 100.00% <100.00%> (ø)
app/ante/evm/06_account_verification.go 100.00% <100.00%> (ø)
app/ante/evm/fee_checker.go 100.00% <100.00%> (ø)
app/ante/handler_options.go 91.42% <ø> (+37.14%) ⬆️
app/ante/ante.go 40.62% <0.00%> (ø)
app/ante/evm/10_increment_sequence.go 92.10% <92.10%> (ø)
app/ante/evm/08_vesting.go 89.02% <83.33%> (ø)
... and 9 more

app/ante/evm/mono.go Fixed Show fixed Hide fixed
}

// 12. emit events
txIdx := uint64(i) // nosec: G701

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion Error

Potential integer overflow by integer type conversion
@facs95
Copy link
Contributor

facs95 commented Nov 22, 2023

Added benchmarking tests to the PR which could also be done through another PR but the results where very good actually.

The relvant results to look at are the ones for EVM which are the ones impacted by this PR. Its a 15% increase in time/operation and ~30% increase on memory allocation efficiency with the current changes.

To tests locally run:
go test -v ./app/ante -bench=AnteHandler -benchtime=1000x -run='^$' -benchmem -count 10

goos: darwin
goarch: arm64
pkg: github.com/evmos/evmos/v15/app/ante
                                         │ /tmp/old.txt │            /tmp/new.txt             │
                                         │    sec/op    │   sec/op     vs base                │
AnteHandler/tx_type_evm_transfer_sim-12    176.5µ ±  3%   158.9µ ± 3%   -9.95% (p=0.000 n=10)
AnteHandler/tx_type_evm_transfer-12        180.8µ ±  2%   160.9µ ± 4%  -11.01% (p=0.000 n=10)
AnteHandler/tx_type_bank_msg_send_sim-12   63.85µ ± 10%   62.96µ ± 8%        ~ (p=0.353 n=10)
AnteHandler/tx_type_bank_msg_send-12       121.0µ ±  3%   120.2µ ± 2%        ~ (p=0.280 n=10)
geomean                                    125.3µ         117.9µ        -5.88%

                                         │ /tmp/old.txt │             /tmp/new.txt             │
                                         │     B/op     │     B/op      vs base                │
AnteHandler/tx_type_evm_transfer_sim-12    60.67Ki ± 2%   47.17Ki ± 3%  -22.25% (p=0.000 n=10)
AnteHandler/tx_type_evm_transfer-12        60.64Ki ± 2%   47.13Ki ± 3%  -22.28% (p=0.000 n=10)
AnteHandler/tx_type_bank_msg_send_sim-12   20.67Ki ± 8%   20.65Ki ± 8%        ~ (p=0.796 n=10)
AnteHandler/tx_type_bank_msg_send-12       27.67Ki ± 5%   27.55Ki ± 5%        ~ (p=0.971 n=10)
geomean                                    38.09Ki        33.54Ki       -11.94%

                                         │ /tmp/old.txt │            /tmp/new.txt            │
                                         │  allocs/op   │ allocs/op   vs base                │
AnteHandler/tx_type_evm_transfer_sim-12     1345.0 ± 0%   993.0 ± 0%  -26.17% (p=0.000 n=10)
AnteHandler/tx_type_evm_transfer-12         1345.0 ± 0%   993.0 ± 0%  -26.17% (p=0.000 n=10)
AnteHandler/tx_type_bank_msg_send_sim-12     460.0 ± 0%   460.0 ± 0%        ~ (p=1.000 n=10)
AnteHandler/tx_type_bank_msg_send-12         595.0 ± 0%   594.5 ± 0%        ~ (p=0.650 n=10)
geomean                                      838.8        720.6       -14.09%

@facs95 facs95 marked this pull request as ready for review November 22, 2023 14:23
@facs95 facs95 requested a review from a team as a code owner November 22, 2023 14:23
@facs95 facs95 requested review from facs95 and 0xstepit and removed request for a team November 22, 2023 14:23
@facs95 facs95 marked this pull request as draft November 22, 2023 14:25
@facs95
Copy link
Contributor

facs95 commented Nov 22, 2023

Some tests are failing when using the mono ante handler.. still not ready for review. Will try to fix those early tomorrow

@facs95 facs95 marked this pull request as ready for review November 23, 2023 15:36
app/ante/evm.go Outdated Show resolved Hide resolved
app/ante/evm/04_validate.go Outdated Show resolved Hide resolved
@fedekunze fedekunze merged commit 8a46ed8 into main Nov 27, 2023
32 of 36 checks passed
@fedekunze fedekunze deleted the fedekunze/mono-antehandler branch November 27, 2023 10:11
Copy link
Contributor

@Vvaradinov Vvaradinov left a comment

Choose a reason for hiding this comment

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

Didn't get to fully review before it was merged but LGTM only a few nits.

@@ -27,7 +26,7 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
switch typeURL := opts[0].GetTypeUrl(); typeURL {
case "/ethermint.evm.v1.ExtensionOptionsEthereumTx":
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: define these strings as constants on top of the file?

return next(ctx, tx, simulate)
}

// For dynamic transactions, GetFee() uses the GasFeeCap value, which
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// For dynamic transactions, GetFee() uses the GasFeeCap value, which
// CheckGlobalFee - For dynamic transactions, GetFee() uses the GasFeeCap value, which

return gasWanted, minPriority, nil
}

// deductFee checks if the fee payer has enough funds to pay for the fees and deducts them.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// deductFee checks if the fee payer has enough funds to pay for the fees and deducts them.
// DeductFee checks if the fee payer has enough funds to pay for the fees and deducts them.

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.

None yet

3 participants