Skip to content

Conversation

@Thegaram
Copy link

@Thegaram Thegaram commented Jun 26, 2025

1. Purpose or design rationale of this PR

Test cases from recent transactions on Scroll mainnet.

2. 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:

  • test: Adding missing tests or correcting existing tests

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for transaction compression ratio estimation with multiple real-world Ethereum transaction examples, including ETH transfers, token transfers, swaps, deposits, and oracle updates.

@Thegaram Thegaram requested review from colinlyguo and georgehao June 26, 2025 14:20
@coderabbitai
Copy link

coderabbitai bot commented Jun 26, 2025

Walkthrough

The test suite for transaction compression ratio estimation was expanded by adding several subtests using real Ethereum transaction examples. Each subtest decodes a hex-encoded transaction, invokes the estimation function with fixed parameters, and asserts the output matches expected compression ratios. No changes were made to the core logic or public interfaces.

Changes

File(s) Change Summary
rollup/fees/rollup_fee_test.go Added multiple subtests to TestEstimateTxCompressionRatio, using real transaction data and expected results. Imported common for hex decoding.

Poem

🐇
In the warren of tests, new cases appear,
Real transactions hop in, their data is clear.
Ratios are measured, assertions are tight,
Compression inspected by burrowed byte-light.
With coverage expanded, the code feels just right!

✨ 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: 0

🧹 Nitpick comments (2)
rollup/fees/rollup_fee_test.go (2)

125-132: Consider validating hex decoding success.

The test case correctly implements compression ratio testing for ETH transfer transactions. However, common.Hex2Bytes silently ignores decoding errors and may return nil or partial data for malformed hex strings.

Consider adding validation to ensure the hex string decodes successfully:

-		data := common.Hex2Bytes("02f86b83082750830461a40183830fb782523f94802b65b5d9016621e66003aed0b16615093f328b8080c001a0a1fa6bbede5ae355eaec83fdcda65eab240476895e649576552850de726596cca0424eb1f5221865817b270d85caf8611d35ea6d7c2e86c9c31af5c06df04a2587")
+		hexStr := "02f86b83082750830461a40183830fb782523f94802b65b5d9016621e66003aed0b16615093f328b8080c001a0a1fa6bbede5ae355eaec83fdcda65eab240476895e649576552850de726596cca0424eb1f5221865817b270d85caf8611d35ea6d7c2e86c9c31af5c06df04a2587"
+		data := common.Hex2Bytes(hexStr)
+		assert.NotEmpty(t, data, "Failed to decode transaction hex string")

124-177: Consider parameterizing gas price and base fee values.

All test cases use identical fixed values for gas price (1000000) and base fee (1700000000). Consider if these should vary based on the actual network conditions when these transactions occurred, or if they should be parameterized for better test maintainability.

Consider creating constants or a helper function to make the test parameters more explicit:

+const (
+	testGasPrice = 1000000
+	testBaseFee  = 1700000000
+)
+
 	t.Run("eth-transfer", func(t *testing.T) {
 		// https://scrollscan.com/tx/0x8c7eba9a56e25c4402a1d9fdbe6fbe70e6f6f89484b2e4f5c329258a924193b4
 		data := common.Hex2Bytes("02f86b83082750830461a40183830fb782523f94802b65b5d9016621e66003aed0b16615093f328b8080c001a0a1fa6bbede5ae355eaec83fdcda65eab240476895e649576552850de726596cca0424eb1f5221865817b270d85caf8611d35ea6d7c2e86c9c31af5c06df04a2587")
-		ratio, err := estimateTxCompressionRatio(data, 1000000, 1700000000, params.TestChainConfig)
+		ratio, err := estimateTxCompressionRatio(data, testGasPrice, testBaseFee, params.TestChainConfig)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 941913b and b7af715.

📒 Files selected for processing (1)
  • rollup/fees/rollup_fee_test.go (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
rollup/fees/rollup_fee_test.go (1)
Learnt from: Thegaram
PR: scroll-tech/go-ethereum#1204
File: miner/scroll_worker.go:836-845
Timestamp: 2025-06-11T15:54:05.820Z
Learning: When `processTxn` rejects a transaction because its calculated L1 data fee is ≥ `fees.MaxL1DataFee()`, this indicates a mis-configured system parameter, not a bad transaction, so the tx must remain in the TxPool rather than being purged.
🧬 Code Graph Analysis (1)
rollup/fees/rollup_fee_test.go (2)
common/bytes.go (1)
  • Hex2Bytes (79-82)
params/config.go (1)
  • TestChainConfig (501-541)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test
  • GitHub Check: Analyze (go)
🔇 Additional comments (6)
rollup/fees/rollup_fee_test.go (6)

9-9: LGTM: Import addition is appropriate.

The common package import is correctly added to support the Hex2Bytes function used in the new test cases.


134-141: LGTM: SCR transfer test case is well-implemented.

The test case correctly validates compression ratio estimation for SCR token transfers with appropriate expected ratio of 1.1x.


143-150: LGTM: SyncSwap test demonstrates good compression.

The test case validates a complex SyncSwap transaction with high compression ratio (3.1x), which is expected given the repetitive patterns in swap contract interactions.


152-159: LGTM: Uniswap test case covers important DeFi scenario.

The test case appropriately validates compression ratio for Uniswap V3 swap transactions with expected 1.7x compression ratio.


161-168: LGTM: EtherFi deposit test covers staking scenario.

The test case correctly validates compression ratio for liquid staking deposits with appropriate 1.4x expected compression ratio.


170-177: LGTM: Oracle update test covers important infrastructure scenario.

The test case validates compression ratio for EdgePushOracle post updates with reasonable 2.1x compression ratio, covering an important infrastructure transaction type.

Copy link
Member

@georgehao georgehao left a comment

Choose a reason for hiding this comment

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

LGTM

@Thegaram Thegaram merged commit 3e96a85 into develop Jun 26, 2025
14 checks passed
@Thegaram Thegaram deleted the feat-add-more-compression-ratio-test-cases branch June 26, 2025 16:06
@coderabbitai coderabbitai bot mentioned this pull request Nov 4, 2025
5 tasks
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.

2 participants