-
Notifications
You must be signed in to change notification settings - Fork 193
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
refactor(evm): removed blockGasUsed transient variable #2167
Conversation
Warning Rate limit exceeded@Unique-Divine has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 55 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis pull request introduces significant changes to the Nibiru EVM project's gas management and transaction processing. The primary modification involves removing the transient Changes
Sequence DiagramsequenceDiagram
participant Client
participant EVMKeeper
participant GasMeter
participant Transaction
Client->>EVMKeeper: Execute Transaction
EVMKeeper->>Transaction: Process Transaction
Transaction->>GasMeter: Consume Gas Directly
GasMeter-->>Transaction: Gas Consumption Tracked
Transaction-->>EVMKeeper: Transaction Result
EVMKeeper-->>Client: Transaction Response
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
CHANGELOG.md (1)
80-80
: Consider adding more context about gas tracking simplification.While the entry is clear, consider expanding it to mention the impact on gas tracking logic as noted in the AI summary. This would provide better context for the change.
-refactor(evm): removed blockGasUsed transient variable +refactor(evm): removed blockGasUsed transient variable to simplify gas tracking logiceth/rpc/backend/backend_suite_test.go (1)
246-250
: LGTM! Consider adding parameter validation.The parameterization of gas limits and parameter reordering improves both flexibility and readability. Consider adding validation to ensure
gasLimit
is not zero.func (s *BackendSuite) buildContractCallTx( contractAddr gethcommon.Address, nonce uint64, gasLimit uint64, ) gethcore.Transaction { + if gasLimit == 0 { + s.T().Fatal("gas limit cannot be zero") + } // recipient := crypto.CreateAddress(s.fundedAccEthAddr, 29381) transferAmount := big.NewInt(100)Also applies to: 264-264
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (19)
CHANGELOG.md
(1 hunks)app/evmante/evmante_setup_ctx.go
(0 hunks)app/evmante/evmante_setup_ctx_test.go
(0 hunks)eth/indexer/evm_tx_indexer_test.go
(2 hunks)eth/rpc/backend/backend_suite_test.go
(3 hunks)eth/rpc/backend/gas_used_test.go
(1 hunks)eth/rpc/backend/nonce_test.go
(1 hunks)eth/rpc/events_parser.go
(1 hunks)x/evm/evmtest/test_deps.go
(0 hunks)x/evm/keeper/evm_state.go
(0 hunks)x/evm/keeper/funtoken_from_coin.go
(1 hunks)x/evm/keeper/funtoken_from_coin_test.go
(0 hunks)x/evm/keeper/funtoken_from_erc20_test.go
(0 hunks)x/evm/keeper/gas_fees.go
(0 hunks)x/evm/keeper/keeper.go
(0 hunks)x/evm/keeper/msg_server.go
(2 hunks)x/evm/precompile/funtoken_test.go
(0 hunks)x/evm/precompile/test/export.go
(0 hunks)x/evm/precompile/wasm_test.go
(0 hunks)
💤 Files with no reviewable changes (11)
- app/evmante/evmante_setup_ctx.go
- app/evmante/evmante_setup_ctx_test.go
- x/evm/precompile/test/export.go
- x/evm/keeper/evm_state.go
- x/evm/keeper/keeper.go
- x/evm/keeper/gas_fees.go
- x/evm/evmtest/test_deps.go
- x/evm/precompile/wasm_test.go
- x/evm/precompile/funtoken_test.go
- x/evm/keeper/funtoken_from_erc20_test.go
- x/evm/keeper/funtoken_from_coin_test.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: integration-tests
🔇 Additional comments (12)
eth/indexer/evm_tx_indexer_test.go (2)
4-4
: LGTM: Import addition is necessary.The fmt package import is required for formatting the eth_hash attribute value.
113-113
: LGTM: Enhanced event attribute verification.The addition of the eth_hash attribute in the test case improves verification of transaction hash handling in Ethereum events, ensuring consistency between pending_ethereum_tx and EventEthereumTx events.
x/evm/keeper/msg_server.go (2)
83-83
: LGTM! Gas consumption is now more direct and accurate.The change simplifies gas tracking by directly consuming the actual gas used from the EVM response, removing the need for intermediate calculations.
564-564
: LGTM! Consistent gas consumption pattern for ERC20 minting.The change maintains consistency with the simplified gas tracking approach, directly consuming the actual gas used from the EVM response.
CHANGELOG.md (2)
80-80
: LGTM! The changelog entry accurately reflects the PR objectives.The entry "refactor(evm): removed blockGasUsed transient variable" clearly and concisely describes the change, following the conventional commit format with type(scope): description.
Line range hint
1-24
: LGTM! The changelog follows best practices.The changelog is well-structured following the Keep a Changelog format with:
- Clear version headers and links
- Proper categorization of changes
- PR references
- Semantic versioning
x/evm/keeper/funtoken_from_coin.go (2)
87-87
: LGTM! Gas consumption is now handled more directly.The simplified gas consumption logic aligns well with the PR objective of removing the
blockGasUsed
variable while maintaining proper gas tracking.
87-87
: Verify gas consumption behavior with multiple messages.Since this PR aims to improve handling of multiple Ethereum messages within a single transaction, let's verify that the gas consumption is correctly tracked in such scenarios.
✅ Verification successful
Gas consumption behavior is properly implemented for multiple messages
The gas consumption implementation correctly tracks and accumulates gas usage across multiple Ethereum messages within a single transaction. This is verified by:
- Individual gas consumption tracking for each operation (deploy, mint, execute)
- Proper gas metering implementation in the msg_server
- Comprehensive test coverage in
gas_used_test.go
that verifies correct gas accounting across multiple messages🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for test cases that verify gas consumption with multiple messages # and check if the gas consumption is properly tracked. # Look for test files containing multiple message tests echo "Searching for relevant test files..." rg -l "multiple|message.*transaction|gas.*consumption" --type go # Look for specific gas consumption patterns in EVM calls echo "Checking gas consumption patterns..." ast-grep --pattern 'CallContractWithInput($$$)' # Look for gas meter usage patterns echo "Checking gas meter usage..." rg -A 2 "GasMeter\(\).ConsumeGas"Length of output: 1955
Script:
#!/bin/bash # Search for test cases specifically handling multiple messages and gas tracking echo "Searching test files for multiple message scenarios..." rg -B 2 -A 5 "TestMultiple|TestGas.*Message" --type go echo "Checking msg_server implementation for gas tracking..." rg -B 2 -A 5 "func \(k Keeper\) (Eth|MsgEth).*Message" x/evm/keeper/msg_server.go echo "Looking for gas tracking in tests..." rg -B 2 -A 5 "GasMeter.*Assert" --type goLength of output: 1535
Script:
#!/bin/bash # Examine the multiple message gas usage test implementation echo "Checking multiple messages gas usage test implementation..." rg -B 10 -A 20 "TestMultipleMsgsTxGasUsage" eth/rpc/backend/gas_used_test.go # Look for related gas tracking utilities echo "Checking gas tracking utilities..." rg -l "GasUsed.*multiple|gas.*tracking" --type goLength of output: 1505
eth/rpc/events_parser.go (1)
89-92
: Robust replacement of pending transactions using transaction hashThe updated logic replaces pending transactions by matching the transaction hash (
EthHash
), which is more reliable than relying solely on the message index (MsgIndex
). This change enhances the robustness of the transaction parsing process and ensures accurate transaction mapping.eth/rpc/backend/nonce_test.go (1)
23-25
:⚠️ Potential issueVerify function parameter alignment for
buildContractCallTx
The
buildContractCallTx
function's signature has been updated to include an additional parameter. Ensure that the argument100_000
corresponds to the correct parameter in the updated function signature. There might be a mismatch between the expectedgasLimit
oramount
parameter and the provided arguments.eth/rpc/backend/gas_used_test.go (1)
191-234
: Comprehensive test for gas usage with multiple messagesThe
TestMultipleMsgsTxGasUsage
function is a valuable addition that effectively verifies gas consumption for each message within a single transaction. The test correctly asserts that the gas used is within expected limits and that the account balance reflects the total gas consumed. The implementation follows best practices and enhances test coverage.eth/rpc/backend/backend_suite_test.go (1)
226-226
: LGTM! Good improvement in test flexibility.The parameterization of gas limits allows for more comprehensive testing of different gas usage scenarios, which aligns well with the PR's goal of improving gas usage tracking.
Also applies to: 234-234
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2167 +/- ##
==========================================
- Coverage 65.14% 65.13% -0.02%
==========================================
Files 277 277
Lines 22284 22238 -46
==========================================
- Hits 14518 14485 -33
+ Misses 6771 6762 -9
+ Partials 995 991 -4
|
EvmKeeper.EvmState.BlockGasUsed
variableSummary by CodeRabbit
Based on the comprehensive summary, here are the updated release notes:
New Features
Bug Fixes
Refactoring
Testing
The changes focus on optimizing the EVM's gas management and transaction processing infrastructure, with an emphasis on more efficient and accurate gas tracking.