@aztec/foundation 0.0.1-commit.f5d02921e → 0.0.1-commit.f7ea82942
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/branded-types/buffer32_hash.d.ts +24 -0
- package/dest/branded-types/buffer32_hash.d.ts.map +1 -0
- package/dest/branded-types/buffer32_hash.js +19 -0
- package/dest/branded-types/checkpoint_number.d.ts +4 -1
- package/dest/branded-types/checkpoint_number.d.ts.map +1 -1
- package/dest/branded-types/checkpoint_number.js +3 -0
- package/dest/branded-types/index.d.ts +2 -1
- package/dest/branded-types/index.d.ts.map +1 -1
- package/dest/branded-types/index.js +1 -0
- package/dest/buffer/buffer16.d.ts +3 -3
- package/dest/buffer/buffer16.d.ts.map +1 -1
- package/dest/buffer/buffer32.d.ts +28 -63
- package/dest/buffer/buffer32.d.ts.map +1 -1
- package/dest/buffer/buffer32.js +26 -60
- package/dest/config/env_var.d.ts +2 -2
- package/dest/config/env_var.d.ts.map +1 -1
- package/dest/config/index.d.ts +48 -30
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +21 -30
- package/dest/crypto/aes128/index.d.ts +2 -1
- package/dest/crypto/aes128/index.d.ts.map +1 -1
- package/dest/crypto/aes128/index.js +11 -2
- package/dest/crypto/bls/bn254_keystore.d.ts +1 -10
- package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -1
- package/dest/crypto/bls/bn254_keystore.js +0 -17
- package/dest/curves/bls12/field.d.ts +1 -1
- package/dest/curves/bls12/field.d.ts.map +1 -1
- package/dest/curves/bls12/field.js +0 -5
- package/dest/curves/bn254/field.d.ts +17 -16
- package/dest/curves/bn254/field.d.ts.map +1 -1
- package/dest/curves/bn254/field.js +18 -13
- package/dest/curves/grumpkin/point.d.ts +4 -4
- package/dest/curves/grumpkin/point.d.ts.map +1 -1
- package/dest/curves/grumpkin/point.js +7 -4
- package/dest/eth-address/index.d.ts +1 -1
- package/dest/eth-address/index.d.ts.map +1 -1
- package/dest/eth-address/index.js +0 -3
- package/dest/json-rpc/client/fetch.d.ts +1 -1
- package/dest/json-rpc/client/fetch.d.ts.map +1 -1
- package/dest/json-rpc/client/fetch.js +4 -3
- package/dest/json-rpc/client/undici.d.ts +1 -1
- package/dest/json-rpc/client/undici.d.ts.map +1 -1
- package/dest/json-rpc/client/undici.js +5 -3
- package/dest/log/pino-logger.js +15 -1
- package/dest/queue/batch_queue.d.ts +1 -1
- package/dest/queue/batch_queue.d.ts.map +1 -1
- package/dest/queue/batch_queue.js +1 -0
- package/dest/retry/index.d.ts +12 -1
- package/dest/retry/index.d.ts.map +1 -1
- package/dest/retry/index.js +21 -0
- package/dest/string/index.js +1 -1
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts +11 -2
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +1 -1
- package/dest/transport/index.d.ts +1 -2
- package/dest/transport/index.d.ts.map +1 -1
- package/dest/transport/index.js +0 -1
- package/dest/trees/balanced_merkle_tree_root.d.ts +2 -3
- package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -1
- package/dest/trees/balanced_merkle_tree_root.js +2 -3
- package/dest/trees/hasher.d.ts +3 -2
- package/dest/trees/hasher.d.ts.map +1 -1
- package/dest/trees/hasher.js +5 -5
- package/dest/trees/merkle_tree_calculator.d.ts +4 -2
- package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.js +1 -5
- package/dest/trees/sibling_path.d.ts +2 -2
- package/dest/trees/sibling_path.d.ts.map +1 -1
- package/dest/trees/sibling_path.js +1 -5
- package/dest/trees/unbalanced_merkle_tree_root.d.ts +2 -3
- package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree_root.js +2 -3
- package/package.json +2 -2
- package/src/branded-types/buffer32_hash.ts +42 -0
- package/src/branded-types/checkpoint_number.ts +5 -0
- package/src/branded-types/index.ts +1 -0
- package/src/buffer/buffer16.ts +2 -2
- package/src/buffer/buffer32.ts +36 -68
- package/src/config/env_var.ts +4 -5
- package/src/config/index.ts +96 -84
- package/src/crypto/aes128/index.ts +11 -2
- package/src/crypto/bls/bn254_keystore.ts +0 -23
- package/src/curves/bls12/field.ts +0 -7
- package/src/curves/bn254/field.ts +25 -31
- package/src/curves/grumpkin/point.ts +6 -3
- package/src/eth-address/index.ts +0 -4
- package/src/json-rpc/client/fetch.ts +4 -3
- package/src/json-rpc/client/undici.ts +5 -3
- package/src/log/pino-logger.ts +16 -1
- package/src/queue/batch_queue.ts +1 -0
- package/src/retry/index.ts +30 -0
- package/src/string/index.ts +1 -1
- package/src/transport/dispatch/create_dispatch_proxy.ts +11 -1
- package/src/transport/index.ts +0 -1
- package/src/trees/balanced_merkle_tree_root.ts +2 -5
- package/src/trees/hasher.ts +6 -3
- package/src/trees/merkle_tree_calculator.ts +4 -10
- package/src/trees/sibling_path.ts +1 -2
- package/src/trees/unbalanced_merkle_tree_root.ts +2 -5
- package/dest/transport/dispatch/create_dispatch_fn.d.ts +0 -25
- package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +0 -1
- package/dest/transport/dispatch/create_dispatch_fn.js +0 -17
- package/src/transport/dispatch/create_dispatch_fn.ts +0 -35
|
@@ -93,5 +93,5 @@ export declare class SiblingPath<N extends number> {
|
|
|
93
93
|
getSubtreeSiblingPath<SubtreeHeight extends number, SubtreeSiblingPathHeight extends number>(subtreeHeight: SubtreeHeight): SiblingPath<SubtreeSiblingPathHeight>;
|
|
94
94
|
}
|
|
95
95
|
/** Computes the expected root of a merkle tree given a leaf and its sibling path. */
|
|
96
|
-
export declare function computeRootFromSiblingPath(leaf: Buffer, siblingPath: Buffer[], index: number, hasher
|
|
97
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
96
|
+
export declare function computeRootFromSiblingPath(leaf: Buffer, siblingPath: Buffer[], index: number, hasher: (left: Buffer, right: Buffer) => Promise<Buffer>): Promise<Buffer<ArrayBufferLike>>;
|
|
97
|
+
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VBQ3JCLEtBQUssRUFBRSxNQUFNLEVBQ2IsTUFBTSxFQUFFLENBQUMsSUFBSSxFQUFFLE1BQU0sRUFBRSxLQUFLLEVBQUUsTUFBTSxLQUFLLE9BQU8sQ0FBQyxNQUFNLENBQUMsb0NBUXpEIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sibling_path.d.ts","sourceRoot":"","sources":["../../src/trees/sibling_path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sibling_path.d.ts","sourceRoot":"","sources":["../../src/trees/sibling_path.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EACL,KAAK,KAAK,EAIX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;GASG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,MAAM;IASrC,+DAA+D;IACxD,QAAQ,EAAE,CAAC;IATpB,OAAO,CAAC,IAAI,CAAmB;IAE/B;;;;OAIG;IACH;IACE,+DAA+D;IACxD,QAAQ,EAAE,CAAC;IAClB,6BAA6B;IAC7B,IAAI,EAAE,MAAM,EAAE,EAGf;IAED,MAAM,KAAK,MAAM,sHAEhB;IAED,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,+JAKzC;IAED,MAAM,4BAEL;IAED;;;;;;OAMG;IACH,OAAc,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAQjG;IAED,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,kBAGxC;IAED;;;OAGG;IACI,QAAQ,IAAI,MAAM,CAExB;IAED;;;OAGG;IACI,aAAa,IAAI,MAAM,EAAE,CAE/B;IAED;;;OAGG;IACI,QAAQ,IAAI,EAAE,EAAE,CAEtB;IAED;;;OAGG;IACI,OAAO,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAG7B;IAED;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAG3E;IAED;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,SAAI;;;MAQ3D;IAED;;;OAGG;IACI,QAAQ,IAAI,MAAM,CAExB;IAED;;;;OAIG;IACH,OAAc,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAEvE;IAED;;;;OAIG;IACI,qBAAqB,CAAC,aAAa,SAAS,MAAM,EAAE,wBAAwB,SAAS,MAAM,EAChG,aAAa,EAAE,aAAa,GAC3B,WAAW,CAAC,wBAAwB,CAAC,CAKvC;CACF;AAED,qFAAqF;AACrF,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EAAE,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,oCAQzD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { makeTuple } from '../array/array.js';
|
|
2
|
-
import { poseidon2Hash } from '../crypto/poseidon/index.js';
|
|
3
2
|
import { Fr } from '../curves/bn254/index.js';
|
|
4
3
|
import { schemas } from '../schemas/index.js';
|
|
5
4
|
import { assertLength, deserializeArrayFromVector, serializeArrayOfBufferableToVector } from '../serialize/index.js';
|
|
@@ -131,10 +130,7 @@ import { bufferToHex, hexToBuffer } from '../string/index.js';
|
|
|
131
130
|
return new SiblingPath(subtreePathSize, subtreeData);
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
|
-
/** Computes the expected root of a merkle tree given a leaf and its sibling path. */ export async function computeRootFromSiblingPath(leaf, siblingPath, index, hasher
|
|
135
|
-
left,
|
|
136
|
-
right
|
|
137
|
-
])).toBuffer()) {
|
|
133
|
+
/** Computes the expected root of a merkle tree given a leaf and its sibling path. */ export async function computeRootFromSiblingPath(leaf, siblingPath, index, hasher) {
|
|
138
134
|
let result = leaf;
|
|
139
135
|
for (const sibling of siblingPath){
|
|
140
136
|
result = index & 1 ? await hasher(sibling, result) : await hasher(result, sibling);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const computeUnbalancedShaRoot: (leaves: Buffer<ArrayBufferLike>[]) => Buffer<ArrayBufferLike>;
|
|
2
|
-
export declare const computeUnbalancedPoseidonRoot: (leaves: Buffer<ArrayBufferLike>[]) => Promise<Buffer<ArrayBufferLike>>;
|
|
3
2
|
export declare const computeWonkyShaRoot: (leaves: Buffer<ArrayBufferLike>[]) => Buffer<ArrayBufferLike>;
|
|
4
3
|
/**
|
|
5
4
|
* Computes the Merkle root of an unbalanced tree.
|
|
@@ -23,6 +22,6 @@ export declare const computeWonkyShaRoot: (leaves: Buffer<ArrayBufferLike>[]) =>
|
|
|
23
22
|
* (depth 1), the final tree has a depth of 5.
|
|
24
23
|
*/
|
|
25
24
|
export declare function computeUnbalancedMerkleTreeRoot(leaves: Buffer[], hasher?: (lhs: Uint8Array<ArrayBufferLike>, rhs: Uint8Array<ArrayBufferLike>) => Buffer<ArrayBuffer>, emptyRoot?: Buffer<ArrayBuffer>): Buffer;
|
|
26
|
-
export declare function computeUnbalancedMerkleTreeRootAsync(leaves: Buffer[], hasher
|
|
25
|
+
export declare function computeUnbalancedMerkleTreeRootAsync(leaves: Buffer[], hasher: (left: Uint8Array, right: Uint8Array) => Promise<Buffer<ArrayBuffer>>, emptyRoot?: Buffer<ArrayBuffer>): Promise<Buffer>;
|
|
27
26
|
export declare function computeWonkyMerkleTreeRoot(leaves: Buffer[], valueToCompress?: Buffer<ArrayBuffer>, emptyRoot?: Buffer<ArrayBuffer>, hasher?: (lhs: Uint8Array<ArrayBufferLike>, rhs: Uint8Array<ArrayBufferLike>) => Buffer<ArrayBuffer>): Buffer;
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5iYWxhbmNlZF9tZXJrbGVfdHJlZV9yb290LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHJlZXMvdW5iYWxhbmNlZF9tZXJrbGVfdHJlZV9yb290LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLGVBQU8sTUFBTSx3QkFBd0IsZ0VBQStFLENBQUM7QUFFckgsZUFBTyxNQUFNLG1CQUFtQixnRUFBMkQsQ0FBQztBQUU1Rjs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FvQkc7QUFDSCx3QkFBZ0IsK0JBQStCLENBQzdDLE1BQU0sRUFBRSxNQUFNLEVBQUUsRUFDaEIsTUFBTSw4RkFBZ0IsRUFDdEIsU0FBUyxzQkFBbUIsR0FDM0IsTUFBTSxDQTZCUjtBQUVELHdCQUFzQixvQ0FBb0MsQ0FDeEQsTUFBTSxFQUFFLE1BQU0sRUFBRSxFQUNoQixNQUFNLEVBQUUsQ0FBQyxJQUFJLEVBQUUsVUFBVSxFQUFFLEtBQUssRUFBRSxVQUFVLEtBQUssT0FBTyxDQUFDLE1BQU0sQ0FBQyxXQUFXLENBQUMsQ0FBQyxFQUM3RSxTQUFTLHNCQUFtQixHQUMzQixPQUFPLENBQUMsTUFBTSxDQUFDLENBNkJqQjtBQU1ELHdCQUFnQiwwQkFBMEIsQ0FDeEMsTUFBTSxFQUFFLE1BQU0sRUFBRSxFQUNoQixlQUFlLHNCQUFtQixFQUNsQyxTQUFTLHNCQUFtQixFQUM1QixNQUFNLDhGQUFnQixHQUNyQixNQUFNLENBR1IifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unbalanced_merkle_tree_root.d.ts","sourceRoot":"","sources":["../../src/trees/unbalanced_merkle_tree_root.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,wBAAwB,gEAA+E,CAAC;AAErH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"unbalanced_merkle_tree_root.d.ts","sourceRoot":"","sources":["../../src/trees/unbalanced_merkle_tree_root.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,wBAAwB,gEAA+E,CAAC;AAErH,eAAO,MAAM,mBAAmB,gEAA2D,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,8FAAgB,EACtB,SAAS,sBAAmB,GAC3B,MAAM,CA6BR;AAED,wBAAsB,oCAAoC,CACxD,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAC7E,SAAS,sBAAmB,GAC3B,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAMD,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EAAE,EAChB,eAAe,sBAAmB,EAClC,SAAS,sBAAmB,EAC5B,MAAM,8FAAgB,GACrB,MAAM,CAGR"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { computeBalancedMerkleTreeRoot, computeBalancedMerkleTreeRootAsync } from './balanced_merkle_tree_root.js';
|
|
2
|
-
import {
|
|
2
|
+
import { shaMerkleHash } from './hasher.js';
|
|
3
3
|
import { UnbalancedMerkleTreeCalculator } from './unbalanced_merkle_tree_calculator.js';
|
|
4
4
|
export const computeUnbalancedShaRoot = (leaves)=>computeUnbalancedMerkleTreeRoot(leaves, shaMerkleHash);
|
|
5
|
-
export const computeUnbalancedPoseidonRoot = async (leaves)=>await computeUnbalancedMerkleTreeRootAsync(leaves, poseidonMerkleHash);
|
|
6
5
|
export const computeWonkyShaRoot = (leaves)=>computeWonkyMerkleTreeRoot(leaves);
|
|
7
6
|
/**
|
|
8
7
|
* Computes the Merkle root of an unbalanced tree.
|
|
@@ -49,7 +48,7 @@ export const computeWonkyShaRoot = (leaves)=>computeWonkyMerkleTreeRoot(leaves);
|
|
|
49
48
|
}
|
|
50
49
|
return root;
|
|
51
50
|
}
|
|
52
|
-
export async function computeUnbalancedMerkleTreeRootAsync(leaves, hasher
|
|
51
|
+
export async function computeUnbalancedMerkleTreeRootAsync(leaves, hasher, emptyRoot = Buffer.alloc(32)) {
|
|
53
52
|
if (!leaves.length) {
|
|
54
53
|
return emptyRoot;
|
|
55
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/foundation",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.f7ea82942",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dest/index.js",
|
|
6
6
|
"types": "./dest/index.d.ts",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"testEnvironment": "../../foundation/src/jest/env.mjs"
|
|
146
146
|
},
|
|
147
147
|
"dependencies": {
|
|
148
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
148
|
+
"@aztec/bb.js": "0.0.1-commit.f7ea82942",
|
|
149
149
|
"@koa/cors": "^5.0.0",
|
|
150
150
|
"@noble/curves": "=1.7.0",
|
|
151
151
|
"@noble/hashes": "^1.6.1",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { BaseBuffer32 } from '../buffer/buffer32.js';
|
|
2
|
+
import { Buffer32 } from '../buffer/buffer32.js';
|
|
3
|
+
import type { Branded } from './types.js';
|
|
4
|
+
|
|
5
|
+
/** A branded Buffer32 representing a block proposal hash, used for p2p deduplication. */
|
|
6
|
+
export type BlockProposalHash = Branded<BaseBuffer32, 'BlockProposalHash'>;
|
|
7
|
+
|
|
8
|
+
/** Creates a BlockProposalHash from a BaseBuffer32. */
|
|
9
|
+
export function BlockProposalHash(buf: BaseBuffer32): BlockProposalHash {
|
|
10
|
+
return buf as BlockProposalHash;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Creates a BlockProposalHash from a raw Buffer. */
|
|
14
|
+
BlockProposalHash.fromBuffer = function (buf: Buffer): BlockProposalHash {
|
|
15
|
+
return new Buffer32(buf) as unknown as BlockProposalHash;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** A branded Buffer32 representing a checkpoint proposal hash, used for p2p deduplication. */
|
|
19
|
+
export type CheckpointProposalHash = Branded<BaseBuffer32, 'CheckpointProposalHash'>;
|
|
20
|
+
|
|
21
|
+
/** Creates a CheckpointProposalHash from a BaseBuffer32. */
|
|
22
|
+
export function CheckpointProposalHash(buf: BaseBuffer32): CheckpointProposalHash {
|
|
23
|
+
return buf as CheckpointProposalHash;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Creates a CheckpointProposalHash from a raw Buffer. */
|
|
27
|
+
CheckpointProposalHash.fromBuffer = function (buf: Buffer): CheckpointProposalHash {
|
|
28
|
+
return new Buffer32(buf) as unknown as CheckpointProposalHash;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** A branded Buffer32 representing a checkpoint attestation hash, used for p2p deduplication. */
|
|
32
|
+
export type CheckpointAttestationHash = Branded<BaseBuffer32, 'CheckpointAttestationHash'>;
|
|
33
|
+
|
|
34
|
+
/** Creates a CheckpointAttestationHash from a BaseBuffer32. */
|
|
35
|
+
export function CheckpointAttestationHash(buf: BaseBuffer32): CheckpointAttestationHash {
|
|
36
|
+
return buf as CheckpointAttestationHash;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Creates a CheckpointAttestationHash from a raw Buffer. */
|
|
40
|
+
CheckpointAttestationHash.fromBuffer = function (buf: Buffer): CheckpointAttestationHash {
|
|
41
|
+
return new Buffer32(buf) as unknown as CheckpointAttestationHash;
|
|
42
|
+
};
|
|
@@ -85,6 +85,11 @@ CheckpointNumber.isValid = function (value: unknown): value is CheckpointNumber
|
|
|
85
85
|
return typeof value === 'number' && Number.isInteger(value) && value >= 0;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
/** Increments a CheckpointNumber by a given value. */
|
|
89
|
+
CheckpointNumber.add = function (n: CheckpointNumber, increment: number): CheckpointNumber {
|
|
90
|
+
return CheckpointNumber(n + increment);
|
|
91
|
+
};
|
|
92
|
+
|
|
88
93
|
/** The zero checkpoint value. */
|
|
89
94
|
CheckpointNumber.ZERO = CheckpointNumber(0);
|
|
90
95
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { BlockNumber, BlockNumberSchema, BlockNumberPositiveSchema } from './block_number.js';
|
|
2
|
+
export { BlockProposalHash, CheckpointAttestationHash, CheckpointProposalHash } from './buffer32_hash.js';
|
|
2
3
|
export { CheckpointNumber, CheckpointNumberSchema, CheckpointNumberPositiveSchema } from './checkpoint_number.js';
|
|
3
4
|
export { EpochNumber, EpochNumberSchema } from './epoch.js';
|
|
4
5
|
export { IndexWithinCheckpoint, IndexWithinCheckpointSchema } from './index_within_checkpoint.js';
|
package/src/buffer/buffer16.ts
CHANGED
|
@@ -10,8 +10,8 @@ import { bufferToHex } from '../string/index.js';
|
|
|
10
10
|
* A class representing a 16 byte Buffer.
|
|
11
11
|
*/
|
|
12
12
|
export class Buffer16 {
|
|
13
|
-
/** Branding
|
|
14
|
-
declare readonly
|
|
13
|
+
/** Branding for nominal typing. */
|
|
14
|
+
declare private readonly _branding: 'Buffer16';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* The size of the hash in bytes.
|
package/src/buffer/buffer32.ts
CHANGED
|
@@ -7,72 +7,39 @@ import { inspect } from 'util';
|
|
|
7
7
|
import { bufferToHex } from '../string/index.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Abstract unbranded base class for 32-byte buffers.
|
|
11
|
+
* Extend this instead of Buffer32 when defining a branded subtype
|
|
12
|
+
* to avoid inheriting Buffer32's `_branding`.
|
|
11
13
|
*/
|
|
12
|
-
export class
|
|
13
|
-
/**
|
|
14
|
-
declare readonly __brand: 'Buffer32';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The size of the hash in bytes.
|
|
18
|
-
*/
|
|
14
|
+
export abstract class BaseBuffer32 {
|
|
15
|
+
/** The size of the buffer in bytes. */
|
|
19
16
|
public static SIZE = 32;
|
|
20
17
|
|
|
21
|
-
/**
|
|
22
|
-
* Buffer32 with value zero.
|
|
23
|
-
*/
|
|
24
|
-
public static ZERO = new Buffer32(Buffer.alloc(Buffer32.SIZE));
|
|
25
|
-
|
|
26
18
|
constructor(
|
|
27
|
-
/**
|
|
28
|
-
* The buffer containing the hash.
|
|
29
|
-
*/
|
|
19
|
+
/** The buffer containing the data. */
|
|
30
20
|
public buffer: Buffer,
|
|
31
21
|
) {
|
|
32
|
-
if (buffer.length !==
|
|
33
|
-
throw new Error(`Expected buffer to have length ${
|
|
22
|
+
if (buffer.length !== BaseBuffer32.SIZE) {
|
|
23
|
+
throw new Error(`Expected buffer to have length ${BaseBuffer32.SIZE} but was ${buffer.length}`);
|
|
34
24
|
}
|
|
35
25
|
}
|
|
36
26
|
|
|
37
|
-
/**
|
|
38
|
-
* Returns the raw buffer of the hash.
|
|
39
|
-
* @returns The buffer containing the hash.
|
|
40
|
-
*/
|
|
27
|
+
/** Returns the raw buffer. */
|
|
41
28
|
public toBuffer() {
|
|
42
29
|
return this.buffer;
|
|
43
30
|
}
|
|
44
31
|
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
* @param buffer - The buffer to create from.
|
|
48
|
-
* @returns A new Buffer32 object.
|
|
49
|
-
*/
|
|
50
|
-
public static fromBuffer(buffer: Buffer | BufferReader) {
|
|
51
|
-
const reader = BufferReader.asReader(buffer);
|
|
52
|
-
return new Buffer32(reader.readBytes(Buffer32.SIZE));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Checks if this hash and another hash are equal.
|
|
57
|
-
* @param hash - A hash to compare with.
|
|
58
|
-
* @returns True if the hashes are equal, false otherwise.
|
|
59
|
-
*/
|
|
60
|
-
public equals(hash: Buffer32): boolean {
|
|
32
|
+
/** Checks if this and another buffer are equal. */
|
|
33
|
+
public equals(hash: BaseBuffer32): boolean {
|
|
61
34
|
return this.buffer.equals(hash.buffer);
|
|
62
35
|
}
|
|
63
36
|
|
|
64
|
-
/**
|
|
65
|
-
* Returns true if this hash is zero.
|
|
66
|
-
* @returns True if this hash is zero.
|
|
67
|
-
*/
|
|
37
|
+
/** Returns true if all bytes are zero. */
|
|
68
38
|
public isZero(): boolean {
|
|
69
39
|
return this.buffer.equals(Buffer.alloc(32, 0));
|
|
70
40
|
}
|
|
71
41
|
|
|
72
|
-
/**
|
|
73
|
-
* Convert this hash to a hex string.
|
|
74
|
-
* @returns The hex string.
|
|
75
|
-
*/
|
|
42
|
+
/** Convert to a hex string. */
|
|
76
43
|
public toString() {
|
|
77
44
|
return bufferToHex(this.buffer);
|
|
78
45
|
}
|
|
@@ -85,16 +52,27 @@ export class Buffer32 {
|
|
|
85
52
|
return this.toString();
|
|
86
53
|
}
|
|
87
54
|
|
|
88
|
-
/**
|
|
89
|
-
* Convert this hash to a big int.
|
|
90
|
-
* @returns The big int.
|
|
91
|
-
*/
|
|
55
|
+
/** Convert to a big int. */
|
|
92
56
|
public toBigInt() {
|
|
93
|
-
return deserializeBigInt(this.buffer, 0,
|
|
57
|
+
return deserializeBigInt(this.buffer, 0, BaseBuffer32.SIZE).elem;
|
|
94
58
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** A branded 32-byte buffer. */
|
|
62
|
+
export class Buffer32 extends BaseBuffer32 {
|
|
63
|
+
/** Branding for nominal typing. */
|
|
64
|
+
declare private readonly _branding: 'Buffer32';
|
|
65
|
+
|
|
66
|
+
/** Buffer32 with value zero. */
|
|
67
|
+
public static ZERO = new Buffer32(Buffer.alloc(Buffer32.SIZE));
|
|
68
|
+
|
|
69
|
+
/** Creates a Buffer32 from a buffer. */
|
|
70
|
+
public static fromBuffer(buffer: Buffer | BufferReader) {
|
|
71
|
+
const reader = BufferReader.asReader(buffer);
|
|
72
|
+
return new Buffer32(reader.readBytes(Buffer32.SIZE));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Creates a Buffer32 from a bigint. */
|
|
98
76
|
public static fromBigInt(hash: bigint) {
|
|
99
77
|
return new Buffer32(serializeBigInt(hash, Buffer32.SIZE));
|
|
100
78
|
}
|
|
@@ -104,8 +82,7 @@ export class Buffer32 {
|
|
|
104
82
|
}
|
|
105
83
|
|
|
106
84
|
/**
|
|
107
|
-
* Converts
|
|
108
|
-
* Verifies the input is 28 bytes.
|
|
85
|
+
* Converts from a buffer of 28 bytes.
|
|
109
86
|
* @param buffer - The 28 byte buffer to construct from.
|
|
110
87
|
* @returns A Buffer32 created from the input buffer with 4 bytes 0 padding at the front.
|
|
111
88
|
*/
|
|
@@ -117,9 +94,7 @@ export class Buffer32 {
|
|
|
117
94
|
return new Buffer32(padded);
|
|
118
95
|
}
|
|
119
96
|
|
|
120
|
-
/**
|
|
121
|
-
* Converts a string into a Buffer32 object.
|
|
122
|
-
*/
|
|
97
|
+
/** Converts a string into a Buffer32 object. */
|
|
123
98
|
public static fromString(str: string): Buffer32 {
|
|
124
99
|
if (str.startsWith('0x')) {
|
|
125
100
|
str = str.slice(2);
|
|
@@ -130,19 +105,12 @@ export class Buffer32 {
|
|
|
130
105
|
return new Buffer32(Buffer.from(str, 'hex'));
|
|
131
106
|
}
|
|
132
107
|
|
|
133
|
-
/**
|
|
134
|
-
* Converts a number into a Buffer32 object.
|
|
135
|
-
* @param num - The number to convert.
|
|
136
|
-
* @returns A new Buffer32 object.
|
|
137
|
-
*/
|
|
108
|
+
/** Converts a number into a Buffer32 object. */
|
|
138
109
|
public static fromNumber(num: number): Buffer32 {
|
|
139
110
|
return new Buffer32(serializeBigInt(BigInt(num), Buffer32.SIZE));
|
|
140
111
|
}
|
|
141
112
|
|
|
142
|
-
/**
|
|
143
|
-
* Generates a random Buffer32.
|
|
144
|
-
* @returns A new Buffer32 object.
|
|
145
|
-
*/
|
|
113
|
+
/** Generates a random Buffer32. */
|
|
146
114
|
public static random(): Buffer32 {
|
|
147
115
|
return new Buffer32(Buffer.from(randomBytes(Buffer32.SIZE)));
|
|
148
116
|
}
|
package/src/config/env_var.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
export type EnvVar =
|
|
2
2
|
| 'REGISTRY_CONTRACT_ADDRESS'
|
|
3
3
|
| 'FEE_ASSET_HANDLER_CONTRACT_ADDRESS'
|
|
4
|
-
| 'SLASH_FACTORY_CONTRACT_ADDRESS'
|
|
5
4
|
| 'ACVM_BINARY_PATH'
|
|
6
5
|
| 'ACVM_WORKING_DIRECTORY'
|
|
7
6
|
| 'API_KEY'
|
|
8
7
|
| 'API_PREFIX'
|
|
9
8
|
| 'ARCHIVER_MAX_LOGS'
|
|
10
9
|
| 'ARCHIVER_POLLING_INTERVAL_MS'
|
|
10
|
+
| 'ARCHIVER_SKIP_HISTORICAL_LOGS_CHECK'
|
|
11
11
|
| 'ARCHIVER_URL'
|
|
12
12
|
| 'ARCHIVER_VIEM_POLLING_INTERVAL_MS'
|
|
13
13
|
| 'ARCHIVER_BATCH_SIZE'
|
|
14
14
|
| 'AZTEC_ADMIN_PORT'
|
|
15
|
+
| 'AZTEC_NODE_DEBUG'
|
|
15
16
|
| 'AZTEC_ADMIN_API_KEY_HASH'
|
|
16
17
|
| 'AZTEC_DISABLE_ADMIN_API_KEY'
|
|
17
18
|
| 'AZTEC_RESET_ADMIN_API_KEY'
|
|
@@ -94,7 +95,6 @@ export type EnvVar =
|
|
|
94
95
|
| 'MNEMONIC'
|
|
95
96
|
| 'NETWORK'
|
|
96
97
|
| 'NETWORK_CONFIG_LOCATION'
|
|
97
|
-
| 'NO_PXE'
|
|
98
98
|
| 'USE_GCLOUD_LOGGING'
|
|
99
99
|
| 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'
|
|
100
100
|
| 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'
|
|
@@ -228,13 +228,12 @@ export type EnvVar =
|
|
|
228
228
|
| 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT'
|
|
229
229
|
| 'SEQ_ATTESTATION_PROPAGATION_TIME'
|
|
230
230
|
| 'SEQ_BLOCK_DURATION_MS'
|
|
231
|
+
| 'SEQ_LAST_BLOCK_DURATION_MS'
|
|
231
232
|
| 'SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT'
|
|
232
233
|
| 'SEQ_BUILD_CHECKPOINT_IF_EMPTY'
|
|
233
234
|
| 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER'
|
|
234
235
|
| 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER'
|
|
235
236
|
| 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT'
|
|
236
|
-
| 'SLASH_MIN_PENALTY_PERCENTAGE'
|
|
237
|
-
| 'SLASH_MAX_PENALTY_PERCENTAGE'
|
|
238
237
|
| 'SLASH_VALIDATORS_ALWAYS'
|
|
239
238
|
| 'SLASH_VALIDATORS_NEVER'
|
|
240
239
|
| 'SLASH_PRUNE_PENALTY'
|
|
@@ -327,7 +326,7 @@ export type EnvVar =
|
|
|
327
326
|
| 'AZTEC_SLASH_AMOUNT_SMALL'
|
|
328
327
|
| 'AZTEC_SLASH_AMOUNT_MEDIUM'
|
|
329
328
|
| 'AZTEC_SLASH_AMOUNT_LARGE'
|
|
330
|
-
| '
|
|
329
|
+
| 'AZTEC_SLASHER_ENABLED'
|
|
331
330
|
| 'AZTEC_GOVERNANCE_PROPOSER_QUORUM'
|
|
332
331
|
| 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE'
|
|
333
332
|
| 'AZTEC_GOVERNANCE_VOTING_DURATION'
|