@aztec/stdlib 0.79.0 → 0.81.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/abi/abi.d.ts +7 -5
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +8 -3
- package/dest/abi/contract_artifact.d.ts +16 -1
- package/dest/abi/contract_artifact.d.ts.map +1 -1
- package/dest/abi/contract_artifact.js +72 -11
- package/dest/avm/avm.d.ts +173 -405
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +34 -27
- package/dest/avm/avm_proving_request.d.ts +84 -186
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/avm/public_data_write.d.ts +1 -0
- package/dest/avm/public_data_write.d.ts.map +1 -1
- package/dest/avm/public_data_write.js +3 -0
- package/dest/block/body.d.ts +1 -0
- package/dest/block/body.d.ts.map +1 -1
- package/dest/block/body.js +3 -0
- package/dest/block/index.d.ts +1 -0
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +1 -0
- package/dest/block/l2_block.d.ts +2 -1
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +3 -0
- package/dest/block/l2_block_downloader/l2_block_stream.d.ts +3 -3
- package/dest/block/l2_block_downloader/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_downloader/l2_block_stream.js +2 -2
- package/dest/block/l2_block_source.d.ts +3 -0
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/published_l2_block.d.ts +89 -0
- package/dest/block/published_l2_block.d.ts.map +1 -0
- package/dest/block/published_l2_block.js +32 -0
- package/dest/contract/contract_class.d.ts.map +1 -1
- package/dest/contract/contract_class.js +2 -0
- package/dest/contract/contract_instance.d.ts +2 -2
- package/dest/contract/contract_instance.d.ts.map +1 -1
- package/dest/contract/contract_instance.js +3 -2
- package/dest/contract/interfaces/contract_data_source.d.ts +3 -9
- package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
- package/dest/database-version/version_manager.js +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +4 -3
- package/dest/interfaces/aztec-node.d.ts +1 -1
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +2 -0
- package/dest/interfaces/proving-job.d.ts +106 -208
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/logs/contract_class_log.d.ts +1 -0
- package/dest/logs/contract_class_log.d.ts.map +1 -1
- package/dest/logs/contract_class_log.js +3 -0
- package/dest/logs/l1_payload/index.d.ts +1 -1
- package/dest/logs/l1_payload/index.d.ts.map +1 -1
- package/dest/logs/l1_payload/index.js +1 -1
- package/dest/logs/private_log.d.ts +2 -1
- package/dest/logs/private_log.d.ts.map +1 -1
- package/dest/logs/private_log.js +14 -3
- package/dest/logs/public_log.d.ts.map +1 -1
- package/dest/logs/public_log.js +4 -1
- package/dest/logs/tx_scoped_l2_log.d.ts +16 -28
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +28 -19
- package/dest/note/extended_note.d.ts +10 -21
- package/dest/note/extended_note.d.ts.map +1 -1
- package/dest/note/extended_note.js +19 -28
- package/dest/note/notes_filter.d.ts +2 -2
- package/dest/note/notes_filter.d.ts.map +1 -1
- package/dest/note/notes_filter.js +1 -1
- package/dest/p2p/consensus_payload.d.ts +3 -1
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +3 -0
- package/dest/proofs/proof.d.ts +0 -1
- package/dest/proofs/proof.d.ts.map +1 -1
- package/dest/proofs/proof.js +2 -7
- package/dest/rollup/block_root_rollup.d.ts +1 -1
- package/dest/tests/factories.d.ts +3 -2
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +14 -8
- package/dest/tests/mocks.d.ts +2 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +5 -5
- package/dest/trees/nullifier_membership_witness.d.ts +7 -7
- package/dest/trees/public_data_witness.d.ts +7 -7
- package/dest/tx/capsule.d.ts +2 -0
- package/dest/tx/capsule.d.ts.map +1 -1
- package/dest/tx/capsule.js +2 -0
- package/dest/tx/tx_effect.d.ts +1 -0
- package/dest/tx/tx_effect.d.ts.map +1 -1
- package/dest/tx/tx_effect.js +4 -1
- package/package.json +6 -6
- package/src/abi/abi.ts +16 -9
- package/src/abi/contract_artifact.ts +87 -10
- package/src/avm/avm.ts +42 -39
- package/src/avm/public_data_write.ts +4 -0
- package/src/block/body.ts +6 -0
- package/src/block/index.ts +1 -0
- package/src/block/l2_block.ts +4 -0
- package/src/block/l2_block_downloader/l2_block_stream.ts +5 -5
- package/src/block/l2_block_source.ts +4 -0
- package/src/block/published_l2_block.ts +45 -0
- package/src/contract/contract_class.ts +2 -0
- package/src/contract/contract_instance.ts +13 -5
- package/src/contract/interfaces/contract_data_source.ts +3 -10
- package/src/database-version/version_manager.ts +1 -1
- package/src/interfaces/archiver.ts +9 -6
- package/src/interfaces/aztec-node.ts +4 -1
- package/src/logs/contract_class_log.ts +8 -0
- package/src/logs/l1_payload/index.ts +1 -1
- package/src/logs/private_log.ts +13 -3
- package/src/logs/public_log.ts +11 -1
- package/src/logs/tx_scoped_l2_log.ts +28 -25
- package/src/note/extended_note.ts +17 -36
- package/src/note/notes_filter.ts +3 -3
- package/src/p2p/consensus_payload.ts +9 -0
- package/src/proofs/proof.ts +2 -8
- package/src/tests/factories.ts +15 -14
- package/src/tests/mocks.ts +5 -9
- package/src/tx/capsule.ts +2 -0
- package/src/tx/tx_effect.ts +23 -1
- package/dest/logs/l1_payload/l1_note_payload.d.ts +0 -82
- package/dest/logs/l1_payload/l1_note_payload.d.ts.map +0 -1
- package/dest/logs/l1_payload/l1_note_payload.js +0 -129
- package/src/logs/l1_payload/l1_note_payload.ts +0 -182
|
@@ -28,6 +28,14 @@ export class ContractClassLog {
|
|
|
28
28
|
return [this.contractAddress.toField(), ...this.fields];
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
equals(other: ContractClassLog) {
|
|
32
|
+
return (
|
|
33
|
+
this.contractAddress.equals(other.contractAddress) &&
|
|
34
|
+
this.fields.length === other.fields.length &&
|
|
35
|
+
this.fields.every((f, i) => f.equals(other.fields[i]))
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
static fromFields(fields: Fr[] | FieldReader) {
|
|
32
40
|
const reader = FieldReader.asReader(fields);
|
|
33
41
|
// Below line gives error 'Type instantiation is excessively deep and possibly infinite. ts(2589)'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './encrypted_log_payload.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './shared_secret_derivation.js';
|
package/src/logs/private_log.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
|
|
1
|
+
import { PRIVATE_LOG_SIZE_IN_FIELDS, PUBLIC_LOG_DATA_SIZE_IN_FIELDS } from '@aztec/constants';
|
|
2
2
|
import { makeTuple } from '@aztec/foundation/array';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { schemas } from '@aztec/foundation/schemas';
|
|
@@ -38,8 +38,8 @@ export class PrivateLog {
|
|
|
38
38
|
return new PrivateLog(reader.readArray(PRIVATE_LOG_SIZE_IN_FIELDS, Fr));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
static random() {
|
|
42
|
-
return
|
|
41
|
+
static random(tag = Fr.random()) {
|
|
42
|
+
return PrivateLog.fromFields([tag, ...Array.from({ length: PRIVATE_LOG_SIZE_IN_FIELDS - 1 }, () => Fr.random())]);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
getEmittedLength() {
|
|
@@ -54,6 +54,12 @@ export class PrivateLog {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
static get schema() {
|
|
57
|
+
if (PUBLIC_LOG_DATA_SIZE_IN_FIELDS + 1 == PRIVATE_LOG_SIZE_IN_FIELDS) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
'Constants got updated and schema for PublicLog matches that of PrivateLog. This needs to be updated now as Zod is no longer able to differentiate the 2 in TxScopedL2Log.',
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
57
63
|
return z
|
|
58
64
|
.object({
|
|
59
65
|
fields: z.array(schemas.Fr),
|
|
@@ -61,6 +67,10 @@ export class PrivateLog {
|
|
|
61
67
|
.transform(({ fields }) => PrivateLog.fromFields(fields));
|
|
62
68
|
}
|
|
63
69
|
|
|
70
|
+
equals(other: PrivateLog) {
|
|
71
|
+
return this.fields.every((field, i) => field.equals(other.fields[i]));
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
[inspect.custom](): string {
|
|
65
75
|
return `PrivateLog {
|
|
66
76
|
fields: [${this.fields.map(x => inspect(x)).join(', ')}],
|
package/src/logs/public_log.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
PRIVATE_LOG_SIZE_IN_FIELDS,
|
|
3
|
+
PUBLIC_LOG_DATA_SIZE_IN_FIELDS,
|
|
4
|
+
PUBLIC_LOG_SIZE_IN_FIELDS,
|
|
5
|
+
} from '@aztec/constants';
|
|
2
6
|
import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
|
|
3
7
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
8
|
import { type ZodFor, schemas } from '@aztec/foundation/schemas';
|
|
@@ -78,6 +82,12 @@ export class PublicLog {
|
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
static get schema(): ZodFor<PublicLog> {
|
|
85
|
+
if (PUBLIC_LOG_DATA_SIZE_IN_FIELDS + 1 == PRIVATE_LOG_SIZE_IN_FIELDS) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
'Constants got updated and schema for PrivateLog matches that of PublicLog. This needs to be updated now as Zod is no longer able to differentiate the 2 in TxScopedL2Log.',
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
81
91
|
return z
|
|
82
92
|
.object({
|
|
83
93
|
contractAddress: AztecAddress.schema,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
1
|
import { BufferReader, boolToBuffer, numToUInt32BE } from '@aztec/foundation/serialize';
|
|
3
2
|
|
|
4
3
|
import { z } from 'zod';
|
|
5
4
|
|
|
6
|
-
import { schemas } from '../schemas/schemas.js';
|
|
7
5
|
import { TxHash } from '../tx/tx_hash.js';
|
|
6
|
+
import { PrivateLog } from './private_log.js';
|
|
7
|
+
import { PublicLog } from './public_log.js';
|
|
8
8
|
|
|
9
9
|
export class TxScopedL2Log {
|
|
10
10
|
constructor(
|
|
@@ -22,53 +22,55 @@ export class TxScopedL2Log {
|
|
|
22
22
|
*/
|
|
23
23
|
public blockNumber: number,
|
|
24
24
|
/*
|
|
25
|
-
*
|
|
25
|
+
* The log data as either a PrivateLog or PublicLog
|
|
26
26
|
*/
|
|
27
|
-
public
|
|
28
|
-
/*
|
|
29
|
-
* The log data
|
|
30
|
-
*/
|
|
31
|
-
public logData: Buffer,
|
|
27
|
+
public log: PrivateLog | PublicLog,
|
|
32
28
|
) {}
|
|
33
29
|
|
|
30
|
+
get isFromPublic() {
|
|
31
|
+
return this.log instanceof PublicLog;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
34
|
static get schema() {
|
|
35
35
|
return z
|
|
36
36
|
.object({
|
|
37
37
|
txHash: TxHash.schema,
|
|
38
38
|
dataStartIndexForTx: z.number(),
|
|
39
39
|
blockNumber: z.number(),
|
|
40
|
-
|
|
41
|
-
logData: schemas.Buffer,
|
|
40
|
+
log: z.union([PrivateLog.schema, PublicLog.schema]),
|
|
42
41
|
})
|
|
43
42
|
.transform(
|
|
44
|
-
({ txHash, dataStartIndexForTx, blockNumber,
|
|
45
|
-
new TxScopedL2Log(txHash, dataStartIndexForTx, blockNumber,
|
|
43
|
+
({ txHash, dataStartIndexForTx, blockNumber, log }) =>
|
|
44
|
+
new TxScopedL2Log(txHash, dataStartIndexForTx, blockNumber, log),
|
|
46
45
|
);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
toBuffer() {
|
|
49
|
+
const isFromPublic = this.log instanceof PublicLog;
|
|
50
50
|
return Buffer.concat([
|
|
51
51
|
this.txHash.toBuffer(),
|
|
52
52
|
numToUInt32BE(this.dataStartIndexForTx),
|
|
53
53
|
numToUInt32BE(this.blockNumber),
|
|
54
|
-
boolToBuffer(
|
|
55
|
-
this.
|
|
54
|
+
boolToBuffer(isFromPublic),
|
|
55
|
+
this.log.toBuffer(),
|
|
56
56
|
]);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
static fromBuffer(buffer: Buffer) {
|
|
60
60
|
const reader = BufferReader.asReader(buffer);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
);
|
|
61
|
+
const txHash = reader.readObject(TxHash);
|
|
62
|
+
const dataStartIndexForTx = reader.readNumber();
|
|
63
|
+
const blockNumber = reader.readNumber();
|
|
64
|
+
const isFromPublic = reader.readBoolean();
|
|
65
|
+
const log = isFromPublic ? PublicLog.fromBuffer(reader) : PrivateLog.fromBuffer(reader);
|
|
66
|
+
|
|
67
|
+
return new TxScopedL2Log(txHash, dataStartIndexForTx, blockNumber, log);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
static random() {
|
|
71
|
-
|
|
70
|
+
static async random() {
|
|
71
|
+
const isFromPublic = Math.random() < 0.5;
|
|
72
|
+
const log = isFromPublic ? await PublicLog.random() : PrivateLog.random();
|
|
73
|
+
return new TxScopedL2Log(TxHash.random(), 1, 1, log);
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
equals(other: TxScopedL2Log) {
|
|
@@ -76,8 +78,9 @@ export class TxScopedL2Log {
|
|
|
76
78
|
this.txHash.equals(other.txHash) &&
|
|
77
79
|
this.dataStartIndexForTx === other.dataStartIndexForTx &&
|
|
78
80
|
this.blockNumber === other.blockNumber &&
|
|
79
|
-
this.
|
|
80
|
-
|
|
81
|
+
((this.log instanceof PublicLog && other.log instanceof PublicLog) ||
|
|
82
|
+
(this.log instanceof PrivateLog && other.log instanceof PrivateLog)) &&
|
|
83
|
+
this.log.equals(other.log as any)
|
|
81
84
|
);
|
|
82
85
|
}
|
|
83
86
|
}
|
|
@@ -4,7 +4,6 @@ import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
|
4
4
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
7
|
-
import { NoteSelector } from '../abi/note_selector.js';
|
|
8
7
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
9
8
|
import { type ZodFor, schemas } from '../schemas/index.js';
|
|
10
9
|
import { TxHash } from '../tx/tx_hash.js';
|
|
@@ -17,54 +16,43 @@ export class ExtendedNote {
|
|
|
17
16
|
constructor(
|
|
18
17
|
/** The note as emitted from the Noir contract. */
|
|
19
18
|
public note: Note,
|
|
20
|
-
/** The
|
|
21
|
-
public
|
|
19
|
+
/** The address whose public key was used to encrypt the note. */
|
|
20
|
+
public recipient: AztecAddress,
|
|
22
21
|
/** The contract address this note is created in. */
|
|
23
22
|
public contractAddress: AztecAddress,
|
|
24
23
|
/** The specific storage location of the note on the contract. */
|
|
25
24
|
public storageSlot: Fr,
|
|
26
|
-
/** The type identifier of the note on the contract. */
|
|
27
|
-
public noteTypeId: NoteSelector,
|
|
28
25
|
/** The hash of the tx the note was created in. */
|
|
29
26
|
public txHash: TxHash,
|
|
30
27
|
) {}
|
|
31
28
|
|
|
32
29
|
toBuffer(): Buffer {
|
|
33
|
-
return serializeToBuffer([
|
|
34
|
-
this.note,
|
|
35
|
-
this.owner,
|
|
36
|
-
this.contractAddress,
|
|
37
|
-
this.storageSlot,
|
|
38
|
-
this.noteTypeId,
|
|
39
|
-
this.txHash,
|
|
40
|
-
]);
|
|
30
|
+
return serializeToBuffer([this.note, this.recipient, this.contractAddress, this.storageSlot, this.txHash]);
|
|
41
31
|
}
|
|
42
32
|
|
|
43
33
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
44
34
|
const reader = BufferReader.asReader(buffer);
|
|
45
35
|
|
|
46
36
|
const note = reader.readObject(Note);
|
|
47
|
-
const
|
|
37
|
+
const recipient = reader.readObject(AztecAddress);
|
|
48
38
|
const contractAddress = reader.readObject(AztecAddress);
|
|
49
39
|
const storageSlot = reader.readObject(Fr);
|
|
50
|
-
const noteTypeId = reader.readObject(NoteSelector);
|
|
51
40
|
const txHash = reader.readObject(TxHash);
|
|
52
41
|
|
|
53
|
-
return new this(note,
|
|
42
|
+
return new this(note, recipient, contractAddress, storageSlot, txHash);
|
|
54
43
|
}
|
|
55
44
|
|
|
56
45
|
static get schema(): ZodFor<ExtendedNote> {
|
|
57
46
|
return z
|
|
58
47
|
.object({
|
|
59
48
|
note: Note.schema,
|
|
60
|
-
|
|
49
|
+
recipient: schemas.AztecAddress,
|
|
61
50
|
contractAddress: schemas.AztecAddress,
|
|
62
51
|
storageSlot: schemas.Fr,
|
|
63
|
-
noteTypeId: schemas.NoteSelector,
|
|
64
52
|
txHash: TxHash.schema,
|
|
65
53
|
})
|
|
66
|
-
.transform(({ note,
|
|
67
|
-
return new ExtendedNote(note,
|
|
54
|
+
.transform(({ note, recipient, contractAddress, storageSlot, txHash }) => {
|
|
55
|
+
return new ExtendedNote(note, recipient, contractAddress, storageSlot, txHash);
|
|
68
56
|
});
|
|
69
57
|
}
|
|
70
58
|
|
|
@@ -82,7 +70,6 @@ export class ExtendedNote {
|
|
|
82
70
|
await AztecAddress.random(),
|
|
83
71
|
await AztecAddress.random(),
|
|
84
72
|
Fr.random(),
|
|
85
|
-
NoteSelector.random(),
|
|
86
73
|
TxHash.random(),
|
|
87
74
|
);
|
|
88
75
|
}
|
|
@@ -92,45 +79,41 @@ export class UniqueNote extends ExtendedNote {
|
|
|
92
79
|
constructor(
|
|
93
80
|
/** The note as emitted from the Noir contract. */
|
|
94
81
|
note: Note,
|
|
95
|
-
/** The
|
|
96
|
-
|
|
82
|
+
/** The recipient whose public key was used to encrypt the note. */
|
|
83
|
+
recipient: AztecAddress,
|
|
97
84
|
/** The contract address this note is created in. */
|
|
98
85
|
contractAddress: AztecAddress,
|
|
99
86
|
/** The specific storage location of the note on the contract. */
|
|
100
87
|
storageSlot: Fr,
|
|
101
|
-
/** The type identifier of the note on the contract. */
|
|
102
|
-
noteTypeId: NoteSelector,
|
|
103
88
|
/** The hash of the tx the note was created in. */
|
|
104
89
|
txHash: TxHash,
|
|
105
90
|
/** The nonce of the note. */
|
|
106
91
|
public nonce: Fr,
|
|
107
92
|
) {
|
|
108
|
-
super(note,
|
|
93
|
+
super(note, recipient, contractAddress, storageSlot, txHash);
|
|
109
94
|
}
|
|
110
95
|
|
|
111
96
|
static override get schema() {
|
|
112
97
|
return z
|
|
113
98
|
.object({
|
|
114
99
|
note: Note.schema,
|
|
115
|
-
|
|
100
|
+
recipient: schemas.AztecAddress,
|
|
116
101
|
contractAddress: schemas.AztecAddress,
|
|
117
102
|
storageSlot: schemas.Fr,
|
|
118
|
-
noteTypeId: schemas.NoteSelector,
|
|
119
103
|
txHash: TxHash.schema,
|
|
120
104
|
nonce: schemas.Fr,
|
|
121
105
|
})
|
|
122
|
-
.transform(({ note,
|
|
123
|
-
return new UniqueNote(note,
|
|
106
|
+
.transform(({ note, recipient, contractAddress, storageSlot, txHash, nonce }) => {
|
|
107
|
+
return new UniqueNote(note, recipient, contractAddress, storageSlot, txHash, nonce);
|
|
124
108
|
});
|
|
125
109
|
}
|
|
126
110
|
|
|
127
111
|
override toBuffer(): Buffer {
|
|
128
112
|
return serializeToBuffer([
|
|
129
113
|
this.note,
|
|
130
|
-
this.
|
|
114
|
+
this.recipient,
|
|
131
115
|
this.contractAddress,
|
|
132
116
|
this.storageSlot,
|
|
133
|
-
this.noteTypeId,
|
|
134
117
|
this.txHash,
|
|
135
118
|
this.nonce,
|
|
136
119
|
]);
|
|
@@ -142,7 +125,6 @@ export class UniqueNote extends ExtendedNote {
|
|
|
142
125
|
await AztecAddress.random(),
|
|
143
126
|
await AztecAddress.random(),
|
|
144
127
|
Fr.random(),
|
|
145
|
-
NoteSelector.random(),
|
|
146
128
|
TxHash.random(),
|
|
147
129
|
Fr.random(),
|
|
148
130
|
);
|
|
@@ -152,14 +134,13 @@ export class UniqueNote extends ExtendedNote {
|
|
|
152
134
|
const reader = BufferReader.asReader(buffer);
|
|
153
135
|
|
|
154
136
|
const note = reader.readObject(Note);
|
|
155
|
-
const
|
|
137
|
+
const recipient = reader.readObject(AztecAddress);
|
|
156
138
|
const contractAddress = reader.readObject(AztecAddress);
|
|
157
139
|
const storageSlot = reader.readObject(Fr);
|
|
158
|
-
const noteTypeId = reader.readObject(NoteSelector);
|
|
159
140
|
const txHash = reader.readObject(TxHash);
|
|
160
141
|
const nonce = reader.readObject(Fr);
|
|
161
142
|
|
|
162
|
-
return new this(note,
|
|
143
|
+
return new this(note, recipient, contractAddress, storageSlot, txHash, nonce);
|
|
163
144
|
}
|
|
164
145
|
|
|
165
146
|
static override fromString(str: string) {
|
package/src/note/notes_filter.ts
CHANGED
|
@@ -18,8 +18,8 @@ export type NotesFilter = {
|
|
|
18
18
|
contractAddress?: AztecAddress;
|
|
19
19
|
/** The specific storage location of the note on the contract. */
|
|
20
20
|
storageSlot?: Fr;
|
|
21
|
-
/** The
|
|
22
|
-
|
|
21
|
+
/** The recipient of the note (whose public key was used to encrypt the note). */
|
|
22
|
+
recipient?: AztecAddress;
|
|
23
23
|
/** The status of the note. Defaults to 'ACTIVE'. */
|
|
24
24
|
status?: NoteStatus;
|
|
25
25
|
/** The siloed nullifier for the note. */
|
|
@@ -32,7 +32,7 @@ export const NotesFilterSchema: ZodFor<NotesFilter> = z.object({
|
|
|
32
32
|
txHash: TxHash.schema.optional(),
|
|
33
33
|
contractAddress: schemas.AztecAddress.optional(),
|
|
34
34
|
storageSlot: schemas.Fr.optional(),
|
|
35
|
-
|
|
35
|
+
recipient: schemas.AztecAddress.optional(),
|
|
36
36
|
status: z.nativeEnum(NoteStatus).optional(),
|
|
37
37
|
siloedNullifier: schemas.Fr.optional(),
|
|
38
38
|
scopes: z.array(schemas.AztecAddress).optional(),
|
|
@@ -7,6 +7,7 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
7
7
|
import { encodeAbiParameters, parseAbiParameters } from 'viem';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
|
|
10
|
+
import type { L2Block } from '../block/l2_block.js';
|
|
10
11
|
import { BlockHeader } from '../tx/block_header.js';
|
|
11
12
|
import { TxHash } from '../tx/tx_hash.js';
|
|
12
13
|
import type { Signable, SignatureDomainSeparator } from './signature_utils.js';
|
|
@@ -73,6 +74,14 @@ export class ConsensusPayload implements Signable {
|
|
|
73
74
|
return new ConsensusPayload(fields.header, fields.archive, fields.txHashes);
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
static fromBlock(block: L2Block): ConsensusPayload {
|
|
78
|
+
return new ConsensusPayload(
|
|
79
|
+
block.header,
|
|
80
|
+
block.archive.root,
|
|
81
|
+
block.body.txEffects.map(tx => tx.txHash),
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
76
85
|
static empty(): ConsensusPayload {
|
|
77
86
|
return new ConsensusPayload(BlockHeader.empty(), Fr.ZERO, []);
|
|
78
87
|
}
|
package/src/proofs/proof.ts
CHANGED
|
@@ -18,9 +18,6 @@ export class Proof {
|
|
|
18
18
|
// Honk proofs start with a 4 byte length prefix
|
|
19
19
|
// the proof metadata starts immediately after
|
|
20
20
|
private readonly metadataOffset = 4;
|
|
21
|
-
// the metadata is 3 Frs long
|
|
22
|
-
// the public inputs are after it
|
|
23
|
-
private readonly publicInputsOffset = 100;
|
|
24
21
|
|
|
25
22
|
constructor(
|
|
26
23
|
/**
|
|
@@ -65,15 +62,12 @@ export class Proof {
|
|
|
65
62
|
}
|
|
66
63
|
|
|
67
64
|
public withoutPublicInputs(): Buffer {
|
|
68
|
-
return Buffer.concat([
|
|
69
|
-
this.buffer.subarray(this.metadataOffset, this.publicInputsOffset),
|
|
70
|
-
this.buffer.subarray(this.publicInputsOffset + Fr.SIZE_IN_BYTES * this.numPublicInputs),
|
|
71
|
-
]);
|
|
65
|
+
return Buffer.concat([this.buffer.subarray(this.metadataOffset + Fr.SIZE_IN_BYTES * this.numPublicInputs)]);
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
public extractPublicInputs(): Fr[] {
|
|
75
69
|
const reader = BufferReader.asReader(
|
|
76
|
-
this.buffer.subarray(this.
|
|
70
|
+
this.buffer.subarray(this.metadataOffset, this.metadataOffset + Fr.SIZE_IN_BYTES * this.numPublicInputs),
|
|
77
71
|
);
|
|
78
72
|
return reader.readArray(this.numPublicInputs, Fr);
|
|
79
73
|
}
|
package/src/tests/factories.ts
CHANGED
|
@@ -56,6 +56,7 @@ import { ContractStorageUpdateRequest } from '../avm/contract_storage_update_req
|
|
|
56
56
|
import {
|
|
57
57
|
AvmAccumulatedData,
|
|
58
58
|
AvmAppendTreeHint,
|
|
59
|
+
AvmBytecodeCommitmentHint,
|
|
59
60
|
AvmCircuitInputs,
|
|
60
61
|
AvmCircuitPublicInputs,
|
|
61
62
|
AvmContractClassHint,
|
|
@@ -1337,7 +1338,6 @@ export function makeAvmStorageUpdateTreeHints(seed = 0): AvmPublicDataWriteTreeH
|
|
|
1337
1338
|
export function makeAvmContractInstanceHint(seed = 0): AvmContractInstanceHint {
|
|
1338
1339
|
return new AvmContractInstanceHint(
|
|
1339
1340
|
new AztecAddress(new Fr(seed)),
|
|
1340
|
-
true /* exists */,
|
|
1341
1341
|
new Fr(seed + 0x2),
|
|
1342
1342
|
new AztecAddress(new Fr(seed + 0x3)),
|
|
1343
1343
|
new Fr(seed + 0x4),
|
|
@@ -1349,8 +1349,6 @@ export function makeAvmContractInstanceHint(seed = 0): AvmContractInstanceHint {
|
|
|
1349
1349
|
new Point(new Fr(seed + 0x11), new Fr(seed + 0x12), false),
|
|
1350
1350
|
new Point(new Fr(seed + 0x13), new Fr(seed + 0x14), false),
|
|
1351
1351
|
),
|
|
1352
|
-
makeAvmPublicDataReadTreeHints(seed + 0x2000),
|
|
1353
|
-
makeArray(4, i => new Fr(i), seed + 0x3000),
|
|
1354
1352
|
);
|
|
1355
1353
|
}
|
|
1356
1354
|
|
|
@@ -1358,22 +1356,23 @@ export function makeAvmContractInstanceHint(seed = 0): AvmContractInstanceHint {
|
|
|
1358
1356
|
* @param seed - The seed to use for generating the state reference.
|
|
1359
1357
|
* @returns AvmContractClassHint.
|
|
1360
1358
|
*/
|
|
1361
|
-
export
|
|
1359
|
+
export function makeAvmContractClassHint(seed = 0): AvmContractClassHint {
|
|
1362
1360
|
const bytecode = makeBytes(32, seed + 0x5);
|
|
1363
|
-
return new AvmContractClassHint(
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
);
|
|
1361
|
+
return new AvmContractClassHint(new Fr(seed), new Fr(seed + 0x2), new Fr(seed + 0x3), bytecode);
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
export async function makeAvmBytecodeCommitmentHint(seed = 0): Promise<AvmBytecodeCommitmentHint> {
|
|
1365
|
+
const classId = new Fr(seed + 2);
|
|
1366
|
+
const bytecode = makeBytes(32, seed + 0x5);
|
|
1367
|
+
return new AvmBytecodeCommitmentHint(classId, await computePublicBytecodeCommitment(bytecode));
|
|
1371
1368
|
}
|
|
1372
1369
|
|
|
1373
1370
|
export function makeAvmEnqueuedCallHint(seed = 0): AvmEnqueuedCallHint {
|
|
1374
1371
|
return new AvmEnqueuedCallHint(
|
|
1375
1372
|
new AztecAddress(new Fr(seed)),
|
|
1373
|
+
new AztecAddress(new Fr(seed + 2)),
|
|
1376
1374
|
makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x1000),
|
|
1375
|
+
/*isStaticCall=*/ false,
|
|
1377
1376
|
);
|
|
1378
1377
|
}
|
|
1379
1378
|
|
|
@@ -1392,8 +1391,9 @@ export async function makeAvmExecutionHints(
|
|
|
1392
1391
|
|
|
1393
1392
|
const fields = {
|
|
1394
1393
|
enqueuedCalls: makeArray(baseLength, makeAvmEnqueuedCallHint, seed + 0x4100),
|
|
1395
|
-
contractInstances: makeArray(baseLength +
|
|
1396
|
-
contractClasses:
|
|
1394
|
+
contractInstances: makeArray(baseLength + 2, makeAvmContractInstanceHint, seed + 0x4700),
|
|
1395
|
+
contractClasses: makeArray(baseLength + 5, makeAvmContractClassHint, seed + 0x4900),
|
|
1396
|
+
bytecodeCommitments: await makeArrayAsync(baseLength + 5, makeAvmBytecodeCommitmentHint, seed + 0x4900),
|
|
1397
1397
|
publicDataReads: makeArray(baseLength + 7, makeAvmStorageReadTreeHints, seed + 0x4900),
|
|
1398
1398
|
publicDataWrites: makeArray(baseLength + 8, makeAvmStorageUpdateTreeHints, seed + 0x4a00),
|
|
1399
1399
|
nullifierReads: makeArray(baseLength + 9, makeAvmNullifierReadTreeHints, seed + 0x4b00),
|
|
@@ -1408,6 +1408,7 @@ export async function makeAvmExecutionHints(
|
|
|
1408
1408
|
fields.enqueuedCalls,
|
|
1409
1409
|
fields.contractInstances,
|
|
1410
1410
|
fields.contractClasses,
|
|
1411
|
+
fields.bytecodeCommitments,
|
|
1411
1412
|
fields.publicDataReads,
|
|
1412
1413
|
fields.publicDataWrites,
|
|
1413
1414
|
fields.nullifierReads,
|
package/src/tests/mocks.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { Secp256k1Signer, randomBytes } from '@aztec/foundation/crypto';
|
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
|
|
6
6
|
import type { ContractArtifact } from '../abi/abi.js';
|
|
7
|
-
import { NoteSelector } from '../abi/note_selector.js';
|
|
8
7
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
9
8
|
import { computeContractAddressFromInstance } from '../contract/contract_address.js';
|
|
10
9
|
import { getContractClassFromArtifact } from '../contract/contract_class.js';
|
|
@@ -46,37 +45,33 @@ export const randomTxHash = (): TxHash => TxHash.random();
|
|
|
46
45
|
|
|
47
46
|
export const randomExtendedNote = async ({
|
|
48
47
|
note = Note.random(),
|
|
49
|
-
|
|
48
|
+
recipient = undefined,
|
|
50
49
|
contractAddress = undefined,
|
|
51
50
|
txHash = randomTxHash(),
|
|
52
51
|
storageSlot = Fr.random(),
|
|
53
|
-
noteTypeId = NoteSelector.random(),
|
|
54
52
|
}: Partial<ExtendedNote> = {}) => {
|
|
55
53
|
return new ExtendedNote(
|
|
56
54
|
note,
|
|
57
|
-
|
|
55
|
+
recipient ?? (await AztecAddress.random()),
|
|
58
56
|
contractAddress ?? (await AztecAddress.random()),
|
|
59
57
|
storageSlot,
|
|
60
|
-
noteTypeId,
|
|
61
58
|
txHash,
|
|
62
59
|
);
|
|
63
60
|
};
|
|
64
61
|
|
|
65
62
|
export const randomUniqueNote = async ({
|
|
66
63
|
note = Note.random(),
|
|
67
|
-
|
|
64
|
+
recipient = undefined,
|
|
68
65
|
contractAddress = undefined,
|
|
69
66
|
txHash = randomTxHash(),
|
|
70
67
|
storageSlot = Fr.random(),
|
|
71
|
-
noteTypeId = NoteSelector.random(),
|
|
72
68
|
nonce = Fr.random(),
|
|
73
69
|
}: Partial<UniqueNote> = {}) => {
|
|
74
70
|
return new UniqueNote(
|
|
75
71
|
note,
|
|
76
|
-
|
|
72
|
+
recipient ?? (await AztecAddress.random()),
|
|
77
73
|
contractAddress ?? (await AztecAddress.random()),
|
|
78
74
|
storageSlot,
|
|
79
|
-
noteTypeId,
|
|
80
75
|
txHash,
|
|
81
76
|
nonce,
|
|
82
77
|
);
|
|
@@ -228,6 +223,7 @@ export const mockSimulatedTx = async (seed = 1) => {
|
|
|
228
223
|
export const randomContractArtifact = (): ContractArtifact => ({
|
|
229
224
|
name: randomBytes(4).toString('hex'),
|
|
230
225
|
functions: [],
|
|
226
|
+
nonDispatchPublicFunctions: [],
|
|
231
227
|
outputs: {
|
|
232
228
|
structs: {},
|
|
233
229
|
globals: {},
|
package/src/tx/capsule.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { Vector } from '../types/shared.js';
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Read-only data that is passed to the contract through an oracle during a transaction execution.
|
|
11
|
+
* TODO(#12425): Check whether this is always used to represent a transient capsule and if so, rename to
|
|
12
|
+
* TransientCapsule.
|
|
11
13
|
*/
|
|
12
14
|
export class Capsule {
|
|
13
15
|
constructor(
|
package/src/tx/tx_effect.ts
CHANGED
|
@@ -158,6 +158,28 @@ export class TxEffect {
|
|
|
158
158
|
]);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
equals(other: TxEffect): boolean {
|
|
162
|
+
return (
|
|
163
|
+
this.revertCode.equals(other.revertCode) &&
|
|
164
|
+
this.txHash.equals(other.txHash) &&
|
|
165
|
+
this.transactionFee.equals(other.transactionFee) &&
|
|
166
|
+
this.noteHashes.length === other.noteHashes.length &&
|
|
167
|
+
this.noteHashes.every((h, i) => h.equals(other.noteHashes[i])) &&
|
|
168
|
+
this.nullifiers.length === other.nullifiers.length &&
|
|
169
|
+
this.nullifiers.every((h, i) => h.equals(other.nullifiers[i])) &&
|
|
170
|
+
this.l2ToL1Msgs.length === other.l2ToL1Msgs.length &&
|
|
171
|
+
this.l2ToL1Msgs.every((h, i) => h.equals(other.l2ToL1Msgs[i])) &&
|
|
172
|
+
this.publicDataWrites.length === other.publicDataWrites.length &&
|
|
173
|
+
this.publicDataWrites.every((h, i) => h.equals(other.publicDataWrites[i])) &&
|
|
174
|
+
this.privateLogs.length === other.privateLogs.length &&
|
|
175
|
+
this.privateLogs.every((h, i) => h.equals(other.privateLogs[i])) &&
|
|
176
|
+
this.publicLogs.length === other.publicLogs.length &&
|
|
177
|
+
this.publicLogs.every((h, i) => h.equals(other.publicLogs[i])) &&
|
|
178
|
+
this.contractClassLogs.length === other.contractClassLogs.length &&
|
|
179
|
+
this.contractClassLogs.every((h, i) => h.equals(other.contractClassLogs[i]))
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
161
183
|
/** Returns the size of this tx effect in bytes as serialized onto DA. */
|
|
162
184
|
getDASize() {
|
|
163
185
|
return this.toBlobFields().length * Fr.SIZE_IN_BYTES;
|
|
@@ -223,7 +245,7 @@ export class TxEffect {
|
|
|
223
245
|
makeTuple(MAX_L2_TO_L1_MSGS_PER_TX, Fr.random),
|
|
224
246
|
makeTuple(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, () => new PublicDataWrite(Fr.random(), Fr.random())),
|
|
225
247
|
makeTuple(MAX_PRIVATE_LOGS_PER_TX, () => new PrivateLog(makeTuple(PRIVATE_LOG_SIZE_IN_FIELDS, Fr.random))),
|
|
226
|
-
await makeTupleAsync(numPublicCallsPerTx * numPublicLogsPerCall, PublicLog.random),
|
|
248
|
+
await makeTupleAsync(numPublicCallsPerTx * numPublicLogsPerCall, async () => await PublicLog.random()),
|
|
227
249
|
await makeTupleAsync(MAX_CONTRACT_CLASS_LOGS_PER_TX, ContractClassLog.random),
|
|
228
250
|
);
|
|
229
251
|
}
|