Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions dlp-api/src/v2/args/challenger_reveal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use wheels::variable_offset_layout;

use crate::compat::Pubkey;

#[derive(Clone, Debug, PartialEq, Eq)]
#[variable_offset_layout(buffer_offset = 1)]
pub struct ChallengerRevealArgs {
/// Challenger-revealed account lamports.
pub lamports: u64,

/// Challenger-revealed account owner.
pub owner: Pubkey,

/// Hash of the full challenger-uploaded account data.
pub data_hash: [u8; 32],

/// Salt used to open the challenge hash.
pub salt: [u8; 32],
}
2 changes: 2 additions & 0 deletions dlp-api/src/v2/args/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// V2 processors decode args from `instruction_data[1..]` after the one-byte
// instruction tag, so v2 instruction args use `buffer_offset = 1`.

mod challenger_reveal;
mod init_protocol_config;
mod post_commitment;
mod raise_challenge;
Expand All @@ -10,6 +11,7 @@ mod update_protocol_config;
mod update_verifier_registry;
mod write_state_buffer;

pub use challenger_reveal::*;
pub use init_protocol_config::*;
pub use post_commitment::*;
pub use raise_challenge::*;
Expand Down
2 changes: 2 additions & 0 deletions dlp-api/src/v2/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ pub enum DlpV2Instruction {
FinalizeCommitment = 108,
/// Raises a hash-only challenge against a v2 pending commitment.
RaiseChallenge = 109,
/// Reveals challenger state for a v2 challenge.
ChallengerReveal = 110,
}

impl DlpV2Instruction {
Expand Down
72 changes: 72 additions & 0 deletions dlp-api/src/v2/instruction_builder/challenger_reveal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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, pending_commitment_pda, protocol_config_pda,
state_buffer_pda,
},
ChallengerRevealArgs, DlpV2Instruction,
},
};

/// Builds the instruction that reveals challenger state for a v2 challenge.
pub fn challenger_reveal(
challenger: Pubkey,
operator: Pubkey,
account: Pubkey,
commit_id: u64,
args: ChallengerRevealArgs,
) -> Instruction {
Instruction {
program_id: crate::id().modernize(),
accounts: vec![
AccountMeta::new(challenger, 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_readonly(
state_buffer_pda(
&account.compatize(),
commit_id,
&operator.compatize(),
)
.modernize(),
false,
),
AccountMeta::new_readonly(
state_buffer_pda(
&account.compatize(),
commit_id,
&challenger.compatize(),
)
.modernize(),
false,
),
AccountMeta::new_readonly(protocol_config_pda().modernize(), false),
AccountMeta::new(fees_vault_pda().modernize(), false),
],
data: [
DlpV2Instruction::ChallengerReveal.to_vec(),
args.encode().unwrap(),
]
.concat(),
}
}
2 changes: 2 additions & 0 deletions dlp-api/src/v2/instruction_builder/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod approve_commitment;
mod challenger_reveal;
mod finalize_commitment;
mod init_protocol_config;
mod post_commitment;
Expand All @@ -10,6 +11,7 @@ mod update_verifier_registry;
mod write_state_buffer;

pub use approve_commitment::*;
pub use challenger_reveal::*;
pub use finalize_commitment::*;
pub use init_protocol_config::*;
pub use post_commitment::*;
Expand Down
Loading
Loading