Skip to content

Commit

Permalink
add fork_version field
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiyaa committed Nov 6, 2023
1 parent c2f2449 commit b812c78
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/client/guardian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ pub struct GuardianClient {

impl GuardianClient {
pub async fn health(&self) -> bool {
let Ok(resp) = self.client.get(format!("{}/upcheck", self.url)).send().await else {
let Ok(resp) = self
.client
.get(format!("{}/upcheck", self.url))
.send()
.await
else {
return false;
};
resp.status() == reqwest::StatusCode::OK
Expand Down
3 changes: 3 additions & 0 deletions src/client/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ fn generate_bls_keystore(

#[cfg(test)]
mod tests {
use crate::eth2::eth_types::GENESIS_FORK_VERSION;

use super::*;

#[test]
Expand All @@ -91,6 +93,7 @@ mod tests {
guardian_pubkeys: vec![g_pk.clone()],
withdrawal_credentials: withdrawal_credentials.clone(),
threshold,
fork_version: GENESIS_FORK_VERSION,
do_remote_attestation: false,
};
let payload = generate_bls_keystore_handler(payload, &password).unwrap();
Expand Down
7 changes: 6 additions & 1 deletion src/client/secure_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ pub struct SecureSignerClient {

impl SecureSignerClient {
pub async fn health(&self) -> bool {
let Ok(resp) = self.client.get(format!("{}/upcheck", self.url)).send().await else {
let Ok(resp) = self
.client
.get(format!("{}/upcheck", self.url))
.send()
.await
else {
return false;
};
resp.status() == reqwest::StatusCode::OK
Expand Down
3 changes: 3 additions & 0 deletions src/client/tests/guardian.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::eth2::eth_types::GENESIS_FORK_VERSION;

#[tokio::test]
async fn call_health_with_success() {
let client = super::build_client();
Expand Down Expand Up @@ -49,6 +51,7 @@ async fn call_validate_custody_with_success() {
guardian_pubkeys: g_pks,
withdrawal_credentials: [1; 32],
threshold: 7,
fork_version: GENESIS_FORK_VERSION,
do_remote_attestation: false,
};

Expand Down
4 changes: 4 additions & 0 deletions src/client/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ mod guardian;
mod secure_signer;
mod validator;

use crate::eth2::eth_types::GENESIS_FORK_VERSION;

fn build_client() -> super::Client {
let builder = super::ClientBuilder::new();
builder
Expand Down Expand Up @@ -44,6 +46,7 @@ async fn registration_flow_succeeds() {
guardian_pubkeys: vec![guardian_pk.clone()],
withdrawal_credentials: withdrawal_credentials.clone(),
threshold: threshold,
fork_version: GENESIS_FORK_VERSION,
do_remote_attestation: verify_remote_attestation,
};

Expand Down Expand Up @@ -108,6 +111,7 @@ async fn test_cli_keygen_verified_by_guardians() {
guardian_pubkeys: vec![guardian_pk.clone()],
withdrawal_credentials: withdrawal_credentials.clone(),
threshold: threshold,
fork_version: GENESIS_FORK_VERSION,
do_remote_attestation: verify_remote_attestation,
};
let bls_keygen_payload = dbg!(crate::client::keygen::generate_bls_keystore_handler(
Expand Down
4 changes: 4 additions & 0 deletions src/client/tests/validator.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::eth2::eth_types::GENESIS_FORK_VERSION;

#[tokio::test]
async fn call_health_with_success() {
let client = super::build_client();
Expand All @@ -16,6 +18,7 @@ async fn call_attest_fresh_bls_key_with_success() {
],
withdrawal_credentials: [0; 32],
threshold: 3,
fork_version: GENESIS_FORK_VERSION,
do_remote_attestation: true,
};
client
Expand Down Expand Up @@ -52,6 +55,7 @@ async fn call_attest_fresh_bls_key_and_decrypt() {
guardian_pubkeys: g_pks,
withdrawal_credentials: [1; 32],
threshold: 3,
fork_version: GENESIS_FORK_VERSION,
do_remote_attestation: true,
};

Expand Down
7 changes: 6 additions & 1 deletion src/client/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ pub struct ValidatorClient {

impl ValidatorClient {
pub async fn health(&self) -> bool {
let Ok(resp) = self.client.get(format!("{}/upcheck", self.url)).send().await else {
let Ok(resp) = self
.client
.get(format!("{}/upcheck", self.url))
.send()
.await
else {
return false;
};
resp.status() == reqwest::StatusCode::OK
Expand Down
1 change: 1 addition & 0 deletions src/enclave/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ pub struct AttestFreshBlsKeyPayload {
)]
pub withdrawal_credentials: [u8; 32],
pub threshold: usize,
pub fork_version: crate::eth2::eth_types::Version,
pub do_remote_attestation: bool,
}

Expand Down
2 changes: 1 addition & 1 deletion src/enclave/validator/handlers/attest_fresh_bls_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub async fn handler(
keygen_payload.withdrawal_credentials,
keygen_payload.guardian_pubkeys,
keygen_payload.threshold,
crate::eth2::eth_types::GENESIS_FORK_VERSION,
keygen_payload.fork_version,
keygen_payload.do_remote_attestation,
) {
Ok(keygen_result) => {
Expand Down

0 comments on commit b812c78

Please sign in to comment.