@aztec/stdlib 0.0.1-commit.9b94fc1 → 0.0.1-commit.d3ec352c
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 +187 -24
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +174 -20
- package/dest/avm/avm_circuit_public_inputs.d.ts +5 -3
- package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
- package/dest/avm/avm_proving_request.d.ts +9 -5
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/block/block_parameter.d.ts +5 -0
- package/dest/block/block_parameter.d.ts.map +1 -0
- package/dest/block/block_parameter.js +6 -0
- package/dest/block/in_block.d.ts +12 -9
- package/dest/block/in_block.d.ts.map +1 -1
- package/dest/block/in_block.js +3 -3
- package/dest/block/index.d.ts +1 -1
- package/dest/block/index.js +1 -1
- package/dest/block/l2_block.d.ts +5 -5
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +3 -2
- package/dest/block/l2_block_code_to_purge.js +3 -3
- package/dest/block/l2_block_header.d.ts +3 -3
- package/dest/block/l2_block_header.d.ts.map +1 -1
- package/dest/block/l2_block_info.d.ts +15 -10
- package/dest/block/l2_block_info.d.ts.map +1 -1
- package/dest/block/l2_block_info.js +7 -6
- package/dest/block/l2_block_new.d.ts +6 -4
- package/dest/block/l2_block_new.d.ts.map +1 -1
- package/dest/block/l2_block_new.js +4 -1
- package/dest/block/l2_block_source.d.ts +63 -97
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +5 -11
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +4 -3
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +3 -2
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_memory_store.js +4 -2
- package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +6 -4
- package/dest/checkpoint/checkpoint.d.ts +14 -11
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +5 -5
- package/dest/checkpoint/published_checkpoint.d.ts +5 -3
- package/dest/checkpoint/published_checkpoint.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_data_source.d.ts +3 -2
- package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +15 -9
- package/dest/interfaces/aztec-node.d.ts +29 -24
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +25 -23
- package/dest/interfaces/block-builder.d.ts +3 -2
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/epoch-prover.d.ts +4 -4
- package/dest/interfaces/epoch-prover.d.ts.map +1 -1
- package/dest/interfaces/get_logs_response.d.ts +5 -3
- package/dest/interfaces/get_logs_response.d.ts.map +1 -1
- package/dest/interfaces/l2_logs_source.d.ts +4 -3
- package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
- package/dest/interfaces/merkle_tree_operations.d.ts +3 -2
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/proving-job.d.ts +9 -5
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/tx_provider.d.ts +3 -3
- package/dest/interfaces/tx_provider.d.ts.map +1 -1
- package/dest/interfaces/world_state.d.ts +9 -26
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/interfaces/world_state.js +4 -3
- package/dest/logs/extended_public_log.d.ts +5 -3
- package/dest/logs/extended_public_log.d.ts.map +1 -1
- package/dest/logs/log_id.d.ts +8 -5
- package/dest/logs/log_id.d.ts.map +1 -1
- package/dest/logs/log_id.js +5 -4
- package/dest/logs/tx_scoped_l2_log.d.ts +10 -7
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +4 -3
- package/dest/messaging/l1_to_l2_message_source.d.ts +10 -3
- package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.d.ts +4 -3
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/note/note_dao.d.ts +9 -5
- package/dest/note/note_dao.d.ts.map +1 -1
- package/dest/note/note_dao.js +12 -7
- package/dest/note/notes_filter.d.ts +3 -1
- package/dest/note/notes_filter.d.ts.map +1 -1
- package/dest/note/notes_filter.js +1 -0
- package/dest/rollup/checkpoint_header.d.ts +2 -2
- package/dest/rollup/checkpoint_header.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.js +1 -1
- package/dest/tests/factories.js +5 -5
- package/dest/tests/mocks.d.ts +1 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +2 -1
- package/dest/tx/block_header.d.ts +4 -4
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/content_commitment.d.ts +3 -2
- package/dest/tx/content_commitment.d.ts.map +1 -1
- package/dest/tx/content_commitment.js +10 -2
- package/dest/tx/global_variables.d.ts +13 -11
- package/dest/tx/global_variables.d.ts.map +1 -1
- package/dest/tx/global_variables.js +6 -6
- package/dest/tx/indexed_tx_effect.d.ts +8 -5
- package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
- package/dest/tx/indexed_tx_effect.js +2 -1
- package/dest/tx/private_execution_result.d.ts +3 -3
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/processed_tx.d.ts +2 -2
- package/dest/tx/processed_tx.d.ts.map +1 -1
- package/dest/tx/processed_tx.js +4 -1
- package/dest/tx/tx.d.ts +2 -2
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +1 -0
- package/dest/tx/tx_receipt.d.ts +4 -3
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +2 -1
- package/package.json +9 -9
- package/src/avm/avm.ts +238 -23
- package/src/block/block_parameter.ts +8 -0
- package/src/block/in_block.ts +13 -9
- package/src/block/index.ts +1 -1
- package/src/block/l2_block.ts +10 -5
- package/src/block/l2_block_code_to_purge.ts +3 -3
- package/src/block/l2_block_info.ts +10 -9
- package/src/block/l2_block_new.ts +8 -3
- package/src/block/l2_block_source.ts +40 -22
- package/src/block/l2_block_stream/l2_block_stream.ts +10 -5
- package/src/block/l2_block_stream/l2_tips_memory_store.ts +5 -2
- package/src/block/test/l2_tips_store_test_suite.ts +8 -3
- package/src/checkpoint/checkpoint.ts +7 -7
- package/src/contract/interfaces/contract_data_source.ts +2 -1
- package/src/interfaces/archiver.ts +18 -9
- package/src/interfaces/aztec-node.ts +61 -46
- package/src/interfaces/block-builder.ts +2 -1
- package/src/interfaces/epoch-prover.ts +3 -3
- package/src/interfaces/l2_logs_source.ts +3 -2
- package/src/interfaces/merkle_tree_operations.ts +2 -1
- package/src/interfaces/tx_provider.ts +2 -2
- package/src/interfaces/world_state.ts +12 -11
- package/src/logs/log_id.ts +6 -5
- package/src/logs/tx_scoped_l2_log.ts +5 -4
- package/src/messaging/l1_to_l2_message_source.ts +10 -2
- package/src/messaging/l2_to_l1_membership.ts +3 -2
- package/src/note/note_dao.ts +15 -5
- package/src/note/notes_filter.ts +3 -0
- package/src/rollup/checkpoint_header.ts +4 -2
- package/src/tests/factories.ts +4 -4
- package/src/tests/mocks.ts +2 -1
- package/src/tx/block_header.ts +2 -2
- package/src/tx/content_commitment.ts +11 -2
- package/src/tx/global_variables.ts +8 -8
- package/src/tx/indexed_tx_effect.ts +4 -3
- package/src/tx/private_execution_result.ts +2 -2
- package/src/tx/processed_tx.ts +8 -2
- package/src/tx/tx.ts +2 -1
- package/src/tx/tx_receipt.ts +3 -2
- package/dest/block/l2_block_number.d.ts +0 -5
- package/dest/block/l2_block_number.d.ts.map +0 -1
- package/dest/block/l2_block_number.js +0 -6
- package/src/block/l2_block_number.ts +0 -8
package/src/note/note_dao.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { Fr, Point } from '@aztec/foundation/fields';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -17,13 +18,15 @@ export class NoteDao {
|
|
|
17
18
|
public note: Note,
|
|
18
19
|
/** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */
|
|
19
20
|
public contractAddress: AztecAddress,
|
|
21
|
+
/** The owner of the note - generally the account that can spend the note. */
|
|
22
|
+
public owner: AztecAddress,
|
|
20
23
|
/**
|
|
21
24
|
* The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
|
|
22
25
|
* since contracts typically make queries based on it.
|
|
23
26
|
*/
|
|
24
27
|
public storageSlot: Fr,
|
|
25
28
|
/**
|
|
26
|
-
* The randomness injected to the note.
|
|
29
|
+
* The randomness injected to the note hash preimage.
|
|
27
30
|
*/
|
|
28
31
|
public randomness: Fr,
|
|
29
32
|
/** The nonce that was injected into the note hash preimage in order to guarantee uniqueness. */
|
|
@@ -48,7 +51,7 @@ export class NoteDao {
|
|
|
48
51
|
public txHash: TxHash,
|
|
49
52
|
/** The L2 block number in which the tx with this note was included. Used for note management while processing
|
|
50
53
|
* reorgs.*/
|
|
51
|
-
public l2BlockNumber:
|
|
54
|
+
public l2BlockNumber: BlockNumber,
|
|
52
55
|
/** The L2 block hash in which the tx with this note was included. Used for note management while processing
|
|
53
56
|
* reorgs.*/
|
|
54
57
|
public l2BlockHash: string,
|
|
@@ -60,6 +63,7 @@ export class NoteDao {
|
|
|
60
63
|
return serializeToBuffer([
|
|
61
64
|
this.note,
|
|
62
65
|
this.contractAddress,
|
|
66
|
+
this.owner,
|
|
63
67
|
this.storageSlot,
|
|
64
68
|
this.randomness,
|
|
65
69
|
this.noteNonce,
|
|
@@ -77,19 +81,21 @@ export class NoteDao {
|
|
|
77
81
|
|
|
78
82
|
const note = Note.fromBuffer(reader);
|
|
79
83
|
const contractAddress = AztecAddress.fromBuffer(reader);
|
|
84
|
+
const owner = AztecAddress.fromBuffer(reader);
|
|
80
85
|
const storageSlot = Fr.fromBuffer(reader);
|
|
81
86
|
const randomness = Fr.fromBuffer(reader);
|
|
82
87
|
const noteNonce = Fr.fromBuffer(reader);
|
|
83
88
|
const noteHash = Fr.fromBuffer(reader);
|
|
84
89
|
const siloedNullifier = Fr.fromBuffer(reader);
|
|
85
90
|
const txHash = reader.readObject(TxHash);
|
|
86
|
-
const l2BlockNumber = reader.readNumber();
|
|
91
|
+
const l2BlockNumber = BlockNumber(reader.readNumber());
|
|
87
92
|
const l2BlockHash = Fr.fromBuffer(reader).toString();
|
|
88
93
|
const index = toBigIntBE(reader.readBytes(32));
|
|
89
94
|
|
|
90
95
|
return new NoteDao(
|
|
91
96
|
note,
|
|
92
97
|
contractAddress,
|
|
98
|
+
owner,
|
|
93
99
|
storageSlot,
|
|
94
100
|
randomness,
|
|
95
101
|
noteNonce,
|
|
@@ -118,25 +124,29 @@ export class NoteDao {
|
|
|
118
124
|
public getSize() {
|
|
119
125
|
const indexSize = Math.ceil(Math.log2(Number(this.index)));
|
|
120
126
|
const noteSize = 4 + this.note.items.length * Fr.SIZE_IN_BYTES;
|
|
121
|
-
return
|
|
127
|
+
return (
|
|
128
|
+
noteSize + AztecAddress.SIZE_IN_BYTES * 2 + Fr.SIZE_IN_BYTES * 4 + TxHash.SIZE + Point.SIZE_IN_BYTES + indexSize
|
|
129
|
+
);
|
|
122
130
|
}
|
|
123
131
|
|
|
124
132
|
static async random({
|
|
125
133
|
note = Note.random(),
|
|
126
134
|
contractAddress = undefined,
|
|
135
|
+
owner = undefined,
|
|
127
136
|
storageSlot = Fr.random(),
|
|
128
137
|
randomness = Fr.random(),
|
|
129
138
|
noteNonce = Fr.random(),
|
|
130
139
|
noteHash = Fr.random(),
|
|
131
140
|
siloedNullifier = Fr.random(),
|
|
132
141
|
txHash = TxHash.random(),
|
|
133
|
-
l2BlockNumber = Math.floor(Math.random() * 1000),
|
|
142
|
+
l2BlockNumber = BlockNumber(Math.floor(Math.random() * 1000)),
|
|
134
143
|
l2BlockHash = Fr.random().toString(),
|
|
135
144
|
index = Fr.random().toBigInt(),
|
|
136
145
|
}: Partial<NoteDao> = {}) {
|
|
137
146
|
return new NoteDao(
|
|
138
147
|
note,
|
|
139
148
|
contractAddress ?? (await AztecAddress.random()),
|
|
149
|
+
owner ?? (await AztecAddress.random()),
|
|
140
150
|
storageSlot,
|
|
141
151
|
randomness,
|
|
142
152
|
noteNonce,
|
package/src/note/notes_filter.ts
CHANGED
|
@@ -16,6 +16,8 @@ export type NotesFilter = {
|
|
|
16
16
|
* @remarks Providing a contract address is required as we need that information to trigger private state sync.
|
|
17
17
|
*/
|
|
18
18
|
contractAddress: AztecAddress;
|
|
19
|
+
/** The owner of the note. */
|
|
20
|
+
owner?: AztecAddress;
|
|
19
21
|
/** The specific storage location of the note on the contract. */
|
|
20
22
|
storageSlot?: Fr;
|
|
21
23
|
/** The status of the note. Defaults to 'ACTIVE'. */
|
|
@@ -28,6 +30,7 @@ export type NotesFilter = {
|
|
|
28
30
|
|
|
29
31
|
export const NotesFilterSchema: ZodFor<NotesFilter> = z.object({
|
|
30
32
|
contractAddress: schemas.AztecAddress,
|
|
33
|
+
owner: schemas.AztecAddress.optional(),
|
|
31
34
|
storageSlot: schemas.Fr.optional(),
|
|
32
35
|
status: z.nativeEnum(NoteStatus).optional(),
|
|
33
36
|
siloedNullifier: schemas.Fr.optional(),
|
|
@@ -137,11 +137,13 @@ export class CheckpointHeader {
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
static random(
|
|
140
|
+
static random(
|
|
141
|
+
overrides: Partial<FieldsOf<CheckpointHeader>> & Partial<FieldsOf<ContentCommitment>> = {},
|
|
142
|
+
): CheckpointHeader {
|
|
141
143
|
return CheckpointHeader.from({
|
|
142
144
|
lastArchiveRoot: Fr.random(),
|
|
143
145
|
blockHeadersHash: Fr.random(),
|
|
144
|
-
contentCommitment: ContentCommitment.random(),
|
|
146
|
+
contentCommitment: ContentCommitment.random(overrides),
|
|
145
147
|
slotNumber: SlotNumber(Math.floor(Math.random() * 1000) + 1),
|
|
146
148
|
timestamp: BigInt(Math.floor(Date.now() / 1000)),
|
|
147
149
|
coinbase: EthAddress.random(),
|
package/src/tests/factories.ts
CHANGED
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
VK_TREE_HEIGHT,
|
|
44
44
|
} from '@aztec/constants';
|
|
45
45
|
import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
|
|
46
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
46
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
47
47
|
import { compact } from '@aztec/foundation/collection';
|
|
48
48
|
import { Grumpkin, SchnorrSignature, poseidon2HashWithSeparator, sha256 } from '@aztec/foundation/crypto';
|
|
49
49
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -694,7 +694,7 @@ export function makeGlobalVariables(seed = 1, overrides: Partial<FieldsOf<Global
|
|
|
694
694
|
return GlobalVariables.from({
|
|
695
695
|
chainId: new Fr(seed),
|
|
696
696
|
version: new Fr(seed + 1),
|
|
697
|
-
blockNumber: seed + 2,
|
|
697
|
+
blockNumber: BlockNumber(seed + 2),
|
|
698
698
|
slotNumber: SlotNumber(seed + 3),
|
|
699
699
|
timestamp: BigInt(seed + 4),
|
|
700
700
|
coinbase: EthAddress.fromField(new Fr(seed + 5)),
|
|
@@ -916,8 +916,8 @@ export function makeL2BlockHeader(
|
|
|
916
916
|
overrides?.contentCommitment ?? makeContentCommitment(seed + 0x200),
|
|
917
917
|
overrides?.state ?? makeStateReference(seed + 0x600),
|
|
918
918
|
makeGlobalVariables((seed += 0x700), {
|
|
919
|
-
...(blockNumber ? { blockNumber } : {}),
|
|
920
|
-
...(slotNumber ? { slotNumber: SlotNumber(slotNumber) } : {}),
|
|
919
|
+
...(blockNumber !== undefined ? { blockNumber: BlockNumber(blockNumber) } : {}),
|
|
920
|
+
...(slotNumber !== undefined ? { slotNumber: SlotNumber(slotNumber) } : {}),
|
|
921
921
|
}),
|
|
922
922
|
new Fr(seed + 0x800),
|
|
923
923
|
new Fr(seed + 0x900),
|
package/src/tests/mocks.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
8
8
|
} from '@aztec/constants';
|
|
9
9
|
import { makeTuple } from '@aztec/foundation/array';
|
|
10
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
10
11
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
11
12
|
import { padArrayEnd, times } from '@aztec/foundation/collection';
|
|
12
13
|
import { Secp256k1Signer, randomBytes } from '@aztec/foundation/crypto';
|
|
@@ -513,7 +514,7 @@ export async function randomPublishedL2Block(
|
|
|
513
514
|
l2BlockNumber: number,
|
|
514
515
|
opts: { signers?: Secp256k1Signer[] } = {},
|
|
515
516
|
): Promise<PublishedL2Block> {
|
|
516
|
-
const block = await L2Block.random(l2BlockNumber);
|
|
517
|
+
const block = await L2Block.random(BlockNumber(l2BlockNumber));
|
|
517
518
|
const l1 = L1PublishedData.fromFields({
|
|
518
519
|
blockNumber: BigInt(block.number),
|
|
519
520
|
timestamp: block.header.globalVariables.timestamp,
|
package/src/tx/block_header.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BLOCK_HEADER_LENGTH, GeneratorIndex } from '@aztec/constants';
|
|
2
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { poseidon2HashWithSeparator, randomInt } from '@aztec/foundation/crypto';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { type ZodFor, schemas } from '@aztec/foundation/schemas';
|
|
@@ -66,7 +66,7 @@ export class BlockHeader {
|
|
|
66
66
|
return this.globalVariables.slotNumber;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
getBlockNumber() {
|
|
69
|
+
getBlockNumber(): BlockNumber {
|
|
70
70
|
return this.globalVariables.blockNumber;
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -28,6 +28,10 @@ export class ContentCommitment {
|
|
|
28
28
|
return [fields.blobsHash, fields.inHash, fields.outHash] as const;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
static from(fields: FieldsOf<ContentCommitment>) {
|
|
32
|
+
return new ContentCommitment(...ContentCommitment.getFields(fields));
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
getSize() {
|
|
32
36
|
return this.toBuffer().length;
|
|
33
37
|
}
|
|
@@ -75,8 +79,13 @@ export class ContentCommitment {
|
|
|
75
79
|
return new ContentCommitment(reader.readField(), reader.readField(), reader.readField());
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
static random(): ContentCommitment {
|
|
79
|
-
return
|
|
82
|
+
static random(overrides: Partial<FieldsOf<ContentCommitment>> = {}): ContentCommitment {
|
|
83
|
+
return ContentCommitment.from({
|
|
84
|
+
blobsHash: Fr.random(),
|
|
85
|
+
inHash: Fr.random(),
|
|
86
|
+
outHash: Fr.random(),
|
|
87
|
+
...overrides,
|
|
88
|
+
});
|
|
80
89
|
}
|
|
81
90
|
|
|
82
91
|
static empty(): ContentCommitment {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GLOBAL_VARIABLES_LENGTH } from '@aztec/constants';
|
|
2
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { BlockNumber, BlockNumberSchema, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { randomInt } from '@aztec/foundation/crypto';
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -19,7 +19,7 @@ import { z } from 'zod';
|
|
|
19
19
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
20
20
|
import { GasFees } from '../gas/gas_fees.js';
|
|
21
21
|
import { schemas } from '../schemas/index.js';
|
|
22
|
-
import type {
|
|
22
|
+
import type { UInt64 } from '../types/index.js';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Global variables of the L2 block.
|
|
@@ -31,7 +31,7 @@ export class GlobalVariables {
|
|
|
31
31
|
/** Version for the L2 block. */
|
|
32
32
|
public version: Fr,
|
|
33
33
|
/** Block number of the L2 block. */
|
|
34
|
-
public blockNumber:
|
|
34
|
+
public blockNumber: BlockNumber,
|
|
35
35
|
/** Slot number of the L2 block */
|
|
36
36
|
public slotNumber: SlotNumber,
|
|
37
37
|
/** Timestamp of the L2 block. */
|
|
@@ -49,7 +49,7 @@ export class GlobalVariables {
|
|
|
49
49
|
.object({
|
|
50
50
|
chainId: schemas.Fr,
|
|
51
51
|
version: schemas.Fr,
|
|
52
|
-
blockNumber:
|
|
52
|
+
blockNumber: BlockNumberSchema,
|
|
53
53
|
slotNumber: schemas.SlotNumber,
|
|
54
54
|
timestamp: schemas.BigInt,
|
|
55
55
|
coinbase: schemas.EthAddress,
|
|
@@ -89,7 +89,7 @@ export class GlobalVariables {
|
|
|
89
89
|
|
|
90
90
|
static empty(fields: Partial<FieldsOf<GlobalVariables>> = {}): GlobalVariables {
|
|
91
91
|
return GlobalVariables.from({
|
|
92
|
-
blockNumber:
|
|
92
|
+
blockNumber: BlockNumber.ZERO,
|
|
93
93
|
slotNumber: SlotNumber.ZERO,
|
|
94
94
|
timestamp: 0n,
|
|
95
95
|
chainId: Fr.ZERO,
|
|
@@ -106,7 +106,7 @@ export class GlobalVariables {
|
|
|
106
106
|
return new GlobalVariables(
|
|
107
107
|
Fr.fromBuffer(reader),
|
|
108
108
|
Fr.fromBuffer(reader),
|
|
109
|
-
reader.readNumber(),
|
|
109
|
+
BlockNumber(reader.readNumber()),
|
|
110
110
|
SlotNumber(reader.readNumber()),
|
|
111
111
|
reader.readUInt64(),
|
|
112
112
|
reader.readObject(EthAddress),
|
|
@@ -121,7 +121,7 @@ export class GlobalVariables {
|
|
|
121
121
|
return new GlobalVariables(
|
|
122
122
|
reader.readField(),
|
|
123
123
|
reader.readField(),
|
|
124
|
-
reader.readU32(),
|
|
124
|
+
BlockNumber(reader.readU32()),
|
|
125
125
|
SlotNumber(reader.readU32()),
|
|
126
126
|
reader.readField().toBigInt(),
|
|
127
127
|
EthAddress.fromField(reader.readField()),
|
|
@@ -219,7 +219,7 @@ export class GlobalVariables {
|
|
|
219
219
|
return GlobalVariables.from({
|
|
220
220
|
chainId: new Fr(randomInt(100_000)),
|
|
221
221
|
version: new Fr(randomInt(100_000)),
|
|
222
|
-
blockNumber: randomInt(100_000),
|
|
222
|
+
blockNumber: BlockNumber(randomInt(100_000)),
|
|
223
223
|
slotNumber: SlotNumber(randomInt(100_000)),
|
|
224
224
|
coinbase: EthAddress.random(),
|
|
225
225
|
feeRecipient: AztecAddress.fromField(Fr.random()),
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { schemas } from '@aztec/foundation/schemas';
|
|
2
3
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
4
|
|
|
4
5
|
import { L2BlockHash } from '../block/block_hash.js';
|
|
5
|
-
import { type
|
|
6
|
+
import { type DataInBlock, inBlockSchemaFor, randomInBlock } from '../block/in_block.js';
|
|
6
7
|
import { TxEffect } from './tx_effect.js';
|
|
7
8
|
|
|
8
|
-
export type IndexedTxEffect =
|
|
9
|
+
export type IndexedTxEffect = DataInBlock<TxEffect> & { txIndexInBlock: number };
|
|
9
10
|
|
|
10
11
|
export function indexedTxSchema() {
|
|
11
12
|
return inBlockSchemaFor(TxEffect.schema).extend({ txIndexInBlock: schemas.Integer });
|
|
@@ -26,7 +27,7 @@ export function deserializeIndexedTxEffect(buffer: Buffer): IndexedTxEffect {
|
|
|
26
27
|
const reader = BufferReader.asReader(buffer);
|
|
27
28
|
|
|
28
29
|
const l2BlockHash = reader.readObject(L2BlockHash);
|
|
29
|
-
const l2BlockNumber = reader.readNumber();
|
|
30
|
+
const l2BlockNumber = BlockNumber(reader.readNumber());
|
|
30
31
|
const txIndexInBlock = reader.readNumber();
|
|
31
32
|
const data = reader.readObject(TxEffect);
|
|
32
33
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { timesParallel } from '@aztec/foundation/collection';
|
|
2
3
|
import { randomBytes, randomInt } from '@aztec/foundation/crypto';
|
|
3
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -13,7 +14,6 @@ import { ContractClassLog, ContractClassLogFields } from '../logs/contract_class
|
|
|
13
14
|
import { type PreTag, PreTagSchema } from '../logs/pre_tag.js';
|
|
14
15
|
import { Note } from '../note/note.js';
|
|
15
16
|
import { type ZodFor, mapSchema, schemas } from '../schemas/index.js';
|
|
16
|
-
import type { UInt32 } from '../types/index.js';
|
|
17
17
|
import { HashedValues } from './hashed_values.js';
|
|
18
18
|
import type { OffchainEffect } from './offchain_effect.js';
|
|
19
19
|
|
|
@@ -109,7 +109,7 @@ export class PrivateExecutionResult {
|
|
|
109
109
|
/**
|
|
110
110
|
* The anchor block number that this execution was simulated with.
|
|
111
111
|
*/
|
|
112
|
-
getSimulationAnchorBlockNumber():
|
|
112
|
+
getSimulationAnchorBlockNumber(): BlockNumber {
|
|
113
113
|
return this.entrypoint.publicInputs.anchorBlockHeader.globalVariables.blockNumber;
|
|
114
114
|
}
|
|
115
115
|
}
|
package/src/tx/processed_tx.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
3
3
|
import type { AvmProvingRequest } from '../avm/avm_proving_request.js';
|
|
4
4
|
import type { PublicDataWrite } from '../avm/public_data_write.js';
|
|
5
5
|
import { RevertCode } from '../avm/revert_code.js';
|
|
6
|
-
import
|
|
6
|
+
import { SimulationError } from '../errors/simulation_error.js';
|
|
7
7
|
import { Gas } from '../gas/gas.js';
|
|
8
8
|
import type { GasUsed } from '../gas/gas_used.js';
|
|
9
9
|
import { computeL2ToL1MessageHash } from '../hash/hash.js';
|
|
@@ -173,6 +173,12 @@ export function makeProcessedTxFromTxWithPublicCalls(
|
|
|
173
173
|
contractClassLogs,
|
|
174
174
|
);
|
|
175
175
|
|
|
176
|
+
// Some callers expect a revert reason if the tx reverted.
|
|
177
|
+
const finalRevertReason =
|
|
178
|
+
revertReason === undefined && !revertCode.isOK()
|
|
179
|
+
? new SimulationError('TX reverted', /*functionErrorStack=*/ [], /*revertData=*/ [])
|
|
180
|
+
: revertReason;
|
|
181
|
+
|
|
176
182
|
return {
|
|
177
183
|
hash: txEffect.txHash,
|
|
178
184
|
data: tx.data,
|
|
@@ -182,6 +188,6 @@ export function makeProcessedTxFromTxWithPublicCalls(
|
|
|
182
188
|
txEffect,
|
|
183
189
|
gasUsed,
|
|
184
190
|
revertCode,
|
|
185
|
-
revertReason,
|
|
191
|
+
revertReason: finalRevertReason,
|
|
186
192
|
};
|
|
187
193
|
}
|
package/src/tx/tx.ts
CHANGED
|
@@ -300,8 +300,9 @@ export class Tx extends Gossipable {
|
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
/** Recomputes the tx hash. Used for testing purposes only when a property of the tx was mutated. */
|
|
303
|
-
public async recomputeHash() {
|
|
303
|
+
public async recomputeHash(): Promise<TxHash> {
|
|
304
304
|
(this as any).txHash = await Tx.computeTxHash(this);
|
|
305
|
+
return this.txHash;
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
#combinePublicCallRequestWithCallData(request: PublicCallRequest) {
|
package/src/tx/tx_receipt.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
3
|
|
|
3
4
|
import { z } from 'zod';
|
|
@@ -38,7 +39,7 @@ export class TxReceipt {
|
|
|
38
39
|
/** The hash of the block containing the transaction. */
|
|
39
40
|
public blockHash?: L2BlockHash,
|
|
40
41
|
/** The block number in which the transaction was included. */
|
|
41
|
-
public blockNumber?:
|
|
42
|
+
public blockNumber?: BlockNumber,
|
|
42
43
|
) {}
|
|
43
44
|
|
|
44
45
|
static empty() {
|
|
@@ -52,7 +53,7 @@ export class TxReceipt {
|
|
|
52
53
|
status: z.nativeEnum(TxStatus),
|
|
53
54
|
error: z.string(),
|
|
54
55
|
blockHash: L2BlockHash.schema.optional(),
|
|
55
|
-
blockNumber:
|
|
56
|
+
blockNumber: BlockNumberSchema.optional(),
|
|
56
57
|
transactionFee: schemas.BigInt.optional(),
|
|
57
58
|
})
|
|
58
59
|
.transform(TxReceipt.from);
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const L2BlockNumberSchema: z.ZodUnion<[z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>, z.ZodLiteral<"latest">]>;
|
|
3
|
-
/** Helper type for a specific L2 block number or the latest block number */
|
|
4
|
-
export type L2BlockNumber = z.infer<typeof L2BlockNumberSchema>;
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDJfYmxvY2tfbnVtYmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYmxvY2svbDJfYmxvY2tfbnVtYmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxDQUFDLEVBQUUsTUFBTSxLQUFLLENBQUM7QUFJeEIsZUFBTyxNQUFNLG1CQUFtQix1SEFBa0QsQ0FBQztBQUVuRiw0RUFBNEU7QUFDNUUsTUFBTSxNQUFNLGFBQWEsR0FBRyxDQUFDLENBQUMsS0FBSyxDQUFDLE9BQU8sbUJBQW1CLENBQUMsQ0FBQyJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"l2_block_number.d.ts","sourceRoot":"","sources":["../../src/block/l2_block_number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,mBAAmB,uHAAkD,CAAC;AAEnF,4EAA4E;AAC5E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import { schemas } from '../schemas/index.js';
|
|
4
|
-
|
|
5
|
-
export const L2BlockNumberSchema = z.union([schemas.Integer, z.literal('latest')]);
|
|
6
|
-
|
|
7
|
-
/** Helper type for a specific L2 block number or the latest block number */
|
|
8
|
-
export type L2BlockNumber = z.infer<typeof L2BlockNumberSchema>;
|