feat(PoC): retry functions
[!NOTE] This PR is just to showcase a PoC of the standardized retry functions and is not intended to be merged
For both the Rust and Go codebases, a proof of concept has been made for the standardization of the retry functions used across the entire project.
The retry functions in each case receives some function to be retried. In our concrete case, these functions will be related to message sending between different entities such as Batcher -> Ethereum, for example.
The function can return two distinct type of errors: Recoverable and NonRecoverable. For the Recoverable case, retry will keep retrying until some of the stop condition is met. For the NonRecoverable case, the retry will not keep trying.
The parameters in both Rust and Go versions have been set to have the same behaviour.
Test
You will see a dummy function that prints to console being called periodically with an exponential backoff spacing between calls. There is some randomness for simulating a NonRecoverable error case, for which the function will return immediately without retrying again
Rust version
From the Aligned root folder,
cd rust_retry_poc
cargo run
Go version
From the Aligned root folder,
cd go_retry_poc
go run main.go
As a side-note: we should probably report a bug or fork the Rust library. I've been thinking and its behavior is incorrect: if you state a parameter is the initial wait time for the first retry, you should honor that rather than multiply it on the first wait behind the users' back. Only after the first retry should it start adding time to the wait.