StateProofs: Add timeout to stateproof api#4515
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4515 +/- ##
==========================================
- Coverage 55.28% 55.25% -0.03%
==========================================
Files 398 398
Lines 50336 50353 +17
==========================================
- Hits 27829 27824 -5
- Misses 20178 20199 +21
- Partials 2329 2330 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
@winder, is it necessary to add "408 Request Timeout " to |
| } | ||
|
|
||
| stateProof, err := GetStateProofTransactionForRound(ledger, basics.Round(round), ledger.Latest()) | ||
| stateProof, err := GetStateProofTransactionForRound(ledger, basics.Round(round), ledger.Latest(), time.Minute, v2.Shutdown) |
There was a problem hiding this comment.
Using a context for this is more conventional and doesn't require managing resources, for example context.WithTimeout(ctx.Request().Context()), time.Minute)
What is v2.Shutdown? It's possible echo would cancel its context during a graceful shutdown, so the context solution might handle this case automatically.
There was a problem hiding this comment.
We got some inspiration from this code
apparently, if alogd is being signaled to stop the shutdown chan gets a message.
So I think it is good to stop this operation if algod tries to quit.
Yes, we should add it to |
Summary
/v2/stateproofs/{round}endpoint on algod is responsible for finding a state proof that covers the given round. There are some edge cases in which this search might take a long time. This PR adds timeout to the search.Test Plan
Add some uint tests + manual test