@aztec/stdlib 0.84.0 → 0.85.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.d.ts +2474 -284
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +116 -17
- package/dest/avm/avm_proving_request.d.ts +1071 -23
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/block/in_block.d.ts.map +1 -1
- package/dest/block/index.d.ts +1 -1
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +1 -1
- package/dest/block/l2_block_source.d.ts +8 -5
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +9 -0
- package/dest/block/l2_block_stream/index.d.ts +4 -0
- package/dest/block/l2_block_stream/index.d.ts.map +1 -0
- package/dest/block/l2_block_stream/index.js +3 -0
- package/dest/block/l2_block_stream/interfaces.d.ts +26 -0
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -0
- package/dest/block/l2_block_stream/interfaces.js +1 -0
- package/dest/block/{l2_block_downloader → l2_block_stream}/l2_block_stream.d.ts +4 -24
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -0
- package/dest/block/{l2_block_downloader → l2_block_stream}/l2_block_stream.js +29 -10
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +18 -0
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -0
- package/dest/block/l2_block_stream/l2_tips_memory_store.js +70 -0
- package/dest/block/test/index.d.ts +2 -0
- package/dest/block/test/index.d.ts.map +1 -0
- package/dest/block/test/index.js +1 -0
- package/dest/block/test/l2_tips_store_test_suite.d.ts +3 -0
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -0
- package/dest/block/test/l2_tips_store_test_suite.js +107 -0
- package/dest/database-version/version_manager.d.ts +21 -5
- package/dest/database-version/version_manager.d.ts.map +1 -1
- package/dest/database-version/version_manager.js +25 -15
- package/dest/epoch-helpers/index.d.ts +9 -0
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +15 -2
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +4 -4
- package/dest/interfaces/aztec-node.d.ts +5 -6
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +2 -3
- package/dest/interfaces/proving-job.d.ts +1071 -23
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/pxe.d.ts +5 -7
- package/dest/interfaces/pxe.d.ts.map +1 -1
- package/dest/interfaces/pxe.js +2 -7
- package/dest/interfaces/world_state.d.ts +3 -2
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/logs/log_with_tx_data.d.ts +3 -2
- package/dest/logs/log_with_tx_data.d.ts.map +1 -1
- package/dest/logs/log_with_tx_data.js +3 -2
- package/dest/logs/pending_tagged_log.d.ts +4 -2
- package/dest/logs/pending_tagged_log.d.ts.map +1 -1
- package/dest/logs/pending_tagged_log.js +6 -3
- package/dest/messaging/l1_to_l2_message_source.d.ts +5 -0
- package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/proofs/proof.d.ts +4 -1
- package/dest/proofs/proof.d.ts.map +1 -1
- package/dest/proofs/proof.js +9 -17
- package/dest/tests/factories.d.ts +5 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +23 -7
- package/dest/tests/mocks.d.ts +3 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +3 -2
- package/dest/tx/index.d.ts +2 -0
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +2 -0
- package/dest/tx/indexed_tx_effect.d.ts +24 -0
- package/dest/tx/indexed_tx_effect.d.ts.map +1 -0
- package/dest/tx/indexed_tx_effect.js +14 -0
- package/dest/tx/tx_hash.d.ts.map +1 -1
- package/dest/tx/tx_hash.js +1 -4
- package/dest/tx/validator/error_texts.d.ts +20 -0
- package/dest/tx/validator/error_texts.d.ts.map +1 -0
- package/dest/tx/validator/error_texts.js +27 -0
- package/package.json +8 -6
- package/src/avm/avm.ts +188 -29
- package/src/block/in_block.ts +1 -0
- package/src/block/index.ts +1 -1
- package/src/block/l2_block_source.ts +15 -5
- package/src/block/l2_block_stream/index.ts +3 -0
- package/src/block/l2_block_stream/interfaces.ts +33 -0
- package/src/block/{l2_block_downloader → l2_block_stream}/l2_block_stream.ts +34 -44
- package/src/block/l2_block_stream/l2_tips_memory_store.ts +75 -0
- package/src/block/test/index.ts +1 -0
- package/src/block/test/l2_tips_store_test_suite.ts +87 -0
- package/src/database-version/version_manager.ts +56 -17
- package/src/epoch-helpers/index.ts +19 -0
- package/src/interfaces/archiver.ts +3 -3
- package/src/interfaces/aztec-node.ts +7 -6
- package/src/interfaces/pxe.ts +15 -11
- package/src/interfaces/world_state.ts +3 -2
- package/src/logs/log_with_tx_data.ts +4 -3
- package/src/logs/pending_tagged_log.ts +5 -2
- package/src/messaging/l1_to_l2_message_source.ts +7 -0
- package/src/proofs/proof.ts +9 -19
- package/src/tests/factories.ts +54 -4
- package/src/tests/mocks.ts +6 -1
- package/src/tx/index.ts +2 -0
- package/src/tx/indexed_tx_effect.ts +17 -0
- package/src/tx/tx_hash.ts +0 -4
- package/src/tx/validator/error_texts.ts +34 -0
- package/dest/block/l2_block_downloader/index.d.ts +0 -3
- package/dest/block/l2_block_downloader/index.d.ts.map +0 -1
- package/dest/block/l2_block_downloader/index.js +0 -2
- package/dest/block/l2_block_downloader/l2_block_downloader.d.ts +0 -58
- package/dest/block/l2_block_downloader/l2_block_downloader.d.ts.map +0 -1
- package/dest/block/l2_block_downloader/l2_block_downloader.js +0 -124
- package/dest/block/l2_block_downloader/l2_block_stream.d.ts.map +0 -1
- package/src/block/l2_block_downloader/index.ts +0 -2
- package/src/block/l2_block_downloader/l2_block_downloader.ts +0 -149
|
@@ -2,6 +2,7 @@ import { MAX_NOTE_HASHES_PER_TX, PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/const
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
|
|
4
4
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
5
|
+
import type { TxHash } from '../tx/tx_hash.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Represents a pending tagged log as it is stored in the pending tagged log array to which the syncNotes oracle
|
|
@@ -10,21 +11,23 @@ import type { AztecAddress } from '../aztec-address/index.js';
|
|
|
10
11
|
export class PendingTaggedLog {
|
|
11
12
|
constructor(
|
|
12
13
|
public log: Fr[],
|
|
13
|
-
public txHash:
|
|
14
|
+
public txHash: TxHash,
|
|
14
15
|
public uniqueNoteHashesInTx: Fr[],
|
|
15
16
|
public firstNullifierInTx: Fr,
|
|
16
17
|
public recipient: AztecAddress,
|
|
17
18
|
public logIndexInTx: number,
|
|
19
|
+
public txIndexInBlock: number,
|
|
18
20
|
) {}
|
|
19
21
|
|
|
20
22
|
toFields(): Fr[] {
|
|
21
23
|
return [
|
|
22
24
|
...serializeBoundedVec(this.log, PRIVATE_LOG_SIZE_IN_FIELDS),
|
|
23
|
-
this.txHash,
|
|
25
|
+
this.txHash.hash,
|
|
24
26
|
...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
|
|
25
27
|
this.firstNullifierInTx,
|
|
26
28
|
this.recipient.toField(),
|
|
27
29
|
new Fr(this.logIndexInTx),
|
|
30
|
+
new Fr(this.txIndexInBlock),
|
|
28
31
|
];
|
|
29
32
|
}
|
|
30
33
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
|
|
3
|
+
import type { L2Tips } from '../block/l2_block_source.js';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Interface of classes allowing for the retrieval of L1 to L2 messages.
|
|
5
7
|
*/
|
|
@@ -23,4 +25,9 @@ export interface L1ToL2MessageSource {
|
|
|
23
25
|
* @returns The number of the latest L2 block processed by the implementation.
|
|
24
26
|
*/
|
|
25
27
|
getBlockNumber(): Promise<number>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Returns the tips of the L2 chain.
|
|
31
|
+
*/
|
|
32
|
+
getL2Tips(): Promise<L2Tips>;
|
|
26
33
|
}
|
package/src/proofs/proof.ts
CHANGED
|
@@ -59,20 +59,26 @@ export class Proof {
|
|
|
59
59
|
return bufferToHex(this.toBuffer());
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Returns the proof without the public inputs, but includes the pairing point object as part of the proof.
|
|
64
|
+
* @returns Proof in bytes form, including the pairing point object at the start.
|
|
65
|
+
*/
|
|
62
66
|
public withoutPublicInputs(): Buffer {
|
|
63
67
|
if (this.isEmpty()) {
|
|
64
68
|
return this.buffer;
|
|
65
69
|
}
|
|
66
70
|
// We are indexing to this particular size because we are assuming the proof buffer looks like:
|
|
67
71
|
// [binary public inputs, binary proof]
|
|
68
|
-
|
|
72
|
+
// Here, we are assuming the pairing point object is the last 16 fields of the public inputs.
|
|
73
|
+
assert(this.numPublicInputs >= AGGREGATION_OBJECT_LENGTH, 'Proof does not contain an aggregation object');
|
|
74
|
+
const proofStart = Fr.SIZE_IN_BYTES * (this.numPublicInputs - AGGREGATION_OBJECT_LENGTH);
|
|
69
75
|
assert(this.buffer.length >= proofStart, 'Proof buffer is not appropriately sized to call withoutPublicInputs()');
|
|
70
76
|
return this.buffer.subarray(proofStart);
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
// This function assumes that the proof will contain an aggregation object and look something like:
|
|
74
80
|
// [binary public inputs, aggregation object, rest of proof]
|
|
75
|
-
// We are extracting the binary public inputs and reading them as Frs
|
|
81
|
+
// We are extracting the binary public inputs and reading them as Frs.
|
|
76
82
|
public extractPublicInputs(): Fr[] {
|
|
77
83
|
if (this.isEmpty()) {
|
|
78
84
|
// return array of this.numPublicInputs 0s
|
|
@@ -81,26 +87,10 @@ export class Proof {
|
|
|
81
87
|
assert(this.numPublicInputs >= AGGREGATION_OBJECT_LENGTH, 'Proof does not contain an aggregation object');
|
|
82
88
|
const numInnerPublicInputs = this.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
|
|
83
89
|
const reader = BufferReader.asReader(this.buffer.subarray(0, Fr.SIZE_IN_BYTES * numInnerPublicInputs));
|
|
84
|
-
|
|
85
|
-
// concatenate Fr[] with aggregation object
|
|
86
|
-
publicInputs = publicInputs.concat(this.extractAggregationObject());
|
|
90
|
+
const publicInputs = reader.readArray(numInnerPublicInputs, Fr);
|
|
87
91
|
return publicInputs;
|
|
88
92
|
}
|
|
89
93
|
|
|
90
|
-
public extractAggregationObject(): Fr[] {
|
|
91
|
-
if (this.isEmpty()) {
|
|
92
|
-
// return array of 16 0s
|
|
93
|
-
return new Array(16).fill(Fr.zero());
|
|
94
|
-
}
|
|
95
|
-
assert(this.numPublicInputs >= AGGREGATION_OBJECT_LENGTH, 'Proof does not contain an aggregation object');
|
|
96
|
-
const numInnerPublicInputs = this.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
|
|
97
|
-
// The aggregation object is currently stored after the initial inner public inputs.
|
|
98
|
-
const reader = BufferReader.asReader(
|
|
99
|
-
this.buffer.subarray(Fr.SIZE_IN_BYTES * numInnerPublicInputs, Fr.SIZE_IN_BYTES * this.numPublicInputs),
|
|
100
|
-
);
|
|
101
|
-
return reader.readArray(AGGREGATION_OBJECT_LENGTH, Fr);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
94
|
/**
|
|
105
95
|
* Deserialize a Proof instance from a hex string.
|
|
106
96
|
* @param str - A hex string to deserialize from.
|
package/src/tests/factories.ts
CHANGED
|
@@ -55,11 +55,14 @@ import { ContractStorageRead } from '../avm/contract_storage_read.js';
|
|
|
55
55
|
import { ContractStorageUpdateRequest } from '../avm/contract_storage_update_request.js';
|
|
56
56
|
import {
|
|
57
57
|
AvmAccumulatedData,
|
|
58
|
+
AvmAppendLeavesHint,
|
|
58
59
|
AvmBytecodeCommitmentHint,
|
|
59
60
|
AvmCircuitInputs,
|
|
60
61
|
AvmCircuitPublicInputs,
|
|
62
|
+
AvmCommitCheckpointHint,
|
|
61
63
|
AvmContractClassHint,
|
|
62
64
|
AvmContractInstanceHint,
|
|
65
|
+
AvmCreateCheckpointHint,
|
|
63
66
|
AvmEnqueuedCallHint,
|
|
64
67
|
AvmExecutionHints,
|
|
65
68
|
AvmGetLeafPreimageHintNullifierTree,
|
|
@@ -67,6 +70,7 @@ import {
|
|
|
67
70
|
AvmGetLeafValueHint,
|
|
68
71
|
AvmGetPreviousValueIndexHint,
|
|
69
72
|
AvmGetSiblingPathHint,
|
|
73
|
+
AvmRevertCheckpointHint,
|
|
70
74
|
AvmSequentialInsertHintNullifierTree,
|
|
71
75
|
AvmSequentialInsertHintPublicDataTree,
|
|
72
76
|
AvmTxHint,
|
|
@@ -1382,6 +1386,42 @@ export function makeAvmSequentialInsertHintNullifierTree(seed = 0): AvmSequentia
|
|
|
1382
1386
|
);
|
|
1383
1387
|
}
|
|
1384
1388
|
|
|
1389
|
+
export function makeAvmAppendLeavesHint(seed = 0): AvmAppendLeavesHint {
|
|
1390
|
+
return new AvmAppendLeavesHint(
|
|
1391
|
+
makeAppendOnlyTreeSnapshot(seed),
|
|
1392
|
+
makeAppendOnlyTreeSnapshot(seed + 1),
|
|
1393
|
+
// Use NOTE_HASH_TREE or L1_TO_L2_MESSAGE_TREE as mentioned in the comment on AvmAppendLeavesHint
|
|
1394
|
+
seed % 2 === 0 ? MerkleTreeId.NOTE_HASH_TREE : MerkleTreeId.L1_TO_L2_MESSAGE_TREE,
|
|
1395
|
+
makeArray((seed % 5) + 1, i => new Fr(seed + i + 2), 0),
|
|
1396
|
+
);
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
export function makeAvmCheckpointActionCreateCheckpointHint(seed = 0): AvmCreateCheckpointHint {
|
|
1400
|
+
return new AvmCreateCheckpointHint(
|
|
1401
|
+
/*actionCounter=*/ seed,
|
|
1402
|
+
/*oldCheckpointId=*/ seed + 1,
|
|
1403
|
+
/*newCheckpointId=*/ seed + 2,
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
export function makeAvmCheckpointActionCommitCheckpointHint(seed = 0): AvmCommitCheckpointHint {
|
|
1408
|
+
return new AvmCommitCheckpointHint(
|
|
1409
|
+
/*actionCounter=*/ seed,
|
|
1410
|
+
/*oldCheckpointId=*/ seed + 1,
|
|
1411
|
+
/*newCheckpointId=*/ seed + 2,
|
|
1412
|
+
);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
export function makeAvmCheckpointActionRevertCheckpointHint(seed = 0): AvmRevertCheckpointHint {
|
|
1416
|
+
return new AvmRevertCheckpointHint(
|
|
1417
|
+
/*actionCounter=*/ seed,
|
|
1418
|
+
/*oldCheckpointId=*/ seed + 1,
|
|
1419
|
+
/*newCheckpointId=*/ seed + 2,
|
|
1420
|
+
/*beforeState=*/ makeTreeSnapshots(seed + 3),
|
|
1421
|
+
/*afterState=*/ makeTreeSnapshots(seed + 7),
|
|
1422
|
+
);
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1385
1425
|
/**
|
|
1386
1426
|
* Makes arbitrary AvmContractInstanceHint.
|
|
1387
1427
|
* @param seed - The seed to use for generating the state reference.
|
|
@@ -1430,6 +1470,8 @@ export function makeAvmEnqueuedCallHint(seed = 0): AvmEnqueuedCallHint {
|
|
|
1430
1470
|
|
|
1431
1471
|
export function makeAvmTxHint(seed = 0): AvmTxHint {
|
|
1432
1472
|
return new AvmTxHint(
|
|
1473
|
+
`txhash-${seed}`,
|
|
1474
|
+
makeGlobalVariables(seed),
|
|
1433
1475
|
{
|
|
1434
1476
|
noteHashes: makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x1000),
|
|
1435
1477
|
nullifiers: makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x2000),
|
|
@@ -1462,6 +1504,7 @@ export async function makeAvmExecutionHints(
|
|
|
1462
1504
|
contractInstances: makeArray(baseLength + 2, makeAvmContractInstanceHint, seed + 0x4700),
|
|
1463
1505
|
contractClasses: makeArray(baseLength + 5, makeAvmContractClassHint, seed + 0x4900),
|
|
1464
1506
|
bytecodeCommitments: await makeArrayAsync(baseLength + 5, makeAvmBytecodeCommitmentHint, seed + 0x4900),
|
|
1507
|
+
startingTreeRoots: makeTreeSnapshots(seed + 0x4900),
|
|
1465
1508
|
getSiblingPathHints: makeArray(baseLength + 5, makeAvmGetSiblingPathHint, seed + 0x4b00),
|
|
1466
1509
|
getPreviousValueIndexHints: makeArray(baseLength + 5, makeAvmGetPreviousValueIndexHint, seed + 0x4d00),
|
|
1467
1510
|
getLeafPreimageHintPublicDataTree: makeArray(
|
|
@@ -1481,6 +1524,10 @@ export async function makeAvmExecutionHints(
|
|
|
1481
1524
|
makeAvmSequentialInsertHintNullifierTree,
|
|
1482
1525
|
seed + 0x5700,
|
|
1483
1526
|
),
|
|
1527
|
+
appendLeavesHints: makeArray(baseLength + 5, makeAvmAppendLeavesHint, seed + 0x5800),
|
|
1528
|
+
createCheckpointHints: makeArray(baseLength + 5, makeAvmCheckpointActionCreateCheckpointHint, seed + 0x5900),
|
|
1529
|
+
commitCheckpointHints: makeArray(baseLength + 5, makeAvmCheckpointActionCommitCheckpointHint, seed + 0x5b00),
|
|
1530
|
+
revertCheckpointHints: makeArray(baseLength + 5, makeAvmCheckpointActionRevertCheckpointHint, seed + 0x5d00),
|
|
1484
1531
|
...overrides,
|
|
1485
1532
|
};
|
|
1486
1533
|
|
|
@@ -1489,6 +1536,7 @@ export async function makeAvmExecutionHints(
|
|
|
1489
1536
|
fields.contractInstances,
|
|
1490
1537
|
fields.contractClasses,
|
|
1491
1538
|
fields.bytecodeCommitments,
|
|
1539
|
+
fields.startingTreeRoots,
|
|
1492
1540
|
fields.getSiblingPathHints,
|
|
1493
1541
|
fields.getPreviousValueIndexHints,
|
|
1494
1542
|
fields.getLeafPreimageHintPublicDataTree,
|
|
@@ -1496,6 +1544,10 @@ export async function makeAvmExecutionHints(
|
|
|
1496
1544
|
fields.getLeafValueHints,
|
|
1497
1545
|
fields.sequentialInsertHintsPublicDataTree,
|
|
1498
1546
|
fields.sequentialInsertHintsNullifierTree,
|
|
1547
|
+
fields.appendLeavesHints,
|
|
1548
|
+
fields.createCheckpointHints,
|
|
1549
|
+
fields.commitCheckpointHints,
|
|
1550
|
+
fields.revertCheckpointHints,
|
|
1499
1551
|
);
|
|
1500
1552
|
}
|
|
1501
1553
|
|
|
@@ -1509,14 +1561,12 @@ export async function makeAvmCircuitInputs(
|
|
|
1509
1561
|
overrides: Partial<FieldsOf<AvmCircuitInputs>> = {},
|
|
1510
1562
|
): Promise<AvmCircuitInputs> {
|
|
1511
1563
|
const fields = {
|
|
1512
|
-
|
|
1513
|
-
calldata: makeArray((seed % 100) + 10, i => new Fr(i), seed + 0x1000),
|
|
1514
|
-
avmHints: await makeAvmExecutionHints(seed + 0x3000),
|
|
1564
|
+
hints: await makeAvmExecutionHints(seed + 0x3000),
|
|
1515
1565
|
publicInputs: makeAvmCircuitPublicInputs(seed + 0x4000),
|
|
1516
1566
|
...overrides,
|
|
1517
1567
|
};
|
|
1518
1568
|
|
|
1519
|
-
return new AvmCircuitInputs(fields.
|
|
1569
|
+
return new AvmCircuitInputs(fields.hints, fields.publicInputs);
|
|
1520
1570
|
}
|
|
1521
1571
|
|
|
1522
1572
|
/**
|
package/src/tests/mocks.ts
CHANGED
|
@@ -78,6 +78,7 @@ export const mockTx = async (
|
|
|
78
78
|
publicCalldataSize = 2,
|
|
79
79
|
feePayer,
|
|
80
80
|
clientIvcProof = ClientIvcProof.empty(),
|
|
81
|
+
maxPriorityFeesPerGas,
|
|
81
82
|
}: {
|
|
82
83
|
numberOfNonRevertiblePublicCallRequests?: number;
|
|
83
84
|
numberOfRevertiblePublicCallRequests?: number;
|
|
@@ -86,6 +87,7 @@ export const mockTx = async (
|
|
|
86
87
|
publicCalldataSize?: number;
|
|
87
88
|
feePayer?: AztecAddress;
|
|
88
89
|
clientIvcProof?: ClientIvcProof;
|
|
90
|
+
maxPriorityFeesPerGas?: GasFees;
|
|
89
91
|
} = {},
|
|
90
92
|
) => {
|
|
91
93
|
const totalPublicCallRequests =
|
|
@@ -95,7 +97,10 @@ export const mockTx = async (
|
|
|
95
97
|
const isForPublic = totalPublicCallRequests > 0;
|
|
96
98
|
const data = PrivateKernelTailCircuitPublicInputs.empty();
|
|
97
99
|
const firstNullifier = new Nullifier(new Fr(seed + 1), 0, Fr.ZERO);
|
|
98
|
-
data.constants.txContext.gasSettings = GasSettings.default({
|
|
100
|
+
data.constants.txContext.gasSettings = GasSettings.default({
|
|
101
|
+
maxFeesPerGas: new GasFees(10, 10),
|
|
102
|
+
maxPriorityFeesPerGas,
|
|
103
|
+
});
|
|
99
104
|
data.feePayer = feePayer ?? (await AztecAddress.random());
|
|
100
105
|
|
|
101
106
|
const publicFunctionCalldata: HashedValues[] = [];
|
package/src/tx/index.ts
CHANGED
|
@@ -24,6 +24,8 @@ export * from './public_simulation_output.js';
|
|
|
24
24
|
export * from './tx_execution_request.js';
|
|
25
25
|
export * from './validator/tx_validator.js';
|
|
26
26
|
export * from './validator/empty_validator.js';
|
|
27
|
+
export * from './validator/error_texts.js';
|
|
27
28
|
export * from './capsule.js';
|
|
28
29
|
export * from './global_variable_builder.js';
|
|
29
30
|
export * from './hashed_values.js';
|
|
31
|
+
export * from './indexed_tx_effect.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { schemas } from '@aztec/foundation/schemas';
|
|
2
|
+
|
|
3
|
+
import { type InBlock, inBlockSchemaFor, randomInBlock } from '../block/in_block.js';
|
|
4
|
+
import { TxEffect } from './tx_effect.js';
|
|
5
|
+
|
|
6
|
+
export type IndexedTxEffect = InBlock<TxEffect> & { txIndexInBlock: number };
|
|
7
|
+
|
|
8
|
+
export function indexedTxSchema() {
|
|
9
|
+
return inBlockSchemaFor(TxEffect.schema).extend({ txIndexInBlock: schemas.Integer });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export async function randomIndexedTxEffect(): Promise<IndexedTxEffect> {
|
|
13
|
+
return {
|
|
14
|
+
...randomInBlock(await TxEffect.random()),
|
|
15
|
+
txIndexInBlock: Math.floor(Math.random() * 1000),
|
|
16
|
+
};
|
|
17
|
+
}
|
package/src/tx/tx_hash.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Gas and fees
|
|
2
|
+
export const TX_ERROR_INSUFFICIENT_FEE_PER_GAS = 'Insufficient fee per gas';
|
|
3
|
+
export const TX_ERROR_INSUFFICIENT_FEE_PAYER_BALANCE = 'Insufficient fee payer balance';
|
|
4
|
+
export const TX_ERROR_INSUFFICIENT_GAS_LIMIT = 'Gas limit is below the minimum fixed cost';
|
|
5
|
+
|
|
6
|
+
// Phases
|
|
7
|
+
export const TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED = 'Setup function not on allow list';
|
|
8
|
+
|
|
9
|
+
// Nullifiers
|
|
10
|
+
export const TX_ERROR_DUPLICATE_NULLIFIER_IN_TX = 'Duplicate nullifier in tx';
|
|
11
|
+
export const TX_ERROR_EXISTING_NULLIFIER = 'Existing nullifier';
|
|
12
|
+
|
|
13
|
+
// Metadata
|
|
14
|
+
export const TX_ERROR_INVALID_BLOCK_NUMBER = 'Invalid block number';
|
|
15
|
+
export const TX_ERROR_INCORRECT_CHAIN_ID = 'Incorrect chain id';
|
|
16
|
+
export const TX_ERROR_INCORRECT_ROLLUP_VERSION = 'Incorrect rollup version';
|
|
17
|
+
|
|
18
|
+
// Proof
|
|
19
|
+
export const TX_ERROR_INVALID_PROOF = 'Invalid proof';
|
|
20
|
+
|
|
21
|
+
//Data
|
|
22
|
+
export const TX_ERROR_INCORRECT_CALLDATA = 'Incorrect calldata for public call';
|
|
23
|
+
export const TX_ERROR_CALLDATA_COUNT_MISMATCH = 'Wrong number of calldata for public calls';
|
|
24
|
+
export const TX_ERROR_CALLDATA_COUNT_TOO_LARGE = 'Total calldata too large for enqueued public calls';
|
|
25
|
+
export const TX_ERROR_CONTRACT_CLASS_LOG_COUNT = 'Mismatched number of contract class logs';
|
|
26
|
+
export const TX_ERROR_CONTRACT_CLASS_LOG_LENGTH = 'Mismatched contract class logs length';
|
|
27
|
+
export const TX_ERROR_CONTRACT_CLASS_LOGS = 'Mismatched contract class logs';
|
|
28
|
+
export const TX_ERROR_CONTRACT_CLASS_LOG_SORTING = 'Incorrectly sorted contract class logs';
|
|
29
|
+
|
|
30
|
+
// Block header
|
|
31
|
+
export const TX_ERROR_BLOCK_HEADER = 'Block header not found';
|
|
32
|
+
|
|
33
|
+
// General
|
|
34
|
+
export const TX_ERROR_DURING_VALIDATION = 'Unexpected error during validation';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/block/l2_block_downloader/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { L2Block } from '../l2_block.js';
|
|
2
|
-
import type { L2BlockSource } from '../l2_block_source.js';
|
|
3
|
-
/**
|
|
4
|
-
* Downloads L2 blocks from a L2BlockSource.
|
|
5
|
-
* The blocks are stored in a queue and can be retrieved using the getBlocks method.
|
|
6
|
-
* The queue size is limited by the maxQueueSize parameter.
|
|
7
|
-
* The downloader will pause when the queue is full or when the L2BlockSource is out of blocks.
|
|
8
|
-
*/
|
|
9
|
-
export declare class L2BlockDownloader {
|
|
10
|
-
private l2BlockSource;
|
|
11
|
-
private runningPromise?;
|
|
12
|
-
private running;
|
|
13
|
-
private from;
|
|
14
|
-
private interruptibleSleep;
|
|
15
|
-
private readonly semaphore;
|
|
16
|
-
private readonly jobQueue;
|
|
17
|
-
private readonly blockQueue;
|
|
18
|
-
private readonly proven;
|
|
19
|
-
private readonly pollIntervalMS;
|
|
20
|
-
constructor(l2BlockSource: L2BlockSource, opts: {
|
|
21
|
-
maxQueueSize: number;
|
|
22
|
-
proven?: boolean;
|
|
23
|
-
pollIntervalMS?: number;
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* Starts the downloader.
|
|
27
|
-
* @param from - The block number to start downloading from. Defaults to INITIAL_L2_BLOCK_NUM.
|
|
28
|
-
*/
|
|
29
|
-
start(from?: number): void;
|
|
30
|
-
/**
|
|
31
|
-
* Repeatedly queries the block source and adds the received blocks to the block queue.
|
|
32
|
-
* Stops when no further blocks are received.
|
|
33
|
-
* @param targetBlockNumber - Optional block number to stop at.
|
|
34
|
-
* @param proven - Optional override of the default "proven" setting.
|
|
35
|
-
* @returns The total number of blocks added to the block queue.
|
|
36
|
-
*/
|
|
37
|
-
private collectBlocks;
|
|
38
|
-
/**
|
|
39
|
-
* Stops the downloader.
|
|
40
|
-
*/
|
|
41
|
-
stop(): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Gets the next batch of blocks from the queue.
|
|
44
|
-
* @param timeout - optional timeout value to prevent permanent blocking
|
|
45
|
-
* @returns The next batch of blocks from the queue.
|
|
46
|
-
*/
|
|
47
|
-
getBlocks(timeout?: number): Promise<L2Block[]>;
|
|
48
|
-
/**
|
|
49
|
-
* Forces an immediate request for blocks.
|
|
50
|
-
* Repeatedly queries the block source and adds the received blocks to the block queue.
|
|
51
|
-
* Stops when no further blocks are received.
|
|
52
|
-
* @param targetBlockNumber - Optional block number to stop at.
|
|
53
|
-
* @param proven - Optional override of the default "proven" setting.
|
|
54
|
-
* @returns A promise that fulfills once the poll is complete
|
|
55
|
-
*/
|
|
56
|
-
pollImmediate(targetBlockNumber?: number, onlyProven?: boolean): Promise<number>;
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=l2_block_downloader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"l2_block_downloader.d.ts","sourceRoot":"","sources":["../../../src/block/l2_block_downloader/l2_block_downloader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAI3D;;;;;GAKG;AACH,qBAAa,iBAAiB;IAY1B,OAAO,CAAC,aAAa;IAXvB,OAAO,CAAC,cAAc,CAAC,CAAgB;IACvC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,kBAAkB,CAA4B;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoC;IAC/D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;gBAG9B,aAAa,EAAE,aAAa,EACpC,IAAI,EAAE;QACJ,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;IAOH;;;OAGG;IACI,KAAK,CAAC,IAAI,SAAuB;IAuBxC;;;;;;OAMG;YACW,aAAa;IAiC3B;;OAEG;IACU,IAAI;IAQjB;;;;OAIG;IACU,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAc5D;;;;;;;OAOG;IACI,aAAa,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;CAGxF"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { FifoMemoryQueue, Semaphore, SerialQueue } from '@aztec/foundation/queue';
|
|
4
|
-
import { InterruptibleSleep } from '@aztec/foundation/sleep';
|
|
5
|
-
const log = createLogger('types:l2_block_downloader');
|
|
6
|
-
/**
|
|
7
|
-
* Downloads L2 blocks from a L2BlockSource.
|
|
8
|
-
* The blocks are stored in a queue and can be retrieved using the getBlocks method.
|
|
9
|
-
* The queue size is limited by the maxQueueSize parameter.
|
|
10
|
-
* The downloader will pause when the queue is full or when the L2BlockSource is out of blocks.
|
|
11
|
-
*/ export class L2BlockDownloader {
|
|
12
|
-
l2BlockSource;
|
|
13
|
-
runningPromise;
|
|
14
|
-
running;
|
|
15
|
-
from;
|
|
16
|
-
interruptibleSleep;
|
|
17
|
-
semaphore;
|
|
18
|
-
jobQueue;
|
|
19
|
-
blockQueue;
|
|
20
|
-
proven;
|
|
21
|
-
pollIntervalMS;
|
|
22
|
-
constructor(l2BlockSource, opts){
|
|
23
|
-
this.l2BlockSource = l2BlockSource;
|
|
24
|
-
this.running = false;
|
|
25
|
-
this.from = 0;
|
|
26
|
-
this.interruptibleSleep = new InterruptibleSleep();
|
|
27
|
-
this.jobQueue = new SerialQueue();
|
|
28
|
-
this.blockQueue = new FifoMemoryQueue();
|
|
29
|
-
this.pollIntervalMS = opts.pollIntervalMS ?? 1000;
|
|
30
|
-
this.proven = opts.proven ?? false;
|
|
31
|
-
this.semaphore = new Semaphore(opts.maxQueueSize);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Starts the downloader.
|
|
35
|
-
* @param from - The block number to start downloading from. Defaults to INITIAL_L2_BLOCK_NUM.
|
|
36
|
-
*/ start(from = INITIAL_L2_BLOCK_NUM) {
|
|
37
|
-
if (this.running) {
|
|
38
|
-
this.interruptibleSleep.interrupt();
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
this.from = from;
|
|
42
|
-
this.running = true;
|
|
43
|
-
const fn = async ()=>{
|
|
44
|
-
while(this.running){
|
|
45
|
-
try {
|
|
46
|
-
await this.jobQueue.put(()=>this.collectBlocks());
|
|
47
|
-
await this.interruptibleSleep.sleep(this.pollIntervalMS);
|
|
48
|
-
} catch (err) {
|
|
49
|
-
log.error(`Error downloading L2 block`, err);
|
|
50
|
-
await this.interruptibleSleep.sleep(this.pollIntervalMS);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
this.jobQueue.start();
|
|
55
|
-
this.runningPromise = fn();
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Repeatedly queries the block source and adds the received blocks to the block queue.
|
|
59
|
-
* Stops when no further blocks are received.
|
|
60
|
-
* @param targetBlockNumber - Optional block number to stop at.
|
|
61
|
-
* @param proven - Optional override of the default "proven" setting.
|
|
62
|
-
* @returns The total number of blocks added to the block queue.
|
|
63
|
-
*/ async collectBlocks(targetBlockNumber, onlyProven) {
|
|
64
|
-
let totalBlocks = 0;
|
|
65
|
-
while(true){
|
|
66
|
-
// If we have a target and have reached it, return
|
|
67
|
-
if (targetBlockNumber !== undefined && this.from > targetBlockNumber) {
|
|
68
|
-
log.verbose(`Reached target block number ${targetBlockNumber}`);
|
|
69
|
-
return totalBlocks;
|
|
70
|
-
}
|
|
71
|
-
// If we have a target, then request at most the number of blocks to get to it
|
|
72
|
-
const limit = targetBlockNumber !== undefined ? Math.min(targetBlockNumber - this.from + 1, 10) : 10;
|
|
73
|
-
const proven = onlyProven === undefined ? this.proven : onlyProven;
|
|
74
|
-
// Hit the archiver for blocks
|
|
75
|
-
const blocks = await this.l2BlockSource.getBlocks(this.from, limit, proven);
|
|
76
|
-
// If there are no more blocks, return
|
|
77
|
-
if (!blocks.length) {
|
|
78
|
-
return totalBlocks;
|
|
79
|
-
}
|
|
80
|
-
log.verbose(`Received ${blocks.length} blocks from archiver after querying from ${this.from} limit ${limit} (proven ${proven})`);
|
|
81
|
-
// Push new blocks into the queue and loop
|
|
82
|
-
await this.semaphore.acquire();
|
|
83
|
-
this.blockQueue.put(blocks);
|
|
84
|
-
this.from += blocks.length;
|
|
85
|
-
totalBlocks += blocks.length;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Stops the downloader.
|
|
90
|
-
*/ async stop() {
|
|
91
|
-
this.running = false;
|
|
92
|
-
this.interruptibleSleep.interrupt();
|
|
93
|
-
await this.jobQueue.cancel();
|
|
94
|
-
this.blockQueue.cancel();
|
|
95
|
-
await this.runningPromise;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Gets the next batch of blocks from the queue.
|
|
99
|
-
* @param timeout - optional timeout value to prevent permanent blocking
|
|
100
|
-
* @returns The next batch of blocks from the queue.
|
|
101
|
-
*/ async getBlocks(timeout) {
|
|
102
|
-
try {
|
|
103
|
-
const blocks = await this.blockQueue.get(timeout);
|
|
104
|
-
if (!blocks) {
|
|
105
|
-
return [];
|
|
106
|
-
}
|
|
107
|
-
this.semaphore.release();
|
|
108
|
-
return blocks;
|
|
109
|
-
} catch (err) {
|
|
110
|
-
// nothing to do
|
|
111
|
-
return [];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Forces an immediate request for blocks.
|
|
116
|
-
* Repeatedly queries the block source and adds the received blocks to the block queue.
|
|
117
|
-
* Stops when no further blocks are received.
|
|
118
|
-
* @param targetBlockNumber - Optional block number to stop at.
|
|
119
|
-
* @param proven - Optional override of the default "proven" setting.
|
|
120
|
-
* @returns A promise that fulfills once the poll is complete
|
|
121
|
-
*/ pollImmediate(targetBlockNumber, onlyProven) {
|
|
122
|
-
return this.jobQueue.put(()=>this.collectBlocks(targetBlockNumber, onlyProven));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"l2_block_stream.d.ts","sourceRoot":"","sources":["../../../src/block/l2_block_downloader/l2_block_stream.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,uHAAuH;AACvH,qBAAa,aAAa;IAMtB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,IAAI;IATd,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;gBAGjB,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,oBAAoB,GAAG,gBAAgB,GAAG,WAAW,CAAC,EACzF,SAAS,EAAE,8BAA8B,EACzC,OAAO,EAAE,yBAAyB,EACzB,GAAG,yCAAqC,EACjD,IAAI,GAAE;QACZ,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;KACnB;IAKD,KAAK;IAKC,IAAI;IAIV,SAAS;IAIH,IAAI;cAMD,IAAI;IA+EpB;;;;OAIG;YACW,qBAAqB;IAenC,OAAO,CAAC,sBAAsB;YAOhB,SAAS;CASxB;AAsBD,8FAA8F;AAC9F,MAAM,WAAW,8BAA8B;IAC7C,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC5D,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED,gDAAgD;AAChD,MAAM,WAAW,yBAAyB;IACxC,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClE;AAED,MAAM,MAAM,kBAAkB,GAC1B,uCAAuC,CAAC;IACtC,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,GACD,kEAAkE,CAAC;IACjE,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,SAAS,CAAC;CAClB,GACD,gCAAgC,CAAC;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,SAAS,CAAC;CAClB,GACD,gEAAgE,CAAC;IAC/D,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC"}
|