Skip to content

feat(rollup-relayer): support Validium #1693

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

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

colinlyguo
Copy link
Member

@colinlyguo colinlyguo commented Jul 7, 2025

Purpose or design rationale of this PR

Support Validium in rollup-relayer.

PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • feat: A new feature

Deployment tag versioning

Has tag in common/version.go been updated or have you added bump-version label to this PR?

  • Yes

Breaking change label

Does this PR have the breaking-change label?

  • No, this PR is not a breaking change

Summary by CodeRabbit

  • New Features

    • Added support for a new "Validium" mode, enabling relayer operation with Validium smart contracts.
    • Introduced configuration option to enable or disable Validium mode.
    • Enhanced batch processing, payload construction, and metrics calculation to support Validium mode.
    • Integrated new ABI for interacting with the Validium contract on ScrollChain.
  • Chores

    • Updated version to v4.5.28.

Copy link

coderabbitai bot commented Jul 7, 2025

"""

Walkthrough

The changes introduce a "validium mode" to the rollup system, affecting batch proposal, relayer logic, configuration, and ABI handling. This includes new ABI definitions for Validium, configuration flags, mode-aware logic in relayer and batch proposer components, and updated utility functions for batch encoding and metadata extraction in validium mode.

Changes

File(s) Change Summary
common/version/version.go Updated version string from "v4.5.27" to "v4.5.28".
rollup/abi/validium_abi.go Added Validium ABI and metadata, with initialization logic for Validium smart contract interaction.
rollup/cmd/rollup_relayer/app/app.go Set ValidiumMode on batch proposer using configuration after creation.
rollup/conf/config.json Added "validium_mode" boolean field to relayer config, defaulting to false.
rollup/internal/config/relayer.go Added ValidiumMode boolean field to RelayerConfig struct.
rollup/internal/controller/relayer/l2_relayer.go Added validium mode support: new ABI field, conditional calldata packing, new payload construction methods.
rollup/internal/controller/watcher/batch_proposer.go Added validiumMode field and setter to BatchProposer; updated batch metric calculations to use mode flag.
rollup/internal/orm/batch.go Passed ValidiumMode to GetBatchMetadata in batch insertion logic.
rollup/internal/utils/utils.go Updated utility functions to accept/use validiumMode; added validium-specific batch header encoding logic.
rollup/internal/controller/watcher/batch_proposer_test.go, bundle_proposer_test.go, proposer_tool.go, tests/rollup_test.go Updated BatchProposer constructor calls in tests and tools to include validiumMode boolean argument.

Sequence Diagram(s)

sequenceDiagram
    participant Config
    participant App
    participant BatchProposer
    participant Relayer
    participant Utils

    Config->>App: Provide ValidiumMode flag
    App->>BatchProposer: SetValidiumMode(ValidiumMode)
    BatchProposer->>Utils: CalculateBatchMetrics(..., validiumMode)
    Relayer->>Utils: GetBatchMetadata(..., validiumMode)
    Relayer->>Relayer: If ValidiumMode, use validium ABI for calldata
    Relayer->>ValidiumABI: Pack calldata for commit/finalize (validium mode)
Loading

Possibly related PRs

  • fix(build): image building #1603: The main PR updates the version tag in common/version/version.go from "v4.5.27" to "v4.5.28", which is similar in nature to the retrieved PR fix(build): image building #1603 that updates the version tag in the same file from "v4.4.88" to "v4.4.89"; both PRs modify only the version string constant without other code changes, indicating a related type of change limited to version bumping.

Suggested labels

bump-version

Suggested reviewers

  • georgehao
  • jonastheis
  • Thegaram

Poem

A toggle for Validium, now in our code,
With ABIs ready and relayers in mode.
Batch headers encoded with hashes anew,
The relayer and proposer both know what to do!
A hop and a skip, our chain’s future is bright—
Version bumped up, and all systems light!
🐇✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a398f64 and 7dfb8b5.

📒 Files selected for processing (2)
  • rollup/cmd/rollup_relayer/app/app.go (2 hunks)
  • rollup/internal/controller/relayer/l2_relayer.go (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • rollup/cmd/rollup_relayer/app/app.go
  • rollup/internal/controller/relayer/l2_relayer.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: tests
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3050ccb and 9297244.

📒 Files selected for processing (9)
  • common/version/version.go (1 hunks)
  • rollup/abi/validium_abi.go (1 hunks)
  • rollup/cmd/rollup_relayer/app/app.go (1 hunks)
  • rollup/conf/config.json (2 hunks)
  • rollup/internal/config/relayer.go (1 hunks)
  • rollup/internal/controller/relayer/l2_relayer.go (9 hunks)
  • rollup/internal/controller/watcher/batch_proposer.go (7 hunks)
  • rollup/internal/orm/batch.go (1 hunks)
  • rollup/internal/utils/utils.go (4 hunks)
🧰 Additional context used
🧠 Learnings (6)
rollup/conf/config.json (1)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1645
File: rollup/proposer-tool-config.json:34-40
Timestamp: 2025-04-15T08:52:44.176Z
Learning: In configuration files like `rollup/proposer-tool-config.json`, placeholders such as `<mainnet read db config>` are intentionally left as-is to be replaced by users with their own configuration values when deploying the tool.
rollup/cmd/rollup_relayer/app/app.go (1)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1530
File: rollup/internal/controller/watcher/batch_proposer.go:291-294
Timestamp: 2024-10-20T16:13:20.397Z
Learning: In `batch_proposer.go`, it's acceptable to call `utils.CalculateBatchMetrics` multiple times within the loop because the batch's chunks are increasing in the loop, and each calculation reflects the updated batch state.
rollup/internal/controller/watcher/batch_proposer.go (1)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1530
File: rollup/internal/controller/watcher/batch_proposer.go:291-294
Timestamp: 2024-10-20T16:13:20.397Z
Learning: In `batch_proposer.go`, it's acceptable to call `utils.CalculateBatchMetrics` multiple times within the loop because the batch's chunks are increasing in the loop, and each calculation reflects the updated batch state.
rollup/internal/orm/batch.go (1)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1530
File: rollup/internal/controller/watcher/batch_proposer.go:291-294
Timestamp: 2024-10-20T16:13:20.397Z
Learning: In `batch_proposer.go`, it's acceptable to call `utils.CalculateBatchMetrics` multiple times within the loop because the batch's chunks are increasing in the loop, and each calculation reflects the updated batch state.
rollup/internal/utils/utils.go (1)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1530
File: rollup/internal/controller/watcher/batch_proposer.go:291-294
Timestamp: 2024-10-20T16:13:20.397Z
Learning: In `batch_proposer.go`, it's acceptable to call `utils.CalculateBatchMetrics` multiple times within the loop because the batch's chunks are increasing in the loop, and each calculation reflects the updated batch state.
rollup/internal/controller/relayer/l2_relayer.go (1)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1530
File: rollup/internal/controller/watcher/batch_proposer.go:291-294
Timestamp: 2024-10-20T16:13:20.397Z
Learning: In `batch_proposer.go`, it's acceptable to call `utils.CalculateBatchMetrics` multiple times within the loop because the batch's chunks are increasing in the loop, and each calculation reflects the updated batch state.
🧬 Code Graph Analysis (3)
rollup/cmd/rollup_relayer/app/app.go (2)
rollup/internal/config/l2.go (1)
  • L2Config (10-29)
rollup/internal/config/relayer.go (1)
  • RelayerConfig (55-82)
rollup/internal/orm/batch.go (1)
rollup/internal/utils/utils.go (1)
  • GetBatchMetadata (148-207)
rollup/internal/utils/utils.go (2)
rollup/internal/orm/batch.go (2)
  • Batch (22-72)
  • Batch (80-82)
coordinator/internal/types/auth.go (1)
  • Hash (134-141)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
🔇 Additional comments (7)
common/version/version.go (1)

8-8: LGTM: Version bump is correctly implemented.

The version increment from v4.5.27 to v4.5.28 properly reflects the addition of new Validium mode functionality.

rollup/conf/config.json (1)

39-39: LGTM: Well-structured configuration addition.

The validium_mode field is appropriately placed within the relayer configuration and uses a safe default value of false for backward compatibility.

rollup/internal/config/relayer.go (1)

56-57: LGTM: Proper struct field implementation.

The ValidiumMode field is correctly added with appropriate JSON tagging and a clear descriptive comment. The placement at the beginning of the struct is logical for a fundamental operational mode setting.

rollup/cmd/rollup_relayer/app/app.go (1)

111-111: Confirmed: SetValidiumMode Exists on BatchProposer

The SetValidiumMode(validiumMode bool) method is defined in
rollup/internal/controller/watcher/batch_proposer.go:134.
The integration in rollup/cmd/rollup_relayer/app/app.go:111 is correct and can be approved.

rollup/internal/orm/batch.go (1)

288-288: LGTM: Correct function signature alignment.

The addition of metrics.ValidiumMode parameter correctly aligns with the updated GetBatchMetadata function signature that now accepts a validiumMode boolean parameter.

rollup/internal/controller/watcher/batch_proposer.go (1)

35-35: LGTM! Validium mode integration is clean and consistent.

The addition of the validiumMode field with proper initialization and the consistent propagation to all CalculateBatchMetrics calls is well implemented.

Also applies to: 67-68, 133-137, 181-181, 297-297, 322-322, 332-332

rollup/internal/controller/relayer/l2_relayer.go (1)

1017-1019: Confirm EndBlockHash usage as validium commitment

We weren’t able to locate any in-repo documentation or examples that define how the commitment should be derived for validium mode. The code currently does:

lastChunk := lastBatch.Chunks[len(lastBatch.Chunks)-1]
commitment := common.HexToHash(lastChunk.EndBlockHash)

Please verify against the official validium protocol specification that using the last chunk’s EndBlockHash here is the correct source for the commitment.

@codecov-commenter
Copy link

codecov-commenter commented Jul 7, 2025

Codecov Report

Attention: Patch coverage is 15.92357% with 132 lines in your changes missing coverage. Please review.

Project coverage is 39.87%. Comparing base (b7a172a) to head (7dfb8b5).
Report is 4 commits behind head on develop.

Files with missing lines Patch % Lines
rollup/internal/controller/relayer/l2_relayer.go 18.82% 63 Missing and 6 partials ⚠️
rollup/internal/utils/utils.go 0.00% 54 Missing ⚠️
rollup/cmd/rollup_relayer/app/app.go 0.00% 7 Missing ⚠️
...llup/internal/controller/watcher/batch_proposer.go 85.71% 1 Missing ⚠️
...ollup/internal/controller/watcher/proposer_tool.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1693      +/-   ##
===========================================
+ Coverage    39.86%   39.87%   +0.01%     
===========================================
  Files          236      233       -3     
  Lines        18808    18369     -439     
===========================================
- Hits          7498     7325     -173     
+ Misses       10575    10336     -239     
+ Partials       735      708      -27     
Flag Coverage Δ
rollup 45.39% <15.92%> (-0.94%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Thegaram
Thegaram previously approved these changes Jul 7, 2025
// Generated manually from abigen.

// ValidiumMetaData contains all meta data concerning the ScrollChain contract.
var ValidiumMetaData = &bind.MetaData{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please generate these from the latest contract version? (Ignore this comment if you already did it.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated with this commit: f4d6e67. We can update it again after contract implementation is finalized (maybe merged).

@@ -108,6 +108,7 @@ func action(ctx *cli.Context) error {

chunkProposer := watcher.NewChunkProposer(subCtx, cfg.L2Config.ChunkProposerConfig, minCodecVersion, genesis.Config, db, registry)
batchProposer := watcher.NewBatchProposer(subCtx, cfg.L2Config.BatchProposerConfig, minCodecVersion, genesis.Config, db, registry)
batchProposer.SetValidiumMode(cfg.L2Config.RelayerConfig.ValidiumMode)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just pass it in NewBatchProposer?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is added to not modify the parameters of NewBatchProposer, but true based on your comment it's clearer, so changed to pass it in NewBatchProposer with this commit: f4d6e67.

log.Error("failed to construct constructCommitBatchPayloadCodecV7 payload for V7", "codecVersion", codecVersion, "start index", firstBatch.Index, "end index", lastBatch.Index, "err", err)
return
if r.cfg.ValidiumMode {
calldata, maxBlockHeight, totalGasUsed, err = r.constructCommitBatchPayloadValidium(batchesToSubmit, firstBatch)
Copy link
Contributor

Choose a reason for hiding this comment

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

This made me think. If we have multiple pending batches, maybe we should actually recreate them into a single batch; there's no point in committing in multiple steps (apart from controlling the prover workload). Something to consider in a later version.

Copy link
Member Author

@colinlyguo colinlyguo Jul 7, 2025

Choose a reason for hiding this comment

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

I think currently it's OK because timeout seems to be the only limit of batch proposing, so that the batch can be very large. It would be rare that there are many pending batches in db unless batch commit is stuck. I may misunderstand the real issue and miss some cases.

To apply batch merging, since inter-component coordination, such as freeze batch-proposer and bundle-proposer, and tweak db, would be a bit tricky.

Another way is to support commitBatches in the contract (though this only partially solved the cost problem).

Copy link
Member Author

Choose a reason for hiding this comment

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

Or do these limits of v7 and v8 chunk/batch still apply?

    "chunk_proposer_config": {
      "propose_interval_milliseconds": 100,
      "max_block_num_per_chunk": 100,
      "max_l2_gas_per_chunk": 20000000,
      "chunk_timeout_sec": 300,
      "max_uncompressed_batch_bytes_size": 4194304
    },
    "batch_proposer_config": {
      "propose_interval_milliseconds": 1000,
      "batch_timeout_sec": 300,
      "max_chunks_per_batch": 45,
      "max_uncompressed_batch_bytes_size": 4194304
    },
    "bundle_proposer_config": {
      "max_batch_num_per_bundle": 20,
      "bundle_timeout_sec": 36000
    },

Copy link
Member Author

Choose a reason for hiding this comment

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

Also found that currently it will not commit one batch at a time, fixed in this commit: 7dfb8b5.

parentHashSize = 32
stateRootSize = 32
withdrawRootSize = 32
commitmentSize = 32
Copy link
Contributor

Choose a reason for hiding this comment

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

We might use larger commitment in the future; for now let's keep it as 32 bytes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a comment in this commit: f4d6e67, also other TODO comments in related commitment places.


// For validium mode, use the last block hash as commitment to the off-chain data
var commitment common.Hash
if len(b.Blocks) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not allow the case when len(blocks) == 0.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a check and error return in f4d6e67.

Co-authored-by: Péter Garamvölgyi <[email protected]>
Copy link

@coderabbitai coderabbitai bot left a 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 (1)
rollup/internal/controller/relayer/l2_relayer.go (1)

984-1027: Consider the validium commitment strategy and batch processing differences.

The function correctly implements validium-specific logic:

  • Uses last block hash as commitment (acknowledged as temporary in TODO)
  • Calculates metrics without processing individual L2 blocks (appropriate for validium)
  • Validates batch consistency and codec versions

However, consider if the temporary commitment strategy meets security requirements for your use case.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd00cb4 and f4d6e67.

📒 Files selected for processing (9)
  • rollup/abi/validium_abi.go (1 hunks)
  • rollup/cmd/rollup_relayer/app/app.go (1 hunks)
  • rollup/internal/controller/relayer/l2_relayer.go (9 hunks)
  • rollup/internal/controller/watcher/batch_proposer.go (7 hunks)
  • rollup/internal/controller/watcher/batch_proposer_test.go (4 hunks)
  • rollup/internal/controller/watcher/bundle_proposer_test.go (1 hunks)
  • rollup/internal/controller/watcher/proposer_tool.go (1 hunks)
  • rollup/internal/utils/utils.go (4 hunks)
  • rollup/tests/rollup_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • rollup/cmd/rollup_relayer/app/app.go
  • rollup/internal/controller/watcher/batch_proposer.go
  • rollup/internal/utils/utils.go
  • rollup/abi/validium_abi.go
🧰 Additional context used
🧠 Learnings (5)
rollup/internal/controller/watcher/proposer_tool.go (1)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1530
File: rollup/internal/controller/watcher/batch_proposer.go:291-294
Timestamp: 2024-10-20T16:13:20.397Z
Learning: In `batch_proposer.go`, it's acceptable to call `utils.CalculateBatchMetrics` multiple times within the loop because the batch's chunks are increasing in the loop, and each calculation reflects the updated batch state.
rollup/tests/rollup_test.go (1)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1530
File: rollup/internal/controller/watcher/batch_proposer.go:291-294
Timestamp: 2024-10-20T16:13:20.397Z
Learning: In `batch_proposer.go`, it's acceptable to call `utils.CalculateBatchMetrics` multiple times within the loop because the batch's chunks are increasing in the loop, and each calculation reflects the updated batch state.
rollup/internal/controller/watcher/bundle_proposer_test.go (1)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1530
File: rollup/internal/controller/watcher/batch_proposer.go:291-294
Timestamp: 2024-10-20T16:13:20.397Z
Learning: In `batch_proposer.go`, it's acceptable to call `utils.CalculateBatchMetrics` multiple times within the loop because the batch's chunks are increasing in the loop, and each calculation reflects the updated batch state.
rollup/internal/controller/watcher/batch_proposer_test.go (1)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1530
File: rollup/internal/controller/watcher/batch_proposer.go:291-294
Timestamp: 2024-10-20T16:13:20.397Z
Learning: In `batch_proposer.go`, it's acceptable to call `utils.CalculateBatchMetrics` multiple times within the loop because the batch's chunks are increasing in the loop, and each calculation reflects the updated batch state.
rollup/internal/controller/relayer/l2_relayer.go (2)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1693
File: rollup/abi/validium_abi.go:13-15
Timestamp: 2025-07-07T12:02:52.191Z
Learning: In the Scroll codebase, ABI initialization in files like bridge_abi.go and validium_abi.go follows a consistent pattern of ignoring errors from GetAbi() in init functions to maintain code style consistency across the project.
Learnt from: colinlyguo
PR: scroll-tech/scroll#1530
File: rollup/internal/controller/watcher/batch_proposer.go:291-294
Timestamp: 2024-10-20T16:13:20.397Z
Learning: In `batch_proposer.go`, it's acceptable to call `utils.CalculateBatchMetrics` multiple times within the loop because the batch's chunks are increasing in the loop, and each calculation reflects the updated batch state.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
🔇 Additional comments (10)
rollup/internal/controller/watcher/proposer_tool.go (1)

128-128: LGTM: Constructor update is consistent with validium mode support.

The addition of the false /* rollup mode */ parameter aligns with the BatchProposer constructor signature update to support both rollup and validium modes.

rollup/internal/controller/watcher/bundle_proposer_test.go (1)

106-106: LGTM: Test constructor update is correct.

The test correctly specifies rollup mode with the false /* rollup mode */ parameter, which is appropriate for general batch proposer testing.

rollup/tests/rollup_test.go (1)

131-131: LGTM: Test constructor update maintains existing behavior.

The explicit false /* rollup mode */ parameter ensures the test continues to use rollup mode as expected.

rollup/internal/controller/watcher/batch_proposer_test.go (1)

103-103: LGTM: Consistent test constructor updates across all test functions.

All test functions correctly add the false /* rollup mode */ parameter to maintain existing rollup mode behavior in tests.

Also applies to: 181-181, 249-249, 338-338

rollup/internal/controller/relayer/l2_relayer.go (6)

82-82: LGTM: ValidiumABI field addition and initialization.

The validiumABI field is properly added and initialized from the bridgeAbi package, following the same pattern as the existing l1RollupABI.

Also applies to: 176-176


279-296: LGTM: Genesis batch commitment logic branches correctly for validium mode.

The conditional logic properly handles both rollup and validium modes:

  • Validium mode: Only passes batchHeader to importGenesisBatch
  • Rollup mode: Passes both batchHeader and stateRoot
  • Logging appropriately identifies the mode being used

Also applies to: 303-303, 328-328


484-496: LGTM: Batch processing correctly branches based on validium mode.

The ProcessPendingBatches function properly calls different payload construction methods based on the validium mode flag, with appropriate error handling for each path.


716-726: LGTM: Bundle finalization correctly branches based on validium mode.

The finalizeBundle function appropriately calls different payload construction methods for validium vs rollup modes with proper error handling.


1045-1045: LGTM: Added logging for rollup mode finalization.

The logging addition provides useful visibility into the rollup mode finalization process, mirroring the logging added for validium mode.


1061-1078: Validium finalizeBundle always requires aggProof

I compared both implementations and confirmed:

  • In rollup mode (constructFinalizeBundlePayloadCodecV7), a nil aggProof falls back to finalizeBundlePostEuclidV2NoProof.
  • In validium mode (constructFinalizeBundlePayloadValidium), a nil aggProof returns an error (lines 1064–1066).
  • There are no test-bypass flags or special branches for validium mode.

This behavior is intentional: validium finalization cannot proceed without a proof. If you need proof-less finalization in test environments, add a nil-proof branch similar to the rollup version.

@colinlyguo colinlyguo force-pushed the validium-devnet-wip branch from a398f64 to 7dfb8b5 Compare July 7, 2025 21:01
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.

4 participants