Skip to content

feat(tx-pool): migrate upstream setcode transaction changes #1148

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

Merged
merged 3 commits into from
Mar 20, 2025

Conversation

colinlyguo
Copy link
Member

@colinlyguo colinlyguo commented Mar 14, 2025

1. Purpose or design rationale of this PR

This PR migrates some recent upstream changes:

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:

  • feat: A new feature

3. Deployment tag versioning

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

  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change

Summary by CodeRabbit

  • Refactor
    • Revamped transaction validations to provide clearer error messaging when the in-flight transaction limit is reached and to ensure unique tracking of authorizations.
  • Tests
    • Expanded test coverage to validate enhanced transaction processing, including improved handling during chain reorganization scenarios.
  • Chores
    • Incremented the patch version to reflect these updates.

Copy link

coderabbitai bot commented Mar 14, 2025

Walkthrough

This pull request refactors the transaction pool’s error handling and validation logic. It replaces the previous account limit error with a new error for in-flight transaction limits and introduces a dedicated authorization check method. The changes update function signatures for managing transaction authorities, improve testing—especially for reorganization scenarios—and ensure duplicate authorities in transactions are filtered. Additionally, the patch version has been incremented.

Changes

Files Change Summary
core/tx_pool.go, core/tx_pool_test.go Refactored transaction pool validation: removed ErrAccountLimitExceeded in favor of ErrInflightTxLimitReached, added new method validateAuth, updated removeAuthorities signature, and enhanced tests (e.g., reorg scenario).
core/types/transaction.go Modified SetCodeAuthorities to filter duplicate authority addresses, ensuring the returned list is unique.
params/version.go Updated VersionPatch constant from 27 to 28.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant TxPool
    participant Validator
    participant Transaction

    Client->>TxPool: Submit Transaction
    TxPool->>TxPool: validateTx()
    TxPool->>Validator: validateAuth(from, tx)
    Validator->>Transaction: Retrieve authority list
    Transaction-->>Validator: Return unique authorities
    Validator-->>TxPool: Validation result
    TxPool->>Client: Accept/Reject Transaction
Loading

Possibly related PRs

Suggested labels

bump-version

Suggested reviewers

  • omerfirmak
  • colinlyguo

Poem

I hop through lines of code with glee,
Clearing errors as smooth as a breeze.
New limits and checks now dance in place,
In our code garden, bugs lose their chase.
Hoppy coding to all, from a rabbit in space!
🐇✨


📜 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 6b16faa and 410c54b.

📒 Files selected for processing (1)
  • params/version.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • params/version.go
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test
  • GitHub Check: Analyze (go)

🪧 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.
  • @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: 1

🧹 Nitpick comments (1)
core/tx_pool_test.go (1)

163-176: Handle potential signature errors.

The MustSignNewTx call panics on failure. Consider validating or returning the error to avoid unexpected panics. Also, verify that the hard-coded Value: uint256.NewInt(100) is intentional.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 94fcd7d and 6b16faa.

📒 Files selected for processing (4)
  • core/tx_pool.go (5 hunks)
  • core/tx_pool_test.go (8 hunks)
  • core/types/transaction.go (1 hunks)
  • params/version.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test
  • GitHub Check: Analyze (go)
🔇 Additional comments (12)
params/version.go (1)

27-27: Incrementing the patch version looks good.

This minor version bump from 25 to 26 aligns with the feature additions in the transaction handling logic, and there do not appear to be any issues with this change.

core/types/transaction.go (1)

487-496: Ensure uniqueness logic is correct and efficient.

The introduction of the marks map to prevent duplicate authorities is a straightforward and efficient solution. It correctly skips already-seen addresses while building the final list. The time complexity is O(n), which is acceptable for typical authorization lists, and there is no risk of data races since this method only reads local data.

core/tx_pool.go (4)

1887-1911: Check single in-flight transaction rule logic carefully.

The check combining:

  1. A non-empty code hash (account has a deployed delegation) or
  2. Existing in-flight authorization (tracked in pool.all.auths[from])
    to limit the account to one transaction is clearly implemented here.
    However, consider clarifying behavior for partially overlapping transactions (same nonce but different gas prices) vs. truly distinct in-flight transactions (different nonces). This enforcement might cause confusion if an account wants to replace an existing delegated transaction with a higher gas price.

Could you confirm that overlapping transactions (i.e., same nonce) are allowed as “replace” transactions as intended?


1914-1920: Validate reserved authority logic.

This logic prevents conflicting authorities from different transactions in-flight. It ensures that if a SetCode authorization is already pending or queued for a particular address, no other transaction can attempt to use that same address for authorization. This effectively maintains one unique authority usage at a time in the pool. This approach appears correct for the delegated scenario.


2170-2170: Switching to removeAuthorities(tx) is consistent.

Switching from removing authorities by hash to removing them using the full tx object ensures the code can accurately clear the relevant addresses, especially now that you track multiple authorities within a single transaction. This implements the logic more robustly, preventing partial or incorrect lookups by hash alone.


95-97:

✅ Verification successful

Validate new error usage.

The newly added ErrInflightTxLimitReached error is clearly named and scoped to the delegated account case. Ensure it’s handled consistently in the rest of the codebase so that calling sites properly differentiate between in-flight limit violations and other capacity constraints.

To confirm coverage, please search for usage of ErrInflightTxLimitReached across the codebase:


🏁 Script executed:

#!/bin/bash
# Searching all code for occurrences of ErrInflightTxLimitReached
rg "ErrInflightTxLimitReached"

Length of output: 1505


Usage Verified: ErrInflightTxLimitReached is Consistently Handled

After verifying the repository, it’s clear that the new error is not only defined appropriately in core/tx_pool.go but also consistently used in the test suite (core/tx_pool_test.go). The tests correctly compare the error via errors.Is, ensuring that calling sites can differentiate in-flight limit violations from other error conditions.

  • Definition Check: The error is defined with a clear message in core/tx_pool.go.
  • Return & Handling: It is returned from functions as expected and is validated in multiple test cases.
  • Test Coverage: Tests in core/tx_pool_test.go verify that the error is properly used when the in-flight transaction limit is reached.

No further changes are required.

core/tx_pool_test.go (6)

27-27: Confirm Go 1.21+ compatibility.

You've introduced the slices package at line 27. Please ensure the build environment uses Go 1.21 or higher, otherwise this import may cause compilation issues.


160-160: No issues with new function call.

Replacing inline logic with a call to pricedSetCodeTxWithAuth appears clean and consistent. No immediate concerns.


2737-2742: Test coverage for in-flight transaction limit.

These lines properly confirm that any additional transactions for the same account trigger ErrInflightTxLimitReached once the limit is reached. The logic looks sound.


2776-2777: Clarify in-flight transaction limit for delegated accounts.

Same pattern of verifying ErrInflightTxLimitReached. The approach ensures delegated or authority-based constraints. No immediate issues.


2882-2908: Verify authority tracker cleanup logic.

You're testing that replaced SetCode transactions remove their old hashes from the authority tracker. It might be worth confirming that no partial references remain in other data structures. Otherwise, this is a helpful test scenario.


2937-2990: Reorg handling for SetCode transactions.

This test thoroughly verifies state transitions for delegations and checks that older authorizations no longer block new transactions. The logic is clear, and the coverage is good.

Thegaram
Thegaram previously approved these changes Mar 17, 2025
@Thegaram Thegaram merged commit e1e578d into develop Mar 20, 2025
14 checks passed
@Thegaram Thegaram deleted the feat-tx-pool-migrate-setcode-tx-upstream-changes branch March 20, 2025 12:19
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