@aztec/simulator 0.53.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/avm/avm_execution_environment.d.ts +2 -2
- package/dest/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/avm/avm_execution_environment.js +5 -6
- package/dest/avm/avm_gas.d.ts.map +1 -1
- package/dest/avm/avm_gas.js +73 -35
- package/dest/avm/avm_memory_types.d.ts +1 -1
- package/dest/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/avm/avm_memory_types.js +5 -3
- package/dest/avm/bytecode_utils.js +5 -5
- package/dest/avm/opcodes/arithmetic.d.ts +9 -16
- package/dest/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/avm/opcodes/arithmetic.js +12 -37
- package/dest/avm/opcodes/bitwise.d.ts +5 -5
- package/dest/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/avm/opcodes/bitwise.js +6 -6
- package/dest/avm/opcodes/comparators.d.ts +3 -3
- package/dest/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/avm/opcodes/comparators.js +4 -4
- package/dest/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/avm/opcodes/control_flow.js +6 -6
- package/dest/avm/opcodes/instruction.d.ts +18 -12
- package/dest/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/avm/opcodes/instruction.js +36 -19
- package/dest/avm/opcodes/instruction_impl.d.ts +4 -2
- package/dest/avm/opcodes/instruction_impl.d.ts.map +1 -1
- package/dest/avm/opcodes/instruction_impl.js +15 -7
- package/dest/avm/opcodes/memory.d.ts +8 -9
- package/dest/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/avm/opcodes/memory.js +59 -59
- package/dest/avm/serialization/bytecode_serialization.d.ts +7 -8
- package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/bytecode_serialization.js +83 -63
- package/dest/avm/serialization/instruction_serialization.d.ts +84 -64
- package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/instruction_serialization.js +102 -67
- package/dest/public/hints_builder.d.ts +3 -4
- package/dest/public/hints_builder.d.ts.map +1 -1
- package/dest/public/hints_builder.js +2 -5
- package/dest/public/tail_phase_manager.d.ts.map +1 -1
- package/dest/public/tail_phase_manager.js +2 -3
- package/package.json +9 -9
- package/src/avm/avm_execution_environment.ts +3 -4
- package/src/avm/avm_gas.ts +72 -34
- package/src/avm/avm_memory_types.ts +4 -2
- package/src/avm/bytecode_utils.ts +4 -4
- package/src/avm/opcodes/arithmetic.ts +12 -41
- package/src/avm/opcodes/bitwise.ts +5 -5
- package/src/avm/opcodes/comparators.ts +3 -3
- package/src/avm/opcodes/control_flow.ts +5 -5
- package/src/avm/opcodes/instruction.ts +41 -19
- package/src/avm/opcodes/instruction_impl.ts +14 -6
- package/src/avm/opcodes/memory.ts +60 -66
- package/src/avm/serialization/bytecode_serialization.ts +93 -73
- package/src/avm/serialization/instruction_serialization.ts +58 -21
- package/src/public/hints_builder.ts +0 -11
- package/src/public/tail_phase_manager.ts +0 -7
|
@@ -2,7 +2,7 @@ import { PedersenCommitment } from '../opcodes/commitment.js';
|
|
|
2
2
|
import { DAGasLeft, L2GasLeft } from '../opcodes/context_getters.js';
|
|
3
3
|
import { EcAdd } from '../opcodes/ec_add.js';
|
|
4
4
|
import { Keccak, KeccakF1600, Pedersen, Poseidon2, Sha256 } from '../opcodes/hashing.js';
|
|
5
|
-
import
|
|
5
|
+
import { Instruction } from '../opcodes/index.js';
|
|
6
6
|
import {
|
|
7
7
|
Add,
|
|
8
8
|
Address,
|
|
@@ -59,102 +59,122 @@ import { MultiScalarMul } from '../opcodes/multi_scalar_mul.js';
|
|
|
59
59
|
import { BufferCursor } from './buffer_cursor.js';
|
|
60
60
|
import { Opcode } from './instruction_serialization.js';
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
export type InstructionDeserializer = (buf: BufferCursor | Buffer) => Instruction;
|
|
63
|
+
|
|
64
|
+
export interface Serializable {
|
|
65
|
+
serialize(): Buffer;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface Deserializable {
|
|
69
|
+
deserialize: InstructionDeserializer;
|
|
65
70
|
}
|
|
66
71
|
|
|
67
|
-
export type InstructionSet = Map<Opcode,
|
|
72
|
+
export type InstructionSet = Map<Opcode, InstructionDeserializer>;
|
|
68
73
|
// TODO(4359): This is a function so that Call and StaticCall can be lazily resolved.
|
|
69
74
|
// This is a temporary solution until we solve the dependency cycle.
|
|
70
75
|
const INSTRUCTION_SET = () =>
|
|
71
|
-
new Map<Opcode,
|
|
72
|
-
[
|
|
73
|
-
[
|
|
74
|
-
[
|
|
75
|
-
[
|
|
76
|
-
[
|
|
77
|
-
[
|
|
78
|
-
[
|
|
79
|
-
[
|
|
80
|
-
[
|
|
81
|
-
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
89
|
-
[
|
|
90
|
-
[
|
|
91
|
-
[
|
|
76
|
+
new Map<Opcode, InstructionDeserializer>([
|
|
77
|
+
[Opcode.ADD_8, Add.as(Add.wireFormat8).deserialize],
|
|
78
|
+
[Opcode.ADD_16, Add.as(Add.wireFormat16).deserialize],
|
|
79
|
+
[Opcode.SUB_8, Sub.as(Sub.wireFormat8).deserialize],
|
|
80
|
+
[Opcode.SUB_16, Sub.as(Sub.wireFormat16).deserialize],
|
|
81
|
+
[Opcode.MUL_8, Mul.as(Mul.wireFormat8).deserialize],
|
|
82
|
+
[Opcode.MUL_16, Mul.as(Mul.wireFormat16).deserialize],
|
|
83
|
+
[Opcode.DIV_8, Div.as(Div.wireFormat8).deserialize],
|
|
84
|
+
[Opcode.DIV_16, Div.as(Div.wireFormat16).deserialize],
|
|
85
|
+
[Opcode.FDIV_8, FieldDiv.as(FieldDiv.wireFormat8).deserialize],
|
|
86
|
+
[Opcode.FDIV_16, FieldDiv.as(FieldDiv.wireFormat16).deserialize],
|
|
87
|
+
[Opcode.EQ_8, Eq.as(Eq.wireFormat8).deserialize],
|
|
88
|
+
[Opcode.EQ_16, Eq.as(Eq.wireFormat16).deserialize],
|
|
89
|
+
[Opcode.LT_8, Lt.as(Lt.wireFormat8).deserialize],
|
|
90
|
+
[Opcode.LT_16, Lt.as(Lt.wireFormat16).deserialize],
|
|
91
|
+
[Opcode.LTE_8, Lte.as(Lte.wireFormat8).deserialize],
|
|
92
|
+
[Opcode.LTE_16, Lte.as(Lte.wireFormat16).deserialize],
|
|
93
|
+
[Opcode.AND_8, And.as(And.wireFormat8).deserialize],
|
|
94
|
+
[Opcode.AND_16, And.as(And.wireFormat16).deserialize],
|
|
95
|
+
[Opcode.OR_8, Or.as(Or.wireFormat8).deserialize],
|
|
96
|
+
[Opcode.OR_16, Or.as(Or.wireFormat16).deserialize],
|
|
97
|
+
[Opcode.XOR_8, Xor.as(Xor.wireFormat8).deserialize],
|
|
98
|
+
[Opcode.XOR_16, Xor.as(Xor.wireFormat16).deserialize],
|
|
99
|
+
[Not.opcode, Instruction.deserialize.bind(Not)],
|
|
100
|
+
[Opcode.SHL_8, Shl.as(Shl.wireFormat8).deserialize],
|
|
101
|
+
[Opcode.SHL_16, Shl.as(Shl.wireFormat16).deserialize],
|
|
102
|
+
[Opcode.SHR_8, Shr.as(Shr.wireFormat8).deserialize],
|
|
103
|
+
[Opcode.SHR_16, Shr.as(Shr.wireFormat16).deserialize],
|
|
104
|
+
[Cast.opcode, Instruction.deserialize.bind(Cast)],
|
|
105
|
+
[Address.opcode, Instruction.deserialize.bind(Address)],
|
|
106
|
+
[StorageAddress.opcode, Instruction.deserialize.bind(StorageAddress)],
|
|
107
|
+
[Sender.opcode, Instruction.deserialize.bind(Sender)],
|
|
108
|
+
[FunctionSelector.opcode, Instruction.deserialize.bind(FunctionSelector)],
|
|
109
|
+
[TransactionFee.opcode, Instruction.deserialize.bind(TransactionFee)],
|
|
92
110
|
// Execution Environment - Globals
|
|
93
|
-
[ChainId.opcode, ChainId],
|
|
94
|
-
[Version.opcode, Version],
|
|
95
|
-
[BlockNumber.opcode, BlockNumber],
|
|
96
|
-
[Timestamp.opcode, Timestamp],
|
|
97
|
-
[FeePerL2Gas.opcode, FeePerL2Gas],
|
|
98
|
-
[FeePerDAGas.opcode, FeePerDAGas],
|
|
111
|
+
[ChainId.opcode, Instruction.deserialize.bind(ChainId)],
|
|
112
|
+
[Version.opcode, Instruction.deserialize.bind(Version)],
|
|
113
|
+
[BlockNumber.opcode, Instruction.deserialize.bind(BlockNumber)],
|
|
114
|
+
[Timestamp.opcode, Instruction.deserialize.bind(Timestamp)],
|
|
115
|
+
[FeePerL2Gas.opcode, Instruction.deserialize.bind(FeePerL2Gas)],
|
|
116
|
+
[FeePerDAGas.opcode, Instruction.deserialize.bind(FeePerDAGas)],
|
|
99
117
|
// Execution Environment - Calldata
|
|
100
|
-
[CalldataCopy.opcode, CalldataCopy],
|
|
118
|
+
[CalldataCopy.opcode, Instruction.deserialize.bind(CalldataCopy)],
|
|
101
119
|
|
|
102
120
|
// Machine State
|
|
103
121
|
// Machine State - Gas
|
|
104
|
-
[L2GasLeft.opcode, L2GasLeft],
|
|
105
|
-
[DAGasLeft.opcode, DAGasLeft],
|
|
122
|
+
[L2GasLeft.opcode, Instruction.deserialize.bind(L2GasLeft)],
|
|
123
|
+
[DAGasLeft.opcode, Instruction.deserialize.bind(DAGasLeft)],
|
|
106
124
|
// Machine State - Internal Control Flow
|
|
107
|
-
[Jump.opcode, Jump],
|
|
108
|
-
[JumpI.opcode, JumpI],
|
|
109
|
-
[InternalCall.opcode, InternalCall],
|
|
110
|
-
[InternalReturn.opcode, InternalReturn],
|
|
111
|
-
[
|
|
112
|
-
[
|
|
113
|
-
[
|
|
125
|
+
[Jump.opcode, Instruction.deserialize.bind(Jump)],
|
|
126
|
+
[JumpI.opcode, Instruction.deserialize.bind(JumpI)],
|
|
127
|
+
[InternalCall.opcode, Instruction.deserialize.bind(InternalCall)],
|
|
128
|
+
[InternalReturn.opcode, Instruction.deserialize.bind(InternalReturn)],
|
|
129
|
+
[Opcode.SET_8, Set.as(Set.wireFormat8).deserialize],
|
|
130
|
+
[Opcode.SET_16, Set.as(Set.wireFormat16).deserialize],
|
|
131
|
+
[Opcode.SET_32, Set.as(Set.wireFormat32).deserialize],
|
|
132
|
+
[Opcode.SET_64, Set.as(Set.wireFormat64).deserialize],
|
|
133
|
+
[Opcode.SET_128, Set.as(Set.wireFormat128).deserialize],
|
|
134
|
+
[Opcode.SET_FF, Set.as(Set.wireFormatFF).deserialize],
|
|
135
|
+
[Opcode.MOV_8, Mov.as(Mov.wireFormat8).deserialize],
|
|
136
|
+
[Opcode.MOV_16, Mov.as(Mov.wireFormat16).deserialize],
|
|
137
|
+
[CMov.opcode, Instruction.deserialize.bind(CMov)],
|
|
114
138
|
|
|
115
139
|
// World State
|
|
116
|
-
[SLoad.opcode, SLoad], // Public Storage
|
|
117
|
-
[SStore.opcode, SStore], // Public Storage
|
|
118
|
-
[NoteHashExists.opcode, NoteHashExists], // Notes & Nullifiers
|
|
119
|
-
[EmitNoteHash.opcode, EmitNoteHash], // Notes & Nullifiers
|
|
120
|
-
[NullifierExists.opcode, NullifierExists], // Notes & Nullifiers
|
|
121
|
-
[EmitNullifier.opcode, EmitNullifier], // Notes & Nullifiers
|
|
122
|
-
[L1ToL2MessageExists.opcode, L1ToL2MessageExists], // Messages
|
|
140
|
+
[SLoad.opcode, Instruction.deserialize.bind(SLoad)], // Public Storage
|
|
141
|
+
[SStore.opcode, Instruction.deserialize.bind(SStore)], // Public Storage
|
|
142
|
+
[NoteHashExists.opcode, Instruction.deserialize.bind(NoteHashExists)], // Notes & Nullifiers
|
|
143
|
+
[EmitNoteHash.opcode, Instruction.deserialize.bind(EmitNoteHash)], // Notes & Nullifiers
|
|
144
|
+
[NullifierExists.opcode, Instruction.deserialize.bind(NullifierExists)], // Notes & Nullifiers
|
|
145
|
+
[EmitNullifier.opcode, Instruction.deserialize.bind(EmitNullifier)], // Notes & Nullifiers
|
|
146
|
+
[L1ToL2MessageExists.opcode, Instruction.deserialize.bind(L1ToL2MessageExists)], // Messages
|
|
123
147
|
|
|
124
148
|
// Accrued Substate
|
|
125
|
-
[EmitUnencryptedLog.opcode, EmitUnencryptedLog],
|
|
126
|
-
[SendL2ToL1Message.opcode, SendL2ToL1Message],
|
|
127
|
-
[GetContractInstance.opcode, GetContractInstance],
|
|
149
|
+
[EmitUnencryptedLog.opcode, Instruction.deserialize.bind(EmitUnencryptedLog)],
|
|
150
|
+
[SendL2ToL1Message.opcode, Instruction.deserialize.bind(SendL2ToL1Message)],
|
|
151
|
+
[GetContractInstance.opcode, Instruction.deserialize.bind(GetContractInstance)],
|
|
128
152
|
|
|
129
153
|
// Control Flow - Contract Calls
|
|
130
|
-
[Call.opcode, Call],
|
|
131
|
-
[StaticCall.opcode, StaticCall],
|
|
132
|
-
//[DelegateCall.opcode, DelegateCall],
|
|
133
|
-
[Return.opcode, Return],
|
|
134
|
-
[Revert.opcode, Revert],
|
|
154
|
+
[Call.opcode, Instruction.deserialize.bind(Call)],
|
|
155
|
+
[StaticCall.opcode, Instruction.deserialize.bind(StaticCall)],
|
|
156
|
+
//[DelegateCall.opcode, Instruction.deserialize.bind(DelegateCall)],
|
|
157
|
+
[Return.opcode, Instruction.deserialize.bind(Return)],
|
|
158
|
+
[Revert.opcode, Instruction.deserialize.bind(Revert)],
|
|
135
159
|
|
|
136
160
|
// Misc
|
|
137
|
-
[DebugLog.opcode, DebugLog],
|
|
161
|
+
[DebugLog.opcode, Instruction.deserialize.bind(DebugLog)],
|
|
138
162
|
|
|
139
163
|
// Gadgets
|
|
140
|
-
[EcAdd.opcode, EcAdd],
|
|
141
|
-
[Keccak.opcode, Keccak],
|
|
142
|
-
[Poseidon2.opcode, Poseidon2],
|
|
143
|
-
[Sha256.opcode, Sha256],
|
|
144
|
-
[Pedersen.opcode, Pedersen],
|
|
145
|
-
[MultiScalarMul.opcode, MultiScalarMul],
|
|
146
|
-
[PedersenCommitment.opcode, PedersenCommitment],
|
|
164
|
+
[EcAdd.opcode, Instruction.deserialize.bind(EcAdd)],
|
|
165
|
+
[Keccak.opcode, Instruction.deserialize.bind(Keccak)],
|
|
166
|
+
[Poseidon2.opcode, Instruction.deserialize.bind(Poseidon2)],
|
|
167
|
+
[Sha256.opcode, Instruction.deserialize.bind(Sha256)],
|
|
168
|
+
[Pedersen.opcode, Instruction.deserialize.bind(Pedersen)],
|
|
169
|
+
[MultiScalarMul.opcode, Instruction.deserialize.bind(MultiScalarMul)],
|
|
170
|
+
[PedersenCommitment.opcode, Instruction.deserialize.bind(PedersenCommitment)],
|
|
147
171
|
// Conversions
|
|
148
|
-
[ToRadixLE.opcode, ToRadixLE],
|
|
172
|
+
[ToRadixLE.opcode, Instruction.deserialize.bind(ToRadixLE)],
|
|
149
173
|
// Future Gadgets -- pending changes in noir
|
|
150
174
|
// SHA256COMPRESSION,
|
|
151
|
-
[KeccakF1600.opcode, KeccakF1600],
|
|
175
|
+
[KeccakF1600.opcode, Instruction.deserialize.bind(KeccakF1600)],
|
|
152
176
|
]);
|
|
153
177
|
|
|
154
|
-
interface Serializable {
|
|
155
|
-
serialize(): Buffer;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
178
|
/**
|
|
159
179
|
* Serializes an array of instructions to bytecode.
|
|
160
180
|
*/
|
|
@@ -182,8 +202,8 @@ export function decodeFromBytecode(
|
|
|
182
202
|
throw new Error(`Opcode ${Opcode[opcode]} (0x${opcode.toString(16)}) not implemented`);
|
|
183
203
|
}
|
|
184
204
|
|
|
185
|
-
const instructionDeserializer:
|
|
186
|
-
const i: Instruction = instructionDeserializer
|
|
205
|
+
const instructionDeserializer: InstructionDeserializer = instructionDeserializerOrUndef;
|
|
206
|
+
const i: Instruction = instructionDeserializer(cursor);
|
|
187
207
|
instructions.push(i);
|
|
188
208
|
}
|
|
189
209
|
|
|
@@ -8,20 +8,33 @@ import { BufferCursor } from './buffer_cursor.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export enum Opcode {
|
|
10
10
|
// Compute
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
ADD_8,
|
|
12
|
+
ADD_16,
|
|
13
|
+
SUB_8,
|
|
14
|
+
SUB_16,
|
|
15
|
+
MUL_8,
|
|
16
|
+
MUL_16,
|
|
17
|
+
DIV_8,
|
|
18
|
+
DIV_16,
|
|
19
|
+
FDIV_8,
|
|
20
|
+
FDIV_16,
|
|
21
|
+
EQ_8,
|
|
22
|
+
EQ_16,
|
|
23
|
+
LT_8,
|
|
24
|
+
LT_16,
|
|
25
|
+
LTE_8,
|
|
26
|
+
LTE_16,
|
|
27
|
+
AND_8,
|
|
28
|
+
AND_16,
|
|
29
|
+
OR_8,
|
|
30
|
+
OR_16,
|
|
31
|
+
XOR_8,
|
|
32
|
+
XOR_16,
|
|
22
33
|
NOT,
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
SHL_8,
|
|
35
|
+
SHL_16,
|
|
36
|
+
SHR_8,
|
|
37
|
+
SHR_16,
|
|
25
38
|
CAST,
|
|
26
39
|
// Execution environment
|
|
27
40
|
ADDRESS,
|
|
@@ -40,13 +53,19 @@ export enum Opcode {
|
|
|
40
53
|
L2GASLEFT,
|
|
41
54
|
DAGASLEFT,
|
|
42
55
|
// Control flow
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
JUMP_16,
|
|
57
|
+
JUMPI_16,
|
|
45
58
|
INTERNALCALL,
|
|
46
59
|
INTERNALRETURN,
|
|
47
60
|
// Memory
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
SET_8,
|
|
62
|
+
SET_16,
|
|
63
|
+
SET_32,
|
|
64
|
+
SET_64,
|
|
65
|
+
SET_128,
|
|
66
|
+
SET_FF,
|
|
67
|
+
MOV_8,
|
|
68
|
+
MOV_16,
|
|
50
69
|
CMOV,
|
|
51
70
|
// World state
|
|
52
71
|
SLOAD,
|
|
@@ -92,6 +111,7 @@ export enum OperandType {
|
|
|
92
111
|
UINT32,
|
|
93
112
|
UINT64,
|
|
94
113
|
UINT128,
|
|
114
|
+
FF,
|
|
95
115
|
}
|
|
96
116
|
|
|
97
117
|
type OperandNativeType = number | bigint;
|
|
@@ -104,8 +124,27 @@ const OPERAND_SPEC = new Map<OperandType, [number, () => OperandNativeType, Oper
|
|
|
104
124
|
[OperandType.UINT32, [4, Buffer.prototype.readUint32BE, Buffer.prototype.writeUint32BE]],
|
|
105
125
|
[OperandType.UINT64, [8, Buffer.prototype.readBigInt64BE, Buffer.prototype.writeBigInt64BE]],
|
|
106
126
|
[OperandType.UINT128, [16, readBigInt128BE, writeBigInt128BE]],
|
|
127
|
+
[OperandType.FF, [32, readBigInt254BE, writeBigInt254BE]],
|
|
107
128
|
]);
|
|
108
129
|
|
|
130
|
+
function readBigInt254BE(this: Buffer): bigint {
|
|
131
|
+
const totalBytes = 32;
|
|
132
|
+
let ret: bigint = 0n;
|
|
133
|
+
for (let i = 0; i < totalBytes; ++i) {
|
|
134
|
+
ret <<= 8n;
|
|
135
|
+
ret |= BigInt(this.readUint8(i));
|
|
136
|
+
}
|
|
137
|
+
return ret;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function writeBigInt254BE(this: Buffer, value: bigint): void {
|
|
141
|
+
const totalBytes = 32;
|
|
142
|
+
for (let offset = totalBytes - 1; offset >= 0; --offset) {
|
|
143
|
+
this.writeUint8(Number(value & 0xffn), offset);
|
|
144
|
+
value >>= 8n;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
109
148
|
function readBigInt128BE(this: Buffer): bigint {
|
|
110
149
|
const totalBytes = 16;
|
|
111
150
|
let ret: bigint = 0n;
|
|
@@ -156,12 +195,10 @@ export function deserialize(cursor: BufferCursor | Buffer, operands: OperandType
|
|
|
156
195
|
* @param cls The class to be serialized.
|
|
157
196
|
* @returns
|
|
158
197
|
*/
|
|
159
|
-
export function
|
|
198
|
+
export function serializeAs(operands: OperandType[], opcode: Opcode, cls: any): Buffer {
|
|
160
199
|
const chunks: Buffer[] = [];
|
|
161
200
|
|
|
162
|
-
|
|
163
|
-
assert(cls.constructor.opcode !== undefined && cls.constructor.opcode !== null);
|
|
164
|
-
const rawClassValues: any[] = [cls.constructor.opcode, ...Object.values(cls)];
|
|
201
|
+
const rawClassValues: any[] = [opcode, ...Object.values(cls)];
|
|
165
202
|
assert(
|
|
166
203
|
rawClassValues.length === operands.length,
|
|
167
204
|
`Got ${rawClassValues.length} values but only ${operands.length} serialization operands are specified!`,
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
type MAX_NULLIFIERS_PER_TX,
|
|
8
8
|
type MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX,
|
|
9
9
|
MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
10
|
-
type MAX_PUBLIC_DATA_HINTS,
|
|
11
10
|
type MAX_PUBLIC_DATA_READS_PER_TX,
|
|
12
11
|
type MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
13
12
|
MembershipWitness,
|
|
@@ -15,7 +14,6 @@ import {
|
|
|
15
14
|
NULLIFIER_TREE_HEIGHT,
|
|
16
15
|
type Nullifier,
|
|
17
16
|
PUBLIC_DATA_TREE_HEIGHT,
|
|
18
|
-
type PublicDataHint,
|
|
19
17
|
type PublicDataRead,
|
|
20
18
|
type PublicDataTreeLeafPreimage,
|
|
21
19
|
type PublicDataUpdateRequest,
|
|
@@ -25,7 +23,6 @@ import {
|
|
|
25
23
|
buildNullifierNonExistentReadRequestHints,
|
|
26
24
|
buildPublicDataHint,
|
|
27
25
|
buildPublicDataHints,
|
|
28
|
-
buildPublicDataReadRequestHints,
|
|
29
26
|
buildSiloedNullifierReadRequestHints,
|
|
30
27
|
} from '@aztec/circuits.js';
|
|
31
28
|
import { makeTuple } from '@aztec/foundation/array';
|
|
@@ -91,14 +88,6 @@ export class HintsBuilder {
|
|
|
91
88
|
return buildPublicDataHint(this, slot);
|
|
92
89
|
}
|
|
93
90
|
|
|
94
|
-
getPublicDataReadRequestHints(
|
|
95
|
-
publicDataReads: Tuple<PublicDataRead, typeof MAX_PUBLIC_DATA_READS_PER_TX>,
|
|
96
|
-
publicDataUpdateRequests: Tuple<PublicDataUpdateRequest, typeof MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX>,
|
|
97
|
-
publicDataHints: Tuple<PublicDataHint, typeof MAX_PUBLIC_DATA_HINTS>,
|
|
98
|
-
) {
|
|
99
|
-
return buildPublicDataReadRequestHints(publicDataReads, publicDataUpdateRequests, publicDataHints);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
91
|
async getNullifierMembershipWitness(nullifier: Fr) {
|
|
103
92
|
const index = await this.db.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer());
|
|
104
93
|
if (index === undefined) {
|
|
@@ -112,12 +112,6 @@ export class TailPhaseManager extends AbstractPhaseManager {
|
|
|
112
112
|
pendingPublicDataWrites,
|
|
113
113
|
);
|
|
114
114
|
|
|
115
|
-
const publicDataReadRequestHints = this.hintsBuilder.getPublicDataReadRequestHints(
|
|
116
|
-
validationRequests.publicDataReads,
|
|
117
|
-
pendingPublicDataWrites,
|
|
118
|
-
publicDataHints,
|
|
119
|
-
);
|
|
120
|
-
|
|
121
115
|
const currentState = await this.db.getStateReference();
|
|
122
116
|
|
|
123
117
|
return new PublicKernelTailCircuitPrivateInputs(
|
|
@@ -127,7 +121,6 @@ export class TailPhaseManager extends AbstractPhaseManager {
|
|
|
127
121
|
nullifierNonExistentReadRequestHints,
|
|
128
122
|
l1ToL2MsgReadRequestHints,
|
|
129
123
|
publicDataHints,
|
|
130
|
-
publicDataReadRequestHints,
|
|
131
124
|
currentState.partial,
|
|
132
125
|
);
|
|
133
126
|
}
|