Skip to content

feat(execution): expose GasUsed via X-Arb-Gas-Used HTTP header#671

Draft
AnkushinDaniil wants to merge 1 commit intomainfrom
daniil/feature/expose-gas-used-in-message-result
Draft

feat(execution): expose GasUsed via X-Arb-Gas-Used HTTP header#671
AnkushinDaniil wants to merge 1 commit intomainfrom
daniil/feature/expose-gas-used-in-message-result

Conversation

@AnkushinDaniil
Copy link
Copy Markdown
Collaborator

@AnkushinDaniil AnkushinDaniil commented Feb 25, 2026

Add infrastructure to expose block metadata via HTTP response headers for benchmarking between Nitro EL and Nethermind EL.

Related PR:

Related branches and commits:

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a config-gated GasUsed metric to Arbitrum MessageResult responses to support benchmarking/comparison of execution clients by exposing per-block gas consumption.

Changes:

  • Introduces ExposeGasUsedInMessageResult config flag (default false) and wires it into message result construction.
  • Extends MessageResult / MessageResultForRpc with optional GasUsed and updates equality logic.
  • Adds RPC module tests and Makefile targets to run Nethermind with the benchmark flag enabled.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Nethermind.Arbitrum/Execution/ArbitrumExecutionEngine.cs Conditionally populates MessageResult.GasUsed from block/header gas used.
src/Nethermind.Arbitrum/Data/MessageResultForRpc.cs Adds gasUsed field for RPC (external block fetch DTO) and maps into MessageResult.
src/Nethermind.Arbitrum/Data/MessageResult.cs Adds nullable GasUsed to MessageResult and includes it in Equals.
src/Nethermind.Arbitrum/Config/IArbitrumConfig.cs Adds ExposeGasUsedInMessageResult config item.
src/Nethermind.Arbitrum/Config/ArbitrumConfig.cs Implements the new config property with default false.
src/Nethermind.Arbitrum.Test/Rpc/ArbitrumRpcModuleTests.DigestMessage.cs Adds tests verifying GasUsed is null/filled depending on config.
Makefile Adds benchmark run targets passing --Arbitrum.ExposeGasUsedInMessageResult=true.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +22 to +23
SendRoot.Equals(other.SendRoot) &&
GasUsed == other.GasUsed;
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

MessageResult.Equals now includes GasUsed, but MessageResult is used for external block comparison in ArbitrumExecutionEngineWithComparison (it calls digestResultData.Equals(rpcResultData)). When ExposeGasUsedInMessageResult is disabled (default), internal results will have GasUsed == null while eth_getBlockByNumber responses typically always include gasUsed, causing false mismatches and triggering shutdown in comparison mode. Consider keeping Equals focused on identity fields (BlockHash/SendRoot) and adding a separate comparison method for GasUsed (or otherwise ensuring comparison mode does not factor GasUsed in unless both sides explicitly opt-in).

Suggested change
SendRoot.Equals(other.SendRoot) &&
GasUsed == other.GasUsed;
SendRoot.Equals(other.SendRoot);
/// <summary>
/// Compares all fields, including <see cref="GasUsed"/>.
/// Intended for benchmarking / testing scenarios where gas usage is relevant.
/// </summary>
public bool EqualsIncludingGasUsed(MessageResult other) =>
Equals(other) && GasUsed == other.GasUsed;

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.73%. Comparing base (71bec8f) to head (e1509dd).

Files with missing lines Patch % Lines
src/Nethermind.Arbitrum/Data/MessageResult.cs 0.00% 3 Missing ⚠️
...rc/Nethermind.Arbitrum/Data/MessageResultForRpc.cs 0.00% 3 Missing ⚠️
...mind.Arbitrum/Execution/ArbitrumExecutionEngine.cs 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #671      +/-   ##
==========================================
- Coverage   76.75%   76.73%   -0.03%     
==========================================
  Files         178      178              
  Lines       11719    11729      +10     
  Branches     1555     1557       +2     
==========================================
+ Hits         8995     9000       +5     
- Misses       2160     2165       +5     
  Partials      564      564              
Files with missing lines Coverage Δ
src/Nethermind.Arbitrum/Config/ArbitrumConfig.cs 70.00% <100.00%> (+3.33%) ⬆️
...mind.Arbitrum/Execution/ArbitrumExecutionEngine.cs 52.08% <77.77%> (+0.49%) ⬆️
src/Nethermind.Arbitrum/Data/MessageResult.cs 0.00% <0.00%> (ø)
...rc/Nethermind.Arbitrum/Data/MessageResultForRpc.cs 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@wurdum wurdum left a comment

Choose a reason for hiding this comment

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

It smells really bad. Can we use metrics instead? Can the caller side query this information through JSON RPC?

@AnkushinDaniil AnkushinDaniil marked this pull request as draft February 26, 2026 09:06
Add infrastructure to expose block metadata via HTTP response headers
  for comparison benchmarking between Nitro EL and Nethermind EL.

  - Add SetMetadataHeaders(BlockHeader) overload for header-only paths
  - Call SetMetadataHeaders in ResultAtMessageIndexAsync
  - Gate header injection behind Arbitrum.ExposeMetadataHeaders config
  - Add benchmark Makefile targets with header exposure enabled
@AnkushinDaniil AnkushinDaniil force-pushed the daniil/feature/expose-gas-used-in-message-result branch from e1509dd to 0719b8e Compare February 26, 2026 13:50
@AnkushinDaniil AnkushinDaniil changed the title feat(arbitrum): add GasUsed field to MessageResult for benchmarking feat(execution): expose GasUsed via X-Arb-Gas-Used HTTP header Feb 26, 2026
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.

3 participants