From 1363a7c54c9e73aa0dfb43c05f0a3284d151c0cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Narzis?= <78718413+lean-apple@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:34:19 +0100 Subject: [PATCH] Remove `vt_burn_offset` (#58) * remove vt_burn_offset * disable some warnings * fmt --- src/client/mock/guardian.rs | 4 ++-- src/client/mock/validator.rs | 10 +++++----- src/client/tests/mod.rs | 5 ----- src/enclave/guardian/mod.rs | 11 ++--------- src/enclave/types.rs | 4 ++-- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/client/mock/guardian.rs b/src/client/mock/guardian.rs index 7260073..4c0a142 100644 --- a/src/client/mock/guardian.rs +++ b/src/client/mock/guardian.rs @@ -62,7 +62,7 @@ impl GuardianClientTrait for MockGuardianClient { async fn attest_fresh_eth_key( &self, - blockhash: &str, + _blockhash: &str, ) -> anyhow::Result { match self .attest_fresh_eth_key_responses @@ -106,7 +106,7 @@ impl GuardianClientTrait for MockGuardianClient { async fn sign_exit( &self, - request: crate::enclave::types::SignExitRequest, + _request: crate::enclave::types::SignExitRequest, ) -> anyhow::Result { match self.sign_exit_responses.lock().unwrap().pop_front() { Some(res) => Ok(res), diff --git a/src/client/mock/validator.rs b/src/client/mock/validator.rs index c6fc4ab..5b6f09b 100644 --- a/src/client/mock/validator.rs +++ b/src/client/mock/validator.rs @@ -27,7 +27,7 @@ impl ValidatorClientTrait for MockValidatorClient { async fn attest_fresh_bls_key( &self, - payload: &crate::enclave::types::AttestFreshBlsKeyPayload, + _payload: &crate::enclave::types::AttestFreshBlsKeyPayload, ) -> anyhow::Result { match self.fresh_bls_key.as_ref() { Some(resp) => Ok(resp.clone()), @@ -43,10 +43,10 @@ impl ValidatorClientTrait for MockValidatorClient { async fn sign_voluntary_exit_message( &self, - bls_pk_hex: String, - epoch: crate::eth2::eth_types::Epoch, - validator_index: crate::eth2::eth_types::ValidatorIndex, - fork_info: crate::eth2::eth_types::ForkInfo, + _bls_pk_hex: String, + _epoch: crate::eth2::eth_types::Epoch, + _validator_index: crate::eth2::eth_types::ValidatorIndex, + _fork_info: crate::eth2::eth_types::ForkInfo, ) -> anyhow::Result { match self.voluntary_exit_message.as_ref() { Some(resp) => Ok(resp.clone()), diff --git a/src/client/tests/mod.rs b/src/client/tests/mod.rs index 2a8f3e3..b7a2f7d 100644 --- a/src/client/tests/mod.rs +++ b/src/client/tests/mod.rs @@ -2,8 +2,6 @@ mod guardian; mod secure_signer; mod validator; -use ethers::types::U256; - use crate::client::traits::{GuardianClientTrait, ValidatorClientTrait}; use crate::eth2::eth_types::GENESIS_FORK_VERSION; @@ -70,7 +68,6 @@ async fn registration_flow_succeeds() { mrsigner, verify_remote_attestation, validator_index: 0, - vt_burn_offset: U256::from_dec_str("1000000000000000000").unwrap(), }; // Guardian validates they received custody @@ -134,9 +131,7 @@ async fn test_cli_keygen_verified_by_guardians() { mrsigner: "".to_string(), verify_remote_attestation, validator_index: 0, - vt_burn_offset: U256::from_dec_str("1000").unwrap(), }; - println!("req: {:?}", req.vt_burn_offset); // Guardian validates they received custody let resp3: crate::enclave::types::ValidateCustodyResponse = diff --git a/src/enclave/guardian/mod.rs b/src/enclave/guardian/mod.rs index 7d17a6d..3dadd4c 100644 --- a/src/enclave/guardian/mod.rs +++ b/src/enclave/guardian/mod.rs @@ -83,7 +83,6 @@ pub async fn verify_and_sign_custody_received( &request.keygen_payload, &guardian_enclave_sk, &request.validator_index, - request.vt_burn_offset.clone(), ) .await?; @@ -197,14 +196,12 @@ async fn approve_custody( keygen_payload: &crate::enclave::types::BlsKeygenPayload, guardian_enclave_sk: &EthSecretKey, validator_index: &ValidatorIndex, - vt_burn_offset: U256, ) -> Result { let mut hasher = sha3::Keccak256::new(); - // validatorIndex, vtBurnOffset, pubKey, withdrawalCredentials, signature, depositDataRoot + // validatorIndex, pubKey, withdrawalCredentials, signature, depositDataRoot let msg = ethers::abi::encode(&[ ethers::abi::Token::Uint(U256::from(validator_index.clone())), - ethers::abi::Token::Uint(vt_burn_offset), ethers::abi::Token::Bytes( keygen_payload .public_key_set()? @@ -471,11 +468,7 @@ mod tests { let (resp, g_sks, _mre, _mrs) = setup(); for g_sk in g_sks { - assert!( - approve_custody(&resp, &g_sk, &0, U256::from_dec_str("1000").unwrap()) - .await - .is_ok() - ); + assert!(approve_custody(&resp, &g_sk, &0).await.is_ok()); } } diff --git a/src/enclave/types.rs b/src/enclave/types.rs index 02084ca..7d1eab6 100644 --- a/src/enclave/types.rs +++ b/src/enclave/types.rs @@ -4,7 +4,6 @@ use crate::{crypto::eth_keys, strip_0x_prefix}; use anyhow::{bail, Result}; use blsttc::{PublicKey as BlsPublicKey, PublicKeySet}; use ecies::{PublicKey as EthPublicKey, SecretKey as EthSecretKey}; -use ethers::types::U256; use serde::ser::SerializeSeq; use serde::{Deserialize, Serialize}; use tree_hash::TreeHash; @@ -140,7 +139,6 @@ pub struct ValidateCustodyRequest { pub mrsigner: String, pub verify_remote_attestation: bool, pub validator_index: ValidatorIndex, - pub vt_burn_offset: U256, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -153,6 +151,7 @@ pub struct ValidateCustodyResponse { pub deposit_data_root: String, } +#[allow(dead_code)] fn serialize_signature_as_hex( signature: &libsecp256k1::Signature, serializer: S, @@ -165,6 +164,7 @@ where serializer.serialize_str(&hex_string) } +#[allow(dead_code)] fn deserialize_signature_from_hex<'de, D>( deserializer: D, ) -> Result