Pr02: state management#61
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.
This PR implements the complete state storage and retrieval layer for Vaults V2. Key features: - CRUD operations for all vault state entities: - Vault configuration and parameters - User shares and positions - Remote positions (cross-chain) - Inflight funds tracking - Withdrawal queue management - Cross-chain routes - Oracle configuration - NAV tracking and snapshots - Deposit velocity and limits - Iterator support for efficient state queries - Proper key prefixes and storage organization (based on types/vaults/v2/keys.go) - Type-safe getters and setters This provides the foundation for all business logic in subsequent PRs. Depends on: PR #1 (Protocol Buffers)
…helpers - Add detailed docs for getDepositVelocity/setDepositVelocity (internal helpers) - Clarify difference between internal (returns found bool) vs public (simpler error handling) - Document recordUserDeposit, incrementBlockDeposit, getBlockDepositVolume helpers - Explain when to use internal vs public APIs - Cross-reference related functions (e.g., PruneUserDepositHistory) This makes the codebase more maintainable by clearly explaining: 1. Why both private and public versions exist 2. When to use each version 3. What each helper function does in the deposit tracking system
|
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 |
jtieri
left a comment
There was a problem hiding this comment.
I only made it through a little over half of the code in state_vaults_v2.go but wanted to submit what review I had. I should be able to finish tomorrow, or possibly later tonight if I have some free time.
|
|
||
| // GetVaultsV2UserPosition returns the position for the supplied account. The | ||
| // boolean flag indicates whether the position existed in state. | ||
| func (k *Keeper) GetVaultsV2UserPosition(ctx context.Context, address sdk.AccAddress) (vaultsv2.UserPosition, bool, error) { |
There was a problem hiding this comment.
the boolean feels redundant here since we know the position existed in state based on whether or not we get a non-zero value returned for UserPosition
| } | ||
|
|
||
| // GetVaultsV2RemotePosition fetches a remote position entry by id. | ||
| func (k *Keeper) GetVaultsV2RemotePosition(ctx context.Context, id uint64) (vaultsv2.RemotePosition, bool, error) { |
There was a problem hiding this comment.
the boolean feels redundant here as well for the same reason.
| } | ||
|
|
||
| // GetVaultsV2RemotePositionChainID returns the chain identifier associated with a remote position. | ||
| func (k *Keeper) GetVaultsV2RemotePositionChainID(ctx context.Context, id uint64) (uint32, bool, error) { |
| } | ||
|
|
||
| // GetVaultsV2CrossChainRoute fetches a cross-chain route configuration by identifier. | ||
| func (k *Keeper) GetVaultsV2CrossChainRoute(ctx context.Context, id uint32) (vaultsv2.CrossChainRoute, bool, error) { |
| } | ||
|
|
||
| // GetVaultsV2EnrolledOracle retrieves an enrolled oracle configuration. | ||
| func (k *Keeper) GetVaultsV2EnrolledOracle(ctx context.Context, oracleID string) (vaultsv2.EnrolledOracle, bool, error) { |
Builds on top of #60
This PR implements the complete state storage and retrieval layer for Vaults V2.
Key Features:
CRUD operations for all vault state entities (vault config, user shares, remote positions, inflight funds, withdrawal queue, cross-chain routes, oracle config, NAV tracking)
Iterator support for efficient state queries
Type-safe getters and setters
We don't expect this PR to build on it's own it heavily depends on logic that will come in the next PR.