Skip to content

feat(ethrpc): Refactor EVM store to ensure atomic block allocation and transaction/log writes#172

Merged
dhyaniarun1993 merged 3 commits intomainfrom
arun/feat/evm-store-atomic-block-writes
Apr 1, 2026
Merged

feat(ethrpc): Refactor EVM store to ensure atomic block allocation and transaction/log writes#172
dhyaniarun1993 merged 3 commits intomainfrom
arun/feat/evm-store-atomic-block-writes

Conversation

@dhyaniarun1993
Copy link
Copy Markdown
Member

Closes #171

@dhyaniarun1993 dhyaniarun1993 self-assigned this Mar 25, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the EVM store's block allocation and data writing mechanisms to enhance atomicity and concurrency. By introducing a PendingBlock abstraction, the system now ensures that all transactions and logs associated with a synthetic EVM block are written within a single, atomic database transaction. This change also decouples block number allocation from the transaction lifecycle, allowing for more concurrent block creation while gracefully handling potential block number gaps on transaction rollback.

Highlights

  • Atomic Block Allocation: The EVM store now allocates the next block number using an atomic counter outside of the database transaction. This improves concurrency by decoupling block number allocation from the transaction's lifetime, though it may result in skipped block numbers if a transaction is rolled back.
  • PendingBlock Abstraction: Introduced a new PendingBlock interface that encapsulates all operations related to constructing a synthetic EVM block, including saving transactions and logs. This ensures that all writes for a given block are grouped into a single, atomic database transaction.
  • Store Interface Refactoring: The Store interface was refactored to remove direct SaveEvmTransaction and SaveEvmLog methods. Instead, it now provides a NewBlock method that returns a PendingBlock instance, centralizing block-related write operations.
  • Service Layer Integration: The recordSyntheticTransfer function in ethService was updated to utilize the new PendingBlock interface, ensuring that all synthetic transfer-related writes (transactions and logs) are performed atomically within the context of a pending block, with proper commit and rollback handling.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the synthetic EVM block creation and storage mechanism. It introduces a new PendingBlock interface and its pendingBlock implementation, which encapsulates block-related database operations within a single transaction. The PGStore now allocates the next block number atomically outside the transaction for improved concurrency, and the recordSyntheticTransfer function has been updated to use this new transactional block context. Dependency updates for Go modules are also included. A review comment points out a logical error in a test case for BlockRollback, where the test incorrectly asserts that the block counter should not advance after a rollback, which contradicts the intended design of the NewBlock function.

@dhyaniarun1993
Copy link
Copy Markdown
Member Author

@copilot review

@dhyaniarun1993
Copy link
Copy Markdown
Member Author

@gemini-code-assist please review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the synthetic EVM block creation and data persistence logic. It introduces a new PendingBlock interface and an associated pendingBlock implementation in the PostgreSQL store. This change allows for atomic block creation, transaction, and log saving within a single database transaction, with explicit commit (Finalize) and rollback (Abort) capabilities. The TxIndex for both transactions and logs is currently hardcoded to 0, which implies that each synthetic block will contain only one transaction. Clarification is requested on whether this is an intentional limitation or if future support for multiple transactions per synthetic block is planned.

@dhyaniarun1993 dhyaniarun1993 merged commit d25db23 into main Apr 1, 2026
2 checks passed
@dhyaniarun1993 dhyaniarun1993 deleted the arun/feat/evm-store-atomic-block-writes branch April 1, 2026 10:20
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.

Add Database Transactionality in EVM Store Operations

2 participants