Skip to content

Comments

add reorg, sequence delayed messages functionality#131

Closed
tanishqjasoria wants to merge 39 commits intomainfrom
tanishq/feat/reorg-new
Closed

add reorg, sequence delayed messages functionality#131
tanishqjasoria wants to merge 39 commits intomainfrom
tanishq/feat/reorg-new

Conversation

@tanishqjasoria
Copy link

No description provided.

@tanishqjasoria tanishqjasoria marked this pull request as ready for review August 11, 2025 05:44
Copilot AI review requested due to automatic review settings August 11, 2025 05:44
Copy link

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

This PR adds reorg and sequence delayed message functionality to the Arbitrum module, enabling blockchain reorganization and processing of delayed messages from L1.

Key changes:

  • Adds reorg functionality to handle blockchain reorganizations with message reprocessing
  • Implements sequence delayed message processing for L1-originated delayed messages
  • Introduces message parsing utilities for round-trip transaction encoding/decoding

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Nethermind.Arbitrum/Modules/IArbitrumRpcModule.cs Adds interface definitions for Reorg and SequenceDelayedMessage RPC methods
src/Nethermind.Arbitrum/Modules/ArbitrumRpcModule.cs Implements reorg and delayed message sequencing with event handling and message reprocessing
src/Nethermind.Arbitrum/Exceptions/ArbitrumBlockProductionException.cs New exception class for block production errors with error codes
src/Nethermind.Arbitrum/Data/Transactions/NitroL2MessageParser.cs Adds transaction-to-message parsing for round-trip message construction
src/Nethermind.Arbitrum/Data/DigestMessageParameters.cs Defines parameter classes for reorg and delayed message operations
src/Nethermind.Arbitrum.Test/Rpc/SequenceDelayedMessagesTests.cs Test suite for delayed message sequencing functionality
src/Nethermind.Arbitrum.Test/Rpc/DigestMessage/NitroL2MessageParserTests.cs Tests for round-trip message parsing functionality
src/Nethermind.Arbitrum.Test/Rpc/ArbitrumFullSimulationRunTests.cs Removes TODO comment from existing test

tanishqjasoria and others added 2 commits August 11, 2025 11:24
…ption.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@AnkushinDaniil AnkushinDaniil left a comment

Choose a reason for hiding this comment

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

There is some commented code that can possibly be removed.
Good job!

(ulong)_decoder.GetLength(tx, RlpBehaviors.SkipTypedWrapping) + 1);
stream.Write(sizeBuf);
stream.WriteByte((byte)ArbitrumL2MessageKind.SignedTx);
_decoder.Encode(stream, tx, RlpBehaviors.SkipTypedWrapping);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that it doesn't filter failed transactions as Nitro does

Copy link
Author

Choose a reason for hiding this comment

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

yes, we dont have hooks implemented yet
was planning to discuss this today

private static readonly TxDecoder _decoder;
static NitroL2MessageParser()
{
TxDecoder decoder = TxDecoder.Instance;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use a safer private, isolated decoder?

Copy link
Author

Choose a reason for hiding this comment

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

that needed a change in nethermind and that is why i did it this way.

Copy link
Author

Choose a reason for hiding this comment

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

will change it

@codecov
Copy link

codecov bot commented Aug 12, 2025

Codecov Report

❌ Patch coverage is 49.51923% with 105 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.72%. Comparing base (1b15f82) to head (e326f74).

Files with missing lines Patch % Lines
...c/Nethermind.Arbitrum/Modules/ArbitrumRpcModule.cs 42.23% 93 Missing ⚠️
...ethermind.Arbitrum/Data/DigestMessageParameters.cs 28.57% 10 Missing ⚠️
...rum/Exceptions/ArbitrumBlockProductionException.cs 0.00% 2 Missing ⚠️

❌ Your patch check has failed because the patch coverage (49.51%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #131      +/-   ##
==========================================
- Coverage   83.93%   83.72%   -0.22%     
==========================================
  Files          89       90       +1     
  Lines        5123     5314     +191     
  Branches      726      762      +36     
==========================================
+ Hits         4300     4449     +149     
- Misses        823      865      +42     
Flag Coverage Δ
unittests 83.72% <49.51%> (-0.22%) ⬇️
Files with missing lines Coverage Δ
...Arbitrum/Data/Transactions/NitroL2MessageParser.cs 80.20% <100.00%> (+5.88%) ⬆️
...rum/Exceptions/ArbitrumBlockProductionException.cs 0.00% <0.00%> (ø)
...ethermind.Arbitrum/Data/DigestMessageParameters.cs 72.50% <28.57%> (-23.66%) ⬇️
...c/Nethermind.Arbitrum/Modules/ArbitrumRpcModule.cs 63.88% <42.23%> (-25.70%) ⬇️

... and 7 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1b15f82...e326f74. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
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.

From PR description it's not clear whether it's finished PR and what is ommitted here. Lack of tests for reorg, unused vars and lots of todos hints there are more work to finish, but it's not communicated.

Also, we need to refactor ArbitrumRpcModule to remove blockchain logic from it. It should be responsible only for RPC transport specific concerns. Let's introduce something like ArbitrumBlockchain, ArbitrumFacade, ArbitrumApi, etc. and move block production, reorg, etc. logic there. That could be a separate PR.

/// <summary>
/// Notifies that a resequencing (reorg) operation is about to start.
/// </summary>
public event EventHandler<ResequenceOperationNotifier>? ResequenceOperationStarting;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of this event? Is it being used?

ResultWrapper<MessageResult> msgResult;
try
{
Block? block = await ProduceBlockWhileLockedAsync(parameters.Message, headBlockHeader.Number + 1, headBlockHeader);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make ProduceBlockWhileLockedAsync return ResultWrapper to avoid magic exceptions?

}

[Test]
public static void Parse_RoundTrip_EthLegacy_ParsesCorrectly()
Copy link
Contributor

Choose a reason for hiding this comment

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

Test name doesn't follow the convention.

}

[Test]
public static void Parse_RoundTrip_DynamicFeeTx_ParsesCorrectly()
Copy link
Contributor

Choose a reason for hiding this comment

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

Test name doesn't follow the convention.

}

[Test]
public static void Parse_RoundTrip_EthLegacyAndDynamicFeeTx_ParsesCorrectly()
Copy link
Contributor

Choose a reason for hiding this comment

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

Test name doesn't follow the convention.

@tanishqjasoria tanishqjasoria marked this pull request as draft August 14, 2025 09:20
@tanishqjasoria
Copy link
Author

replaced by #172

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