-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
82 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
yarn-project/circuit-types/src/tx/public_simulation_output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { CombinedAccumulatedData, CombinedConstantData, Fr, Gas } from '@aztec/circuits.js'; | ||
import { mapValues } from '@aztec/foundation/collection'; | ||
|
||
import { EncryptedTxL2Logs, UnencryptedTxL2Logs } from '../logs/tx_l2_logs.js'; | ||
import { type SimulationError } from '../simulation_error.js'; | ||
import { type PublicKernelType } from './processed_tx.js'; | ||
|
||
/** Return values of simulating a circuit. */ | ||
export type ProcessReturnValues = Fr[] | undefined; | ||
|
||
/** | ||
* Outputs of processing the public component of a transaction. | ||
*/ | ||
export class PublicSimulationOutput { | ||
constructor( | ||
public encryptedLogs: EncryptedTxL2Logs, | ||
public unencryptedLogs: UnencryptedTxL2Logs, | ||
public revertReason: SimulationError | undefined, | ||
public constants: CombinedConstantData, | ||
public end: CombinedAccumulatedData, | ||
public publicReturnValues: ProcessReturnValues, | ||
public gasUsed: Partial<Record<PublicKernelType, Gas>>, | ||
) {} | ||
|
||
toJSON() { | ||
return { | ||
encryptedLogs: this.encryptedLogs.toJSON(), | ||
unencryptedLogs: this.unencryptedLogs.toJSON(), | ||
revertReason: this.revertReason, | ||
constants: this.constants.toBuffer().toString('hex'), | ||
end: this.end.toBuffer().toString('hex'), | ||
publicReturnValues: this.publicReturnValues?.map(fr => fr.toString()), | ||
gasUsed: mapValues(this.gasUsed, gas => gas?.toJSON()), | ||
}; | ||
} | ||
|
||
static fromJSON(json: any): PublicSimulationOutput { | ||
return new PublicSimulationOutput( | ||
EncryptedTxL2Logs.fromJSON(json.encryptedLogs), | ||
UnencryptedTxL2Logs.fromJSON(json.unencryptedLogs), | ||
json.revertReason, | ||
CombinedConstantData.fromBuffer(Buffer.from(json.constants, 'hex')), | ||
CombinedAccumulatedData.fromBuffer(Buffer.from(json.end, 'hex')), | ||
json.publicReturnValues?.map(Fr.fromString), | ||
mapValues(json.gasUsed, gas => (gas ? Gas.fromJSON(gas) : undefined)), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters