Skip to content

Commit

Permalink
Decoding evm events in ciphernode
Browse files Browse the repository at this point in the history
  • Loading branch information
ryardley committed Sep 30, 2024
1 parent 0c6eab7 commit e66ab85
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 158 deletions.
15 changes: 10 additions & 5 deletions packages/ciphernode/core/src/evm_enclave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ use crate::{
events,
evm_listener::{AddEventHandler, ContractEvent, StartListening},
evm_manager::{AddListener, EvmContractManager},
EnclaveEvent, EventBus, Seed,
EnclaveEvent, EventBus,
};
use actix::Addr;
use alloy::{primitives::Address, sol};
use alloy::{primitives::Address, sol, sol_types::SolValue};
use anyhow::{Context, Result};

sol! {
struct EncodedE3ProgramParams {
bytes params;
address input_validator;
}

#[derive(Debug)]
struct E3 {
uint256 seed;
Expand Down Expand Up @@ -44,10 +49,10 @@ sol! {
impl TryFrom<&E3Requested> for events::E3Requested {
type Error = anyhow::Error;
fn try_from(value: &E3Requested) -> Result<Self, Self::Error> {
let params = value.e3.e3ProgramParams.to_vec();

let program_params = value.e3.e3ProgramParams.to_vec();
let decoded = EncodedE3ProgramParams::abi_decode(&program_params, true)?;
Ok(events::E3Requested {
params,
params: decoded.params.into(),
threshold_m: value.e3.threshold[0] as usize,
seed: value.e3.seed.into(),
e3_id: value.e3Id.to_string().into(),
Expand Down
47 changes: 0 additions & 47 deletions packages/ciphernode/core/src/evm_utils.rs

This file was deleted.

2 changes: 0 additions & 2 deletions packages/ciphernode/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ mod evm_ciphernode_registry;
mod evm_enclave;
mod evm_listener;
mod evm_manager;
mod evm_utils;
mod fhe;
mod keyshare;
mod logger;
Expand All @@ -35,7 +34,6 @@ pub use data::*;
pub use e3_request::*;
pub use eventbus::*;
pub use events::*;
pub use evm_utils::*;
pub use fhe::*;
pub use keyshare::*;
pub use logger::*;
Expand Down
3 changes: 1 addition & 2 deletions packages/ciphernode/enclave_node/src/bin/bfvgen.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use alloy::sol;
use clap::{command, Parser};
use enclave_core::{abi_encode_params, abi_encode_params_crpgen, encode_bfv_params};
use enclave_core::encode_bfv_params;
use std::{error::Error, num::ParseIntError, process};

fn parse_hex(arg: &str) -> Result<u64, ParseIntError> {
Expand Down
4 changes: 2 additions & 2 deletions packages/evm/contracts/test/MockE3Program.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ contract MockE3Program is IE3Program {
computeProviderParams.length == 32,
invalidParams(e3ProgramParams, computeProviderParams)
);
(inputValidator, ) = abi.decode(
(,inputValidator) = abi.decode(
e3ProgramParams,
(IInputValidator, bytes)
(bytes, IInputValidator)
);

encryptionSchemeId = 0x0000000000000000000000000000000000000000000000000000000000000001;
Expand Down
Loading

0 comments on commit e66ab85

Please sign in to comment.