Conversation
Summary of ChangesHello @sadiq1971, 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 significantly enhances the project's interaction capabilities with the Canton ledger by introducing a modular Go SDK. It provides dedicated clients for managing asset bridging, user identities, and CIP-56 compliant tokens, all built upon a robust low-level ledger client. Concurrently, it establishes a comprehensive and automated linting setup to ensure code quality and consistency across the Go codebase. Highlights
🧠 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. Changelog
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive Canton SDK for Go, organized into several packages: ledger, identity, token, bridge, client, and values. It also adds a golangci-lint configuration and updates the Makefile to support it. The changes are extensive and establish a solid foundation for the new SDK. My review focuses on ensuring the new linting configuration is correctly applied, improving the build process, and enhancing the testability and robustness of the new SDK code.
| - pkg/apidb | ||
| - pkg/auth | ||
| - pkg/canton | ||
| - pkg/config | ||
| - pkg/db | ||
| - pkg/ethereum | ||
| - pkg/ethrpc | ||
| - pkg/keys | ||
| - pkg/registration | ||
| - pkg/relayer | ||
| - pkg/service | ||
| - cmd | ||
| - internal |
There was a problem hiding this comment.
The paths in exclusions.paths are not anchored. As the comment on line 142 points out, this can lead to unintended exclusions. For example, pkg/canton will also match pkg/canton-sdk, effectively disabling linters for the new SDK code. The paths should be anchored to match only the intended directories.
- ^pkg/apidb/
- ^pkg/auth/
- ^pkg/canton/
- ^pkg/config/
- ^pkg/db/
- ^pkg/ethereum/
- ^pkg/ethrpc/
- ^pkg/keys/
- ^pkg/registration/
- ^pkg/relayer/
- ^pkg/service/
- ^cmd/
- ^internal/| - pkg/apidb | ||
| - pkg/auth | ||
| - pkg/canton | ||
| - pkg/config | ||
| - pkg/db | ||
| - pkg/ethereum | ||
| - pkg/ethrpc | ||
| - pkg/keys | ||
| - pkg/registration | ||
| - pkg/relayer | ||
| - pkg/service | ||
| - cmd | ||
| - internal |
There was a problem hiding this comment.
Similar to the linter exclusions, the paths in formatters.exclusions.paths are not anchored. This will cause formatters to be disabled for unintended paths, such as the new pkg/canton-sdk directory. Please anchor these regex patterns to ensure they only apply to the specified directories.
- ^pkg/apidb/
- ^pkg/auth/
- ^pkg/canton/
- ^pkg/config/
- ^pkg/db/
- ^pkg/ethereum/
- ^pkg/ethrpc/
- ^pkg/keys/
- ^pkg/registration/
- ^pkg/relayer/
- ^pkg/service/
- ^cmd/
- ^internal/|
|
||
| get_lint: | ||
| if [ ! -f ./bin/golangci-lint ]; then \ | ||
| curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v2.9.0; \ |
There was a problem hiding this comment.
The version v2.9.0 specified for golangci-lint appears to be invalid. golangci-lint versions follow a v1.x.y format, so this will likely cause the installation to fail. Please use a valid and recent version, for example v1.59.1.
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- v1.59.1; \
| if strings.Contains(strings.ToLower(err.Error()), "already") { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
The error check for an already completed withdrawal is brittle as it relies on string matching the error message. It's better to inspect the gRPC status code, as noted in the TODO on the preceding line. You can use google.golang.org/grpc/status and google.golang.org/grpc/codes to check for codes.AlreadyExists. A similar pattern is already used in pkg/canton-sdk/identity/client.go.
| if strings.Contains(strings.ToLower(err.Error()), "already") { | |
| return nil | |
| } | |
| s, ok := status.FromError(err) | |
| if ok && s.Code() == codes.AlreadyExists { | |
| return nil | |
| } |
| {Label: "fingerprint", Value: values.TextValue(req.Fingerprint)}, | ||
| {Label: "amount", Value: values.NumericValue(req.Amount)}, | ||
| {Label: "evmTxHash", Value: values.TextValue(req.EvmTxHash)}, | ||
| {Label: "eventTime", Value: values.TimestampValue(time.Now())}, |
There was a problem hiding this comment.
Using time.Now() directly in these encoding functions makes them non-deterministic and harder to test. Consider passing the timestamp as an argument to the functions, for example by adding an EventTime field to the request structs (e.g., CreatePendingDepositRequest). If the field is not set, you could then default to time.Now(). This change would improve testability for all encode* functions in this file.
| Fields: []*lapiv2.RecordField{ | ||
| {Label: "recipient", Value: values.PartyValue(req.RecipientParty)}, | ||
| {Label: "amount", Value: values.NumericValue(req.Amount)}, | ||
| {Label: "eventTime", Value: values.TimestampValue(time.Now())}, |
There was a problem hiding this comment.
Using time.Now() directly in these encoding functions makes them non-deterministic and harder to test. Consider passing the timestamp as an argument to the functions, for example by adding an EventTime field to the request structs (e.g., MintRequest). If the field is not set, you could then default to time.Now(). This change would improve testability for encodeIssuerMintArgs and encodeIssuerBurnArgs in this file.
Closes #95