Closed bobbinth closed 8 months ago
Regarding the account creation logic, we refactored it: https://github.com/0xPolygonMiden/miden-client/pull/49 In regards to the transaction API, in general I agree but I wonder if we want to make it a bit more granular (ie, execute the transaction, prove it and submit/save it through 3 different calls that the user has to handle). I updated the feature PR to reflect this API change: https://github.com/0xPolygonMiden/miden-client/pull/38
In regards to the transaction API, in general I agree but I wonder if we want to make it a bit more granular (ie, execute the transaction, prove it and submit/save it through 3 different calls that the user has to handle).
I'm not opposed to this. Not sure I see a lot of value in breaking out proving and saving/sending - but if you thing it is better, let's go for it.
And in the future, this could become something like:
pub struct Client<S: Store, N: Node, A: Authenticator, R: Rng> { store: S, node: N, tx_executor: TransactionExecutor, tx_prover: TransactionProver, authenticator: A, rng: R, }
Based on some recent conversations, I think we should make the prover field generic too. So, it would look more like so:
pub struct Client<S: Store, P: Prover, N: NodeApi, A: Authenticator, R: Rng> {
store: S,
node: N,
tx_executor: TransactionExecutor,
tx_prover: P,
authenticator: A,
rng: R,
}
pub trait Prover {
async fn prove<T: Into<TransactionWitness>>(
&self,
transaction: T,
) -> Result<ProvenTransaction, TransactionProverError>;
}
In the above:
Store
is a trait version of our current Store struct.NodeApi
is a trait version of our current RpcClient struct.Prover
is a trait version of our current TransactionProver from miden-base
.Authenticator
is yet to be defined.Rng
could be based on FeltRng from miden-crypto
, but maybe we need more than that.Closing this as most of it is already implemented and the remaining pieces can be handled in #128.
A few thoughts about how the
Client
struct could look like. These are just proposals at this point and we don't need to implement everything here right away. If we agree on this general approach, we can move theClient
struct close to this over time.Overall, the main goal is to move more logic into the
Client
struct (or related structs) and make the CLI part relatively "dumb". The benefit of this is that thisClient
struct could be used by other "front-ends" without requiring this front end to implement lots of redundant logic.Another goal is to make the client "modular" - that is, have several internal components in the client. For now, these components can be just structs, but over time, we can make them into generic types.
For example, the client struct could look something like this (just a sketch, probably missing something):
And in the future, this could become something like:
In terms of API, the client could look something like this:
The main idea is that the methods listed above are the only way to modify the client state (i.e., we don't update account states or insert notes directly).
And again, this is just a general sketch - so, any feedback is welcome.