Skip to content

feat: Implement UpdateVerifierRegistry - #199

Draft
snawaz wants to merge 1 commit into
snawaz/register-verifierfrom
snawaz/update-verifier
Draft

feat: Implement UpdateVerifierRegistry#199
snawaz wants to merge 1 commit into
snawaz/register-verifierfrom
snawaz/update-verifier

Conversation

@snawaz

@snawaz snawaz commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

⚠️ NOTE: Use notes like this to emphasize something important about the PR.

This could include other PRs this PR is built on top of; API breaking changes; reasons for why the PR is on hold; or anything else you would like to draw attention to.

Status Type ⚠️ Core Change Issue
Ready/Hold Feature/Bug/Tooling/Refactor/Hotfix Yes/No Link

Problem

What problem are you trying to solve?

Solution

How did you solve the problem?

Before & After Screenshots

Insert screenshots of example code output

BEFORE:
[insert screenshot here]

AFTER:
[insert screenshot here]

Other changes (e.g. bug fixes, small refactors)

Deploy Notes

Notes regarding deployment of the contained body of work. These should note any
new dependencies, new scripts, etc.

New scripts:

  • script : script details

New dependencies:

  • dependency : dependency details

Summary by CodeRabbit

  • New Features

    • Added support for updating the v2 verifier registry.
    • Verifiers can be added with a specified weight after required eligibility checks.
    • Registry revisions and verifier state are updated automatically.
  • Bug Fixes

    • Added validation for authorization, account configuration, duplicate entries, invalid weights, and unsupported actions.
  • Tests

    • Added integration coverage for successful additions and common validation failures.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds the v2 UpdateVerifierRegistry instruction with encoded add/remove arguments and a public instruction builder. Dispatch now invokes a processor that validates accounts, authority, PDAs, verifier bond state, and add parameters. Valid additions update the registry revision and entries, resize the registry PDA, and serialize the new state. Integration tests cover successful additions and invalid duplicate, authority, weight, and removal cases.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch snawaz/update-verifier

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@dlp-api/src/v2/instruction_builder/update_verifier_registry.rs`:
- Line 36: Replace the unwrap on args.encode() in update_verifier_registry()
with explicit error propagation by changing the builder to return
Result<Instruction, ...> and forwarding the encoding error; only preserve a
non-fallible return if a concrete invariant is enforced that guarantees encoding
cannot fail.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 83d9ce7d-9a49-4ea2-b237-0b99ae5e0964

📥 Commits

Reviewing files that changed from the base of the PR and between 067f5e3 and 52f8b3c.

📒 Files selected for processing (9)
  • dlp-api/src/v2/args/mod.rs
  • dlp-api/src/v2/args/update_verifier_registry.rs
  • dlp-api/src/v2/instruction.rs
  • dlp-api/src/v2/instruction_builder/mod.rs
  • dlp-api/src/v2/instruction_builder/update_verifier_registry.rs
  • src/v2/processor/bootstrap/mod.rs
  • src/v2/processor/bootstrap/update_verifier_registry.rs
  • src/v2/processor/mod.rs
  • tests/test_v2_update_verifier_registry.rs

],
data: [
DlpV2Instruction::UpdateVerifierRegistry.to_vec(),
args.encode().unwrap(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 4 'fn update_verifier_registry|args\.encode\(\)|trait Encodable|impl Encodable' dlp-api

Repository: magicblock-labs/delegation-program

Length of output: 4119


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== file outline =="
ast-grep outline dlp-api/src/v2/instruction_builder/update_verifier_registry.rs || true
echo
echo "== file contents =="
cat -n dlp-api/src/v2/instruction_builder/update_verifier_registry.rs
echo
echo "== search encode implementation =="
rg -n -C 5 'trait Encodable|impl.*Encodable|fn encode|UpdateVerifierRegistryArgs' src dlp-api || true

Repository: magicblock-labs/delegation-program

Length of output: 7911


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import re
from pathlib import Path

# Inspect the macro-derived encoding path as data
macro_files = list(Path(".").rglob("variable_offset_layout*"))
print("candidate macro files:")
for p in macro_files:
    print(f"  {p}")

for p in Path(".").rglob("*.rs"):
    text = p.read_text(errors="ignore")
    if "pub trait Encodable" in text or "fn encode" in text or "variable_offset_layout" in text:
        # print concise hits, not the whole file
        for i,line in enumerate(text.splitlines(),1):
            if "pub trait Encodable" in line or "fn encode" in line or "variable_offset_layout" in line:
                print(f"\n== {p}:{i} ==")
                print(line.strip())
                break

encodable_macro_path = next((p for p in list(Path(".").rglob("*.rs")) if "variable_offset" in p.name), None)
if encodable_macro_path and encodable_macro_path.name != "update_verifier_registry.rs":
    print("\n== full macro file excerpt ==")
    lines = encodable_macro_path.read_text(errors="ignore").splitlines()
    for i in range(1, min(len(lines),240)+1):
        print(f"{i:4}: {lines[i-1]}")
PY

Repository: magicblock-labs/delegation-program

Length of output: 633


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== dependency manifests for wheels =="
fd 'Cargo.toml' . -t f -x sh -c 'echo "-- $1"; sed -n "s/wheels[^[:space:]].*/line: /p" "$1" || true' sh {}
echo
echo "== lockfile references =="
if [ -f Cargo.lock ]; then rg -n -C 3 "name = \"wheels\"|source = \".*wheels|wheels" Cargo.lock; fi
echo
echo "== all encode/decode implementation snippets =="
python3 - <<'PY'
from pathlib import Path
for p in sorted(Path(".").rglob("*.rs")):
    txt = p.read_text(errors="ignore")
    hits = []
    for i,line in enumerate(txt.splitlines(),1):
        if any(s in line for s in ["impl Encodable for", "impl Decodable for", "fn encode", "fn decode", "variable_offset_layout", "encodable", "decodable"]):
            hits.append((i,line.strip()))
    if hits and "wheels" in txt:
        print(f"\n== {p} ==")
        for i,l in hits[:40]:
            print(f"{i}: {l}")
PY

Repository: magicblock-labs/delegation-program

Length of output: 1639


🌐 Web query:

wheels crate crates.io variable_offset_layout Encodable encode

💡 Result:

There is no widely known Rust crate named "wheels" that features "variable_offset_layout" or the "Encodable::encode" pattern as its core definition. The terminology you are inquiring about appears to stem from separate, unrelated Rust libraries: 1. Encoding and Serialization: The "Encodable" trait and its "encode" method are core components of the "encode" crate [1][2][3]. This crate is a toolbox for building encoders and serializers, drawing inspiration from parsing libraries like "nom" and "winnow" [2][3]. Its Encodable trait is defined as: fn encode(&self, encoder: &mut E) -> Result<, Self::Error>; 2. Memory and Data Layout: The term "variable_offset_layout" is not a standard crate name, but the concept of explicit memory and field layout in Rust is addressed by several specialized crates, including: - "memory-layout" [4]: Allows defining struct layouts similar to C#'s [StructLayout(LayoutKind.Explicit)] [4]. - "struct_layout" [5]: Provides a similar mechanism with a focus on internal arrays and specific offset annotations [5]. - "binary_layout" [6]: Provides a type-safe, zero-copy way to access binary data structures [6]. 3. Crates named "wheel": Several unrelated crates exist with "wheel" in their name, such as "wheel-rs" (a general utility library) [7][8], "uwheel" (for stream aggregation) [9], "logs-wheel" (for rolling log files) [10], and "bitwheel" (for high-performance timers) [11]. None of these are primarily associated with the encoding or layout features mentioned. If you are following a specific tutorial or project, you may be conflating these distinct libraries. To use the encoding functionality, you should refer to the "encode" crate documentation [2], and for explicit memory layout, you should investigate "memory-layout" or "binary_layout" [4][6].

Citations:


Replace the fallible encoding unwrap.

args.encode() can return an error, and update_verifier_registry() currently panics by using .unwrap(). Return a Result<Instruction, ...> from this builder, or document and enforce an invariant that makes encoding failure impossible.

🤖 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 `@dlp-api/src/v2/instruction_builder/update_verifier_registry.rs` at line 36,
Replace the unwrap on args.encode() in update_verifier_registry() with explicit
error propagation by changing the builder to return Result<Instruction, ...> and
forwarding the encoding error; only preserve a non-fallible return if a concrete
invariant is enforced that guarantees encoding cannot fail.

Source: Path instructions

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