Skip to content

Commit

Permalink
Remove vt_burn_offset (#58)
Browse files Browse the repository at this point in the history
* remove vt_burn_offset

* disable some warnings

* fmt
  • Loading branch information
lean-apple authored Mar 12, 2024
1 parent d360de5 commit 1363a7c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/client/mock/guardian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl GuardianClientTrait for MockGuardianClient {

async fn attest_fresh_eth_key(
&self,
blockhash: &str,
_blockhash: &str,
) -> anyhow::Result<crate::enclave::types::KeyGenResponse> {
match self
.attest_fresh_eth_key_responses
Expand Down Expand Up @@ -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<crate::enclave::types::SignExitResponse> {
match self.sign_exit_responses.lock().unwrap().pop_front() {
Some(res) => Ok(res),
Expand Down
10 changes: 5 additions & 5 deletions src/client/mock/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<crate::enclave::types::BlsKeygenPayload> {
match self.fresh_bls_key.as_ref() {
Some(resp) => Ok(resp.clone()),
Expand All @@ -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<crate::enclave::types::SignatureResponse> {
match self.voluntary_exit_message.as_ref() {
Some(resp) => Ok(resp.clone()),
Expand Down
5 changes: 0 additions & 5 deletions src/client/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
11 changes: 2 additions & 9 deletions src/enclave/guardian/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;

Expand Down Expand Up @@ -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<String> {
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()?
Expand Down Expand Up @@ -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());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/enclave/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)]
Expand All @@ -153,6 +151,7 @@ pub struct ValidateCustodyResponse {
pub deposit_data_root: String,
}

#[allow(dead_code)]
fn serialize_signature_as_hex<S>(
signature: &libsecp256k1::Signature,
serializer: S,
Expand All @@ -165,6 +164,7 @@ where
serializer.serialize_str(&hex_string)
}

#[allow(dead_code)]
fn deserialize_signature_from_hex<'de, D>(
deserializer: D,
) -> Result<libsecp256k1::Signature, D::Error>
Expand Down

0 comments on commit 1363a7c

Please sign in to comment.