Skip to content
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

refactor(l2geth dependency): downgrade to l2geth latest develop #32

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

jonastheis
Copy link
Contributor

@jonastheis jonastheis commented Dec 10, 2024

Purpose or design rationale of this PR

This PR downgrades to l2geth latest develop and fixes all incompatibilities.

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:

  • build: Changes that affect the build system or external dependencies (example scopes: yarn, eslint, typescript)
  • ci: Changes to our CI configuration files and scripts (example scopes: vercel, github, cypress)
  • docs: Documentation-only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that doesn't fix a bug, or add a feature, or improves performance
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • test: Adding missing tests or correcting existing tests

Breaking change label

Does this PR have the breaking-change label?

  • No, this PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • New Features

    • Enhanced error handling for batch processing and transaction decoding.
    • Introduced a new constant for gas cost related to blob transaction point evaluation.
    • Added comprehensive test cases for Codec V0, V1, V2, V3, and V4 functionalities, improving validation of encoding and decoding processes.
  • Bug Fixes

    • Improved error messages for transaction decoding and reporting.
  • Documentation

    • Updated method signatures for clarity and consistency.
  • Chores

    • Updated dependency versions in the project configuration.

Copy link

coderabbitai bot commented Dec 10, 2024

Walkthrough

The changes in this pull request involve modifications to several files related to the DACodecV3 struct and transaction processing. Key updates include enhanced error handling in methods for creating batches and decoding transactions, the addition of a new gas cost constant, and simplification of function parameters in codec selection. The go.mod file reflects updated dependency versions. Overall, these changes improve the robustness and clarity of the encoding logic.

Changes

File Change Summary
encoding/codecv3.go Updated DACodecV3 methods for error handling in NewDABatch and NewDABatchFromBytes. Changed gas cost references in EstimateChunkL1CommitGas and EstimateBatchL1CommitGas. JSONFromBytes remains largely unchanged.
encoding/da.go Added constant blobTxPointEvaluationPrecompileGas. Simplified GetHardforkName and GetCodecVersion functions. Enhanced error handling in getNextTx and improved messages in decodeTxsFromBytes.
encoding/interfaces.go Simplified CodecFromConfig function by removing startBlockNumber parameter from calls to IsDarwin and IsDarwinV2.
go.mod Updated github.com/scroll-tech/go-ethereum dependency version and modified several indirect dependencies.

Poem

In the code where rabbits play,
Changes hop in a bright array.
With gas costs set and errors tamed,
Our codec's now more aptly named.
So here’s to bytes and batches new,
A joyful leap for me and you! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0bc23e8 and abcf1b2.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • go.mod

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Experiment)
  • @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.

colinlyguo
colinlyguo previously approved these changes Dec 10, 2024
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

🧹 Outside diff range and nitpick comments (7)
encoding/codecv0_test.go (2)

Line range hint 15-297: Consider refactoring long test functions into table-driven tests

While the test coverage is comprehensive, some test functions (like TestCodecV0BlockEncode and TestCodecV0ChunkEncode) are quite long and contain repetitive patterns. Consider refactoring these into table-driven tests to improve maintainability and make it easier to add new test cases.

Example refactor for TestCodecV0BlockEncode:

-func TestCodecV0BlockEncode(t *testing.T) {
+func TestCodecV0BlockEncode(t *testing.T) {
+    tests := []struct {
+        name     string
+        jsonFile string
+        want     string
+    }{
+        {
+            name: "empty block",
+            want: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+        },
+        {
+            name:     "block 02",
+            jsonFile: "testdata/blockTrace_02.json",
+            want:     "00000000000000020000000063807b2a0000000000000000000000000000000000000000000000000000000000001de9000355418d1e818400020000",
+        },
+        // Add more test cases...
+    }
+
+    codecv0, err := CodecFromVersion(CodecV0)
+    require.NoError(t, err)
+
+    for _, tt := range tests {
+        t.Run(tt.name, func(t *testing.T) {
+            var block DABlock
+            if tt.jsonFile == "" {
+                block = &daBlockV0{}
+            } else {
+                b := readBlockFromJSON(t, tt.jsonFile)
+                block, err = codecv0.NewDABlock(b, 0)
+                require.NoError(t, err)
+            }
+            encoded := hex.EncodeToString(block.Encode())
+            assert.Equal(t, tt.want, encoded)
+        })
+    }
+}

Line range hint 298-595: Add validation for test data format

While the test data organization is good, consider adding validation for the test data format to ensure the JSON files contain the expected structure. This would help catch issues with malformed test data early.

+func validateBlockJSON(t *testing.T, data []byte) error {
+    var block struct {
+        Number     string   `json:"number"`
+        Timestamp  string   `json:"timestamp"`
+        Hash      string   `json:"hash"`
+        // Add other expected fields
+    }
+    if err := json.Unmarshal(data, &block); err != nil {
+        return fmt.Errorf("invalid block JSON format: %v", err)
+    }
+    return nil
+}

 func readBlockFromJSON(t *testing.T, path string) *Block {
     data, err := os.ReadFile(path)
     require.NoError(t, err)
+    require.NoError(t, validateBlockJSON(t, data))
     // ... rest of the function
 }
encoding/codecv1_test.go (1)

Line range hint 1890-2130: Consider adding test cases for invalid inputs in TestCodecV1BatchStandardTestCases

The function TestCodecV1BatchStandardTestCases robustly tests various standard scenarios, including empty and non-empty chunks, maximum chunk limits, and full blobs. To further strengthen the test suite, consider adding test cases for invalid or edge-case inputs, such as:

  • Chunks containing data that exceed maximum allowed sizes.
  • Batches with an excessive number of chunks beyond the limit.
  • Chunks with malformed or corrupted data.

Including these tests will ensure that the codec handles erroneous inputs gracefully and maintains stability under all conditions.

encoding/codecv4_test.go (4)

Line range hint 111-115: Ensure error handling for nil inputs in TestCodecV4BatchCompressedDataCompatibilityCheck

Consider adding test cases to handle nil or invalid batch inputs to verify that the function behaves correctly under edge conditions.


Line range hint 169-173: Expand test coverage in TestCodecV4ChunkCompressedDataCompatibilityCheck

Include additional test cases with mixed transaction types and malformed data to thoroughly test the chunk compatibility logic.


Line range hint 227-230: Clarify purpose in TestDACodecV4SimpleMethods

Adding comments or descriptive names for test cases can improve the readability and maintainability of the tests for simple methods.


Line range hint 232-488: Improve readability by splitting TestCodecV4BatchStandardTestCasesEnableCompression

This test function covers multiple scenarios with extensive data. Splitting it into smaller, focused test functions can enhance readability and maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 70810fa and 0bc23e8.

📒 Files selected for processing (6)
  • encoding/codecv0_test.go (1 hunks)
  • encoding/codecv1_test.go (1 hunks)
  • encoding/codecv2_test.go (1 hunks)
  • encoding/codecv3_test.go (1 hunks)
  • encoding/codecv4_test.go (1 hunks)
  • encoding/interfaces_test.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • encoding/interfaces_test.go
🔇 Additional comments (8)
encoding/codecv0_test.go (1)

7-8: Good addition of testify imports!

The addition of testify/assert and testify/require packages improves test reliability by providing better assertion handling. require is correctly used for critical checks that should stop test execution, while assert is used for non-critical comparisons.

encoding/codecv1_test.go (2)

11-12: LGTM!

The import statements for assert and require from the testify library are correctly added and will assist in enhancing the test assertions.


Line range hint 2132-2145: LGTM!

The simple methods Version and EstimateBlockL1CommitCalldataSize are appropriately tested in TestDACodecV1SimpleMethods. The tests effectively confirm the correct versioning and calldata size estimations.

encoding/codecv2_test.go (1)

11-12: Good use of testing libraries

The addition of github.com/stretchr/testify/assert and github.com/stretchr/testify/require imports enhances the readability and effectiveness of the test cases.

encoding/codecv3_test.go (1)

13-15: Appropriate inclusion of testify assertions

Including assert and require from the testify library improves test readability and ensures consistent assertion handling.

encoding/codecv4_test.go (3)

12-13: Appropriate inclusion of testing packages

Importing the assert and require packages from github.com/stretchr/testify aligns with best practices for writing concise and readable tests.


Line range hint 490-733: Verify handling of maximum data sizes in TestCodecV4BatchStandardTestCasesDisableCompression

Ensure that the test cases accurately simulate scenarios with maximum blob sizes and that all edge cases related to data limits are appropriately handled.


Line range hint 735-746: Good practice in TestDACodecV4SimpleMethods

The test correctly verifies the Version() method, ensuring that the codec version is returned as expected.

@Thegaram Thegaram merged commit 9852fa4 into main Dec 18, 2024
4 checks passed
@Thegaram Thegaram deleted the jt/downgrade-main-to-l2geth-develop branch December 18, 2024 10:26
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