feat(gas): add and use ArbitrumGas policy#476
Conversation
ArbitrumGas policy
19ae370 to
22ef845
Compare
bd80dee to
4579c5d
Compare
48a33a7 to
0f444e9
Compare
38807bb to
8be2b05
Compare
d96266a to
a2d3ca0
Compare
8be2b05 to
0c37b87
Compare
ae3f133 to
2ff236f
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new ArbitrumGasPolicy that implements multidimensional gas tracking for Arbitrum, replacing the use of EthereumGasPolicy throughout the Arbitrum codebase. The implementation adds a MultiGas structure to track gas consumption across different resource kinds (Computation, HistoryGrowth, StorageAccess, StorageGrowth, L1Calldata, L2Calldata, WasmComputation) while maintaining backward compatibility by embedding EthereumGasPolicy for single-dimensional gas tracking.
Key changes:
- Introduces
MultiGasstruct with saturating arithmetic for tracking gas across 8 resource dimensions - Implements
ArbitrumGasPolicythat wrapsEthereumGasPolicyand adds multidimensional gas breakdown - Updates all gas-related operations throughout the Arbitrum codebase to use the new policy
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/Nethermind.Arbitrum/Evm/MultiGas.cs |
New file implementing inline array-based multidimensional gas tracking with overflow protection |
src/Nethermind.Arbitrum/Evm/ArbitrumGasPolicy.cs |
New file implementing the Arbitrum-specific gas policy with resource kind categorization |
src/Nethermind.Arbitrum/Evm/ArbitrumVirtualMachine.cs |
Updated to use ArbitrumGasPolicy instead of EthereumGasPolicy throughout VM execution |
src/Nethermind.Arbitrum/Execution/ArbitrumTransactionProcessor.cs |
Updated transaction processor to use ArbitrumGasPolicy for gas calculations and refunds |
src/Nethermind.Arbitrum/Precompiles/OwnerLogic.cs |
Updated precompile owner logic to use ArbitrumGasPolicy in event emission |
src/Nethermind.Arbitrum/Evm/ArbitrumEvmInstructions.Environment.cs |
Updated EVM instructions to use ArbitrumGasPolicy and optimized TxTracer access |
src/Nethermind.Arbitrum/Arbos/Programs/WasmGas.cs |
Updated WASM gas calculations to use ArbitrumGasPolicy |
src/Nethermind.Arbitrum/Arbos/Programs/StylusPrograms.cs |
Updated Stylus program execution to use ArbitrumGasPolicy |
src/Nethermind.Arbitrum/Arbos/Programs/IStylusVmHost.cs |
Updated interface to require VmState<ArbitrumGasPolicy> |
src/Nethermind.Arbitrum/ArbitrumPlugin.cs |
Updated DI registration to use generic IVirtualMachine<ArbitrumGasPolicy> and renamed gas limit calculator |
src/Nethermind.Arbitrum.Test/Infrastructure/ArbitrumTestBlockchainBase.cs |
Updated test infrastructure to use renamed gas limit calculator |
src/Nethermind.Arbitrum.Test/Execution/ArbitrumTransactionProcessorTests.cs |
Updated DI registrations to use IVirtualMachine<ArbitrumGasPolicy> |
src/Nethermind.Arbitrum.Test/Evm/MultiGasTests.cs |
New comprehensive test suite for MultiGas functionality including overflow handling |
src/Nethermind.Arbitrum.Test/Evm/ArbitrumGasTests.cs |
New comprehensive test suite for ArbitrumGasPolicy resource categorization |
src/Nethermind.Arbitrum.Test/Arbos/Stylus/Infrastructure/TestStylusVmHost.cs |
Updated test host to use ArbitrumGasPolicy |
src/Nethermind.Arbitrum.Test/Arbos/Programs/StylusProgramsTests.cs |
Updated all test cases to use ArbitrumGasPolicy |
Comments suppressed due to low confidence (1)
src/Nethermind.Arbitrum/Execution/ArbitrumTransactionProcessor.cs:184
- Default 'ToString()': ArbitrumGasPolicy inherits 'ToString()' from 'Object', and so is not suitable for printing.
Logger.Trace("Refunding unused gas of " + unspentGas + " and refund of " + actualRefund);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2ff236f to
455062f
Compare
wurdum
left a comment
There was a problem hiding this comment.
Really like how it looks. Well done!
|
@AnkushinDaniil Very smooth implementation btw, great work! |
455062f to
73de8e1
Compare
73de8e1 to
58a954a
Compare
666ff4b to
dea3491
Compare
dea3491 to
a7beb32
Compare
a7beb32 to
0254c7f
Compare
0254c7f to
09fee70
Compare
Depends on
ConsumeCodeCopyGasmethod nethermind#10068