@lodestar/native 1.51.0-dev.fac22802f6 → 1.52.0-dev.025dabac49

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/README.md CHANGED
@@ -22,10 +22,11 @@ pnpm build
22
22
  pnpm test:native
23
23
  ```
24
24
 
25
- For native-only changes, rebuild with `pnpm build:native`. The output is
26
- `bindings/zig-out/lib/bindings.node`. Use
27
- `pnpm --filter @lodestar/native prepare-minimal` or `prepare-gnosis` to select another
28
- preset. Rebuild before switching presets; they share an output directory.
25
+ For native-only changes, rebuild with `pnpm build:native`. It builds one addon per preset
26
+ into `bindings/zig-out/lib/bindings-<preset>.node`, and `LODESTAR_PRESET` selects which one
27
+ is loaded (default `mainnet`). Use `pnpm --filter @lodestar/native prepare-mainnet`,
28
+ `prepare-minimal` or `prepare-gnosis` to rebuild a single preset. Do not run them
29
+ concurrently; they share an intermediate output file.
29
30
 
30
31
  Bindings use their own Vitest configuration and the root workspace lockfile.
31
32
  Consensus spec vectors are pinned in [`build.zig.zon`](../build.zig.zon).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodestar/native",
3
- "version": "1.51.0-dev.fac22802f6",
3
+ "version": "1.52.0-dev.025dabac49",
4
4
  "description": "Native consensus modules for Lodestar",
5
5
  "files": [
6
6
  "src/"
@@ -23,6 +23,10 @@
23
23
  "types": "./src/pubkeys.d.ts",
24
24
  "import": "./src/pubkeys.js"
25
25
  },
26
+ "./committee-pubkeys": {
27
+ "types": "./src/committee-pubkeys.d.ts",
28
+ "import": "./src/committee-pubkeys.js"
29
+ },
26
30
  "./state-transition": {
27
31
  "types": "./src/state-transition.d.ts",
28
32
  "import": "./src/state-transition.js"
@@ -41,17 +45,17 @@
41
45
  }
42
46
  },
43
47
  "scripts": {
44
- "prepare-mainnet": "cd .. && zig build build-lib:bindings -Doptimize=ReleaseSafe -Dcpu=baseline -Dpreset=mainnet --prefix bindings/zig-out",
45
- "prepare-minimal": "cd .. && zig build build-lib:bindings -Doptimize=ReleaseSafe -Dcpu=baseline -Dpreset=minimal --prefix bindings/zig-out",
46
- "prepare-gnosis": "cd .. && zig build build-lib:bindings -Doptimize=ReleaseSafe -Dcpu=baseline -Dpreset=gnosis --prefix bindings/zig-out",
48
+ "prepare-mainnet": "zapi build --variant mainnet --optimize ReleaseSafe --zig-cwd .. --prefix bindings/zig-out",
49
+ "prepare-minimal": "zapi build --variant minimal --optimize ReleaseSafe --zig-cwd .. --prefix bindings/zig-out",
50
+ "prepare-gnosis": "zapi build --variant gnosis --optimize ReleaseSafe --zig-cwd .. --prefix bindings/zig-out",
47
51
  "lint": "biome check",
48
52
  "test": "NODE_OPTIONS='--expose-gc' vitest run",
49
53
  "benchmark": "NODE_OPTIONS='--import tsx' benchmark 'perf/**/*.test.ts' --isolate --config .benchrc.yaml --defaultBranch unstable",
50
- "build": "pnpm run prepare-${LODESTAR_PRESET:-mainnet}",
51
- "build:watch": "pnpm run build --watch",
54
+ "build": "pnpm run prepare-mainnet && pnpm run prepare-minimal && pnpm run prepare-gnosis",
55
+ "build:watch": "preset=${LODESTAR_PRESET:-mainnet} && mkdir -p zig-out/lib && ln -sf bindings.node zig-out/lib/bindings-$preset.node && cd .. && zig build build-lib:bindings -Doptimize=ReleaseSafe -Dcpu=baseline -Dpreset=$preset --prefix bindings/zig-out --watch",
52
56
  "build:release": "pnpm clean && pnpm build",
53
57
  "clean": "rm -rf zig-out",
54
- "check-build": "node -e \"import('./src/index.js')\"",
58
+ "check-build": "for preset in mainnet minimal gnosis; do LODESTAR_PRESET=$preset node -e \"import('./src/index.js')\" || exit 1; done",
55
59
  "prepack": "zapi prepublish --main-only"
56
60
  },
57
61
  "keywords": [],
@@ -72,10 +76,21 @@
72
76
  "x86_64-apple-darwin",
73
77
  "x86_64-unknown-linux-gnu",
74
78
  "x86_64-unknown-linux-musl"
75
- ]
79
+ ],
80
+ "variants": {
81
+ "mainnet": [
82
+ "-Dpreset=mainnet"
83
+ ],
84
+ "minimal": [
85
+ "-Dpreset=minimal"
86
+ ],
87
+ "gnosis": [
88
+ "-Dpreset=gnosis"
89
+ ]
90
+ }
76
91
  },
77
92
  "dependencies": {
78
- "@chainsafe/zapi": "4.3.0"
93
+ "@chainsafe/zapi": "4.5.0"
79
94
  },
80
95
  "devDependencies": {
81
96
  "@chainsafe/benchmark": "2.1.0",
@@ -84,13 +99,13 @@
84
99
  "publishConfig": {
85
100
  "access": "public"
86
101
  },
87
- "gitHead": "78837807d1019eb30bae0f962c58e6738239768c",
102
+ "gitHead": "305a0dd66da9fd70ac11effcc58f70dfa7dc50ff",
88
103
  "optionalDependencies": {
89
- "@lodestar/native-aarch64-apple-darwin": "1.51.0-dev.fac22802f6",
90
- "@lodestar/native-aarch64-unknown-linux-gnu": "1.51.0-dev.fac22802f6",
91
- "@lodestar/native-aarch64-unknown-linux-musl": "1.51.0-dev.fac22802f6",
92
- "@lodestar/native-x86_64-apple-darwin": "1.51.0-dev.fac22802f6",
93
- "@lodestar/native-x86_64-unknown-linux-gnu": "1.51.0-dev.fac22802f6",
94
- "@lodestar/native-x86_64-unknown-linux-musl": "1.51.0-dev.fac22802f6"
104
+ "@lodestar/native-aarch64-apple-darwin": "1.52.0-dev.025dabac49",
105
+ "@lodestar/native-aarch64-unknown-linux-gnu": "1.52.0-dev.025dabac49",
106
+ "@lodestar/native-aarch64-unknown-linux-musl": "1.52.0-dev.025dabac49",
107
+ "@lodestar/native-x86_64-apple-darwin": "1.52.0-dev.025dabac49",
108
+ "@lodestar/native-x86_64-unknown-linux-gnu": "1.52.0-dev.025dabac49",
109
+ "@lodestar/native-x86_64-unknown-linux-musl": "1.52.0-dev.025dabac49"
95
110
  }
96
111
  }
package/src/bindings.js CHANGED
@@ -1,6 +1,13 @@
1
1
  import {join} from "node:path";
2
2
  import {requireNapiLibrary} from "@chainsafe/zapi";
3
3
 
4
- const bindings = requireNapiLibrary(join(import.meta.dirname, ".."));
4
+ // Consensus presets are compiled into the addon, so there is one binary per preset.
5
+ // The selection mirrors `ACTIVE_PRESET` in `@lodestar/params`.
6
+ const presets = ["mainnet", "minimal", "gnosis"];
7
+ const preset = process.env.LODESTAR_PRESET;
8
+
9
+ const bindings = requireNapiLibrary(join(import.meta.dirname, ".."), {
10
+ variant: preset !== undefined && presets.includes(preset) ? preset : "mainnet",
11
+ });
5
12
 
6
13
  export default bindings;
@@ -2,6 +2,7 @@ export declare const BLS_VERIFIER_SET_TYPE: {
2
2
  readonly indexed: 0;
3
3
  readonly aggregate: 1;
4
4
  readonly single: 2;
5
+ readonly committee: 3;
5
6
  };
6
7
 
7
8
  export declare const BLS_VERIFIER_MAX_BATCH_SIZE: 256;
@@ -30,7 +31,25 @@ export type SingleSignatureSet = {
30
31
  signature: Uint8Array;
31
32
  };
32
33
 
33
- export type BlsSignatureSet = IndexedSignatureSet | AggregateSignatureSet | SingleSignatureSet;
34
+ /**
35
+ * An attestation over whole committees of one slot, verified with the committee pubkeys from
36
+ * `computeCommitteePubkeys()`. Its aggregation bits are concatenated in `committeeIndices` order. `indices` lists the
37
+ * participants and is aggregated instead when the entry is not cached. Only the participant count is checked, so
38
+ * callers must derive `indices` and the aggregation bits from the same attestation.
39
+ */
40
+ export type CommitteeSignatureSet = {
41
+ type: typeof BLS_VERIFIER_SET_TYPE.committee;
42
+ indices: Uint32Array;
43
+ committeePubkeysId: number;
44
+ slot: number;
45
+ committeeIndices: Uint32Array;
46
+ aggregationBits: Uint8Array;
47
+ bitLen: number;
48
+ message: Uint8Array;
49
+ signature: Uint8Array;
50
+ };
51
+
52
+ export type BlsSignatureSet = IndexedSignatureSet | AggregateSignatureSet | SingleSignatureSet | CommitteeSignatureSet;
34
53
 
35
54
  export type SameMessageSignatureSet = {
36
55
  index: number;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Aggregate pubkeys of the beacon committees of an epoch shuffling, held in native memory. Signature sets reference an
3
+ * entry by id, so BLS worker threads can use it too.
4
+ */
5
+
6
+ /** Entries the cache holds at most, counting computations in flight. */
7
+ export declare const COMMITTEE_PUBKEYS_MAX_ENTRIES: number;
8
+
9
+ /**
10
+ * Aggregate the pubkeys of every committee of a shuffling on a libuv worker thread and resolve to the entry id.
11
+ * `shuffling` is the shuffled active validator indices, and it is copied before this returns. Throws when
12
+ * `COMMITTEE_PUBKEYS_MAX_ENTRIES` entries are cached or being computed.
13
+ */
14
+ export declare function computeCommitteePubkeys(
15
+ shuffling: Uint32Array,
16
+ slotsPerEpoch: number,
17
+ committeesPerSlot: number
18
+ ): Promise<number>;
19
+
20
+ /**
21
+ * Free an entry. Returns false if `id` is unknown. A signature set that still references it falls back to its
22
+ * participant indices.
23
+ */
24
+ export declare function releaseCommitteePubkeys(id: number): boolean;
25
+
26
+ /** Number of cached entries. */
27
+ export declare function committeePubkeysCount(): number;
@@ -0,0 +1,9 @@
1
+ import bindings from "./bindings.js";
2
+
3
+ const native = bindings.committeePubkeys;
4
+
5
+ export const COMMITTEE_PUBKEYS_MAX_ENTRIES = native.MAX_ENTRIES;
6
+
7
+ export const computeCommitteePubkeys = native.compute;
8
+ export const releaseCommitteePubkeys = native.release;
9
+ export const committeePubkeysCount = native.size;
package/src/index.d.ts CHANGED
@@ -293,6 +293,21 @@ export declare class BeaconStateView {
293
293
  historicalSummaries: HistoricalSummary[];
294
294
  pendingDeposits: Uint8Array;
295
295
  pendingDepositsCount: number;
296
+ /** Fulu only. Limits: 0..10,000 new verifications and 0..60,000 milliseconds per call. */
297
+ preVerifyBuilderDepositsPreGloas(
298
+ maxBuilderDeposits: number,
299
+ maxDurationMs: number
300
+ ): {
301
+ validBuilderSignaturesCount: number;
302
+ invalidBuilderSignaturesCount: number;
303
+ validValidatorSignaturesCount: number;
304
+ invalidValidatorSignaturesCount: number;
305
+ scannedPendingDeposits: number;
306
+ totalCachedDeposits: number;
307
+ totalBuilderPubkeys: number;
308
+ pendingDepositsCount: number;
309
+ };
310
+ clearPreGloasBuilderDepositCache(): void;
296
311
  pendingPartialWithdrawals: Uint8Array;
297
312
  pendingPartialWithdrawalsCount: number;
298
313
  pendingConsolidations: Uint8Array;
package/src/metrics.d.ts CHANGED
@@ -12,7 +12,7 @@ export declare function registerLocalValidator(index: number): void;
12
12
 
13
13
  /**
14
14
  * Remove a validator index from the native validator monitor, so its
15
- * `validator_monitor_*` status metrics stop being recorded. Mirrors the pruning
15
+ * `lodestar_validator_monitor_*` status metrics stop being recorded. Mirrors the pruning
16
16
  * of stale registrations in lodestar's validator monitor.
17
17
  */
18
18
  export declare function unregisterLocalValidator(index: number): void;
package/src/pubkeys.d.ts CHANGED
@@ -48,7 +48,10 @@ export interface PubkeyCache {
48
48
  * recorded in the file is discarded above this limit.
49
49
  */
50
50
  load(filepath: string, maxCapacity: number): void;
51
- /** Testing-only reset from the control environment while no workers are using the cache. */
51
+ /**
52
+ * Testing-only reset from the control environment while no workers are using the cache.
53
+ * Also drops the committee pubkeys aggregated from the cleared keys.
54
+ */
52
55
  reset(): void;
53
56
  /** Save from the control environment. */
54
57
  save(filepath: string): void;