Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sequencer): remove get block with timeout #184

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions crates/pathfinder/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,6 @@ impl Client {
.await
}

/// Gets block by number with the specified timeout.
#[tracing::instrument(skip(self))]
pub async fn block_by_number_with_timeout(
&self,
block_number: BlockNumberOrTag,
timeout: Duration,
) -> Result<reply::Block, SequencerError> {
let number = block_number_str(block_number);
retry(|| async {
let resp = self
.inner
.get(self.build_query("get_block", &[("blockNumber", &number)]))
.timeout(timeout)
.send()
.await?;
parse::<reply::Block>(resp).await
})
.await
}

/// Get block by hash.
#[tracing::instrument(skip(self))]
pub async fn block_by_hash(
Expand Down Expand Up @@ -632,63 +612,6 @@ mod tests {
}
}

mod block_by_number_with_timeout {
use super::*;

#[tokio::test]
async fn latest() {
retry_on_rate_limiting!(
client()
.block_by_number_with_timeout(
BlockNumberOrTag::Tag(Tag::Latest),
Duration::from_secs(120)
)
.await
)
.unwrap();
}

#[tokio::test]
async fn pending() {
retry_on_rate_limiting!(
client()
.block_by_number_with_timeout(
BlockNumberOrTag::Tag(Tag::Pending),
Duration::from_secs(120)
)
.await
)
.unwrap();
}

#[tokio::test]
async fn invalid() {
let error = retry_on_rate_limiting!(
client()
.block_by_number_with_timeout(*INVALID_BLOCK_NUMBER, Duration::from_secs(120))
.await
)
.unwrap_err();
assert_matches!(
error,
SequencerError::StarknetError(e) => assert_eq!(e.code, StarknetErrorCode::BlockNotFound)
);
}

#[tokio::test]
async fn contains_receipts_without_status_field() {
retry_on_rate_limiting!(
client()
.block_by_number_with_timeout(
BlockNumberOrTag::Number(StarknetBlockNumber(1716)),
Duration::from_secs(120)
)
.await
)
.unwrap();
}
}

mod call {
use super::*;
use pretty_assertions::assert_eq;
Expand Down
5 changes: 1 addition & 4 deletions crates/pathfinder/src/state/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,7 @@ async fn update_sync_status_latest(
// Work-around the sequencer block fetch being flakey.
let latest = loop {
if let Ok(block) = sequencer
.block_by_number_with_timeout(
BlockNumberOrTag::Tag(Tag::Latest),
Duration::from_secs(3),
)
.block_by_number(BlockNumberOrTag::Tag(Tag::Latest))
.await
{
// Unwrap is safe as only pending blocks have None.
Expand Down
4 changes: 1 addition & 3 deletions crates/pathfinder/src/state/sync/l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ async fn download_block(
) -> anyhow::Result<DownloadBlock> {
use sequencer::error::StarknetErrorCode::BlockNotFound;

let result = sequencer
.block_by_number_with_timeout(block.into(), Duration::from_secs(3))
.await;
let result = sequencer.block_by_number(block.into()).await;

match result {
Ok(block) => Ok(DownloadBlock::Block(block)),
Expand Down