-
Notifications
You must be signed in to change notification settings - Fork 21
feat(fraud-proofs): Implement InitProtocolConfig #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7287dfc
1673c3c
735105a
70ae4cf
4020222
36942e5
60787bf
586a3e4
f2423fc
8b3c741
6f17d1c
1e65677
2e538ea
f725f00
77d6a7e
ceeefcf
67cf8f7
58336c6
becbdb4
3936e2a
7fa66c5
77a62b5
d922dc4
fab9eb6
03282f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ static_assertions = "1.1.0" | |
| strum = { version = ">=0.27", features = ["derive"] } | ||
| thiserror = { version = ">=1" } | ||
| serde = { version = "1.0.228", default-features = false, features = ["derive"] } | ||
| wheels = { path = "../../magicblock-wheels/rust/wheels" } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
dependency_path="$(cd dlp-api && realpath -m ../../magicblock-wheels/rust/wheels)"
printf 'Resolved wheels path: %s\n' "$dependency_path"
test -f "$dependency_path/Cargo.toml"Repository: magicblock-labs/delegation-program Length of output: 218 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' "Cargo deps around wheels:"
sed -n '45,58p' dlp-api/Cargo.toml 2>/dev/null || true
printf '%s\n' "Repository top-level entries:"
find . -maxdepth 2 -type d \( -name 'magicblock-wheels' -o -name 'dlp-api' -o -name 'wheels' \) 2>/dev/null | sort
printf '%s\n' "Manifest references to magicblock-wheels/wheels:"
rg -n "magicblock-wheels|wheels\s*=" .github dlp-api Cargo.toml . 2>/dev/null | head -200
printf '%s\n' "README/workflow hints for checkout/setup:"
sed -n '1,220p' README.md 2>/dev/null || true
find .github/workflows -type f -maxdepth 2 -print 2>/dev/null | sort | xargs -r -I{} sh -c 'echo "--- {}"; sed -n "1,220p" "{}"'Repository: magicblock-labs/delegation-program Length of output: 20908 Use a resolvable dependency for
🤖 Prompt for AI Agents |
||
|
|
||
| solana-pubkey-compat = { package = "solana-pubkey", version = "2.4", features = ["borsh", "bytemuck", "curve25519"] } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,222 +12,7 @@ use crate::{ | |
| validator_fees_vault_pda_from_validator, | ||
| }, | ||
| }; | ||
|
|
||
| // require true | ||
| #[macro_export] | ||
| macro_rules! require { | ||
| ($cond:expr, $error:expr) => {{ | ||
| if !$cond { | ||
| let expr = stringify!($cond); | ||
| pinocchio_log::log!("require!({}) failed.", expr); | ||
| return Err($error.into()); | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| // require (info.is_signer()) | ||
| #[macro_export] | ||
| macro_rules! require_signer { | ||
| ($info: expr) => {{ | ||
| if !$info.is_signer() { | ||
| pinocchio_log::log!("require_signer!({}): ", stringify!($info)); | ||
| $info.address().log(); | ||
| return Err(ProgramError::MissingRequiredSignature); | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| // require key1 == key2 | ||
| #[macro_export] | ||
| macro_rules! require_eq_keys { | ||
| ( $key1:expr, $key2:expr, $error:expr) => {{ | ||
| if !pinocchio::address::address_eq($key1, $key2) { | ||
| pinocchio_log::log!( | ||
| "require_eq_keys!({}, {}) failed: ", | ||
| stringify!($key1), | ||
| stringify!($key2) | ||
| ); | ||
| $key1.log(); | ||
| $key2.log(); | ||
| return Err($error.into()); | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| // require a == b | ||
| #[macro_export] | ||
| macro_rules! require_eq { | ||
| ( $val1:expr, $val2:expr, $error:expr) => {{ | ||
| if !($val1 == $val2) { | ||
| pinocchio_log::log!( | ||
| "require_eq!({}, {}) failed: {} == {}", | ||
| stringify!($val1), | ||
| stringify!($val2), | ||
| $val1, | ||
| $val2 | ||
| ); | ||
| return Err($error.into()); | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| // require a <= b | ||
| #[macro_export] | ||
| macro_rules! require_le { | ||
| ( $val1:expr, $val2:expr, $error:expr) => {{ | ||
| if !($val1 <= $val2) { | ||
| pinocchio_log::log!( | ||
| "require_le!({}, {}) failed: {} <= {}", | ||
| stringify!($val1), | ||
| stringify!($val2), | ||
| $val1, | ||
| $val2 | ||
| ); | ||
| return Err($error.into()); | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| // require a < b | ||
| #[macro_export] | ||
| macro_rules! require_lt { | ||
| ( $val1:expr, $val2:expr, $error:expr) => {{ | ||
| if !($val1 < $val2) { | ||
| pinocchio_log::log!( | ||
| "require_lt!({}, {}) failed: {} < {}", | ||
| stringify!($val1), | ||
| stringify!($val2), | ||
| $val1, | ||
| $val2 | ||
| ); | ||
| return Err($error.into()); | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| // require a >= b | ||
| #[macro_export] | ||
| macro_rules! require_ge { | ||
| ( $val1:expr, $val2:expr, $error:expr) => {{ | ||
| if !($val1 >= $val2) { | ||
| pinocchio_log::log!( | ||
| "require_ge!({}, {}) failed: {} >= {}", | ||
| stringify!($val1), | ||
| stringify!($val2), | ||
| $val1, | ||
| $val2 | ||
| ); | ||
| return Err($error.into()); | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| // require a > b | ||
| #[macro_export] | ||
| macro_rules! require_gt { | ||
| ( $val1:expr, $val2:expr, $error:expr) => {{ | ||
| if !($val1 > $val2) { | ||
| pinocchio_log::log!( | ||
| "require_gt!({}, {}) failed: {} > {}", | ||
| stringify!($val1), | ||
| stringify!($val2), | ||
| $val1, | ||
| $val2 | ||
| ); | ||
| return Err($error.into()); | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| #[macro_export] | ||
| macro_rules! require_n_accounts { | ||
| ( $accounts:expr, $n:literal) => {{ | ||
| match $accounts.len().cmp(&$n) { | ||
| core::cmp::Ordering::Less => { | ||
| pinocchio_log::log!( | ||
| "Need {} accounts, but got less ({}) accounts", | ||
| $n, | ||
| $accounts.len() | ||
| ); | ||
| return Err( | ||
| pinocchio::error::ProgramError::NotEnoughAccountKeys, | ||
| ); | ||
| } | ||
| core::cmp::Ordering::Equal => { | ||
| TryInto::<&[_; $n]>::try_into($accounts) | ||
| .map_err(|_| $crate::error::DlpError::InfallibleError)? | ||
| } | ||
| core::cmp::Ordering::Greater => { | ||
| pinocchio_log::log!( | ||
| "Need {} accounts, but got more ({}) accounts", | ||
| $n, | ||
| $accounts.len() | ||
| ); | ||
| return Err($crate::error::DlpError::TooManyAccountKeys.into()); | ||
| } | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| #[macro_export] | ||
| macro_rules! require_n_accounts_with_optionals { | ||
| ( $accounts:expr, $n:literal) => {{ | ||
| match $accounts.len().cmp(&$n) { | ||
| core::cmp::Ordering::Less => { | ||
| pinocchio_log::log!( | ||
| "Need {} accounts, but got less ({}) accounts", | ||
| $n, | ||
| $accounts.len() | ||
| ); | ||
| return Err( | ||
| pinocchio::error::ProgramError::NotEnoughAccountKeys, | ||
| ); | ||
| } | ||
| _ => { | ||
| let (exact, optionals) = $accounts.split_at($n); | ||
|
|
||
| ( | ||
| TryInto::<&[_; $n]>::try_into(exact).map_err(|_| { | ||
| $crate::error::DlpError::InfallibleError | ||
| })?, | ||
| optionals, | ||
| ) | ||
| } | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| #[macro_export] | ||
| macro_rules! require_some { | ||
| ($option:expr, $error:expr) => {{ | ||
| match $option { | ||
| Some(val) => val, | ||
| None => return Err($error.into()), | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| /// | ||
| /// require_owned_by( | ||
| /// info: &AccountView, | ||
| /// owner: &Address | ||
| /// ) -> Result<(), ProgramError> | ||
| /// | ||
| #[macro_export] | ||
| macro_rules! require_owned_by { | ||
| ($info: expr, $owner: expr) => {{ | ||
| if !address_eq(unsafe { $info.owner() }, $owner) { | ||
| pinocchio_log::log!( | ||
| "require_owned_by!({}, {})", | ||
| stringify!($info), | ||
| stringify!($owner) | ||
| ); | ||
| $info.address().log(); | ||
| $owner.log(); | ||
| return Err(ProgramError::InvalidAccountOwner); | ||
| } | ||
| }}; | ||
| } | ||
| use wheels::require_eq_keys; | ||
|
|
||
| /// | ||
| /// require_initialized_pda( | ||
|
|
@@ -266,7 +51,7 @@ macro_rules! require_initialized_pda { | |
| return Err(ProgramError::InvalidSeeds); | ||
| } | ||
|
|
||
| require_owned_by!($info, $program_id); | ||
| wheels::require_owned_by!($info, $program_id); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Confirm which crates expand these macros and whether each declares a `wheels` dependency.
set -uo pipefail
echo "== macro export attributes in requires.rs =="
rg -n -B2 'macro_rules! require_initialized_pda' dlp-api/src/requires.rs
echo "== call sites of the exported macros =="
rg -n 'require_initialized_pda(_fast)?!' -g '!target/**'
echo "== bare wheels:: paths inside macro bodies =="
rg -n 'wheels::' -g '*.rs' -g '!target/**'
echo "== wheels dependency per manifest =="
fd -t f 'Cargo.toml' -g '!target/**' --exec sh -c 'echo "--- $1"; rg -n "wheels" "$1" || echo "(no wheels dep)"' _ {}Repository: magicblock-labs/delegation-program Length of output: 398 🏁 Script executed: #!/bin/bash
set +e
echo "== relevant macro definitions =="
sed -n '1,105p' dlp-api/src/requires.rs
echo "== all related macro references =="
rg -n -i 'require[_-]?initialized|initialized[_-]?pda' . -g '*.rs' -g '!target/**'
echo "== exported macro usage forms =="
rg -n 'require_initialized_pda|require_initialized_pda_fast' . -g '!target/**'
echo "== manifests =="
find . -name Cargo.toml -not -path './target/*' -print
echo "== wheels references in manifests =="
for f in $(find . -name Cargo.toml -not -path './target/*'); do
echo "--- $f"
rg -n '(^|[[:space:]])wheels([[:space:]]|=|")|package[[:space:]]*=[[:space:]]*"wheels"' "$f"
doneRepository: magicblock-labs/delegation-program Length of output: 16175 🏁 Script executed: #!/bin/bash
set +e
echo "== workspace and package manifests =="
for f in $(find . -name Cargo.toml -not -path './target/*'); do
echo "--- $f"
sed -n '1,130p' "$f"
done
echo "== macro definitions and nearby imports =="
rg -n -B8 -A45 'macro_rules! require_initialized_pda(_fast)?' dlp-api/src/requires.rs
echo "== token-level references in Rust files =="
rg -n -F 'require_initialized_pda!' . -g '*.rs' -g '!target/**'
rg -n -F 'require_initialized_pda_fast!' . -g '*.rs' -g '!target/**'Repository: magicblock-labs/delegation-program Length of output: 11916 🏁 Script executed: #!/bin/bash
set +e
echo "== dlp-api module exports =="
rg -n -B5 -A20 'mod requires|pub.*requires|requires::|pub use' dlp-api/src/lib.rs dlp-api/src/*.rs
echo "== root crate imports of the exported macros =="
sed -n '1,55p' src/lib.rs
sed -n '1,90p' src/processor/fast/internal/commit_finalize_internal.rs
echo "== wheels macro definition and export =="
WHEELS_FILES=$(find .. -path '*magicblock-wheels*' -type f -name '*.rs' 2>/dev/null)
if [ -n "$WHEELS_FILES" ]; then
rg -n -B3 -A12 'macro_rules! require_owned_by|require_owned_by' $WHEELS_FILES
else
echo "magicblock-wheels source is not present"
fiRepository: magicblock-labs/delegation-program Length of output: 11899 Route both macro calls through
Add 🤖 Prompt for AI Agents |
||
|
|
||
| if $is_writable && !$info.is_writable() { | ||
| pinocchio_log::log!( | ||
|
|
@@ -297,7 +82,7 @@ macro_rules! require_initialized_pda_fast { | |
| return Err(ProgramError::InvalidSeeds); | ||
| } | ||
|
|
||
| require_owned_by!($info, &$crate::fast::ID); | ||
| wheels::require_owned_by!($info, &$crate::fast::ID); | ||
|
|
||
| if $is_writable && !$info.is_writable() { | ||
| pinocchio_log::log!( | ||
|
|
@@ -703,6 +488,39 @@ pub trait RequireUninitializedAccountCtx { | |
| fn immutable(&self) -> ProgramError; | ||
| } | ||
|
|
||
| #[derive(Clone, Copy, Debug)] | ||
| pub struct StandardCtx { | ||
| label: &'static str, | ||
| } | ||
|
|
||
| impl StandardCtx { | ||
| pub const fn new(label: &'static str) -> Self { | ||
| Self { label } | ||
| } | ||
| } | ||
|
|
||
| impl RequireUninitializedAccountCtx for StandardCtx { | ||
| fn label(&self) -> &str { | ||
| self.label | ||
| } | ||
|
|
||
| fn invalid_seeds(&self) -> ProgramError { | ||
| ProgramError::InvalidSeeds | ||
| } | ||
|
|
||
| fn invalid_account_owner(&self) -> ProgramError { | ||
| ProgramError::InvalidAccountOwner | ||
| } | ||
|
|
||
| fn account_already_initialized(&self) -> ProgramError { | ||
| ProgramError::AccountAlreadyInitialized | ||
| } | ||
|
|
||
| fn immutable(&self) -> ProgramError { | ||
| ProgramError::Immutable | ||
| } | ||
| } | ||
|
|
||
| macro_rules! define_uninitialized_ctx { | ||
| ( | ||
| $name:ident, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: magicblock-labs/delegation-program
Length of output: 228
🏁 Script executed:
Repository: magicblock-labs/delegation-program
Length of output: 870
🏁 Script executed:
Repository: magicblock-labs/delegation-program
Length of output: 8025
🏁 Script executed:
Repository: magicblock-labs/delegation-program
Length of output: 453
🌐 Web query:
Cargo publish path-only dependency without version requires version specified official documentation💡 Result:
When publishing a crate to crates.io, Cargo requires that all non-dev dependencies explicitly specify a version [1][2][3]. Using a path-only dependency (e.g.,
my-crate = { path = "../my-crate" }) without a version is not permitted for standard dependencies, andcargo publishwill fail with an error [1][4][5]. The official documentation explains that crates.io does not support dependencies on code outside of the registry [2][6]. To publish a crate that depends on a local path, you must: 1. Publish the local dependency as a separate crate to crates.io [2][6]. 2. Specify both thepathand theversionin yourCargo.toml[2][5][6]. When both are specified, Cargo uses the localpathversion for development and the registryversionwhen publishing (it strips thepathdirective for the published package) [2][5][6]. There is one exception: dev-dependencies are permitted to be specified with only a path [7][8]. If a dev-dependency lacks a version, Cargo will strip that dependency entirely from the published manifest [8]. While there have been proposals (such as RFC 2906) to allow Cargo to automatically infer the version of path dependencies during publication, this feature has not been implemented [4][9]. As of August 2026, you must still explicitly include a version for all standard dependencies [1][2].Citations:
Replace the sibling path with a publishable or repository-contained dependency.
Both crates resolve
wheelsto an absent sibling checkout, so clean CI builds fail during dependency resolution. Thedlp-apipublish workflow also rejects this non-dev path dependency because it has noversion.If
wheelsis published, specify its registryversionand pin its Git source. Otherwise, vendor it in this repository or add it as a submodule.🤖 Prompt for AI Agents