Skip to content

chore: replace unmaintained backoff crate with backon in stacks-signer - #7863

Open
brady-stacks wants to merge 1 commit into
stacks-network:mainfrom
brady-stacks:chore/replace-backoff-unmaintained
Open

brady-stacks wants to merge 1 commit into
stacks-network:mainfrom
brady-stacks:chore/replace-backoff-unmaintained

Conversation

@brady-stacks

Copy link
Copy Markdown
Contributor

Description

The backoff crate is unmaintained, and it pulls in instant, which is also unmaintained. This PR replaces it with backon (https://github.com/Xuanwo/backon) in stacks-signer, the only crate that used it. The signer's retries still use the blocking API, so nothing becomes async. backon is built without default features (only std and std-blocking-sleep), so it doesn't pull in tokio.

What changed:

  • retry_with_exponential_backoff in stacks-signer/src/client/mod.rs now uses backon. It keeps the old starting delay (128ms), maximum delay (16384ms) and growth factor (1.5). It also turns off backon's default limit of 3 attempts.
  • A new RetryError<E> type (Transient / Permanent) replaces backoff::Error. It has the same transient() / permanent() constructors, so each call site only changes the path.
  • backoff and instant are removed from Cargo.lock. backon's only dependency, fastrand, was already in the lockfile.

Additional info (benefits, drawbacks, caveats)

  • The 5s limit still counts real elapsed time. backoff stopped retrying once real elapsed time, including time spent waiting on requests, would pass 5s. backon's with_total_delay counts only sleep time, so slow or timed-out requests could stretch retries well past 5s and block the runloop. To keep the old behavior, the delay sequence is wrapped in a take_while that checks real elapsed time.
  • Jitter is different. This PR uses backon's built-in jitter, which adds a random 0–100% on top of each delay. backoff spread delays ±50% around the base value. So each delay is a little longer on average, and slightly fewer retries fit in the 5s window (roughly 7–8 instead of about 9). This is noted in the function's doc comment.
  • The log messages are unchanged: "Non-retry error" for errors that aren't retried, and "Exceeded max retries" when the time limit runs out.

Checklist

  • Test coverage for new or modified code paths: no new tests. All existing stacks-signer tests pass (263 + 4).
  • Changelog fragment(s) or "no changelog" label added
  • Required documentation changes: N/A
  • New clarity functions have corresponding PR in clarity-benchmarking repo: N/A

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant