Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use ts_rs::TS;
#[ts(rename = "SolanaClient")]
pub struct Client {
pub id: ClientId,
#[ts(type = "number[]")]
pub claimer: Pubkey,
pub _unused: [u8; 8],
pub earned: u64,
pub slashed: u64,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
use anchor_lang::prelude::*;
use bytemuck::Pod;
use bytemuck::Zeroable;
use psyche_coordinator::model::HubRepo;
use psyche_coordinator::model::Model;
use psyche_coordinator::ClientState;
use psyche_coordinator::Coordinator;
use psyche_coordinator::CoordinatorConfig;
use psyche_coordinator::CoordinatorProgress;
use psyche_coordinator::HealthChecks;
use psyche_coordinator::RunState;
use psyche_coordinator::SOLANA_MAX_STRING_LEN;
use psyche_coordinator::TickResult;
use psyche_coordinator::Witness;
use psyche_coordinator::model::HubRepo;
use psyche_coordinator::model::Model;
use psyche_coordinator::SOLANA_MAX_STRING_LEN;
use psyche_core::sha256v;
use psyche_core::FixedString;
use psyche_core::SmallBoolean;
use psyche_core::sha256v;
use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;

use crate::ClientId;
use crate::ProgramError;
use crate::client::Client;
use crate::clients_state::ClientsState;
use crate::ClientId;
use crate::ProgramError;

#[derive(
Debug,
Expand Down Expand Up @@ -323,7 +323,7 @@ impl CoordinatorInstanceState {
Ok(())
}

pub fn join_run(&mut self, id: ClientId) -> Result<()> {
pub fn join_run(&mut self, id: ClientId, claimer: Pubkey) -> Result<()> {
let existing = match self
.clients_state
.clients
Expand All @@ -335,6 +335,7 @@ impl CoordinatorInstanceState {
return err!(ProgramError::ClientIdMismatch);
}
client.id = id; // IMPORTANT. Equality is on wallet key but includes ephemeral p2p key
client.claimer = claimer;
client.active = self.clients_state.next_active;
msg!("Existing client {} re-joined", id.signer);
true
Expand All @@ -352,6 +353,7 @@ impl CoordinatorInstanceState {

let new_client = Client {
id,
claimer,
earned: 0,
slashed: 0,
active: self.clients_state.next_active,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anchor_lang::prelude::*;
use psyche_solana_authorizer::state::Authorization;

use crate::bytes_from_string;
use crate::program_error::ProgramError;
use crate::ClientId;
use crate::CoordinatorAccount;
use crate::CoordinatorInstance;
use crate::bytes_from_string;
use crate::program_error::ProgramError;

pub const JOIN_RUN_AUTHORIZATION_SCOPE: &[u8] = b"CoordinatorJoinRun";

Expand Down Expand Up @@ -44,6 +44,7 @@ pub struct JoinRunAccounts<'info> {
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub struct JoinRunParams {
pub client_id: ClientId,
pub claimer: Pubkey,
}

pub fn join_run_processor(
Expand All @@ -55,5 +56,5 @@ pub fn join_run_processor(
}
let mut account = context.accounts.coordinator_account.load_mut()?;
account.increment_nonce();
account.state.join_run(params.client_id)
account.state.join_run(params.client_id, params.claimer)
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use anchor_lang::prelude::*;
use anchor_spl::token::transfer;
use anchor_spl::token::Token;
use anchor_spl::token::TokenAccount;
use anchor_spl::token::Transfer;
use anchor_spl::token::transfer;
use psyche_solana_coordinator::CoordinatorAccount;

use crate::ProgramError;
use crate::state::Participant;
use crate::state::Run;
use crate::ProgramError;

#[derive(Accounts)]
#[instruction(params: ParticipantClaimParams)]
Expand Down Expand Up @@ -75,9 +75,8 @@ pub fn participant_claim_processor(
.clients
.iter()
{
if client.id.signer == context.accounts.user.key() {
participant_earned_points = client.earned;
break;
if client.claimer == context.accounts.user.key() {
participant_earned_points += client.earned;
}
}

Expand Down
Loading