@aztec/stdlib 0.0.1-commit.2ed92850 → 0.0.1-commit.43c09e3f
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/block/block_hash.d.ts +16 -19
- package/dest/block/block_hash.d.ts.map +1 -1
- package/dest/block/block_hash.js +21 -34
- package/dest/block/block_parameter.d.ts +4 -4
- package/dest/block/block_parameter.d.ts.map +1 -1
- package/dest/block/block_parameter.js +2 -2
- package/dest/block/in_block.d.ts +9 -9
- package/dest/block/in_block.d.ts.map +1 -1
- package/dest/block/in_block.js +4 -4
- package/dest/block/l2_block.d.ts +3 -2
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +2 -3
- package/dest/block/l2_block_source.d.ts +5 -4
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/contract/contract_address.js +1 -1
- package/dest/contract/contract_class_id.d.ts +1 -1
- package/dest/contract/contract_class_id.js +1 -1
- package/dest/contract/private_function.js +1 -1
- package/dest/contract/private_function_membership_proof.d.ts +1 -1
- package/dest/contract/private_function_membership_proof.js +1 -1
- package/dest/database-version/database_version.d.ts +58 -0
- package/dest/database-version/database_version.d.ts.map +1 -0
- package/dest/database-version/database_version.js +69 -0
- package/dest/database-version/version_manager.d.ts +2 -50
- package/dest/database-version/version_manager.d.ts.map +1 -1
- package/dest/database-version/version_manager.js +1 -66
- package/dest/epoch-helpers/index.d.ts +3 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +4 -0
- package/dest/hash/hash.js +2 -2
- package/dest/hash/map_slot.d.ts +1 -1
- package/dest/hash/map_slot.d.ts.map +1 -1
- package/dest/hash/map_slot.js +4 -3
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +4 -3
- package/dest/interfaces/aztec-node-admin.d.ts +8 -2
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +3 -1
- package/dest/interfaces/aztec-node.d.ts +33 -54
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +6 -10
- package/dest/interfaces/block-builder.d.ts +10 -4
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +7 -0
- package/dest/interfaces/get_logs_response.d.ts +15 -8
- package/dest/interfaces/get_logs_response.d.ts.map +1 -1
- package/dest/interfaces/prover-broker.d.ts +16 -1
- package/dest/interfaces/prover-broker.d.ts.map +1 -1
- package/dest/interfaces/prover-broker.js +4 -1
- package/dest/interfaces/prover-client.d.ts +6 -1
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +5 -0
- package/dest/interfaces/proving-job.d.ts +34 -34
- package/dest/interfaces/validator.d.ts +34 -2
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/keys/derivation.d.ts +3 -3
- package/dest/keys/derivation.js +8 -8
- package/dest/keys/key_types.d.ts +1 -1
- package/dest/keys/utils.d.ts +1 -1
- package/dest/keys/utils.d.ts.map +1 -1
- package/dest/keys/utils.js +7 -3
- package/dest/l1-contracts/slash_factory.d.ts +1 -1
- package/dest/l1-contracts/slash_factory.d.ts.map +1 -1
- package/dest/l1-contracts/slash_factory.js +1 -0
- package/dest/logs/extended_public_log.d.ts +13 -7
- package/dest/logs/extended_public_log.d.ts.map +1 -1
- package/dest/logs/log_id.d.ts +17 -14
- package/dest/logs/log_id.d.ts.map +1 -1
- package/dest/logs/log_id.js +20 -17
- package/dest/logs/siloed_tag.d.ts +1 -1
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +4 -3
- package/dest/p2p/block_proposal.d.ts +10 -3
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts +10 -3
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/stats/stats.d.ts +1 -3
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/mocks.d.ts +6 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +4 -3
- package/dest/tx/block_header.d.ts +3 -3
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +3 -3
- package/dest/tx/in_tx.d.ts +3 -3
- package/dest/tx/indexed_tx_effect.d.ts +5 -5
- package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
- package/dest/tx/indexed_tx_effect.js +3 -2
- package/dest/tx/tx_receipt.d.ts +5 -5
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +2 -2
- package/package.json +22 -11
- package/src/block/block_hash.ts +25 -50
- package/src/block/block_parameter.ts +3 -3
- package/src/block/in_block.ts +5 -5
- package/src/block/l2_block.ts +3 -3
- package/src/block/l2_block_source.ts +4 -3
- package/src/contract/contract_address.ts +1 -1
- package/src/contract/contract_class_id.ts +1 -1
- package/src/contract/private_function.ts +1 -1
- package/src/contract/private_function_membership_proof.ts +1 -1
- package/src/database-version/database_version.ts +87 -0
- package/src/database-version/version_manager.ts +1 -77
- package/src/epoch-helpers/index.ts +9 -0
- package/src/hash/hash.ts +2 -2
- package/src/hash/map_slot.ts +3 -2
- package/src/interfaces/archiver.ts +4 -3
- package/src/interfaces/aztec-node-admin.ts +3 -2
- package/src/interfaces/aztec-node.ts +42 -93
- package/src/interfaces/block-builder.ts +12 -2
- package/src/interfaces/prover-broker.ts +22 -0
- package/src/interfaces/prover-client.ts +7 -0
- package/src/interfaces/validator.ts +1 -2
- package/src/keys/derivation.ts +8 -8
- package/src/keys/key_types.ts +1 -1
- package/src/keys/utils.ts +7 -3
- package/src/l1-contracts/slash_factory.ts +1 -0
- package/src/logs/log_id.ts +22 -18
- package/src/logs/siloed_tag.ts +3 -2
- package/src/p2p/block_proposal.ts +9 -2
- package/src/p2p/checkpoint_proposal.ts +9 -2
- package/src/stats/stats.ts +0 -2
- package/src/tests/mocks.ts +6 -4
- package/src/tx/block_header.ts +6 -6
- package/src/tx/indexed_tx_effect.ts +3 -2
- package/src/tx/tx_receipt.ts +4 -4
- package/dest/database-version/index.d.ts +0 -2
- package/dest/database-version/index.d.ts.map +0 -1
- package/dest/database-version/index.js +0 -1
- package/src/database-version/index.ts +0 -1
package/dest/tx/block_header.js
CHANGED
|
@@ -8,7 +8,7 @@ import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from
|
|
|
8
8
|
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
9
9
|
import { inspect } from 'util';
|
|
10
10
|
import { z } from 'zod';
|
|
11
|
-
import {
|
|
11
|
+
import { BlockHash } from '../block/block_hash.js';
|
|
12
12
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
13
13
|
import { GlobalVariables } from './global_variables.js';
|
|
14
14
|
import { StateReference } from './state_reference.js';
|
|
@@ -110,12 +110,12 @@ _computedKey = inspect.custom;
|
|
|
110
110
|
}
|
|
111
111
|
hash() {
|
|
112
112
|
if (!this._cachedHash) {
|
|
113
|
-
this._cachedHash = poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.
|
|
113
|
+
this._cachedHash = poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.BLOCK_HEADER_HASH).then((fr)=>new BlockHash(fr));
|
|
114
114
|
}
|
|
115
115
|
return this._cachedHash;
|
|
116
116
|
}
|
|
117
117
|
/** Manually set the hash for this block header if already computed */ setHash(hashed) {
|
|
118
|
-
this._cachedHash = Promise.resolve(
|
|
118
|
+
this._cachedHash = Promise.resolve(new BlockHash(hashed));
|
|
119
119
|
}
|
|
120
120
|
static random(overrides = {}) {
|
|
121
121
|
return BlockHeader.from({
|
package/dest/tx/in_tx.d.ts
CHANGED
|
@@ -7,15 +7,15 @@ export type InTx = InBlock & {
|
|
|
7
7
|
export declare function randomInTx(): InTx;
|
|
8
8
|
export declare function inTxSchema(): z.ZodIntersection<z.ZodObject<{
|
|
9
9
|
l2BlockNumber: z.ZodEffects<z.ZodPipeline<z.ZodUnion<[z.ZodNumber, z.ZodBigInt, z.ZodString]>, z.ZodNumber>, import("@aztec/foundation/branded-types").BlockNumber, string | number | bigint>;
|
|
10
|
-
l2BlockHash:
|
|
10
|
+
l2BlockHash: import("@aztec/foundation/schemas").ZodFor<import("../block/block_hash.js").BlockHash>;
|
|
11
11
|
}, "strip", z.ZodTypeAny, {
|
|
12
12
|
l2BlockNumber: number & {
|
|
13
13
|
_branding: "BlockNumber";
|
|
14
14
|
};
|
|
15
|
-
l2BlockHash: import("../block/block_hash.js").
|
|
15
|
+
l2BlockHash: import("../block/block_hash.js").BlockHash;
|
|
16
16
|
}, {
|
|
17
17
|
l2BlockNumber: string | number | bigint;
|
|
18
|
-
l2BlockHash
|
|
18
|
+
l2BlockHash?: any;
|
|
19
19
|
}>, z.ZodObject<{
|
|
20
20
|
txHash: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, Buffer<ArrayBuffer>, string>, TxHash, string>;
|
|
21
21
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import {
|
|
2
|
+
import { BlockHash } from '../block/block_hash.js';
|
|
3
3
|
import { type DataInBlock } from '../block/in_block.js';
|
|
4
4
|
import { TxEffect } from './tx_effect.js';
|
|
5
5
|
export type IndexedTxEffect = DataInBlock<TxEffect> & {
|
|
@@ -7,7 +7,7 @@ export type IndexedTxEffect = DataInBlock<TxEffect> & {
|
|
|
7
7
|
};
|
|
8
8
|
export declare function indexedTxSchema(): import("zod").ZodObject<{
|
|
9
9
|
l2BlockNumber: import("zod").ZodEffects<import("zod").ZodPipeline<import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodBigInt, import("zod").ZodString]>, import("zod").ZodNumber>, BlockNumber, string | number | bigint>;
|
|
10
|
-
l2BlockHash: import("
|
|
10
|
+
l2BlockHash: import("@aztec/foundation/schemas").ZodFor<BlockHash>;
|
|
11
11
|
} & {
|
|
12
12
|
data: import("@aztec/foundation/schemas").ZodFor<TxEffect>;
|
|
13
13
|
} & {
|
|
@@ -16,16 +16,16 @@ export declare function indexedTxSchema(): import("zod").ZodObject<{
|
|
|
16
16
|
l2BlockNumber: number & {
|
|
17
17
|
_branding: "BlockNumber";
|
|
18
18
|
};
|
|
19
|
-
l2BlockHash:
|
|
19
|
+
l2BlockHash: BlockHash;
|
|
20
20
|
data: TxEffect;
|
|
21
21
|
txIndexInBlock: number;
|
|
22
22
|
}, {
|
|
23
23
|
l2BlockNumber: string | number | bigint;
|
|
24
|
-
l2BlockHash
|
|
24
|
+
l2BlockHash?: any;
|
|
25
25
|
data?: any;
|
|
26
26
|
txIndexInBlock: string | number | bigint;
|
|
27
27
|
}>;
|
|
28
28
|
export declare function randomIndexedTxEffect(): Promise<IndexedTxEffect>;
|
|
29
29
|
export declare function serializeIndexedTxEffect(effect: IndexedTxEffect): Buffer;
|
|
30
30
|
export declare function deserializeIndexedTxEffect(buffer: Buffer): IndexedTxEffect;
|
|
31
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXhlZF90eF9lZmZlY3QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eC9pbmRleGVkX3R4X2VmZmVjdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFLOUQsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ25ELE9BQU8sRUFBRSxLQUFLLFdBQVcsRUFBMkMsTUFBTSxzQkFBc0IsQ0FBQztBQUNqRyxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFFMUMsTUFBTSxNQUFNLGVBQWUsR0FBRyxXQUFXLENBQUMsUUFBUSxDQUFDLEdBQUc7SUFBRSxjQUFjLEVBQUUsTUFBTSxDQUFBO0NBQUUsQ0FBQztBQUVqRix3QkFBZ0IsZUFBZTs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQUU5QjtBQUVELHdCQUFzQixxQkFBcUIsSUFBSSxPQUFPLENBQUMsZUFBZSxDQUFDLENBS3RFO0FBRUQsd0JBQWdCLHdCQUF3QixDQUFDLE1BQU0sRUFBRSxlQUFlLEdBQUcsTUFBTSxDQUV4RTtBQUVELHdCQUFnQiwwQkFBMEIsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLGVBQWUsQ0FjMUUifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexed_tx_effect.d.ts","sourceRoot":"","sources":["../../src/tx/indexed_tx_effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"indexed_tx_effect.d.ts","sourceRoot":"","sources":["../../src/tx/indexed_tx_effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAK9D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,KAAK,WAAW,EAA2C,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF,wBAAgB,eAAe;;;;;;;;;;;;;;;;;;;GAE9B;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,eAAe,CAAC,CAKtE;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAExE;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAc1E"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { schemas } from '@aztec/foundation/schemas';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
-
import {
|
|
5
|
+
import { BlockHash } from '../block/block_hash.js';
|
|
5
6
|
import { dataInBlockSchemaFor, randomDataInBlock } from '../block/in_block.js';
|
|
6
7
|
import { TxEffect } from './tx_effect.js';
|
|
7
8
|
export function indexedTxSchema() {
|
|
@@ -22,7 +23,7 @@ export function serializeIndexedTxEffect(effect) {
|
|
|
22
23
|
}
|
|
23
24
|
export function deserializeIndexedTxEffect(buffer) {
|
|
24
25
|
const reader = BufferReader.asReader(buffer);
|
|
25
|
-
const l2BlockHash = reader.readObject(
|
|
26
|
+
const l2BlockHash = new BlockHash(reader.readObject(Fr));
|
|
26
27
|
const l2BlockNumber = BlockNumber(reader.readNumber());
|
|
27
28
|
const txIndexInBlock = reader.readNumber();
|
|
28
29
|
const data = reader.readObject(TxEffect);
|
package/dest/tx/tx_receipt.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { RevertCode } from '../avm/revert_code.js';
|
|
3
|
-
import {
|
|
3
|
+
import { BlockHash } from '../block/block_hash.js';
|
|
4
4
|
import { type ZodFor } from '../schemas/schemas.js';
|
|
5
5
|
import { TxHash } from './tx_hash.js';
|
|
6
6
|
/** Block inclusion/finalization status. */
|
|
@@ -39,7 +39,7 @@ export declare class TxReceipt {
|
|
|
39
39
|
/** The transaction fee paid for the transaction. */
|
|
40
40
|
transactionFee?: bigint | undefined;
|
|
41
41
|
/** The hash of the block containing the transaction. */
|
|
42
|
-
blockHash?:
|
|
42
|
+
blockHash?: BlockHash | undefined;
|
|
43
43
|
/** The block number in which the transaction was included. */
|
|
44
44
|
blockNumber?: BlockNumber | undefined;
|
|
45
45
|
constructor(
|
|
@@ -54,7 +54,7 @@ export declare class TxReceipt {
|
|
|
54
54
|
/** The transaction fee paid for the transaction. */
|
|
55
55
|
transactionFee?: bigint | undefined,
|
|
56
56
|
/** The hash of the block containing the transaction. */
|
|
57
|
-
blockHash?:
|
|
57
|
+
blockHash?: BlockHash | undefined,
|
|
58
58
|
/** The block number in which the transaction was included. */
|
|
59
59
|
blockNumber?: BlockNumber | undefined);
|
|
60
60
|
/** Returns true if the transaction was executed successfully. */
|
|
@@ -75,9 +75,9 @@ export declare class TxReceipt {
|
|
|
75
75
|
executionResult?: TxExecutionResult;
|
|
76
76
|
error?: string;
|
|
77
77
|
transactionFee?: bigint;
|
|
78
|
-
blockHash?:
|
|
78
|
+
blockHash?: BlockHash;
|
|
79
79
|
blockNumber?: BlockNumber;
|
|
80
80
|
}): TxReceipt;
|
|
81
81
|
static executionResultFromRevertCode(revertCode: RevertCode): TxExecutionResult;
|
|
82
82
|
}
|
|
83
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
83
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfcmVjZWlwdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R4L3R4X3JlY2VpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBcUIsTUFBTSxpQ0FBaUMsQ0FBQztBQUlqRixPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ25ELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBVyxNQUFNL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IACvB,+EAA+E;IACxE,eAAe,EAAE,iBAAiB,GAAG,SAAS;IACrD,gDAAgD;IACzC,KAAK,EAAE,MAAM,GAAG,SAAS;IAChC,oDAAoD;IAC7C,cAAc,CAAC,oBAAQ;IAC9B,wDAAwD;IACjD,SAAS,CAAC,uBAAW;IAC5B,8DAA8D;IACvD,WAAW,CAAC,yBAAa,EAC9B;IAEJ,iEAAiE;IACjE,qBAAqB,IAAI,OAAO,CAE/B;IAED,0DAA0D;IAC1D,oBAAoB,IAAI,OAAO,CAE9B;IAED,mHAAmH;IACnH,OAAO,IAAI,OAAO,CAOjB;IAED,kDAAkD;IAClD,SAAS,IAAI,OAAO,CAEnB;IAED,mDAAmD;IACnD,SAAS,IAAI,OAAO,CAEnB;IAED,MAAM,CAAC,KAAK,cAEX;IAED,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,CAYrC;IAED,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,QAAQ,CAAC;QACjB,eAAe,CAAC,EAAE,iBAAiB,CAAC;QACpC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,WAAW,CAAC,EAAE,WAAW,CAAC;KAC3B,aAUA;IAED,OAAc,6BAA6B,CAAC,UAAU,EAAE,UAAU,GAAG,iBAAiB,CAYrF;CACF"}
|
package/dest/tx/tx_receipt.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { RevertCode } from '../avm/revert_code.js';
|
|
4
|
-
import {
|
|
4
|
+
import { BlockHash } from '../block/block_hash.js';
|
|
5
5
|
import { schemas } from '../schemas/schemas.js';
|
|
6
6
|
import { TxHash } from './tx_hash.js';
|
|
7
7
|
/** Block inclusion/finalization status. */ export var TxStatus = /*#__PURE__*/ function(TxStatus) {
|
|
@@ -74,7 +74,7 @@ import { TxHash } from './tx_hash.js';
|
|
|
74
74
|
status: z.nativeEnum(TxStatus),
|
|
75
75
|
executionResult: z.nativeEnum(TxExecutionResult).optional(),
|
|
76
76
|
error: z.string().optional(),
|
|
77
|
-
blockHash:
|
|
77
|
+
blockHash: BlockHash.schema.optional(),
|
|
78
78
|
blockNumber: BlockNumberSchema.optional(),
|
|
79
79
|
transactionFee: schemas.BigInt.optional()
|
|
80
80
|
}).transform((fields)=>TxReceipt.from(fields));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.43c09e3f",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
"./epoch-helpers": "./dest/epoch-helpers/index.js",
|
|
53
53
|
"./config": "./dest/config/index.js",
|
|
54
54
|
"./testing/jest": "./dest/tests/jest.js",
|
|
55
|
-
"./database-version": "./dest/database-version/
|
|
55
|
+
"./database-version/version": "./dest/database-version/database_version.js",
|
|
56
|
+
"./database-version/manager": "./dest/database-version/version_manager.js",
|
|
56
57
|
"./validators": "./dest/validators/index.js",
|
|
57
58
|
"./file-store": "./dest/file-store/index.js",
|
|
58
59
|
"./snapshots": "./dest/snapshots/index.js",
|
|
@@ -64,7 +65,17 @@
|
|
|
64
65
|
},
|
|
65
66
|
"typedocOptions": {
|
|
66
67
|
"entryPoints": [
|
|
67
|
-
"./src/index.ts"
|
|
68
|
+
"./src/abi/index.ts",
|
|
69
|
+
"./src/aztec-address/index.ts",
|
|
70
|
+
"./src/block/index.ts",
|
|
71
|
+
"./src/contract/index.ts",
|
|
72
|
+
"./src/gas/index.ts",
|
|
73
|
+
"./src/hash/index.ts",
|
|
74
|
+
"./src/keys/index.ts",
|
|
75
|
+
"./src/logs/index.ts",
|
|
76
|
+
"./src/note/index.ts",
|
|
77
|
+
"./src/proofs/index.ts",
|
|
78
|
+
"./src/tx/index.ts"
|
|
68
79
|
],
|
|
69
80
|
"name": "stdlib",
|
|
70
81
|
"tsconfig": "./tsconfig.json"
|
|
@@ -78,14 +89,14 @@
|
|
|
78
89
|
},
|
|
79
90
|
"dependencies": {
|
|
80
91
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
81
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
82
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
83
|
-
"@aztec/constants": "0.0.1-commit.
|
|
84
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
85
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
86
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
87
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
88
|
-
"@aztec/validator-ha-signer": "0.0.1-commit.
|
|
92
|
+
"@aztec/bb.js": "0.0.1-commit.43c09e3f",
|
|
93
|
+
"@aztec/blob-lib": "0.0.1-commit.43c09e3f",
|
|
94
|
+
"@aztec/constants": "0.0.1-commit.43c09e3f",
|
|
95
|
+
"@aztec/ethereum": "0.0.1-commit.43c09e3f",
|
|
96
|
+
"@aztec/foundation": "0.0.1-commit.43c09e3f",
|
|
97
|
+
"@aztec/l1-artifacts": "0.0.1-commit.43c09e3f",
|
|
98
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.43c09e3f",
|
|
99
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.43c09e3f",
|
|
89
100
|
"@google-cloud/storage": "^7.15.0",
|
|
90
101
|
"axios": "^1.12.0",
|
|
91
102
|
"json-stringify-deterministic": "1.0.12",
|
package/src/block/block_hash.ts
CHANGED
|
@@ -1,70 +1,45 @@
|
|
|
1
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import {
|
|
2
|
+
import type { ZodFor } from '@aztec/foundation/schemas';
|
|
4
3
|
|
|
5
|
-
import {
|
|
4
|
+
import { inspect } from 'util';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
export class L2BlockHash extends Buffer32 {
|
|
9
|
-
constructor(
|
|
10
|
-
/** The buffer containing the hash. */
|
|
11
|
-
hash: Buffer,
|
|
12
|
-
) {
|
|
13
|
-
super(hash);
|
|
14
|
-
}
|
|
6
|
+
import { hexSchemaFor } from '../schemas/schemas.js';
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
* Type guard that checks if a value is an L2BlockHash instance.
|
|
18
|
-
* Uses duck typing to handle cases where instanceof fails due to module duplication.
|
|
19
|
-
* Checks for Buffer32-like structure with a 32-byte buffer.
|
|
20
|
-
*/
|
|
21
|
-
static isL2BlockHash(value: unknown): value is L2BlockHash {
|
|
22
|
-
if (value instanceof L2BlockHash) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
// Duck typing fallback: check if it looks like a Buffer32 with a 32-byte buffer
|
|
26
|
-
// This helps when instanceof fails due to module duplication
|
|
27
|
-
return (
|
|
28
|
-
typeof value === 'object' &&
|
|
29
|
-
value !== null &&
|
|
30
|
-
'buffer' in value &&
|
|
31
|
-
Buffer.isBuffer((value as Buffer32).buffer) &&
|
|
32
|
-
(value as Buffer32).buffer.length === 32 &&
|
|
33
|
-
'toBuffer' in value &&
|
|
34
|
-
typeof (value as Buffer32).toBuffer === 'function'
|
|
35
|
-
);
|
|
36
|
-
}
|
|
8
|
+
const BLOCK_HASH_BRAND = Symbol.for('aztec.BlockHash');
|
|
37
9
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
10
|
+
/** Hash of an L2 block. */
|
|
11
|
+
export class BlockHash extends Fr {
|
|
12
|
+
readonly [BLOCK_HASH_BRAND] = true as const;
|
|
41
13
|
|
|
42
|
-
|
|
43
|
-
|
|
14
|
+
constructor(hash: Fr) {
|
|
15
|
+
super(hash);
|
|
44
16
|
}
|
|
45
17
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return new L2BlockHash(reader.readBytes(L2BlockHash.SIZE));
|
|
18
|
+
override [inspect.custom]() {
|
|
19
|
+
return `BlockHash<${this.toString()}>`;
|
|
49
20
|
}
|
|
50
21
|
|
|
51
|
-
|
|
52
|
-
return new
|
|
22
|
+
toFr(): Fr {
|
|
23
|
+
return new Fr(this.toBigInt());
|
|
53
24
|
}
|
|
54
25
|
|
|
55
|
-
|
|
56
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Type guard that checks if a value is a BlockHash instance.
|
|
28
|
+
* Uses Symbol.for to ensure cross-module compatibility.
|
|
29
|
+
*/
|
|
30
|
+
static isBlockHash(value: unknown): value is BlockHash {
|
|
31
|
+
return typeof value === 'object' && value !== null && BLOCK_HASH_BRAND in value;
|
|
57
32
|
}
|
|
58
33
|
|
|
59
|
-
static
|
|
60
|
-
return new
|
|
34
|
+
static override random() {
|
|
35
|
+
return new BlockHash(Fr.random());
|
|
61
36
|
}
|
|
62
37
|
|
|
63
|
-
static override
|
|
64
|
-
return new
|
|
38
|
+
static override fromString(str: string): BlockHash {
|
|
39
|
+
return new BlockHash(Fr.fromString(str));
|
|
65
40
|
}
|
|
66
41
|
|
|
67
|
-
|
|
68
|
-
return
|
|
42
|
+
static override get schema() {
|
|
43
|
+
return hexSchemaFor(BlockHash) as ZodFor<BlockHash>;
|
|
69
44
|
}
|
|
70
45
|
}
|
|
@@ -2,9 +2,9 @@ import { BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { BlockHash } from './block_hash.js';
|
|
6
6
|
|
|
7
|
-
export const BlockParameterSchema = z.union([
|
|
7
|
+
export const BlockParameterSchema = z.union([BlockHash.schema, BlockNumberSchema, z.literal('latest')]);
|
|
8
8
|
|
|
9
|
-
/** Block parameter - either a specific BlockNumber, block hash (
|
|
9
|
+
/** Block parameter - either a specific BlockNumber, block hash (BlockHash), or 'latest' */
|
|
10
10
|
export type BlockParameter = z.infer<typeof BlockParameterSchema>;
|
package/src/block/in_block.ts
CHANGED
|
@@ -2,12 +2,12 @@ import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types'
|
|
|
2
2
|
|
|
3
3
|
import { type ZodTypeAny, z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { BlockHash } from './block_hash.js';
|
|
6
6
|
import type { L2Block } from './l2_block.js';
|
|
7
7
|
|
|
8
8
|
export type InBlock = {
|
|
9
9
|
l2BlockNumber: BlockNumber;
|
|
10
|
-
l2BlockHash:
|
|
10
|
+
l2BlockHash: BlockHash;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// Note: If you expand this type with indexInBlock, then delete `IndexedTxEffect` and use this type instead.
|
|
@@ -18,7 +18,7 @@ export type DataInBlock<T> = {
|
|
|
18
18
|
export function randomInBlock(): InBlock {
|
|
19
19
|
return {
|
|
20
20
|
l2BlockNumber: BlockNumber(Math.floor(Math.random() * 1000)),
|
|
21
|
-
l2BlockHash:
|
|
21
|
+
l2BlockHash: BlockHash.random(),
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -33,14 +33,14 @@ export async function wrapDataInBlock<T>(data: T, block: L2Block): Promise<DataI
|
|
|
33
33
|
return {
|
|
34
34
|
data,
|
|
35
35
|
l2BlockNumber: block.number,
|
|
36
|
-
l2BlockHash:
|
|
36
|
+
l2BlockHash: await block.hash(),
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export function inBlockSchema() {
|
|
41
41
|
return z.object({
|
|
42
42
|
l2BlockNumber: BlockNumberSchema,
|
|
43
|
-
l2BlockHash:
|
|
43
|
+
l2BlockHash: BlockHash.schema,
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
|
package/src/block/l2_block.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { z } from 'zod';
|
|
|
15
15
|
import type { PrivateLog } from '../logs/private_log.js';
|
|
16
16
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
17
17
|
import { BlockHeader } from '../tx/block_header.js';
|
|
18
|
+
import type { BlockHash } from './block_hash.js';
|
|
18
19
|
import { Body } from './body.js';
|
|
19
20
|
import type { L2BlockInfo } from './l2_block_info.js';
|
|
20
21
|
|
|
@@ -89,9 +90,8 @@ export class L2Block {
|
|
|
89
90
|
* Returns the block's hash (hash of block header).
|
|
90
91
|
* @returns The block's hash.
|
|
91
92
|
*/
|
|
92
|
-
public
|
|
93
|
-
|
|
94
|
-
return blockHash.toField();
|
|
93
|
+
public hash(): Promise<BlockHash> {
|
|
94
|
+
return this.header.hash();
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
@@ -20,6 +20,7 @@ import type { BlockHeader } from '../tx/block_header.js';
|
|
|
20
20
|
import type { IndexedTxEffect } from '../tx/indexed_tx_effect.js';
|
|
21
21
|
import type { TxHash } from '../tx/tx_hash.js';
|
|
22
22
|
import type { TxReceipt } from '../tx/tx_receipt.js';
|
|
23
|
+
import type { BlockHash } from './block_hash.js';
|
|
23
24
|
import type { CheckpointedL2Block } from './checkpointed_l2_block.js';
|
|
24
25
|
import type { L2Block } from './l2_block.js';
|
|
25
26
|
import type { ValidateCheckpointNegativeResult, ValidateCheckpointResult } from './validate_block_result.js';
|
|
@@ -102,7 +103,7 @@ export interface L2BlockSource {
|
|
|
102
103
|
* @param blockHash - The block hash to retrieve.
|
|
103
104
|
* @returns The requested block header (or undefined if not found).
|
|
104
105
|
*/
|
|
105
|
-
getBlockHeaderByHash(blockHash:
|
|
106
|
+
getBlockHeaderByHash(blockHash: BlockHash): Promise<BlockHeader | undefined>;
|
|
106
107
|
|
|
107
108
|
/**
|
|
108
109
|
* Gets a block header by its archive root.
|
|
@@ -123,7 +124,7 @@ export interface L2BlockSource {
|
|
|
123
124
|
* @param blockHash - The block hash to retrieve.
|
|
124
125
|
* @returns The requested L2 block (or undefined if not found).
|
|
125
126
|
*/
|
|
126
|
-
getL2BlockByHash(blockHash:
|
|
127
|
+
getL2BlockByHash(blockHash: BlockHash): Promise<L2Block | undefined>;
|
|
127
128
|
|
|
128
129
|
/**
|
|
129
130
|
* Gets an L2 block by its archive root.
|
|
@@ -228,7 +229,7 @@ export interface L2BlockSource {
|
|
|
228
229
|
* @param blockHash - The block hash to retrieve.
|
|
229
230
|
* @returns The requested block (or undefined if not found).
|
|
230
231
|
*/
|
|
231
|
-
getCheckpointedBlockByHash(blockHash:
|
|
232
|
+
getCheckpointedBlockByHash(blockHash: BlockHash): Promise<CheckpointedL2Block | undefined>;
|
|
232
233
|
|
|
233
234
|
/**
|
|
234
235
|
* Gets a checkpointed block by its archive root.
|
|
@@ -87,5 +87,5 @@ export async function computeInitializationHashFromEncodedArgs(
|
|
|
87
87
|
encodedArgs: Fr[],
|
|
88
88
|
): Promise<Fr> {
|
|
89
89
|
const argsHash = await computeVarArgsHash(encodedArgs);
|
|
90
|
-
return poseidon2HashWithSeparator([initFn, argsHash], GeneratorIndex.
|
|
90
|
+
return poseidon2HashWithSeparator([initFn, argsHash], GeneratorIndex.INITIALIZER);
|
|
91
91
|
}
|
|
@@ -13,7 +13,7 @@ import { computePrivateFunctionsRoot } from './private_function.js';
|
|
|
13
13
|
*
|
|
14
14
|
* ```
|
|
15
15
|
* version = 1
|
|
16
|
-
* private_function_leaves = private_functions.map(fn => pedersen([fn.function_selector as Field, fn.vk_hash],
|
|
16
|
+
* private_function_leaves = private_functions.map(fn => pedersen([fn.function_selector as Field, fn.vk_hash], GENERATOR__PRIVATE_FUNCTION_LEAF))
|
|
17
17
|
* private_functions_root = merkleize(private_function_leaves)
|
|
18
18
|
* bytecode_commitment = calculate_commitment(packed_bytecode)
|
|
19
19
|
* contract_class_id = pedersen([version, artifact_hash, private_functions_root, bytecode_commitment], GENERATOR__CLASS_IDENTIFIER)
|
|
@@ -31,7 +31,7 @@ function computePrivateFunctionLeaves(fns: PrivateFunction[]): Promise<Buffer[]>
|
|
|
31
31
|
|
|
32
32
|
/** Returns the leaf for a given private function. */
|
|
33
33
|
export async function computePrivateFunctionLeaf(fn: PrivateFunction): Promise<Buffer> {
|
|
34
|
-
return (await poseidon2HashWithSeparator([fn.selector, fn.vkHash], GeneratorIndex.
|
|
34
|
+
return (await poseidon2HashWithSeparator([fn.selector, fn.vkHash], GeneratorIndex.PRIVATE_FUNCTION_LEAF)).toBuffer();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
async function getPrivateFunctionTreeCalculator(): Promise<MerkleTreeCalculator> {
|
|
@@ -99,7 +99,7 @@ export async function createPrivateFunctionMembershipProof(
|
|
|
99
99
|
* contract_class = db.get_contract_class(contract_class_id)
|
|
100
100
|
*
|
|
101
101
|
* // Compute function leaf and assert it belongs to the private functions tree
|
|
102
|
-
* function_leaf = pedersen([selector as Field, vk_hash],
|
|
102
|
+
* function_leaf = pedersen([selector as Field, vk_hash], GENERATOR__PRIVATE_FUNCTION_LEAF)
|
|
103
103
|
* computed_private_function_tree_root = compute_root(function_leaf, private_function_tree_sibling_path)
|
|
104
104
|
* assert computed_private_function_tree_root == contract_class.private_functions_root
|
|
105
105
|
*
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
|
+
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Symbol for Node.js custom inspect. Using Symbol.for() is the documented way to
|
|
8
|
+
* reference this without importing node:util. In browsers, objects with this symbol
|
|
9
|
+
* simply won't have custom inspect behavior (which is fine).
|
|
10
|
+
* @see https://nodejs.org/api/util.html#utilinspectcustom
|
|
11
|
+
*/
|
|
12
|
+
const inspectCustomSymbol = Symbol.for('nodejs.util.inspect.custom');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents a version record for storing in a version file.
|
|
16
|
+
*/
|
|
17
|
+
export class DatabaseVersion {
|
|
18
|
+
constructor(
|
|
19
|
+
/** The version of the data on disk. Used to perform upgrades */
|
|
20
|
+
public readonly schemaVersion: number,
|
|
21
|
+
/** The rollup the data pertains to */
|
|
22
|
+
public readonly rollupAddress: EthAddress,
|
|
23
|
+
) {}
|
|
24
|
+
|
|
25
|
+
public toBuffer(): Buffer {
|
|
26
|
+
return Buffer.from(jsonStringify(this));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static fromBuffer(buf: Buffer): DatabaseVersion {
|
|
30
|
+
try {
|
|
31
|
+
return jsonParseWithSchema(buf.toString('utf-8'), DatabaseVersion.schema);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
throw new Error(`Failed to deserialize version information: ${err}`, { cause: err });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Compares two versions. If the rollups addresses are different then it returns undefined
|
|
39
|
+
*/
|
|
40
|
+
public cmp(other: DatabaseVersion): undefined | -1 | 0 | 1 {
|
|
41
|
+
if (this.rollupAddress.equals(other.rollupAddress)) {
|
|
42
|
+
if (this.schemaVersion < other.schemaVersion) {
|
|
43
|
+
return -1;
|
|
44
|
+
} else if (this.schemaVersion > other.schemaVersion) {
|
|
45
|
+
return 1;
|
|
46
|
+
} else {
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Checks if two versions exactly match
|
|
55
|
+
*/
|
|
56
|
+
public equals(other: DatabaseVersion): boolean {
|
|
57
|
+
return this.cmp(other) === 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns the schema for this class
|
|
62
|
+
*/
|
|
63
|
+
static get schema() {
|
|
64
|
+
return z
|
|
65
|
+
.object({
|
|
66
|
+
schemaVersion: z.number(),
|
|
67
|
+
rollupAddress: EthAddress.schema,
|
|
68
|
+
})
|
|
69
|
+
.transform(({ schemaVersion, rollupAddress }) => new DatabaseVersion(schemaVersion, rollupAddress));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Allows for better introspection in Node.js console. Ignored in browser envs. */
|
|
73
|
+
public [inspectCustomSymbol](): string {
|
|
74
|
+
return this.toString();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public toString(): string {
|
|
78
|
+
return `DatabaseVersion{schemaVersion=${this.schemaVersion},rollupAddress=${this.rollupAddress}"}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns an empty instance
|
|
83
|
+
*/
|
|
84
|
+
static empty() {
|
|
85
|
+
return new DatabaseVersion(0, EthAddress.ZERO);
|
|
86
|
+
}
|
|
87
|
+
}
|