Skip to content

Pr02: state management#61

Closed
zmanian wants to merge 4 commits intonoble-assets:managed-vaultfrom
iqlusioninc:pr/02-state-management
Closed

Pr02: state management#61
zmanian wants to merge 4 commits intonoble-assets:managed-vaultfrom
iqlusioninc:pr/02-state-management

Conversation

@zmanian
Copy link
Copy Markdown

@zmanian zmanian commented Oct 14, 2025

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.

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
@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.

Copy link
Copy Markdown
Member

@jtieri jtieri left a comment

Choose a reason for hiding this comment

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

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.

Comment thread keeper/state_vaults_v2.go

// 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) {
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.

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

Comment thread keeper/state_vaults_v2.go
}

// GetVaultsV2RemotePosition fetches a remote position entry by id.
func (k *Keeper) GetVaultsV2RemotePosition(ctx context.Context, id uint64) (vaultsv2.RemotePosition, bool, error) {
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.

the boolean feels redundant here as well for the same reason.

Comment thread keeper/state_vaults_v2.go
}

// GetVaultsV2RemotePositionChainID returns the chain identifier associated with a remote position.
func (k *Keeper) GetVaultsV2RemotePositionChainID(ctx context.Context, id uint64) (uint32, bool, error) {
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 thing here with the bool

Comment thread keeper/state_vaults_v2.go
}

// GetVaultsV2CrossChainRoute fetches a cross-chain route configuration by identifier.
func (k *Keeper) GetVaultsV2CrossChainRoute(ctx context.Context, id uint32) (vaultsv2.CrossChainRoute, bool, error) {
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

Comment thread keeper/state_vaults_v2.go
}

// GetVaultsV2EnrolledOracle retrieves an enrolled oracle configuration.
func (k *Keeper) GetVaultsV2EnrolledOracle(ctx context.Context, oracleID string) (vaultsv2.EnrolledOracle, bool, error) {
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

@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.

3 participants