Skip to content

Conversation

@feeblefakie
Copy link
Contributor

This is an automated backport of the following:

Please merge this PR after all checks have passed.

Copy link

@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.

Summary of Changes

Hello @feeblefakie, 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 is an automated backport aimed at correcting an issue where transaction state was not consistently recorded for read-only transactions when state management was enabled. The core change ensures that the transaction state is always put via the state manager before committing, regardless of whether the transaction involved writes, and includes enhanced test coverage to validate this behavior.

Highlights

  • Transaction State Management Fix: The stateManager.putCommit call in ScalarTamperEvidentAssetLedger.java has been repositioned. It is now executed unconditionally before a transaction commits, ensuring that the transaction state is always recorded via the state manager, even for read-only transactions that do not involve a write set, provided that transaction state management is enabled.
  • Enhanced Test Coverage: The test suite for ScalarTamperEvidentAssetLedgerTest.java has been significantly improved. Existing tests related to transaction state management have been converted into parameterized tests, allowing for comprehensive verification of the stateManager.putCommit behavior across both write and read-only transaction types, and under conditions where transaction state management is either enabled or disabled.
  • Testing Dependency Update: The build.gradle file has been updated to include junit-jupiter-params as a test dependency, enabling the use of parameterized tests for more robust and efficient testing of various transaction scenarios.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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

@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

The pull request aims to fix an issue where the transaction state was not being updated in read-only transactions. The changes involve moving the state management logic to ensure it's executed even in read-only scenarios. However, there are concerns about the placement of the state management logic and the accuracy of the test case for read-only transactions.

Comment on lines 136 to 141
transaction.put(puts);

if (!config.isDirectAssetAccessEnabled()) {
metadata.put(snapshot.getWriteSet().values());
}
}

Choose a reason for hiding this comment

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

high

Moving the transaction.put call outside the if block could lead to unexpected behavior if config.isTxStateManagementEnabled() is true but snapshot.hasWriteSet() is false. In such cases, the transaction state would be updated without any actual data being written, potentially causing inconsistencies. This should be reverted to ensure the transaction state is only updated when there are writes to the snapshot.

        if (config.isTxStateManagementEnabled()) {
          stateManager.putCommit(transaction, transaction.getId());
        }

        transaction.put(puts);

        if (!config.isDirectAssetAccessEnabled()) {
          metadata.put(snapshot.getWriteSet().values());

Comment on lines +799 to +800
verify(transaction, never()).put(any(List.class));
verify(transaction, never()).put(any(Put.class));

Choose a reason for hiding this comment

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

medium

The assertions verify(transaction, never()).put(any(List.class)) and verify(transaction, never()).put(any(Put.class)) are checking that put is never called on the transaction when txStateManagementEnabled is false. However, the test setup includes snapshot.put(ANY_ID, asset), which means there's data to be written. This contradicts the intention of testing a read-only transaction and could lead to incorrect test results. The snapshot.put call should be removed or conditioned on txStateManagementEnabled to accurately test the read-only scenario.

Suggested change
verify(transaction, never()).put(any(List.class));
verify(transaction, never()).put(any(Put.class));
if (txStateManagementEnabled) {
snapshot.put(ANY_ID, asset);
}

@jnmt jnmt merged commit 5f35ce8 into 3.11 Jul 10, 2025
8 checks passed
@jnmt jnmt deleted the 3.11-pull-181 branch July 10, 2025 09:48
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