0xPolygonMiden / miden-base

Core components of the Polygon Miden rollup
MIT License
69 stars 42 forks source link

Make `RemoteTransactionProver` lazily connect #927

Open igamigo opened 4 hours ago

igamigo commented 4 hours ago

What should be done?

For now, RemoteTransactionProver connects on object creation, which implies a connection to the Prover RPC endpoint.

It would be nice to initialize the connection lazily, once the connection is attempted to be used, since otherwise this would imply unnecessary connections (for instance, creating a Client for doing something else rather than remotely proving a transaction).

An alternative is to just connect to the RPC server and drop the connection once the proven transaction arrives.

How should it be done?

Initialize a connection only on RemoteTransactionProver::prove(). This can be long-lived (stored as part of the struct), or dropped after having proven the transation.

When is this task done?

When a connection is not initialized on RemoteTransactionProver::new().

Additional context

No response

bobbinth commented 4 hours ago

If connection initialization overhead is not too big - we could drop the connection after every request.