-
Notifications
You must be signed in to change notification settings - Fork 21
feat(fraud-proofs): Implement ResolveDispute #238
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
Draft
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| use wheels::variable_offset_layout; | ||
|
|
||
| pub const DISPUTE_DECISION_OPERATOR_STATE_CORRECT: u8 = 1; | ||
| pub const DISPUTE_DECISION_CHALLENGER_STATE_CORRECT: u8 = 2; | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq)] | ||
| #[variable_offset_layout(buffer_offset = 1)] | ||
| pub struct ResolveDisputeArgs { | ||
| /// Resolver decision for a valid mismatched reveal. | ||
| pub decision: u8, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| use solana_program::{ | ||
| instruction::{AccountMeta, Instruction}, | ||
| pubkey::Pubkey, | ||
| }; | ||
| use wheels::layout::Encodable; | ||
|
|
||
| use crate::{ | ||
| compat::{Compatize, Modernize}, | ||
| pda::fees_vault_pda, | ||
| v2::{ | ||
| pda::{ | ||
| challenge_pda, operator_bond_pda, pending_commitment_pda, | ||
| protocol_config_pda, | ||
| }, | ||
| DlpV2Instruction, ResolveDisputeArgs, | ||
| }, | ||
| }; | ||
|
|
||
| /// Builds the instruction that applies a resolver decision for a v2 challenge. | ||
| pub fn resolve_dispute( | ||
| resolver: Pubkey, | ||
| operator: Pubkey, | ||
| challenger: Pubkey, | ||
| account: Pubkey, | ||
| commit_id: u64, | ||
| args: ResolveDisputeArgs, | ||
| ) -> Instruction { | ||
| Instruction { | ||
| program_id: crate::id().modernize(), | ||
| accounts: vec![ | ||
| AccountMeta::new_readonly(resolver, true), | ||
| AccountMeta::new( | ||
| challenge_pda( | ||
| &account.compatize(), | ||
| commit_id, | ||
| &challenger.compatize(), | ||
| ) | ||
| .modernize(), | ||
| false, | ||
| ), | ||
| AccountMeta::new( | ||
| pending_commitment_pda(&account.compatize(), commit_id) | ||
| .modernize(), | ||
| false, | ||
| ), | ||
| AccountMeta::new( | ||
| operator_bond_pda(&operator.compatize()).modernize(), | ||
| false, | ||
| ), | ||
| AccountMeta::new(challenger, false), | ||
| AccountMeta::new_readonly(protocol_config_pda().modernize(), false), | ||
| AccountMeta::new(fees_vault_pda().modernize(), false), | ||
| ], | ||
| data: [ | ||
| DlpV2Instruction::ResolveDispute.to_vec(), | ||
| args.encode().unwrap(), | ||
| ] | ||
| .concat(), | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: magicblock-labs/delegation-program
Length of output: 20595
🏁 Script executed:
Repository: magicblock-labs/delegation-program
Length of output: 3767
🌐 Web query:
magicblock-labs magicblock-wheels wheels layout Encodable encode variable_offset_layout💡 Result:
The term variable_offset_layout, in the context of magicblock-wheels, refers to a specific utility structure used for handling data serialization and deserialization within MagicBlock's internal SDK [1]. MagicBlock-wheels is an internal, reusable codebase maintained by MagicBlock Labs that contains shared Rust crates and macros [1]. It serves as a backing library for MagicBlock's Ephemeral Rollups (ER) infrastructure rather than being a primary user-facing SDK [1]. Within this repository, the layout and Encodable traits are part of a framework designed to manage account data structures [1]. Specifically: - Encodable: This trait is implemented to facilitate the serialization of data types, ensuring they can be converted into a byte format compatible with the Solana Virtual Machine (SVM) and MagicBlock's ephemeral environments [1]. - variable_offset_layout: This is a layout implementation used when dealing with data structures that have non-fixed sizes. It allows for the correct encoding and decoding of variables where the offset within the byte buffer may change, such as with dynamic arrays or strings within an account state [1]. Developers primarily interact with these utilities indirectly through the ephemeral-rollups-sdk or by utilizing higher-level macros (such as #[ephemeral]) when building their Solana programs, rather than implementing or interacting with variable_offset_layout directly [1][2][3]. Official documentation for MagicBlock development is centrally located at docs.magicblock.gg and the accompanying integration examples repositories [4][5][6].
Citations:
🏁 Script executed:
Repository: magicblock-labs/delegation-program
Length of output: 474
🏁 Script executed:
Repository: magicblock-labs/delegation-program
Length of output: 878
🏁 Script executed:
Repository: magicblock-labs/delegation-program
Length of output: 201
Handle argument-encoding errors instead of unwrapping.
The
unwrap()call panics whenargs.encode()returns an error. Propagate the error, or document an invariant that proves encoding cannot fail.🤖 Prompt for AI Agents
Source: Path instructions