You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Part 1 of a refactor to `ContractFunctionInteraction`
## PXE APIs better reflect the lifecycle of a TX:
`execute private -> simulate kernels -> simulate public (estimate gas)
-> prove -> send`
`prove` potentially goes back to `execute private` (so we can swap to a
`FakeAccountContract` for example), but that's a story for another time.
## Removal of weird `SimulatedTx` class, now we have:
- `PrivateExecutionResult` (old `ExecutionResult`)
- `PrivateSimulationResult`: output of private simulation + kernel
simulation: includes the former and
`PrivateKernelTailCircuitPublicInputs`
- `TxSimulationResult`: output of private + kernel + public simulation:
includes the former + public outputs
- `TxProvingResult`: output of private + proving: includes everything in
`PrivateSimulationResult` + clientIvcProof
## Removal of mutability in `ContractFunctionInteraction`
no more `this.txRequest = undefined` nonsense
Now you can `.prove()` a `BaseContractInteraction`, which returns a
`ProvenTx`. This doesn't mutate the original object, and the returned
value can later be `.send()`.
```typescript
// Example from block_building e2e, used to generate a block with multiple txs in it:
const provenTxs = [];
for (let i = 0; i < TX_COUNT; i++) {
provenTxs.push(
await methods[i].prove({
contractAddressSalt: new Fr(BigInt(i + 1)),
skipClassRegistration: true,
skipPublicDeployment: true,
}),
);
}
// Send them simultaneously to be picked up by the sequencer
const txs = await Promise.all(provenTxs.map(tx => tx.send()));
logger.info(`Txs sent with hashes: `);
for (const tx of txs) {
logger.info(` ${await tx.getTxHash()}`);
}
```
Copy file name to clipboardexpand all lines: docs/docs/migration_notes.md
+23
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,29 @@ Aztec is in full-speed development. Literally every version breaks compatibility
8
8
9
9
## TBD
10
10
11
+
### Changes to PXE API and `ContractFunctionInteraction``
12
+
13
+
PXE APIs have been refactored to better reflext the lifecycle of a Tx (`execute private -> simulate kernels -> simulate public (estimate gas) -> prove -> send`)
14
+
15
+
*`.simulateTx`: Now returns a `TxSimulationResult`, containing the output of private execution, kernel simulation and public simulation (optional).
16
+
*`.proveTx`: Now accepts the result of executing the private part of a transaction, so simulation doesn't have to happen again.
17
+
18
+
Thanks to this refactor, `ContractFunctionInteraction` has been updated to remove its internal cache and avoid bugs due to its mutable nature. As a result our type-safe interfaces now have to be used as follows:
It's still possible to use `.send()` as before, which will perform proving under the hood.
30
+
31
+
More changes are coming to these APIs to better support gas estimation mechanisms and advanced features.
32
+
33
+
11
34
### Changes to public calling convention
12
35
13
36
Contracts that include public functions (that is, marked with `#[public]`), are required to have a function `public_dispatch(selector: Field)` which acts as an entry point. This will be soon the only public function registered/deployed in contracts. The calling convention is updated so that external calls are made to this function.
0 commit comments