PR 1 Add Vaults V2 protocol buffers and generated code#60
PR 1 Add Vaults V2 protocol buffers and generated code#60zmanian wants to merge 6 commits intonoble-assets:managed-vaultfrom
Conversation
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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
| coverage.html | ||
| go.work | ||
| go.work.sum | ||
| .gocache |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
| sigs.k8s.io/yaml v1.4.0 // indirect | ||
| ) | ||
|
|
||
| replace github.com/gogo/protobuf/grpc => ./third_party/github.com/gogo/protobuf/grpc |
| uint32 route_id = 2; | ||
|
|
||
| // Operation type (DEPOSIT_TO_POSITION, WITHDRAWAL_FROM_POSITION, etc.) | ||
| string operation_type = 3; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
| ]; | ||
|
|
||
| // Hours overdue | ||
| int64 hours_overdue = 4; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
| } | ||
|
|
||
| func RegisterInterfaces(registry codectypes.InterfaceRegistry) { | ||
| msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) |
There was a problem hiding this comment.
shouldn't we register the implementations for each of our custom message types that implement sdk.Msg?
| @@ -0,0 +1,6 @@ | |||
| module github.com/gogo/protobuf/grpc | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| var ackID uint64 | ||
| if len(body) == navPayloadWithAck { | ||
| ackID = binary.BigEndian.Uint64(body[105:113]) | ||
| } |
There was a problem hiding this comment.
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.
| // 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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
nit
| 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])) |
There was a problem hiding this comment.
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
| 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]) |
There was a problem hiding this comment.
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 .
|
|
||
| const SubmoduleName = "dollar/vaults/v2" | ||
|
|
||
| var ( |
There was a problem hiding this comment.
nit: could we sort/organize them? So, for example, to have all the remote_position indexes/keys together? 😄
|
Closing in favor of simplified 3-PR approach with updated implementation |
This PR establishes the API contract for the Vaults V2 system by adding:
Files included:
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.