@aztec/native 3.0.0-canary.a9708bd → 3.0.0-manual.20251030

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.
@@ -4,5 +4,13 @@ interface NativeClassCtor {
4
4
  }
5
5
  export declare const NativeWorldState: NativeClassCtor;
6
6
  export declare const NativeLMDBStore: NativeClassCtor;
7
+ /**
8
+ * AVM simulation function that uses pre-collected hints from TypeScript simulation.
9
+ * All contract data and merkle tree hints are included in the AvmCircuitInputs, so no runtime
10
+ * callbacks to TS or WS pointer are needed.
11
+ * @param inputs - Msgpack-serialized AvmCircuitInputs (AvmProvingInputs in C++) buffer
12
+ * @returns Promise resolving to msgpack-serialized simulation results buffer
13
+ */
14
+ export declare const avmSimulateWithHintedDbs: (inputs: Buffer) => Promise<Buffer>;
7
15
  export {};
8
16
  //# sourceMappingURL=native_module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"native_module.d.ts","sourceRoot":"","sources":["../src/native_module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,UAAU,eAAe;IACvB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;CAC3C;AAID,eAAO,MAAM,gBAAgB,EAAE,eAAyC,CAAC;AACzE,eAAO,MAAM,eAAe,EAAE,eAAwC,CAAC"}
1
+ {"version":3,"file":"native_module.d.ts","sourceRoot":"","sources":["../src/native_module.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,UAAU,eAAe;IACvB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;CAC3C;AA2BD,eAAO,MAAM,gBAAgB,EAAE,eAA4D,CAAC;AAC5F,eAAO,MAAM,eAAe,EAAE,eAA2D,CAAC;AAE1F;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAErD,CAAC"}
@@ -1,4 +1,28 @@
1
- import bindings from 'bindings';
2
- const nativeModule = bindings('nodejs_module');
1
+ import { createRequire } from 'module';
2
+ import { dirname, join } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ function loadNativeModule() {
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = dirname(__filename);
7
+ // Map Node.js platform/arch to build directory names
8
+ const arch = process.arch === 'x64' ? 'amd64' : process.arch;
9
+ const platform = process.platform === 'darwin' ? 'macos' : process.platform;
10
+ const variant = `${arch}-${platform}`;
11
+ const modulePath = join(__dirname, '..', 'build', variant, 'nodejs_module.node');
12
+ try {
13
+ const require = createRequire(import.meta.url);
14
+ return require(modulePath);
15
+ } catch (error) {
16
+ throw new Error(`Failed to load native module for ${variant} from ${modulePath}. ` + `Supported: amd64-linux, arm64-linux, amd64-macos, arm64-macos. ` + `Error: ${error}`);
17
+ }
18
+ }
19
+ const nativeModule = loadNativeModule();
3
20
  export const NativeWorldState = nativeModule.WorldState;
4
21
  export const NativeLMDBStore = nativeModule.LMDBStore;
22
+ /**
23
+ * AVM simulation function that uses pre-collected hints from TypeScript simulation.
24
+ * All contract data and merkle tree hints are included in the AvmCircuitInputs, so no runtime
25
+ * callbacks to TS or WS pointer are needed.
26
+ * @param inputs - Msgpack-serialized AvmCircuitInputs (AvmProvingInputs in C++) buffer
27
+ * @returns Promise resolving to msgpack-serialized simulation results buffer
28
+ */ export const avmSimulateWithHintedDbs = nativeModule.avmSimulateWithHintedDbs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/native",
3
- "version": "3.0.0-canary.a9708bd",
3
+ "version": "3.0.0-manual.20251030",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js"
@@ -12,20 +12,18 @@
12
12
  "clean:cpp": "rm -rf $(git rev-parse --show-toplevel)/barretenberg/cpp/build-pic",
13
13
  "clean": "rm -rf ./dest .tsbuildinfo",
14
14
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
15
- "generate": "mkdir -p build && cp -v $(git rev-parse --show-toplevel)/barretenberg/cpp/build-pic/lib/nodejs_module.node build"
15
+ "generate": "bash scripts/copy-modules.sh"
16
16
  },
17
17
  "inherits": [
18
18
  "../package.common.json",
19
19
  "./package.local.json"
20
20
  ],
21
21
  "dependencies": {
22
- "@aztec/foundation": "3.0.0-canary.a9708bd",
23
- "bindings": "^1.5.0",
22
+ "@aztec/foundation": "3.0.0-manual.20251030",
24
23
  "msgpackr": "^1.11.2"
25
24
  },
26
25
  "devDependencies": {
27
26
  "@jest/globals": "^30.0.0",
28
- "@types/bindings": "^1.5.5",
29
27
  "@types/jest": "^30.0.0",
30
28
  "@types/node": "^22.15.17",
31
29
  "jest": "^30.0.0",
@@ -35,6 +33,7 @@
35
33
  "files": [
36
34
  "dest",
37
35
  "src",
36
+ "build",
38
37
  "!*.test.*"
39
38
  ],
40
39
  "engines": {
@@ -1,4 +1,6 @@
1
- import bindings from 'bindings';
1
+ import { createRequire } from 'module';
2
+ import { dirname, join } from 'path';
3
+ import { fileURLToPath } from 'url';
2
4
 
3
5
  import type { MessageReceiver } from './msgpack_channel.js';
4
6
 
@@ -6,7 +8,41 @@ interface NativeClassCtor {
6
8
  new (...args: unknown[]): MessageReceiver;
7
9
  }
8
10
 
9
- const nativeModule: Record<string, NativeClassCtor> = bindings('nodejs_module');
11
+ function loadNativeModule(): Record<string, NativeClassCtor> {
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
10
14
 
11
- export const NativeWorldState: NativeClassCtor = nativeModule.WorldState;
12
- export const NativeLMDBStore: NativeClassCtor = nativeModule.LMDBStore;
15
+ // Map Node.js platform/arch to build directory names
16
+ const arch = process.arch === 'x64' ? 'amd64' : process.arch;
17
+ const platform = process.platform === 'darwin' ? 'macos' : process.platform;
18
+ const variant = `${arch}-${platform}`;
19
+
20
+ const modulePath = join(__dirname, '..', 'build', variant, 'nodejs_module.node');
21
+
22
+ try {
23
+ const require = createRequire(import.meta.url);
24
+ return require(modulePath);
25
+ } catch (error) {
26
+ throw new Error(
27
+ `Failed to load native module for ${variant} from ${modulePath}. ` +
28
+ `Supported: amd64-linux, arm64-linux, amd64-macos, arm64-macos. ` +
29
+ `Error: ${error}`,
30
+ );
31
+ }
32
+ }
33
+
34
+ const nativeModule: Record<string, NativeClassCtor | Function> = loadNativeModule();
35
+
36
+ export const NativeWorldState: NativeClassCtor = nativeModule.WorldState as NativeClassCtor;
37
+ export const NativeLMDBStore: NativeClassCtor = nativeModule.LMDBStore as NativeClassCtor;
38
+
39
+ /**
40
+ * AVM simulation function that uses pre-collected hints from TypeScript simulation.
41
+ * All contract data and merkle tree hints are included in the AvmCircuitInputs, so no runtime
42
+ * callbacks to TS or WS pointer are needed.
43
+ * @param inputs - Msgpack-serialized AvmCircuitInputs (AvmProvingInputs in C++) buffer
44
+ * @returns Promise resolving to msgpack-serialized simulation results buffer
45
+ */
46
+ export const avmSimulateWithHintedDbs: (inputs: Buffer) => Promise<Buffer> = nativeModule.avmSimulateWithHintedDbs as (
47
+ inputs: Buffer,
48
+ ) => Promise<Buffer>;