Add support for cuda code submissions.

This commit is contained in:
FiveMovesAhead 2025-04-30 14:24:18 +01:00
parent 492890a4fc
commit d652e9503f
4 changed files with 9 additions and 11 deletions

View File

@ -8,7 +8,7 @@ pub trait Context {
async fn add_algorithm_to_mempool(
&self,
details: AlgorithmDetails,
code: String,
code: AlgorithmCode,
) -> Result<String>;
async fn get_benchmark_details(&self, benchmark_id: &String) -> Option<BenchmarkDetails>;
async fn get_solution_nonces(&self, benchmark_id: &String) -> Option<HashSet<u64>>;

View File

@ -12,7 +12,7 @@ pub async fn submit_algorithm<T: Context>(
algorithm_name: String,
challenge_id: String,
breakthrough_id: Option<String>,
code: String,
code: AlgorithmCode,
) -> Result<String> {
let config = ctx.get_config().await;
let latest_block_id = ctx.get_latest_block_id().await;
@ -46,7 +46,6 @@ pub async fn submit_algorithm<T: Context>(
challenge_id,
player_id,
breakthrough_id,
r#type: AlgorithmType::Wasm,
fee_paid: config.algorithms.submission_fee,
},
code,

View File

@ -1,4 +1,4 @@
use crate::{core::AlgorithmType, serializable_struct_with_getters};
use crate::serializable_struct_with_getters;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
pub use tig_utils::Point;
@ -67,7 +67,7 @@ serializable_struct_with_getters! {
lifespan_period: u32,
min_per_nonce_fee: PreciseNumber,
min_base_fee: PreciseNumber,
runtime_configs: HashMap<AlgorithmType, RuntimeConfig>,
runtime_configs: HashMap<String, RuntimeConfig>,
target_solution_rate: u32,
hash_threshold_max_percent_delta: f64,
}

View File

@ -111,11 +111,11 @@ serializable_struct_with_getters! {
}
// Algorithm child structs
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum AlgorithmType {
Wasm,
Ptx,
serializable_struct_with_getters! {
AlgorithmCode {
rust: String,
cuda: Option<String>,
}
}
serializable_struct_with_getters! {
AlgorithmDetails {
@ -123,7 +123,6 @@ serializable_struct_with_getters! {
player_id: String,
challenge_id: String,
breakthrough_id: Option<String>,
r#type: AlgorithmType,
fee_paid: PreciseNumber,
}
}