@aztec/pxe 0.0.1-commit.a5db02d → 0.0.1-commit.aa0c64f
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/bin/check_oracle_version.js +3 -8
- package/dest/bin/index.d.ts +2 -2
- package/dest/bin/index.d.ts.map +1 -1
- package/dest/bin/index.js +1 -1
- package/dest/bin/oracle_version_helpers.d.ts +8 -25
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -1
- package/dest/bin/oracle_version_helpers.js +11 -219
- package/dest/config/package_info.js +1 -1
- package/dest/contract/helpers.d.ts +1 -1
- package/dest/contract/helpers.d.ts.map +1 -1
- package/dest/contract/helpers.js +3 -3
- package/dest/contract/skip_sync_contracts.d.ts +11 -0
- package/dest/contract/skip_sync_contracts.d.ts.map +1 -0
- package/dest/contract/skip_sync_contracts.js +18 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +5 -3
- package/dest/contract_function_simulator/index.d.ts +3 -3
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -2
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +7 -9
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tx.js +3 -44
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +5 -4
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +2 -2
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +3 -3
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +6 -6
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +87 -35
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +286 -286
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +5 -6
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +2 -1
- package/dest/entrypoints/client/store.d.ts +1 -1
- package/dest/entrypoints/client/store.d.ts.map +1 -1
- package/dest/entrypoints/client/store.js +16 -2
- package/dest/logs/log_service.d.ts +1 -1
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +7 -2
- package/dest/messages/tx_resolver_service.d.ts +2 -2
- package/dest/messages/tx_resolver_service.d.ts.map +1 -1
- package/dest/messages/tx_resolver_service.js +7 -2
- package/dest/oracle_version.d.ts +1 -1
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/batch_planner.d.ts +1 -1
- package/dest/private_kernel/batch_planner.d.ts.map +1 -1
- package/dest/private_kernel/batch_planner.js +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +45 -5
- package/dest/storage/fact_store/fact_store.d.ts +1 -1
- package/dest/storage/fact_store/fact_store.js +1 -1
- package/dest/storage/fact_store/index.d.ts +2 -2
- package/dest/storage/fact_store/index.d.ts.map +1 -1
- package/dest/storage/fact_store/index.js +1 -1
- package/dest/storage/fact_store/origin_state.d.ts +3 -1
- package/dest/storage/fact_store/origin_state.d.ts.map +1 -1
- package/dest/storage/fact_store/origin_state.js +7 -0
- package/dest/tagging/constants.d.ts +2 -1
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +9 -0
- package/dest/tagging/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +9 -4
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +60 -25
- package/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
- package/dest/tagging/testing/tag_query_test_utils.js +10 -0
- package/package.json +17 -17
- package/src/bin/check_oracle_version.ts +3 -10
- package/src/bin/index.ts +1 -5
- package/src/bin/oracle_version_helpers.ts +11 -268
- package/src/config/package_info.ts +1 -1
- package/src/contract/helpers.ts +3 -3
- package/src/contract/skip_sync_contracts.ts +23 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +5 -3
- package/src/contract_function_simulator/index.ts +23 -3
- package/src/contract_function_simulator/noir-structs/resolved_tx.ts +11 -45
- package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +4 -3
- package/src/contract_function_simulator/oracle/oracle_registry.ts +7 -8
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +285 -197
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +12 -7
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +8 -3
- package/src/entrypoints/client/store.ts +23 -7
- package/src/logs/log_service.ts +7 -2
- package/src/messages/tx_resolver_service.ts +8 -8
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/batch_planner.ts +0 -1
- package/src/private_kernel/private_kernel_execution_prover.ts +90 -4
- package/src/storage/fact_store/fact_store.ts +1 -1
- package/src/storage/fact_store/index.ts +1 -0
- package/src/storage/fact_store/origin_state.ts +9 -0
- package/src/tagging/constants.ts +10 -0
- package/src/tagging/index.ts +1 -1
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +103 -46
- package/src/tagging/testing/tag_query_test_utils.ts +11 -0
|
@@ -4,12 +4,12 @@ import { padArrayEnd } from '@aztec/foundation/collection';
|
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
6
|
import { FieldReader } from '@aztec/foundation/serialize';
|
|
7
|
-
import { fromUintArray } from '@aztec/simulator/client';
|
|
8
7
|
import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
9
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
9
|
import { BlockHash } from '@aztec/stdlib/block';
|
|
11
10
|
import { Tag, appTaggingSecretKindFromDeliveryMode } from '@aztec/stdlib/logs';
|
|
12
11
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
12
|
+
import { originBlockStateFromNumber } from '../../storage/fact_store/index.js';
|
|
13
13
|
import { BoundedVec } from '../noir-structs/bounded_vec.js';
|
|
14
14
|
import { EphemeralArray } from '../noir-structs/ephemeral_array.js';
|
|
15
15
|
import { EventValidationRequest } from '../noir-structs/event_validation_request.js';
|
|
@@ -28,7 +28,25 @@ import { packAsHintedNote } from './note_packing_utils.js';
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
// ─── Scalar Type Mappings ────────────────────────────────────────────────────
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* A leaf mapping whose {@link TypeMapping.label} is just its bare {@link TypeMapping.kind}. Its wire shape is arbitrary
|
|
33
|
+
* (several fields, or a variable-width run); a single-field scalar uses the shorter {@link SCALAR} instead.
|
|
34
|
+
*/ export function LEAF(mapping) {
|
|
35
|
+
return {
|
|
36
|
+
...mapping,
|
|
37
|
+
label: mapping.kind
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** A {@link LEAF} occupying a single `'scalar'` wire slot, so callers omit the shape. */ export function SCALAR(mapping) {
|
|
41
|
+
return LEAF({
|
|
42
|
+
...mapping,
|
|
43
|
+
shape: [
|
|
44
|
+
'scalar'
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export const FIELD = SCALAR({
|
|
49
|
+
kind: 'field',
|
|
32
50
|
serialization: {
|
|
33
51
|
fn: (v)=>[
|
|
34
52
|
v
|
|
@@ -36,12 +54,10 @@ export const FIELD = {
|
|
|
36
54
|
},
|
|
37
55
|
deserialization: {
|
|
38
56
|
fn: ([reader])=>reader.readField()
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
export const BOOL = {
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
export const BOOL = SCALAR({
|
|
60
|
+
kind: 'bool',
|
|
45
61
|
serialization: {
|
|
46
62
|
fn: (v)=>[
|
|
47
63
|
new Fr(v ? 1n : 0n)
|
|
@@ -49,70 +65,43 @@ export const BOOL = {
|
|
|
49
65
|
},
|
|
50
66
|
deserialization: {
|
|
51
67
|
fn: ([reader])=>!reader.readField().isZero()
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
export const U32 = {
|
|
58
|
-
serialization: {
|
|
59
|
-
fn: (v)=>[
|
|
60
|
-
new Fr(v)
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
deserialization: {
|
|
64
|
-
fn: ([reader])=>{
|
|
65
|
-
const value = reader.readField().toBigInt();
|
|
66
|
-
if (value > 0xffffffffn) {
|
|
67
|
-
throw new Error(`U32 overflow: value ${value} exceeds u32 max (${0xffffffffn})`);
|
|
68
|
-
}
|
|
69
|
-
return Number(value);
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
shape: [
|
|
73
|
-
'scalar'
|
|
74
|
-
]
|
|
75
|
-
};
|
|
76
|
-
export const BLOCK_NUMBER = {
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
export const U32 = SCALAR({
|
|
71
|
+
kind: 'u32',
|
|
77
72
|
serialization: {
|
|
78
73
|
fn: (v)=>[
|
|
79
74
|
new Fr(v)
|
|
80
75
|
]
|
|
81
76
|
},
|
|
82
77
|
deserialization: {
|
|
83
|
-
fn: ([reader])=>
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
78
|
+
fn: ([reader])=>Number(uintFromField(reader.readField(), 32))
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
export const BLOCK_NUMBER = ALIAS(U32, {
|
|
82
|
+
wrap: (v)=>BlockNumber(v),
|
|
83
|
+
unwrap: (v)=>v
|
|
84
|
+
});
|
|
85
|
+
export const U8 = SCALAR({
|
|
86
|
+
kind: 'u8',
|
|
90
87
|
serialization: {
|
|
91
88
|
fn: (byte)=>[
|
|
92
89
|
new Fr(byte)
|
|
93
90
|
]
|
|
94
91
|
},
|
|
95
92
|
deserialization: {
|
|
96
|
-
fn: ([reader])=>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
throw new Error(`BYTE overflow: value ${value} exceeds u8 max (255)`);
|
|
100
|
-
}
|
|
101
|
-
return Number(value);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
shape: [
|
|
105
|
-
'scalar'
|
|
106
|
-
]
|
|
107
|
-
};
|
|
93
|
+
fn: ([reader])=>Number(uintFromField(reader.readField(), 8))
|
|
94
|
+
}
|
|
95
|
+
});
|
|
108
96
|
// Noir passes `MessageDelivery` onchain variants here.
|
|
109
|
-
export const DELIVERY_MODE = {
|
|
97
|
+
export const DELIVERY_MODE = SCALAR({
|
|
98
|
+
kind: 'onchain-delivery-mode',
|
|
110
99
|
deserialization: {
|
|
111
|
-
fn: (readers)=>appTaggingSecretKindFromDeliveryMode(
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
100
|
+
fn: (readers)=>appTaggingSecretKindFromDeliveryMode(U8.deserialization.fn(readers))
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
export const RESOLVED_TAGGING_STRATEGY = LEAF({
|
|
104
|
+
kind: 'resolved-tagging-strategy',
|
|
116
105
|
serialization: {
|
|
117
106
|
fn: (resolved)=>resolvedTaggingStrategyToFields(resolved)
|
|
118
107
|
},
|
|
@@ -123,21 +112,39 @@ export const RESOLVED_TAGGING_STRATEGY = {
|
|
|
123
112
|
'scalar',
|
|
124
113
|
'scalar'
|
|
125
114
|
]
|
|
126
|
-
};
|
|
127
|
-
export const BIGINT = {
|
|
115
|
+
});
|
|
116
|
+
export const BIGINT = ALIAS(FIELD, {
|
|
117
|
+
wrap: (f)=>f.toBigInt(),
|
|
118
|
+
unwrap: (v)=>new Fr(v)
|
|
119
|
+
});
|
|
120
|
+
export const U64 = SCALAR({
|
|
121
|
+
kind: 'u64',
|
|
128
122
|
serialization: {
|
|
129
123
|
fn: (v)=>[
|
|
130
124
|
new Fr(v)
|
|
131
125
|
]
|
|
132
126
|
},
|
|
133
127
|
deserialization: {
|
|
134
|
-
fn: ([reader])=>reader.readField()
|
|
128
|
+
fn: ([reader])=>uintFromField(reader.readField(), 64)
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
export const U128 = SCALAR({
|
|
132
|
+
kind: 'u128',
|
|
133
|
+
serialization: {
|
|
134
|
+
fn: (v)=>[
|
|
135
|
+
new Fr(v)
|
|
136
|
+
]
|
|
135
137
|
},
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
};
|
|
140
|
-
|
|
138
|
+
deserialization: {
|
|
139
|
+
fn: ([reader])=>uintFromField(reader.readField(), 128)
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
export const LEAF_INDEX = ALIAS(FIELD, {
|
|
143
|
+
wrap: (f)=>f.toNumber(),
|
|
144
|
+
unwrap: (v)=>new Fr(v)
|
|
145
|
+
});
|
|
146
|
+
/** Reads every field in the slot as a UTF-8 character code. */ export const STR = LEAF({
|
|
147
|
+
kind: 'str',
|
|
141
148
|
serialization: {
|
|
142
149
|
fn: (str)=>[
|
|
143
150
|
Array.from(Buffer.from(str, 'utf-8')).map((b)=>new Fr(b))
|
|
@@ -155,8 +162,9 @@ export const BIGINT = {
|
|
|
155
162
|
shape: [
|
|
156
163
|
'variable'
|
|
157
164
|
]
|
|
158
|
-
};
|
|
159
|
-
export const AZTEC_ADDRESS = {
|
|
165
|
+
});
|
|
166
|
+
export const AZTEC_ADDRESS = SCALAR({
|
|
167
|
+
kind: 'aztec-address',
|
|
160
168
|
serialization: {
|
|
161
169
|
fn: (v)=>[
|
|
162
170
|
v.toField()
|
|
@@ -164,25 +172,14 @@ export const AZTEC_ADDRESS = {
|
|
|
164
172
|
},
|
|
165
173
|
deserialization: {
|
|
166
174
|
fn: ([reader])=>AztecAddress.fromFieldUnsafe(reader.readField())
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
new Fr(v.toBuffer())
|
|
176
|
-
]
|
|
177
|
-
},
|
|
178
|
-
deserialization: {
|
|
179
|
-
fn: ([reader])=>new BlockHash(reader.readField())
|
|
180
|
-
},
|
|
181
|
-
shape: [
|
|
182
|
-
'scalar'
|
|
183
|
-
]
|
|
184
|
-
};
|
|
185
|
-
export const FUNCTION_SELECTOR = {
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
export const BLOCK_HASH = ALIAS(FIELD, {
|
|
178
|
+
wrap: (f)=>new BlockHash(f),
|
|
179
|
+
unwrap: (v)=>new Fr(v.toBuffer())
|
|
180
|
+
});
|
|
181
|
+
export const FUNCTION_SELECTOR = SCALAR({
|
|
182
|
+
kind: 'function-selector',
|
|
186
183
|
serialization: {
|
|
187
184
|
fn: (v)=>[
|
|
188
185
|
v.toField()
|
|
@@ -190,50 +187,20 @@ export const FUNCTION_SELECTOR = {
|
|
|
190
187
|
},
|
|
191
188
|
deserialization: {
|
|
192
189
|
fn: ([reader])=>FunctionSelector.fromField(reader.readField())
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
shape: [
|
|
208
|
-
'scalar'
|
|
209
|
-
]
|
|
210
|
-
};
|
|
211
|
-
export const TX_HASH = {
|
|
212
|
-
serialization: {
|
|
213
|
-
fn: (v)=>[
|
|
214
|
-
v.hash
|
|
215
|
-
]
|
|
216
|
-
},
|
|
217
|
-
deserialization: {
|
|
218
|
-
fn: ([reader])=>TxHash.fromField(reader.readField())
|
|
219
|
-
},
|
|
220
|
-
shape: [
|
|
221
|
-
'scalar'
|
|
222
|
-
]
|
|
223
|
-
};
|
|
224
|
-
const TAG = {
|
|
225
|
-
serialization: {
|
|
226
|
-
fn: (v)=>[
|
|
227
|
-
v.value
|
|
228
|
-
]
|
|
229
|
-
},
|
|
230
|
-
deserialization: {
|
|
231
|
-
fn: ([reader])=>new Tag(reader.readField())
|
|
232
|
-
},
|
|
233
|
-
shape: [
|
|
234
|
-
'scalar'
|
|
235
|
-
]
|
|
236
|
-
};
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
export const NOTE_SELECTOR = ALIAS(FIELD, {
|
|
193
|
+
wrap: (f)=>NoteSelector.fromField(f),
|
|
194
|
+
unwrap: (v)=>v.toField()
|
|
195
|
+
});
|
|
196
|
+
export const TX_HASH = ALIAS(FIELD, {
|
|
197
|
+
wrap: (f)=>TxHash.fromField(f),
|
|
198
|
+
unwrap: (v)=>v.hash
|
|
199
|
+
});
|
|
200
|
+
const TAG = ALIAS(FIELD, {
|
|
201
|
+
wrap: (f)=>new Tag(f),
|
|
202
|
+
unwrap: (v)=>v.value
|
|
203
|
+
});
|
|
237
204
|
export const POINT = STRUCT([
|
|
238
205
|
{
|
|
239
206
|
name: 'x',
|
|
@@ -244,7 +211,8 @@ export const POINT = STRUCT([
|
|
|
244
211
|
type: FIELD
|
|
245
212
|
}
|
|
246
213
|
]);
|
|
247
|
-
const LOG_SOURCE = {
|
|
214
|
+
const LOG_SOURCE = SCALAR({
|
|
215
|
+
kind: 'log-source',
|
|
248
216
|
serialization: {
|
|
249
217
|
fn: (v)=>[
|
|
250
218
|
new Fr(v)
|
|
@@ -252,12 +220,10 @@ const LOG_SOURCE = {
|
|
|
252
220
|
},
|
|
253
221
|
deserialization: {
|
|
254
222
|
fn: ([reader])=>logSourceFromField(reader.readField())
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
};
|
|
260
|
-
export const ETH_ADDRESS = {
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
export const ETH_ADDRESS = SCALAR({
|
|
226
|
+
kind: 'eth-address',
|
|
261
227
|
serialization: {
|
|
262
228
|
fn: (v)=>[
|
|
263
229
|
v.toField()
|
|
@@ -265,21 +231,11 @@ export const ETH_ADDRESS = {
|
|
|
265
231
|
},
|
|
266
232
|
deserialization: {
|
|
267
233
|
fn: ([reader])=>EthAddress.fromField(reader.readField())
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
};
|
|
273
|
-
export const SLOT_NUMBER = {
|
|
274
|
-
serialization: {
|
|
275
|
-
fn: (v)=>[
|
|
276
|
-
new Fr(v)
|
|
277
|
-
]
|
|
278
|
-
},
|
|
279
|
-
shape: [
|
|
280
|
-
'scalar'
|
|
281
|
-
]
|
|
282
|
-
};
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
export const SLOT_NUMBER = ALIAS(FIELD, {
|
|
237
|
+
unwrap: (v)=>new Fr(v)
|
|
238
|
+
});
|
|
283
239
|
const APPEND_ONLY_TREE_SNAPSHOT = STRUCT([
|
|
284
240
|
{
|
|
285
241
|
name: 'root',
|
|
@@ -287,7 +243,7 @@ const APPEND_ONLY_TREE_SNAPSHOT = STRUCT([
|
|
|
287
243
|
},
|
|
288
244
|
{
|
|
289
245
|
name: 'nextAvailableLeafIndex',
|
|
290
|
-
type:
|
|
246
|
+
type: LEAF_INDEX
|
|
291
247
|
}
|
|
292
248
|
]);
|
|
293
249
|
const PARTIAL_STATE_REFERENCE = STRUCT([
|
|
@@ -317,11 +273,11 @@ const STATE_REFERENCE = STRUCT([
|
|
|
317
273
|
const GAS_FEES = STRUCT([
|
|
318
274
|
{
|
|
319
275
|
name: 'feePerDaGas',
|
|
320
|
-
type:
|
|
276
|
+
type: U128
|
|
321
277
|
},
|
|
322
278
|
{
|
|
323
279
|
name: 'feePerL2Gas',
|
|
324
|
-
type:
|
|
280
|
+
type: U128
|
|
325
281
|
}
|
|
326
282
|
]);
|
|
327
283
|
const GLOBAL_VARIABLES = STRUCT([
|
|
@@ -343,7 +299,7 @@ const GLOBAL_VARIABLES = STRUCT([
|
|
|
343
299
|
},
|
|
344
300
|
{
|
|
345
301
|
name: 'timestamp',
|
|
346
|
-
type:
|
|
302
|
+
type: U64
|
|
347
303
|
},
|
|
348
304
|
{
|
|
349
305
|
name: 'coinbase',
|
|
@@ -577,16 +533,6 @@ export const CONTRACT_CLASS_LOG = STRUCT([
|
|
|
577
533
|
type: U32
|
|
578
534
|
}
|
|
579
535
|
]);
|
|
580
|
-
const REVERT_CODE = {
|
|
581
|
-
serialization: {
|
|
582
|
-
fn: (rc)=>[
|
|
583
|
-
rc.toField()
|
|
584
|
-
]
|
|
585
|
-
},
|
|
586
|
-
shape: [
|
|
587
|
-
'scalar'
|
|
588
|
-
]
|
|
589
|
-
};
|
|
590
536
|
const PUBLIC_DATA_WRITE = STRUCT([
|
|
591
537
|
{
|
|
592
538
|
name: 'leafSlot',
|
|
@@ -635,7 +581,7 @@ const CONTRACT_CLASS_LOGS = FIXED_ARRAY(CONTRACT_CLASS_LOG_ENTRY, MAX_CONTRACT_C
|
|
|
635
581
|
export const TX_EFFECT = STRUCT([
|
|
636
582
|
{
|
|
637
583
|
name: 'revertCode',
|
|
638
|
-
type:
|
|
584
|
+
type: U8
|
|
639
585
|
},
|
|
640
586
|
{
|
|
641
587
|
name: 'txHash',
|
|
@@ -674,7 +620,8 @@ export const TX_EFFECT = STRUCT([
|
|
|
674
620
|
type: CONTRACT_CLASS_LOGS
|
|
675
621
|
}
|
|
676
622
|
]);
|
|
677
|
-
export const NOTE = {
|
|
623
|
+
export const NOTE = LEAF({
|
|
624
|
+
kind: 'note',
|
|
678
625
|
serialization: {
|
|
679
626
|
fn: (noteData)=>packAsHintedNote({
|
|
680
627
|
contractAddress: noteData.contractAddress,
|
|
@@ -691,23 +638,25 @@ export const NOTE = {
|
|
|
691
638
|
shape: [
|
|
692
639
|
'variable'
|
|
693
640
|
]
|
|
694
|
-
};
|
|
695
|
-
export const NOTE_VALIDATION_REQUEST = {
|
|
641
|
+
});
|
|
642
|
+
export const NOTE_VALIDATION_REQUEST = LEAF({
|
|
643
|
+
kind: 'note-validation-request',
|
|
696
644
|
deserialization: {
|
|
697
645
|
fn: ([reader])=>NoteValidationRequest.fromFields(reader)
|
|
698
646
|
},
|
|
699
647
|
shape: [
|
|
700
648
|
'variable'
|
|
701
649
|
]
|
|
702
|
-
};
|
|
703
|
-
export const EVENT_VALIDATION_REQUEST = {
|
|
650
|
+
});
|
|
651
|
+
export const EVENT_VALIDATION_REQUEST = LEAF({
|
|
652
|
+
kind: 'event-validation-request',
|
|
704
653
|
deserialization: {
|
|
705
654
|
fn: ([reader])=>EventValidationRequest.fromFields(reader)
|
|
706
655
|
},
|
|
707
656
|
shape: [
|
|
708
657
|
'variable'
|
|
709
658
|
]
|
|
710
|
-
};
|
|
659
|
+
});
|
|
711
660
|
export const LOG_RETRIEVAL_REQUEST = STRUCT([
|
|
712
661
|
{
|
|
713
662
|
name: 'contractAddress',
|
|
@@ -753,27 +702,35 @@ export const LOG_RETRIEVAL_RESPONSE = STRUCT([
|
|
|
753
702
|
},
|
|
754
703
|
{
|
|
755
704
|
name: 'blockTimestamp',
|
|
756
|
-
type:
|
|
705
|
+
type: U64
|
|
757
706
|
},
|
|
758
707
|
{
|
|
759
708
|
name: 'blockHash',
|
|
760
709
|
type: BLOCK_HASH
|
|
761
710
|
}
|
|
762
711
|
]);
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
fn: (resolved)=>[
|
|
768
|
-
resolved.toFields()
|
|
769
|
-
]
|
|
712
|
+
export const RESOLVED_TX = STRUCT([
|
|
713
|
+
{
|
|
714
|
+
name: 'txHash',
|
|
715
|
+
type: TX_HASH
|
|
770
716
|
},
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
717
|
+
{
|
|
718
|
+
name: 'uniqueNoteHashesInTx',
|
|
719
|
+
type: FIXED_BOUNDED_VEC(FIELD, MAX_NOTE_HASHES_PER_TX)
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
name: 'firstNullifierInTx',
|
|
723
|
+
type: FIELD
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
name: 'blockNumber',
|
|
727
|
+
type: U32
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
name: 'blockHash',
|
|
731
|
+
type: FIELD
|
|
732
|
+
}
|
|
733
|
+
]);
|
|
777
734
|
export const PENDING_TAGGED_LOG = STRUCT([
|
|
778
735
|
{
|
|
779
736
|
name: 'log',
|
|
@@ -784,93 +741,109 @@ export const PENDING_TAGGED_LOG = STRUCT([
|
|
|
784
741
|
type: RESOLVED_TX
|
|
785
742
|
}
|
|
786
743
|
]);
|
|
787
|
-
export const ORIGIN_BLOCK =
|
|
744
|
+
export const ORIGIN_BLOCK = STRUCT([
|
|
745
|
+
{
|
|
746
|
+
name: 'blockNumber',
|
|
747
|
+
type: U32
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
name: 'blockHash',
|
|
751
|
+
type: FIELD
|
|
752
|
+
}
|
|
753
|
+
]);
|
|
754
|
+
const ORIGIN_BLOCK_STATE = SCALAR({
|
|
755
|
+
kind: 'origin-block-state',
|
|
788
756
|
serialization: {
|
|
789
|
-
fn: (
|
|
790
|
-
new Fr(
|
|
791
|
-
ob.blockHash
|
|
757
|
+
fn: (v)=>[
|
|
758
|
+
new Fr(v)
|
|
792
759
|
]
|
|
793
760
|
},
|
|
794
761
|
deserialization: {
|
|
795
|
-
fn: ([
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
762
|
+
fn: ([reader])=>originBlockStateFromNumber(reader.readField().toNumber())
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
/** Read-side origin of a retractable fact, carrying the chain state of its origin block. */ export const RETRACTABLE_FACT_ORIGIN = STRUCT([
|
|
766
|
+
{
|
|
767
|
+
name: 'blockNumber',
|
|
768
|
+
type: U32
|
|
799
769
|
},
|
|
800
|
-
|
|
801
|
-
'
|
|
802
|
-
|
|
803
|
-
]
|
|
804
|
-
};
|
|
805
|
-
/** Read-side origin of a retractable fact, carrying the chain state of its origin block. */ export const RETRACTABLE_FACT_ORIGIN = {
|
|
806
|
-
serialization: {
|
|
807
|
-
fn: (o)=>[
|
|
808
|
-
new Fr(o.blockNumber),
|
|
809
|
-
o.blockHash,
|
|
810
|
-
new Fr(o.blockState)
|
|
811
|
-
]
|
|
770
|
+
{
|
|
771
|
+
name: 'blockHash',
|
|
772
|
+
type: FIELD
|
|
812
773
|
},
|
|
813
|
-
|
|
814
|
-
'
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
serialization: {
|
|
823
|
-
fn: (f)=>[
|
|
824
|
-
f.factTypeId,
|
|
825
|
-
f.payload.materializeSlot((v)=>FIELD.serialization.fn(v).flat()),
|
|
826
|
-
...OPTION(RETRACTABLE_FACT_ORIGIN).serialization.fn(f.originBlock)
|
|
827
|
-
]
|
|
774
|
+
{
|
|
775
|
+
name: 'blockState',
|
|
776
|
+
type: ORIGIN_BLOCK_STATE
|
|
777
|
+
}
|
|
778
|
+
]);
|
|
779
|
+
export const FACT = STRUCT([
|
|
780
|
+
{
|
|
781
|
+
name: 'factTypeId',
|
|
782
|
+
type: FIELD
|
|
828
783
|
},
|
|
829
|
-
|
|
830
|
-
'
|
|
831
|
-
|
|
832
|
-
'scalar',
|
|
833
|
-
'scalar',
|
|
834
|
-
'scalar',
|
|
835
|
-
'scalar'
|
|
836
|
-
]
|
|
837
|
-
};
|
|
838
|
-
export const FACT_COLLECTION = {
|
|
839
|
-
serialization: {
|
|
840
|
-
fn: (c)=>[
|
|
841
|
-
c.contractAddress.toField(),
|
|
842
|
-
c.scope.toField(),
|
|
843
|
-
c.factCollectionTypeId,
|
|
844
|
-
c.factCollectionId,
|
|
845
|
-
c.facts.materializeSlot((v)=>FACT.serialization.fn(v).flat())
|
|
846
|
-
]
|
|
784
|
+
{
|
|
785
|
+
name: 'payload',
|
|
786
|
+
type: EPHEMERAL_ARRAY(FIELD)
|
|
847
787
|
},
|
|
848
|
-
|
|
849
|
-
'
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
deserialization: {
|
|
858
|
-
fn: ([reader])=>({
|
|
859
|
-
secret: reader.readField(),
|
|
860
|
-
mode: appTaggingSecretKindFromDeliveryMode(BYTE.deserialization.fn([
|
|
861
|
-
reader
|
|
862
|
-
]))
|
|
863
|
-
})
|
|
788
|
+
{
|
|
789
|
+
name: 'originBlock',
|
|
790
|
+
type: OPTION(RETRACTABLE_FACT_ORIGIN)
|
|
791
|
+
}
|
|
792
|
+
]);
|
|
793
|
+
export const FACT_COLLECTION = STRUCT([
|
|
794
|
+
{
|
|
795
|
+
name: 'contractAddress',
|
|
796
|
+
type: AZTEC_ADDRESS
|
|
864
797
|
},
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
798
|
+
{
|
|
799
|
+
name: 'scope',
|
|
800
|
+
type: AZTEC_ADDRESS
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
name: 'factCollectionTypeId',
|
|
804
|
+
type: FIELD
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
name: 'factCollectionId',
|
|
808
|
+
type: FIELD
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
name: 'facts',
|
|
812
|
+
type: EPHEMERAL_ARRAY(FACT)
|
|
813
|
+
}
|
|
814
|
+
]);
|
|
815
|
+
export const PROVIDED_SECRET = STRUCT([
|
|
816
|
+
{
|
|
817
|
+
name: 'secret',
|
|
818
|
+
type: FIELD
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
name: 'mode',
|
|
822
|
+
type: DELIVERY_MODE
|
|
823
|
+
}
|
|
824
|
+
]);
|
|
871
825
|
// ─── Combinator Type Mappings ────────────────────────────────────────────────
|
|
872
|
-
|
|
826
|
+
/**
|
|
827
|
+
* A TS-side alias of `base`: the same Noir type on the wire (it inherits `base`'s `kind`, `label`, and `shape`) but a
|
|
828
|
+
* richer TS value. `wrap` maps a base value to the alias, `unwrap` back; a serialize-only alias passes only `unwrap`.
|
|
829
|
+
*/ export function ALIAS(base, conversions) {
|
|
830
|
+
const { wrap, unwrap } = conversions;
|
|
873
831
|
return {
|
|
832
|
+
kind: base.kind,
|
|
833
|
+
label: base.label,
|
|
834
|
+
serialization: base.serialization && unwrap ? {
|
|
835
|
+
fn: (value)=>base.serialization.fn(unwrap(value))
|
|
836
|
+
} : undefined,
|
|
837
|
+
deserialization: base.deserialization && wrap ? {
|
|
838
|
+
fn: (readers)=>wrap(base.deserialization.fn(readers))
|
|
839
|
+
} : undefined,
|
|
840
|
+
shape: base.shape
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
function SIBLING_PATH(height) {
|
|
844
|
+
return LEAF({
|
|
845
|
+
// On the wire (and in Noir) a sibling path is a plain `[Field; height]`, so it shares the fixed-array kind.
|
|
846
|
+
kind: `array(field,${height})`,
|
|
874
847
|
serialization: {
|
|
875
848
|
fn: (sp)=>[
|
|
876
849
|
sp.toFields()
|
|
@@ -881,7 +854,7 @@ function SIBLING_PATH(height) {
|
|
|
881
854
|
len: height
|
|
882
855
|
}
|
|
883
856
|
]
|
|
884
|
-
};
|
|
857
|
+
});
|
|
885
858
|
}
|
|
886
859
|
export function MEMBERSHIP_WITNESS(height) {
|
|
887
860
|
return STRUCT([
|
|
@@ -898,6 +871,7 @@ export function MEMBERSHIP_WITNESS(height) {
|
|
|
898
871
|
export function ARRAY(inner) {
|
|
899
872
|
return {
|
|
900
873
|
kind: 'array',
|
|
874
|
+
label: `array(${inner.label})`,
|
|
901
875
|
inner,
|
|
902
876
|
serialization: inner.serialization ? {
|
|
903
877
|
fn: (values)=>[
|
|
@@ -924,6 +898,7 @@ export function ARRAY(inner) {
|
|
|
924
898
|
const elementWidth = fieldWidth(element.shape);
|
|
925
899
|
return {
|
|
926
900
|
kind: 'fixed-array',
|
|
901
|
+
label: `array(${element.label},${length})`,
|
|
927
902
|
inner: element,
|
|
928
903
|
length,
|
|
929
904
|
serialization: element.serialization ? {
|
|
@@ -948,7 +923,7 @@ export function ARRAY(inner) {
|
|
|
948
923
|
*
|
|
949
924
|
* Both directions are derived from `element`: bidirectional iff `element` has both serialization and deserialization.
|
|
950
925
|
*
|
|
951
|
-
* @example Serializing `BoundedVec.from({ data: [0x41, 0x42], maxLength: 4 })` with `BOUNDED_VEC(
|
|
926
|
+
* @example Serializing `BoundedVec.from({ data: [0x41, 0x42], maxLength: 4 })` with `BOUNDED_VEC(U8)`:
|
|
952
927
|
* ```
|
|
953
928
|
* slot 0: [Fr(0x41), Fr(0x42), Fr(0), Fr(0)] // data padded to maxLength
|
|
954
929
|
* slot 1: Fr(2) // actual length
|
|
@@ -956,6 +931,7 @@ export function ARRAY(inner) {
|
|
|
956
931
|
*/ export function BOUNDED_VEC(inner) {
|
|
957
932
|
return {
|
|
958
933
|
kind: 'bounded-vec',
|
|
934
|
+
label: `bounded-vec(${inner.label})`,
|
|
959
935
|
inner,
|
|
960
936
|
serialization: inner.serialization ? {
|
|
961
937
|
fn: (bv)=>{
|
|
@@ -1003,6 +979,7 @@ export function ARRAY(inner) {
|
|
|
1003
979
|
const width = fieldWidth(element.shape);
|
|
1004
980
|
return {
|
|
1005
981
|
kind: 'fixed-bounded-vec',
|
|
982
|
+
label: `bounded-vec(${element.label},${maxLength})`,
|
|
1006
983
|
inner: element,
|
|
1007
984
|
maxLength,
|
|
1008
985
|
serialization: element.serialization ? {
|
|
@@ -1046,6 +1023,7 @@ export function ARRAY(inner) {
|
|
|
1046
1023
|
*/ export function OPTION(inner) {
|
|
1047
1024
|
return {
|
|
1048
1025
|
kind: 'option',
|
|
1026
|
+
label: `option(${inner.label})`,
|
|
1049
1027
|
inner,
|
|
1050
1028
|
serialization: inner.serialization ? {
|
|
1051
1029
|
fn: (opt)=>opt.isSome() ? [
|
|
@@ -1074,31 +1052,13 @@ export function ARRAY(inner) {
|
|
|
1074
1052
|
]
|
|
1075
1053
|
};
|
|
1076
1054
|
}
|
|
1077
|
-
/**
|
|
1078
|
-
* A fixed packed uint buffer (Noir `[u8; length]` at `bitSize` 8): one slot of `length` packed uint values ↔ `Buffer`.
|
|
1079
|
-
* `length` is the field count, which equals the byte count at `bitSize` 8.
|
|
1080
|
-
*/ export function BUFFER(bitSize, length) {
|
|
1081
|
-
return {
|
|
1082
|
-
serialization: {
|
|
1083
|
-
fn: (buf)=>[
|
|
1084
|
-
Array.from(buf).map((b)=>new Fr(b))
|
|
1085
|
-
]
|
|
1086
|
-
},
|
|
1087
|
-
deserialization: {
|
|
1088
|
-
fn: ([reader])=>fromUintArray(reader.readFieldArray(length).map((f)=>f.toString()), bitSize)
|
|
1089
|
-
},
|
|
1090
|
-
shape: [
|
|
1091
|
-
{
|
|
1092
|
-
len: length
|
|
1093
|
-
}
|
|
1094
|
-
]
|
|
1095
|
-
};
|
|
1096
|
-
}
|
|
1097
1055
|
export function EPHEMERAL_ARRAY(element) {
|
|
1098
1056
|
// EphemeralArray.readAll hands each row's flat fields in as a single reader; reconstruct the element's per-slot
|
|
1099
1057
|
// readers from its shape, deserialize, and assert the row was fully consumed so a row with trailing fields is
|
|
1100
1058
|
// rejected.
|
|
1101
1059
|
const rowElement = element.deserialization ? {
|
|
1060
|
+
kind: element.kind,
|
|
1061
|
+
label: element.label,
|
|
1102
1062
|
deserialization: {
|
|
1103
1063
|
fn: ([rowReader])=>deserializeElement(element, rowReader.readFieldArray(rowReader.remainingFields()))
|
|
1104
1064
|
},
|
|
@@ -1109,6 +1069,9 @@ export function EPHEMERAL_ARRAY(element) {
|
|
|
1109
1069
|
]
|
|
1110
1070
|
} : undefined;
|
|
1111
1071
|
return {
|
|
1072
|
+
kind: 'ephemeral-array',
|
|
1073
|
+
label: `ephemeral-array(${element.label})`,
|
|
1074
|
+
inner: element,
|
|
1112
1075
|
serialization: element.serialization ? {
|
|
1113
1076
|
fn: (ea)=>[
|
|
1114
1077
|
ea.materializeSlot((v)=>serializeElement(element, v))
|
|
@@ -1130,6 +1093,7 @@ export function EPHEMERAL_ARRAY(element) {
|
|
|
1130
1093
|
*/ export function STRUCT(fields) {
|
|
1131
1094
|
return {
|
|
1132
1095
|
kind: 'struct',
|
|
1096
|
+
label: `{${structFieldLabels(fields)}}`,
|
|
1133
1097
|
fields,
|
|
1134
1098
|
serialization: fields.every((f)=>f.type.serialization) ? {
|
|
1135
1099
|
fn: (value)=>{
|
|
@@ -1152,6 +1116,42 @@ export function EPHEMERAL_ARRAY(element) {
|
|
|
1152
1116
|
shape: fields.flatMap((f)=>f.type.shape)
|
|
1153
1117
|
};
|
|
1154
1118
|
}
|
|
1119
|
+
export function isArrayMapping(type) {
|
|
1120
|
+
return type.kind === 'array';
|
|
1121
|
+
}
|
|
1122
|
+
export function isBoundedVecMapping(type) {
|
|
1123
|
+
return type.kind === 'bounded-vec';
|
|
1124
|
+
}
|
|
1125
|
+
export function isOptionMapping(type) {
|
|
1126
|
+
return type.kind === 'option';
|
|
1127
|
+
}
|
|
1128
|
+
export function isStructMapping(type) {
|
|
1129
|
+
return type.kind === 'struct';
|
|
1130
|
+
}
|
|
1131
|
+
export function isFixedArrayMapping(type) {
|
|
1132
|
+
return type.kind === 'fixed-array';
|
|
1133
|
+
}
|
|
1134
|
+
export function isFixedBoundedVecMapping(type) {
|
|
1135
|
+
return type.kind === 'fixed-bounded-vec';
|
|
1136
|
+
}
|
|
1137
|
+
export function isEphemeralArrayMapping(type) {
|
|
1138
|
+
return type.kind === 'ephemeral-array';
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* The comma-joined labels of a struct's fields, with nested struct labels spliced into the parent: nesting affects
|
|
1142
|
+
* neither the wire (struct slots concatenate) nor the interface, so the label treats nested and flat declarations as
|
|
1143
|
+
* the same type.
|
|
1144
|
+
*/ function structFieldLabels(fields) {
|
|
1145
|
+
return fields.map((f)=>isStructMapping(f.type) ? structFieldLabels(f.type.fields) : f.type.label).join(',');
|
|
1146
|
+
}
|
|
1147
|
+
/** The field's value as a bigint, asserted to fit a `bits`-wide uint. */ function uintFromField(field, bits) {
|
|
1148
|
+
const max = 2n ** BigInt(bits) - 1n;
|
|
1149
|
+
const value = field.toBigInt();
|
|
1150
|
+
if (value > max) {
|
|
1151
|
+
throw new Error(`u${bits} overflow: value ${value} exceeds max (${max})`);
|
|
1152
|
+
}
|
|
1153
|
+
return value;
|
|
1154
|
+
}
|
|
1155
1155
|
/** Number of InputSlots a deserializable type spans, derived from its {@link TypeMapping.shape}. */ export function slotsOf(mapping) {
|
|
1156
1156
|
return mapping.shape.length;
|
|
1157
1157
|
}
|