-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update signer to support multiple stacks node urls #382
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks okay, but I think we inadvertently introduced some behavior that we don't want. I think I see one main issue, and another "stylistic issue":
- We switch to another stacks node even when the current stacks node that we were using was perfectly fine. For example, Stacks nodes return an error when they don't have enough data to estimate fees, the node could be perfectly fine. With these changes, we'd change node endpoints in that example, but I think it would be better to change node endpoints only when we suspect that the node is down.
- We switch to a new node within the endpoint functions when we it feels more natural to switch outside of them. To me, it feels better to have a simple endpoint function that wraps the API call, and another that uses the simple endpoint function and rotates the node endpoint if it gets connectivity error (or a similar error) from the simple function. This other function could also retry the call after switching nodes (but we can save that part for another day). So I wouldn't change the endpoint functions here, probably just the trait functions.
Anyway, let me know if you think that these suggestions make sense.
|
Forgot return Deserializer return vec needs to be mutable Store full endpoint array from config; keep an index into endpoints and use it to get current url Fix missing endpoints updates Fix config tests for multiple endpoints Fix tests in api.rs for multiple endpoints Fix remaining test Update default config Stacks node not API uses multiple endpoints Fix environment variables in config tests Test multiple endpoints via environment Increment index on network error Specify result return Specify request::Error Try making self mutable so we can increment the index Need semicolon since we’re returning a value Make stacks client mutable Keep going down the mutable rabbit hole More mutable Moar mutable Need moar mutable Use ephemeral stacks clients Fix usage of stacks client Remove mutable since stacks client is now ephemeral Try again to fix mutable issue Handle connection errors on all functions Add mutable and fix response types Trait functions need to be mutable Need to clone before moving into closure; trait needs to be mutable Remove closure Fix braces Return on error from dummy tx Fix warnings Stacks client ref needs to be mut Remove unused imports; mutability fixes Take mutable reference Stacks client needs to be mutable Moar mutability fixes Keep going down mutability rabbit hole Trait functions need mutable self Fix final trait Handle response failure in get account Return Err not just error Handler response errors in submit tx Handle response errors in get fee estimate Try again with match not if let else Try closure map_err for get block Add next _endpoint fn; use only closure map err in get block Add doc comment for next endpoint fn Handle rest of response errors Convert everything to map err Moar map err map_err for get_account Remove unneeded question mark check for network errors in trait not api functions themselves; unwind as much of the mutable changes as possible
5c53151
to
992fd78
Compare
Ok @djordon I've addressed all review comments, rebased on main, and squashed the bulk of the commits to make the PR less verbose. lmk what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I think this feels better. My main comments are around factoring out the identical logic into a function and matching on fewer error variants.
… endpoint if necessary; revert unnecessary muts and other changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good ✅
Description
Update code and config to support multiple stacks urls.
Closes: #225
Changes
Config and stacks api now store multiple endpoints. Stacks api also keeps an index for the current endpoint. This index is incremented on network failure.
Testing Information
Existing tests have been updated to check previous and new functionality.
Checklist: