Skip to content

Conversation

@jnmt
Copy link
Collaborator

@jnmt jnmt commented Nov 25, 2025

Description

This PR removes the ScalarDB dependency from AssetProofComposer. I think it's better to refactor it before changing it for the namespace feature.

Additionally, this PR consolidates duplicate certificate constants, eliminating duplicate long string constants across multiple test classes to fix the SpotBugs HSC_HUGE_SHARED_STRING_CONSTANT warning. This is essentially not related to the refactoring of AssetProofComposer, but somehow it started to occur.

Related issues and/or PRs

N/A

Changes made

  • Remove the create(Put, String) method in AssetProofComposer and add a helper method in ScalarTamperEvidentAssetLedger to extract data from Put.
  • Move AssetProofComposer from the scalardb package to the database package.
  • Consolidate duplicate certificate constants in TestConstants.

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

Refactored AssetProofComposer.

Copilot AI review requested due to automatic review settings November 25, 2025 08:20
@gemini-code-assist
Copy link

Summary of Changes

Hello @jnmt, 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 primarily focuses on refactoring the AssetProofComposer to remove its direct dependency on ScalarDB, which is a foundational step for upcoming namespace features. Concurrently, it improves code quality by centralizing redundant certificate and private key constants from various test files into a dedicated TestConstants class, thereby resolving a SpotBugs warning and enhancing test code maintainability.

Highlights

  • Decoupling AssetProofComposer: The AssetProofComposer class has been refactored to remove its direct dependency on ScalarDB, making it more modular and preparing it for future enhancements like namespace support.
  • Package Relocation: AssetProofComposer has been moved from the scalardb specific package to a more general database package, reflecting its reduced dependency on ScalarDB.
  • Centralized Test Constants: Duplicate certificate and private key string constants, previously scattered across multiple test classes, have been consolidated into a new TestConstants utility class. This change addresses a SpotBugs warning (HSC_HUGE_SHARED_STRING_CONSTANT) and improves maintainability.
  • Put Data Extraction Helper: A new helper method, createProofFrom, has been introduced in ScalarTamperEvidentAssetLedger to handle the extraction of data from Put objects, replacing the functionality previously provided by a removed method in AssetProofComposer.
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.

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.

@jnmt jnmt self-assigned this Nov 25, 2025
Copilot finished reviewing on behalf of jnmt November 25, 2025 08:32
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

This pull request effectively refactors AssetProofComposer to decouple it from ScalarDB, which is a good architectural improvement. The logic for handling ScalarDB-specific Put objects is now correctly encapsulated within ScalarTamperEvidentAssetLedger. Additionally, consolidating duplicated test constants into a new TestConstants class is a great move for maintainability and successfully addresses the SpotBugs warning. The changes are clean and well-implemented. I have one minor suggestion to further improve the new constants class.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors AssetProofComposer to remove its ScalarDB dependency by moving it from the scalardb package to the generic database package, and consolidates duplicate certificate constants across test files to address SpotBugs HSC_HUGE_SHARED_STRING_CONSTANT warnings.

  • Removed ScalarDB-specific create(Put, String) method from AssetProofComposer and added a helper method in ScalarTamperEvidentAssetLedger to extract data from ScalarDB's Put objects
  • Moved AssetProofComposer from com.scalar.dl.ledger.database.scalardb to com.scalar.dl.ledger.database package
  • Created TestConstants class to centralize certificate and private key constants, eliminating duplication across 4 test classes and 1 integration test constants class

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ledger/src/main/java/com/scalar/dl/ledger/database/AssetProofComposer.java Moved from scalardb package to database package; removed ScalarDB-specific create(Put, String) method
ledger/src/main/java/com/scalar/dl/ledger/database/scalardb/ScalarTamperEvidentAssetLedger.java Added createProofFrom helper method to extract data from ScalarDB Put objects before calling AssetProofComposer
ledger/src/test/java/com/scalar/dl/ledger/test/TestConstants.java New class centralizing certificate and private key constants used across test files
ledger/src/test/java/com/scalar/dl/ledger/validation/ContractValidatorTest.java Removed duplicate constants, added imports for TestConstants
ledger/src/test/java/com/scalar/dl/ledger/service/LedgerValidationServiceTest.java Removed duplicate constants, added imports for TestConstants and updated AssetProofComposer import
ledger/src/test/java/com/scalar/dl/ledger/contract/ContractManagerTest.java Removed duplicate constants, added imports for TestConstants
ledger/src/test/java/com/scalar/dl/ledger/database/scalardb/ScalarTransactionManagerTest.java Updated AssetProofComposer import to new package
ledger/src/test/java/com/scalar/dl/ledger/database/scalardb/ScalarTamperEvidentAssetLedgerTest.java Updated AssetProofComposer import to new package
ledger/src/main/java/com/scalar/dl/ledger/service/ValidationService.java Updated AssetProofComposer import to new package
ledger/src/main/java/com/scalar/dl/ledger/service/LedgerValidationService.java Updated AssetProofComposer import to new package
ledger/src/main/java/com/scalar/dl/ledger/database/scalardb/ScalarTransactionManager.java Updated AssetProofComposer import to new package
ledger/src/integration-test/java/com/scalar/dl/ledger/service/LedgerServiceIntegrationTest.java Removed constant imports from integration test Constants, added imports for TestConstants
ledger/src/integration-test/java/com/scalar/dl/ledger/service/LedgerServiceEndToEndTest.java Removed constant imports from integration test Constants, added imports for TestConstants
ledger/src/integration-test/java/com/scalar/dl/ledger/service/Constants.java Removed duplicate certificate and private key constants

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@jnmt jnmt requested review from choplin and feeblefakie November 25, 2025 09:02
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant