Skip to content

Dev - #254

Merged
matteoettam09 merged 10 commits into
mainfrom
dev
Aug 11, 2026
Merged

Dev#254
matteoettam09 merged 10 commits into
mainfrom
dev

Conversation

@matteoettam09

@matteoettam09 matteoettam09 commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added encrypted vault creation and management.
    • Added HPKE-encrypted portfolio and strategist-intent storage.
    • Updated liquidity processing for transparent and encrypted vaults.
    • Added encrypted vault configuration, factory controls, ciphertext validation, and related events.
    • Released version 2.6.0 with HPKE support.
  • Tests

    • Added coverage for encrypted vaults, HPKE encryption/decryption, orchestration, authorization, upgrades, and decommissioning.
  • Chores

    • Updated Codecov tooling.

matteoettam09 and others added 5 commits August 9, 2026 23:03
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5 to 7.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v5...v7)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 20e200ca-a67f-4e30-a85f-b52e8b7f2cd0

📥 Commits

Reviewing files that changed from the base of the PR and between 0f04317 and c7c784f.

📒 Files selected for processing (1)
  • contracts/interfaces/IOrionVault.sol
💤 Files with no reviewable changes (1)
  • contracts/interfaces/IOrionVault.sol

📝 Walkthrough

Walkthrough

The protocol adds upgradeable encrypted vaults, HPKE configuration, ciphertext-based epoch processing, and test utilities. The orchestrator includes encrypted vaults in epochs, hashes ciphertext state, processes structured vault states, and applies encrypted decommissioning rules. The CI workflow updates the Codecov action.

Changes

Encrypted vault support

Layer / File(s) Summary
Encrypted vault contracts and configuration
contracts/interfaces/*, contracts/OrionConfig.sol, contracts/factories/EncryptedVaultFactory.sol, contracts/vaults/OrionEncryptedVault.sol, contracts/libraries/EventsLib.sol
Adds encrypted-vault interfaces, configuration, factory deployment, ciphertext storage, intent submission, state updates, and confidential events.
Encrypted epoch and vault-state processing
contracts/LiquidityOrchestrator.sol
Includes encrypted vaults in epoch lists, hashes encrypted portfolio and intent data, accepts structured VaultState values, updates encrypted state, and checks encrypted decommissioning completion.
HPKE encoding and interoperability validation
package.json, test/helpers/orionHpke.ts, test/OrionHpke.test.ts, test/OrionEncryptedVaultHpke.test.ts, test/vectors/hpke-orion-v1.json
Adds Orion HPKE helpers, dependencies, test vectors, encryption and decryption tests, key derivation tests, and vault integration tests.
Orchestrator test support and feature coverage
contracts/test/*, test/helpers/loPerformPayload.ts, test/LiquidityOrchestratorEncrypted.test.ts, test/EncryptedVaultFactoryOrchestratorBranches.test.ts, test/*Orchestrator*.test.ts, test/VaultDecommissioning.test.ts
Adds dedicated harnesses and validates encrypted vault creation, ordering, commitments, writeback, decommissioning, branch behavior, and structured operation inputs.

CI coverage action update

Layer / File(s) Summary
Codecov workflow update
.github/workflows/ci.yml
Changes the coverage upload action from v5 to v7.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Owner
  participant OrionConfig
  participant EncryptedVaultFactory
  participant OrionEncryptedVault
  participant LiquidityOrchestrator
  Owner->>OrionConfig: configure encrypted factory and HPKE key
  EncryptedVaultFactory->>OrionEncryptedVault: deploy and initialize vault proxy
  EncryptedVaultFactory->>OrionConfig: register encrypted vault
  OrionEncryptedVault->>OrionEncryptedVault: store strategist intent ciphertext
  LiquidityOrchestrator->>OrionEncryptedVault: read portfolio and intent ciphertext
  LiquidityOrchestrator->>LiquidityOrchestrator: build epoch commitment
  LiquidityOrchestrator->>OrionEncryptedVault: write portfolio ciphertext and total assets
Loading

Possibly related PRs

Poem

A rabbit guards each ciphertext byte,
Encrypted vaults join the flight.
HPKE keys and epochs align,
State writebacks follow the design.
Codecov hops to version seven—
Tests raise carrots up to heaven!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "Dev" is too vague and does not identify the encrypted-vault, HPKE, or CI changes in this pull request. Replace "Dev" with a concise title that states the primary change, such as "Add encrypted vault support with HPKE integration".
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

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

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@matteoettam09
matteoettam09 marked this pull request as ready for review August 10, 2026 17:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
contracts/LiquidityOrchestrator.sol (1)

575-608: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Commit the vault type inside the leaf.

The leaf preimage mixes two different hashing schemes into the same portfolioHash and intentHash positions. For an encrypted vault the preimage is a raw ciphertext. For a transparent vault it is abi.encode of parallel arrays. The leaf carries no tag that records which scheme applied.

The prover must therefore learn the vault type from state that sits outside the commitment. Add the type to the leaf so the commitment binds the interpretation of both hashes.

♻️ Proposed change
             bytes32 portfolioHash;
             bytes32 intentHash;
-            if (config.isEncryptedVault(vaultAddress)) {
+            bool isEncrypted = config.isEncryptedVault(vaultAddress);
+            if (isEncrypted) {
                 IOrionEncryptedVault encryptedVault = IOrionEncryptedVault(vaultAddress);
                 portfolioHash = keccak256(encryptedVault.getPortfolio());
                 intentHash = keccak256(encryptedVault.getIntent());
             } else {
                 IOrionTransparentVault transparentVault = IOrionTransparentVault(vaultAddress);
                 (address[] memory portfolioTokens, uint256[] memory portfolioShares) = transparentVault.getPortfolio();
                 (address[] memory intentTokens, uint32[] memory intentWeights) = transparentVault.getIntent();
                 portfolioHash = keccak256(abi.encode(portfolioTokens, portfolioShares));
                 intentHash = keccak256(abi.encode(intentTokens, intentWeights));
             }
 
             bytes32 vaultLeaf = keccak256(
                 abi.encode(
                     vaultAddress,
+                    isEncrypted,
                     uint8(feeModel.feeType),

This changes the commitment preimage. Update the off-chain prover to match.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/LiquidityOrchestrator.sol` around lines 575 - 608, Update the vault
leaf preimage in the loop building vaultLeaf to include an explicit vault-type
discriminator alongside portfolioHash and intentHash, using distinct values for
encrypted and transparent vaults. Ensure the discriminator is derived from
config.isEncryptedVault(vaultAddress) and included in the committed abi.encode
data, then update the off-chain prover’s leaf construction to use the same field
and encoding.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Line 58: Update the Codecov step’s codecov/codecov-action reference to an
immutable commit SHA instead of the mutable v7 tag, preserving the existing
action configuration.

In `@contracts/factories/EncryptedVaultFactory.sol`:
- Around line 61-90: Update the shared __OrionVault_init initializer to reject
strategist_ == address(0) with the existing invalid-arguments error, alongside
its feeType_ validation. Ensure all vault creation paths using this initializer
enforce a nonzero strategist before assigning it.

In `@contracts/LiquidityOrchestrator.sol`:
- Around line 982-994: Update the encrypted branch of the decommissioning check
in the vault finalization flow to require both an empty portfolioCiphertext and
vaultState.finalTotalAssets == 0 before setting portfolioLiquidated true. Leave
the transparent-branch conditions and surrounding request checks unchanged.

In `@contracts/OrionConfig.sol`:
- Around line 280-286: Update setHpkePublicKey in OrionConfig to require
isSystemIdle() alongside onlyOwner before accepting the key, preserving the
existing nonzero validation. Add the proposed HpkePublicKeyUpdated event to
EventsLib and emit it after successfully storing the new key, following the
setGuardian event pattern.

In `@contracts/test/LiquidityOrchestratorEpochEndHarness.sol`:
- Around line 44-71: Align h_advancePvoIndexLikeProcessMinibatch with production
by reusing internal helpers for PVO completion and epoch-end handling. Extract
the shared i1 clamping and _nextUpdateTime update into a production helper used
by both performUpkeep and the harness, and extract the inline epoch-end sequence
into another helper used by both paths, replacing _maybeEpochEndAfterPvo while
preserving existing state resets, failed-token cleanup, event emission, and
epoch increment.

In `@contracts/test/MaliciousManagerRemovalVault.sol`:
- Around line 7-10: Rename the local IOwnable2Step interface to an
accept-ownership-specific name containing only acceptOwnership. Update
acceptOwnership() to cast config through the renamed interface, and change
triggerRemoveManager() and overrideIntentForDecommissioning() to call
config.removeWhitelistedManager(manager) directly through IOrionConfig.

In `@contracts/vaults/OrionEncryptedVault.sol`:
- Around line 70-80: Mark the base OrionVault.overrideIntentForDecommissioning
hook as virtual, then override it in OrionEncryptedVault with external override
onlyConfig; set isDecommissioning to true and delete _intentCiphertext so
getIntent no longer exposes stale data during decommissioning.

In `@test/EncryptedVaultFactoryOrchestratorBranches.test.ts`:
- Around line 49-53: Ensure all impersonated accounts are released after each
test. In test/EncryptedVaultFactoryOrchestratorBranches.test.ts lines 49-53,
track addresses enabled by impersonate and release them in an afterEach hook. In
test/LiquidityOrchestratorEncrypted.test.ts lines 243-248 and 309-313, stop
impersonating loAddr after each updateVaultState call or use shared afterEach
cleanup; preserve the existing test behavior.

In `@test/LiquidityOrchestratorBufferAccrual.test.ts`:
- Around line 17-18: Remove the duplicated payload ABI definitions and reuse the
canonical helpers. In test/LiquidityOrchestratorBufferAccrual.test.ts:17-18,
delete STATES_STRUCT_TYPE and the local encodePerformPayload, importing both
from ./helpers/loPerformPayload; in
test/LiquidityOrchestratorEpochEnd.test.ts:55-67, delete local emptyVaultState
and import it from that helper; in
test/EncryptedVaultFactoryOrchestratorBranches.test.ts:30, delete local
PUBLIC_VALUES_TYPE and add it to the existing helper import.

In `@test/OrionEncryptedVault.test.ts`:
- Around line 226-232: Extend the updateVaultState test around
vault.connect(loSigner).updateVaultState to assert the
ConfidentialVaultStateUpdated event arguments, including the expected
currentSharePrice. Add a separate scenario that deposits shares before updating
the vault so totalSupply() is non-zero and the high-water-mark branch executes,
then verify both feeModel.highWaterMark and oldFeeModel.highWaterMark advance.
- Around line 150-170: Add an assertion in the `rejects stranger, empty,
too-short, and too-long blobs` test that
`strategist.submitIntent(ciphertextOfLength(maxLen))` succeeds, pairing the
existing `maxLen + 1` rejection with the inclusive upper-boundary acceptance.

---

Outside diff comments:
In `@contracts/LiquidityOrchestrator.sol`:
- Around line 575-608: Update the vault leaf preimage in the loop building
vaultLeaf to include an explicit vault-type discriminator alongside
portfolioHash and intentHash, using distinct values for encrypted and
transparent vaults. Ensure the discriminator is derived from
config.isEncryptedVault(vaultAddress) and included in the committed abi.encode
data, then update the off-chain prover’s leaf construction to use the same field
and encoding.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 87e2a85c-5149-4725-a36a-329aed7bef42

📥 Commits

Reviewing files that changed from the base of the PR and between 3a30943 and fdf365a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (27)
  • .github/workflows/ci.yml
  • contracts/LiquidityOrchestrator.sol
  • contracts/OrionConfig.sol
  • contracts/factories/EncryptedVaultFactory.sol
  • contracts/interfaces/ILiquidityOrchestrator.sol
  • contracts/interfaces/IOrionConfig.sol
  • contracts/interfaces/IOrionEncryptedVault.sol
  • contracts/libraries/EventsLib.sol
  • contracts/test/LiquidityOrchestratorEpochEndHarness.sol
  • contracts/test/LiquidityOrchestratorHarness.sol
  • contracts/test/LiquidityOrchestratorSlippageHarness.sol
  • contracts/test/MaliciousManagerRemovalVault.sol
  • contracts/vaults/OrionEncryptedVault.sol
  • package.json
  • test/EncryptedVaultFactoryOrchestratorBranches.test.ts
  • test/LiquidityOrchestratorBufferAccrual.test.ts
  • test/LiquidityOrchestratorEncrypted.test.ts
  • test/LiquidityOrchestratorEpochEnd.test.ts
  • test/LiquidityOrchestratorSlippage.test.ts
  • test/OrionEncryptedVault.test.ts
  • test/OrionEncryptedVaultHpke.test.ts
  • test/OrionHpke.test.ts
  • test/OrionVaultConfigOrchestratorBranches.test.ts
  • test/VaultDecommissioning.test.ts
  • test/helpers/loPerformPayload.ts
  • test/helpers/orionHpke.ts
  • test/vectors/hpke-orion-v1.json

Comment thread .github/workflows/ci.yml
Comment thread contracts/factories/EncryptedVaultFactory.sol
Comment thread contracts/LiquidityOrchestrator.sol
Comment thread contracts/OrionConfig.sol
Comment thread contracts/test/LiquidityOrchestratorEpochEndHarness.sol
Comment thread contracts/vaults/OrionEncryptedVault.sol
Comment thread test/EncryptedVaultFactoryOrchestratorBranches.test.ts
Comment thread test/LiquidityOrchestratorBufferAccrual.test.ts
Comment thread test/OrionEncryptedVault.test.ts
Comment thread test/OrionEncryptedVault.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
contracts/LiquidityOrchestrator.sol (1)

992-994: ⚠️ Potential issue | 🟠 Major

Require zero assets before encrypted decommissioning.

portfolioCiphertext.length == 0 does not prove that the vault has no assets. Lines 975-978 store the prover-supplied vaultState.finalTotalAssets in the encrypted vault. An empty ciphertext with a non-zero total can therefore satisfy portfolioLiquidated and call config.completeVaultDecommissioning at Line 1002.

Require both conditions before finalizing decommissioning.

Proposed fix
             if (encrypted) {
-                // Empty encrypted portfolio => liquidation complete.
-                portfolioLiquidated = vaultState.portfolioCiphertext.length == 0;
+                // Empty encrypted portfolio and zero assets => liquidation complete.
+                portfolioLiquidated =
+                    vaultState.portfolioCiphertext.length == 0 && vaultState.finalTotalAssets == 0;
             } else {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/LiquidityOrchestrator.sol` around lines 992 - 994, Update the
encrypted branch in the liquidation logic around portfolioLiquidated so
decommissioning is considered complete only when portfolioCiphertext is empty
and the stored finalTotalAssets represents zero assets. Preserve the existing
ciphertext check and require both conditions before
config.completeVaultDecommissioning can be reached.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@contracts/LiquidityOrchestrator.sol`:
- Around line 992-994: Update the encrypted branch in the liquidation logic
around portfolioLiquidated so decommissioning is considered complete only when
portfolioCiphertext is empty and the stored finalTotalAssets represents zero
assets. Preserve the existing ciphertext check and require both conditions
before config.completeVaultDecommissioning can be reached.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e185bf40-fdfe-4c77-b362-a308af648d89

📥 Commits

Reviewing files that changed from the base of the PR and between fdf365a and 0f04317.

📒 Files selected for processing (1)
  • contracts/LiquidityOrchestrator.sol

@matteoettam09
matteoettam09 merged commit 7d3c5b8 into main Aug 11, 2026
5 checks passed
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.

1 participant