-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
CombinedConstantData
not registered for serialization (#6292)
Fixes: <img width="634" alt="image" src="https://github.com/AztecProtocol/aztec-packages/assets/13470840/e4707b61-1e26-4b3c-b880-9f5b1bf85e4e"> I decided to not register `CombinedConstantData` directly on JsonRpc server and client since that would just make it all much less readable because CombinedConstantData is not a return value itself on any of AztecNode methods. And since I am a fan of nice readable encapsulated classes instead of the `Pick` type typescript freestyle I refactored ProcessOutput such that we can register that directly on the Json RPC server.
- Loading branch information
Showing
8 changed files
with
102 additions
and
67 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