Skip to content

Conversation

@neekolas
Copy link
Contributor

@neekolas neekolas commented May 28, 2025

TL;DR

Replaced ReportsAdmin with a fully implemented ReportsManager that interacts with the blockchain to manage payer reports.

What changed?

  • Renamed PayerReportsAdmin interface to PayerReportsManager and added new methods: GetReport, GetReportID
  • Replaced the stub ReportsAdmin implementation with a complete ReportsManager implementation that interacts with the blockchain
  • Added blockchain integration for submitting and retrieving payer reports
  • Made BuildPayerReportID function public to allow external verification
  • Added tests for the new functionality, including blockchain integration tests
  • Updated configuration to include the payer report manager contract address
  • Modified server initialization to use the blockchain domain separator

How to test?

  1. Run the integration tests in pkg/payerreport/workers/integration_test.go
  2. Verify that reports can be generated, attested, and submitted to the blockchain
  3. Confirm that report IDs match between local calculation and blockchain retrieval
  4. Test the domain separator caching by calling GetDomainSeparator multiple times

Why make this change?

This change implements the blockchain integration for payer reports, allowing the system to submit reports to the blockchain and verify their integrity. The implementation enables the full payer report lifecycle - from generation to attestation to on-chain submission - which is critical for the settlement process. Making the report ID calculation consistent between local and blockchain environments ensures data integrity throughout the system.

Summary by CodeRabbit

  • New Features

    • Introduced blockchain-backed management of payer reports, enabling submission and retrieval of reports directly on-chain.
    • Added support for configuring the Payer Report Manager contract address.
  • Improvements

    • Enhanced integration tests to verify report consistency and submission using a real blockchain environment.
    • Domain separator is now dynamically fetched from the blockchain, improving accuracy and flexibility.
    • Updated test utilities and server setup to use real blockchain contract configurations.
  • Bug Fixes

    • Ensured consistent report ID generation between local and blockchain sources.
  • Refactor

    • Renamed and updated interfaces and methods for clarity and expanded functionality.
    • Replaced mock components with real blockchain-backed implementations in tests and worker logic.
    • Simplified signature method by removing domain separator parameter across registrant interfaces and mocks.
    • Updated submitter worker to use the new reports manager interface and exported submission method.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 28, 2025

Warning

Rate limit exceeded

@neekolas has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 32 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 405462a and b3265fd.

📒 Files selected for processing (20)
  • dev/environments/anvil.json (1 hunks)
  • pkg/blockchain/interface.go (1 hunks)
  • pkg/blockchain/reportsManager.go (1 hunks)
  • pkg/blockchain/reportsManager_test.go (1 hunks)
  • pkg/mocks/registrant/mock_IRegistrant.go (3 hunks)
  • pkg/mocks/retryable_errors/mock_RetryableError.go (0 hunks)
  • pkg/payerreport/report.go (2 hunks)
  • pkg/payerreport/report_test.go (1 hunks)
  • pkg/payerreport/store.go (1 hunks)
  • pkg/payerreport/workers/attestation.go (1 hunks)
  • pkg/payerreport/workers/attestation_test.go (1 hunks)
  • pkg/payerreport/workers/integration_test.go (11 hunks)
  • pkg/payerreport/workers/submitter.go (4 hunks)
  • pkg/registrant/interface.go (0 hunks)
  • pkg/registrant/registrant.go (0 hunks)
  • pkg/server/server.go (3 hunks)
  • pkg/server/server_test.go (3 hunks)
  • pkg/testutils/anvil/anvil.go (1 hunks)
  • pkg/testutils/config.go (1 hunks)
  • pkg/testutils/server/server.go (1 hunks)

Walkthrough

This change replaces the previous PayerReportsAdmin interface and its implementation with a new PayerReportsManager interface and a concrete ReportsManager type that interacts directly with a blockchain smart contract for payer reports. It introduces new methods for report retrieval and ID computation, updates related worker and server logic, expands configuration options, and enhances integration testing to use a real blockchain environment.

Changes

File(s) Change Summary
pkg/blockchain/interface.go Renamed PayerReportsAdmin to PayerReportsManager; added GetReport, GetReportID.
pkg/blockchain/reportsAdmin.go Removed the ReportsAdmin struct and all related methods.
pkg/blockchain/reportsManager.go Added ReportsManager type implementing PayerReportsManager, with methods to submit and retrieve reports, get report IDs, and fetch domain separator.
pkg/blockchain/reportsManager_test.go Added tests for ReportsManager, including domain separator retrieval and consistency.
pkg/config/options.go, pkg/testutils/config.go Added PayerReportManagerAddress field to configuration structs and initialization.
pkg/payerreport/report.go, pkg/payerreport/report_test.go, pkg/payerreport/store.go Renamed and exported buildPayerReportID to BuildPayerReportID; updated usages.
pkg/payerreport/workers/submitter.go Changed field and parameter types from PayerReportsAdmin to PayerReportsManager; exported SubmitReports method.
pkg/payerreport/workers/integration_test.go Replaced mock registry with blockchain-backed registry and reports manager; added blockchain setup and new tests for report ID consistency.
pkg/registrant/registrant.go Changed attestation signing to use raw report ID bytes instead of a hash with domain separator.
pkg/server/server.go, pkg/server/server_test.go, pkg/testutils/server/server.go Updated server initialization and tests to use dynamic domain separator from blockchain contracts via new configuration options.
pkg/mocks/blockchain/mock_PayerReportsAdmin.go Removed autogenerated mock for deprecated PayerReportsAdmin interface.
pkg/mocks/registrant/mock_IRegistrant.go Updated mock method signatures to remove domainSeparator parameter from SignPayerReportAttestation.
pkg/mocks/retryable_errors/mock_RetryableError.go Removed autogenerated mock for RetryableError interface.
pkg/payerreport/workers/attestation.go, pkg/payerreport/workers/attestation_test.go Updated calls and mocks of SignPayerReportAttestation to remove domainSeparator argument.
pkg/registrant/interface.go Removed domainSeparator parameter from SignPayerReportAttestation method in IRegistrant interface.
pkg/testutils/anvil/anvil.go Updated Anvil container image version from v0.4.0 to v0.4.3.

Sequence Diagram(s)

sequenceDiagram
    participant Worker as SubmitterWorker
    participant Manager as ReportsManager
    participant Blockchain as PayerReportManagerContract

    Worker->>Manager: SubmitPayerReport(ctx, report)
    Manager->>Blockchain: Submit(report fields, attestation signatures)
    Blockchain-->>Manager: PayerReportSubmitted event
    Manager-->>Worker: Return result

    Worker->>Manager: GetReport(ctx, originatorNodeID, index)
    Manager->>Blockchain: GetReport(originatorNodeID, index)
    Blockchain-->>Manager: On-chain report data
    Manager-->>Worker: Return PayerReport

    Worker->>Manager: GetReportID(ctx, payerReport)
    Manager->>Blockchain: ComputeDigest(payerReport fields)
    Blockchain-->>Manager: ReportID
    Manager-->>Worker: Return ReportID

    Worker->>Manager: GetDomainSeparator(ctx)
    Manager->>Blockchain: DomainSeparator()
    Blockchain-->>Manager: domainSeparator
    Manager-->>Worker: Return domainSeparator
Loading

Suggested reviewers

  • fbac
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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
Contributor Author

neekolas commented May 28, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • Queue - adds this PR to the back of the merge queue
  • Hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@macroscopeapp
Copy link

macroscopeapp bot commented May 28, 2025

Replace PayerReportsAdmin interface with PayerReportsManager to enable blockchain interaction for payer report submission and retrieval

Replaces the stub PayerReportsAdmin interface with a fully functional PayerReportsManager that connects to Ethereum smart contracts for payer report operations. The changes include:

• Creates new reportsManager.go implementing blockchain interaction methods GetReport, GetReportID, and SubmitPayerReport
• Removes stub implementation in reportsAdmin.go and updates interface in interface.go
• Modifies server initialization in server.go to retrieve domain separator from blockchain instead of using hardcoded values
• Updates BuildPayerReportID function visibility in report.go and modifies signature generation in registrant.go
• Replaces mock blockchain components with actual blockchain infrastructure in integration tests integration_test.go
• Adds configuration support for payer report manager contract address in options.go

📍Where to Start

Start with the new ReportsManager struct and its methods in reportsManager.go to understand the core blockchain interaction implementation.


Macroscope summarized 6322ffa. (Automatic summaries will resume when PR exits draft mode or review begins).

}

if options.Sync.Enable {
signer, err := blockchain.NewPrivateKeySigner(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will need to figure out a tidier way to get the Domain Separator into sync worker

Copy link
Contributor

@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: 4

🧹 Nitpick comments (3)
pkg/server/server.go (1)

190-193: Consider caching domain separator to avoid repeated blockchain calls.

The domain separator is fetched from the blockchain during every server startup. If this value is expected to be static, consider caching it to improve startup performance and reduce blockchain dependency.

Since the domain separator typically doesn't change frequently, you might want to verify if caching is already implemented in the ReportsManager or add startup-time caching to reduce blockchain calls.

pkg/blockchain/reportsManager_test.go (1)

37-49: Good test coverage for domain separator functionality.

The test verifies both the basic functionality (32-byte domain separator) and caching behavior (consistent results across calls). This covers the critical path for domain separator retrieval.

Consider adding error case testing:

+func TestDomainSeparatorError(t *testing.T) {
+	// Test with invalid RPC URL to verify error handling
+	logger := testutils.NewLog(t)
+	signer, err := blockchain.NewPrivateKeySigner(
+		testutils.GetPayerOptions(t).PrivateKey,
+		1, // Invalid chain ID
+	)
+	require.NoError(t, err)
+
+	client, err := blockchain.NewClient(t.Context(), "http://invalid-url")
+	require.Error(t, err) // Should fail to connect
+}
pkg/blockchain/reportsManager.go (1)

70-74: Consider reducing log verbosity.

Logging the entire report and signatures could be verbose in production. Consider logging only key fields or using debug level.

-			r.log.Info(
+			r.log.Debug(
 				"submitting report",
-				zap.Any("report", report),
-				zap.Any("signatures", signatures),
+				zap.Uint32("originator_node_id", report.OriginatorNodeID),
+				zap.Uint64("start_sequence_id", report.StartSequenceID),
+				zap.Uint64("end_sequence_id", report.EndSequenceID),
+				zap.Int("signature_count", len(signatures)),
 			)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 70c8ada and 6322ffa.

📒 Files selected for processing (15)
  • pkg/blockchain/interface.go (1 hunks)
  • pkg/blockchain/reportsAdmin.go (0 hunks)
  • pkg/blockchain/reportsManager.go (1 hunks)
  • pkg/blockchain/reportsManager_test.go (1 hunks)
  • pkg/config/options.go (1 hunks)
  • pkg/payerreport/report.go (2 hunks)
  • pkg/payerreport/report_test.go (1 hunks)
  • pkg/payerreport/store.go (1 hunks)
  • pkg/payerreport/workers/integration_test.go (11 hunks)
  • pkg/payerreport/workers/submitter.go (4 hunks)
  • pkg/registrant/registrant.go (1 hunks)
  • pkg/server/server.go (2 hunks)
  • pkg/server/server_test.go (4 hunks)
  • pkg/testutils/config.go (2 hunks)
  • pkg/testutils/server/server.go (1 hunks)
💤 Files with no reviewable changes (1)
  • pkg/blockchain/reportsAdmin.go
🧰 Additional context used
🧬 Code Graph Analysis (5)
pkg/server/server_test.go (2)
pkg/testutils/config.go (2)
  • NewContractsOptions (28-49)
  • BLOCKCHAIN_RPC_URL (10-10)
pkg/testutils/server/server.go (1)
  • NewTestServer (19-53)
pkg/payerreport/workers/submitter.go (2)
pkg/blockchain/interface.go (1)
  • PayerReportsManager (54-66)
pkg/payerreport/interface.go (1)
  • IPayerReportStore (37-68)
pkg/payerreport/store.go (1)
pkg/payerreport/report.go (1)
  • BuildPayerReportID (141-170)
pkg/payerreport/report_test.go (1)
pkg/payerreport/report.go (1)
  • BuildPayerReportID (141-170)
pkg/blockchain/interface.go (2)
pkg/payerreport/report.go (3)
  • PayerReportWithStatus (104-113)
  • PayerReport (69-83)
  • ReportID (63-63)
pkg/db/queries/models.go (1)
  • PayerReport (65-76)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test (Node)
  • GitHub Check: Upgrade Tests
  • GitHub Check: Code Review
🔇 Additional comments (26)
pkg/payerreport/store.go (1)

259-259: LGTM: Function call updated to use exported version.

The change from buildPayerReportID to BuildPayerReportID correctly aligns with the function being exported in pkg/payerreport/report.go. This enables external access to the report ID building functionality, which appears necessary for the blockchain integration.

pkg/config/options.go (1)

52-52: LGTM: Well-structured configuration addition.

The new PayerReportManagerAddress field follows the established pattern for contract address configuration. The naming convention, environment variable, and description are consistent with other contract address fields in the struct.

pkg/payerreport/report.go (2)

141-141: LGTM: Function correctly exported.

The function buildPayerReportID is properly renamed to BuildPayerReportID to make it publicly accessible. This follows Go naming conventions for exported functions and enables external packages to access the report ID building functionality.


179-179: LGTM: Internal call updated consistently.

The function call is correctly updated to use the new exported name BuildPayerReportID, maintaining consistency with the function rename.

pkg/registrant/registrant.go (1)

123-123:

Details

❓ Verification inconclusive

Verify cryptographic signature change across the system.

The signing logic has been changed from signing a hash digest (likely involving reportID and domainSeparator) to signing the raw reportID bytes directly. This is a significant cryptographic behavior change that could break signature validation in other components.

Please verify that all signature validation logic has been updated to match this new signing approach:

Also note that the domainSeparator parameter is still present in the method signature but is no longer used in the signing operation, which could be confusing.


🏁 Script executed:

#!/bin/bash
# Description: Search for signature validation logic related to payer report attestations
# Expected: All validation should expect raw reportID signatures, not hash digests

# Search for signature verification patterns
echo "=== Searching for signature verification patterns ==="
rg -A 10 -B 5 "VerifySignature|crypto\.VerifySignature|secp256k1\.VerifySignature" --type go

echo "=== Searching for payer report attestation verification ==="
rg -A 10 -B 5 "PayerReportAttestation.*[Vv]erif" --type go

echo "=== Searching for reportID signature handling ==="
rg -A 5 -B 5 "reportID.*[Ss]ignature|[Ss]ignature.*reportID" --type go

Length of output: 1458


🏁 Script executed:

#!/bin/bash
# Locate actual implementation of SignPayerReportAttestation to verify domainSeparator usage
echo "=== Searching for SignPayerReportAttestation implementation ==="
rg -n -A 10 -B 2 "SignPayerReportAttestation" --type go

Length of output: 8594


Verify downstream signature validation and domain separation usage

No verification routines were found in this repo that consume the new raw-reportID signature, and the domainSeparator parameter is still present yet unused in SignPayerReportAttestation. This is a breaking change in cryptographic guarantees—ensure all consumers and validators of these signatures have been updated accordingly.

Please review and update the following locations as needed:

  • pkg/registrant/registrant.go (around line 123): sig, err := r.sign(reportID[:]) now ignores domainSeparator.
  • pkg/registrant/interface.go: consider removing or re-using the domainSeparator parameter.
  • pkg/payerreport/workers/attestation.go: downstream attestation builder still passes w.domainSeparator but validation code is absent here.
  • Tests in pkg/payerreport/workers/attestation_test.go: no checks on the actual bytes being signed or domain separation—add or adjust mocks to reflect the new behavior.

Ensure that any external services or smart contracts verifying these signatures expect the raw reportID payload (and domain separation, if intended) rather than the previous hash digest.

pkg/testutils/config.go (2)

10-10: LGTM! Port change follows Ethereum standards.

The port change from 7545 to 8545 aligns with the standard HTTP-RPC port for Ethereum development nodes.


45-45: LGTM! Configuration properly supports new blockchain integration.

The addition of PayerReportManagerAddress to the settlement chain configuration correctly supports the new ReportsManager implementation that interacts with the Payer Report Manager smart contract.

pkg/payerreport/report_test.go (1)

104-111: LGTM! Correctly uses the newly exported function.

The change from buildPayerReportID to BuildPayerReportID properly reflects the function being made public to support blockchain integration where report ID computation is needed externally.

pkg/server/server_test.go (3)

47-47: LGTM! Proper migration to blockchain-backed configuration.

The replacement of random domain separator generation with contractsOptions enables dynamic retrieval from the blockchain reports manager, supporting more realistic testing scenarios.


56-56: LGTM! Consistent parameter update across test server creation.

Both test server instances correctly use the new contractsOptions parameter, maintaining consistency with the updated NewTestServer signature.

Also applies to: 65-65


162-162: LGTM! Test function consistently updated.

The TestReadOwnWritesGuarantee function properly follows the same pattern as TestCreateServer, using contractsOptions for test server creation.

Also applies to: 171-171

pkg/blockchain/interface.go (3)

54-54: LGTM! Interface rename better reflects its purpose.

The rename from PayerReportsAdmin to PayerReportsManager more accurately describes the interface's role in managing payer reports rather than just administering them.


56-60: LGTM! GetReport method enables blockchain report retrieval.

The GetReport method properly supports querying the blockchain for existing reports by originator node ID and index, which is essential for verification and synchronization with on-chain data.


62-66: LGTM! GetReportID method supports report ID computation.

The GetReportID method enables computing report IDs from PayerReportWithStatus, supporting consistency verification between local and on-chain report representations.

pkg/testutils/server/server.go (2)

26-26: Good improvement: Using ContractsOptions for better configuration.

The change from a hardcoded domain separator to contractsOptions provides better flexibility and aligns with the dynamic blockchain approach implemented in the main server.


30-31: Excellent: Using test context for proper lifecycle management.

Using t.Context() instead of context.Background() ensures the server is properly canceled when the test completes, and using contractsOptions maintains consistency with the new blockchain integration approach.

pkg/payerreport/workers/submitter.go (1)

24-24: Interface update aligns with blockchain integration.

The change from PayerReportsAdmin to PayerReportsManager is consistent with the broader refactoring to use the new blockchain-backed reports manager. The interface provides the same SubmitPayerReport method, ensuring compatibility.

Also applies to: 32-32, 42-42

pkg/blockchain/reportsManager_test.go (1)

12-35: Well-structured test helper function.

The buildReportsManager helper properly sets up all required dependencies including logger, Anvil test node, contracts options, signer, and client. This provides a realistic test environment for blockchain interactions.

pkg/payerreport/workers/integration_test.go (5)

9-36:


49-52: LGTM!

The scaffold struct additions properly support the blockchain integration.


136-247: LGTM!

The modifications properly integrate the blockchain components into the test setup.


293-325: LGTM!

Excellent test for verifying report ID consistency between local and blockchain storage.


434-459: LGTM!

The submitter worker integration completes the end-to-end test flow, properly verifying that reports are submitted to and retrievable from the blockchain.

pkg/blockchain/reportsManager.go (3)

106-124: LGTM!

Clean implementation with proper error handling for report retrieval.


126-137: LGTM!

Simple and correct implementation for retrieving report IDs from the contract.


153-177: LGTM!

Well-structured helper function that cleanly transforms on-chain data to the local format.

}

func (w *SubmitterWorker) submitReports(ctx context.Context) error {
func (w *SubmitterWorker) SubmitReports(ctx context.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify if method export is intentional.

The method was renamed from submitReports to SubmitReports (exported). Ensure this export is intentional and doesn't expose internal implementation details inappropriately.


🏁 Script executed:

#!/bin/bash
# Description: Check if the exported SubmitReports method is used outside the package
# Expected: Find usage patterns to verify if export is needed

rg -A 3 "SubmitReports" --type go

Length of output: 915


Confirm Export Intent for SubmitReports

The SubmitReports method is only referenced in:

  • pkg/payerreport/workers/submitter.go (self-call)
  • pkg/payerreport/workers/integration_test.go

No external packages invoke this method.
If you don’t intend to expose it beyond this package, consider reverting it to an unexported submitReports. If your integration tests live in a separate _test package and rely on it, keeping it exported is acceptable.

Please verify your intended public API before merging.

func (w *SubmitterWorker) SubmitReports(ctx context.Context) error {
    // …
}
🤖 Prompt for AI Agents
In pkg/payerreport/workers/submitter.go at line 70, the method SubmitReports was
changed from unexported to exported but is only used internally and in
integration tests. Confirm if you want this method accessible outside the
package; if not, rename it back to submitReports to keep it unexported. If your
integration tests require access and are in a separate _test package, keeping it
exported is fine. Adjust the method name accordingly based on your intended API
exposure.

@neekolas neekolas force-pushed the 05-27-talk_to_the_blockchain branch from 6322ffa to d075523 Compare May 29, 2025 15:22
) (*payerreport.PayerReport, error) {
report, err := r.reportManagerContract.GetPayerReport(&bind.CallOpts{
Context: ctx,
}, originatorNodeID, big.NewInt(int64(index)))
Copy link

Choose a reason for hiding this comment

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

The conversion of index from uint64 to int64 when calling big.NewInt may overflow for values greater than math.MaxInt64, leading to negative results and unexpected behavior in GetPayerReport. Consider using new(big.Int).SetUint64(index) to correctly support the full uint64 range.

- 	}, originatorNodeID, big.NewInt(int64(index)))
+ 	}, originatorNodeID, new(big.Int).SetUint64(index))

🚀 Reply to ask Macroscope to explain or update this suggestion.

👍 Helpful? React to give us feedback.

@neekolas neekolas force-pushed the 05-27-talk_to_the_blockchain branch from d075523 to 405462a Compare June 2, 2025 21:21
// The smart contract expects the signature to use the legacy EIP-155 recovery ID
// which is the last byte of the signature. We need to add 27 to the last byte
// to get the correct recovery ID.
sig := make([]byte, len(signature.Signature))
Copy link

Choose a reason for hiding this comment

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

The code in the loop over report.AttestationSignatures accesses sig[64] without first ensuring that the original signature.Signature slice is at least 65 bytes long. If a shorter slice were ever provided, this would cause a runtime panic. Consider adding a guard—checking len(signature.Signature) >= 65—and returning an error if the signature is unexpectedly short before modifying its recovery ID.

+            if len(signature.Signature) < 65 {
+                return nil, fmt.Errorf("invalid signature length for node %d: got %d bytes", signature.NodeID, len(signature.Signature))
+            }

🚀 Reply to ask Macroscope to explain or update this suggestion.

👍 Helpful? React to give us feedback.

@neekolas neekolas force-pushed the 05-27-talk_to_the_blockchain branch from 405462a to f134a52 Compare June 2, 2025 21:42
@neekolas neekolas force-pushed the 05-16-use_real_merkle_generator branch 2 times, most recently from 18200e3 to f98e9fb Compare June 2, 2025 21:47
@neekolas neekolas force-pushed the 05-27-talk_to_the_blockchain branch from f134a52 to a8afe7e Compare June 2, 2025 21:47
@neekolas neekolas force-pushed the 05-16-use_real_merkle_generator branch from f98e9fb to b76b9b9 Compare June 2, 2025 22:11
@neekolas neekolas force-pushed the 05-27-talk_to_the_blockchain branch from a8afe7e to b3265fd Compare June 2, 2025 22:11
@neekolas neekolas closed this Jun 17, 2025
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