mirror of
https://github.com/tig-foundation/tig-monorepo.git
synced 2026-02-21 10:27:49 +08:00
Add hyperparameters and runtime to precommit.
This commit is contained in:
parent
64ba783ead
commit
0d8fa8dab9
@ -62,7 +62,6 @@ pub trait Context {
|
||||
&self,
|
||||
settings: BenchmarkSettings,
|
||||
details: PrecommitDetails,
|
||||
hyperparameters: Option<Map<String, Value>>,
|
||||
) -> Result<String>;
|
||||
async fn get_proof_details(&self, benchmark_id: &String) -> Option<ProofDetails>;
|
||||
async fn get_proof_state(&self, benchmark_id: &String) -> Option<ProofState>;
|
||||
|
||||
@ -12,6 +12,7 @@ pub async fn submit_precommit<T: Context>(
|
||||
player_id: String,
|
||||
settings: BenchmarkSettings,
|
||||
hyperparameters: Option<Map<String, Value>>,
|
||||
runtime: Runtime,
|
||||
num_nonces: u64,
|
||||
seed: u64,
|
||||
) -> Result<String> {
|
||||
@ -90,8 +91,9 @@ pub async fn submit_precommit<T: Context>(
|
||||
num_nonces,
|
||||
rand_hash: hex::encode(StdRng::seed_from_u64(seed).gen::<[u8; 16]>()),
|
||||
fee_paid: submission_fee,
|
||||
hyperparameters,
|
||||
runtime,
|
||||
},
|
||||
hyperparameters,
|
||||
)
|
||||
.await?;
|
||||
Ok(benchmark_id)
|
||||
@ -162,8 +164,14 @@ pub async fn submit_benchmark<T: Context>(
|
||||
));
|
||||
}
|
||||
|
||||
// check at least 2 sets of nonces are provided
|
||||
// check solution_quality length
|
||||
let precommit_details = ctx.get_precommit_details(&benchmark_id).await.unwrap();
|
||||
if solution_quality.len() != precommit_details.num_nonces as usize {
|
||||
return Err(anyhow!(
|
||||
"Invalid solution_quality length. Should match number of nonces {}",
|
||||
precommit_details.num_nonces
|
||||
));
|
||||
}
|
||||
|
||||
// random sample nonces
|
||||
let config = ctx.get_config().await;
|
||||
|
||||
@ -86,7 +86,6 @@ serializable_struct_with_getters! {
|
||||
details: PrecommitDetails,
|
||||
settings: BenchmarkSettings,
|
||||
state: PrecommitState,
|
||||
hyperparameters: Option<Map<String, Value>>,
|
||||
}
|
||||
}
|
||||
serializable_struct_with_getters! {
|
||||
@ -404,12 +403,20 @@ serializable_struct_with_getters! {
|
||||
}
|
||||
|
||||
// Precommit child structs
|
||||
serializable_struct_with_getters! {
|
||||
Runtime {
|
||||
memory: u64,
|
||||
fuel: u64,
|
||||
}
|
||||
}
|
||||
serializable_struct_with_getters! {
|
||||
PrecommitDetails {
|
||||
block_started: u32,
|
||||
num_nonces: u64,
|
||||
rand_hash: String,
|
||||
fee_paid: PreciseNumber,
|
||||
runtime: Runtime,
|
||||
hyperparameters: Option<Map<String, Value>>,
|
||||
}
|
||||
}
|
||||
serializable_struct_with_getters! {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user