Skip to content

PR 1 Add Vaults V2 protocol buffers and generated code#60

Closed
zmanian wants to merge 6 commits intonoble-assets:managed-vaultfrom
iqlusioninc:pr/01-protocol-buffers
Closed

PR 1 Add Vaults V2 protocol buffers and generated code#60
zmanian wants to merge 6 commits intonoble-assets:managed-vaultfrom
iqlusioninc:pr/01-protocol-buffers

Conversation

@zmanian
Copy link
Copy Markdown

@zmanian zmanian commented Oct 14, 2025

This PR establishes the API contract for the Vaults V2 system by adding:

  • Protocol buffer definitions for all Vaults V2 messages and queries
  • Generated Go code (pulsar and standard protobuf types)
  • Type definitions for cross-chain operations, NAV tracking, and oracle management
  • Updated go.mod dependencies for protobuf support

Files included:

  • proto/noble/dollar/vaults/v2/*.proto (8 proto files)
  • api/vaults/v2/*.go (13 generated files)
  • types/vaults/v2/*.go (13 generated files + codec/keys/errors)
  • go.mod updates
  • .gitignore updates

This is the foundation for all subsequent Vaults V2 implementation work.

Consists of minor changes to protobuf files. The NAV update payload and generated code.

This PR establishes the API contract for the Vaults V2 system by adding:

- Protocol buffer definitions for all Vaults V2 messages and queries
- Generated Go code (pulsar and standard protobuf types)
- Type definitions for cross-chain operations, NAV tracking, and oracle management
- Updated go.mod dependencies for protobuf support

Files included:
- proto/noble/dollar/vaults/v2/*.proto (8 proto files)
- api/vaults/v2/*.go (13 generated files)
- types/vaults/v2/*.go (13 generated files + codec/keys/errors)
- go.mod updates
- .gitignore updates

This is the foundation for all subsequent Vaults V2 implementation work.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 14, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@zmanian zmanian mentioned this pull request Oct 14, 2025
Comment thread .gitignore
coverage.html
go.work
go.work.sum
.gocache
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we need to add this to .gitignore? to the best of my knowledge we don't configure the project to use a build cache in the root of the directory so the location of the build cache should be system dependent and vary depending on what you have configured in the GOCACHE env var

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

My guess is GOCACHE was set in-line at some point when Zaki was working. Should we add globbing that will ignore it in any path?

Comment thread go.mod Outdated
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/gogo/protobuf/grpc => ./third_party/github.com/gogo/protobuf/grpc
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we need this replace?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We do not. Removing.

uint32 route_id = 2;

// Operation type (DEPOSIT_TO_POSITION, WITHDRAWAL_FROM_POSITION, etc.)
string operation_type = 3;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

didn't we decide to use an enum for the operation type in the previous PR dealing with protos?

uint32 route_id = 2;

// Previous status
string previous_status = 3;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i recall using enums for some sort of status in the previous PR as well, not sure if this is the same thing or not.

string previous_status = 3;

// New status
string new_status = 4;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here

];

// Hours overdue
int64 hours_overdue = 4;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i think previously hours_overdue was used in another Protobuf message but with type double. perhaps that is changed elsewhere in this PR but otherwise we should be consistent

string current_status = 6;

// Recommended action
string recommended_action = 7;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will this be some value taken from a predetermined set of actions or will it be some arbitrary string data that provides context to maintainers/operators? If it is the former then imo we should consider using an enum here to clearly define the available actions.

Comment thread types/vaults/v2/codec.go
}

func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shouldn't we register the implementations for each of our custom message types that implement sdk.Msg?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Added

@@ -0,0 +1,6 @@
module github.com/gogo/protobuf/grpc
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need this new go.mod file? I'm actually a bit confused as to why we need this third_party directory at all.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

protobuf/grpc isn't needed, I'm removing it.

the third_party/ directory is due to the hyperlane protos not being present in buf.build.

Comment on lines +70 to +73
var ackID uint64
if len(body) == navPayloadWithAck {
ackID = binary.BigEndian.Uint64(body[105:113])
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i'm not sure if it's documented somewhere but it could be worthwhile to make note somewhere that essentially 0 is an invalid value for an acknowledgement ID or is used to express the fact that an acknowledgement ID does not exist.

Comment on lines +117 to +121
// Whether user wants to receive yield for this deposit.
bool receive_yield = 3;

// Set to true when the deposit should override the current preference.
bool receive_yield_override = 4;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i'm not entirely sure to understand why we need to use 2 mandatory booleans instead of a single one but optional . Is there a specific technical reason?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe it is already planned to do it a future PR, but we should definitely have extensive unit tests around the parsing of the payload!

navPayloadSize = 105
navPayloadWithAck = 113
navUpdateMessageType = 0x01
navDecimalPrecision = int64(1_000_000_000_000_000_000) // 1e18 precision
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit

Suggested change
navDecimalPrecision = int64(1_000_000_000_000_000_000) // 1e18 precision
navDecimalPrecision = int64(1e18) // 1e18 precision


sharePriceBig := new(big.Int).SetBytes(body[33:65])
sharesHeldBig := new(big.Int).SetBytes(body[65:97])
timestamp := int64(binary.BigEndian.Uint64(body[97:105]))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We are casting a possible value > uint64 to an int64, which can lead to negative and non-sense values, especially as we don't validate the timestamp value here

Comment on lines +62 to +68
positionBig := new(big.Int).SetBytes(body[1:33])
if !positionBig.IsUint64() {
return NAVUpdatePayload{}, fmt.Errorf("position identifier exceeds uint64 range")
}

sharePriceBig := new(big.Int).SetBytes(body[33:65])
sharesHeldBig := new(big.Int).SetBytes(body[65:97])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not sure if we are planning to add validation in another place or in the contract, but we are not checking if the bytes are signed, and SetBytes(...) always casts to unsigned .

Comment thread types/vaults/v2/keys.go

const SubmoduleName = "dollar/vaults/v2"

var (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: could we sort/organize them? So, for example, to have all the remote_position indexes/keys together? 😄

@zmanian
Copy link
Copy Markdown
Author

zmanian commented Oct 23, 2025

Closing in favor of simplified 3-PR approach with updated implementation

@zmanian zmanian closed this Oct 23, 2025
@zmanian zmanian reopened this Oct 23, 2025
@g-luca g-luca closed this Apr 7, 2026
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.

4 participants