Skip to content

Commit

Permalink
merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay111meher committed Nov 13, 2024
2 parents 5f1372e + a07cd3d commit 5cfb6e8
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 5 deletions.
13 changes: 13 additions & 0 deletions kalypso-cli/src/common_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ pub struct GeneratorRegister {
>,
pub reward_address: Address,
pub declared_compute: U256,
pub display_name: String,
pub display_description: String,
pub website: String,
pub twitter: String,
}

pub struct GeneratorJoinMarket {
Expand Down Expand Up @@ -126,6 +130,11 @@ impl CommonDeps {
get_config_ref!(config, "chain_id", chain_id);
get_config_ref!(config, "declared_compute", declared_compute);

get_config_ref!(config, "display_name", display_name);
get_config_ref!(config, "display_description", display_description);
get_config_ref!(config, "website", website);
get_config_ref!(config, "twitter", twitter);

let (generator_registry, private_key_signer) = get_generator_registry_instance(
private_key,
chain_id,
Expand All @@ -145,6 +154,10 @@ impl CommonDeps {
generator_registry,
reward_address,
declared_compute,
display_name: display_name.into(),
display_description: display_description.into(),
website: website.into(),
twitter: twitter.into(),
})
}
}
Expand Down
30 changes: 29 additions & 1 deletion kalypso-cli/src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,30 @@
"prompt": "Enter enclave client URL",
"secret": false,
"env_var": "ENCLAVE_CLIENT_URL"
},
{
"field": "display_name",
"prompt": "Enter Display Name",
"secret": false,
"env_var": "DISPLAY_NAME"
},
{
"field": "display_description",
"prompt": "A brief description of the generator",
"secret": false,
"env_var": "DESCRIPTION"
},
{
"field": "website",
"prompt": "Website",
"secret": false,
"env_var": "WEBSITE"
},
{
"field": "twitter",
"prompt": "Twitter",
"secret": false,
"env_var": "TWITTER"
}
],
"operations": [
Expand All @@ -179,7 +203,11 @@
"chain_id",
"generator_registry",
"reward_address",
"declared_compute"
"declared_compute",
"display_name",
"display_description",
"website",
"twitter"
]
},
{
Expand Down
23 changes: 22 additions & 1 deletion kalypso-cli/src/operations/complete_registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::operations::Operation;
use async_trait::async_trait;
use ethers::signers::Signer;
use ethers::types::Address;
use serde::Serialize;
use std::collections::HashMap;

/// Struct representing the "Complete Registration" operation
Expand All @@ -17,6 +18,26 @@ impl Operation for CompleteRegistration {
// Initialize common dependencies
let generator_info = CommonDeps::generator_registration_instance(&config)?;

#[derive(Serialize)]
struct Generator {
display_name: String,
display_description: String,
website: String,
twitter: String,
}

let generator = Generator {
display_name: generator_info.display_name,
display_description: generator_info.display_description,
website: generator_info.website,
twitter: generator_info.twitter,
};

let generator_json = serde_json::to_string(&generator)
.map_err(|_| "Failed composing generator metadata".to_string())?;

let generator_metadata = generator_json.as_bytes();

match generator_info
.generator_registry
.generator_registry(generator_info.private_key_signer.address())
Expand All @@ -31,7 +52,7 @@ impl Operation for CompleteRegistration {
.register(
generator_info.reward_address,
generator_info.declared_compute,
vec![12, 23].into(),
generator_metadata.to_vec().into(),
)
.send(),
)
Expand Down
12 changes: 12 additions & 0 deletions kalypso-cli/src/prompts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ impl<'a> Prompter<'a> {
validators.insert("enclave_client_url".to_string(), validate_rpc_url);
validators.insert("private_inputs".to_string(), validate_inputs);
validators.insert("entity_registry".to_string(), validate_eth_address);
validators.insert("display_name".to_string(), validate_string);
validators.insert("display_description".to_string(), validate_string);
validators.insert("website".to_string(), validate_string);
validators.insert("twitter".to_string(), validate_string);

validators.insert(
"confirmation".to_string(),
Expand Down Expand Up @@ -301,3 +305,11 @@ fn get_image_id_from_pcrs_inner(
Ok(image_id)
}
// Add more validators as needed

fn validate_string(key: &str) -> Result<(), String> {
if key.len() > 0 {
return Ok(());
}

return Err("cannot be empty".into());
}
5 changes: 2 additions & 3 deletions slasher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ impl SlashingInstance {
matching_engine_helpers::ask_lib::ask_status::get_ask_state(ask_state);

if ask_state == AskState::DeadlineCrossed || ask_state == AskState::Assigned {
let mut slashing_transaction = self
.proof_marketplace
.slash_generator(ask_id);
let mut slashing_transaction =
self.proof_marketplace.slash_generator(ask_id);

if cfg!(feature = "force_transactions") {
slashing_transaction = slashing_transaction.gas(10_000_000);
Expand Down

0 comments on commit 5cfb6e8

Please sign in to comment.