Skip to content

feat(gas): add and use ArbitrumGas policy#476

Merged
AnkushinDaniil merged 1 commit into
mainfrom
daniil/feature/arbitrum-gas
Jan 5, 2026
Merged

feat(gas): add and use ArbitrumGas policy#476
AnkushinDaniil merged 1 commit into
mainfrom
daniil/feature/arbitrum-gas

Conversation

@AnkushinDaniil

@AnkushinDaniil AnkushinDaniil commented Dec 17, 2025

Copy link
Copy Markdown
Collaborator

@AnkushinDaniil AnkushinDaniil changed the title use arbitrum gas feat(gas): add and use ArbitrumGas policy Dec 17, 2025
@AnkushinDaniil AnkushinDaniil marked this pull request as ready for review December 17, 2025 14:00
@AnkushinDaniil AnkushinDaniil force-pushed the daniil/feature/arbitrum-gas branch from 19ae370 to 22ef845 Compare December 18, 2025 10:55
@AnkushinDaniil AnkushinDaniil force-pushed the daniil/feature/arbitrum-gas branch from 48a33a7 to 0f444e9 Compare December 18, 2025 15:49
@AnkushinDaniil AnkushinDaniil force-pushed the daniil/feature/arbitrum-gas branch from d96266a to a2d3ca0 Compare December 19, 2025 06:54
Base automatically changed from daniil/feat/gas-policy to main December 19, 2025 15:24
Copilot AI review requested due to automatic review settings December 19, 2025 15:33
@AnkushinDaniil AnkushinDaniil force-pushed the daniil/feature/arbitrum-gas branch from ae3f133 to 2ff236f Compare December 19, 2025 15:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 MultiGas struct with saturating arithmetic for tracking gas across 8 resource dimensions
  • Implements ArbitrumGasPolicy that wraps EthereumGasPolicy and 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.

@AnkushinDaniil AnkushinDaniil force-pushed the daniil/feature/arbitrum-gas branch from 2ff236f to 455062f Compare December 22, 2025 08:56

@wurdum wurdum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Really like how it looks. Well done!

Comment thread src/Nethermind.Arbitrum/Evm/MultiGas.cs Outdated
Comment thread src/Nethermind.Arbitrum.Test/Evm/ArbitrumGasTests.cs Outdated
Comment thread src/Nethermind.Arbitrum.Test/Evm/ArbitrumGasTests.cs
Comment thread src/Nethermind.Arbitrum/Evm/MultiGas.cs Outdated
Comment thread src/Nethermind.Arbitrum/Evm/MultiGas.cs Outdated
Comment thread src/Nethermind.Arbitrum/Evm/ArbitrumGasPolicy.cs Outdated
Comment thread src/Nethermind.Arbitrum/Evm/ArbitrumGasPolicy.cs Outdated
Comment thread src/Nethermind.Arbitrum/Evm/MultiGas.cs Outdated
@svlachakis

Copy link
Copy Markdown
Collaborator

@AnkushinDaniil Very smooth implementation btw, great work!

@AnkushinDaniil AnkushinDaniil force-pushed the daniil/feature/arbitrum-gas branch from 455062f to 73de8e1 Compare December 27, 2025 14:51
@AnkushinDaniil AnkushinDaniil force-pushed the daniil/feature/arbitrum-gas branch from 73de8e1 to 58a954a Compare December 27, 2025 15:41

@svlachakis svlachakis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we need more E2E & Integration tests

Comment thread src/Nethermind.Arbitrum/Evm/ArbitrumGasPolicy.cs Outdated
Comment thread src/Nethermind.Arbitrum/Evm/ArbitrumGasPolicy.cs Outdated
Comment thread src/Nethermind.Arbitrum/Evm/MultiGas.cs
@AnkushinDaniil AnkushinDaniil force-pushed the daniil/feature/arbitrum-gas branch 3 times, most recently from 666ff4b to dea3491 Compare December 30, 2025 13:29
@AnkushinDaniil AnkushinDaniil force-pushed the daniil/feature/arbitrum-gas branch from a7beb32 to 0254c7f Compare January 5, 2026 10:13
@AnkushinDaniil AnkushinDaniil force-pushed the daniil/feature/arbitrum-gas branch from 0254c7f to 09fee70 Compare January 5, 2026 10:36
@AnkushinDaniil AnkushinDaniil enabled auto-merge (squash) January 5, 2026 10:36
@github-actions

github-actions Bot commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Branch Rate Health
Nethermind.Arbitrum 81% 58%
Summary 81% (8485 / 10532) 58% (2086 / 3604)

Minimum allowed line rate is 60%

@AnkushinDaniil AnkushinDaniil merged commit f5b6b26 into main Jan 5, 2026
5 checks passed
@AnkushinDaniil AnkushinDaniil deleted the daniil/feature/arbitrum-gas branch January 5, 2026 10:42
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.

5 participants