From 7632cfd789277c6c072b32dab6560e0fcc259bf1 Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Sun, 14 Dec 2025 22:47:13 +0000 Subject: [PATCH 1/2] fix: abi encode custom params --- examples/CRISP/server/src/cli/commands.rs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/examples/CRISP/server/src/cli/commands.rs b/examples/CRISP/server/src/cli/commands.rs index befa0dafc0..9c1df45a9a 100644 --- a/examples/CRISP/server/src/cli/commands.rs +++ b/examples/CRISP/server/src/cli/commands.rs @@ -6,9 +6,7 @@ use crisp_constants::get_default_paramset; use dialoguer::{theme::ColorfulTheme, FuzzySelect, Input}; -use e3_sdk::bfv_helpers::BfvParamSets; use log::info; -use num_bigint::BigUint; use reqwest::Client; use serde::{Deserialize, Serialize}; @@ -16,6 +14,7 @@ use super::approve; use super::CLI_DB; use alloy::primitives::{Address, Bytes, U256}; use alloy::providers::{Provider, ProviderBuilder}; +use alloy::sol_types::SolValue; use crisp::config::CONFIG; use e3_sdk::bfv_helpers::{build_bfv_params_from_set_arc, encode_bfv_params}; use e3_sdk::evm_helpers::contracts::{EnclaveContract, EnclaveRead, EnclaveWrite, E3}; @@ -41,12 +40,6 @@ struct ComputeProviderParams { batch_size: u32, } -#[derive(Debug, Deserialize, Serialize)] -struct CustomParams { - token_address: String, - balance_threshold: String, -} - #[derive(Debug, Deserialize, Serialize)] struct PKRequest { round_id: u64, @@ -105,15 +98,10 @@ pub async fn initialize_crisp_round( } let token_address: Address = token_address.parse()?; - let balance_threshold = BigUint::parse_bytes(balance_threshold.as_bytes(), 10) - .ok_or("Invalid balance threshold")?; + let balance_threshold = U256::from_str_radix(&balance_threshold, 10)?; - let custom_params = CustomParams { - token_address: token_address.to_string(), - balance_threshold: balance_threshold.to_string(), - }; // Serialize the custom parameters to bytes. - let custom_params_bytes = Bytes::from(serde_json::to_vec(&custom_params)?); + let custom_params_bytes = Bytes::from((token_address, balance_threshold).abi_encode()); let threshold: [u32; 2] = [CONFIG.e3_threshold_min, CONFIG.e3_threshold_max]; let mut current_timestamp = get_current_timestamp().await?; From 312885b29d9570f0dc4480830a0e85f831a9c794 Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Tue, 16 Dec 2025 11:11:39 +0000 Subject: [PATCH 2/2] chore: fix inside server route --- examples/CRISP/server/src/server/routes/rounds.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/examples/CRISP/server/src/server/routes/rounds.rs b/examples/CRISP/server/src/server/routes/rounds.rs index e491339e1e..a7edb4ae1b 100644 --- a/examples/CRISP/server/src/server/routes/rounds.rs +++ b/examples/CRISP/server/src/server/routes/rounds.rs @@ -7,17 +7,17 @@ use crate::config::CONFIG; use crate::server::app_data::AppData; use crate::server::models::{ - CTRequest, ComputeProviderParams, CustomParams, JsonResponse, PKRequest, RoundRequest, + CTRequest, ComputeProviderParams, JsonResponse, PKRequest, RoundRequest, }; use actix_web::{web, HttpResponse, Responder}; use alloy::primitives::{Address, Bytes, U256}; +use alloy::sol_types::SolValue; use chrono::Utc; use crisp_constants::get_default_paramset; use e3_sdk::bfv_helpers::{build_bfv_params_from_set_arc, encode_bfv_params}; use e3_sdk::evm_helpers::contracts::{EnclaveContract, EnclaveRead, EnclaveWrite}; use log::{error, info}; -use num_bigint::BigUint; pub fn setup_routes(config: &mut web::ServiceConfig) { config.service( @@ -183,16 +183,10 @@ pub async fn initialize_crisp_round( let params = encode_bfv_params(&build_bfv_params_from_set_arc(get_default_paramset())); let token_address: Address = token_address.parse()?; - let balance_threshold = BigUint::parse_bytes(balance_threshold.as_bytes(), 10) - .ok_or("Invalid balance threshold")?; - - let custom_params = CustomParams { - token_address: token_address.to_string(), - balance_threshold: balance_threshold.to_string(), - }; + let balance_threshold = U256::from_str_radix(&balance_threshold, 10)?; // Serialize the custom parameters to bytes. - let custom_params_bytes = Bytes::from(serde_json::to_vec(&custom_params)?); + let custom_params_bytes = Bytes::from((token_address, balance_threshold).abi_encode()); info!("Requesting E3..."); let threshold: [u32; 2] = [CONFIG.e3_threshold_min, CONFIG.e3_threshold_max];