-
Notifications
You must be signed in to change notification settings - Fork 79
feat: Replace FeltRng trait object in ClientBuilder and Client with generic
#1015
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
base: next
Are you sure you want to change the base?
Conversation
1dc9185 to
c91abb1
Compare
|
Oddly the docs already had an example without Box<>. So did not need to change |
db690d3 to
04e94da
Compare
| /// RPC endpoint, store, RNG, and keystore. It is generic over the keystore type. By default, it | ||
| /// uses `FilesystemKeyStore<rand::rngs::StdRng>`. | ||
| pub struct ClientBuilder { | ||
| pub struct ClientBuilder<R: FeltRng = RpoRandomCoin> { |
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.
Would be nice to do away with this by requiring the R to be supplied during the build fn. But wasn't sure people would prefer those ergonomics.
Generics was the old way we used to do it but it was removed here. I think I prefer the trait object approach but it's totally subjective. In any case we should be consistent, so if we want to go with the generics route we should also change the other trait objects. If we wanted to keep trait objects could we add |
|
We briefly discussed deferring this to the next release, mainly for making these changes cohesively and see how the requirements change with the upcoming VM API refactors. |
|
Hi, @igamigo! Are there any plans to merge this PR? It would be much easier if we had the ability to use |
Context
Relates to #849.
We have various trait objects in our stack that cause Send/Sync problems downstream.
One such trait object is the
Box<dyn FeltRng>used byClientandClientBuilder.We also hand roll
ClientRng(Box<dyn FeltRng>)for a reason that eludes me at the moment. In any case its not required when moving to generics AFAICT.Changes
Box<dyn FeltRng>with generics.ClientRng.Future Work
Consider moving the remaining trait objects of the Client struct to generics.
store: Arc<dyn Store>rpc_api: Arc<dyn NodeRpcClient + Send>authenticator: Option<Arc<dyn TransactionAuthenticator>>