From d652e9503fb27c0fc2bee31cdfbef1bb39eec713 Mon Sep 17 00:00:00 2001 From: FiveMovesAhead Date: Wed, 30 Apr 2025 14:24:18 +0100 Subject: [PATCH] Add support for cuda code submissions. --- tig-protocol/src/context.rs | 2 +- tig-protocol/src/contracts/algorithms.rs | 3 +-- tig-structs/src/config.rs | 4 ++-- tig-structs/src/core.rs | 11 +++++------ 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tig-protocol/src/context.rs b/tig-protocol/src/context.rs index 0ff1e89..4af4d4a 100644 --- a/tig-protocol/src/context.rs +++ b/tig-protocol/src/context.rs @@ -8,7 +8,7 @@ pub trait Context { async fn add_algorithm_to_mempool( &self, details: AlgorithmDetails, - code: String, + code: AlgorithmCode, ) -> Result; async fn get_benchmark_details(&self, benchmark_id: &String) -> Option; async fn get_solution_nonces(&self, benchmark_id: &String) -> Option>; diff --git a/tig-protocol/src/contracts/algorithms.rs b/tig-protocol/src/contracts/algorithms.rs index 4a48514..d4b7623 100644 --- a/tig-protocol/src/contracts/algorithms.rs +++ b/tig-protocol/src/contracts/algorithms.rs @@ -12,7 +12,7 @@ pub async fn submit_algorithm( algorithm_name: String, challenge_id: String, breakthrough_id: Option, - code: String, + code: AlgorithmCode, ) -> Result { 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( challenge_id, player_id, breakthrough_id, - r#type: AlgorithmType::Wasm, fee_paid: config.algorithms.submission_fee, }, code, diff --git a/tig-structs/src/config.rs b/tig-structs/src/config.rs index f51d95f..5479d6d 100644 --- a/tig-structs/src/config.rs +++ b/tig-structs/src/config.rs @@ -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, + runtime_configs: HashMap, target_solution_rate: u32, hash_threshold_max_percent_delta: f64, } diff --git a/tig-structs/src/core.rs b/tig-structs/src/core.rs index 39f4ddd..c21966e 100644 --- a/tig-structs/src/core.rs +++ b/tig-structs/src/core.rs @@ -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, + } } serializable_struct_with_getters! { AlgorithmDetails { @@ -123,7 +123,6 @@ serializable_struct_with_getters! { player_id: String, challenge_id: String, breakthrough_id: Option, - r#type: AlgorithmType, fee_paid: PreciseNumber, } }