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

chore: add checktx for AnteDecVerifyEthAcc #2171

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ needed to include double quotes around the hexadecimal string.
- [#2168](https://github.com/NibiruChain/nibiru/pull/2168) - chore(evm-solidity): Move unrelated docs, gen-embeds, and add Solidity docs
- [#2165](https://github.com/NibiruChain/nibiru/pull/2165) - fix(evm): use Singleton StateDB pattern for EVM txs
- [#2169](https://github.com/NibiruChain/nibiru/pull/2169) - fix(evm): Better handling erc20 metadata
- [#2171](https://github.com/NibiruChain/nibiru/pull/2171) - chore: add checktx for AnteDecVerifyEthAcc
- [#2172](https://github.com/NibiruChain/nibiru/pull/2172) - chore: close iterator in IterateEpochInfo

#### Nibiru EVM | Before Audit 2 - 2024-12-06

The codebase went through a third-party [Code4rena
Expand Down
4 changes: 4 additions & 0 deletions app/evmante/evmante_verify_eth_acc.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
simulate bool,
next sdk.AnteHandler,
) (newCtx sdk.Context, err error) {
if !ctx.IsCheckTx() {
return next(ctx, tx, simulate)
}

Check warning on line 45 in app/evmante/evmante_verify_eth_acc.go

View check run for this annotation

Codecov / codecov/patch

app/evmante/evmante_verify_eth_acc.go#L44-L45

Added lines #L44 - L45 were not covered by tests
Comment on lines +43 to +45
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: The CheckTx optimization logic is reversed

The current implementation skips validation during DeliverTx (actual block execution) and performs validation during CheckTx (mempool pre-screening). This is the opposite of the intended optimization and could allow invalid transactions to be processed during block execution.

Apply this diff to correct the logic:

-if !ctx.IsCheckTx() {
+if ctx.IsCheckTx() {
   return next(ctx, tx, simulate)
 }

This correction will:

  1. Skip expensive validation during CheckTx (mempool) as intended
  2. Ensure full validation during DeliverTx (block execution) for security
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if !ctx.IsCheckTx() {
return next(ctx, tx, simulate)
}
if ctx.IsCheckTx() {
return next(ctx, tx, simulate)
}


for i, msg := range tx.GetMsgs() {
msgEthTx, ok := msg.(*evm.MsgEthereumTx)
if !ok {
Expand Down
Loading