Skip to content

Commit 5b3e127

Browse files
committed
Remove circular dependency on citrea
1 parent e61a3e2 commit 5b3e127

File tree

5 files changed

+7
-112
lines changed

5 files changed

+7
-112
lines changed

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,5 @@ toml = "0.8.0"
2222
tracing = { version = "0.1.40", default-features = false }
2323
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json", "fmt"] }
2424

25-
# Citrea dependencies
26-
sov-ledger-rpc = { git = "https://github.com/chainwayxyz/citrea", rev = "962e125", default-features = false, features = ["client"] }
27-
sov-rollup-interface = { git = "https://github.com/chainwayxyz/citrea", rev = "962e125"}
28-
2925
[patch.crates-io]
3026
bitcoincore-rpc = { version = "0.18.0", git = "https://github.com/chainwayxyz/rust-bitcoincore-rpc.git", rev = "5ce1bed" }

src/client.rs

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ use jsonrpsee::{
66
http_client::{HttpClient, HttpClientBuilder},
77
rpc_params,
88
};
9-
use sov_ledger_rpc::client::RpcClient;
10-
use sov_rollup_interface::rpc::{
11-
SequencerCommitmentResponse, SoftConfirmationResponse, VerifiedBatchProofResponse,
12-
};
139
use tokio::time::sleep;
1410
use tracing::trace;
1511

@@ -51,59 +47,19 @@ impl Client {
5147
.await?)
5248
}
5349

54-
pub async fn ledger_get_head_soft_confirmation(
55-
&self,
56-
) -> Result<Option<SoftConfirmationResponse>> {
57-
Ok(self.client.get_head_soft_confirmation().await?)
58-
}
59-
60-
pub async fn ledger_get_verified_batch_proofs_by_slot_height(
61-
&self,
62-
height: u64,
63-
) -> Result<Option<Vec<VerifiedBatchProofResponse>>> {
64-
Ok(self
65-
.client
66-
.get_verified_batch_proofs_by_slot_height(height)
67-
.await?)
68-
}
69-
70-
pub async fn ledger_get_sequencer_commitments_on_slot_by_number(
71-
&self,
72-
height: u64,
73-
) -> Result<Option<Vec<SequencerCommitmentResponse>>> {
50+
pub async fn ledger_get_head_soft_confirmation_height(&self) -> Result<u64> {
7451
Ok(self
7552
.client
76-
.get_sequencer_commitments_on_slot_by_number(height)
53+
.request("ledger_getHeadSoftConfirmationHeight", rpc_params![])
7754
.await?)
7855
}
7956

80-
pub async fn ledger_get_soft_confirmation_by_number(
81-
&self,
82-
num: u64,
83-
) -> Result<Option<SoftConfirmationResponse>> {
84-
Ok(self.client.get_soft_confirmation_by_number(num).await?)
85-
}
86-
87-
pub async fn ledger_get_sequencer_commitments_on_slot_by_hash(
88-
&self,
89-
hash: [u8; 32],
90-
) -> Result<Option<Vec<SequencerCommitmentResponse>>> {
91-
self.client
92-
.get_sequencer_commitments_on_slot_by_hash(hash)
93-
.await
94-
.map_err(Into::into)
95-
}
96-
97-
pub async fn ledger_get_head_soft_confirmation_height(&self) -> Result<u64> {
98-
Ok(self.client.get_head_soft_confirmation_height().await?)
99-
}
100-
10157
pub async fn wait_for_l2_block(&self, num: u64, timeout: Option<Duration>) -> Result<()> {
10258
let start = SystemTime::now();
10359
let timeout = timeout.unwrap_or(Duration::from_secs(30)); // Default 30 seconds timeout
10460
loop {
10561
trace!("Waiting for soft confirmation {}", num);
106-
let latest_block = self.client.get_head_soft_confirmation_height().await?;
62+
let latest_block = self.ledger_get_head_soft_confirmation_height().await?;
10763

10864
if latest_block >= num {
10965
break;

src/full_node.rs

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,4 @@
1-
use anyhow::bail;
2-
use sov_rollup_interface::rpc::{SequencerCommitmentResponse, VerifiedBatchProofResponse};
3-
use tokio::time::{sleep, Duration, Instant};
4-
5-
use super::{config::FullFullNodeConfig, Result};
1+
use super::config::FullFullNodeConfig;
62
use crate::node::Node;
73

84
pub type FullNode = Node<FullFullNodeConfig>;
9-
10-
impl FullNode {
11-
pub async fn wait_for_sequencer_commitments(
12-
&self,
13-
height: u64,
14-
timeout: Option<Duration>,
15-
) -> Result<Vec<SequencerCommitmentResponse>> {
16-
let start = Instant::now();
17-
let timeout = timeout.unwrap_or(Duration::from_secs(30));
18-
19-
loop {
20-
if start.elapsed() >= timeout {
21-
bail!("FullNode failed to get sequencer commitments within the specified timeout");
22-
}
23-
24-
match self
25-
.client
26-
.ledger_get_sequencer_commitments_on_slot_by_number(height)
27-
.await
28-
{
29-
Ok(Some(commitments)) => return Ok(commitments),
30-
Ok(None) => sleep(Duration::from_millis(500)).await,
31-
Err(e) => bail!("Error fetching sequencer commitments: {}", e),
32-
}
33-
}
34-
}
35-
36-
pub async fn wait_for_zkproofs(
37-
&self,
38-
height: u64,
39-
timeout: Option<Duration>,
40-
) -> Result<Vec<VerifiedBatchProofResponse>> {
41-
let start = Instant::now();
42-
let timeout = timeout.unwrap_or(Duration::from_secs(30));
43-
44-
loop {
45-
if start.elapsed() >= timeout {
46-
bail!("FullNode failed to get zkproofs within the specified timeout");
47-
}
48-
49-
match self
50-
.client
51-
.ledger_get_verified_batch_proofs_by_slot_height(height)
52-
.await?
53-
{
54-
Some(proofs) => return Ok(proofs),
55-
None => sleep(Duration::from_millis(500)).await,
56-
}
57-
}
58-
}
59-
}

src/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ where
200200
while start.elapsed() < timeout {
201201
if self
202202
.client
203-
.ledger_get_head_soft_confirmation()
203+
.ledger_get_head_soft_confirmation_height()
204204
.await
205205
.is_ok()
206206
{

tests/docker.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ impl TestCase for DockerIntegrationTest {
4747
.wait_for_l1_height(finalized_height, None)
4848
.await?;
4949

50-
let commitments = full_node
51-
.wait_for_sequencer_commitments(finalized_height, None)
50+
full_node
51+
.wait_for_l2_height(min_soft_confirmations_per_commitment, None)
5252
.await?;
5353

54-
assert_eq!(commitments.len(), 1);
55-
5654
let unspent_sequencer = sequencer
5755
.da
5856
.list_unspent(None, None, None, None, None)

0 commit comments

Comments
 (0)