Skip to content

Commit

Permalink
add gcloud KMS signer into SigningEthClientLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
JayT106 committed Jun 19, 2024
1 parent 824c77d commit c9174e1
Show file tree
Hide file tree
Showing 11 changed files with 1,026 additions and 128 deletions.
606 changes: 526 additions & 80 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/lib/eth_client/src/clients/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use vise::{

pub use self::{
query::QueryClient,
signing::{PKSigningClient, SigningClient},
signing::{GKMSSigningClient, PKSigningClient, SigningClient},
};

mod decl;
Expand Down
27 changes: 26 additions & 1 deletion core/lib/eth_client/src/clients/http/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use std::{fmt, sync::Arc};

use async_trait::async_trait;
use zksync_contracts::hyperchain_contract;
use zksync_eth_signer::{EthereumSigner, PrivateKeySigner, TransactionParameters};
use zksync_eth_signer::{
g_kms_signer::GKMSSigner, EthereumSigner, PrivateKeySigner, TransactionParameters,
};
use zksync_types::{
ethabi, web3, Address, K256PrivateKey, L1ChainId, EIP_4844_TX_TYPE, H160, U256,
};
Expand Down Expand Up @@ -39,6 +41,29 @@ impl PKSigningClient {
}
}

pub type GKMSSigningClient = SigningClient<GKMSSigner>;

impl GKMSSigningClient {
pub async fn new_raw(
diamond_proxy_addr: Address,
default_priority_fee_per_gas: u64,
l1_chain_id: L1ChainId,
query_client: Box<dyn EthInterface>,
key_name: String,
) -> Self {
let signer = GKMSSigner::new(key_name).await.unwrap();
SigningClient::new(
query_client,
hyperchain_contract(),
Address::default(),
signer,
diamond_proxy_addr,
default_priority_fee_per_gas.into(),
l1_chain_id,
)
}
}

/// Gas limit value to be used in transaction if for some reason
/// gas limit was not set for it.
///
Expand Down
2 changes: 1 addition & 1 deletion core/lib/eth_client/src/clients/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ mod http;
mod mock;

pub use self::{
http::{PKSigningClient, QueryClient, SigningClient},
http::{GKMSSigningClient, PKSigningClient, QueryClient, SigningClient},
mock::MockEthereum,
};
12 changes: 12 additions & 0 deletions core/lib/eth_signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ zksync_types.workspace = true
rlp.workspace = true
thiserror.workspace = true
async-trait.workspace = true
google-cloud-kms = { git="https://github.com/yoshidan/google-cloud-rust.git", rev="3ec403e"}
google-cloud-auth = { git="https://github.com/yoshidan/google-cloud-rust.git", rev="3ec403e"}
google-cloud-googleapis = { git="https://github.com/yoshidan/google-cloud-rust.git", rev="3ec403e", features=["kms"]}
openssl = "0.10.64"
tiny-keccak = "2.0.2"
hex = "0.4.3"
asn1-rs = { version = "0.6.1", features = ["bigint"]}
secp256k1 = {version="0.29.0", features=["std", "recovery"]}
num-bigint = "0.4.5"
num-traits = "0.2.19"
tracing = "0.1"
x509-parser = "0.16"

[dev-dependencies]
tokio = { workspace = true, features = ["full"] }
Loading

0 comments on commit c9174e1

Please sign in to comment.