Skip to content

Commit 7a788b1

Browse files
committed
fix: revert to raw signer only.
1 parent f5e154b commit 7a788b1

File tree

12 files changed

+1504
-636
lines changed

12 files changed

+1504
-636
lines changed

Cargo.lock

Lines changed: 1291 additions & 507 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ publish = false
5252
rust-version = "1.81.0"
5353

5454
[workspace.dependencies]
55-
alloy = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2", features = [
55+
alloy = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5", features = [
5656
"node-bindings",
5757
"rpc-types-trace",
5858
"json-rpc",
@@ -63,22 +63,22 @@ alloy = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy", rev
6363
"pubsub",
6464
"providers",
6565
] }
66-
alloy-rpc-types-eth = "0.1.3"
67-
alloy-eips = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
68-
alloy-contract = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
69-
alloy-network = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
70-
alloy-primitives = { version = "0.7.2", default-features = false }
71-
alloy-consensus = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
72-
alloy-provider = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2", features = [
66+
alloy-rpc-types-eth = "0.12"
67+
alloy-eips = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
68+
alloy-contract = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
69+
alloy-network = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
70+
alloy-primitives = { version = "0.8.22", default-features = false }
71+
alloy-consensus = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
72+
alloy-provider = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5", features = [
7373
"ws",
7474
] }
75-
alloy-rlp = "0.3.5"
76-
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
77-
alloy-sol-types = { version = "0.7.2", features = ["json"] }
78-
alloy-signer = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
79-
alloy-transport = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
80-
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2", features = ["reqwest-rustls-tls"] }
81-
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
75+
alloy-rlp = "0.3.9"
76+
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
77+
alloy-sol-types = { version = "0.8.22", features = ["json"] }
78+
alloy-signer = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
79+
alloy-transport = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
80+
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5", features = ["reqwest-rustls-tls"] }
81+
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
8282
anyhow = "1.0"
8383
async-stream = "0.3.0"
8484
async-trait = "0.1.71"
@@ -95,6 +95,10 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
9595
tracing-test = "0.2.5"
9696
tokio = { version = "1.35.1", features = ["full", "tracing"] }
9797
tokio-stream = "0.1.15"
98+
hex = { version = "0.4.3", default-features = false, features = [
99+
"alloc",
100+
"serde",
101+
] }
98102

99103
# model checking and verification
100104

protocol/mcr/cli/client/src/cli/eth/post_admin_commitment.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use mcr_types::block_commitment::BlockCommitment;
66
use serde::{Deserialize, Serialize};
77

88
#[derive(Parser, Serialize, Deserialize, Debug, Clone)]
9+
#[clap(help_expected = true)]
910
pub struct PostAdminCommitment {
1011
#[clap(flatten)]
1112
pub config: Option<Config>,

protocol/mcr/clients/eth/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ tokio = { workspace = true }
3838
tokio-stream = { workspace = true }
3939
tracing = { workspace = true }
4040
serde = { workspace = true }
41+
hex = { workspace = true }
4142

4243
alloy-rpc-types = { workspace = true }
4344
futures = { workspace = true }

protocol/mcr/clients/eth/src/client/mod.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use crate::util::send_eth_transaction::send_transaction;
22
use crate::util::send_eth_transaction::McrEthConnectorError;
33
use crate::util::send_eth_transaction::VerifyRule;
4-
use alloy::providers::{Provider, RootProvider};
5-
use alloy::pubsub::PubSubFrontend;
4+
use alloy::providers::Provider;
65
use alloy_primitives::Address;
76
use alloy_primitives::U256;
87
use alloy_sol_types::sol;
@@ -39,28 +38,29 @@ sol!(
3938
"abis/MOVEToken.json"
4039
);
4140

42-
pub struct Client<P> {
41+
pub struct Client<R, W> {
4342
pub(crate) run_commitment_admin_mode: bool,
44-
pub(crate) rpc_provider: P,
45-
pub(crate) ws_provider: RootProvider<PubSubFrontend>,
43+
pub(crate) rpc_provider: R,
44+
pub(crate) ws_provider: W,
4645
pub(crate) signer_address: Address,
4746
pub(crate) contract_address: Address,
4847
pub(crate) send_transaction_error_rules: Vec<Box<dyn VerifyRule>>,
4948
pub(crate) gas_limit: u64,
5049
pub(crate) send_transaction_retries: u32,
5150
}
5251

53-
impl<P> McrClientOperations for Client<P>
52+
impl<R, W> McrClientOperations for Client<R, W>
5453
where
55-
P: Provider + Clone,
54+
R: Provider + Clone,
55+
W: Provider + Clone,
5656
{
5757
async fn post_block_commitment(
5858
&self,
5959
block_commitment: BlockCommitment,
6060
) -> Result<(), McrClientError> {
6161
let contract = MCR::new(self.contract_address, &self.rpc_provider);
6262

63-
let eth_block_commitment = MCR::BlockCommitment {
63+
let eth_block_commitment = MCRStorage::BlockCommitment {
6464
// Currently, to simplify the API, we'll say 0 is uncommitted all other numbers are legitimate heights
6565
height: U256::from(block_commitment.height()),
6666
commitment: alloy_primitives::FixedBytes(
@@ -72,6 +72,7 @@ where
7272
if self.run_commitment_admin_mode {
7373
let call_builder = contract.forceLatestCommitment(eth_block_commitment);
7474
send_transaction(
75+
self.signer_address.clone(),
7576
call_builder,
7677
&self.send_transaction_error_rules,
7778
self.send_transaction_retries,
@@ -81,6 +82,7 @@ where
8182
} else {
8283
let call_builder = contract.submitBlockCommitment(eth_block_commitment);
8384
send_transaction(
85+
self.signer_address.clone(),
8486
call_builder,
8587
&self.send_transaction_error_rules,
8688
self.send_transaction_retries,
@@ -99,7 +101,7 @@ where
99101
let eth_block_commitment: Vec<_> = block_commitments
100102
.into_iter()
101103
.map(|block_commitment| {
102-
Ok(MCR::BlockCommitment {
104+
Ok(MCRStorage::BlockCommitment {
103105
// Currently, to simplify the API, we'll say 0 is uncommitted all other numbers are legitimate heights
104106
height: U256::from(block_commitment.height()),
105107
commitment: alloy_primitives::FixedBytes(
@@ -116,6 +118,7 @@ where
116118
let call_builder = contract.submitBatchBlockCommitment(eth_block_commitment);
117119

118120
send_transaction(
121+
self.signer_address.clone(),
119122
call_builder,
120123
&self.send_transaction_error_rules,
121124
self.send_transaction_retries,
@@ -130,7 +133,7 @@ where
130133
) -> Result<(), McrClientError> {
131134
let contract = MCR::new(self.contract_address, &self.rpc_provider);
132135

133-
let eth_block_commitment = MCR::BlockCommitment {
136+
let eth_block_commitment = MCRStorage::BlockCommitment {
134137
// Currently, to simplify the API, we'll say 0 is uncommitted all other numbers are legitimate heights
135138
height: U256::from(block_commitment.height()),
136139
commitment: alloy_primitives::FixedBytes(
@@ -141,6 +144,7 @@ where
141144

142145
let call_builder = contract.forceLatestCommitment(eth_block_commitment);
143146
send_transaction(
147+
self.signer_address.clone(),
144148
call_builder,
145149
&self.send_transaction_error_rules,
146150
self.send_transaction_retries,

protocol/mcr/clients/eth/src/config/mod.rs

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,48 @@ use alloy::providers::fillers::JoinFill;
1010
use alloy::providers::fillers::NonceFiller;
1111
use alloy::providers::fillers::WalletFiller;
1212
use alloy::providers::{Provider, ProviderBuilder, RootProvider};
13-
use alloy::signers::Signer as _;
14-
use alloy_network::Ethereum;
13+
use alloy::signers::local::PrivateKeySigner;
14+
// use alloy::signers::Signer as _;
1515
use alloy_network::EthereumWallet;
1616
use alloy_primitives::Address;
17-
use alloy_transport::BoxTransport;
17+
use alloy_provider::fillers::BlobGasFiller;
1818
use alloy_transport_ws::WsConnect;
1919
use anyhow::Context;
2020
use clap::Parser;
21-
use secure_signer::cryptography::secp256k1::Secp256k1;
21+
// use secure_signer::cryptography::secp256k1::Secp256k1;
2222
use secure_signer::key::TryFromCanonicalString;
23-
use secure_signer_eth::Signer;
24-
use secure_signer_loader::{identifiers::SignerIdentifier, Load};
23+
// use secure_signer_eth::Signer;
24+
use secure_signer_loader::{identifiers::SignerIdentifier /*Load*/};
2525
use serde::{Deserialize, Serialize};
26-
use tracing::info;
26+
// use tracing::info;
2727

2828
#[derive(Parser, Debug, Serialize, Deserialize, Clone)]
29+
#[clap(help_expected = true)]
2930
pub struct Config {
3031
/// The address of the MCR settlement contract.
32+
#[arg(long)]
3133
pub mcr_contract_address: String,
3234
/// The Ethereum RPC connection URL.
35+
#[arg(long)]
3336
pub rpc_url: String,
3437
/// The Ethereum WebSocket connection URL.
38+
#[arg(long)]
3539
pub ws_url: String,
3640
/// The Ethereum chain ID.
41+
#[arg(long)]
3742
pub chain_id: u64,
3843
/// The signer identifier.
3944
#[arg(value_parser = SignerIdentifier::try_from_canonical_string)]
45+
#[arg(long)]
4046
pub signer_identifier: SignerIdentifier,
4147
/// Whether to run in settlement admin mode.
48+
#[arg(long)]
4249
pub run_commitment_admin_mode: bool,
4350
/// The gas limit for transactions.
51+
#[arg(long)]
4452
pub gas_limit: u64,
4553
/// The number of retries for sending transactions.
54+
#[arg(long)]
4655
pub transaction_send_retries: u32,
4756
}
4857

@@ -78,42 +87,66 @@ impl Config {
7887
FillProvider<
7988
JoinFill<
8089
JoinFill<
81-
JoinFill<JoinFill<alloy::providers::Identity, GasFiller>, NonceFiller>,
82-
ChainIdFiller,
90+
alloy::providers::Identity,
91+
JoinFill<
92+
GasFiller,
93+
JoinFill<BlobGasFiller, JoinFill<NonceFiller, ChainIdFiller>>,
94+
>,
8395
>,
8496
WalletFiller<EthereumWallet>,
8597
>,
86-
RootProvider<BoxTransport>,
87-
BoxTransport,
88-
Ethereum,
98+
RootProvider,
99+
>,
100+
FillProvider<
101+
JoinFill<
102+
alloy::providers::Identity,
103+
JoinFill<
104+
GasFiller,
105+
JoinFill<BlobGasFiller, JoinFill<NonceFiller, ChainIdFiller>>,
106+
>,
107+
>,
108+
RootProvider,
89109
>,
90110
>,
91111
anyhow::Error,
92112
> {
93-
let signer_identifier: Box<dyn Load<Secp256k1> + Send> =
113+
let raw_key = self.signer_identifier.try_raw_private_key().context("failed to get the raw private key from the signer identifier; only local signers are currently supported")?;
114+
// add the 0x
115+
let raw_key_string = format!("0x{}", hex::encode(raw_key));
116+
let private_key_signer: PrivateKeySigner = raw_key_string.parse()?;
117+
let signer_address = private_key_signer.address();
118+
119+
/*let signer_identifier: Box<dyn Load<Secp256k1> + Send> =
94120
Box::new(self.signer_identifier.clone());
95121
let signer_provider = signer_identifier.load().await?;
96-
let signer = Signer::try_new(signer_provider, Some(self.chain_id)).await?;
122+
123+
let signer = Signer::try_new(signer_provider, Some(self.chain_id)).await?;*
97124
98125
let signer_address = signer.address();
99-
info!("Signer address: {}", signer_address);
126+
info!("Signer address: {}", signer_address);*/
100127
let contract_address = self
101128
.mcr_contract_address
102129
.parse()
103-
.context("Failed to parse the contract address for the MCR settlement client")?;
130+
.context("failed to parse the contract address for the MCR settlement client")?;
104131

105132
// Build the rpc provider
106133
let rpc_provider = ProviderBuilder::new()
107-
.with_recommended_fillers()
108-
.wallet(EthereumWallet::from(signer))
109-
.on_builtin(&self.rpc_url)
134+
.wallet(EthereumWallet::from(private_key_signer))
135+
.connect(&self.rpc_url)
136+
.await
137+
.context("failed to create the RPC provider for the MCR settlement client")?;
138+
139+
// Build the ws provider
140+
let ws = WsConnect::new(self.ws_url);
141+
let ws_provider = ProviderBuilder::new()
142+
.on_ws(ws)
110143
.await
111-
.context("Failed to create the RPC provider for the MCR settlement client")?;
144+
.context("failed to create the WebSocket provider for the MCR settlement client")?;
112145

113146
let client = Self::build_with_provider(
114147
self.run_commitment_admin_mode,
115148
rpc_provider,
116-
self.ws_url,
149+
ws_provider,
117150
signer_address,
118151
contract_address,
119152
self.gas_limit,
@@ -127,26 +160,19 @@ impl Config {
127160
}
128161

129162
// Helper to build the MCR client with a custom provider.
130-
async fn build_with_provider<S, P>(
163+
async fn build_with_provider<R, W>(
131164
run_commitment_admin_mode: bool,
132-
rpc_provider: P,
133-
ws_url: S,
165+
rpc_provider: R,
166+
ws_provider: W,
134167
signer_address: Address,
135168
contract_address: Address,
136169
gas_limit: u64,
137170
send_transaction_retries: u32,
138-
) -> Result<Client<P>, anyhow::Error>
171+
) -> Result<Client<R, W>, anyhow::Error>
139172
where
140-
P: Provider + Clone,
141-
S: Into<String>,
173+
R: Provider + Clone,
174+
W: Provider + Clone,
142175
{
143-
let ws = WsConnect::new(ws_url);
144-
145-
let ws_provider = ProviderBuilder::new()
146-
.on_ws(ws)
147-
.await
148-
.context("Failed to create the WebSocket provider for the MCR settlement client")?;
149-
150176
let rule1: Box<dyn VerifyRule> = Box::new(SendTransactionErrorRule::<UnderPriced>::new());
151177
let rule2: Box<dyn VerifyRule> =
152178
Box::new(SendTransactionErrorRule::<InsufficentFunds>::new());

0 commit comments

Comments
 (0)