Skip to content

Commit 90c12b6

Browse files
committed
update risc0 to 2.0, alloy to 1.0
1 parent 8db624f commit 90c12b6

File tree

17 files changed

+3938
-2812
lines changed

17 files changed

+3938
-2812
lines changed

Cargo.lock

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

cli/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
alloy = { version = "0.3.1", features = ["node-bindings", "network", "providers", "transports", "signer-local", "rpc-types"] }
8-
alloy-contract = "0.3.1"
9-
alloy-sol-types = { version = "0.8.2", features = ["json"] }
7+
alloy = { version = "1.0.3", features = ["node-bindings", "network", "providers", "transports", "signer-local"] }
8+
alloy-sol-types = "1.1.0"
9+
alloy-contract = "1.0.3"
1010
anyhow = "1.0"
1111
bincode = "1.3.3"
1212
blobstream0-core = { path = "../core" }

cli/src/fireblocks.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use alloy::{
1919
fillers::{FillerControlFlow, TxFiller},
2020
Provider, SendableTx,
2121
},
22-
transports::{Transport, TransportResult},
22+
transports::TransportResult,
2323
};
2424

2525
#[derive(Clone, Copy, Debug, Default)]
@@ -45,14 +45,13 @@ impl<N: Network> TxFiller<N> for FireblocksFiller {
4545
}
4646
}
4747

48-
async fn prepare<P, T>(
48+
async fn prepare<P>(
4949
&self,
5050
_provider: &P,
5151
_tx: &<N as Network>::TransactionRequest,
5252
) -> TransportResult<Self::Fillable>
5353
where
54-
P: Provider<T, N>,
55-
T: Transport + Clone,
54+
P: Provider<N>,
5655
{
5756
Ok(())
5857
}

cli/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ macro_rules! setup_provider {
6363
.filler(crate::fireblocks::FireblocksFiller {
6464
sender: fireblocks_address,
6565
})
66-
.on_http($cli.eth_rpc.parse()?);
66+
.connect_http($cli.eth_rpc.parse()?);
6767
(provider, fireblocks_address)
6868
}};
6969
}
@@ -74,9 +74,8 @@ macro_rules! setup_provider {
7474
let signer: alloy::signers::local::PrivateKeySigner = $cli.private_key_hex.parse()?;
7575
let signer_address = signer.address();
7676
let provider = ProviderBuilder::new()
77-
.with_recommended_fillers()
7877
.wallet(alloy::network::EthereumWallet::from(signer))
79-
.on_http($cli.eth_rpc.parse()?);
78+
.connect_http($cli.eth_rpc.parse()?);
8079
(provider, signer_address)
8180
}};
8281
}

cli/src/service/blobstream.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ use std::future::Future;
1616
use std::sync::Arc;
1717
use std::time::{Duration, Instant};
1818

19-
use alloy::{network::Network, primitives::FixedBytes, providers::Provider, transports::Transport};
19+
use alloy::{network::Network, primitives::FixedBytes, providers::Provider};
2020
use anyhow::Context;
2121
use blobstream0_core::{post_batch, prove_block_range};
2222
use blobstream0_primitives::IBlobstream::IBlobstreamInstance;
2323
use rand::Rng;
2424
use tendermint_rpc::{Client, HttpClient};
2525
use tokio::task::JoinError;
2626

27-
pub(crate) struct BlobstreamService<T, P, N> {
28-
contract: Arc<IBlobstreamInstance<T, P, N>>,
27+
pub(crate) struct BlobstreamService<P, N> {
28+
contract: Arc<IBlobstreamInstance<P, N>>,
2929
tm_client: Arc<HttpClient>,
3030
batch_size: u64,
3131
}
3232

33-
impl<T, P, N> BlobstreamService<T, P, N> {
33+
impl<P, N> BlobstreamService<P, N> {
3434
pub fn new(
35-
contract: IBlobstreamInstance<T, P, N>,
35+
contract: IBlobstreamInstance<P, N>,
3636
tm_client: HttpClient,
3737
batch_size: u64,
3838
) -> Self {
@@ -44,10 +44,9 @@ impl<T, P, N> BlobstreamService<T, P, N> {
4444
}
4545
}
4646

47-
impl<T, P, N> BlobstreamService<T, P, N>
47+
impl<P, N> BlobstreamService<P, N>
4848
where
49-
T: Transport + Clone,
50-
P: Provider<T, N> + 'static,
49+
P: Provider<N> + 'static,
5150
N: Network,
5251
{
5352
async fn fetch_current_state(&self) -> Result<anyhow::Result<BlobstreamState>, JoinError> {
@@ -66,8 +65,8 @@ where
6665
let (height, hash, tm_height) = tokio::try_join!(height_task, hash_task, tm_height_task)?;
6766

6867
let result = || {
69-
let height = height?._0;
70-
let eth_verified_hash = hash?._0;
68+
let height = height?;
69+
let eth_verified_hash = hash?;
7170
let tm_height = tm_height?.value();
7271
Ok(BlobstreamState {
7372
eth_verified_height: height,

cli/tests/e2e_test.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
use alloy::network::Ethereum;
1616
use alloy::providers::Provider;
17-
use alloy::transports::http::Http;
1817
use alloy::{
1918
network::EthereumWallet,
2019
node_bindings::{Anvil, AnvilInstance},
@@ -67,11 +66,7 @@ struct DataRootInclusionResponse {
6766

6867
async fn setup_test_environment() -> anyhow::Result<(
6968
AnvilInstance,
70-
IBlobstreamInstance<
71-
Http<reqwest::Client>,
72-
impl Provider<Http<reqwest::Client>, Ethereum>,
73-
Ethereum,
74-
>,
69+
IBlobstreamInstance<impl Provider<Ethereum>, Ethereum>,
7570
)> {
7671
// Set dev mode for test.
7772
std::env::set_var("RISC0_DEV_MODE", "true");
@@ -85,10 +80,7 @@ async fn setup_test_environment() -> anyhow::Result<(
8580

8681
// Create a provider with the wallet.
8782
let rpc_url = anvil.endpoint().parse()?;
88-
let provider = ProviderBuilder::new()
89-
.with_recommended_fillers()
90-
.wallet(wallet)
91-
.on_http(rpc_url);
83+
let provider = ProviderBuilder::new().wallet(wallet).connect_http(rpc_url);
9284

9385
let verifier = MockVerifier::deploy(&provider, [0, 0, 0, 0].into()).await?;
9486

@@ -137,7 +129,7 @@ async fn e2e_basic_range() -> anyhow::Result<()> {
137129
post_batch(&contract, &receipt).await?;
138130

139131
let height = contract.latestHeight().call().await?;
140-
assert_eq!(height._0, BATCH_END as u64 - 1);
132+
assert_eq!(height, BATCH_END as u64 - 1);
141133

142134
// Somewhat hacky to do this manually, seems no Rust tooling for this endpoint.
143135
let http_client = reqwest::Client::new();
@@ -184,7 +176,7 @@ async fn e2e_basic_range() -> anyhow::Result<()> {
184176
)
185177
.call()
186178
.await?;
187-
assert!(is_valid._0);
179+
assert!(is_valid);
188180

189181
Ok(())
190182
}
@@ -202,7 +194,7 @@ async fn test_admin_functions() -> anyhow::Result<()> {
202194
.watch()
203195
.await?;
204196
let current_image_id = contract.imageId().call().await?;
205-
assert_eq!(current_image_id._0, new_image_id);
197+
assert_eq!(current_image_id, new_image_id);
206198

207199
// Test adminSetVerifier
208200
let new_verifier = MockVerifier::deploy(contract.provider(), [1, 1, 1, 1].into()).await?;
@@ -213,7 +205,7 @@ async fn test_admin_functions() -> anyhow::Result<()> {
213205
.watch()
214206
.await?;
215207
let current_verifier = contract.verifier().call().await?;
216-
assert_eq!(current_verifier._0, *new_verifier.address());
208+
assert_eq!(current_verifier, *new_verifier.address());
217209

218210
// Test adminSetTrustedState
219211
let new_trusted_hash = [2u8; 32];
@@ -226,8 +218,8 @@ async fn test_admin_functions() -> anyhow::Result<()> {
226218
.await?;
227219
let current_trusted_hash = contract.latestBlockHash().call().await?;
228220
let current_trusted_height = contract.latestHeight().call().await?;
229-
assert_eq!(current_trusted_hash._0, new_trusted_hash);
230-
assert_eq!(current_trusted_height._0, new_trusted_height);
221+
assert_eq!(current_trusted_hash, new_trusted_hash);
222+
assert_eq!(current_trusted_height, new_trusted_height);
231223

232224
Ok(())
233225
}
@@ -270,7 +262,7 @@ async fn test_contract_upgrade() -> anyhow::Result<()> {
270262
post_batch(&contract, &receipt).await?;
271263

272264
let height = contract.latestHeight().call().await?;
273-
assert_eq!(height._0, BATCH_END as u64 - 1);
265+
assert_eq!(height, BATCH_END as u64 - 1);
274266

275267
Ok(())
276268
}
@@ -281,7 +273,7 @@ async fn test_ownership_transfer() -> anyhow::Result<()> {
281273

282274
// Get the initial owner
283275
let initial_owner = contract.owner().call().await?;
284-
assert_eq!(initial_owner._0, anvil.addresses()[0]);
276+
assert_eq!(initial_owner, anvil.addresses()[0]);
285277

286278
// Transfer ownership
287279
let new_owner = anvil.addresses()[1];
@@ -296,9 +288,8 @@ async fn test_ownership_transfer() -> anyhow::Result<()> {
296288
let new_owner_signer: PrivateKeySigner = anvil.keys()[1].clone().into();
297289
let new_owner_wallet = EthereumWallet::from(new_owner_signer);
298290
let new_owner_provider = ProviderBuilder::new()
299-
.with_recommended_fillers()
300291
.wallet(new_owner_wallet)
301-
.on_http(anvil.endpoint().parse()?);
292+
.connect_http(anvil.endpoint().parse()?);
302293
let contract_as_new_owner = IBlobstream::new(contract.address().clone(), new_owner_provider);
303294
contract_as_new_owner
304295
.acceptOwnership()
@@ -309,7 +300,7 @@ async fn test_ownership_transfer() -> anyhow::Result<()> {
309300

310301
// Verify the new owner
311302
let final_owner = contract.owner().call().await?;
312-
assert_eq!(final_owner._0, new_owner);
303+
assert_eq!(final_owner, new_owner);
313304

314305
Ok(())
315306
}

0 commit comments

Comments
 (0)