Skip to content

Commit 3c32aaa

Browse files
authored
Merge branch 'main' into ma/binary-upgrade-test-scenarios
2 parents 63a0ac8 + 65743ff commit 3c32aaa

24 files changed

Lines changed: 2604 additions & 405 deletions

File tree

Cargo.lock

Lines changed: 35 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ async-trait = "0.1"
143143
atomic = "0.6"
144144
atomic_store = { git = "https://github.com/EspressoSystems/atomicstore.git", tag = "0.1.5" }
145145
automod = "1.0.14"
146-
axum = "0.8.8"
146+
axum = { version = "0.8.8", features = ["ws"] }
147147
backoff = "0.4"
148148
base64 = "0.22"
149149
base64-bytes = "0.1"

contracts/rust/deployer/src/network_config.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ pub async fn fetch_stake_table_from_sequencer(
3535
epoch: Option<EpochNumber>,
3636
) -> Result<HSStakeTable<SeqTypes>> {
3737
tracing::info!("Initializing stake table from node for epoch {epoch:?}");
38+
const NUM_RETRIES: usize = 5;
3839

39-
loop {
40+
for i in 0..NUM_RETRIES {
4041
match epoch {
4142
Some(epoch) => match surf_disco::Client::<
4243
tide_disco::error::ServerError,
@@ -46,13 +47,15 @@ pub async fn fetch_stake_table_from_sequencer(
4647
.send()
4748
.await
4849
{
49-
Ok(resp) => break Ok(resp.into()),
50+
Ok(resp) => return Ok(resp.into()),
5051
Err(e) => {
5152
let url = sequencer_url
5253
.join(&format!("node/stake-table/{}", epoch.u64()))
5354
.unwrap();
54-
tracing::error!(%url, "Failed to fetch the stake table: {e}");
55-
sleep(Duration::from_secs(5)).await;
55+
tracing::warn!(%url, "Failed to fetch the stake table: {e}, num_retries left: {}", NUM_RETRIES - i - 1);
56+
if NUM_RETRIES - i > 1 {
57+
sleep(Duration::from_secs(5)).await;
58+
}
5659
},
5760
},
5861
None => {
@@ -67,16 +70,21 @@ pub async fn fetch_stake_table_from_sequencer(
6770
&value["config"]["known_nodes_with_stake"].to_string(),
6871
)
6972
.with_context(|| "Failed to parse the stake table")?;
70-
break Ok(known_nodes_with_stake.into());
73+
return Ok(known_nodes_with_stake.into());
7174
},
7275
Err(e) => {
73-
tracing::error!(%url, "Failed to fetch the network config: {e}");
74-
sleep(Duration::from_secs(5)).await;
76+
tracing::warn!(%url, "Failed to fetch the network config: {e}, num_retries left: {}", NUM_RETRIES - i - 1);
77+
if NUM_RETRIES - i > 1 {
78+
sleep(Duration::from_secs(5)).await;
79+
}
7580
},
7681
}
7782
},
7883
}
7984
}
85+
Err(anyhow::anyhow!(
86+
"Failed to fetch the stake table after {NUM_RETRIES} attempts"
87+
))
8088
}
8189

8290
#[inline]

crates/espresso/api/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ anyhow = { workspace = true }
99
async-trait = { workspace = true }
1010
axum = { workspace = true }
1111
base64 = { workspace = true }
12+
futures = { workspace = true }
1213
hex = { workspace = true }
1314
prost = { workspace = true }
1415
schemars = { workspace = true }
1516
serde = { workspace = true }
1617
serde_json = { workspace = true }
1718
serialization-api = { path = "../../serialization/api" }
19+
thiserror = { workspace = true }
1820
tokio = { workspace = true }
1921
tonic = { workspace = true }
2022
tonic-prost = { workspace = true }

crates/espresso/api/examples/test_api.rs

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ impl v1::AvailabilityApi for TestApi {
170170
Ok(vec![0xde, 0xad, 0xbe, 0xef])
171171
}
172172

173+
async fn stream_namespace_proofs(
174+
&self,
175+
_from: usize,
176+
_namespace: u32,
177+
) -> Result<futures::stream::BoxStream<'static, Self::NamespaceProofQueryData>> {
178+
Ok(Box::pin(futures::stream::empty()))
179+
}
180+
173181
async fn get_state_cert(&self, epoch: u64) -> Result<Self::StateCertQueryDataV1> {
174182
tracing::info!("v1: get_state_cert(epoch={})", epoch);
175183
Ok(vec![0x01, 0x02, 0x03])
@@ -181,6 +189,132 @@ impl v1::AvailabilityApi for TestApi {
181189
}
182190
}
183191

192+
// Stub HotShotAvailabilityApi for the example — returns empty/unit data.
193+
#[async_trait]
194+
impl v1::HotShotAvailabilityApi for TestApi {
195+
type Leaf = serde_json::Value;
196+
type Block = serde_json::Value;
197+
type Header = serde_json::Value;
198+
type Payload = serde_json::Value;
199+
type VidCommon = serde_json::Value;
200+
type Transaction = serde_json::Value;
201+
type TransactionWithProof = serde_json::Value;
202+
type BlockSummary = serde_json::Value;
203+
type Limits = serde_json::Value;
204+
type Cert2 = serde_json::Value;
205+
206+
async fn get_leaf(&self, _id: v1::LeafId) -> Result<Self::Leaf> {
207+
Ok(serde_json::json!({}))
208+
}
209+
async fn get_leaf_range(&self, _from: usize, _until: usize) -> Result<Vec<Self::Leaf>> {
210+
Ok(vec![])
211+
}
212+
async fn get_header(&self, _id: v1::BlockId) -> Result<Self::Header> {
213+
Ok(serde_json::json!({}))
214+
}
215+
async fn get_header_range(&self, _from: usize, _until: usize) -> Result<Vec<Self::Header>> {
216+
Ok(vec![])
217+
}
218+
async fn get_block(&self, _id: v1::BlockId) -> Result<Self::Block> {
219+
Ok(serde_json::json!({}))
220+
}
221+
async fn get_block_range(&self, _from: usize, _until: usize) -> Result<Vec<Self::Block>> {
222+
Ok(vec![])
223+
}
224+
async fn get_payload(&self, _id: v1::PayloadId) -> Result<Self::Payload> {
225+
Ok(serde_json::json!({}))
226+
}
227+
async fn get_payload_range(&self, _from: usize, _until: usize) -> Result<Vec<Self::Payload>> {
228+
Ok(vec![])
229+
}
230+
async fn get_vid_common(&self, _id: v1::BlockId) -> Result<Self::VidCommon> {
231+
Ok(serde_json::json!({}))
232+
}
233+
async fn get_vid_common_range(
234+
&self,
235+
_from: usize,
236+
_until: usize,
237+
) -> Result<Vec<Self::VidCommon>> {
238+
Ok(vec![])
239+
}
240+
async fn get_transaction_by_position(
241+
&self,
242+
_height: u64,
243+
_index: u64,
244+
) -> Result<Self::Transaction> {
245+
Ok(serde_json::json!({}))
246+
}
247+
async fn get_transaction_by_hash(&self, _hash: String) -> Result<Self::Transaction> {
248+
Ok(serde_json::json!({}))
249+
}
250+
async fn get_transaction_proof_by_position(
251+
&self,
252+
_height: u64,
253+
_index: u64,
254+
) -> Result<Self::TransactionWithProof> {
255+
Ok(serde_json::json!({}))
256+
}
257+
async fn get_transaction_proof_by_hash(
258+
&self,
259+
_hash: String,
260+
) -> Result<Self::TransactionWithProof> {
261+
Ok(serde_json::json!({}))
262+
}
263+
async fn get_block_summary(&self, _height: usize) -> Result<Self::BlockSummary> {
264+
Ok(serde_json::json!({}))
265+
}
266+
async fn get_block_summary_range(
267+
&self,
268+
_from: usize,
269+
_until: usize,
270+
) -> Result<Vec<Self::BlockSummary>> {
271+
Ok(vec![])
272+
}
273+
async fn get_limits(&self) -> Result<Self::Limits> {
274+
Ok(serde_json::json!({"small_object_range_limit": 500, "large_object_range_limit": 100}))
275+
}
276+
async fn get_cert2(&self, _height: u64) -> Result<Option<Self::Cert2>> {
277+
Ok(None)
278+
}
279+
async fn stream_leaves(
280+
&self,
281+
_from: usize,
282+
) -> Result<futures::stream::BoxStream<'static, Self::Leaf>> {
283+
Ok(Box::pin(futures::stream::empty()))
284+
}
285+
async fn stream_headers(
286+
&self,
287+
_from: usize,
288+
) -> Result<futures::stream::BoxStream<'static, Self::Header>> {
289+
Ok(Box::pin(futures::stream::empty()))
290+
}
291+
async fn stream_blocks(
292+
&self,
293+
_from: usize,
294+
) -> Result<futures::stream::BoxStream<'static, Self::Block>> {
295+
Ok(Box::pin(futures::stream::empty()))
296+
}
297+
async fn stream_payloads(
298+
&self,
299+
_from: usize,
300+
) -> Result<futures::stream::BoxStream<'static, Self::Payload>> {
301+
Ok(Box::pin(futures::stream::empty()))
302+
}
303+
async fn stream_vid_common(
304+
&self,
305+
_from: usize,
306+
) -> Result<futures::stream::BoxStream<'static, Self::VidCommon>> {
307+
Ok(Box::pin(futures::stream::empty()))
308+
}
309+
async fn stream_transactions(
310+
&self,
311+
_from: usize,
312+
_namespace: Option<u32>,
313+
) -> Result<futures::stream::BoxStream<'static, Self::Transaction>> {
314+
Ok(Box::pin(futures::stream::empty()))
315+
}
316+
}
317+
184318
// Implement v2::RewardApi (simplified API - latest-only for claim/balance/proof)
185319
#[async_trait]
186320
impl v2::RewardApi for TestApi {

0 commit comments

Comments
 (0)