diff --git a/package.json b/package.json index 735e2be0d..bc714db3c 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@babel/preset-react": "^7.14.5", "@babel/preset-typescript": "^7.14.5", "@babel/register": "^7.15.3", + "@biomejs/biome": "^1.9.4", "@chainsafe/benchmark": "^1.1.0", "@types/node": "^22.10.2", "@typescript-eslint/eslint-plugin": "^6", diff --git a/packages/as-sha256/scripts/codegen.ts b/packages/as-sha256/scripts/codegen.ts index 6168c8d30..b19d7d349 100644 --- a/packages/as-sha256/scripts/codegen.ts +++ b/packages/as-sha256/scripts/codegen.ts @@ -26,7 +26,7 @@ for (const {input, exportName} of binaries) { const outputString = `// This file was autogenerated by scripts/codegen.ts // DO NOT modify this file by hand! -// eslint-disable-next-line prettier/prettier + export const ${exportName} = Uint8Array.from([${wasmBinary.toString()}]); `; diff --git a/packages/as-sha256/src/index.ts b/packages/as-sha256/src/index.ts index 093024d55..685137f5b 100644 --- a/packages/as-sha256/src/index.ts +++ b/packages/as-sha256/src/index.ts @@ -1,8 +1,8 @@ import {allocUnsafe} from "./alloc.js"; -import {newInstance, WasmContext} from "./wasm.js"; import type {HashObject} from "./hashObject.js"; import {byteArrayIntoHashObject, byteArrayToHashObject, hashObjectToByteArray} from "./hashObject.js"; import SHA256 from "./sha256.js"; +import {WasmContext, newInstance} from "./wasm.js"; export {HashObject, byteArrayToHashObject, hashObjectToByteArray, byteArrayIntoHashObject, SHA256}; export {allocUnsafe}; diff --git a/packages/as-sha256/src/sha256.ts b/packages/as-sha256/src/sha256.ts index 16b38302a..ee535e98a 100644 --- a/packages/as-sha256/src/sha256.ts +++ b/packages/as-sha256/src/sha256.ts @@ -1,4 +1,4 @@ -import {newInstance, WasmContext} from "./wasm.js"; +import {WasmContext, newInstance} from "./wasm.js"; /** * Class based SHA256 diff --git a/packages/as-sha256/src/wasm.ts b/packages/as-sha256/src/wasm.ts index b30145689..8d8df0b3b 100644 --- a/packages/as-sha256/src/wasm.ts +++ b/packages/as-sha256/src/wasm.ts @@ -28,7 +28,7 @@ export interface WasmContext { const importObj = { env: { // modified from https://github.com/AssemblyScript/assemblyscript/blob/v0.9.2/lib/loader/index.js#L70 - abort: function (msg: number, file: number, line: number, col: number) { + abort: (msg: number, file: number, line: number, col: number) => { throw Error(`abort: ${msg}:${file}:${line}:${col}`); }, }, diff --git a/packages/as-sha256/src/wasmCode.ts b/packages/as-sha256/src/wasmCode.ts index 6a57a84be..804194524 100644 --- a/packages/as-sha256/src/wasmCode.ts +++ b/packages/as-sha256/src/wasmCode.ts @@ -1,6 +1,5 @@ // This file was autogenerated by scripts/codegen.ts // DO NOT modify this file by hand! -// eslint-disable-next-line prettier/prettier - +// biome-ignore format: export const wasmCode = Uint8Array.from([0,97,115,109,1,0,0,0,1,43,8,96,2,127,127,0,96,1,127,0,96,1,127,1,127,96,2,127,127,1,127,96,0,0,96,3,127,127,127,0,96,4,127,127,127,127,0,96,3,127,127,126,0,2,13,1,3,101,110,118,5,97,98,111,114,116,0,6,3,23,22,0,0,0,0,0,7,2,3,3,2,4,5,1,2,5,0,1,1,0,1,1,4,5,3,1,0,1,6,187,1,37,127,0,65,4,11,127,0,65,128,4,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,0,65,0,11,7,169,1,13,8,72,65,83,95,83,73,77,68,3,36,22,98,97,116,99,104,72,97,115,104,52,85,105,110,116,65,114,114,97,121,54,52,115,0,17,26,98,97,116,99,104,72,97,115,104,52,72,97,115,104,79,98,106,101,99,116,73,110,112,117,116,115,0,18,12,73,78,80,85,84,95,76,69,78,71,84,72,3,1,15,80,65,82,65,76,76,69,76,95,70,65,67,84,79,82,3,0,5,105,110,112,117,116,3,30,6,111,117,116,112,117,116,3,32,4,105,110,105,116,0,11,6,117,112,100,97,116,101,0,19,5,102,105,110,97,108,0,20,6,100,105,103,101,115,116,0,21,8,100,105,103,101,115,116,54,52,0,16,6,109,101,109,111,114,121,2,0,8,1,22,12,1,18,10,196,23,22,9,0,32,0,32,1,54,2,0,11,9,0,32,0,32,1,54,2,4,11,9,0,32,0,32,1,54,2,8,11,192,1,1,4,127,32,1,40,2,0,65,124,113,34,3,65,128,2,73,4,127,32,3,65,4,118,5,65,31,65,252,255,255,255,3,32,3,32,3,65,252,255,255,255,3,79,27,34,3,103,107,34,4,65,7,107,33,2,32,3,32,4,65,4,107,118,65,16,115,11,33,3,32,1,40,2,8,33,5,32,1,40,2,4,34,4,4,64,32,4,32,5,16,3,11,32,5,4,64,32,5,32,4,16,2,11,32,1,32,0,32,2,65,4,116,32,3,106,65,2,116,106,34,1,40,2,96,70,4,64,32,1,32,5,54,2,96,32,5,69,4,64,32,0,32,2,65,2,116,106,34,1,40,2,4,65,126,32,3,119,113,33,3,32,1,32,3,54,2,4,32,3,69,4,64,32,0,32,0,40,2,0,65,126,32,2,119,113,16,1,11,11,11,11,181,2,1,5,127,32,1,40,2,0,33,3,32,1,65,4,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,34,2,65,1,113,4,64,32,0,32,4,16,4,32,1,32,3,65,4,106,32,2,65,124,113,106,34,3,16,1,32,1,65,4,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,33,2,11,32,3,65,2,113,4,64,32,1,65,4,107,40,2,0,34,1,40,2,0,33,6,32,0,32,1,16,4,32,1,32,6,65,4,106,32,3,65,124,113,106,34,3,16,1,11,32,4,32,2,65,2,114,16,1,32,4,65,4,107,32,1,54,2,0,32,0,32,3,65,124,113,34,2,65,128,2,73,4,127,32,2,65,4,118,5,65,31,65,252,255,255,255,3,32,2,32,2,65,252,255,255,255,3,79,27,34,2,103,107,34,3,65,7,107,33,5,32,2,32,3,65,4,107,118,65,16,115,11,34,2,32,5,65,4,116,106,65,2,116,106,40,2,96,33,3,32,1,65,0,16,2,32,1,32,3,16,3,32,3,4,64,32,3,32,1,16,2,11,32,0,32,5,65,4,116,32,2,106,65,2,116,106,32,1,54,2,96,32,0,32,0,40,2,0,65,1,32,5,116,114,16,1,32,0,32,5,65,2,116,106,34,0,32,0,40,2,4,65,1,32,2,116,114,54,2,4,11,130,1,1,3,127,32,1,65,19,106,65,112,113,65,4,107,33,1,32,0,40,2,160,12,34,3,4,64,32,3,32,1,65,16,107,34,5,70,4,64,32,3,40,2,0,33,4,32,5,33,1,11,11,32,2,167,65,112,113,32,1,107,34,3,65,20,73,4,64,15,11,32,1,32,4,65,2,113,32,3,65,8,107,34,3,65,1,114,114,16,1,32,1,65,0,16,2,32,1,65,0,16,3,32,1,65,4,106,32,3,106,34,3,65,2,16,1,32,0,32,3,54,2,160,12,32,0,32,1,16,5,11,29,0,32,0,65,1,65,27,32,0,103,107,116,106,65,1,107,32,0,32,0,65,254,255,255,255,1,73,27,11,142,1,1,2,127,32,1,65,128,2,73,4,127,32,1,65,4,118,5,65,31,32,1,16,7,34,1,103,107,34,3,65,7,107,33,2,32,1,32,3,65,4,107,118,65,16,115,11,33,1,32,0,32,2,65,2,116,106,40,2,4,65,127,32,1,116,113,34,1,4,127,32,0,32,1,104,32,2,65,4,116,106,65,2,116,106,40,2,96,5,32,0,40,2,0,65,127,32,2,65,1,106,116,113,34,1,4,127,32,0,32,0,32,1,104,34,0,65,2,116,106,40,2,4,104,32,0,65,4,116,106,65,2,116,106,40,2,96,5,65,0,11,11,11,148,2,1,3,127,32,1,65,252,255,255,255,3,75,4,64,65,176,14,65,176,15,65,205,3,65,29,16,0,0,11,32,0,65,12,32,1,65,19,106,65,112,113,65,4,107,32,1,65,12,77,27,34,1,16,8,34,2,69,4,64,32,1,65,128,2,79,4,127,32,1,16,7,5,32,1,11,33,2,63,0,34,3,32,2,65,4,32,0,40,2,160,12,32,3,65,16,116,65,4,107,71,116,106,65,255,255,3,106,65,128,128,124,113,65,16,118,34,2,32,2,32,3,72,27,64,0,65,0,72,4,64,32,2,64,0,65,0,72,4,64,0,11,11,32,0,32,3,65,16,116,63,0,172,66,16,134,16,6,32,0,32,1,16,8,33,2,11,32,2,40,2,0,26,32,0,32,2,16,4,32,2,40,2,0,34,3,65,124,113,32,1,107,34,4,65,16,79,4,64,32,2,32,1,32,3,65,2,113,114,16,1,32,2,65,4,106,32,1,106,34,1,32,4,65,4,107,65,1,114,16,1,32,0,32,1,16,5,5,32,2,32,3,65,126,113,16,1,32,2,65,4,106,32,2,40,2,0,65,124,113,106,34,0,32,0,40,2,0,65,125,113,16,1,11,32,2,11,169,2,1,3,127,32,0,65,252,255,255,255,3,75,4,64,65,192,13,65,240,13,65,52,65,43,16,0,0,11,32,0,65,236,255,255,255,3,75,4,64,65,176,14,65,240,14,65,253,0,65,30,16,0,0,11,35,23,69,4,64,63,0,34,2,65,0,76,4,127,65,1,32,2,107,64,0,65,0,72,5,65,0,11,4,64,0,11,65,128,16,65,0,16,1,65,160,28,65,0,54,2,0,3,64,32,1,65,23,73,4,64,32,1,65,2,116,65,128,16,106,65,0,54,2,4,65,0,33,2,3,64,32,2,65,16,73,4,64,32,1,65,4,116,32,2,106,65,2,116,65,128,16,106,65,0,54,2,96,32,2,65,1,106,33,2,12,1,11,11,32,1,65,1,106,33,1,12,1,11,11,65,128,16,65,164,28,63,0,172,66,16,134,16,6,65,128,16,36,23,11,35,23,32,0,65,16,106,16,9,34,2,65,1,54,2,12,32,2,32,0,54,2,16,35,24,34,3,40,2,8,33,1,32,2,32,3,16,2,32,2,32,1,16,3,32,1,32,2,32,1,40,2,4,65,3,113,114,16,2,32,3,32,2,16,3,35,25,32,2,40,2,0,65,124,113,65,4,106,106,36,25,32,2,65,20,106,34,1,65,0,32,0,252,11,0,32,1,11,74,0,65,231,204,167,208,6,36,4,65,133,221,158,219,123,36,5,65,242,230,187,227,3,36,6,65,186,234,191,170,122,36,7,65,255,164,185,136,5,36,8,65,140,209,149,216,121,36,9,65,171,179,143,252,1,36,10,65,153,154,131,223,5,36,11,65,0,36,34,65,0,36,35,11,233,3,1,1,127,35,4,36,12,35,5,36,13,35,6,36,14,35,7,36,15,35,8,36,16,35,9,36,17,35,10,36,18,35,11,36,19,65,0,36,20,3,64,35,20,65,16,73,4,64,32,0,35,20,65,2,116,106,32,1,35,20,32,2,108,65,2,116,34,3,65,3,106,106,45,0,0,32,1,32,3,106,45,0,0,65,24,116,32,1,32,3,65,1,106,106,45,0,0,65,16,116,114,32,1,32,3,65,2,106,106,45,0,0,65,8,116,114,114,54,2,0,35,20,65,1,106,36,20,12,1,11,11,65,16,36,20,3,64,35,20,65,192,0,73,4,64,32,0,35,20,65,2,116,106,32,0,35,20,65,16,107,65,2,116,106,40,2,0,32,0,35,20,65,7,107,65,2,116,106,40,2,0,32,0,35,20,65,2,107,65,2,116,106,40,2,0,34,1,65,17,120,32,1,65,19,120,115,32,1,65,10,118,115,106,32,0,35,20,65,15,107,65,2,116,106,40,2,0,34,1,65,7,120,32,1,65,18,120,115,32,1,65,3,118,115,106,106,54,2,0,35,20,65,1,106,36,20,12,1,11,11,65,0,36,20,3,64,35,20,65,192,0,73,4,64,32,0,35,20,65,2,116,34,1,106,40,2,0,32,1,35,2,106,40,2,0,35,19,35,16,34,1,65,6,120,32,1,65,11,120,115,32,1,65,25,120,115,106,35,16,34,1,35,17,113,35,18,32,1,65,127,115,113,115,106,106,106,36,21,35,12,34,1,65,2,120,32,1,65,13,120,115,32,1,65,22,120,115,35,13,34,1,35,14,34,2,113,32,1,35,12,34,1,113,32,1,32,2,113,115,115,106,36,22,35,18,36,19,35,17,36,18,35,16,36,17,35,15,35,21,106,36,16,35,14,36,15,35,13,36,14,35,12,36,13,35,21,35,22,106,36,12,35,20,65,1,106,36,20,12,1,11,11,35,4,35,12,106,36,4,35,5,35,13,106,36,5,35,6,35,14,106,36,6,35,7,35,15,106,36,7,35,8,35,16,106,36,8,35,9,35,17,106,36,9,35,10,35,18,106,36,10,35,11,35,19,106,36,11,11,253,1,1,2,127,35,4,36,12,35,5,36,13,35,6,36,14,35,7,36,15,35,8,36,16,35,9,36,17,35,10,36,18,35,11,36,19,65,0,36,20,3,64,35,20,65,192,0,73,4,64,32,0,35,20,65,2,116,106,40,2,0,35,19,35,16,34,1,65,6,120,32,1,65,11,120,115,32,1,65,25,120,115,106,35,16,34,1,35,17,113,35,18,32,1,65,127,115,113,115,106,106,36,21,35,12,34,1,65,2,120,32,1,65,13,120,115,32,1,65,22,120,115,35,13,34,2,35,14,34,1,113,32,2,35,12,34,2,113,32,1,32,2,113,115,115,106,36,22,35,18,36,19,35,17,36,18,35,16,36,17,35,15,35,21,106,36,16,35,14,36,15,35,13,36,14,35,12,36,13,35,21,35,22,106,36,12,35,20,65,1,106,36,20,12,1,11,11,35,4,35,12,106,36,4,35,5,35,13,106,36,5,35,6,35,14,106,36,6,35,7,35,15,106,36,7,35,8,35,16,106,36,8,35,9,35,17,106,36,9,35,10,35,18,106,36,10,35,11,35,19,106,36,11,11,25,0,32,0,65,128,254,131,120,113,65,8,119,32,0,65,255,129,252,7,113,65,8,120,114,11,88,0,16,11,35,29,32,0,32,2,16,12,35,3,16,13,32,1,35,4,16,14,54,2,0,32,1,35,5,16,14,54,2,4,32,1,35,6,16,14,54,2,8,32,1,35,7,16,14,54,2,12,32,1,35,8,16,14,54,2,16,32,1,35,9,16,14,54,2,20,32,1,35,10,16,14,54,2,24,32,1,35,11,16,14,54,2,28,11,10,0,32,0,32,1,65,1,16,15,11,42,1,1,127,3,64,32,1,65,4,72,4,64,35,31,32,1,65,6,116,106,32,0,32,1,65,5,116,106,16,16,32,1,65,1,106,33,1,12,1,11,11,11,44,1,1,127,3,64,32,1,65,4,72,4,64,35,31,32,1,65,2,116,106,32,0,32,1,65,5,116,106,65,4,16,15,32,1,65,1,106,33,1,12,1,11,11,11,178,1,1,2,127,35,35,32,1,106,36,35,35,34,4,64,65,192,0,35,34,107,34,2,32,1,76,4,64,35,27,35,34,106,32,0,32,2,252,10,0,0,35,34,32,2,106,36,34,65,192,0,35,34,107,33,2,32,1,65,192,0,35,34,107,107,33,1,35,29,35,27,65,1,16,12,65,0,36,34,5,35,27,35,34,106,32,0,32,1,252,10,0,0,35,34,32,1,106,36,34,15,11,11,3,64,32,3,32,1,65,192,0,109,72,4,64,35,29,32,0,32,2,106,65,1,16,12,32,3,65,1,106,33,3,32,2,65,64,107,33,2,12,1,11,11,32,1,65,63,113,34,1,4,64,35,27,35,34,106,32,0,32,2,106,32,1,252,10,0,0,35,34,32,1,106,36,34,11,11,150,2,1,2,127,35,35,65,63,113,65,63,73,4,64,35,27,35,34,106,65,128,1,58,0,0,35,34,65,1,106,36,34,11,35,35,65,63,113,65,56,79,4,64,35,27,35,34,106,34,1,65,192,0,35,34,107,106,33,2,3,64,32,1,32,2,73,4,64,32,1,65,0,58,0,0,32,1,65,1,106,33,1,12,1,11,11,35,29,35,27,65,1,16,12,65,0,36,34,11,35,35,65,63,113,65,63,79,4,64,35,27,35,34,106,65,128,1,58,0,0,35,34,65,1,106,36,34,11,35,27,35,34,106,34,1,65,56,35,34,107,106,33,2,3,64,32,1,32,2,73,4,64,32,1,65,0,58,0,0,32,1,65,1,106,33,1,12,1,11,11,35,27,35,35,65,128,128,128,128,2,109,16,14,54,2,56,35,27,35,35,65,3,116,16,14,54,2,60,35,29,35,27,65,1,16,12,32,0,35,4,16,14,54,2,0,32,0,35,5,16,14,54,2,4,32,0,35,6,16,14,54,2,8,32,0,35,7,16,14,54,2,12,32,0,35,8,16,14,54,2,16,32,0,35,9,16,14,54,2,20,32,0,35,10,16,14,54,2,24,32,0,35,11,16,14,54,2,28,11,14,0,16,11,35,31,32,0,16,19,35,33,16,20,11,82,0,65,196,10,40,2,0,36,2,65,148,13,40,2,0,36,3,65,224,15,65,224,15,16,2,65,224,15,65,224,15,16,3,65,224,15,36,24,65,192,0,16,10,36,26,35,26,36,27,65,128,8,16,10,36,28,35,28,36,29,65,128,4,16,10,36,30,35,30,36,31,65,32,16,10,36,32,35,32,36,33,11,11,253,6,18,0,65,140,8,11,2,28,1,0,65,152,8,11,136,2,1,0,0,0,0,1,0,0,152,47,138,66,145,68,55,113,207,251,192,181,165,219,181,233,91,194,86,57,241,17,241,89,164,130,63,146,213,94,28,171,152,170,7,216,1,91,131,18,190,133,49,36,195,125,12,85,116,93,190,114,254,177,222,128,167,6,220,155,116,241,155,193,193,105,155,228,134,71,190,239,198,157,193,15,204,161,12,36,111,44,233,45,170,132,116,74,220,169,176,92,218,136,249,118,82,81,62,152,109,198,49,168,200,39,3,176,199,127,89,191,243,11,224,198,71,145,167,213,81,99,202,6,103,41,41,20,133,10,183,39,56,33,27,46,252,109,44,77,19,13,56,83,84,115,10,101,187,10,106,118,46,201,194,129,133,44,114,146,161,232,191,162,75,102,26,168,112,139,75,194,163,81,108,199,25,232,146,209,36,6,153,214,133,53,14,244,112,160,106,16,22,193,164,25,8,108,55,30,76,119,72,39,181,188,176,52,179,12,28,57,74,170,216,78,79,202,156,91,243,111,46,104,238,130,143,116,111,99,165,120,20,120,200,132,8,2,199,140,250,255,190,144,235,108,80,164,247,163,249,190,242,120,113,198,0,65,172,10,11,1,44,0,65,184,10,11,21,4,0,0,0,16,0,0,0,32,4,0,0,32,4,0,0,0,1,0,0,64,0,65,220,10,11,2,28,1,0,65,232,10,11,136,2,1,0,0,0,0,1,0,0,152,47,138,194,145,68,55,113,207,251,192,181,165,219,181,233,91,194,86,57,241,17,241,89,164,130,63,146,213,94,28,171,152,170,7,216,1,91,131,18,190,133,49,36,195,125,12,85,116,93,190,114,254,177,222,128,167,6,220,155,116,243,155,193,193,105,155,100,134,71,254,240,198,237,225,15,84,242,12,36,111,52,233,79,190,132,201,108,30,65,185,97,250,136,249,22,82,81,198,242,109,90,142,168,101,252,25,176,199,158,217,185,195,49,18,154,160,234,14,231,43,35,177,253,176,62,53,199,213,186,105,48,95,109,151,203,143,17,15,90,253,238,30,220,137,182,53,10,4,122,11,222,157,202,244,88,22,91,93,225,134,62,127,0,128,137,8,55,50,234,7,165,55,149,171,111,16,97,64,23,241,214,140,13,109,59,170,205,55,190,187,192,218,59,97,131,99,163,72,219,49,233,2,11,167,92,209,111,202,250,26,82,49,132,51,49,149,26,212,110,144,120,67,109,242,145,156,195,189,171,204,158,230,160,201,181,60,182,47,83,198,65,199,210,163,126,35,7,104,75,149,164,118,29,25,76,0,65,252,12,11,1,44,0,65,136,13,11,21,4,0,0,0,16,0,0,0,112,5,0,0,112,5,0,0,0,1,0,0,64,0,65,172,13,11,1,44,0,65,184,13,11,35,2,0,0,0,28,0,0,0,73,0,110,0,118,0,97,0,108,0,105,0,100,0,32,0,108,0,101,0,110,0,103,0,116,0,104,0,65,220,13,11,1,60,0,65,232,13,11,45,2,0,0,0,38,0,0,0,126,0,108,0,105,0,98,0,47,0,97,0,114,0,114,0,97,0,121,0,98,0,117,0,102,0,102,0,101,0,114,0,46,0,116,0,115,0,65,156,14,11,1,60,0,65,168,14,11,47,2,0,0,0,40,0,0,0,65,0,108,0,108,0,111,0,99,0,97,0,116,0,105,0,111,0,110,0,32,0,116,0,111,0,111,0,32,0,108,0,97,0,114,0,103,0,101,0,65,220,14,11,1,60,0,65,232,14,11,37,2,0,0,0,30,0,0,0,126,0,108,0,105,0,98,0,47,0,114,0,116,0,47,0,116,0,99,0,109,0,115,0,46,0,116,0,115,0,65,156,15,11,1,60,0,65,168,15,11,37,2,0,0,0,30,0,0,0,126,0,108,0,105,0,98,0,47,0,114,0,116,0,47,0,116,0,108,0,115,0,102,0,46,0,116,0,115]); diff --git a/packages/as-sha256/src/wasmSimdCode.ts b/packages/as-sha256/src/wasmSimdCode.ts index 7209726ff..2ec88fc4f 100644 --- a/packages/as-sha256/src/wasmSimdCode.ts +++ b/packages/as-sha256/src/wasmSimdCode.ts @@ -1,6 +1,5 @@ // This file was autogenerated by scripts/codegen.ts // DO NOT modify this file by hand! -// eslint-disable-next-line prettier/prettier - +// biome-ignore format: export const wasmSimdCode = Uint8Array.from([0,97,115,109,1,0,0,0,1,37,7,96,2,127,127,0,96,1,127,1,127,96,2,127,127,1,127,96,1,127,0,96,0,0,96,4,127,127,127,127,0,96,3,127,127,126,0,2,13,1,3,101,110,118,5,97,98,111,114,116,0,5,3,30,29,0,0,0,0,0,6,1,2,2,2,1,2,1,1,2,4,4,1,0,3,3,4,0,0,3,3,3,0,4,5,3,1,0,1,6,227,4,61,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,127,1,65,0,11,123,1,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,0,65,4,11,127,0,65,128,4,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,0,65,1,11,7,169,1,13,8,72,65,83,95,83,73,77,68,3,60,22,98,97,116,99,104,72,97,115,104,52,85,105,110,116,65,114,114,97,121,54,52,115,0,20,26,98,97,116,99,104,72,97,115,104,52,72,97,115,104,79,98,106,101,99,116,73,110,112,117,116,115,0,21,12,73,78,80,85,84,95,76,69,78,71,84,72,3,28,15,80,65,82,65,76,76,69,76,95,70,65,67,84,79,82,3,27,5,105,110,112,117,116,3,54,6,111,117,116,112,117,116,3,56,4,105,110,105,116,0,22,6,117,112,100,97,116,101,0,24,5,102,105,110,97,108,0,25,6,100,105,103,101,115,116,0,26,8,100,105,103,101,115,116,54,52,0,28,6,109,101,109,111,114,121,2,0,8,1,29,12,1,38,10,158,112,29,9,0,32,0,32,1,54,2,0,11,9,0,32,0,32,1,54,2,4,11,9,0,32,0,32,1,54,2,8,11,192,1,1,4,127,32,1,40,2,0,65,124,113,34,3,65,128,2,73,4,127,32,3,65,4,118,5,65,31,65,252,255,255,255,3,32,3,32,3,65,252,255,255,255,3,79,27,34,3,103,107,34,4,65,7,107,33,2,32,3,32,4,65,4,107,118,65,16,115,11,33,3,32,1,40,2,8,33,5,32,1,40,2,4,34,4,4,64,32,4,32,5,16,3,11,32,5,4,64,32,5,32,4,16,2,11,32,1,32,0,32,2,65,4,116,32,3,106,65,2,116,106,34,1,40,2,96,70,4,64,32,1,32,5,54,2,96,32,5,69,4,64,32,0,32,2,65,2,116,106,34,1,40,2,4,65,126,32,3,119,113,33,3,32,1,32,3,54,2,4,32,3,69,4,64,32,0,32,0,40,2,0,65,126,32,2,119,113,16,1,11,11,11,11,181,2,1,5,127,32,1,40,2,0,33,3,32,1,65,4,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,34,2,65,1,113,4,64,32,0,32,4,16,4,32,1,32,3,65,4,106,32,2,65,124,113,106,34,3,16,1,32,1,65,4,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,33,2,11,32,3,65,2,113,4,64,32,1,65,4,107,40,2,0,34,1,40,2,0,33,6,32,0,32,1,16,4,32,1,32,6,65,4,106,32,3,65,124,113,106,34,3,16,1,11,32,4,32,2,65,2,114,16,1,32,4,65,4,107,32,1,54,2,0,32,0,32,3,65,124,113,34,2,65,128,2,73,4,127,32,2,65,4,118,5,65,31,65,252,255,255,255,3,32,2,32,2,65,252,255,255,255,3,79,27,34,2,103,107,34,3,65,7,107,33,5,32,2,32,3,65,4,107,118,65,16,115,11,34,2,32,5,65,4,116,106,65,2,116,106,40,2,96,33,3,32,1,65,0,16,2,32,1,32,3,16,3,32,3,4,64,32,3,32,1,16,2,11,32,0,32,5,65,4,116,32,2,106,65,2,116,106,32,1,54,2,96,32,0,32,0,40,2,0,65,1,32,5,116,114,16,1,32,0,32,5,65,2,116,106,34,0,32,0,40,2,4,65,1,32,2,116,114,54,2,4,11,130,1,1,3,127,32,1,65,19,106,65,112,113,65,4,107,33,1,32,0,40,2,160,12,34,3,4,64,32,3,32,1,65,16,107,34,5,70,4,64,32,3,40,2,0,33,4,32,5,33,1,11,11,32,2,167,65,112,113,32,1,107,34,3,65,20,73,4,64,15,11,32,1,32,4,65,2,113,32,3,65,8,107,34,3,65,1,114,114,16,1,32,1,65,0,16,2,32,1,65,0,16,3,32,1,65,4,106,32,3,106,34,3,65,2,16,1,32,0,32,3,54,2,160,12,32,0,32,1,16,5,11,29,0,32,0,65,1,65,27,32,0,103,107,116,106,65,1,107,32,0,32,0,65,254,255,255,255,1,73,27,11,142,1,1,2,127,32,1,65,128,2,73,4,127,32,1,65,4,118,5,65,31,32,1,16,7,34,1,103,107,34,3,65,7,107,33,2,32,1,32,3,65,4,107,118,65,16,115,11,33,1,32,0,32,2,65,2,116,106,40,2,4,65,127,32,1,116,113,34,1,4,127,32,0,32,1,104,32,2,65,4,116,106,65,2,116,106,40,2,96,5,32,0,40,2,0,65,127,32,2,65,1,106,116,113,34,1,4,127,32,0,32,0,32,1,104,34,0,65,2,116,106,40,2,4,104,32,0,65,4,116,106,65,2,116,106,40,2,96,5,65,0,11,11,11,148,2,1,3,127,32,1,65,252,255,255,255,3,75,4,64,65,176,14,65,176,15,65,205,3,65,29,16,0,0,11,32,0,65,12,32,1,65,19,106,65,112,113,65,4,107,32,1,65,12,77,27,34,1,16,8,34,2,69,4,64,32,1,65,128,2,79,4,127,32,1,16,7,5,32,1,11,33,2,63,0,34,3,32,2,65,4,32,0,40,2,160,12,32,3,65,16,116,65,4,107,71,116,106,65,255,255,3,106,65,128,128,124,113,65,16,118,34,2,32,2,32,3,72,27,64,0,65,0,72,4,64,32,2,64,0,65,0,72,4,64,0,11,11,32,0,32,3,65,16,116,63,0,172,66,16,134,16,6,32,0,32,1,16,8,33,2,11,32,2,40,2,0,26,32,0,32,2,16,4,32,2,40,2,0,34,3,65,124,113,32,1,107,34,4,65,16,79,4,64,32,2,32,1,32,3,65,2,113,114,16,1,32,2,65,4,106,32,1,106,34,1,32,4,65,4,107,65,1,114,16,1,32,0,32,1,16,5,5,32,2,32,3,65,126,113,16,1,32,2,65,4,106,32,2,40,2,0,65,124,113,106,34,0,32,0,40,2,0,65,125,113,16,1,11,32,2,11,133,2,1,2,127,32,0,65,236,255,255,255,3,75,4,64,65,176,14,65,240,14,65,253,0,65,30,16,0,0,11,35,20,69,4,64,63,0,34,3,65,0,76,4,127,65,1,32,3,107,64,0,65,0,72,5,65,0,11,4,64,0,11,65,208,21,65,0,16,1,65,240,33,65,0,54,2,0,3,64,32,2,65,23,73,4,64,32,2,65,2,116,65,208,21,106,65,0,54,2,4,65,0,33,3,3,64,32,3,65,16,73,4,64,32,2,65,4,116,32,3,106,65,2,116,65,208,21,106,65,0,54,2,96,32,3,65,1,106,33,3,12,1,11,11,32,2,65,1,106,33,2,12,1,11,11,65,208,21,65,244,33,63,0,172,66,16,134,16,6,65,208,21,36,20,11,35,20,32,0,65,16,106,16,9,34,2,32,1,54,2,12,32,2,32,0,54,2,16,35,21,34,0,40,2,8,33,1,32,2,32,0,16,2,32,2,32,1,16,3,32,1,32,2,32,1,40,2,4,65,3,113,114,16,2,32,0,32,2,16,3,35,22,32,2,40,2,0,65,124,113,65,4,106,106,36,22,32,2,65,20,106,11,46,1,1,127,32,0,65,252,255,255,255,3,75,4,64,65,192,13,65,240,13,65,52,65,43,16,0,0,11,32,0,65,1,16,10,34,1,65,0,32,0,252,11,0,32,1,11,41,0,32,1,32,0,40,2,12,79,4,64,65,144,16,65,208,16,65,242,0,65,42,16,0,0,11,32,0,40,2,4,32,1,65,2,116,106,40,2,0,11,181,1,1,4,127,32,0,69,4,64,65,192,18,15,11,65,0,32,0,107,32,0,32,0,65,31,118,65,1,116,34,1,27,34,0,65,10,79,65,1,106,32,0,65,144,206,0,79,65,3,106,32,0,65,232,7,79,106,32,0,65,228,0,73,27,32,0,65,192,132,61,79,65,6,106,32,0,65,128,148,235,220,3,79,65,8,106,32,0,65,128,194,215,47,79,106,32,0,65,128,173,226,4,73,27,32,0,65,160,141,6,73,27,34,2,65,1,116,32,1,106,65,2,16,10,34,3,32,1,106,33,4,3,64,32,4,32,2,65,1,107,34,2,65,1,116,106,32,0,65,10,112,65,48,106,59,1,0,32,0,65,10,110,34,0,13,0,11,32,1,4,64,32,3,65,45,59,1,0,11,32,3,11,13,0,32,0,65,20,107,40,2,16,65,1,118,11,64,1,3,127,32,0,16,14,65,1,116,34,2,32,1,16,14,65,1,116,34,3,106,34,4,69,4,64,65,160,20,15,11,32,4,65,2,16,10,34,4,32,0,32,2,252,10,0,0,32,2,32,4,106,32,1,32,3,252,10,0,0,32,4,11,145,16,2,2,127,1,123,65,224,15,65,224,15,16,2,65,224,15,65,224,15,16,3,65,224,15,36,21,65,128,8,16,11,36,23,35,23,36,24,2,64,3,64,32,0,65,192,0,72,4,64,35,24,33,1,65,192,10,32,0,16,12,253,17,33,2,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,32,0,14,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,67,11,32,1,32,2,253,11,4,0,12,63,11,32,1,32,2,253,11,4,16,12,62,11,32,1,32,2,253,11,4,32,12,61,11,32,1,32,2,253,11,4,48,12,60,11,32,1,32,2,253,11,4,64,12,59,11,32,1,32,2,253,11,4,80,12,58,11,32,1,32,2,253,11,4,96,12,57,11,32,1,32,2,253,11,4,112,12,56,11,32,1,32,2,253,11,4,128,1,12,55,11,32,1,32,2,253,11,4,144,1,12,54,11,32,1,32,2,253,11,4,160,1,12,53,11,32,1,32,2,253,11,4,176,1,12,52,11,32,1,32,2,253,11,4,192,1,12,51,11,32,1,32,2,253,11,4,208,1,12,50,11,32,1,32,2,253,11,4,224,1,12,49,11,32,1,32,2,253,11,4,240,1,12,48,11,32,1,32,2,253,11,4,128,2,12,47,11,32,1,32,2,253,11,4,144,2,12,46,11,32,1,32,2,253,11,4,160,2,12,45,11,32,1,32,2,253,11,4,176,2,12,44,11,32,1,32,2,253,11,4,192,2,12,43,11,32,1,32,2,253,11,4,208,2,12,42,11,32,1,32,2,253,11,4,224,2,12,41,11,32,1,32,2,253,11,4,240,2,12,40,11,32,1,32,2,253,11,4,128,3,12,39,11,32,1,32,2,253,11,4,144,3,12,38,11,32,1,32,2,253,11,4,160,3,12,37,11,32,1,32,2,253,11,4,176,3,12,36,11,32,1,32,2,253,11,4,192,3,12,35,11,32,1,32,2,253,11,4,208,3,12,34,11,32,1,32,2,253,11,4,224,3,12,33,11,32,1,32,2,253,11,4,240,3,12,32,11,32,1,32,2,253,11,4,128,4,12,31,11,32,1,32,2,253,11,4,144,4,12,30,11,32,1,32,2,253,11,4,160,4,12,29,11,32,1,32,2,253,11,4,176,4,12,28,11,32,1,32,2,253,11,4,192,4,12,27,11,32,1,32,2,253,11,4,208,4,12,26,11,32,1,32,2,253,11,4,224,4,12,25,11,32,1,32,2,253,11,4,240,4,12,24,11,32,1,32,2,253,11,4,128,5,12,23,11,32,1,32,2,253,11,4,144,5,12,22,11,32,1,32,2,253,11,4,160,5,12,21,11,32,1,32,2,253,11,4,176,5,12,20,11,32,1,32,2,253,11,4,192,5,12,19,11,32,1,32,2,253,11,4,208,5,12,18,11,32,1,32,2,253,11,4,224,5,12,17,11,32,1,32,2,253,11,4,240,5,12,16,11,32,1,32,2,253,11,4,128,6,12,15,11,32,1,32,2,253,11,4,144,6,12,14,11,32,1,32,2,253,11,4,160,6,12,13,11,32,1,32,2,253,11,4,176,6,12,12,11,32,1,32,2,253,11,4,192,6,12,11,11,32,1,32,2,253,11,4,208,6,12,10,11,32,1,32,2,253,11,4,224,6,12,9,11,32,1,32,2,253,11,4,240,6,12,8,11,32,1,32,2,253,11,4,128,7,12,7,11,32,1,32,2,253,11,4,144,7,12,6,11,32,1,32,2,253,11,4,160,7,12,5,11,32,1,32,2,253,11,4,176,7,12,4,11,32,1,32,2,253,11,4,192,7,12,3,11,32,1,32,2,253,11,4,208,7,12,2,11,32,1,32,2,253,11,4,224,7,12,1,11,32,1,32,2,253,11,4,240,7,11,32,0,65,1,106,33,0,12,1,11,11,65,128,8,16,11,36,25,35,25,36,26,65,0,33,0,3,64,32,0,65,192,0,72,4,64,35,26,33,1,65,144,13,32,0,16,12,253,17,33,2,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,32,0,14,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,67,11,32,1,32,2,253,11,4,0,12,63,11,32,1,32,2,253,11,4,16,12,62,11,32,1,32,2,253,11,4,32,12,61,11,32,1,32,2,253,11,4,48,12,60,11,32,1,32,2,253,11,4,64,12,59,11,32,1,32,2,253,11,4,80,12,58,11,32,1,32,2,253,11,4,96,12,57,11,32,1,32,2,253,11,4,112,12,56,11,32,1,32,2,253,11,4,128,1,12,55,11,32,1,32,2,253,11,4,144,1,12,54,11,32,1,32,2,253,11,4,160,1,12,53,11,32,1,32,2,253,11,4,176,1,12,52,11,32,1,32,2,253,11,4,192,1,12,51,11,32,1,32,2,253,11,4,208,1,12,50,11,32,1,32,2,253,11,4,224,1,12,49,11,32,1,32,2,253,11,4,240,1,12,48,11,32,1,32,2,253,11,4,128,2,12,47,11,32,1,32,2,253,11,4,144,2,12,46,11,32,1,32,2,253,11,4,160,2,12,45,11,32,1,32,2,253,11,4,176,2,12,44,11,32,1,32,2,253,11,4,192,2,12,43,11,32,1,32,2,253,11,4,208,2,12,42,11,32,1,32,2,253,11,4,224,2,12,41,11,32,1,32,2,253,11,4,240,2,12,40,11,32,1,32,2,253,11,4,128,3,12,39,11,32,1,32,2,253,11,4,144,3,12,38,11,32,1,32,2,253,11,4,160,3,12,37,11,32,1,32,2,253,11,4,176,3,12,36,11,32,1,32,2,253,11,4,192,3,12,35,11,32,1,32,2,253,11,4,208,3,12,34,11,32,1,32,2,253,11,4,224,3,12,33,11,32,1,32,2,253,11,4,240,3,12,32,11,32,1,32,2,253,11,4,128,4,12,31,11,32,1,32,2,253,11,4,144,4,12,30,11,32,1,32,2,253,11,4,160,4,12,29,11,32,1,32,2,253,11,4,176,4,12,28,11,32,1,32,2,253,11,4,192,4,12,27,11,32,1,32,2,253,11,4,208,4,12,26,11,32,1,32,2,253,11,4,224,4,12,25,11,32,1,32,2,253,11,4,240,4,12,24,11,32,1,32,2,253,11,4,128,5,12,23,11,32,1,32,2,253,11,4,144,5,12,22,11,32,1,32,2,253,11,4,160,5,12,21,11,32,1,32,2,253,11,4,176,5,12,20,11,32,1,32,2,253,11,4,192,5,12,19,11,32,1,32,2,253,11,4,208,5,12,18,11,32,1,32,2,253,11,4,224,5,12,17,11,32,1,32,2,253,11,4,240,5,12,16,11,32,1,32,2,253,11,4,128,6,12,15,11,32,1,32,2,253,11,4,144,6,12,14,11,32,1,32,2,253,11,4,160,6,12,13,11,32,1,32,2,253,11,4,176,6,12,12,11,32,1,32,2,253,11,4,192,6,12,11,11,32,1,32,2,253,11,4,208,6,12,10,11,32,1,32,2,253,11,4,224,6,12,9,11,32,1,32,2,253,11,4,240,6,12,8,11,32,1,32,2,253,11,4,128,7,12,7,11,32,1,32,2,253,11,4,144,7,12,6,11,32,1,32,2,253,11,4,160,7,12,5,11,32,1,32,2,253,11,4,176,7,12,4,11,32,1,32,2,253,11,4,192,7,12,3,11,32,1,32,2,253,11,4,208,7,12,2,11,32,1,32,2,253,11,4,224,7,12,1,11,32,1,32,2,253,11,4,240,7,11,32,0,65,1,106,33,0,12,1,11,11,15,11,65,192,19,32,0,16,13,16,15,65,192,20,65,201,1,65,7,16,0,0,11,192,10,2,2,123,2,127,35,0,36,8,35,1,36,9,35,2,36,10,35,3,36,11,35,4,36,12,35,5,36,13,35,6,36,14,35,7,36,15,65,0,36,18,3,64,35,18,65,192,0,72,4,64,35,15,35,12,34,0,65,6,253,173,1,32,0,65,26,253,171,1,253,80,32,0,65,11,253,173,1,32,0,65,21,253,171,1,253,80,253,81,32,0,65,25,253,173,1,32,0,65,7,253,171,1,253,80,253,81,253,174,1,35,12,34,0,35,13,253,78,32,0,253,77,35,14,253,78,253,81,253,174,1,33,1,35,26,33,2,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,35,18,34,3,14,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,11,32,2,253,0,4,0,33,0,12,64,11,32,2,253,0,4,16,33,0,12,63,11,32,2,253,0,4,32,33,0,12,62,11,32,2,253,0,4,48,33,0,12,61,11,32,2,253,0,4,64,33,0,12,60,11,32,2,253,0,4,80,33,0,12,59,11,32,2,253,0,4,96,33,0,12,58,11,32,2,253,0,4,112,33,0,12,57,11,32,2,253,0,4,128,1,33,0,12,56,11,32,2,253,0,4,144,1,33,0,12,55,11,32,2,253,0,4,160,1,33,0,12,54,11,32,2,253,0,4,176,1,33,0,12,53,11,32,2,253,0,4,192,1,33,0,12,52,11,32,2,253,0,4,208,1,33,0,12,51,11,32,2,253,0,4,224,1,33,0,12,50,11,32,2,253,0,4,240,1,33,0,12,49,11,32,2,253,0,4,128,2,33,0,12,48,11,32,2,253,0,4,144,2,33,0,12,47,11,32,2,253,0,4,160,2,33,0,12,46,11,32,2,253,0,4,176,2,33,0,12,45,11,32,2,253,0,4,192,2,33,0,12,44,11,32,2,253,0,4,208,2,33,0,12,43,11,32,2,253,0,4,224,2,33,0,12,42,11,32,2,253,0,4,240,2,33,0,12,41,11,32,2,253,0,4,128,3,33,0,12,40,11,32,2,253,0,4,144,3,33,0,12,39,11,32,2,253,0,4,160,3,33,0,12,38,11,32,2,253,0,4,176,3,33,0,12,37,11,32,2,253,0,4,192,3,33,0,12,36,11,32,2,253,0,4,208,3,33,0,12,35,11,32,2,253,0,4,224,3,33,0,12,34,11,32,2,253,0,4,240,3,33,0,12,33,11,32,2,253,0,4,128,4,33,0,12,32,11,32,2,253,0,4,144,4,33,0,12,31,11,32,2,253,0,4,160,4,33,0,12,30,11,32,2,253,0,4,176,4,33,0,12,29,11,32,2,253,0,4,192,4,33,0,12,28,11,32,2,253,0,4,208,4,33,0,12,27,11,32,2,253,0,4,224,4,33,0,12,26,11,32,2,253,0,4,240,4,33,0,12,25,11,32,2,253,0,4,128,5,33,0,12,24,11,32,2,253,0,4,144,5,33,0,12,23,11,32,2,253,0,4,160,5,33,0,12,22,11,32,2,253,0,4,176,5,33,0,12,21,11,32,2,253,0,4,192,5,33,0,12,20,11,32,2,253,0,4,208,5,33,0,12,19,11,32,2,253,0,4,224,5,33,0,12,18,11,32,2,253,0,4,240,5,33,0,12,17,11,32,2,253,0,4,128,6,33,0,12,16,11,32,2,253,0,4,144,6,33,0,12,15,11,32,2,253,0,4,160,6,33,0,12,14,11,32,2,253,0,4,176,6,33,0,12,13,11,32,2,253,0,4,192,6,33,0,12,12,11,32,2,253,0,4,208,6,33,0,12,11,11,32,2,253,0,4,224,6,33,0,12,10,11,32,2,253,0,4,240,6,33,0,12,9,11,32,2,253,0,4,128,7,33,0,12,8,11,32,2,253,0,4,144,7,33,0,12,7,11,32,2,253,0,4,160,7,33,0,12,6,11,32,2,253,0,4,176,7,33,0,12,5,11,32,2,253,0,4,192,7,33,0,12,4,11,32,2,253,0,4,208,7,33,0,12,3,11,32,2,253,0,4,224,7,33,0,12,2,11,32,2,253,0,4,240,7,33,0,12,1,11,65,128,21,32,3,16,13,16,15,65,192,20,65,213,2,65,7,16,0,0,11,32,1,32,0,253,174,1,36,16,35,8,34,0,65,2,253,173,1,32,0,65,30,253,171,1,253,80,32,0,65,13,253,173,1,32,0,65,19,253,171,1,253,80,253,81,32,0,65,22,253,173,1,32,0,65,10,253,171,1,253,80,253,81,35,8,34,0,35,9,34,1,253,78,32,0,35,10,34,0,253,78,253,81,32,1,32,0,253,78,253,81,253,174,1,36,17,35,14,36,15,35,13,36,14,35,12,36,13,35,11,35,16,253,174,1,36,12,35,10,36,11,35,9,36,10,35,8,36,9,35,16,35,17,253,174,1,36,8,35,18,65,1,106,36,18,12,1,11,11,35,0,35,8,253,174,1,36,0,35,1,35,9,253,174,1,36,1,35,2,35,10,253,174,1,36,2,35,3,35,11,253,174,1,36,3,35,4,35,12,253,174,1,36,4,35,5,35,13,253,174,1,36,5,35,6,35,14,253,174,1,36,6,35,7,35,15,253,174,1,36,7,11,25,0,32,0,65,128,254,131,120,113,65,8,119,32,0,65,255,129,252,7,113,65,8,120,114,11,157,57,2,2,123,2,127,253,12,103,230,9,106,103,230,9,106,103,230,9,106,103,230,9,106,36,0,253,12,133,174,103,187,133,174,103,187,133,174,103,187,133,174,103,187,36,1,253,12,114,243,110,60,114,243,110,60,114,243,110,60,114,243,110,60,36,2,253,12,58,245,79,165,58,245,79,165,58,245,79,165,58,245,79,165,36,3,253,12,127,82,14,81,127,82,14,81,127,82,14,81,127,82,14,81,36,4,253,12,140,104,5,155,140,104,5,155,140,104,5,155,140,104,5,155,36,5,253,12,171,217,131,31,171,217,131,31,171,217,131,31,171,217,131,31,36,6,253,12,25,205,224,91,25,205,224,91,25,205,224,91,25,205,224,91,36,7,253,12,103,230,9,106,103,230,9,106,103,230,9,106,103,230,9,106,36,8,253,12,133,174,103,187,133,174,103,187,133,174,103,187,133,174,103,187,36,9,253,12,114,243,110,60,114,243,110,60,114,243,110,60,114,243,110,60,36,10,253,12,58,245,79,165,58,245,79,165,58,245,79,165,58,245,79,165,36,11,253,12,127,82,14,81,127,82,14,81,127,82,14,81,127,82,14,81,36,12,253,12,140,104,5,155,140,104,5,155,140,104,5,155,140,104,5,155,36,13,253,12,171,217,131,31,171,217,131,31,171,217,131,31,171,217,131,31,36,14,253,12,25,205,224,91,25,205,224,91,25,205,224,91,25,205,224,91,36,15,65,0,36,18,2,64,3,64,35,18,65,192,0,72,4,64,35,18,65,16,72,4,123,2,123,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,35,18,34,4,14,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,11,32,0,253,0,4,0,12,63,11,32,0,253,0,4,16,12,62,11,32,0,253,0,4,32,12,61,11,32,0,253,0,4,48,12,60,11,32,0,253,0,4,64,12,59,11,32,0,253,0,4,80,12,58,11,32,0,253,0,4,96,12,57,11,32,0,253,0,4,112,12,56,11,32,0,253,0,4,128,1,12,55,11,32,0,253,0,4,144,1,12,54,11,32,0,253,0,4,160,1,12,53,11,32,0,253,0,4,176,1,12,52,11,32,0,253,0,4,192,1,12,51,11,32,0,253,0,4,208,1,12,50,11,32,0,253,0,4,224,1,12,49,11,32,0,253,0,4,240,1,12,48,11,32,0,253,0,4,128,2,12,47,11,32,0,253,0,4,144,2,12,46,11,32,0,253,0,4,160,2,12,45,11,32,0,253,0,4,176,2,12,44,11,32,0,253,0,4,192,2,12,43,11,32,0,253,0,4,208,2,12,42,11,32,0,253,0,4,224,2,12,41,11,32,0,253,0,4,240,2,12,40,11,32,0,253,0,4,128,3,12,39,11,32,0,253,0,4,144,3,12,38,11,32,0,253,0,4,160,3,12,37,11,32,0,253,0,4,176,3,12,36,11,32,0,253,0,4,192,3,12,35,11,32,0,253,0,4,208,3,12,34,11,32,0,253,0,4,224,3,12,33,11,32,0,253,0,4,240,3,12,32,11,32,0,253,0,4,128,4,12,31,11,32,0,253,0,4,144,4,12,30,11,32,0,253,0,4,160,4,12,29,11,32,0,253,0,4,176,4,12,28,11,32,0,253,0,4,192,4,12,27,11,32,0,253,0,4,208,4,12,26,11,32,0,253,0,4,224,4,12,25,11,32,0,253,0,4,240,4,12,24,11,32,0,253,0,4,128,5,12,23,11,32,0,253,0,4,144,5,12,22,11,32,0,253,0,4,160,5,12,21,11,32,0,253,0,4,176,5,12,20,11,32,0,253,0,4,192,5,12,19,11,32,0,253,0,4,208,5,12,18,11,32,0,253,0,4,224,5,12,17,11,32,0,253,0,4,240,5,12,16,11,32,0,253,0,4,128,6,12,15,11,32,0,253,0,4,144,6,12,14,11,32,0,253,0,4,160,6,12,13,11,32,0,253,0,4,176,6,12,12,11,32,0,253,0,4,192,6,12,11,11,32,0,253,0,4,208,6,12,10,11,32,0,253,0,4,224,6,12,9,11,32,0,253,0,4,240,6,12,8,11,32,0,253,0,4,128,7,12,7,11,32,0,253,0,4,144,7,12,6,11,32,0,253,0,4,160,7,12,5,11,32,0,253,0,4,176,7,12,4,11,32,0,253,0,4,192,7,12,3,11,32,0,253,0,4,208,7,12,2,11,32,0,253,0,4,224,7,12,1,11,32,0,253,0,4,240,7,11,5,2,123,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,35,18,65,2,107,34,4,14,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,11,32,0,253,0,4,0,12,63,11,32,0,253,0,4,16,12,62,11,32,0,253,0,4,32,12,61,11,32,0,253,0,4,48,12,60,11,32,0,253,0,4,64,12,59,11,32,0,253,0,4,80,12,58,11,32,0,253,0,4,96,12,57,11,32,0,253,0,4,112,12,56,11,32,0,253,0,4,128,1,12,55,11,32,0,253,0,4,144,1,12,54,11,32,0,253,0,4,160,1,12,53,11,32,0,253,0,4,176,1,12,52,11,32,0,253,0,4,192,1,12,51,11,32,0,253,0,4,208,1,12,50,11,32,0,253,0,4,224,1,12,49,11,32,0,253,0,4,240,1,12,48,11,32,0,253,0,4,128,2,12,47,11,32,0,253,0,4,144,2,12,46,11,32,0,253,0,4,160,2,12,45,11,32,0,253,0,4,176,2,12,44,11,32,0,253,0,4,192,2,12,43,11,32,0,253,0,4,208,2,12,42,11,32,0,253,0,4,224,2,12,41,11,32,0,253,0,4,240,2,12,40,11,32,0,253,0,4,128,3,12,39,11,32,0,253,0,4,144,3,12,38,11,32,0,253,0,4,160,3,12,37,11,32,0,253,0,4,176,3,12,36,11,32,0,253,0,4,192,3,12,35,11,32,0,253,0,4,208,3,12,34,11,32,0,253,0,4,224,3,12,33,11,32,0,253,0,4,240,3,12,32,11,32,0,253,0,4,128,4,12,31,11,32,0,253,0,4,144,4,12,30,11,32,0,253,0,4,160,4,12,29,11,32,0,253,0,4,176,4,12,28,11,32,0,253,0,4,192,4,12,27,11,32,0,253,0,4,208,4,12,26,11,32,0,253,0,4,224,4,12,25,11,32,0,253,0,4,240,4,12,24,11,32,0,253,0,4,128,5,12,23,11,32,0,253,0,4,144,5,12,22,11,32,0,253,0,4,160,5,12,21,11,32,0,253,0,4,176,5,12,20,11,32,0,253,0,4,192,5,12,19,11,32,0,253,0,4,208,5,12,18,11,32,0,253,0,4,224,5,12,17,11,32,0,253,0,4,240,5,12,16,11,32,0,253,0,4,128,6,12,15,11,32,0,253,0,4,144,6,12,14,11,32,0,253,0,4,160,6,12,13,11,32,0,253,0,4,176,6,12,12,11,32,0,253,0,4,192,6,12,11,11,32,0,253,0,4,208,6,12,10,11,32,0,253,0,4,224,6,12,9,11,32,0,253,0,4,240,6,12,8,11,32,0,253,0,4,128,7,12,7,11,32,0,253,0,4,144,7,12,6,11,32,0,253,0,4,160,7,12,5,11,32,0,253,0,4,176,7,12,4,11,32,0,253,0,4,192,7,12,3,11,32,0,253,0,4,208,7,12,2,11,32,0,253,0,4,224,7,12,1,11,32,0,253,0,4,240,7,11,34,2,65,17,253,173,1,32,2,65,15,253,171,1,253,80,32,2,65,19,253,173,1,32,2,65,13,253,171,1,253,80,253,81,32,2,65,10,253,173,1,253,81,2,123,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,35,18,65,7,107,34,4,14,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,11,32,0,253,0,4,0,12,63,11,32,0,253,0,4,16,12,62,11,32,0,253,0,4,32,12,61,11,32,0,253,0,4,48,12,60,11,32,0,253,0,4,64,12,59,11,32,0,253,0,4,80,12,58,11,32,0,253,0,4,96,12,57,11,32,0,253,0,4,112,12,56,11,32,0,253,0,4,128,1,12,55,11,32,0,253,0,4,144,1,12,54,11,32,0,253,0,4,160,1,12,53,11,32,0,253,0,4,176,1,12,52,11,32,0,253,0,4,192,1,12,51,11,32,0,253,0,4,208,1,12,50,11,32,0,253,0,4,224,1,12,49,11,32,0,253,0,4,240,1,12,48,11,32,0,253,0,4,128,2,12,47,11,32,0,253,0,4,144,2,12,46,11,32,0,253,0,4,160,2,12,45,11,32,0,253,0,4,176,2,12,44,11,32,0,253,0,4,192,2,12,43,11,32,0,253,0,4,208,2,12,42,11,32,0,253,0,4,224,2,12,41,11,32,0,253,0,4,240,2,12,40,11,32,0,253,0,4,128,3,12,39,11,32,0,253,0,4,144,3,12,38,11,32,0,253,0,4,160,3,12,37,11,32,0,253,0,4,176,3,12,36,11,32,0,253,0,4,192,3,12,35,11,32,0,253,0,4,208,3,12,34,11,32,0,253,0,4,224,3,12,33,11,32,0,253,0,4,240,3,12,32,11,32,0,253,0,4,128,4,12,31,11,32,0,253,0,4,144,4,12,30,11,32,0,253,0,4,160,4,12,29,11,32,0,253,0,4,176,4,12,28,11,32,0,253,0,4,192,4,12,27,11,32,0,253,0,4,208,4,12,26,11,32,0,253,0,4,224,4,12,25,11,32,0,253,0,4,240,4,12,24,11,32,0,253,0,4,128,5,12,23,11,32,0,253,0,4,144,5,12,22,11,32,0,253,0,4,160,5,12,21,11,32,0,253,0,4,176,5,12,20,11,32,0,253,0,4,192,5,12,19,11,32,0,253,0,4,208,5,12,18,11,32,0,253,0,4,224,5,12,17,11,32,0,253,0,4,240,5,12,16,11,32,0,253,0,4,128,6,12,15,11,32,0,253,0,4,144,6,12,14,11,32,0,253,0,4,160,6,12,13,11,32,0,253,0,4,176,6,12,12,11,32,0,253,0,4,192,6,12,11,11,32,0,253,0,4,208,6,12,10,11,32,0,253,0,4,224,6,12,9,11,32,0,253,0,4,240,6,12,8,11,32,0,253,0,4,128,7,12,7,11,32,0,253,0,4,144,7,12,6,11,32,0,253,0,4,160,7,12,5,11,32,0,253,0,4,176,7,12,4,11,32,0,253,0,4,192,7,12,3,11,32,0,253,0,4,208,7,12,2,11,32,0,253,0,4,224,7,12,1,11,32,0,253,0,4,240,7,11,253,174,1,2,123,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,35,18,65,15,107,34,4,14,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,11,32,0,253,0,4,0,12,63,11,32,0,253,0,4,16,12,62,11,32,0,253,0,4,32,12,61,11,32,0,253,0,4,48,12,60,11,32,0,253,0,4,64,12,59,11,32,0,253,0,4,80,12,58,11,32,0,253,0,4,96,12,57,11,32,0,253,0,4,112,12,56,11,32,0,253,0,4,128,1,12,55,11,32,0,253,0,4,144,1,12,54,11,32,0,253,0,4,160,1,12,53,11,32,0,253,0,4,176,1,12,52,11,32,0,253,0,4,192,1,12,51,11,32,0,253,0,4,208,1,12,50,11,32,0,253,0,4,224,1,12,49,11,32,0,253,0,4,240,1,12,48,11,32,0,253,0,4,128,2,12,47,11,32,0,253,0,4,144,2,12,46,11,32,0,253,0,4,160,2,12,45,11,32,0,253,0,4,176,2,12,44,11,32,0,253,0,4,192,2,12,43,11,32,0,253,0,4,208,2,12,42,11,32,0,253,0,4,224,2,12,41,11,32,0,253,0,4,240,2,12,40,11,32,0,253,0,4,128,3,12,39,11,32,0,253,0,4,144,3,12,38,11,32,0,253,0,4,160,3,12,37,11,32,0,253,0,4,176,3,12,36,11,32,0,253,0,4,192,3,12,35,11,32,0,253,0,4,208,3,12,34,11,32,0,253,0,4,224,3,12,33,11,32,0,253,0,4,240,3,12,32,11,32,0,253,0,4,128,4,12,31,11,32,0,253,0,4,144,4,12,30,11,32,0,253,0,4,160,4,12,29,11,32,0,253,0,4,176,4,12,28,11,32,0,253,0,4,192,4,12,27,11,32,0,253,0,4,208,4,12,26,11,32,0,253,0,4,224,4,12,25,11,32,0,253,0,4,240,4,12,24,11,32,0,253,0,4,128,5,12,23,11,32,0,253,0,4,144,5,12,22,11,32,0,253,0,4,160,5,12,21,11,32,0,253,0,4,176,5,12,20,11,32,0,253,0,4,192,5,12,19,11,32,0,253,0,4,208,5,12,18,11,32,0,253,0,4,224,5,12,17,11,32,0,253,0,4,240,5,12,16,11,32,0,253,0,4,128,6,12,15,11,32,0,253,0,4,144,6,12,14,11,32,0,253,0,4,160,6,12,13,11,32,0,253,0,4,176,6,12,12,11,32,0,253,0,4,192,6,12,11,11,32,0,253,0,4,208,6,12,10,11,32,0,253,0,4,224,6,12,9,11,32,0,253,0,4,240,6,12,8,11,32,0,253,0,4,128,7,12,7,11,32,0,253,0,4,144,7,12,6,11,32,0,253,0,4,160,7,12,5,11,32,0,253,0,4,176,7,12,4,11,32,0,253,0,4,192,7,12,3,11,32,0,253,0,4,208,7,12,2,11,32,0,253,0,4,224,7,12,1,11,32,0,253,0,4,240,7,11,34,2,65,7,253,173,1,32,2,65,25,253,171,1,253,80,32,2,65,18,253,173,1,32,2,65,14,253,171,1,253,80,253,81,32,2,65,3,253,173,1,253,81,253,174,1,2,123,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,35,18,65,16,107,34,4,14,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,11,32,0,253,0,4,0,12,63,11,32,0,253,0,4,16,12,62,11,32,0,253,0,4,32,12,61,11,32,0,253,0,4,48,12,60,11,32,0,253,0,4,64,12,59,11,32,0,253,0,4,80,12,58,11,32,0,253,0,4,96,12,57,11,32,0,253,0,4,112,12,56,11,32,0,253,0,4,128,1,12,55,11,32,0,253,0,4,144,1,12,54,11,32,0,253,0,4,160,1,12,53,11,32,0,253,0,4,176,1,12,52,11,32,0,253,0,4,192,1,12,51,11,32,0,253,0,4,208,1,12,50,11,32,0,253,0,4,224,1,12,49,11,32,0,253,0,4,240,1,12,48,11,32,0,253,0,4,128,2,12,47,11,32,0,253,0,4,144,2,12,46,11,32,0,253,0,4,160,2,12,45,11,32,0,253,0,4,176,2,12,44,11,32,0,253,0,4,192,2,12,43,11,32,0,253,0,4,208,2,12,42,11,32,0,253,0,4,224,2,12,41,11,32,0,253,0,4,240,2,12,40,11,32,0,253,0,4,128,3,12,39,11,32,0,253,0,4,144,3,12,38,11,32,0,253,0,4,160,3,12,37,11,32,0,253,0,4,176,3,12,36,11,32,0,253,0,4,192,3,12,35,11,32,0,253,0,4,208,3,12,34,11,32,0,253,0,4,224,3,12,33,11,32,0,253,0,4,240,3,12,32,11,32,0,253,0,4,128,4,12,31,11,32,0,253,0,4,144,4,12,30,11,32,0,253,0,4,160,4,12,29,11,32,0,253,0,4,176,4,12,28,11,32,0,253,0,4,192,4,12,27,11,32,0,253,0,4,208,4,12,26,11,32,0,253,0,4,224,4,12,25,11,32,0,253,0,4,240,4,12,24,11,32,0,253,0,4,128,5,12,23,11,32,0,253,0,4,144,5,12,22,11,32,0,253,0,4,160,5,12,21,11,32,0,253,0,4,176,5,12,20,11,32,0,253,0,4,192,5,12,19,11,32,0,253,0,4,208,5,12,18,11,32,0,253,0,4,224,5,12,17,11,32,0,253,0,4,240,5,12,16,11,32,0,253,0,4,128,6,12,15,11,32,0,253,0,4,144,6,12,14,11,32,0,253,0,4,160,6,12,13,11,32,0,253,0,4,176,6,12,12,11,32,0,253,0,4,192,6,12,11,11,32,0,253,0,4,208,6,12,10,11,32,0,253,0,4,224,6,12,9,11,32,0,253,0,4,240,6,12,8,11,32,0,253,0,4,128,7,12,7,11,32,0,253,0,4,144,7,12,6,11,32,0,253,0,4,160,7,12,5,11,32,0,253,0,4,176,7,12,4,11,32,0,253,0,4,192,7,12,3,11,32,0,253,0,4,208,7,12,2,11,32,0,253,0,4,224,7,12,1,11,32,0,253,0,4,240,7,11,253,174,1,11,36,19,35,18,65,16,78,4,64,35,19,33,2,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,35,18,34,4,14,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,11,32,0,32,2,253,11,4,0,12,64,11,32,0,32,2,253,11,4,16,12,63,11,32,0,32,2,253,11,4,32,12,62,11,32,0,32,2,253,11,4,48,12,61,11,32,0,32,2,253,11,4,64,12,60,11,32,0,32,2,253,11,4,80,12,59,11,32,0,32,2,253,11,4,96,12,58,11,32,0,32,2,253,11,4,112,12,57,11,32,0,32,2,253,11,4,128,1,12,56,11,32,0,32,2,253,11,4,144,1,12,55,11,32,0,32,2,253,11,4,160,1,12,54,11,32,0,32,2,253,11,4,176,1,12,53,11,32,0,32,2,253,11,4,192,1,12,52,11,32,0,32,2,253,11,4,208,1,12,51,11,32,0,32,2,253,11,4,224,1,12,50,11,32,0,32,2,253,11,4,240,1,12,49,11,32,0,32,2,253,11,4,128,2,12,48,11,32,0,32,2,253,11,4,144,2,12,47,11,32,0,32,2,253,11,4,160,2,12,46,11,32,0,32,2,253,11,4,176,2,12,45,11,32,0,32,2,253,11,4,192,2,12,44,11,32,0,32,2,253,11,4,208,2,12,43,11,32,0,32,2,253,11,4,224,2,12,42,11,32,0,32,2,253,11,4,240,2,12,41,11,32,0,32,2,253,11,4,128,3,12,40,11,32,0,32,2,253,11,4,144,3,12,39,11,32,0,32,2,253,11,4,160,3,12,38,11,32,0,32,2,253,11,4,176,3,12,37,11,32,0,32,2,253,11,4,192,3,12,36,11,32,0,32,2,253,11,4,208,3,12,35,11,32,0,32,2,253,11,4,224,3,12,34,11,32,0,32,2,253,11,4,240,3,12,33,11,32,0,32,2,253,11,4,128,4,12,32,11,32,0,32,2,253,11,4,144,4,12,31,11,32,0,32,2,253,11,4,160,4,12,30,11,32,0,32,2,253,11,4,176,4,12,29,11,32,0,32,2,253,11,4,192,4,12,28,11,32,0,32,2,253,11,4,208,4,12,27,11,32,0,32,2,253,11,4,224,4,12,26,11,32,0,32,2,253,11,4,240,4,12,25,11,32,0,32,2,253,11,4,128,5,12,24,11,32,0,32,2,253,11,4,144,5,12,23,11,32,0,32,2,253,11,4,160,5,12,22,11,32,0,32,2,253,11,4,176,5,12,21,11,32,0,32,2,253,11,4,192,5,12,20,11,32,0,32,2,253,11,4,208,5,12,19,11,32,0,32,2,253,11,4,224,5,12,18,11,32,0,32,2,253,11,4,240,5,12,17,11,32,0,32,2,253,11,4,128,6,12,16,11,32,0,32,2,253,11,4,144,6,12,15,11,32,0,32,2,253,11,4,160,6,12,14,11,32,0,32,2,253,11,4,176,6,12,13,11,32,0,32,2,253,11,4,192,6,12,12,11,32,0,32,2,253,11,4,208,6,12,11,11,32,0,32,2,253,11,4,224,6,12,10,11,32,0,32,2,253,11,4,240,6,12,9,11,32,0,32,2,253,11,4,128,7,12,8,11,32,0,32,2,253,11,4,144,7,12,7,11,32,0,32,2,253,11,4,160,7,12,6,11,32,0,32,2,253,11,4,176,7,12,5,11,32,0,32,2,253,11,4,192,7,12,4,11,32,0,32,2,253,11,4,208,7,12,3,11,32,0,32,2,253,11,4,224,7,12,2,11,32,0,32,2,253,11,4,240,7,12,1,11,65,192,19,32,4,16,13,16,15,65,192,20,65,201,1,65,7,16,0,0,11,11,35,15,35,12,34,2,65,6,253,173,1,32,2,65,26,253,171,1,253,80,32,2,65,11,253,173,1,32,2,65,21,253,171,1,253,80,253,81,32,2,65,25,253,173,1,32,2,65,7,253,171,1,253,80,253,81,253,174,1,35,12,34,2,35,13,253,78,32,2,253,77,35,14,253,78,253,81,253,174,1,33,3,35,24,33,4,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,35,18,34,5,14,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,11,32,4,253,0,4,0,33,2,12,64,11,32,4,253,0,4,16,33,2,12,63,11,32,4,253,0,4,32,33,2,12,62,11,32,4,253,0,4,48,33,2,12,61,11,32,4,253,0,4,64,33,2,12,60,11,32,4,253,0,4,80,33,2,12,59,11,32,4,253,0,4,96,33,2,12,58,11,32,4,253,0,4,112,33,2,12,57,11,32,4,253,0,4,128,1,33,2,12,56,11,32,4,253,0,4,144,1,33,2,12,55,11,32,4,253,0,4,160,1,33,2,12,54,11,32,4,253,0,4,176,1,33,2,12,53,11,32,4,253,0,4,192,1,33,2,12,52,11,32,4,253,0,4,208,1,33,2,12,51,11,32,4,253,0,4,224,1,33,2,12,50,11,32,4,253,0,4,240,1,33,2,12,49,11,32,4,253,0,4,128,2,33,2,12,48,11,32,4,253,0,4,144,2,33,2,12,47,11,32,4,253,0,4,160,2,33,2,12,46,11,32,4,253,0,4,176,2,33,2,12,45,11,32,4,253,0,4,192,2,33,2,12,44,11,32,4,253,0,4,208,2,33,2,12,43,11,32,4,253,0,4,224,2,33,2,12,42,11,32,4,253,0,4,240,2,33,2,12,41,11,32,4,253,0,4,128,3,33,2,12,40,11,32,4,253,0,4,144,3,33,2,12,39,11,32,4,253,0,4,160,3,33,2,12,38,11,32,4,253,0,4,176,3,33,2,12,37,11,32,4,253,0,4,192,3,33,2,12,36,11,32,4,253,0,4,208,3,33,2,12,35,11,32,4,253,0,4,224,3,33,2,12,34,11,32,4,253,0,4,240,3,33,2,12,33,11,32,4,253,0,4,128,4,33,2,12,32,11,32,4,253,0,4,144,4,33,2,12,31,11,32,4,253,0,4,160,4,33,2,12,30,11,32,4,253,0,4,176,4,33,2,12,29,11,32,4,253,0,4,192,4,33,2,12,28,11,32,4,253,0,4,208,4,33,2,12,27,11,32,4,253,0,4,224,4,33,2,12,26,11,32,4,253,0,4,240,4,33,2,12,25,11,32,4,253,0,4,128,5,33,2,12,24,11,32,4,253,0,4,144,5,33,2,12,23,11,32,4,253,0,4,160,5,33,2,12,22,11,32,4,253,0,4,176,5,33,2,12,21,11,32,4,253,0,4,192,5,33,2,12,20,11,32,4,253,0,4,208,5,33,2,12,19,11,32,4,253,0,4,224,5,33,2,12,18,11,32,4,253,0,4,240,5,33,2,12,17,11,32,4,253,0,4,128,6,33,2,12,16,11,32,4,253,0,4,144,6,33,2,12,15,11,32,4,253,0,4,160,6,33,2,12,14,11,32,4,253,0,4,176,6,33,2,12,13,11,32,4,253,0,4,192,6,33,2,12,12,11,32,4,253,0,4,208,6,33,2,12,11,11,32,4,253,0,4,224,6,33,2,12,10,11,32,4,253,0,4,240,6,33,2,12,9,11,32,4,253,0,4,128,7,33,2,12,8,11,32,4,253,0,4,144,7,33,2,12,7,11,32,4,253,0,4,160,7,33,2,12,6,11,32,4,253,0,4,176,7,33,2,12,5,11,32,4,253,0,4,192,7,33,2,12,4,11,32,4,253,0,4,208,7,33,2,12,3,11,32,4,253,0,4,224,7,33,2,12,2,11,32,4,253,0,4,240,7,33,2,12,1,11,65,128,21,32,5,16,13,16,15,65,192,20,65,213,2,65,7,16,0,0,11,32,3,32,2,253,174,1,35,19,253,174,1,36,16,35,8,34,2,65,2,253,173,1,32,2,65,30,253,171,1,253,80,32,2,65,13,253,173,1,32,2,65,19,253,171,1,253,80,253,81,32,2,65,22,253,173,1,32,2,65,10,253,171,1,253,80,253,81,35,8,34,2,35,9,34,3,253,78,32,2,35,10,34,2,253,78,253,81,32,3,32,2,253,78,253,81,253,174,1,36,17,35,14,36,15,35,13,36,14,35,12,36,13,35,11,35,16,253,174,1,36,12,35,10,36,11,35,9,36,10,35,8,36,9,35,16,35,17,253,174,1,36,8,35,18,65,1,106,36,18,12,1,11,11,35,0,35,8,253,174,1,36,0,35,1,35,9,253,174,1,36,1,35,2,35,10,253,174,1,36,2,35,3,35,11,253,174,1,36,3,35,4,35,12,253,174,1,36,4,35,5,35,13,253,174,1,36,5,35,6,35,14,253,174,1,36,6,35,7,35,15,253,174,1,36,7,16,17,32,1,35,0,253,27,0,16,18,54,2,0,32,1,35,1,253,27,0,16,18,54,2,4,32,1,35,2,253,27,0,16,18,54,2,8,32,1,35,3,253,27,0,16,18,54,2,12,32,1,35,4,253,27,0,16,18,54,2,16,32,1,35,5,253,27,0,16,18,54,2,20,32,1,35,6,253,27,0,16,18,54,2,24,32,1,35,7,253,27,0,16,18,54,2,28,32,1,35,0,253,27,1,16,18,54,2,32,32,1,35,1,253,27,1,16,18,54,2,36,32,1,35,2,253,27,1,16,18,54,2,40,32,1,35,3,253,27,1,16,18,54,2,44,32,1,35,4,253,27,1,16,18,54,2,48,32,1,35,5,253,27,1,16,18,54,2,52,32,1,35,6,253,27,1,16,18,54,2,56,32,1,35,7,253,27,1,16,18,54,2,60,32,1,65,64,107,35,0,253,27,2,16,18,54,2,0,32,1,35,1,253,27,2,16,18,54,2,68,32,1,35,2,253,27,2,16,18,54,2,72,32,1,35,3,253,27,2,16,18,54,2,76,32,1,35,4,253,27,2,16,18,54,2,80,32,1,35,5,253,27,2,16,18,54,2,84,32,1,35,6,253,27,2,16,18,54,2,88,32,1,35,7,253,27,2,16,18,54,2,92,32,1,35,0,253,27,3,16,18,54,2,96,32,1,35,1,253,27,3,16,18,54,2,100,32,1,35,2,253,27,3,16,18,54,2,104,32,1,35,3,253,27,3,16,18,54,2,108,32,1,35,4,253,27,3,16,18,54,2,112,32,1,35,5,253,27,3,16,18,54,2,116,32,1,35,6,253,27,3,16,18,54,2,120,32,1,35,7,253,27,3,16,18,54,2,124,15,11,65,128,21,32,4,16,13,16,15,65,192,20,65,213,2,65,7,16,0,0,11,203,2,1,5,127,3,64,32,1,65,16,72,4,64,32,1,65,2,116,34,2,65,1,106,33,3,35,53,32,2,65,2,116,106,32,2,65,3,106,34,4,35,55,34,5,106,45,0,0,32,2,32,5,106,45,0,0,65,24,116,32,3,32,5,106,45,0,0,65,16,116,114,32,2,65,2,106,34,2,32,5,106,45,0,0,65,8,116,114,114,54,2,0,35,53,32,3,65,2,116,106,35,55,34,3,32,1,65,16,106,65,2,116,34,5,65,3,106,106,45,0,0,32,3,32,5,106,45,0,0,65,24,116,32,5,65,1,106,32,3,106,45,0,0,65,16,116,114,32,5,65,2,106,32,3,106,45,0,0,65,8,116,114,114,54,2,0,35,53,32,2,65,2,116,106,35,55,34,2,32,1,65,32,106,65,2,116,34,3,65,3,106,106,45,0,0,32,2,32,3,106,45,0,0,65,24,116,32,3,65,1,106,32,2,106,45,0,0,65,16,116,114,32,3,65,2,106,32,2,106,45,0,0,65,8,116,114,114,54,2,0,35,53,32,4,65,2,116,106,35,55,34,2,32,1,65,48,106,65,2,116,34,3,65,3,106,106,45,0,0,32,2,32,3,106,45,0,0,65,24,116,32,3,65,1,106,32,2,106,45,0,0,65,16,116,114,32,3,65,2,106,32,2,106,45,0,0,65,8,116,114,114,54,2,0,32,1,65,1,106,33,1,12,1,11,11,35,53,32,0,16,19,11,99,1,3,127,3,64,32,2,65,192,0,72,4,64,32,2,65,2,116,34,1,35,53,106,35,55,34,3,32,1,65,3,106,106,45,0,0,32,1,32,3,106,45,0,0,65,24,116,32,1,65,1,106,32,3,106,45,0,0,65,16,116,114,32,1,65,2,106,32,3,106,45,0,0,65,8,116,114,114,54,2,0,32,2,65,1,106,33,2,12,1,11,11,35,53,32,0,16,19,11,74,0,65,231,204,167,208,6,36,31,65,133,221,158,219,123,36,32,65,242,230,187,227,3,36,33,65,186,234,191,170,122,36,34,65,255,164,185,136,5,36,35,65,140,209,149,216,121,36,36,65,171,179,143,252,1,36,37,65,153,154,131,223,5,36,38,65,0,36,58,65,0,36,59,11,227,3,1,2,127,35,31,36,39,35,32,36,40,35,33,36,41,35,34,36,42,35,35,36,43,35,36,36,44,35,37,36,45,35,38,36,46,65,0,36,47,3,64,35,47,65,16,73,4,64,35,47,65,2,116,34,2,32,0,106,32,1,32,2,65,3,106,106,45,0,0,32,1,32,2,106,45,0,0,65,24,116,32,1,32,2,65,1,106,106,45,0,0,65,16,116,114,32,1,32,2,65,2,106,106,45,0,0,65,8,116,114,114,54,2,0,35,47,65,1,106,36,47,12,1,11,11,65,16,36,47,3,64,35,47,65,192,0,73,4,64,32,0,35,47,65,2,116,106,32,0,35,47,65,16,107,65,2,116,106,40,2,0,32,0,35,47,65,7,107,65,2,116,106,40,2,0,32,0,35,47,65,2,107,65,2,116,106,40,2,0,34,1,65,17,120,32,1,65,19,120,115,32,1,65,10,118,115,106,32,0,35,47,65,15,107,65,2,116,106,40,2,0,34,1,65,7,120,32,1,65,18,120,115,32,1,65,3,118,115,106,106,54,2,0,35,47,65,1,106,36,47,12,1,11,11,65,0,36,47,3,64,35,47,65,192,0,73,4,64,35,47,65,2,116,34,1,32,0,106,40,2,0,32,1,35,29,106,40,2,0,35,46,35,43,34,1,65,6,120,32,1,65,11,120,115,32,1,65,25,120,115,106,35,43,34,1,35,44,113,35,45,32,1,65,127,115,113,115,106,106,106,36,48,35,39,34,1,65,2,120,32,1,65,13,120,115,32,1,65,22,120,115,35,40,34,2,35,41,34,3,113,35,39,34,1,32,2,113,32,1,32,3,113,115,115,106,36,49,35,45,36,46,35,44,36,45,35,43,36,44,35,42,35,48,106,36,43,35,41,36,42,35,40,36,41,35,39,36,40,35,48,35,49,106,36,39,35,47,65,1,106,36,47,12,1,11,11,35,31,35,39,106,36,31,35,32,35,40,106,36,32,35,33,35,41,106,36,33,35,34,35,42,106,36,34,35,35,35,43,106,36,35,35,36,35,44,106,36,36,35,37,35,45,106,36,37,35,38,35,46,106,36,38,11,174,1,1,2,127,35,59,32,1,106,36,59,35,58,4,64,65,192,0,35,58,107,34,2,32,1,76,4,64,35,51,35,58,106,32,0,32,2,252,10,0,0,35,58,32,2,106,36,58,65,192,0,35,58,107,33,2,32,1,65,192,0,35,58,107,107,33,1,35,53,35,51,16,23,65,0,36,58,5,35,51,35,58,106,32,0,32,1,252,10,0,0,35,58,32,1,106,36,58,15,11,11,3,64,32,3,32,1,65,192,0,109,72,4,64,35,53,32,0,32,2,106,16,23,32,3,65,1,106,33,3,32,2,65,64,107,33,2,12,1,11,11,32,1,65,63,113,34,1,4,64,35,51,35,58,106,32,0,32,2,106,32,1,252,10,0,0,35,58,32,1,106,36,58,11,11,146,2,1,2,127,35,59,65,63,113,65,63,73,4,64,35,51,35,58,106,65,128,1,58,0,0,35,58,65,1,106,36,58,11,35,59,65,63,113,65,56,79,4,64,35,51,35,58,106,34,1,65,192,0,35,58,107,106,33,2,3,64,32,1,32,2,73,4,64,32,1,65,0,58,0,0,32,1,65,1,106,33,1,12,1,11,11,35,53,35,51,16,23,65,0,36,58,11,35,59,65,63,113,65,63,79,4,64,35,51,35,58,106,65,128,1,58,0,0,35,58,65,1,106,36,58,11,35,51,35,58,106,34,1,65,56,35,58,107,106,33,2,3,64,32,1,32,2,73,4,64,32,1,65,0,58,0,0,32,1,65,1,106,33,1,12,1,11,11,35,51,35,59,65,128,128,128,128,2,109,16,18,54,2,56,35,51,35,59,65,3,116,16,18,54,2,60,35,53,35,51,16,23,32,0,35,31,16,18,54,2,0,32,0,35,32,16,18,54,2,4,32,0,35,33,16,18,54,2,8,32,0,35,34,16,18,54,2,12,32,0,35,35,16,18,54,2,16,32,0,35,36,16,18,54,2,20,32,0,35,37,16,18,54,2,24,32,0,35,38,16,18,54,2,28,11,14,0,16,22,35,55,32,0,16,24,35,57,16,25,11,253,1,1,2,127,35,31,36,39,35,32,36,40,35,33,36,41,35,34,36,42,35,35,36,43,35,36,36,44,35,37,36,45,35,38,36,46,65,0,36,47,3,64,35,47,65,192,0,73,4,64,32,0,35,47,65,2,116,106,40,2,0,35,46,35,43,34,1,65,6,120,32,1,65,11,120,115,32,1,65,25,120,115,106,35,43,34,1,35,44,113,35,45,32,1,65,127,115,113,115,106,106,36,48,35,39,34,1,65,2,120,32,1,65,13,120,115,32,1,65,22,120,115,35,40,34,2,35,41,34,1,113,32,2,35,39,34,2,113,32,1,32,2,113,115,115,106,36,49,35,45,36,46,35,44,36,45,35,43,36,44,35,42,35,48,106,36,43,35,41,36,42,35,40,36,41,35,39,36,40,35,48,35,49,106,36,39,35,47,65,1,106,36,47,12,1,11,11,35,31,35,39,106,36,31,35,32,35,40,106,36,32,35,33,35,41,106,36,33,35,34,35,42,106,36,34,35,35,35,43,106,36,35,35,36,35,44,106,36,36,35,37,35,45,106,36,37,35,38,35,46,106,36,38,11,86,0,16,22,35,53,32,0,16,23,35,30,16,27,32,1,35,31,16,18,54,2,0,32,1,35,32,16,18,54,2,4,32,1,35,33,16,18,54,2,8,32,1,35,34,16,18,54,2,12,32,1,35,35,16,18,54,2,16,32,1,35,36,16,18,54,2,20,32,1,35,37,16,18,54,2,24,32,1,35,38,16,18,54,2,28,11,63,0,16,16,65,196,10,40,2,0,36,29,65,148,13,40,2,0,36,30,65,192,0,16,11,36,50,35,50,36,51,65,128,8,16,11,36,52,35,52,36,53,65,128,4,16,11,36,54,35,54,36,55,65,32,16,11,36,56,35,56,36,57,11,11,141,12,38,0,65,140,8,11,2,28,1,0,65,152,8,11,136,2,1,0,0,0,0,1,0,0,152,47,138,66,145,68,55,113,207,251,192,181,165,219,181,233,91,194,86,57,241,17,241,89,164,130,63,146,213,94,28,171,152,170,7,216,1,91,131,18,190,133,49,36,195,125,12,85,116,93,190,114,254,177,222,128,167,6,220,155,116,241,155,193,193,105,155,228,134,71,190,239,198,157,193,15,204,161,12,36,111,44,233,45,170,132,116,74,220,169,176,92,218,136,249,118,82,81,62,152,109,198,49,168,200,39,3,176,199,127,89,191,243,11,224,198,71,145,167,213,81,99,202,6,103,41,41,20,133,10,183,39,56,33,27,46,252,109,44,77,19,13,56,83,84,115,10,101,187,10,106,118,46,201,194,129,133,44,114,146,161,232,191,162,75,102,26,168,112,139,75,194,163,81,108,199,25,232,146,209,36,6,153,214,133,53,14,244,112,160,106,16,22,193,164,25,8,108,55,30,76,119,72,39,181,188,176,52,179,12,28,57,74,170,216,78,79,202,156,91,243,111,46,104,238,130,143,116,111,99,165,120,20,120,200,132,8,2,199,140,250,255,190,144,235,108,80,164,247,163,249,190,242,120,113,198,0,65,172,10,11,1,44,0,65,184,10,11,21,4,0,0,0,16,0,0,0,32,4,0,0,32,4,0,0,0,1,0,0,64,0,65,220,10,11,2,28,1,0,65,232,10,11,136,2,1,0,0,0,0,1,0,0,152,47,138,194,145,68,55,113,207,251,192,181,165,219,181,233,91,194,86,57,241,17,241,89,164,130,63,146,213,94,28,171,152,170,7,216,1,91,131,18,190,133,49,36,195,125,12,85,116,93,190,114,254,177,222,128,167,6,220,155,116,243,155,193,193,105,155,100,134,71,254,240,198,237,225,15,84,242,12,36,111,52,233,79,190,132,201,108,30,65,185,97,250,136,249,22,82,81,198,242,109,90,142,168,101,252,25,176,199,158,217,185,195,49,18,154,160,234,14,231,43,35,177,253,176,62,53,199,213,186,105,48,95,109,151,203,143,17,15,90,253,238,30,220,137,182,53,10,4,122,11,222,157,202,244,88,22,91,93,225,134,62,127,0,128,137,8,55,50,234,7,165,55,149,171,111,16,97,64,23,241,214,140,13,109,59,170,205,55,190,187,192,218,59,97,131,99,163,72,219,49,233,2,11,167,92,209,111,202,250,26,82,49,132,51,49,149,26,212,110,144,120,67,109,242,145,156,195,189,171,204,158,230,160,201,181,60,182,47,83,198,65,199,210,163,126,35,7,104,75,149,164,118,29,25,76,0,65,252,12,11,1,44,0,65,136,13,11,21,4,0,0,0,16,0,0,0,112,5,0,0,112,5,0,0,0,1,0,0,64,0,65,172,13,11,1,44,0,65,184,13,11,35,2,0,0,0,28,0,0,0,73,0,110,0,118,0,97,0,108,0,105,0,100,0,32,0,108,0,101,0,110,0,103,0,116,0,104,0,65,220,13,11,1,60,0,65,232,13,11,45,2,0,0,0,38,0,0,0,126,0,108,0,105,0,98,0,47,0,97,0,114,0,114,0,97,0,121,0,98,0,117,0,102,0,102,0,101,0,114,0,46,0,116,0,115,0,65,156,14,11,1,60,0,65,168,14,11,47,2,0,0,0,40,0,0,0,65,0,108,0,108,0,111,0,99,0,97,0,116,0,105,0,111,0,110,0,32,0,116,0,111,0,111,0,32,0,108,0,97,0,114,0,103,0,101,0,65,220,14,11,1,60,0,65,232,14,11,37,2,0,0,0,30,0,0,0,126,0,108,0,105,0,98,0,47,0,114,0,116,0,47,0,116,0,99,0,109,0,115,0,46,0,116,0,115,0,65,156,15,11,1,60,0,65,168,15,11,37,2,0,0,0,30,0,0,0,126,0,108,0,105,0,98,0,47,0,114,0,116,0,47,0,116,0,108,0,115,0,102,0,46,0,116,0,115,0,65,252,15,11,1,60,0,65,136,16,11,43,2,0,0,0,36,0,0,0,73,0,110,0,100,0,101,0,120,0,32,0,111,0,117,0,116,0,32,0,111,0,102,0,32,0,114,0,97,0,110,0,103,0,101,0,65,188,16,11,1,44,0,65,200,16,11,33,2,0,0,0,26,0,0,0,126,0,108,0,105,0,98,0,47,0,97,0,114,0,114,0,97,0,121,0,46,0,116,0,115,0,65,236,16,11,1,124,0,65,248,16,11,107,2,0,0,0,100,0,0,0,116,0,111,0,83,0,116,0,114,0,105,0,110,0,103,0,40,0,41,0,32,0,114,0,97,0,100,0,105,0,120,0,32,0,97,0,114,0,103,0,117,0,109,0,101,0,110,0,116,0,32,0,109,0,117,0,115,0,116,0,32,0,98,0,101,0,32,0,98,0,101,0,116,0,119,0,101,0,101,0,110,0,32,0,50,0,32,0,97,0,110,0,100,0,32,0,51,0,54,0,65,236,17,11,1,60,0,65,248,17,11,45,2,0,0,0,38,0,0,0,126,0,108,0,105,0,98,0,47,0,117,0,116,0,105,0,108,0,47,0,110,0,117,0,109,0,98,0,101,0,114,0,46,0,116,0,115,0,65,172,18,11,1,28,0,65,184,18,11,9,2,0,0,0,2,0,0,0,48,0,65,204,18,11,1,92,0,65,216,18,11,79,2,0,0,0,72,0,0,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,57,0,97,0,98,0,99,0,100,0,101,0,102,0,103,0,104,0,105,0,106,0,107,0,108,0,109,0,110,0,111,0,112,0,113,0,114,0,115,0,116,0,117,0,118,0,119,0,120,0,121,0,122,0,65,172,19,11,1,92,0,65,184,19,11,79,2,0,0,0,72,0,0,0,115,0,101,0,116,0,86,0,49,0,50,0,56,0,58,0,32,0,101,0,120,0,112,0,101,0,99,0,116,0,32,0,105,0,32,0,102,0,114,0,111,0,109,0,32,0,48,0,32,0,116,0,111,0,32,0,54,0,51,0,44,0,32,0,103,0,111,0,116,0,32,0,65,140,20,11,1,28,0,65,152,20,11,1,2,0,65,172,20,11,1,60,0,65,184,20,11,51,2,0,0,0,44,0,0,0,97,0,115,0,115,0,101,0,109,0,98,0,108,0,121,0,47,0,117,0,116,0,105,0,108,0,115,0,47,0,118,0,49,0,50,0,56,0,46,0,116,0,115,0,65,236,20,11,1,92,0,65,248,20,11,79,2,0,0,0,72,0,0,0,103,0,101,0,116,0,86,0,49,0,50,0,56,0,58,0,32,0,101,0,120,0,112,0,101,0,99,0,116,0,32,0,105,0,32,0,102,0,114,0,111,0,109,0,32,0,48,0,32,0,116,0,111,0,32,0,54,0,51,0,44,0,32,0,103,0,111,0,116,0,32]); diff --git a/packages/as-sha256/test/perf/index.test.ts b/packages/as-sha256/test/perf/index.test.ts index ff38f1d56..3724bc833 100644 --- a/packages/as-sha256/test/perf/index.test.ts +++ b/packages/as-sha256/test/perf/index.test.ts @@ -1,9 +1,9 @@ import {bench, describe, setBenchOpts} from "@chainsafe/benchmark"; import { + byteArrayToHashObject, digest, digest2Bytes32, digest64HashObjects, - byteArrayToHashObject, hashObjectToByteArray, } from "../../src/index.js"; diff --git a/packages/as-sha256/test/perf/simd.test.ts b/packages/as-sha256/test/perf/simd.test.ts index 0d71705b4..e7e319393 100644 --- a/packages/as-sha256/test/perf/simd.test.ts +++ b/packages/as-sha256/test/perf/simd.test.ts @@ -1,6 +1,6 @@ import {bench, describe, setBenchOpts} from "@chainsafe/benchmark"; -import {batchHash4HashObjectInputs, batchHash4UintArray64s, digest64, digest64HashObjects} from "../../src/index.js"; import {byteArrayToHashObject} from "../../src/hashObject.js"; +import {batchHash4HashObjectInputs, batchHash4UintArray64s, digest64, digest64HashObjects} from "../../src/index.js"; /** * This really depends on cpu, on a test ubuntu node, batch*() is 2x faster than digest64 @@ -11,7 +11,7 @@ import {byteArrayToHashObject} from "../../src/hashObject.js"; ✓ digest64HashObjects 200092 times 7.095494 ops/s 140.9345 ms/op - 68 runs 10.2 s ✓ hash 200092 times using batchHash4HashObjectInputs 9.211751 ops/s 108.5570 ms/op - 88 runs 10.1 s */ -describe("digest64 vs batchHash4UintArray64s vs digest64HashObjects vs batchHash4HashObjectInputs", function () { +describe("digest64 vs batchHash4UintArray64s vs digest64HashObjects vs batchHash4HashObjectInputs", () => { setBenchOpts({ minMs: 10_000, }); diff --git a/packages/as-sha256/test/unit/getSimdTests.ts b/packages/as-sha256/test/unit/getSimdTests.ts index 3d4af287e..11e33ccf9 100644 --- a/packages/as-sha256/test/unit/getSimdTests.ts +++ b/packages/as-sha256/test/unit/getSimdTests.ts @@ -1,15 +1,11 @@ -/* eslint-disable @typescript-eslint/no-unsafe-return */ -/* eslint-disable @typescript-eslint/no-unsafe-call */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import {describe, beforeAll, expect, it} from "vitest"; -import crypto from "crypto"; +import crypto from "node:crypto"; +import {beforeAll, describe, expect, it} from "vitest"; import {byteArrayToHashObject, hashObjectToByteArray} from "../../src/hashObject.js"; -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +// biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly export function getSimdTests(sha256: any, useSimd: boolean): void { describe(`as-sha256 SIMD enabled methods ${useSimd ? "with SIMD" : "without SIMD"}`, () => { - beforeAll(function () { + beforeAll(() => { sha256.reinitializeInstance(useSimd); expect(sha256.simdEnabled).to.equal(useSimd); }); diff --git a/packages/as-sha256/test/unit/index.test.ts b/packages/as-sha256/test/unit/index.test.ts index ce1fde950..aa33f8c30 100644 --- a/packages/as-sha256/test/unit/index.test.ts +++ b/packages/as-sha256/test/unit/index.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {createHash, randomBytes} from "crypto"; -import {Buffer} from "buffer"; +import {Buffer} from "node:buffer"; +import {createHash, randomBytes} from "node:crypto"; +import {describe, expect, it} from "vitest"; import { byteArrayToHashObject, digest, @@ -10,7 +10,7 @@ import { hashObjectToByteArray, } from "../../src/index.js"; -describe("hashObjectToByteArray and byteArrayToHashObject", function () { +describe("hashObjectToByteArray and byteArrayToHashObject", () => { const tcs = [ new Uint8Array([ 190, 57, 56, 15, 241, 208, 38, 30, 111, 55, 218, 254, 66, 120, 182, 98, 239, 97, 31, 28, 178, 247, 192, 161, 131, @@ -23,7 +23,7 @@ describe("hashObjectToByteArray and byteArrayToHashObject", function () { new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), ]; for (const [i, byteArr] of tcs.entries()) { - it("test case " + i, function () { + it("test case " + i, () => { const obj = byteArrayToHashObject(byteArr, 0); const newByteArr = new Uint8Array(32); hashObjectToByteArray(obj, newByteArr, 0); @@ -32,8 +32,8 @@ describe("hashObjectToByteArray and byteArrayToHashObject", function () { } }); -describe("as-sha256 non-SIMD enabled methods", function () { - describe("digest()", function () { +describe("as-sha256 non-SIMD enabled methods", () => { + describe("digest()", () => { const digestTestCases = [ { input: "", @@ -63,7 +63,7 @@ describe("as-sha256 non-SIMD enabled methods", function () { for (const {input, expectedInputLength, expected} of digestTestCases) { const name = input === "" ? "empty string" : input; const trimmed = name.length > 97 ? `${name.substring(0, 100)}...` : name; - it(trimmed, function () { + it(trimmed, () => { const inputBuffer = Buffer.from(input, "utf8"); if (expectedInputLength) { expect(inputBuffer.length).to.be.equal(expectedInputLength, "Invalid input buffer length"); @@ -74,21 +74,21 @@ describe("as-sha256 non-SIMD enabled methods", function () { } }); - it("digest64()", function () { + it("digest64()", () => { const input = Buffer.alloc(64, "lodestar"); const output = Buffer.from(digest64(input)).toString("hex"); const expected = createHash("sha256").update(input).digest("hex"); expect(output).to.equal(expected); }); - it("digest() and digest64() output matches", function () { + it("digest() and digest64() output matches", () => { const input = Buffer.from("harkamalharkamalharkamalharkamalharkamalharkamalharkamalharkamal", "utf8"); const output = Buffer.from(digest(input)).toString("hex"); const output64 = Buffer.from(digest64(input)).toString("hex"); expect(output).to.be.equal(output64); }); - it("digest2Bytes32()", function () { + it("digest2Bytes32()", () => { const input1 = randomBytes(32); const input2 = randomBytes(32); const output = Buffer.from(digest2Bytes32(input1, input2)).toString("hex"); @@ -98,7 +98,7 @@ describe("as-sha256 non-SIMD enabled methods", function () { expect(output).to.equal(expectedOutput); }); - it("digest2Bytes32() matches digest64()", function () { + it("digest2Bytes32() matches digest64()", () => { const input1 = Buffer.alloc(32, "*"); const input2 = Buffer.alloc(32, "*"); const digestBytes32 = digest2Bytes32(input1, input2); @@ -108,7 +108,7 @@ describe("as-sha256 non-SIMD enabled methods", function () { ); }); - it("digest64HashObject()", function () { + it("digest64HashObject()", () => { const input1 = randomBytes(32); const obj1 = byteArrayToHashObject(input1, 0); const input2 = randomBytes(32); @@ -126,7 +126,7 @@ describe("as-sha256 non-SIMD enabled methods", function () { expect(output).to.equal(expectedOutput); }); - it("digest64HashObject() and digest2Bytes32() output matches", function () { + it("digest64HashObject() and digest2Bytes32() output matches", () => { const input1 = Buffer.from("gajindergajindergajindergajinder", "utf8"); const input2 = Buffer.from("gajindergajindergajindergajinder", "utf8"); const output = digest2Bytes32(input1, input2); diff --git a/packages/persistent-merkle-tree/src/gindex.ts b/packages/persistent-merkle-tree/src/gindex.ts index efa7a8c30..9fb82e4a5 100644 --- a/packages/persistent-merkle-tree/src/gindex.ts +++ b/packages/persistent-merkle-tree/src/gindex.ts @@ -17,9 +17,8 @@ export function toGindexBitstring(depth: number, index: number): GindexBitstring const str = index ? Number(index).toString(2) : ""; if (str.length > depth) { throw new Error("index too large for depth"); - } else { - return "1" + str.padStart(depth, "0"); } + return "1" + str.padStart(depth, "0"); } export function convertGindexToBitstring(gindex: Gindex | GindexBitstring): GindexBitstring { @@ -28,12 +27,11 @@ export function convertGindexToBitstring(gindex: Gindex | GindexBitstring): Gind throw new Error(ERR_INVALID_GINDEX); } return gindex; - } else { - if (gindex < 1) { - throw new Error(ERR_INVALID_GINDEX); - } - return gindex.toString(2); } + if (gindex < 1) { + throw new Error(ERR_INVALID_GINDEX); + } + return gindex.toString(2); } // Get the depth (root starting at 0) necessary to cover a subtree of `count` elements. @@ -63,9 +61,8 @@ export function iterateAtDepth(depth: number, startIndex: bigint, count: bigint) const value = i; i++; return {done: false, value}; - } else { - return {done: true, value: undefined}; } + return {done: true, value: undefined}; }, }; }, diff --git a/packages/persistent-merkle-tree/src/hasher/as-sha256.ts b/packages/persistent-merkle-tree/src/hasher/as-sha256.ts index 2eb26d1b1..34b9a405b 100644 --- a/packages/persistent-merkle-tree/src/hasher/as-sha256.ts +++ b/packages/persistent-merkle-tree/src/hasher/as-sha256.ts @@ -1,13 +1,13 @@ import { + batchHash4HashObjectInputs, digest2Bytes32, - digest64HashObjectsInto, digest64HashObjects, - batchHash4HashObjectInputs, + digest64HashObjectsInto, hashInto, } from "@chainsafe/as-sha256"; -import type {Hasher} from "./types.js"; -import {Node} from "../node.js"; import type {HashComputationLevel} from "../hashComputation.js"; +import {Node} from "../node.js"; +import type {Hasher} from "./types.js"; import {BLOCK_SIZE, doDigestNLevel, doMerkleizeBlockArray, doMerkleizeBlocksBytes} from "./util.js"; /** @@ -21,7 +21,7 @@ export const hasher: Hasher = { digest64: digest2Bytes32, digest64HashObjects: digest64HashObjectsInto, merkleizeBlocksBytes(blocksBytes: Uint8Array, padFor: number, output: Uint8Array, offset: number): void { - return doMerkleizeBlocksBytes(blocksBytes, padFor, output, offset, hashInto); + doMerkleizeBlocksBytes(blocksBytes, padFor, output, offset, hashInto); }, merkleizeBlockArray(blocks, blockLimit, padFor, output, offset) { return doMerkleizeBlockArray(blocks, blockLimit, padFor, output, offset, hashInto, buffer); diff --git a/packages/persistent-merkle-tree/src/hasher/hashtree.ts b/packages/persistent-merkle-tree/src/hasher/hashtree.ts index 27183ec4d..6376e269a 100644 --- a/packages/persistent-merkle-tree/src/hasher/hashtree.ts +++ b/packages/persistent-merkle-tree/src/hasher/hashtree.ts @@ -1,8 +1,8 @@ +import {byteArrayIntoHashObject} from "@chainsafe/as-sha256"; import {hashInto} from "@chainsafe/hashtree"; -import {Hasher, HashObject} from "./types.js"; -import {Node} from "../node.js"; import type {HashComputationLevel} from "../hashComputation.js"; -import {byteArrayIntoHashObject} from "@chainsafe/as-sha256"; +import {Node} from "../node.js"; +import {HashObject, Hasher} from "./types.js"; import {doDigestNLevel, doMerkleizeBlockArray, doMerkleizeBlocksBytes} from "./util.js"; /** @@ -41,7 +41,7 @@ export const hasher: Hasher = { byteArrayIntoHashObject(hash64Output, 0, parent); }, merkleizeBlocksBytes(blocksBytes: Uint8Array, padFor: number, output: Uint8Array, offset: number): void { - return doMerkleizeBlocksBytes(blocksBytes, padFor, output, offset, hashInto); + doMerkleizeBlocksBytes(blocksBytes, padFor, output, offset, hashInto); }, merkleizeBlockArray(blocks, blockLimit, padFor, output, offset) { return doMerkleizeBlockArray(blocks, blockLimit, padFor, output, offset, hashInto, uint8Input); diff --git a/packages/persistent-merkle-tree/src/hasher/index.ts b/packages/persistent-merkle-tree/src/hasher/index.ts index 0aaadb9d4..d9019e957 100644 --- a/packages/persistent-merkle-tree/src/hasher/index.ts +++ b/packages/persistent-merkle-tree/src/hasher/index.ts @@ -1,6 +1,6 @@ -import {Hasher} from "./types.js"; -import {hasher as nobleHasher} from "./noble.js"; import type {HashComputationLevel} from "../hashComputation.js"; +import {hasher as nobleHasher} from "./noble.js"; +import {Hasher} from "./types.js"; export * from "./types.js"; export * from "./util.js"; diff --git a/packages/persistent-merkle-tree/src/hasher/noble.ts b/packages/persistent-merkle-tree/src/hasher/noble.ts index 9096dbb41..f1dac5382 100644 --- a/packages/persistent-merkle-tree/src/hasher/noble.ts +++ b/packages/persistent-merkle-tree/src/hasher/noble.ts @@ -1,5 +1,5 @@ +import {byteArrayIntoHashObject, digest64HashObjects} from "@chainsafe/as-sha256"; import {sha256} from "@noble/hashes/sha256"; -import {digest64HashObjects, byteArrayIntoHashObject} from "@chainsafe/as-sha256"; import type {Hasher} from "./types.js"; import { BLOCK_SIZE, @@ -38,7 +38,7 @@ export const hasher: Hasher = { byteArrayIntoHashObject(digest64(hashObjectToUint8Array(left), hashObjectToUint8Array(right)), 0, parent); }, merkleizeBlocksBytes(blocksBytes: Uint8Array, padFor: number, output: Uint8Array, offset: number): void { - return doMerkleizeBlocksBytes(blocksBytes, padFor, output, offset, hashInto); + doMerkleizeBlocksBytes(blocksBytes, padFor, output, offset, hashInto); }, merkleizeBlockArray(blocks, blockLimit, padFor, output, offset) { return doMerkleizeBlockArray(blocks, blockLimit, padFor, output, offset, hashInto, buffer); diff --git a/packages/persistent-merkle-tree/src/hasher/util.ts b/packages/persistent-merkle-tree/src/hasher/util.ts index a93ec2d26..f2276cafe 100644 --- a/packages/persistent-merkle-tree/src/hasher/util.ts +++ b/packages/persistent-merkle-tree/src/hasher/util.ts @@ -1,4 +1,4 @@ -import {byteArrayToHashObject, HashObject, hashObjectToByteArray} from "@chainsafe/as-sha256"; +import {HashObject, byteArrayToHashObject, hashObjectToByteArray} from "@chainsafe/as-sha256"; import {zeroHash} from "../zeroHash.js"; export function hashObjectToUint8Array(obj: HashObject): Uint8Array { diff --git a/packages/persistent-merkle-tree/src/node.ts b/packages/persistent-merkle-tree/src/node.ts index b522fa747..672c4e2ac 100644 --- a/packages/persistent-merkle-tree/src/node.ts +++ b/packages/persistent-merkle-tree/src/node.ts @@ -58,7 +58,10 @@ export abstract class Node implements HashObject { * An immutable binary merkle tree node that has a `left` and `right` child */ export class BranchNode extends Node { - constructor(private _left: Node, private _right: Node) { + constructor( + private _left: Node, + private _right: Node + ) { // First null value is to save an extra variable to check if a node has a root or not super(null as unknown as number, 0, 0, 0, 0, 0, 0, 0); @@ -115,7 +118,7 @@ export class LeafNode extends Node { } static fromRoot(root: Uint8Array): LeafNode { - return this.fromHashObject(uint8ArrayToHashObject(root)); + return LeafNode.fromHashObject(uint8ArrayToHashObject(root)); } /** @@ -164,34 +167,29 @@ export class LeafNode extends Node { const h = getNodeH(this, hIndex); if (uintBytes === 1) { return 0xff & (h >> bitIndex); - } else { - return 0xffff & (h >> bitIndex); } + return 0xffff & (h >> bitIndex); } // number equals the h value - else if (uintBytes === 4) { + if (uintBytes === 4) { return getNodeH(this, hIndex) >>> 0; } // number spans 2 h values - else if (uintBytes === 8) { + if (uintBytes === 8) { const low = getNodeH(this, hIndex); const high = getNodeH(this, hIndex + 1); - if (high === 0) { - return low >>> 0; - } else if (high === -1 && low === -1 && clipInfinity) { + if (high === 0) return low >>> 0; + if (high === -1 && low === -1 && clipInfinity) { // Limit uint returns - return Infinity; - } else { - return (low >>> 0) + (high >>> 0) * TWO_POWER_32; + return Number.POSITIVE_INFINITY; } + return (low >>> 0) + (high >>> 0) * TWO_POWER_32; } // Bigger uint can't be represented - else { - throw Error("uintBytes > 8"); - } + throw Error("uintBytes > 8"); } getUintBigint(uintBytes: number, offsetBytes: number): bigint { @@ -201,27 +199,23 @@ export class LeafNode extends Node { if (uintBytes < 4) { const bitIndex = (offsetBytes % 4) * 8; const h = getNodeH(this, hIndex); - if (uintBytes === 1) { - return BigInt(0xff & (h >> bitIndex)); - } else { - return BigInt(0xffff & (h >> bitIndex)); - } + if (uintBytes === 1) return BigInt(0xff & (h >> bitIndex)); + + return BigInt(0xffff & (h >> bitIndex)); } // number equals the h value - else if (uintBytes === 4) { + if (uintBytes === 4) { return BigInt(getNodeH(this, hIndex) >>> 0); } // number spans multiple h values - else { - const hRange = Math.ceil(uintBytes / 4); - let v = BigInt(0); - for (let i = 0; i < hRange; i++) { - v += BigInt(getNodeH(this, hIndex + i) >>> 0) << BigInt(32 * i); - } - return v; + const hRange = Math.ceil(uintBytes / 4); + let v = BigInt(0); + for (let i = 0; i < hRange; i++) { + v += BigInt(getNodeH(this, hIndex + i) >>> 0) << BigInt(32 * i); } + return v; } setUint(uintBytes: number, offsetBytes: number, value: number, clipInfinity?: boolean): void { @@ -248,7 +242,7 @@ export class LeafNode extends Node { // number spans 2 h values else if (uintBytes === 8) { - if (value === Infinity && clipInfinity) { + if (value === Number.POSITIVE_INFINITY && clipInfinity) { setNodeH(this, hIndex, -1); setNodeH(this, hIndex + 1, -1); } else { @@ -330,21 +324,19 @@ export function identity(n: Node): Node { } export function compose(inner: Link, outer: Link): Link { - return function (n: Node): Node { - return outer(inner(n)); - }; + return (n: Node): Node => outer(inner(n)); } export function getNodeH(node: Node, hIndex: number): number { if (hIndex === 0) return node.h0; - else if (hIndex === 1) return node.h1; - else if (hIndex === 2) return node.h2; - else if (hIndex === 3) return node.h3; - else if (hIndex === 4) return node.h4; - else if (hIndex === 5) return node.h5; - else if (hIndex === 6) return node.h6; - else if (hIndex === 7) return node.h7; - else throw Error("hIndex > 7"); + if (hIndex === 1) return node.h1; + if (hIndex === 2) return node.h2; + if (hIndex === 3) return node.h3; + if (hIndex === 4) return node.h4; + if (hIndex === 5) return node.h5; + if (hIndex === 6) return node.h6; + if (hIndex === 7) return node.h7; + throw Error("hIndex > 7"); } export function setNodeH(node: Node, hIndex: number, value: number): void { diff --git a/packages/persistent-merkle-tree/src/packedNode.ts b/packages/persistent-merkle-tree/src/packedNode.ts index 0644a5b81..7271ec788 100644 --- a/packages/persistent-merkle-tree/src/packedNode.ts +++ b/packages/persistent-merkle-tree/src/packedNode.ts @@ -1,5 +1,5 @@ +import {LeafNode, Node, getNodeH, setNodeH} from "./node.js"; import {subtreeFillToContents} from "./subtree.js"; -import {Node, LeafNode, getNodeH, setNodeH} from "./node.js"; const NUMBER_2_POW_32 = 2 ** 32; @@ -28,7 +28,7 @@ export function packedUintNum64sToLeafNodes(values: number[]): LeafNode[] { const hIndex = 2 * vIndex; const value = values[i]; // same logic to UintNumberType.value_serializeToBytes() for 8 bytes - if (value === Infinity) { + if (value === Number.POSITIVE_INFINITY) { setNodeH(leafNode, hIndex, 0xffffffff); setNodeH(leafNode, hIndex + 1, 0xffffffff); } else { diff --git a/packages/persistent-merkle-tree/src/proof/compactMulti.ts b/packages/persistent-merkle-tree/src/proof/compactMulti.ts index 712cdb1e9..359f07af1 100644 --- a/packages/persistent-merkle-tree/src/proof/compactMulti.ts +++ b/packages/persistent-merkle-tree/src/proof/compactMulti.ts @@ -1,4 +1,4 @@ -import {convertGindexToBitstring, Gindex, GindexBitstring} from "../gindex.js"; +import {Gindex, GindexBitstring, convertGindexToBitstring} from "../gindex.js"; import {BranchNode, LeafNode, Node} from "../node.js"; import {computeProofBitstrings} from "./util.js"; @@ -29,7 +29,7 @@ export function computeDescriptor(indices: Gindex[]): Uint8Array { let descriptorBitstring = ""; for (const gindexBitstring of allBitstringsSorted) { for (let i = 0; i < gindexBitstring.length; i++) { - if (gindexBitstring[gindexBitstring.length - 1 - i] === "1") { + if (gindexBitstring.at(-1 - i) === "1") { descriptorBitstring += "1".padStart(i + 1, "0"); break; } @@ -37,7 +37,7 @@ export function computeDescriptor(indices: Gindex[]): Uint8Array { } // append zero bits to byte-alignt - if (descriptorBitstring.length % 8 != 0) { + if (descriptorBitstring.length % 8 !== 0) { descriptorBitstring = descriptorBitstring.padEnd( 8 - (descriptorBitstring.length % 8) + descriptorBitstring.length, "0" @@ -111,11 +111,10 @@ export function descriptorToBitlist(descriptor: Uint8Array): boolean[] { export function nodeToCompactMultiProof(node: Node, bitlist: boolean[], bitIndex: number): Uint8Array[] { if (bitlist[bitIndex]) { return [node.root]; - } else { - const left = nodeToCompactMultiProof(node.left, bitlist, bitIndex + 1); - const right = nodeToCompactMultiProof(node.right, bitlist, bitIndex + left.length * 2); - return [...left, ...right]; } + const left = nodeToCompactMultiProof(node.left, bitlist, bitIndex + 1); + const right = nodeToCompactMultiProof(node.right, bitlist, bitIndex + left.length * 2); + return [...left, ...right]; } /** @@ -130,12 +129,11 @@ export function compactMultiProofToNode( ): Node { if (bitlist[pointer.bitIndex++]) { return LeafNode.fromRoot(leaves[pointer.leafIndex++]); - } else { - return new BranchNode( - compactMultiProofToNode(bitlist, leaves, pointer), - compactMultiProofToNode(bitlist, leaves, pointer) - ); } + return new BranchNode( + compactMultiProofToNode(bitlist, leaves, pointer), + compactMultiProofToNode(bitlist, leaves, pointer) + ); } export function createCompactMultiProof(rootNode: Node, descriptor: Uint8Array): Uint8Array[] { diff --git a/packages/persistent-merkle-tree/src/proof/index.ts b/packages/persistent-merkle-tree/src/proof/index.ts index 6fea37c39..168c788c1 100644 --- a/packages/persistent-merkle-tree/src/proof/index.ts +++ b/packages/persistent-merkle-tree/src/proof/index.ts @@ -1,7 +1,7 @@ import {Gindex} from "../gindex.js"; import {Node} from "../node.js"; +import {createCompactMultiProof, createNodeFromCompactMultiProof} from "./compactMulti.js"; import {createMultiProof, createNodeFromMultiProof} from "./multi.js"; -import {createNodeFromCompactMultiProof, createCompactMultiProof} from "./compactMulti.js"; import {createNodeFromSingleProof, createSingleProof} from "./single.js"; import { computeTreeOffsetProofSerializedLength, diff --git a/packages/persistent-merkle-tree/src/proof/multi.ts b/packages/persistent-merkle-tree/src/proof/multi.ts index 3c6d6eaab..707adddcf 100644 --- a/packages/persistent-merkle-tree/src/proof/multi.ts +++ b/packages/persistent-merkle-tree/src/proof/multi.ts @@ -1,7 +1,7 @@ import {Gindex} from "../gindex.js"; import {BranchNode, LeafNode, Node} from "../node.js"; import {Tree} from "../tree.js"; -import {computeMultiProofBitstrings, SortOrder} from "./util.js"; +import {SortOrder, computeMultiProofBitstrings} from "./util.js"; /** * Create an multiproof @@ -80,7 +80,7 @@ export function createNodeFromMultiProof(leaves: Uint8Array[], witnesses: Uint8A continue; } - const isLeft = bitstring[bitstring.length - 1] === "0"; + const isLeft = bitstring.at(-1) === "0"; const parentBitstring = bitstring.substring(0, bitstring.length - 1); const siblingBitstring = parentBitstring + (isLeft ? "1" : "0"); diff --git a/packages/persistent-merkle-tree/src/proof/single.ts b/packages/persistent-merkle-tree/src/proof/single.ts index 31d90dd13..fde02bb8c 100644 --- a/packages/persistent-merkle-tree/src/proof/single.ts +++ b/packages/persistent-merkle-tree/src/proof/single.ts @@ -1,5 +1,5 @@ -import {BranchNode, LeafNode, Node} from "../node.js"; import {Gindex, gindexIterator} from "../gindex.js"; +import {BranchNode, LeafNode, Node} from "../node.js"; export const ERR_INVALID_NAV = "Invalid tree navigation"; diff --git a/packages/persistent-merkle-tree/src/proof/treeOffset.ts b/packages/persistent-merkle-tree/src/proof/treeOffset.ts index 10cb5e099..802081073 100644 --- a/packages/persistent-merkle-tree/src/proof/treeOffset.ts +++ b/packages/persistent-merkle-tree/src/proof/treeOffset.ts @@ -20,18 +20,19 @@ export function nodeToTreeOffsetProof( if (!proofGindices.length || !proofGindices[0].startsWith(gindex)) { // there are no proof indices left OR the current subtree contains no remaining proof indices return [[], []]; - } else if (gindex === proofGindices[0]) { + } + + if (gindex === proofGindices[0]) { // the current node is at the next proof index proofGindices.shift(); return [[], [node.root]]; - } else { - // recursively compute offsets, leaves for the left and right subtree - const [leftOffsets, leftLeaves] = nodeToTreeOffsetProof(node.left, gindex + "0", proofGindices); - const [rightOffsets, rightLeaves] = nodeToTreeOffsetProof(node.right, gindex + "1", proofGindices); - // the offset prepended to the list is # of leaves in the left subtree - const pivot = leftLeaves.length; - return [[pivot].concat(leftOffsets, rightOffsets), leftLeaves.concat(rightLeaves)]; } + // recursively compute offsets, leaves for the left and right subtree + const [leftOffsets, leftLeaves] = nodeToTreeOffsetProof(node.left, gindex + "0", proofGindices); + const [rightOffsets, rightLeaves] = nodeToTreeOffsetProof(node.right, gindex + "1", proofGindices); + // the offset prepended to the list is # of leaves in the left subtree + const pivot = leftLeaves.length; + return [[pivot].concat(leftOffsets, rightOffsets), leftLeaves.concat(rightLeaves)]; } /** @@ -42,18 +43,14 @@ export function nodeToTreeOffsetProof( * See https://github.com/protolambda/eth-merkle-trees/blob/master/tree_offsets.md */ export function treeOffsetProofToNode(offsets: number[], leaves: Uint8Array[]): Node { - if (!leaves.length) { - throw new Error("Proof must contain gt 0 leaves"); - } else if (leaves.length === 1) { - return LeafNode.fromRoot(leaves[0]); - } else { - // the offset popped from the list is the # of leaves in the left subtree - const pivot = offsets[0]; - return new BranchNode( - treeOffsetProofToNode(offsets.slice(1, pivot), leaves.slice(0, pivot)), - treeOffsetProofToNode(offsets.slice(pivot), leaves.slice(pivot)) - ); - } + if (!leaves.length) throw new Error("Proof must contain gt 0 leaves"); + if (leaves.length === 1) return LeafNode.fromRoot(leaves[0]); + // the offset popped from the list is the # of leaves in the left subtree + const pivot = offsets[0]; + return new BranchNode( + treeOffsetProofToNode(offsets.slice(1, pivot), leaves.slice(0, pivot)), + treeOffsetProofToNode(offsets.slice(pivot), leaves.slice(pivot)) + ); } /** diff --git a/packages/persistent-merkle-tree/src/proof/util.ts b/packages/persistent-merkle-tree/src/proof/util.ts index 736102348..eda4f7164 100644 --- a/packages/persistent-merkle-tree/src/proof/util.ts +++ b/packages/persistent-merkle-tree/src/proof/util.ts @@ -34,7 +34,7 @@ export function computeProofBitstrings(gindex: GindexBitstring): { let g = gindex; while (g.length > 1) { path.add(g); - const lastBit = g[g.length - 1]; + const lastBit = g.at(-1); const parent = g.substring(0, g.length - 1); branch.add(parent + (Number(lastBit) ^ 1)); g = parent; @@ -64,26 +64,18 @@ export function sortDecreasingBitstrings(gindices: GindexBitstring[]): GindexBit return []; } return gindices.sort((a, b) => { - if (a.length < b.length) { - return 1; - } else if (b.length < a.length) { - return -1; - } + if (a.length < b.length) return 1; + if (b.length < a.length) return -1; + let aPos0 = a.indexOf("0"); let bPos0 = b.indexOf("0"); - // eslint-disable-next-line no-constant-condition + while (true) { - if (aPos0 === -1) { - return -1; - } else if (bPos0 === -1) { - return 1; - } + if (aPos0 === -1) return -1; + if (bPos0 === -1) return 1; - if (aPos0 < bPos0) { - return 1; - } else if (bPos0 < aPos0) { - return -1; - } + if (aPos0 < bPos0) return 1; + if (bPos0 < aPos0) return -1; aPos0 = a.indexOf("0", aPos0 + 1); bPos0 = b.indexOf("0", bPos0 + 1); @@ -111,9 +103,9 @@ export function filterParentBitstrings(gindices: GindexBitstring[]): GindexBitst } export enum SortOrder { - InOrder, - Decreasing, - Unsorted, + InOrder = 0, + Decreasing = 1, + Unsorted = 2, } /** @@ -138,14 +130,22 @@ export function computeMultiProofBitstrings( for (const gindex of leaves) { if (gindex.length > maxBitLength) maxBitLength = gindex.length; const {path, branch} = computeProofBitstrings(gindex); - path.forEach((g) => paths.add(g)); - branch.forEach((g) => branches.add(g)); + for (const p of path) { + paths.add(p); + } + for (const b of branch) { + branches.add(b); + } } // Remove all branches that are included in the paths - paths.forEach((g) => branches.delete(g)); + for (const p of paths) { + branches.delete(p); + } // Add all remaining branches to the leaves - branches.forEach((g) => proof.add(g)); + for (const b of branches) { + proof.add(b); + } switch (sortOrder) { case SortOrder.InOrder: diff --git a/packages/persistent-merkle-tree/src/snapshot.ts b/packages/persistent-merkle-tree/src/snapshot.ts index 26ab1c471..a343f841f 100644 --- a/packages/persistent-merkle-tree/src/snapshot.ts +++ b/packages/persistent-merkle-tree/src/snapshot.ts @@ -1,7 +1,7 @@ -import {Tree, getNode} from "./tree.js"; -import {zeroNode} from "./zeroNode.js"; import {Gindex, toGindex} from "./gindex.js"; import {LeafNode, Node} from "./node.js"; +import {Tree, getNode} from "./tree.js"; +import {zeroNode} from "./zeroNode.js"; type Snapshot = { finalized: Uint8Array[]; diff --git a/packages/persistent-merkle-tree/src/subtree.ts b/packages/persistent-merkle-tree/src/subtree.ts index 4d3c6bb95..fd028c6d4 100644 --- a/packages/persistent-merkle-tree/src/subtree.ts +++ b/packages/persistent-merkle-tree/src/subtree.ts @@ -1,5 +1,5 @@ +import {HashComputationLevel, getHashComputations, levelAtIndex} from "./hashComputation.js"; import {BranchNode, Node} from "./node.js"; -import {getHashComputations, levelAtIndex, HashComputationLevel} from "./hashComputation.js"; import {zeroNode} from "./zeroNode.js"; export function subtreeFillToDepth(bottom: Node, depth: number): Node { @@ -18,7 +18,7 @@ export function subtreeFillToLength(bottom: Node, depth: number, length: number) if (depth === 0) { if (length === 1) return bottom; - else throw new Error("ERR_NAVIGATION"); + throw new Error("ERR_NAVIGATION"); } if (depth === 1) { @@ -28,12 +28,9 @@ export function subtreeFillToLength(bottom: Node, depth: number, length: number) const pivot = maxLength >> 1; if (length <= pivot) { return new BranchNode(subtreeFillToLength(bottom, depth - 1, length), zeroNode(depth - 1)); - } else { - return new BranchNode( - subtreeFillToDepth(bottom, depth - 1), - subtreeFillToLength(bottom, depth - 1, length - pivot) - ); } + + return new BranchNode(subtreeFillToDepth(bottom, depth - 1), subtreeFillToLength(bottom, depth - 1, length - pivot)); } /** diff --git a/packages/persistent-merkle-tree/src/tree.ts b/packages/persistent-merkle-tree/src/tree.ts index fbb1997b1..6872cdfb1 100644 --- a/packages/persistent-merkle-tree/src/tree.ts +++ b/packages/persistent-merkle-tree/src/tree.ts @@ -1,9 +1,9 @@ -import {zeroNode} from "./zeroNode.js"; import {Gindex, GindexBitstring, convertGindexToBitstring} from "./gindex.js"; -import {Node, LeafNode, BranchNode} from "./node.js"; import {HashComputationLevel, levelAtIndex} from "./hashComputation.js"; -import {createNodeFromProof, createProof, Proof, ProofInput} from "./proof/index.js"; +import {BranchNode, LeafNode, Node} from "./node.js"; +import {Proof, ProofInput, createNodeFromProof, createProof} from "./proof/index.js"; import {createSingleProof} from "./proof/single.js"; +import {zeroNode} from "./zeroNode.js"; export type Hook = (newRootNode: Node) => void; @@ -237,8 +237,9 @@ export function setNodeWithFn( // Pre-compute entire bitstring instead of using an iterator (25% faster) const gindexBitstring = convertGindexToBitstring(gindex); const parentNodes = getParentNodes(rootNode, gindexBitstring); - const lastParentNode = parentNodes[parentNodes.length - 1]; - const lastBit = gindexBitstring[gindexBitstring.length - 1]; + const lastParentNode = parentNodes.at(-1); + if (!lastParentNode) throw new Error("Invalid tree - can not find last parent"); + const lastBit = gindexBitstring.at(-1); const oldNode = lastBit === "1" ? lastParentNode.right : lastParentNode.left; const newNode = getNewNode(oldNode); @@ -541,14 +542,14 @@ export function getNodesAtDepth(rootNode: Node, depth: number, startIndex: numbe // Optimized paths for short trees (x20 times faster) if (depth === 0) { return startIndex === 0 && count > 0 ? [rootNode] : []; - } else if (depth === 1) { - if (count === 0) { - return []; - } else if (count === 1) { + } + + if (depth === 1) { + if (count === 0) return []; + if (count === 1) { return startIndex === 0 ? [rootNode.left] : [rootNode.right]; - } else { - return [rootNode.left, rootNode.right]; } + return [rootNode.left, rootNode.right]; } // Ignore first bit "1", then substract 1 to get to the parent diff --git a/packages/persistent-merkle-tree/test/perf/gindex.test.ts b/packages/persistent-merkle-tree/test/perf/gindex.test.ts index 83df559b9..2abb1fbe7 100644 --- a/packages/persistent-merkle-tree/test/perf/gindex.test.ts +++ b/packages/persistent-merkle-tree/test/perf/gindex.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import {getGindexBits, getGindicesAtDepth, gindexIterator, iterateAtDepth} from "../../src/index.js"; describe("gindices at depth", () => { @@ -17,9 +17,8 @@ describe("gindices at depth", () => { }); bench("iterateAtDepth", () => { - for (let gindex of iterateAtDepth(depth, BigInt(startIx), BigInt(count))) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - gindex++; + for (let _gindex of iterateAtDepth(depth, BigInt(startIx), BigInt(count))) { + _gindex++; } }); }); diff --git a/packages/persistent-merkle-tree/test/perf/hashComputation.test.ts b/packages/persistent-merkle-tree/test/perf/hashComputation.test.ts index f8ca1979e..f1bda2c6a 100644 --- a/packages/persistent-merkle-tree/test/perf/hashComputation.test.ts +++ b/packages/persistent-merkle-tree/test/perf/hashComputation.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import {HashComputation, HashComputationLevel, LeafNode, zeroHash} from "../../src/index.js"; /** @@ -8,7 +8,7 @@ import {HashComputation, HashComputationLevel, LeafNode, zeroHash} from "../../s ✓ HashComputationLevel.push then loop 58.75361 ops/s 17.02023 ms/op - 19 runs 0.835 s ✓ HashComputation[] push then loop 36.51973 ops/s 27.38246 ms/op - 150 runs 4.63 s */ -describe("HashComputationLevel", function () { +describe("HashComputationLevel", () => { const src = LeafNode.fromRoot(zeroHash(0)); const dest = LeafNode.fromRoot(zeroHash(1)); const hashComp: HashComputation = {src0: src, src1: src, dest, next: null}; @@ -28,6 +28,7 @@ describe("HashComputationLevel", function () { } level.clean(); for (const hc of level) { + // biome-ignore lint/correctness/noUnusedVariables: We need to extract values for performance tests const {src0, src1, dest} = hc; } }, @@ -41,6 +42,7 @@ describe("HashComputationLevel", function () { level.push(hashComp); } for (const hc of level) { + // biome-ignore lint/correctness/noUnusedVariables: We need to extract values for performance tests const {src0, src1, dest} = hc; } }, diff --git a/packages/persistent-merkle-tree/test/perf/hasher.test.ts b/packages/persistent-merkle-tree/test/perf/hasher.test.ts index bb306866e..516cfaff8 100644 --- a/packages/persistent-merkle-tree/test/perf/hasher.test.ts +++ b/packages/persistent-merkle-tree/test/perf/hasher.test.ts @@ -1,12 +1,12 @@ -import {describe, bench} from "@chainsafe/benchmark"; -import {Hasher, HashObject, setHasher, uint8ArrayToHashObject} from "../../src/hasher/index.js"; +import {bench, describe} from "@chainsafe/benchmark"; import {hasher as asSha256Hasher} from "../../src/hasher/as-sha256.js"; -import {hasher as nobleHasher} from "../../src/hasher/noble.js"; import {hasher as hashtreeHasher} from "../../src/hasher/hashtree.js"; -import {buildComparisonTrees} from "../utils/tree.js"; +import {HashObject, Hasher, setHasher, uint8ArrayToHashObject} from "../../src/hasher/index.js"; +import {hasher as nobleHasher} from "../../src/hasher/noble.js"; import {HashComputationLevel, getHashComputations} from "../../src/index.js"; +import {buildComparisonTrees} from "../utils/tree.js"; -describe("hasher", function () { +describe("hasher", () => { const iterations = 500_000; const root1 = new Uint8Array(32); @@ -65,7 +65,7 @@ describe("hasher", function () { } }); -describe("hashtree", function () { +describe("hashtree", () => { bench({ id: "getHashComputations", beforeEach: () => { diff --git a/packages/persistent-merkle-tree/test/perf/node.test.ts b/packages/persistent-merkle-tree/test/perf/node.test.ts index 06d145bc4..8eafa86b0 100644 --- a/packages/persistent-merkle-tree/test/perf/node.test.ts +++ b/packages/persistent-merkle-tree/test/perf/node.test.ts @@ -1,6 +1,6 @@ -import {describe, bench} from "@chainsafe/benchmark"; -import {BranchNode, getNodeH, LeafNode} from "../../src/node.js"; +import {bench, describe} from "@chainsafe/benchmark"; import {countToDepth, getHashComputations, subtreeFillToContents} from "../../src/index.js"; +import {BranchNode, LeafNode, getNodeH} from "../../src/node.js"; import {batchHash} from "../utils/batchHash.js"; describe("HashObject LeafNode", () => { diff --git a/packages/persistent-merkle-tree/test/perf/proof.test.ts b/packages/persistent-merkle-tree/test/perf/proof.test.ts index 6d5bad30f..915d6d8d3 100644 --- a/packages/persistent-merkle-tree/test/perf/proof.test.ts +++ b/packages/persistent-merkle-tree/test/perf/proof.test.ts @@ -1,5 +1,5 @@ -import {describe, bench} from "@chainsafe/benchmark"; -import {computeDescriptor, createProof, ProofType} from "../../src/proof/index.js"; +import {bench, describe} from "@chainsafe/benchmark"; +import {ProofType, computeDescriptor, createProof} from "../../src/proof/index.js"; import {createTree} from "../utils/tree.js"; describe("Proofs", () => { diff --git a/packages/persistent-merkle-tree/test/perf/subtree.test.ts b/packages/persistent-merkle-tree/test/perf/subtree.test.ts index 15f52d4f2..0dc2b7280 100644 --- a/packages/persistent-merkle-tree/test/perf/subtree.test.ts +++ b/packages/persistent-merkle-tree/test/perf/subtree.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import {Node} from "../../src/node.js"; import {packedRootsBytesToLeafNodes} from "../../src/packedNode.js"; import {subtreeFillToContents} from "../../src/subtree.js"; diff --git a/packages/persistent-merkle-tree/test/perf/tree.test.ts b/packages/persistent-merkle-tree/test/perf/tree.test.ts index 63f559389..e4a638c4f 100644 --- a/packages/persistent-merkle-tree/test/perf/tree.test.ts +++ b/packages/persistent-merkle-tree/test/perf/tree.test.ts @@ -1,13 +1,13 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import { LeafNode, - subtreeFillToContents, Node, - countToDepth, Tree, + countToDepth, + subtreeFillToContents, toGindex, - uint8ArrayToHashObject, toGindexBitstring, + uint8ArrayToHashObject, } from "../../src/index.js"; describe("Track the performance of different Tree methods", () => { diff --git a/packages/persistent-merkle-tree/test/perf/tree/depthSmall.test.ts b/packages/persistent-merkle-tree/test/perf/tree/depthSmall.test.ts index 9b5d0c805..aaa273f95 100644 --- a/packages/persistent-merkle-tree/test/perf/tree/depthSmall.test.ts +++ b/packages/persistent-merkle-tree/test/perf/tree/depthSmall.test.ts @@ -1,6 +1,6 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import {getNodeAtDepth, getNodesAtDepth, setNodeAtDepth, setNodesAtDepth, zeroNode} from "../../../src/index.js"; -import {linspace, fillArray} from "../../utils/misc.js"; +import {fillArray, linspace} from "../../utils/misc.js"; describe("Tree opts with low depth", () => { const runsFactor = 100_000; diff --git a/packages/persistent-merkle-tree/test/perf/tree/getNodes.test.ts b/packages/persistent-merkle-tree/test/perf/tree/getNodes.test.ts index fffef9947..92b173f6d 100644 --- a/packages/persistent-merkle-tree/test/perf/tree/getNodes.test.ts +++ b/packages/persistent-merkle-tree/test/perf/tree/getNodes.test.ts @@ -1,12 +1,12 @@ -import {describe, bench, beforeAll} from "@chainsafe/benchmark"; +import {beforeAll, bench, describe} from "@chainsafe/benchmark"; import { - subtreeFillToContents, - Tree, - Node, + BranchNode, LeafNode, + Node, + Tree, getNodesAtDepth, + subtreeFillToContents, zeroNode, - BranchNode, } from "../../../src/index.js"; // Results in Linux Dec 2021 diff --git a/packages/persistent-merkle-tree/test/perf/tree/setNodes.test.ts b/packages/persistent-merkle-tree/test/perf/tree/setNodes.test.ts index da3305be7..591fdbf26 100644 --- a/packages/persistent-merkle-tree/test/perf/tree/setNodes.test.ts +++ b/packages/persistent-merkle-tree/test/perf/tree/setNodes.test.ts @@ -1,5 +1,5 @@ -import {describe, bench, beforeAll} from "@chainsafe/benchmark"; -import {subtreeFillToContents, Tree, Node, LeafNode, toGindex, setNodesAtDepth} from "../../../src/index.js"; +import {beforeAll, bench, describe} from "@chainsafe/benchmark"; +import {LeafNode, Node, Tree, setNodesAtDepth, subtreeFillToContents, toGindex} from "../../../src/index.js"; // Results in Linux Dec 2021 // diff --git a/packages/persistent-merkle-tree/test/perf/treeDepth.test.ts b/packages/persistent-merkle-tree/test/perf/treeDepth.test.ts index 0668b87f3..562d60e6a 100644 --- a/packages/persistent-merkle-tree/test/perf/treeDepth.test.ts +++ b/packages/persistent-merkle-tree/test/perf/treeDepth.test.ts @@ -1,5 +1,5 @@ -import {describe, bench} from "@chainsafe/benchmark"; -import {Tree, iterateAtDepth, LeafNode, subtreeFillToDepth} from "../../src/index.js"; +import {bench, describe} from "@chainsafe/benchmark"; +import {LeafNode, Tree, iterateAtDepth, subtreeFillToDepth} from "../../src/index.js"; describe("Tree", () => { for (const depth of [8, 16, 32]) { diff --git a/packages/persistent-merkle-tree/test/perf/validators.test.ts b/packages/persistent-merkle-tree/test/perf/validators.test.ts index 93489b764..776e8bc57 100644 --- a/packages/persistent-merkle-tree/test/perf/validators.test.ts +++ b/packages/persistent-merkle-tree/test/perf/validators.test.ts @@ -1,7 +1,7 @@ import {bench, describe, setBenchOpts} from "@chainsafe/benchmark"; -import {LeafNode, subtreeFillToContents, Node, countToDepth, zeroNode, getHashComputations} from "../../src/index.js"; -import {MemoryTracker} from "../utils/memTracker.js"; +import {LeafNode, Node, countToDepth, getHashComputations, subtreeFillToContents, zeroNode} from "../../src/index.js"; import {batchHash} from "../utils/batchHash.js"; +import {MemoryTracker} from "../utils/memTracker.js"; /** * Below is measured on Mac M1. diff --git a/packages/persistent-merkle-tree/test/unit/backing.test.ts b/packages/persistent-merkle-tree/test/unit/backing.test.ts index 0d28b3c5e..3faf67026 100644 --- a/packages/persistent-merkle-tree/test/unit/backing.test.ts +++ b/packages/persistent-merkle-tree/test/unit/backing.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {Tree, LeafNode, subtreeFillToDepth} from "../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {LeafNode, Tree, subtreeFillToDepth} from "../../src/index.js"; describe("get", () => { it("should return the right node", () => { diff --git a/packages/persistent-merkle-tree/test/unit/gindex.test.ts b/packages/persistent-merkle-tree/test/unit/gindex.test.ts index c8ce814e2..f08e2ef26 100644 --- a/packages/persistent-merkle-tree/test/unit/gindex.test.ts +++ b/packages/persistent-merkle-tree/test/unit/gindex.test.ts @@ -1,14 +1,14 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { - countToDepth, - bitIndexBigInt, - iterateAtDepth, + Bit, Gindex, - gindexIterator, + bitIndexBigInt, concatGindices, - Bit, - getGindicesAtDepth, + countToDepth, getGindexBits, + getGindicesAtDepth, + gindexIterator, + iterateAtDepth, } from "../../src/index.js"; describe("countToDepth", () => { diff --git a/packages/persistent-merkle-tree/test/unit/hashComputation.test.ts b/packages/persistent-merkle-tree/test/unit/hashComputation.test.ts index 6ce413408..5443a1e9a 100644 --- a/packages/persistent-merkle-tree/test/unit/hashComputation.test.ts +++ b/packages/persistent-merkle-tree/test/unit/hashComputation.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect, beforeEach} from "vitest"; -import {zeroNode, Node} from "../../src/index.js"; +import {beforeEach, describe, expect, it} from "vitest"; import {HashComputationLevel} from "../../src/hashComputation.js"; +import {Node, zeroNode} from "../../src/index.js"; describe("HashComputationLevel", () => { let hashComputationLevel: HashComputationLevel; @@ -66,10 +66,10 @@ describe("HashComputationLevel", () => { const arr = toArray(hashComputationLevel); expect(arr).to.be.deep.equal([{src0: zeroNode(0), src1: zeroNode(0), dest: zeroNode(1)}]); const all = hashComputationLevel.dump(); - const last = all[all.length - 1]; - expect(last.src0).toBeNull(); - expect(last.src1).toBeNull(); - expect(last.dest).toBeNull(); + const last = all.at(-1); + expect(last?.src0).toBeNull(); + expect(last?.src1).toBeNull(); + expect(last?.dest).toBeNull(); }); }); diff --git a/packages/persistent-merkle-tree/test/unit/hasher.test.ts b/packages/persistent-merkle-tree/test/unit/hasher.test.ts index 4ddf66ba9..05b9a309c 100644 --- a/packages/persistent-merkle-tree/test/unit/hasher.test.ts +++ b/packages/persistent-merkle-tree/test/unit/hasher.test.ts @@ -1,11 +1,9 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; -import {expectEqualHex} from "../utils/expectHex.js"; -import {uint8ArrayToHashObject, hashObjectToUint8Array} from "../../src/hasher/util.js"; -import {hasher as nobleHasher} from "../../src/hasher/noble.js"; import {hasher as asSha256Hasher} from "../../src/hasher/as-sha256.js"; import {hasher as hashtreeHasher} from "../../src/hasher/hashtree.js"; -import {buildComparisonTrees} from "../utils/tree.js"; +import {hasher as nobleHasher} from "../../src/hasher/noble.js"; +import {hashObjectToUint8Array, uint8ArrayToHashObject} from "../../src/hasher/util.js"; import { HashComputationLevel, HashObject, @@ -15,8 +13,10 @@ import { subtreeFillToContents, } from "../../src/index.js"; import {zeroHash} from "../../src/zeroHash.js"; +import {expectEqualHex} from "../utils/expectHex.js"; +import {buildComparisonTrees} from "../utils/tree.js"; -describe("hashers", function () { +describe("hashers", () => { const hashers: Hasher[] = [hashtreeHasher, asSha256Hasher, nobleHasher]; describe("digest64 vs digest64HashObjects methods should be the same", () => { @@ -76,7 +76,7 @@ describe("hashers", function () { } }); - describe("hasher.digestNLevel", function () { + describe("hasher.digestNLevel", () => { for (const hasher of hashers) { const numValidators = [1, 2, 3, 4]; for (const numValidator of numValidators) { @@ -95,7 +95,7 @@ describe("hashers", function () { } }); - describe("hasher.merkleizeBlocksBytes", function () { + describe("hasher.merkleizeBlocksBytes", () => { const numNodes = [0, 1, 2, 3, 4, 5, 6, 7, 8]; for (const hasher of hashers) { it(`${hasher.name} should throw error if not multiple of 64 bytes`, () => { @@ -123,7 +123,7 @@ describe("hashers", function () { /** * The same to the previous test, but using the merkleizeBlockArray method */ - describe("hasher.merkleizeBlockArray", function () { + describe("hasher.merkleizeBlockArray", () => { for (const hasher of hashers) { it(`${hasher.name} should throw error if invalid blockLimit`, () => { const data = Buffer.alloc(64, 0); diff --git a/packages/persistent-merkle-tree/test/unit/node.test.ts b/packages/persistent-merkle-tree/test/unit/node.test.ts index 7e9f3d508..65a8997fb 100644 --- a/packages/persistent-merkle-tree/test/unit/node.test.ts +++ b/packages/persistent-merkle-tree/test/unit/node.test.ts @@ -1,7 +1,7 @@ import type {HashObject} from "@chainsafe/as-sha256"; -import {describe, it, expect} from "vitest"; -import {BranchNode, LeafNode, countToDepth, subtreeFillToContents} from "../../src/index.js"; +import {describe, expect, it} from "vitest"; import {HashComputation, HashComputationLevel, getHashComputations} from "../../src/hashComputation.js"; +import {BranchNode, LeafNode, countToDepth, subtreeFillToContents} from "../../src/index.js"; describe("LeafNode uint", () => { const testCasesNode: { diff --git a/packages/persistent-merkle-tree/test/unit/packedNode.test.ts b/packages/persistent-merkle-tree/test/unit/packedNode.test.ts index 47682174b..ada09ad9c 100644 --- a/packages/persistent-merkle-tree/test/unit/packedNode.test.ts +++ b/packages/persistent-merkle-tree/test/unit/packedNode.test.ts @@ -1,7 +1,11 @@ -import {describe, it, expect} from "vitest"; import type {HashObject} from "@chainsafe/as-sha256"; +import {describe, expect, it} from "vitest"; import {LeafNode, Node} from "../../src/index.js"; -import {packedNodeRootsToBytes, packedRootsBytesToLeafNodes, packedUintNum64sToLeafNodes} from "../../src/packedNode.js"; +import { + packedNodeRootsToBytes, + packedRootsBytesToLeafNodes, + packedUintNum64sToLeafNodes, +} from "../../src/packedNode.js"; describe("subtree / packedNode single node", () => { const testCases: { @@ -205,7 +209,7 @@ describe("subtree / packedNode single node", () => { const a = dataView.getUint32(i, true); const b = dataView.getUint32(i + 4, true); if (a === 0xffffffff && b === 0xffffffff) { - values.push(Infinity); + values.push(Number.POSITIVE_INFINITY); } else { values.push(b * NUMBER_2_POW_32 + a); } diff --git a/packages/persistent-merkle-tree/test/unit/proof/compactMulti.test.ts b/packages/persistent-merkle-tree/test/unit/proof/compactMulti.test.ts index ca44e9204..1e130b43d 100644 --- a/packages/persistent-merkle-tree/test/unit/proof/compactMulti.test.ts +++ b/packages/persistent-merkle-tree/test/unit/proof/compactMulti.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { - createNodeFromCompactMultiProof, + computeDescriptor, createCompactMultiProof, + createNodeFromCompactMultiProof, descriptorToBitlist, - computeDescriptor, } from "../../../src/proof/compactMulti.js"; import {createTree} from "../../utils/tree.js"; diff --git a/packages/persistent-merkle-tree/test/unit/proof/index.test.ts b/packages/persistent-merkle-tree/test/unit/proof/index.test.ts index 69e98a20a..9caaa9e7c 100644 --- a/packages/persistent-merkle-tree/test/unit/proof/index.test.ts +++ b/packages/persistent-merkle-tree/test/unit/proof/index.test.ts @@ -1,10 +1,10 @@ -import {describe, it, expect, vi} from "vitest"; +import {describe, expect, it, vi} from "vitest"; import { + ProofType, computeDescriptor, createNodeFromProof, createProof, deserializeProof, - ProofType, serializeProof, } from "../../../src/proof/index.js"; import {createTree} from "../../utils/tree.js"; diff --git a/packages/persistent-merkle-tree/test/unit/proof/treeOffset.test.ts b/packages/persistent-merkle-tree/test/unit/proof/treeOffset.test.ts index 28df6577f..1a99fc28d 100644 --- a/packages/persistent-merkle-tree/test/unit/proof/treeOffset.test.ts +++ b/packages/persistent-merkle-tree/test/unit/proof/treeOffset.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {createNodeFromTreeOffsetProof, createTreeOffsetProof} from "../../../src/proof/treeOffset.js"; import {zeroNode} from "../../../src/zeroNode.js"; diff --git a/packages/persistent-merkle-tree/test/unit/proof/util.test.ts b/packages/persistent-merkle-tree/test/unit/proof/util.test.ts index 1250a543a..fba027056 100644 --- a/packages/persistent-merkle-tree/test/unit/proof/util.test.ts +++ b/packages/persistent-merkle-tree/test/unit/proof/util.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { - computeProofGindices, + computeMultiProofBitstrings, computeProofBitstrings, - sortInOrderBitstrings, + computeProofGindices, filterParentBitstrings, - computeMultiProofBitstrings, sortDecreasingBitstrings, + sortInOrderBitstrings, } from "../../../src/proof/util.js"; describe("computeProofGindices", () => { diff --git a/packages/persistent-merkle-tree/test/unit/snapshot.test.ts b/packages/persistent-merkle-tree/test/unit/snapshot.test.ts index 174bf09cc..d19b1a52f 100644 --- a/packages/persistent-merkle-tree/test/unit/snapshot.test.ts +++ b/packages/persistent-merkle-tree/test/unit/snapshot.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; +import {toGindex} from "../../src/index.js"; +import {LeafNode} from "../../src/node.js"; import {fromSnapshot, indexToFinalizedGindices, toSnapshot} from "../../src/snapshot.js"; import {subtreeFillToContents} from "../../src/subtree.js"; -import { LeafNode } from "../../src/node.js"; -import { Tree, setNodesAtDepth } from "../../src/tree.js"; -import { toGindex } from "../../src/index.js"; +import {Tree, setNodesAtDepth} from "../../src/tree.js"; describe("toSnapshot and fromSnapshot", () => { const depth = 4; diff --git a/packages/persistent-merkle-tree/test/unit/subtree.test.ts b/packages/persistent-merkle-tree/test/unit/subtree.test.ts index edf12643b..02d9230e3 100644 --- a/packages/persistent-merkle-tree/test/unit/subtree.test.ts +++ b/packages/persistent-merkle-tree/test/unit/subtree.test.ts @@ -1,5 +1,14 @@ -import {describe, it, expect, vi} from "vitest"; -import {subtreeFillToContents, LeafNode, getNodesAtDepth, executeHashComputations, BranchNode, Node, HashComputationLevel, zeroNode} from "../../src/index.js"; +import {describe, expect, it, vi} from "vitest"; +import { + BranchNode, + HashComputationLevel, + LeafNode, + Node, + executeHashComputations, + getNodesAtDepth, + subtreeFillToContents, + zeroNode, +} from "../../src/index.js"; describe("subtreeFillToContents", () => { // the hash computation takes time @@ -58,7 +67,7 @@ describe("subtreeFillToContents", () => { } }); -describe("subtreeFillToContents with hcByLevel", function () { +describe("subtreeFillToContents with hcByLevel", () => { it("depth = 0", () => { // return zeroNode, no hash computations const nodes = [LeafNode.fromZero()]; diff --git a/packages/persistent-merkle-tree/test/unit/tree.test.ts b/packages/persistent-merkle-tree/test/unit/tree.test.ts index f51d472e7..bebb6b834 100644 --- a/packages/persistent-merkle-tree/test/unit/tree.test.ts +++ b/packages/persistent-merkle-tree/test/unit/tree.test.ts @@ -1,17 +1,17 @@ -import {describe, it, expect, beforeEach} from "vitest"; import {byteArrayToHashObject} from "@chainsafe/as-sha256"; +import {beforeEach, describe, expect, it} from "vitest"; import { - Tree, - Node, - zeroNode, + HashComputationLevel, LeafNode, - subtreeFillToContents, - uint8ArrayToHashObject, - setNodesAtDepth, + Node, + Tree, findDiffDepthi, getHashComputations, - HashComputationLevel, + setNodesAtDepth, + subtreeFillToContents, + uint8ArrayToHashObject, + zeroNode, } from "../../src/index.js"; import {batchHash} from "../utils/batchHash.js"; @@ -222,7 +222,6 @@ describe("Tree batch setNodes", () => { expect(roots).to.deep.equal(rootsOk); } catch (e) { if (process.env.DEBUG) { - /* eslint-disable no-console */ // On error print all roots for easier debugging console.log(" ", " ", "rootsOk".padEnd(64), "roots"); for (let i = 1; i < rootsOk.length; i++) { diff --git a/packages/persistent-merkle-tree/test/unit/tree/getNodes.test.ts b/packages/persistent-merkle-tree/test/unit/tree/getNodes.test.ts index 7cb34ac9b..ad68e527a 100644 --- a/packages/persistent-merkle-tree/test/unit/tree/getNodes.test.ts +++ b/packages/persistent-merkle-tree/test/unit/tree/getNodes.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect, beforeAll} from "vitest"; -import {getNodesAtDepth, LeafNode, Node, subtreeFillToContents, Tree} from "../../../src/index.js"; +import {beforeAll, describe, expect, it} from "vitest"; +import {LeafNode, Node, Tree, getNodesAtDepth, subtreeFillToContents} from "../../../src/index.js"; describe("tree / getNodes", () => { const depth = 40; diff --git a/packages/persistent-merkle-tree/test/unit/tree/zeroAfterIndex.test.ts b/packages/persistent-merkle-tree/test/unit/tree/zeroAfterIndex.test.ts index 59af19f14..1e40daa6a 100644 --- a/packages/persistent-merkle-tree/test/unit/tree/zeroAfterIndex.test.ts +++ b/packages/persistent-merkle-tree/test/unit/tree/zeroAfterIndex.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {LeafNode, Node, toGindex, Tree, zeroNode, treeZeroAfterIndex, getNodesAtDepth} from "../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {LeafNode, Node, Tree, getNodesAtDepth, toGindex, treeZeroAfterIndex, zeroNode} from "../../../src/index.js"; describe("tree / zeroAfterIndex", () => { // Test all possible zeroAfterIndex operations for any tree with 0 <= depth < 6 @@ -43,10 +43,9 @@ function printLeafTreeDiff(nodeA: Node, nodeB: Node, depth: number, length: numb const nodesA = getNodesAtDepth(nodeA, d, 0, length); const nodesB = getNodesAtDepth(nodeB, d, 0, length); const toIndex = Math.ceil(length / 2 ** (depth - d)); - // eslint-disable-next-line no-console + console.log(`Depth ${d}`); for (let i = 0; i < toIndex; i++) { - // eslint-disable-next-line no-console console.log(`${d} ${i} A ${toHex(nodesA[i].root)} B ${toHex(nodesB[i].root)}`); } } diff --git a/packages/persistent-merkle-tree/test/unit/treeNav.test.ts b/packages/persistent-merkle-tree/test/unit/treeNav.test.ts index 89fe3f03b..7f0bd57e5 100644 --- a/packages/persistent-merkle-tree/test/unit/treeNav.test.ts +++ b/packages/persistent-merkle-tree/test/unit/treeNav.test.ts @@ -1,4 +1,4 @@ -import {expect, describe, it} from "vitest"; +import {describe, expect, it} from "vitest"; describe("commonDepth", () => { const testCases: {from: number; to: number; d: number}[] = [ diff --git a/packages/persistent-merkle-tree/test/utils/batchHash.ts b/packages/persistent-merkle-tree/test/utils/batchHash.ts index 6300031c8..fbf4102ec 100644 --- a/packages/persistent-merkle-tree/test/utils/batchHash.ts +++ b/packages/persistent-merkle-tree/test/utils/batchHash.ts @@ -1,6 +1,6 @@ -import { HashComputationLevel, getHashComputations } from "../../src/hashComputation.js"; -import { executeHashComputations } from "../../src/hasher/index.js"; -import { Node } from "../../src/node.js"; +import {HashComputationLevel, getHashComputations} from "../../src/hashComputation.js"; +import {executeHashComputations} from "../../src/hasher/index.js"; +import {Node} from "../../src/node.js"; /** * This is only a test utility function, don't want to use it in production because it allocates memory every time. @@ -12,4 +12,4 @@ export function batchHash(node: Node): void { if (node.h0 === null) { throw Error("Root node h0 is null"); } -} \ No newline at end of file +} diff --git a/packages/persistent-ts/src/List.ts b/packages/persistent-ts/src/List.ts index 41a08ec34..45e880c12 100644 --- a/packages/persistent-ts/src/List.ts +++ b/packages/persistent-ts/src/List.ts @@ -14,7 +14,6 @@ const EMPTY_NODE = {next: null}; * Because a List is Iterable, you can loop over it using `for of` and use the spread operator. */ export class List implements Iterable { - // eslint-disable-next-line @typescript-eslint/naming-convention private constructor(private readonly _node: Node) {} /** @@ -126,7 +125,6 @@ export class List implements Iterable { * @param amount the number of elements to drop */ drop(amount: number): List { - // eslint-disable-next-line @typescript-eslint/no-this-alias let list: List = this; for (let i = 0; i < amount; ++i) { if (list.isEmpty()) break; diff --git a/packages/persistent-ts/src/MutableVector.ts b/packages/persistent-ts/src/MutableVector.ts index 446cb3702..21e462a18 100644 --- a/packages/persistent-ts/src/MutableVector.ts +++ b/packages/persistent-ts/src/MutableVector.ts @@ -4,7 +4,7 @@ import {PersistentVector, TransientVector} from "./Vector.js"; * A mutable reference to a PersistentVector or TransientVector */ export class MutableVector implements Iterable { - public vector: PersistentVector | TransientVector; + vector: PersistentVector | TransientVector; private constructor(vector: PersistentVector) { this.vector = vector; diff --git a/packages/persistent-ts/src/Vector.ts b/packages/persistent-ts/src/Vector.ts index c84482469..1d0f34c22 100644 --- a/packages/persistent-ts/src/Vector.ts +++ b/packages/persistent-ts/src/Vector.ts @@ -37,7 +37,7 @@ function copyNode(node: INode): INode { function ensureEditable(node: INode, edit: {ref: boolean}): INode { if (node.edit === edit) return node; - else return {edit, array: [...node.array] as (INode | undefined)[]}; + return {edit, array: [...node.array] as (INode | undefined)[]}; } /** @@ -48,7 +48,8 @@ export class PersistentVector implements Iterable { /** * The empty vector */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any + + // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly static empty: PersistentVector = new PersistentVector( emptyNode(), DEFAULT_LEVEL_SHIFT, @@ -88,7 +89,7 @@ export class PersistentVector implements Iterable { get(index: number): T | undefined { if (index < 0 || index >= this.length) return undefined; - let array; + let array: T[] | (INode | undefined)[]; if (index >= this.getTailOffset()) { array = this.tail; } else { @@ -222,6 +223,7 @@ export class PersistentVector implements Iterable { cursor = next; } const newTail = [...cursor.array] as T[]; + // biome-ignore lint/style/noNonNullAssertion: Fixing this will require more refactoring, leaving it for now parent!.array[subIndex!] = emptyNode(); let newLevelShift = this.shift; let newRoot: INode = base; @@ -304,12 +306,17 @@ export class PersistentVector implements Iterable { * TransientVectors support access to items by index in log32N hops. */ export class TransientVector implements Iterable { - constructor(private root: INode, private shift: number, private tail: T[], readonly length: number) {} + constructor( + private root: INode, + private shift: number, + private tail: T[], + readonly length: number + ) {} /** * The empty vector */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any + static empty(): TransientVector { return new TransientVector(emptyNode({ref: true}), DEFAULT_LEVEL_SHIFT, Array(BRANCH_SIZE).fill(undefined), 0); } @@ -348,7 +355,7 @@ export class TransientVector implements Iterable { get(index: number): T | undefined { if (index < 0 || index >= this.length) return undefined; - let array; + let array: T[] | (INode | undefined)[]; if (index >= this.getTailOffset()) { array = this.tail; } else { @@ -404,7 +411,7 @@ export class TransientVector implements Iterable { if (this.getTailLength() < BRANCH_SIZE) { // has space in tail this.tail[this.length % BRANCH_SIZE] = value; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore this.length += 1; // The element is added to the tail @@ -436,7 +443,7 @@ export class TransientVector implements Iterable { // it's safe to update cursor bc "next" is a new instance anyway cursor.array = this.tail; this.tail = [value, ...(Array(BRANCH_SIZE - 1).fill(undefined) as T[])]; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore this.length += 1; return this; @@ -454,7 +461,7 @@ export class TransientVector implements Iterable { const tailLength = this.getTailLength(); if (tailLength >= 2) { delete this.tail[tailLength - 1]; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore this.length -= 1; return this; @@ -478,13 +485,14 @@ export class TransientVector implements Iterable { cursor = next; } this.tail = cursor.array as T[]; + // biome-ignore lint/style/noNonNullAssertion: Fixing this will require more refactoring, leaving it for now parent!.array[subIndex!] = emptyNode(this.root.edit); if (isFullBranch(this.length - 1 - BRANCH_SIZE)) { this.root = this.root.array[0] as IBranch; this.shift -= BIT_WIDTH; } - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore this.length -= 1; return this; diff --git a/packages/persistent-ts/test/unit/List.test.ts b/packages/persistent-ts/test/unit/List.test.ts index 98879da94..1f48aab0c 100644 --- a/packages/persistent-ts/test/unit/List.test.ts +++ b/packages/persistent-ts/test/unit/List.test.ts @@ -1,5 +1,5 @@ import fc from "fast-check"; -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {List} from "../../src/List.js"; describe("List", () => { diff --git a/packages/persistent-ts/test/unit/Vector.test.ts b/packages/persistent-ts/test/unit/Vector.test.ts index 294242d34..7a0387f07 100644 --- a/packages/persistent-ts/test/unit/Vector.test.ts +++ b/packages/persistent-ts/test/unit/Vector.test.ts @@ -1,5 +1,5 @@ import fc from "fast-check"; -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {PersistentVector, TransientVector} from "../../src/Vector.js"; describe("Vector", () => { @@ -109,7 +109,9 @@ describe("Vector", () => { newVector = newVector.set(i, i * 4); } for (let i = 0; i < times; i++) { - expect(newVector!.get(i)).toEqual(originalVector.get(i)! * 2); + const val = originalVector.get(i); + expect(val).toBeDefined(); + expect(newVector?.get(i)).toEqual((val as number) * 2); } expect([...newVector]).toEqual(originalArr.map((item) => item * 2)); expect([...newVector].length).toEqual(1025); diff --git a/packages/simpleserialize.com/src/components/Header.tsx b/packages/simpleserialize.com/src/components/Header.tsx index 4732566df..894de1eca 100644 --- a/packages/simpleserialize.com/src/components/Header.tsx +++ b/packages/simpleserialize.com/src/components/Header.tsx @@ -1,4 +1,4 @@ -/* eslint-disable max-len */ + import * as React from "react"; diff --git a/packages/simpleserialize.com/src/components/Input.tsx b/packages/simpleserialize.com/src/components/Input.tsx index 31ef6d3a3..a8955f091 100644 --- a/packages/simpleserialize.com/src/components/Input.tsx +++ b/packages/simpleserialize.com/src/components/Input.tsx @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/ban-types */ + import * as React from "react"; import {Type, toHexString} from "@chainsafe/ssz"; @@ -329,5 +329,5 @@ class Input extends React.Component { } // @TODO: not sure what to put here instead of any -// eslint-disable-next-line @typescript-eslint/no-explicit-any + export default withAlert()(Input); diff --git a/packages/simpleserialize.com/src/components/Output.tsx b/packages/simpleserialize.com/src/components/Output.tsx index fccd6ecd7..d7cd5c1ae 100644 --- a/packages/simpleserialize.com/src/components/Output.tsx +++ b/packages/simpleserialize.com/src/components/Output.tsx @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/ban-types */ + import * as React from "react"; import NamedOutput from "./display/NamedOutput"; diff --git a/packages/simpleserialize.com/src/components/TreeView.tsx b/packages/simpleserialize.com/src/components/TreeView.tsx index db329575d..d1f4bdde4 100644 --- a/packages/simpleserialize.com/src/components/TreeView.tsx +++ b/packages/simpleserialize.com/src/components/TreeView.tsx @@ -1,7 +1,7 @@ // ignoring this file since we don't use it currently -// eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-nocheck -/* eslint-disable */ + import * as React from "react"; // @ts-ignore diff --git a/packages/simpleserialize.com/src/components/worker/index.ts b/packages/simpleserialize.com/src/components/worker/index.ts index bab8bc7f3..739112019 100644 --- a/packages/simpleserialize.com/src/components/worker/index.ts +++ b/packages/simpleserialize.com/src/components/worker/index.ts @@ -1,7 +1,7 @@ -// /* eslint-disable @typescript-eslint/ban-types */ +// import {expose} from "threads/worker"; -import {getSSZType, createRandomValue} from "./helpers"; +import {createRandomValue, getSSZType} from "./helpers"; const worker = { createRandomValue(sszTypeName: string, forkName: string) { @@ -14,9 +14,9 @@ const worker = { const serialized = type.serialize(input); const root = type.hashTreeRoot(input); return {serialized, root}; - } -} + }, +}; export type SszWorker = typeof worker; -expose(worker) \ No newline at end of file +expose(worker); diff --git a/packages/simpleserialize.com/src/index.tsx b/packages/simpleserialize.com/src/index.tsx index 868d4123c..a010a3773 100644 --- a/packages/simpleserialize.com/src/index.tsx +++ b/packages/simpleserialize.com/src/index.tsx @@ -2,7 +2,7 @@ import React from "react"; import ReactDOM from "react-dom"; import App from "./App"; import {transitions, Provider as AlertProvider} from "react-alert"; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore import AlertTemplate from "react-alert-template-basic"; @@ -15,7 +15,7 @@ const options = { }; ReactDOM.render( - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + , diff --git a/packages/simpleserialize.com/src/util/input_types.ts b/packages/simpleserialize.com/src/util/input_types.ts index b4c1b9062..56b46b19c 100644 --- a/packages/simpleserialize.com/src/util/input_types.ts +++ b/packages/simpleserialize.com/src/util/input_types.ts @@ -1,17 +1,18 @@ import {Type, fromHexString, toHexString} from "@chainsafe/ssz"; import {dumpYaml, parseYaml} from "./yaml"; -type InputTypeRecord = Record +type InputTypeRecord = Record; type InputType = { - parse: (raw: string, type: Type) => T, - dump: (value: any, type: Type) => string, -} + parse: (raw: string, type: Type) => T; + // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly + dump: (value: any, type: Type) => string; +}; export const inputTypes: InputTypeRecord = { yaml: { parse: (raw, type) => type.fromJson(parseYaml(raw)), - dump: (value, type) => dumpYaml(type.toJson(typeof value === 'number' ? value.toString() : value)), + dump: (value, type) => dumpYaml(type.toJson(typeof value === "number" ? value.toString() : value)), }, json: { parse: (raw, type) => type.fromJson(JSON.parse(raw)), diff --git a/packages/simpleserialize.com/src/util/output_types.ts b/packages/simpleserialize.com/src/util/output_types.ts index 80d6a6dd6..ac4dd80c1 100644 --- a/packages/simpleserialize.com/src/util/output_types.ts +++ b/packages/simpleserialize.com/src/util/output_types.ts @@ -1,11 +1,9 @@ -import { toHexString, Type } from "@chainsafe/ssz"; +import {Type, toHexString} from "@chainsafe/ssz"; import {dumpYaml} from "./yaml"; function toBase64(data: Uint8Array) { - var binstr = Array.prototype.map.call(data, function (ch) { - return String.fromCharCode(ch); - }).join(''); - return btoa(binstr); + const binstr = Array.prototype.map.call(data, (ch) => String.fromCharCode(ch)).join(""); + return btoa(binstr); } type SerializeOutputTypeRecord = Record; @@ -17,7 +15,8 @@ type SerializeOutputType = { type DeserializeOutputTypeRecord = Record; type DeserializeOutputType = { - dump: (value: any, type: Type) => string, + // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly + dump: (value: any, type: Type) => string; }; export const serializeOutputTypes: SerializeOutputTypeRecord = { @@ -31,7 +30,7 @@ export const serializeOutputTypes: SerializeOutputTypeRecord = { export const deserializeOutputTypes: DeserializeOutputTypeRecord = { yaml: { - dump: (value, type) => dumpYaml(type.toJson(typeof value === 'number' ? value.toString() : value)), + dump: (value, type) => dumpYaml(type.toJson(typeof value === "number" ? value.toString() : value)), }, json: { dump: (value, type) => JSON.stringify(type.toJson(value), null, 2), diff --git a/packages/simpleserialize.com/src/util/partials.ts b/packages/simpleserialize.com/src/util/partials.ts index ea551970c..d980968bf 100644 --- a/packages/simpleserialize.com/src/util/partials.ts +++ b/packages/simpleserialize.com/src/util/partials.ts @@ -1,37 +1,47 @@ // @ts-nocheck -import {ListType, Type, isBooleanType, isUintType, isBitListType, isBitVectorType, isContainerType, isVectorType, isByteVectorType, isListType} from "@chainsafe/ssz"; +import { + ArrayType, + ListType, + Type, + isBitListType, + isBitVectorType, + isBooleanType, + isByteVectorType, + isContainerType, + isListType, + isUintType, + isVectorType, +} from "@chainsafe/ssz"; // binary string -type GenIndex = string +type GenIndex = string; export type Node = { type: Type; - data: any; + data: unknown; key: string | number; genIndex: GenIndex; -} +}; export function isBottomType(type: Type) { - return (isUintType(type) - || isBooleanType(type) - || isBitListType(type) - || isBitVectorType(type) - || isByteVectorType(type)); + return ( + isUintType(type) || isBooleanType(type) || isBitListType(type) || isBitVectorType(type) || isByteVectorType(type) + ); } -export function getRootNode(data: any, type: Type): Node { +export function getRootNode(data: unknown, type: Type): Node { return { type: {_typeSymbols: type._typeSymbols, fields: type.fields, depth: type.tree.depth()}, data: data, key: "root", genIndex: "1", - } + }; } const childIndex = (parentIndex: GenIndex, listIndex: number, depth: number, elementsPerChunk: number): GenIndex => { let genIndex = parentIndex; const chunkIndex = Math.floor(listIndex / elementsPerChunk); - for (let i = depth-1; i >= 0; i--) { + for (let i = depth - 1; i >= 0; i--) { if ((chunkIndex & (1 << i)) !== 0) { genIndex += "1"; } else { @@ -42,10 +52,9 @@ const childIndex = (parentIndex: GenIndex, listIndex: number, depth: number, ele }; export function getChildNodes(node: Node): Array> { - const { type, data, genIndex, depth } = node; - if(isBottomType(type)) { - return []; - } else if(isListType(type) || isVectorType(type)) { + const {type, data, genIndex, depth} = node; + if (isBottomType(type)) return []; + if (isListType(type) || isVectorType(type)) { let elementsPerChunk = 1; const elemType = (type as ListType).elementType; if (isUintType(elemType)) { @@ -53,23 +62,26 @@ export function getChildNodes(node: Node): Array> { } else if (isBooleanType(elemType)) { elementsPerChunk = 32; } - return data.map((e: any, i: number): Node => ({ - type: (type as ArrayType).elementType, - data: e, - key: i, - genIndex: childIndex(genIndex, i, depth, elementsPerChunk), - })); + return data.map( + (e: unknown, i: number): Node => ({ + type: (type as ArrayType).elementType, + data: e, + key: i, + genIndex: childIndex(genIndex, i, depth, elementsPerChunk), + }) + ); } if (isContainerType(type)) { // const depth = type.tree.depth(); - const { fields } = type; - return Object.keys(fields).map((i): Node => ({ - // type: fieldType, - data: data[i], - key: i, - // genIndex: childIndex(genIndex, i, depth, 1), - })); - } else { - return []; + const {fields} = type; + return Object.keys(fields).map( + (i): Node => ({ + // type: fieldType, + data: data[i], + key: i, + // genIndex: childIndex(genIndex, i, depth, 1), + }) + ); } + return []; } diff --git a/packages/simpleserialize.com/src/util/types.ts b/packages/simpleserialize.com/src/util/types.ts index ac5c1155a..24307a982 100644 --- a/packages/simpleserialize.com/src/util/types.ts +++ b/packages/simpleserialize.com/src/util/types.ts @@ -1,10 +1,10 @@ import { - Type, - UintNumberType, - UintBigintType, ContainerType, ListBasicType, ListCompositeType, + Type, + UintBigintType, + UintNumberType, VectorBasicType, VectorCompositeType, } from "@chainsafe/ssz"; diff --git a/packages/simpleserialize.com/src/util/yaml/index.ts b/packages/simpleserialize.com/src/util/yaml/index.ts index 11faa5f08..fdb4b7022 100644 --- a/packages/simpleserialize.com/src/util/yaml/index.ts +++ b/packages/simpleserialize.com/src/util/yaml/index.ts @@ -1,10 +1,10 @@ // @ts-ignore -import yaml from 'js-yaml'; +import yaml from "js-yaml"; -export function dumpYaml(input: any): string { +export function dumpYaml(input: unknown): string { return yaml.dump(input); } -export function parseYaml(input: string): any { +export function parseYaml(input: string): unknown { return yaml.load(input); } diff --git a/packages/simpleserialize.com/src/util/yaml/int.js b/packages/simpleserialize.com/src/util/yaml/int.js index 1208299e3..5ef315a64 100644 --- a/packages/simpleserialize.com/src/util/yaml/int.js +++ b/packages/simpleserialize.com/src/util/yaml/int.js @@ -161,7 +161,7 @@ module.exports = new Type('tag:yaml.org,2002:int', { binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); }, decimal: function (obj) { return obj.toString(10); }, - /* eslint-disable max-len */ + hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } }, defaultStyle: 'decimal', diff --git a/packages/ssz/src/branchNodeStruct.ts b/packages/ssz/src/branchNodeStruct.ts index 9a142d01c..a667b1d00 100644 --- a/packages/ssz/src/branchNodeStruct.ts +++ b/packages/ssz/src/branchNodeStruct.ts @@ -1,5 +1,5 @@ import type {HashObject} from "@chainsafe/as-sha256"; -import {hashObjectToUint8Array, Node} from "@chainsafe/persistent-merkle-tree"; +import {Node, hashObjectToUint8Array} from "@chainsafe/persistent-merkle-tree"; /** * BranchNode whose children's data is represented as a struct, not a tree. @@ -9,7 +9,10 @@ import {hashObjectToUint8Array, Node} from "@chainsafe/persistent-merkle-tree"; * expensive because the tree has to be recreated every time. */ export class BranchNodeStruct extends Node { - constructor(private readonly valueToNode: (value: T) => Node, readonly value: T) { + constructor( + private readonly valueToNode: (value: T) => Node, + readonly value: T + ) { // First null value is to save an extra variable to check if a node has a root or not super(null as unknown as number, 0, 0, 0, 0, 0, 0, 0); } diff --git a/packages/ssz/src/interface.ts b/packages/ssz/src/interface.ts index 240c27951..dff4e38be 100644 --- a/packages/ssz/src/interface.ts +++ b/packages/ssz/src/interface.ts @@ -25,8 +25,7 @@ export type BitVector = Vector; export type BitList = List; export interface ObjectLike { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [fieldName: string]: any; + [fieldName: string]: unknown; } export interface Union { @@ -34,8 +33,7 @@ export interface Union { value: T; } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export type CompositeValue = Record | ArrayLike | Union | Record; +export type CompositeValue = Record | ArrayLike | Union | Record; /** * The Json interface is used for json-serializable input diff --git a/packages/ssz/src/type/abstract.ts b/packages/ssz/src/type/abstract.ts index 792ca0775..17cf6c3af 100644 --- a/packages/ssz/src/type/abstract.ts +++ b/packages/ssz/src/type/abstract.ts @@ -1,7 +1,5 @@ import {Node} from "@chainsafe/persistent-merkle-tree"; -/* eslint-disable @typescript-eslint/member-ordering */ - export type ValueOf> = T extends Type ? V : never; /** diff --git a/packages/ssz/src/type/array.ts b/packages/ssz/src/type/array.ts index 1d6c19b69..33bf14ce7 100644 --- a/packages/ssz/src/type/array.ts +++ b/packages/ssz/src/type/array.ts @@ -1,16 +1,14 @@ -import {concatGindices, getNode, Gindex, Node, toGindex} from "@chainsafe/persistent-merkle-tree"; -import {ValueOf, Type} from "./abstract.js"; -import {CompositeType, isCompositeType, LENGTH_GINDEX} from "./composite.js"; +import {Gindex, Node, concatGindices, getNode, toGindex} from "@chainsafe/persistent-merkle-tree"; +import {Type, ValueOf} from "./abstract.js"; import { - value_fromJsonArray, - value_toJsonArray, + ArrayProps, value_cloneArray, - value_equals, value_defaultValueArray, - ArrayProps, + value_equals, + value_fromJsonArray, + value_toJsonArray, } from "./arrayBasic.js"; - -/* eslint-disable @typescript-eslint/member-ordering */ +import {CompositeType, LENGTH_GINDEX, isCompositeType} from "./composite.js"; /** * Array: ordered homogeneous collection @@ -23,7 +21,10 @@ export abstract class ArrayType, TV, TVDU> ext abstract readonly itemsPerChunk: number; protected abstract readonly defaultLen: number; - constructor(readonly elementType: ElementType, cachePermanentRootStruct?: boolean) { + constructor( + readonly elementType: ElementType, + cachePermanentRootStruct?: boolean + ) { super(cachePermanentRootStruct); } diff --git a/packages/ssz/src/type/arrayBasic.ts b/packages/ssz/src/type/arrayBasic.ts index 9743169fb..dc8694961 100644 --- a/packages/ssz/src/type/arrayBasic.ts +++ b/packages/ssz/src/type/arrayBasic.ts @@ -1,14 +1,14 @@ import { BranchNode, + HashComputationLevel, LeafNode, Node, getNodesAtDepth, + levelAtIndex, packedNodeRootsToBytes, packedRootsBytesToNode, - HashComputationLevel, - levelAtIndex, } from "@chainsafe/persistent-merkle-tree"; -import {Type, ValueOf, ByteViews} from "./abstract.js"; +import {ByteViews, Type, ValueOf} from "./abstract.js"; import {BasicType} from "./basic.js"; // There's a matrix of Array-ish types that require a combination of this functions. @@ -146,9 +146,8 @@ export function tree_deserializeFromBytesArrayBasic>( @@ -35,9 +33,7 @@ export function maxSizeArrayComposite>( @@ -55,9 +51,7 @@ export function value_serializedSizeArrayComposite, unknown, unknown> + ElementType extends CompositeType, unknown, unknown>, >( elementType: ElementType, data: ByteViews, @@ -137,9 +129,7 @@ export function tree_serializedSizeArrayComposite>( @@ -206,9 +194,8 @@ export function tree_deserializeFromBytesArrayComposite>( diff --git a/packages/ssz/src/type/basic.ts b/packages/ssz/src/type/basic.ts index 79746fdbb..f651802af 100644 --- a/packages/ssz/src/type/basic.ts +++ b/packages/ssz/src/type/basic.ts @@ -1,8 +1,6 @@ import {LeafNode} from "@chainsafe/persistent-merkle-tree"; import {Type} from "./abstract.js"; -/* eslint-disable @typescript-eslint/member-ordering */ - /** * Represents a basic type as defined in the spec: * https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#basic-types diff --git a/packages/ssz/src/type/bitArray.ts b/packages/ssz/src/type/bitArray.ts index 0d8fd93b9..b494c737b 100644 --- a/packages/ssz/src/type/bitArray.ts +++ b/packages/ssz/src/type/bitArray.ts @@ -1,12 +1,10 @@ -import {concatGindices, Gindex, Node, toGindex, Tree, HashComputationLevel} from "@chainsafe/persistent-merkle-tree"; -import {fromHexString, toHexString, byteArrayEquals} from "../util/byteArray.js"; -import {CompositeType, LENGTH_GINDEX} from "./composite.js"; +import {Gindex, HashComputationLevel, Node, Tree, concatGindices, toGindex} from "@chainsafe/persistent-merkle-tree"; +import {byteArrayEquals, fromHexString, toHexString} from "../util/byteArray.js"; import {BitArray} from "../value/bitArray.js"; import {BitArrayTreeView} from "../view/bitArray.js"; import {BitArrayTreeViewDU} from "../viewDU/bitArray.js"; import {getBlocksBytes} from "./byteArray.js"; - -/* eslint-disable @typescript-eslint/member-ordering */ +import {CompositeType, LENGTH_GINDEX} from "./composite.js"; /** * BitArray: ordered array collection of boolean values diff --git a/packages/ssz/src/type/bitList.ts b/packages/ssz/src/type/bitList.ts index a3c60537f..f999b6915 100644 --- a/packages/ssz/src/type/bitList.ts +++ b/packages/ssz/src/type/bitList.ts @@ -1,20 +1,18 @@ +import {allocUnsafe} from "@chainsafe/as-sha256"; import { - getNodesAtDepth, Node, + getNodesAtDepth, + merkleizeBlocksBytes, packedNodeRootsToBytes, packedRootsBytesToNode, - merkleizeBlocksBytes, } from "@chainsafe/persistent-merkle-tree"; -import {allocUnsafe} from "@chainsafe/as-sha256"; import {maxChunksToDepth} from "../util/merkleize.js"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; -import {ByteViews} from "./composite.js"; -import {addLengthNode, getLengthFromRootNode, getChunksNodeFromRootNode} from "./arrayBasic.js"; +import {Require} from "../util/types.js"; import {BitArray} from "../value/bitArray.js"; +import {addLengthNode, getChunksNodeFromRootNode, getLengthFromRootNode} from "./arrayBasic.js"; import {BitArrayType} from "./bitArray.js"; - -/* eslint-disable @typescript-eslint/member-ordering */ +import {ByteViews} from "./composite.js"; export interface BitListOptions { typeName?: string; @@ -43,7 +41,10 @@ export class BitListType extends BitArrayType { this.mixInLengthBlockBytes.byteLength ); - constructor(readonly limitBits: number, opts?: BitListOptions) { + constructor( + readonly limitBits: number, + opts?: BitListOptions + ) { super(); if (limitBits === 0) throw Error("List limit must be > 0"); @@ -195,8 +196,8 @@ function applyPaddingBit(output: Uint8Array, offset: number, bitLen: number): nu if (bitLen % 8 === 0) { output[newOffset] = 1; return newOffset + 1; - } else { - output[newOffset - 1] |= 1 << bitLen % 8; - return newOffset; } + + output[newOffset - 1] |= 1 << (bitLen % 8); + return newOffset; } diff --git a/packages/ssz/src/type/bitVector.ts b/packages/ssz/src/type/bitVector.ts index d07304e02..611164680 100644 --- a/packages/ssz/src/type/bitVector.ts +++ b/packages/ssz/src/type/bitVector.ts @@ -1,12 +1,10 @@ -import {getNodesAtDepth, Node, packedNodeRootsToBytes, packedRootsBytesToNode} from "@chainsafe/persistent-merkle-tree"; +import {Node, getNodesAtDepth, packedNodeRootsToBytes, packedRootsBytesToNode} from "@chainsafe/persistent-merkle-tree"; import {maxChunksToDepth} from "../util/merkleize.js"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; -import {ByteViews} from "./composite.js"; +import {Require} from "../util/types.js"; import {BitArray} from "../value/bitArray.js"; import {BitArrayType} from "./bitArray.js"; - -/* eslint-disable @typescript-eslint/member-ordering */ +import {ByteViews} from "./composite.js"; export interface BitVectorOptions { typeName?: string; @@ -40,7 +38,10 @@ export class BitVectorType extends BitArrayType { */ private readonly zeroBitsMask: number; - constructor(readonly lengthBits: number, opts?: BitVectorOptions) { + constructor( + readonly lengthBits: number, + opts?: BitVectorOptions + ) { super(); if (lengthBits === 0) throw Error("Vector length must be > 0"); @@ -53,7 +54,7 @@ export class BitVectorType extends BitArrayType { this.minSize = this.fixedSize; this.maxSize = this.fixedSize; // To cache mask for trailing zero bits validation - this.zeroBitsMask = lengthBits % 8 === 0 ? 0 : 0xff & (0xff << lengthBits % 8); + this.zeroBitsMask = lengthBits % 8 === 0 ? 0 : 0xff & (0xff << (lengthBits % 8)); } static named(limitBits: number, opts: Require): BitVectorType { diff --git a/packages/ssz/src/type/boolean.ts b/packages/ssz/src/type/boolean.ts index 21703fdba..38fb31450 100644 --- a/packages/ssz/src/type/boolean.ts +++ b/packages/ssz/src/type/boolean.ts @@ -1,11 +1,9 @@ import {LeafNode, Node} from "@chainsafe/persistent-merkle-tree"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; +import {Require} from "../util/types.js"; import {ByteViews} from "./abstract.js"; import {BasicType} from "./basic.js"; -/* eslint-disable @typescript-eslint/member-ordering */ - export interface BooleanOpts { typeName?: string; } diff --git a/packages/ssz/src/type/byteArray.ts b/packages/ssz/src/type/byteArray.ts index db79be482..e18d1ef70 100644 --- a/packages/ssz/src/type/byteArray.ts +++ b/packages/ssz/src/type/byteArray.ts @@ -1,20 +1,18 @@ import { - concatGindices, Gindex, + HashComputationLevel, Node, - toGindex, Tree, - HashComputationLevel, + concatGindices, getHashComputations, + toGindex, } from "@chainsafe/persistent-merkle-tree"; -import {fromHexString, toHexString, byteArrayEquals} from "../util/byteArray.js"; +import {byteArrayEquals, fromHexString, toHexString} from "../util/byteArray.js"; import {ByteViews} from "./abstract.js"; import {CompositeType, LENGTH_GINDEX} from "./composite.js"; export type ByteArray = Uint8Array; -/* eslint-disable @typescript-eslint/member-ordering */ - /** * ByteArray: ordered array collection of byte values * - Value: `Uint8Array` diff --git a/packages/ssz/src/type/byteList.ts b/packages/ssz/src/type/byteList.ts index 781cd0237..d4c022551 100644 --- a/packages/ssz/src/type/byteList.ts +++ b/packages/ssz/src/type/byteList.ts @@ -1,19 +1,18 @@ +import {allocUnsafe} from "@chainsafe/as-sha256"; import { - getNodesAtDepth, Node, + getNodesAtDepth, + merkleizeBlockArray, + merkleizeBlocksBytes, packedNodeRootsToBytes, packedRootsBytesToNode, - merkleizeBlocksBytes, - merkleizeBlockArray, } from "@chainsafe/persistent-merkle-tree"; -import {allocUnsafe} from "@chainsafe/as-sha256"; import {maxChunksToDepth} from "../util/merkleize.js"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; +import {Require} from "../util/types.js"; import {addLengthNode, getChunksNodeFromRootNode, getLengthFromRootNode} from "./arrayBasic.js"; +import {ByteArray, ByteArrayType} from "./byteArray.js"; import {ByteViews} from "./composite.js"; -import {ByteArrayType, ByteArray} from "./byteArray.js"; -/* eslint-disable @typescript-eslint/member-ordering */ export interface ByteListOptions { typeName?: string; @@ -50,7 +49,10 @@ export class ByteListType extends ByteArrayType { this.mixInLengthBlockBytes.byteLength ); - constructor(readonly limitBytes: number, opts?: ByteListOptions) { + constructor( + readonly limitBytes: number, + opts?: ByteListOptions + ) { super(); if (limitBytes === 0) throw Error("List limit must be > 0"); diff --git a/packages/ssz/src/type/byteVector.ts b/packages/ssz/src/type/byteVector.ts index bae30ce48..718e86385 100644 --- a/packages/ssz/src/type/byteVector.ts +++ b/packages/ssz/src/type/byteVector.ts @@ -1,9 +1,9 @@ -import {getNodesAtDepth, Node, packedNodeRootsToBytes, packedRootsBytesToNode} from "@chainsafe/persistent-merkle-tree"; +import {Node, getNodesAtDepth, packedNodeRootsToBytes, packedRootsBytesToNode} from "@chainsafe/persistent-merkle-tree"; import {maxChunksToDepth} from "../util/merkleize.js"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; -import {ByteViews} from "./composite.js"; +import {Require} from "../util/types.js"; import {ByteArrayType} from "./byteArray.js"; +import {ByteViews} from "./composite.js"; export type ByteVector = Uint8Array; @@ -11,8 +11,6 @@ export interface ByteVectorOptions { typeName?: string; } -/* eslint-disable @typescript-eslint/member-ordering */ - /** * ByteVector: Immutable alias of Vector[byte, N] * - Notation: `ByteVector[N]` @@ -36,7 +34,10 @@ export class ByteVectorType extends ByteArrayType { readonly maxChunkCount: number; readonly isList = false; - constructor(readonly lengthBytes: number, opts?: ByteVectorOptions) { + constructor( + readonly lengthBytes: number, + opts?: ByteVectorOptions + ) { super(); if (lengthBytes === 0) throw Error("Vector length must be > 0"); diff --git a/packages/ssz/src/type/composite.ts b/packages/ssz/src/type/composite.ts index 8db2fe842..53c1f8f5f 100644 --- a/packages/ssz/src/type/composite.ts +++ b/packages/ssz/src/type/composite.ts @@ -1,20 +1,20 @@ import {allocUnsafe} from "@chainsafe/as-sha256"; import { - concatGindices, - createProof, - getNode, Gindex, + HashComputationLevel, Node, Proof, ProofType, Tree, + concatGindices, + createProof, + getNode, merkleizeBlocksBytes, - HashComputationLevel, } from "@chainsafe/persistent-merkle-tree"; import {byteArrayEquals} from "../util/byteArray.js"; -import {cacheRoot, symbolCachedPermanentRoot, ValueWithCachedPermanentRoot} from "../util/merkleize.js"; +import {ValueWithCachedPermanentRoot, cacheRoot, symbolCachedPermanentRoot} from "../util/merkleize.js"; import {treePostProcessFromProofNode} from "../util/proof/treePostProcessFromProofNode.js"; -import {Type, ByteViews, JsonPath, JsonPathProp} from "./abstract.js"; +import {ByteViews, JsonPath, JsonPathProp, Type} from "./abstract.js"; export {ByteViews}; export const LENGTH_GINDEX = BigInt(3); @@ -40,8 +40,6 @@ export type CompositeViewDU> /** Any CompositeType without any generic arguments */ export type CompositeTypeAny = CompositeType; -/* eslint-disable @typescript-eslint/member-ordering */ - /** * Represents a composite type as defined in the spec: * https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#composite-types diff --git a/packages/ssz/src/type/container.ts b/packages/ssz/src/type/container.ts index e9ef58f78..b3cba6533 100644 --- a/packages/ssz/src/type/container.ts +++ b/packages/ssz/src/type/container.ts @@ -1,28 +1,27 @@ import { + Gindex, + HashComputationLevel, Node, - getNodesAtDepth, - subtreeFillToContents, Tree, - Gindex, - toGindex, concatGindices, getNode, - HashComputationLevel, + getNodesAtDepth, + subtreeFillToContents, + toGindex, } from "@chainsafe/persistent-merkle-tree"; import {maxChunksToDepth} from "../util/merkleize.js"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; -import {Type, ValueOf} from "./abstract.js"; -import {CompositeType, ByteViews, CompositeTypeAny} from "./composite.js"; +import {Case} from "../util/strings.js"; +import {Require} from "../util/types.js"; import {getContainerTreeViewClass} from "../view/container.js"; -import {ValueOfFields, FieldEntry, ContainerTreeViewType, ContainerTreeViewTypeConstructor} from "../view/container.js"; +import {ContainerTreeViewType, ContainerTreeViewTypeConstructor, FieldEntry, ValueOfFields} from "../view/container.js"; import { - getContainerTreeViewDUClass, ContainerTreeViewDUType, ContainerTreeViewDUTypeConstructor, + getContainerTreeViewDUClass, } from "../viewDU/container.js"; -import {Case} from "../util/strings.js"; -/* eslint-disable @typescript-eslint/member-ordering */ +import {Type, ValueOf} from "./abstract.js"; +import {ByteViews, CompositeType, CompositeTypeAny} from "./composite.js"; type BytesRange = {start: number; end: number}; @@ -79,7 +78,10 @@ export class ContainerType>> extends protected readonly TreeView: ContainerTreeViewTypeConstructor; protected readonly TreeViewDU: ContainerTreeViewDUTypeConstructor; - constructor(readonly fields: Fields, readonly opts?: ContainerOptions) { + constructor( + readonly fields: Fields, + readonly opts?: ContainerOptions + ) { super(opts?.cachePermanentRootStruct); // Render detailed typeName. Consumers should overwrite since it can get long @@ -554,11 +556,9 @@ export function precomputeJsonKey>>( throw Error(`casingMap[${String(fieldName as symbol)}] not defined`); } return keyFromCaseMap as string; - } else if (jsonCase) { - return Case[jsonCase](fieldName as string); - } else { - return fieldName as string; } + if (jsonCase) return Case[jsonCase](fieldName as string); + return fieldName as string; } /** diff --git a/packages/ssz/src/type/containerNodeStruct.ts b/packages/ssz/src/type/containerNodeStruct.ts index 42350b46d..4f553d674 100644 --- a/packages/ssz/src/type/containerNodeStruct.ts +++ b/packages/ssz/src/type/containerNodeStruct.ts @@ -1,13 +1,13 @@ import {Node} from "@chainsafe/persistent-merkle-tree"; -import {Type, ByteViews} from "./abstract.js"; -import {isCompositeType} from "./composite.js"; -import {ContainerType, ContainerOptions, renderContainerTypeName} from "./container.js"; -import {Require} from "../util/types.js"; +import {BranchNodeStruct} from "../branchNodeStruct.js"; import {namedClass} from "../util/named.js"; +import {Require} from "../util/types.js"; +import {ValueOfFields} from "../view/container.js"; import {getContainerTreeViewClass} from "../view/containerNodeStruct.js"; import {getContainerTreeViewDUClass} from "../viewDU/containerNodeStruct.js"; -import {BranchNodeStruct} from "../branchNodeStruct.js"; -import {ValueOfFields} from "../view/container.js"; +import {ByteViews, Type} from "./abstract.js"; +import {isCompositeType} from "./composite.js"; +import {ContainerOptions, ContainerType, renderContainerTypeName} from "./container.js"; /** * ContainerNodeStruct: ordered heterogeneous collection of values. @@ -24,7 +24,10 @@ import {ValueOfFields} from "../view/container.js"; * This tradeoff is good for data that is read often, written rarely, and consumes a lot of memory (i.e. Validator) */ export class ContainerNodeStructType>> extends ContainerType { - constructor(readonly fields: Fields, opts?: ContainerOptions) { + constructor( + readonly fields: Fields, + opts?: ContainerOptions + ) { super(fields, { // Overwrite default "Container" typeName // Render detailed typeName. Consumers should overwrite since it can get long diff --git a/packages/ssz/src/type/listBasic.ts b/packages/ssz/src/type/listBasic.ts index b31647cba..f051884b2 100644 --- a/packages/ssz/src/type/listBasic.ts +++ b/packages/ssz/src/type/listBasic.ts @@ -1,30 +1,28 @@ -import {LeafNode, Node, Tree, HashComputationLevel, merkleizeBlocksBytes} from "@chainsafe/persistent-merkle-tree"; import {allocUnsafe} from "@chainsafe/as-sha256"; -import {ValueOf} from "./abstract.js"; -import {BasicType} from "./basic.js"; -import {ByteViews} from "./composite.js"; -import { - value_deserializeFromBytesArrayBasic, - value_serializeToBytesArrayBasic, - tree_deserializeFromBytesArrayBasic, - tree_serializeToBytesArrayBasic, - addLengthNode, - setChunksNode, -} from "./arrayBasic.js"; +import {HashComputationLevel, LeafNode, Node, Tree, merkleizeBlocksBytes} from "@chainsafe/persistent-merkle-tree"; import { + ValueWithCachedPermanentRoot, cacheRoot, maxChunksToDepth, symbolCachedPermanentRoot, - ValueWithCachedPermanentRoot, } from "../util/merkleize.js"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; +import {Require} from "../util/types.js"; import {ArrayBasicType} from "../view/arrayBasic.js"; import {ListBasicTreeView} from "../view/listBasic.js"; import {ListBasicTreeViewDU} from "../viewDU/listBasic.js"; +import {ValueOf} from "./abstract.js"; import {ArrayType} from "./array.js"; - -/* eslint-disable @typescript-eslint/member-ordering */ +import { + addLengthNode, + setChunksNode, + tree_deserializeFromBytesArrayBasic, + tree_serializeToBytesArrayBasic, + value_deserializeFromBytesArrayBasic, + value_serializeToBytesArrayBasic, +} from "./arrayBasic.js"; +import {BasicType} from "./basic.js"; +import {ByteViews} from "./composite.js"; export interface ListBasicOpts { typeName?: string; @@ -60,7 +58,11 @@ export class ListBasicType> ); protected readonly defaultLen = 0; - constructor(readonly elementType: ElementType, readonly limit: number, opts?: ListBasicOpts) { + constructor( + readonly elementType: ElementType, + readonly limit: number, + opts?: ListBasicOpts + ) { super(elementType, opts?.cachePermanentRootStruct); if (!elementType.isBasic) throw Error("elementType must be basic"); @@ -91,7 +93,7 @@ export class ListBasicType> getViewDU(node: Node, cache?: unknown): ListBasicTreeViewDU { // cache type should be validated (if applicate) in the view - // eslint-disable-next-line @typescript-eslint/no-explicit-any + // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly return new ListBasicTreeViewDU(this, node, cache as any); } diff --git a/packages/ssz/src/type/listComposite.ts b/packages/ssz/src/type/listComposite.ts index 2d3ee6455..444de38f2 100644 --- a/packages/ssz/src/type/listComposite.ts +++ b/packages/ssz/src/type/listComposite.ts @@ -1,37 +1,35 @@ +import {allocUnsafe} from "@chainsafe/as-sha256"; import { + HashComputationLevel, Node, Tree, - HashComputationLevel, - merkleizeBlocksBytes, merkleizeBlockArray, + merkleizeBlocksBytes, } from "@chainsafe/persistent-merkle-tree"; -import {allocUnsafe} from "@chainsafe/as-sha256"; import { + ValueWithCachedPermanentRoot, cacheRoot, maxChunksToDepth, symbolCachedPermanentRoot, - ValueWithCachedPermanentRoot, } from "../util/merkleize.js"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; -import {ValueOf, ByteViews} from "./abstract.js"; -import {CompositeType, CompositeView, CompositeViewDU} from "./composite.js"; +import {Require} from "../util/types.js"; +import {ArrayCompositeType} from "../view/arrayComposite.js"; +import {ListCompositeTreeView} from "../view/listComposite.js"; +import {ListCompositeTreeViewDU} from "../viewDU/listComposite.js"; +import {ByteViews, ValueOf} from "./abstract.js"; +import {ArrayType} from "./array.js"; import {addLengthNode, getLengthFromRootNode, setChunksNode} from "./arrayBasic.js"; import { - value_deserializeFromBytesArrayComposite, - value_serializedSizeArrayComposite, - value_serializeToBytesArrayComposite, - tree_serializedSizeArrayComposite, + maxSizeArrayComposite, tree_deserializeFromBytesArrayComposite, tree_serializeToBytesArrayComposite, - maxSizeArrayComposite, + tree_serializedSizeArrayComposite, + value_deserializeFromBytesArrayComposite, + value_serializeToBytesArrayComposite, + value_serializedSizeArrayComposite, } from "./arrayComposite.js"; -import {ArrayCompositeType} from "../view/arrayComposite.js"; -import {ListCompositeTreeView} from "../view/listComposite.js"; -import {ListCompositeTreeViewDU} from "../viewDU/listComposite.js"; -import {ArrayType} from "./array.js"; - -/* eslint-disable @typescript-eslint/member-ordering */ +import {CompositeType, CompositeView, CompositeViewDU} from "./composite.js"; export interface ListCompositeOpts { typeName?: string; @@ -46,8 +44,8 @@ export interface ListCompositeOpts { * - Composite types are always returned as views */ export class ListCompositeType< - // eslint-disable-next-line @typescript-eslint/no-explicit-any - ElementType extends CompositeType, CompositeViewDU> + // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly + ElementType extends CompositeType, CompositeViewDU>, > extends ArrayType, ListCompositeTreeViewDU> implements ArrayCompositeType @@ -71,7 +69,11 @@ export class ListCompositeType< ); protected readonly defaultLen = 0; - constructor(readonly elementType: ElementType, readonly limit: number, opts?: ListCompositeOpts) { + constructor( + readonly elementType: ElementType, + readonly limit: number, + opts?: ListCompositeOpts + ) { super(elementType, opts?.cachePermanentRootStruct); if (elementType.isBasic) throw Error("elementType must not be basic"); @@ -87,7 +89,7 @@ export class ListCompositeType< this.maxSize = maxSizeArrayComposite(elementType, this.limit); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any + // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly static named, CompositeViewDU>>( elementType: ElementType, limit: number, @@ -102,7 +104,7 @@ export class ListCompositeType< getViewDU(node: Node, cache?: unknown): ListCompositeTreeViewDU { // cache type should be validated (if applicate) in the view - // eslint-disable-next-line @typescript-eslint/no-explicit-any + // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly return new ListCompositeTreeViewDU(this, node, cache as any); } diff --git a/packages/ssz/src/type/listUintNum64.ts b/packages/ssz/src/type/listUintNum64.ts index 46c92f3ba..e2ed37232 100644 --- a/packages/ssz/src/type/listUintNum64.ts +++ b/packages/ssz/src/type/listUintNum64.ts @@ -1,9 +1,9 @@ import {LeafNode, Node, packedUintNum64sToLeafNodes, subtreeFillToContents} from "@chainsafe/persistent-merkle-tree"; import {ListBasicTreeViewDU} from "../viewDU/listBasic.js"; +import {addLengthNode} from "./arrayBasic.js"; import {ListBasicOpts, ListBasicType} from "./listBasic.js"; import {UintNumberType} from "./uint.js"; -import {addLengthNode} from "./arrayBasic.js"; /** * Specific implementation of ListBasicType for UintNumberType with some optimizations. diff --git a/packages/ssz/src/type/none.ts b/packages/ssz/src/type/none.ts index 36b01e98e..1bf56d3a2 100644 --- a/packages/ssz/src/type/none.ts +++ b/packages/ssz/src/type/none.ts @@ -2,9 +2,6 @@ import {LeafNode, Node, zeroNode} from "@chainsafe/persistent-merkle-tree"; import {ByteViews} from "./abstract.js"; import {BasicType} from "./basic.js"; -/* eslint-disable @typescript-eslint/member-ordering */ -/* eslint-disable @typescript-eslint/no-unused-vars */ - export class NoneType extends BasicType { readonly typeName = "none"; readonly byteLength = 0; @@ -19,37 +16,37 @@ export class NoneType extends BasicType { // bytes serdes - value_serializeToBytes(output: ByteViews, offset: number, value: null): number { + value_serializeToBytes(_output: ByteViews, offset: number, _value: null): number { return offset; } - value_deserializeFromBytes(data: ByteViews, start: number): null { + value_deserializeFromBytes(_data: ByteViews, _start: number): null { return null; } - tree_serializeToBytes(output: ByteViews, offset: number, node: Node): number { + tree_serializeToBytes(_output: ByteViews, offset: number, _node: Node): number { return offset; } - tree_deserializeFromBytes(data: ByteViews, start: number, end: number): Node { + tree_deserializeFromBytes(_data: ByteViews, _start: number, _end: number): Node { return zeroNode(0); } // Fast tree opts - tree_getFromNode(leafNode: LeafNode): null { + tree_getFromNode(_leafNode: LeafNode): null { return null; } - tree_setToNode(leafNode: LeafNode, value: null): void { + tree_setToNode(_leafNode: LeafNode, _value: null): void { return; } - tree_getFromPackedNode(leafNode: LeafNode, index: number): null { + tree_getFromPackedNode(_leafNode: LeafNode, _index: number): null { return null; } - tree_setToPackedNode(leafNode: LeafNode, index: number, value: null): void { + tree_setToPackedNode(_leafNode: LeafNode, _index: number, _value: null): void { return; } @@ -62,7 +59,7 @@ export class NoneType extends BasicType { return null; } - toJson(value: null): unknown { + toJson(_value: null): unknown { return null; } } diff --git a/packages/ssz/src/type/optional.ts b/packages/ssz/src/type/optional.ts index dddf74cea..f798016f3 100644 --- a/packages/ssz/src/type/optional.ts +++ b/packages/ssz/src/type/optional.ts @@ -1,20 +1,19 @@ +import {allocUnsafe} from "@chainsafe/as-sha256"; import { - concatGindices, Gindex, - merkleizeBlocksBytes, + HashComputationLevel, Node, Tree, - zeroNode, + concatGindices, getHashComputations, - HashComputationLevel, + merkleizeBlocksBytes, + zeroNode, } from "@chainsafe/persistent-merkle-tree"; -import {allocUnsafe} from "@chainsafe/as-sha256"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; -import {Type, ByteViews, JsonPath, JsonPathProp} from "./abstract.js"; -import {CompositeType, isCompositeType} from "./composite.js"; +import {Require} from "../util/types.js"; +import {ByteViews, JsonPath, JsonPathProp, Type} from "./abstract.js"; import {addLengthNode, getLengthFromRootNode} from "./arrayBasic.js"; -/* eslint-disable @typescript-eslint/member-ordering */ +import {CompositeType, isCompositeType} from "./composite.js"; export type NonOptionalType> = T extends OptionalType ? U : T; export type NonOptionalFields>> = { @@ -55,7 +54,10 @@ export class OptionalType> extends CompositeTy this.mixInLengthBlockBytes.byteLength ); - constructor(readonly elementType: ElementType, opts?: OptionalOpts) { + constructor( + readonly elementType: ElementType, + opts?: OptionalOpts + ) { super(); this.typeName = opts?.typeName ?? `Optional[${elementType.typeName}]`; @@ -118,51 +120,44 @@ export class OptionalType> extends CompositeTy if (value !== null) { output.uint8Array[offset] = 1; return this.elementType.value_serializeToBytes(output, offset + 1, value); - } else { - return offset; } + return offset; } value_deserializeFromBytes(data: ByteViews, start: number, end: number): ValueOfType { - if (start === end) { - return null as ValueOfType; - } else { - const selector = data.uint8Array[start]; - if (selector !== 1) { - throw new Error(`Invalid selector for Optional type: ${selector}`); - } - return this.elementType.value_deserializeFromBytes(data, start + 1, end) as ValueOfType; + if (start === end) return null as ValueOfType; + + const selector = data.uint8Array[start]; + if (selector !== 1) { + throw new Error(`Invalid selector for Optional type: ${selector}`); } + return this.elementType.value_deserializeFromBytes(data, start + 1, end) as ValueOfType; } tree_serializedSize(node: Node): number { const selector = getLengthFromRootNode(node); - if (selector === 0) { - return 0; - } else if (selector === 1) { + if (selector === 0) return 0; + if (selector === 1) { return 1 + this.elementType.value_serializedSize(node.left); - } else { - throw new Error(`Invalid selector for Optional type: ${selector}`); } + throw new Error(`Invalid selector for Optional type: ${selector}`); } tree_serializeToBytes(output: ByteViews, offset: number, node: Node): number { const selector = getLengthFromRootNode(node); - if (selector === 0) { - return offset; - } else if (selector === 1) { + if (selector === 0) return offset; + if (selector === 1) { output.uint8Array[offset] = 1; return this.elementType.tree_serializeToBytes(output, offset + 1, node.left); - } else { - throw new Error(`Invalid selector for Optional type: ${selector}`); } + throw new Error(`Invalid selector for Optional type: ${selector}`); } tree_deserializeFromBytes(data: ByteViews, start: number, end: number): Node { - let valueNode; - let selector; + let valueNode: Node; + let selector: number; if (start === end) { selector = 0; valueNode = zeroNode(0); @@ -209,33 +204,29 @@ export class OptionalType> extends CompositeTy if (isCompositeType(this.elementType)) { const propIndex = this.elementType.getPropertyGindex(prop); return propIndex === null ? propIndex : concatGindices([VALUE_GINDEX, propIndex]); - } else { - throw new Error("not applicable for Optional basic type"); } + throw new Error("not applicable for Optional basic type"); } getPropertyType(prop: JsonPathProp): Type { if (isCompositeType(this.elementType)) { return this.elementType.getPropertyType(prop); - } else { - throw new Error("not applicable for Optional basic type"); } + throw new Error("not applicable for Optional basic type"); } getIndexProperty(index: number): JsonPathProp | null { if (isCompositeType(this.elementType)) { return this.elementType.getIndexProperty(index); - } else { - throw new Error("not applicable for Optional basic type"); } + throw new Error("not applicable for Optional basic type"); } tree_createProofGindexes(node: Node, jsonPaths: JsonPath[]): Gindex[] { if (isCompositeType(this.elementType)) { return super.tree_createProofGindexes(node, jsonPaths); - } else { - throw new Error("not applicable for Optional basic type"); } + throw new Error("not applicable for Optional basic type"); } tree_getLeafGindices(rootGindex: bigint, rootNode?: Node): Gindex[] { @@ -251,15 +242,15 @@ export class OptionalType> extends CompositeTy ...this.elementType.tree_getLeafGindices(concatGindices([rootGindex, VALUE_GINDEX]), rootNode.left), concatGindices([rootGindex, SELECTOR_GINDEX]), ]; - } else if (selector === 0 || selector === 1) { + } + if (selector === 0 || selector === 1) { return [ // concatGindices([rootGindex, VALUE_GINDEX]), concatGindices([rootGindex, SELECTOR_GINDEX]), ]; - } else { - throw new Error(`Invalid selector for Optional type: ${selector}`); } + throw new Error(`Invalid selector for Optional type: ${selector}`); } // JSON @@ -277,11 +268,8 @@ export class OptionalType> extends CompositeTy } equals(a: ValueOfType, b: ValueOfType): boolean { - if (a === null && b === null) { - return true; - } else if (a === null || b === null) { - return false; - } + if (a === null && b === null) return true; + if (a === null || b === null) return false; return this.elementType.equals(a, b); } diff --git a/packages/ssz/src/type/partialListComposite.ts b/packages/ssz/src/type/partialListComposite.ts index a7a187d26..4ef91843a 100644 --- a/packages/ssz/src/type/partialListComposite.ts +++ b/packages/ssz/src/type/partialListComposite.ts @@ -1,11 +1,11 @@ import {fromSnapshot, zeroNode} from "@chainsafe/persistent-merkle-tree"; -import {CompositeType, CompositeView, CompositeViewDU} from "./composite.js"; -import {ListCompositeOpts, ListCompositeType} from "./listComposite.js"; -import {PartialListCompositeTreeViewDU} from "../viewDU/partialListComposite.js"; -import {Snapshot} from "../util/types.js"; import {byteArrayEquals} from "../util/byteArray.js"; import {zeroSnapshot} from "../util/snapshot.js"; +import {Snapshot} from "../util/types.js"; +import {PartialListCompositeTreeViewDU} from "../viewDU/partialListComposite.js"; import {addLengthNode} from "./arrayBasic.js"; +import {CompositeType, CompositeView, CompositeViewDU} from "./composite.js"; +import {ListCompositeOpts, ListCompositeType} from "./listComposite.js"; /** * Similar to ListCompositeType, this is mainly used to create a PartialListCompositeTreeViewDU from a snapshot. @@ -14,10 +14,14 @@ import {addLengthNode} from "./arrayBasic.js"; * It'll throw errors for all other methods, most of the usage is in the ViewDU class. */ export class PartialListCompositeType< - // eslint-disable-next-line @typescript-eslint/no-explicit-any - ElementType extends CompositeType, CompositeViewDU> + // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly + ElementType extends CompositeType, CompositeViewDU>, > extends ListCompositeType { - constructor(readonly elementType: ElementType, readonly limit: number, opts?: ListCompositeOpts) { + constructor( + readonly elementType: ElementType, + readonly limit: number, + opts?: ListCompositeOpts + ) { super(elementType, limit, opts); // only inherit methods in ArrayType of ../view/arrayBasic.ts diff --git a/packages/ssz/src/type/profile.ts b/packages/ssz/src/type/profile.ts index 6d0cd1c9a..eb45c8759 100644 --- a/packages/ssz/src/type/profile.ts +++ b/packages/ssz/src/type/profile.ts @@ -1,14 +1,14 @@ import { + BranchNode, + Gindex, Node, - getNodesAtDepth, - subtreeFillToContents, Tree, - Gindex, - toGindex, concatGindices, - merkleizeBlocksBytes, getNode, - BranchNode, + getNodesAtDepth, + merkleizeBlocksBytes, + subtreeFillToContents, + toGindex, zeroHash, zeroNode, } from "@chainsafe/persistent-merkle-tree"; @@ -18,28 +18,27 @@ import { maxChunksToDepth, symbolCachedPermanentRoot, } from "../util/merkleize.js"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; -import {Type, ValueOf} from "./abstract.js"; -import {CompositeType, ByteViews, CompositeTypeAny} from "./composite.js"; +import {Case} from "../util/strings.js"; +import {Require} from "../util/types.js"; +import {BitArray} from "../value/bitArray.js"; import { - getProfileTreeViewClass, - ValueOfFields, - FieldEntry, ContainerTreeViewType, ContainerTreeViewTypeConstructor, + FieldEntry, + ValueOfFields, computeSerdesData, + getProfileTreeViewClass, } from "../view/profile.js"; import { - getProfileTreeViewDUClass, ContainerTreeViewDUType, ContainerTreeViewDUTypeConstructor, + getProfileTreeViewDUClass, } from "../viewDU/profile.js"; -import {Case} from "../util/strings.js"; -import {BitArray} from "../value/bitArray.js"; -import {mixInActiveFields, setActiveFields} from "./stableContainer.js"; +import {Type, ValueOf} from "./abstract.js"; +import {ByteViews, CompositeType, CompositeTypeAny} from "./composite.js"; import {NonOptionalFields, isOptionalType, toNonOptionalType} from "./optional.js"; -/* eslint-disable @typescript-eslint/member-ordering */ +import {mixInActiveFields, setActiveFields} from "./stableContainer.js"; type BytesRange = {start: number; end: number}; @@ -96,7 +95,11 @@ export class ProfileType>> extends C // temporary root to avoid memory allocation private tempRoot = new Uint8Array(32); - constructor(readonly fields: Fields, activeFields: BitArray, readonly opts?: ProfileOptions) { + constructor( + readonly fields: Fields, + activeFields: BitArray, + readonly opts?: ProfileOptions + ) { super(); // Render detailed typeName. Consumers should overwrite since it can get long @@ -661,11 +664,11 @@ export function precomputeJsonKey>>( throw Error(`casingMap[${String(fieldName as symbol)}] not defined`); } return keyFromCaseMap as string; - } else if (jsonCase) { - return Case[jsonCase](fieldName as string); - } else { - return fieldName as string; } + + if (jsonCase) return Case[jsonCase](fieldName as string); + + return fieldName as string; } /** diff --git a/packages/ssz/src/type/stableContainer.ts b/packages/ssz/src/type/stableContainer.ts index 7ffe912d8..727f311f6 100644 --- a/packages/ssz/src/type/stableContainer.ts +++ b/packages/ssz/src/type/stableContainer.ts @@ -1,21 +1,21 @@ import { - Node, BranchNode, + Gindex, LeafNode, - getNodesAtDepth, - subtreeFillToContents, + Node, Tree, - Gindex, - toGindex, concatGindices, - getNode, - zeroNode, - zeroHash, - merkleizeBlocksBytes, countToDepth, + getNode, getNodeH, + getNodesAtDepth, + merkleizeBlocksBytes, setNode, setNodeWithFn, + subtreeFillToContents, + toGindex, + zeroHash, + zeroNode, } from "@chainsafe/persistent-merkle-tree"; import { ValueWithCachedPermanentRoot, @@ -23,27 +23,26 @@ import { maxChunksToDepth, symbolCachedPermanentRoot, } from "../util/merkleize.js"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; -import {JsonPath, Type, ValueOf} from "./abstract.js"; -import {CompositeType, ByteViews, CompositeTypeAny, isCompositeType} from "./composite.js"; +import {Case} from "../util/strings.js"; +import {Require} from "../util/types.js"; +import {BitArray} from "../value/bitArray.js"; import { - getContainerTreeViewClass, - ValueOfFields, - FieldEntry, ContainerTreeViewType, ContainerTreeViewTypeConstructor, + FieldEntry, + ValueOfFields, computeSerdesData, + getContainerTreeViewClass, } from "../view/stableContainer.js"; import { - getContainerTreeViewDUClass, ContainerTreeViewDUType, ContainerTreeViewDUTypeConstructor, + getContainerTreeViewDUClass, } from "../viewDU/stableContainer.js"; -import {Case} from "../util/strings.js"; -import {isOptionalType, toNonOptionalType, NonOptionalFields} from "./optional.js"; -import {BitArray} from "../value/bitArray.js"; -/* eslint-disable @typescript-eslint/member-ordering */ +import {JsonPath, Type, ValueOf} from "./abstract.js"; +import {ByteViews, CompositeType, CompositeTypeAny, isCompositeType} from "./composite.js"; +import {NonOptionalFields, isOptionalType, toNonOptionalType} from "./optional.js"; type BytesRange = {start: number; end: number}; @@ -101,7 +100,11 @@ export class StableContainerType>> e // temporary root to avoid memory allocation private tempRoot = new Uint8Array(32); - constructor(fields: Fields, readonly maxFields: number, readonly opts?: StableContainerOptions) { + constructor( + fields: Fields, + readonly maxFields: number, + readonly opts?: StableContainerOptions + ) { super(); this.fields = fields; @@ -716,11 +719,11 @@ export function precomputeJsonKey>>( throw Error(`casingMap[${String(fieldName as symbol)}] not defined`); } return keyFromCaseMap as string; - } else if (jsonCase) { - return Case[jsonCase](fieldName as string); - } else { - return fieldName as string; } + + if (jsonCase) return Case[jsonCase](fieldName as string); + + return fieldName as string; } /** diff --git a/packages/ssz/src/type/uint.ts b/packages/ssz/src/type/uint.ts index 4652466ad..9e4bbbef3 100644 --- a/packages/ssz/src/type/uint.ts +++ b/packages/ssz/src/type/uint.ts @@ -4,8 +4,6 @@ import {Require} from "../util/types.js"; import {ByteViews} from "./abstract.js"; import {BasicType} from "./basic.js"; -/* eslint-disable @typescript-eslint/member-ordering */ - const MAX_SAFE_INTEGER_BN = BigInt(Number.MAX_SAFE_INTEGER); const BIGINT_2_POW_64 = BigInt(2) ** BigInt(64); const BIGINT_2_POW_128 = BigInt(2) ** BigInt(128); @@ -51,7 +49,10 @@ export class UintNumberType extends BasicType { private readonly clipInfinity: boolean; private readonly setBitwiseOR: boolean; - constructor(readonly byteLength: UintNumberByteLen, opts?: UintNumberOpts) { + constructor( + readonly byteLength: UintNumberByteLen, + opts?: UintNumberOpts + ) { super(); if (byteLength > 8) { @@ -97,7 +98,7 @@ export class UintNumberType extends BasicType { dataView.setUint32(offset, value, true); break; case 8: - if (value === Infinity) { + if (value === Number.POSITIVE_INFINITY) { // TODO: Benchmark if it's faster to set BIGINT_64_MAX once dataView.setUint32(offset, 0xffffffff); dataView.setUint32(offset + 4, 0xffffffff); @@ -125,10 +126,9 @@ export class UintNumberType extends BasicType { const a = dataView.getUint32(start, true); const b = dataView.getUint32(start + 4, true); if (b === NUMBER_32_MAX && a === NUMBER_32_MAX && this.clipInfinity) { - return Infinity; - } else { - return b * NUMBER_2_POW_32 + a; + return Number.POSITIVE_INFINITY; } + return b * NUMBER_2_POW_32 + a; } } } @@ -185,39 +185,41 @@ export class UintNumberType extends BasicType { fromJson(json: unknown): number { if (typeof json === "number") { return json; - } else if (typeof json === "string") { + } + + if (typeof json === "string") { if (this.clipInfinity && json === this.maxDecimalStr) { // Allow to handle max possible number - return Infinity; - } else { - const num = parseInt(json, 10); - if (isNaN(num)) { - throw Error("JSON invalid number isNaN"); - } else if (num > Number.MAX_SAFE_INTEGER) { - // Throw to prevent decimal precision errors downstream - throw Error("JSON invalid number > MAX_SAFE_INTEGER"); - } else { - return num; - } + return Number.POSITIVE_INFINITY; } - } else if (typeof json === "bigint") { + + const num = Number.parseInt(json, 10); + if (Number.isNaN(num)) throw Error("JSON invalid number isNaN"); + + if (num > Number.MAX_SAFE_INTEGER) { + // Throw to prevent decimal precision errors downstream + throw Error("JSON invalid number > MAX_SAFE_INTEGER"); + } + + return num; + } + + if (typeof json === "bigint") { if (json > MAX_SAFE_INTEGER_BN) { // Throw to prevent decimal precision errors downstream throw Error("JSON invalid number > MAX_SAFE_INTEGER_BN"); - } else { - return Number(json); } - } else { - throw Error(`JSON invalid type ${typeof json} expected number`); + return Number(json); } + + throw Error(`JSON invalid type ${typeof json} expected number`); } toJson(value: number): unknown { - if (value === Infinity) { + if (value === Number.POSITIVE_INFINITY) { return this.maxDecimalStr; - } else { - return value.toString(10); } + return value.toString(10); } } @@ -245,7 +247,10 @@ export class UintBigintType extends BasicType { readonly minSize: number; readonly maxSize: number; - constructor(readonly byteLength: UintBigintByteLen, opts?: UintBigintOpts) { + constructor( + readonly byteLength: UintBigintByteLen, + opts?: UintBigintOpts + ) { super(); if (byteLength > 32) { @@ -375,13 +380,9 @@ export class UintBigintType extends BasicType { // JSON fromJson(json: unknown): bigint { - if (typeof json === "bigint") { - return json; - } else if (typeof json === "string" || typeof json === "number") { - return BigInt(json); - } else { - throw Error(`JSON invalid type ${typeof json} expected bigint`); - } + if (typeof json === "bigint") return json; + if (typeof json === "string" || typeof json === "number") return BigInt(json); + throw Error(`JSON invalid type ${typeof json} expected bigint`); } toJson(value: bigint): unknown { diff --git a/packages/ssz/src/type/union.ts b/packages/ssz/src/type/union.ts index a70dfa674..d4ae31f89 100644 --- a/packages/ssz/src/type/union.ts +++ b/packages/ssz/src/type/union.ts @@ -1,23 +1,21 @@ +import {allocUnsafe} from "@chainsafe/as-sha256"; import { - concatGindices, - getNode, Gindex, + HashComputationLevel, Node, Tree, - merkleizeBlocksBytes, + concatGindices, getHashComputations, - HashComputationLevel, + getNode, + merkleizeBlocksBytes, } from "@chainsafe/persistent-merkle-tree"; -import {allocUnsafe} from "@chainsafe/as-sha256"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; -import {Type, ByteViews} from "./abstract.js"; -import {CompositeType, isCompositeType} from "./composite.js"; +import {Require} from "../util/types.js"; +import {ByteViews, Type} from "./abstract.js"; import {addLengthNode, getLengthFromRootNode} from "./arrayBasic.js"; +import {CompositeType, isCompositeType} from "./composite.js"; import {NoneType} from "./none.js"; -/* eslint-disable @typescript-eslint/member-ordering */ - type Union = { readonly selector: number; value: T; @@ -58,7 +56,10 @@ export class UnionType[]> extends CompositeType< protected readonly maxSelector: number; - constructor(readonly types: Types, opts?: UnionOpts) { + constructor( + readonly types: Types, + opts?: UnionOpts + ) { super(); if (types.length >= 128) { diff --git a/packages/ssz/src/type/vectorBasic.ts b/packages/ssz/src/type/vectorBasic.ts index 0f52cf229..dea321d90 100644 --- a/packages/ssz/src/type/vectorBasic.ts +++ b/packages/ssz/src/type/vectorBasic.ts @@ -1,20 +1,18 @@ -import {Node, Tree, HashComputationLevel} from "@chainsafe/persistent-merkle-tree"; +import {HashComputationLevel, Node, Tree} from "@chainsafe/persistent-merkle-tree"; import {maxChunksToDepth} from "../util/merkleize.js"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; -import {ValueOf, ByteViews} from "./abstract.js"; -import {BasicType} from "./basic.js"; +import {Require} from "../util/types.js"; +import {ArrayBasicTreeView, ArrayBasicType} from "../view/arrayBasic.js"; +import {ArrayBasicTreeViewDU} from "../viewDU/arrayBasic.js"; +import {ByteViews, ValueOf} from "./abstract.js"; +import {ArrayType} from "./array.js"; import { - value_deserializeFromBytesArrayBasic, - value_serializeToBytesArrayBasic, tree_deserializeFromBytesArrayBasic, tree_serializeToBytesArrayBasic, + value_deserializeFromBytesArrayBasic, + value_serializeToBytesArrayBasic, } from "./arrayBasic.js"; -import {ArrayBasicType, ArrayBasicTreeView} from "../view/arrayBasic.js"; -import {ArrayBasicTreeViewDU} from "../viewDU/arrayBasic.js"; -import {ArrayType} from "./array.js"; - -/* eslint-disable @typescript-eslint/member-ordering */ +import {BasicType} from "./basic.js"; export type VectorBasicOpts = { typeName?: string; @@ -43,7 +41,11 @@ export class VectorBasicType> readonly isViewMutable = true; protected readonly defaultLen: number; - constructor(readonly elementType: ElementType, readonly length: number, opts?: VectorBasicOpts) { + constructor( + readonly elementType: ElementType, + readonly length: number, + opts?: VectorBasicOpts + ) { super(elementType); if (!elementType.isBasic) throw Error("elementType must be basic"); @@ -76,7 +78,8 @@ export class VectorBasicType> getViewDU(node: Node, cache?: unknown): ArrayBasicTreeViewDU { // cache type should be validated (if applicate) in the view - // eslint-disable-next-line @typescript-eslint/no-explicit-any + + // biome-ignore lint/suspicious/noExplicitAny: We explicity need to use `any` here return new ArrayBasicTreeViewDU(this, node, cache as any); } @@ -141,7 +144,7 @@ export class VectorBasicType> return 0; } - tree_setChunksNode(rootNode: Node, chunksNode: Node): Node { + tree_setChunksNode(_rootNode: Node, chunksNode: Node): Node { return chunksNode; } diff --git a/packages/ssz/src/type/vectorComposite.ts b/packages/ssz/src/type/vectorComposite.ts index 2c85b238f..efab3e3c1 100644 --- a/packages/ssz/src/type/vectorComposite.ts +++ b/packages/ssz/src/type/vectorComposite.ts @@ -1,25 +1,23 @@ -import {Node, Tree, HashComputationLevel} from "@chainsafe/persistent-merkle-tree"; +import {HashComputationLevel, Node, Tree} from "@chainsafe/persistent-merkle-tree"; import {maxChunksToDepth} from "../util/merkleize.js"; -import {Require} from "../util/types.js"; import {namedClass} from "../util/named.js"; -import {ValueOf, ByteViews} from "./abstract.js"; -import {CompositeType, CompositeView, CompositeViewDU} from "./composite.js"; +import {Require} from "../util/types.js"; +import {ArrayCompositeTreeView, ArrayCompositeType} from "../view/arrayComposite.js"; +import {ArrayCompositeTreeViewDU} from "../viewDU/arrayComposite.js"; +import {ByteViews, ValueOf} from "./abstract.js"; +import {ArrayType} from "./array.js"; import { - value_deserializeFromBytesArrayComposite, - value_serializedSizeArrayComposite, - value_serializeToBytesArrayComposite, - tree_serializedSizeArrayComposite, - tree_deserializeFromBytesArrayComposite, - tree_serializeToBytesArrayComposite, maxSizeArrayComposite, minSizeArrayComposite, + tree_deserializeFromBytesArrayComposite, + tree_serializeToBytesArrayComposite, + tree_serializedSizeArrayComposite, + value_deserializeFromBytesArrayComposite, value_getBlocksBytesArrayComposite, + value_serializeToBytesArrayComposite, + value_serializedSizeArrayComposite, } from "./arrayComposite.js"; -import {ArrayCompositeType, ArrayCompositeTreeView} from "../view/arrayComposite.js"; -import {ArrayCompositeTreeViewDU} from "../viewDU/arrayComposite.js"; -import {ArrayType} from "./array.js"; - -/* eslint-disable @typescript-eslint/member-ordering */ +import {CompositeType, CompositeView, CompositeViewDU} from "./composite.js"; export type VectorCompositeOpts = { typeName?: string; @@ -33,8 +31,8 @@ export type VectorCompositeOpts = { * - Composite types are always returned as views */ export class VectorCompositeType< - // eslint-disable-next-line @typescript-eslint/no-explicit-any - ElementType extends CompositeType, CompositeViewDU> + // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly + ElementType extends CompositeType, CompositeViewDU>, > extends ArrayType, ArrayCompositeTreeViewDU> implements ArrayCompositeType @@ -51,7 +49,11 @@ export class VectorCompositeType< readonly isViewMutable = true; protected readonly defaultLen: number; - constructor(readonly elementType: ElementType, readonly length: number, opts?: VectorCompositeOpts) { + constructor( + readonly elementType: ElementType, + readonly length: number, + opts?: VectorCompositeOpts + ) { super(elementType); if (elementType.isBasic) throw Error("elementType must not be basic"); @@ -68,8 +70,7 @@ export class VectorCompositeType< this.blocksBuffer = new Uint8Array(Math.ceil(this.maxChunkCount / 2) * 64); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - static named, CompositeViewDU>>( + static named, CompositeViewDU>>( elementType: ElementType, limit: number, opts: Require @@ -83,7 +84,8 @@ export class VectorCompositeType< getViewDU(node: Node, cache?: unknown): ArrayCompositeTreeViewDU { // cache type should be validated (if applicate) in the view - // eslint-disable-next-line @typescript-eslint/no-explicit-any + + // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly return new ArrayCompositeTreeViewDU(this, node, cache as any); } @@ -148,7 +150,7 @@ export class VectorCompositeType< return 0; } - tree_setChunksNode(rootNode: Node, chunksNode: Node): Node { + tree_setChunksNode(_rootNode: Node, chunksNode: Node): Node { return chunksNode; } diff --git a/packages/ssz/src/util/byteArray.ts b/packages/ssz/src/util/byteArray.ts index 31cf06931..20f2c4c76 100644 --- a/packages/ssz/src/util/byteArray.ts +++ b/packages/ssz/src/util/byteArray.ts @@ -30,7 +30,7 @@ export function fromHexString(hex: string): Uint8Array { const byteLen = hex.length / 2; const bytes = new Uint8Array(byteLen); for (let i = 0; i < byteLen; i++) { - const byte = parseInt(hex.slice(i * 2, (i + 1) * 2), 16); + const byte = Number.parseInt(hex.slice(i * 2, (i + 1) * 2), 16); bytes[i] = byte; } return bytes; diff --git a/packages/ssz/src/util/merkleize.ts b/packages/ssz/src/util/merkleize.ts index 3518473ab..0b494ce03 100644 --- a/packages/ssz/src/util/merkleize.ts +++ b/packages/ssz/src/util/merkleize.ts @@ -25,9 +25,9 @@ export function cacheRoot( safeCache && output.length === 32 && offset === 0 ? output : safeCache - ? output.subarray(offset, offset + 32) - : // Buffer.prototype.slice does not copy memory, Enforce Uint8Array usage https://github.com/nodejs/node/issues/28087 - Uint8Array.prototype.slice.call(output, offset, offset + 32); + ? output.subarray(offset, offset + 32) + : // Buffer.prototype.slice does not copy memory, Enforce Uint8Array usage https://github.com/nodejs/node/issues/28087 + Uint8Array.prototype.slice.call(output, offset, offset + 32); value[symbolCachedPermanentRoot] = cachedRoot; } @@ -37,7 +37,7 @@ export function hash64(bytes32A: Uint8Array, bytes32B: Uint8Array): Uint8Array { export function merkleize(chunks: Uint8Array[], padFor: number): Uint8Array { const layerCount = bitLength(nextPowerOf2(padFor) - 1); - if (chunks.length == 0) { + if (chunks.length === 0) { return zeroHash(layerCount); } diff --git a/packages/ssz/src/util/proof/treePartialToJsonPaths.ts b/packages/ssz/src/util/proof/treePartialToJsonPaths.ts index 40d284055..3465206e8 100644 --- a/packages/ssz/src/util/proof/treePartialToJsonPaths.ts +++ b/packages/ssz/src/util/proof/treePartialToJsonPaths.ts @@ -41,77 +41,67 @@ export function treePartialToJsonPaths( const childType = type.getPropertyType(jsonPathProp); // If this type merkleized fits in a single chunk then this LeafNode includes all data - if (childType.maxChunkCount === 1) { - return {type: TreeDataTypeCode.complete, jsonPathProps: [jsonPathProp]}; - } else { - return {type: TreeDataTypeCode.witness}; - } + if (childType.maxChunkCount === 1) return {type: TreeDataTypeCode.complete, jsonPathProps: [jsonPathProp]}; + + return {type: TreeDataTypeCode.witness}; } // LeafNode not at type depth can be either // - length / selector nodes // - witness - else { - if (currentDepth === 1 && bitstringToIndex(bitstring) === 1 && isCompositeType(type)) { - if (type.isList) { - return {type: TreeDataTypeCode.complete, jsonPathProps: []}; - } - } - return {type: TreeDataTypeCode.witness}; + if (currentDepth === 1 && bitstringToIndex(bitstring) === 1 && isCompositeType(type) && type.isList) { + return {type: TreeDataTypeCode.complete, jsonPathProps: []}; } - } else { - if (atTypeDepth) { - const jsonPathProp = type.getIndexProperty(bitstringToIndex(bitstring)); - if (jsonPathProp === null) { - return {type: TreeDataTypeCode.complete, jsonPathProps: []}; - } + return {type: TreeDataTypeCode.witness}; + } - const childType = type.getPropertyType(jsonPathProp); + if (atTypeDepth) { + const jsonPathProp = type.getIndexProperty(bitstringToIndex(bitstring)); + if (jsonPathProp === null) { + return {type: TreeDataTypeCode.complete, jsonPathProps: []}; + } - if (!isCompositeType(childType)) { - throw Error("BranchNode does not map to CompositeType"); - } + const childType = type.getPropertyType(jsonPathProp); - // Restart navigation with childType, bitstring = "0", currentDepth = 0 - const ress = treePartialToJsonPaths(node, childType, "0", 0); - - if (ress.type === TreeDataTypeCode.complete) { - return {type: TreeDataTypeCode.complete, jsonPathProps: [jsonPathProp]}; - } else if (ress.type === TreeDataTypeCode.partial) { - return { - type: TreeDataTypeCode.partial, - jsonPaths: ress.jsonPaths.filter((jpp) => jpp.length > 0).map((jpp) => [jsonPathProp, ...jpp]), - }; - } else { - throw Error(`BranchNode navigation returns witness - bitstring ${bitstring}`); - } + if (!isCompositeType(childType)) { + throw Error("BranchNode does not map to CompositeType"); } - // BranchNode at not type depth, keep navigating - else { - const leftRes = treePartialToJsonPaths(node.left, type, bitstring + "0", currentDepth + 1); - const rightRes = treePartialToJsonPaths(node.right, type, bitstring + "1", currentDepth + 1); + // Restart navigation with childType, bitstring = "0", currentDepth = 0 + const ress = treePartialToJsonPaths(node, childType, "0", 0); - // Upstream status that all data is there - if (leftRes.type === TreeDataTypeCode.complete && rightRes.type === TreeDataTypeCode.complete) { - return {type: TreeDataTypeCode.complete, jsonPathProps: [...leftRes.jsonPathProps, ...rightRes.jsonPathProps]}; - } + if (ress.type === TreeDataTypeCode.complete) { + return {type: TreeDataTypeCode.complete, jsonPathProps: [jsonPathProp]}; + } + if (ress.type === TreeDataTypeCode.partial) { + return { + type: TreeDataTypeCode.partial, + jsonPaths: ress.jsonPaths.filter((jpp) => jpp.length > 0).map((jpp) => [jsonPathProp, ...jpp]), + }; + } + throw Error(`BranchNode navigation returns witness - bitstring ${bitstring}`); + } - // Ensure there's not a bad BranchNode. All BranchNodes must contain some data at least on one side - else if (leftRes.type === TreeDataTypeCode.witness && rightRes.type === TreeDataTypeCode.witness) { - throw Error(`BranchNode with witness in left and right nodes - bitstring ${bitstring}`); - } + // BranchNode at not type depth, keep navigating + const leftRes = treePartialToJsonPaths(node.left, type, bitstring + "0", currentDepth + 1); + const rightRes = treePartialToJsonPaths(node.right, type, bitstring + "1", currentDepth + 1); - // Here equals to: - // - partial-data on both sides - // - partial-data + full-data - // - partial-data + witness - // - full-data + witness - else { - return {type: TreeDataTypeCode.partial, jsonPaths: getMergedJsonPathsFrom(leftRes, rightRes)}; - } - } + // Upstream status that all data is there + if (leftRes.type === TreeDataTypeCode.complete && rightRes.type === TreeDataTypeCode.complete) { + return {type: TreeDataTypeCode.complete, jsonPathProps: [...leftRes.jsonPathProps, ...rightRes.jsonPathProps]}; + } + + // Ensure there's not a bad BranchNode. All BranchNodes must contain some data at least on one side + if (leftRes.type === TreeDataTypeCode.witness && rightRes.type === TreeDataTypeCode.witness) { + throw Error(`BranchNode with witness in left and right nodes - bitstring ${bitstring}`); } + + // Here equals to: + // - partial-data on both sides + // - partial-data + full-data + // - partial-data + witness + // - full-data + witness + return {type: TreeDataTypeCode.partial, jsonPaths: getMergedJsonPathsFrom(leftRes, rightRes)}; } function getJsonPathFromRes(res: TreeDataType): JsonPath[] { @@ -131,7 +121,7 @@ function getMergedJsonPathsFrom(leftRes: TreeDataType, rightRes: TreeDataType): function bitstringToIndex(bitstring: string): number { if (bitstring === "") return 0; - return parseInt(bitstring, 2); + return Number.parseInt(bitstring, 2); } /** @@ -142,16 +132,14 @@ function bitstringToIndex(bitstring: string): number { * See https://github.com/protolambda/eth-merkle-trees/blob/master/tree_offsets.md */ export function treeOffsetProofToNode(offsets: number[], leaves: Uint8Array[]): Node { - if (!leaves.length) { - throw new Error("Proof must contain gt 0 leaves"); - } else if (leaves.length === 1) { - return LeafNode.fromRoot(leaves[0]); - } else { - // the offset popped from the list is the # of leaves in the left subtree - const pivot = offsets[0]; - return new BranchNode( - treeOffsetProofToNode(offsets.slice(1, pivot), leaves.slice(0, pivot)), - treeOffsetProofToNode(offsets.slice(pivot), leaves.slice(pivot)) - ); - } + if (!leaves.length) throw new Error("Proof must contain gt 0 leaves"); + + if (leaves.length === 1) return LeafNode.fromRoot(leaves[0]); + + // the offset popped from the list is the # of leaves in the left subtree + const pivot = offsets[0]; + return new BranchNode( + treeOffsetProofToNode(offsets.slice(1, pivot), leaves.slice(0, pivot)), + treeOffsetProofToNode(offsets.slice(pivot), leaves.slice(pivot)) + ); } diff --git a/packages/ssz/src/util/proof/treePostProcessFromProofNode.ts b/packages/ssz/src/util/proof/treePostProcessFromProofNode.ts index 36e3064f6..b0720aa70 100644 --- a/packages/ssz/src/util/proof/treePostProcessFromProofNode.ts +++ b/packages/ssz/src/util/proof/treePostProcessFromProofNode.ts @@ -39,11 +39,8 @@ export function treePostProcessFromProofNode(node: Node, type: CompositeType, bi // Must run tree_fromProofNode on the first received node (i.e. Validator object) if (currentDepth === 0) { const nodePost = type.tree_fromProofNode(node); - if (nodePost.done) { - return nodePost.node; - } else { - node = nodePost.node; - } + if (nodePost.done) return nodePost.node; + node = nodePost.node; } const atTypeDepth = type.depth === currentDepth; @@ -63,55 +60,44 @@ export function treePostProcessFromProofNode(node: Node, type: CompositeType, bi return childType.tree_fromProofNode(node).node; } // Witness node - else { - return node; - } + return node; } // LeafNode not at type depth is a witness or a length / selector nodes - else { - return node; - } - } else { - if (atTypeDepth) { - const jsonPathProp = type.getIndexProperty(bitstringToIndex(bitstring)); - if (jsonPathProp === null) { - // bitstring is out of bounds, witness node - return node; - } + return node; + } - const childType = type.getPropertyType(jsonPathProp); + if (atTypeDepth) { + const jsonPathProp = type.getIndexProperty(bitstringToIndex(bitstring)); - if (!isCompositeType(childType)) { - throw Error("BranchNode does not map to CompositeType"); - } + // bitstring is out of bounds, witness node + if (jsonPathProp === null) return node; - const nodePost = childType.tree_fromProofNode(node); + const childType = type.getPropertyType(jsonPathProp); - // If tree_fromProofNode is the identity function, keep going, otherwise stop navigating - if (nodePost.done) { - return nodePost.node; - } else { - return treePostProcessFromProofNode(nodePost.node, childType); - } + if (!isCompositeType(childType)) { + throw Error("BranchNode does not map to CompositeType"); } - // BranchNode at not type depth, keep navigating - else { - const leftNode = treePostProcessFromProofNode(node.left, type, bitstring + "0", currentDepth + 1); - const rightNode = treePostProcessFromProofNode(node.right, type, bitstring + "1", currentDepth + 1); + const nodePost = childType.tree_fromProofNode(node); - if (leftNode === node.left && rightNode === node.right) { - return node; - } else { - return new BranchNode(leftNode, rightNode); - } - } + // If tree_fromProofNode is the identity function, keep going, otherwise stop navigating + if (nodePost.done) return nodePost.node; + + return treePostProcessFromProofNode(nodePost.node, childType); } + + // BranchNode at not type depth, keep navigating + const leftNode = treePostProcessFromProofNode(node.left, type, bitstring + "0", currentDepth + 1); + const rightNode = treePostProcessFromProofNode(node.right, type, bitstring + "1", currentDepth + 1); + + if (leftNode === node.left && rightNode === node.right) return node; + + return new BranchNode(leftNode, rightNode); } /** Return the node horizontal index given a bitstring without the leading "1" */ function bitstringToIndex(bitstring: string): number { if (bitstring === "") return 0; - return parseInt(bitstring, 2); + return Number.parseInt(bitstring, 2); } diff --git a/packages/ssz/src/util/upgrade.ts b/packages/ssz/src/util/upgrade.ts index 8e0830ac3..d8a9b2de4 100644 --- a/packages/ssz/src/util/upgrade.ts +++ b/packages/ssz/src/util/upgrade.ts @@ -2,7 +2,8 @@ import {BranchNode, Node, zeroNode} from "@chainsafe/persistent-merkle-tree"; import {ContainerType} from "../type/container.js"; /** Upgrade the current View/ViewDU to a root node of new type */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any + +// biome-ignore lint/suspicious/noExplicitAny: We need to use `any` here explicitly export function upgradeToNewType(rootNode: Node, oldType: ContainerType, newType: ContainerType): Node { const newFieldsCount = newType.fieldsEntries.length; const currentFieldsCount = oldType.fieldsEntries.length; diff --git a/packages/ssz/src/value/bitArray.ts b/packages/ssz/src/value/bitArray.ts index 2e1282be1..feb1052cd 100644 --- a/packages/ssz/src/value/bitArray.ts +++ b/packages/ssz/src/value/bitArray.ts @@ -206,12 +206,10 @@ export class BitArray { } } - if (index === null) { - // ERROR_NO_BIT_SET - return null; - } else { - return index; - } + // ERROR_NO_BIT_SET + if (index === null) return null; + + return index; } toBoolArray(): boolean[] { diff --git a/packages/ssz/src/view/abstract.ts b/packages/ssz/src/view/abstract.ts index ab16b327b..67737b8b3 100644 --- a/packages/ssz/src/view/abstract.ts +++ b/packages/ssz/src/view/abstract.ts @@ -1,5 +1,5 @@ -import {Node, Tree, Proof} from "@chainsafe/persistent-merkle-tree"; -import {ValueOf, JsonPath} from "../type/abstract.js"; +import {Node, Proof, Tree} from "@chainsafe/persistent-merkle-tree"; +import {JsonPath, ValueOf} from "../type/abstract.js"; import {CompositeType} from "../type/composite.js"; /** diff --git a/packages/ssz/src/view/arrayBasic.ts b/packages/ssz/src/view/arrayBasic.ts index b74da6e93..08d354ba2 100644 --- a/packages/ssz/src/view/arrayBasic.ts +++ b/packages/ssz/src/view/arrayBasic.ts @@ -1,4 +1,4 @@ -import {getNodesAtDepth, LeafNode, Node, Tree, HashComputationLevel} from "@chainsafe/persistent-merkle-tree"; +import {HashComputationLevel, LeafNode, Node, Tree, getNodesAtDepth} from "@chainsafe/persistent-merkle-tree"; import {ValueOf} from "../type/abstract.js"; import {BasicType} from "../type/basic.js"; import {CompositeType} from "../type/composite.js"; @@ -38,7 +38,10 @@ export type ArrayType = { }; export class ArrayBasicTreeView> extends TreeView> { - constructor(readonly type: ArrayBasicType, protected tree: Tree) { + constructor( + readonly type: ArrayBasicType, + protected tree: Tree + ) { super(); } @@ -61,7 +64,6 @@ export class ArrayBasicTreeView> extends const chunkIndex = Math.floor(index / this.type.itemsPerChunk); const leafNode = this.tree.getNodeAtDepth(this.type.depth, chunkIndex) as LeafNode; - // eslint-disable-next-line @typescript-eslint/no-unsafe-return return this.type.elementType.tree_getFromPackedNode(leafNode, index) as ValueOf; } diff --git a/packages/ssz/src/view/arrayComposite.ts b/packages/ssz/src/view/arrayComposite.ts index 0c8c2064c..d702c6d7e 100644 --- a/packages/ssz/src/view/arrayComposite.ts +++ b/packages/ssz/src/view/arrayComposite.ts @@ -1,4 +1,4 @@ -import {getNodesAtDepth, Node, toGindexBitstring, Tree} from "@chainsafe/persistent-merkle-tree"; +import {Node, Tree, getNodesAtDepth, toGindexBitstring} from "@chainsafe/persistent-merkle-tree"; import {ValueOf} from "../type/abstract.js"; import {CompositeType, CompositeView, CompositeViewDU} from "../type/composite.js"; import {TreeView} from "./abstract.js"; @@ -6,7 +6,7 @@ import {ArrayType} from "./arrayBasic.js"; /** Expected API of this View's type. This interface allows to break a recursive dependency between types and views */ export type ArrayCompositeType< - ElementType extends CompositeType, CompositeViewDU> + ElementType extends CompositeType, CompositeViewDU>, > = CompositeType[], unknown, unknown> & ArrayType & { readonly elementType: ElementType; @@ -14,9 +14,12 @@ export type ArrayCompositeType< }; export class ArrayCompositeTreeView< - ElementType extends CompositeType, CompositeView, CompositeViewDU> + ElementType extends CompositeType, CompositeView, CompositeViewDU>, > extends TreeView> { - constructor(readonly type: ArrayCompositeType, protected tree: Tree) { + constructor( + readonly type: ArrayCompositeType, + protected tree: Tree + ) { super(); } diff --git a/packages/ssz/src/view/bitArray.ts b/packages/ssz/src/view/bitArray.ts index 017e6a7df..19fd9330d 100644 --- a/packages/ssz/src/view/bitArray.ts +++ b/packages/ssz/src/view/bitArray.ts @@ -1,6 +1,6 @@ -import {Tree, Node} from "@chainsafe/persistent-merkle-tree"; -import {BitArray} from "../value/bitArray.js"; +import {Node, Tree} from "@chainsafe/persistent-merkle-tree"; import {CompositeType} from "../type/composite.js"; +import {BitArray} from "../value/bitArray.js"; import {TreeView} from "./abstract.js"; /** @@ -9,7 +9,10 @@ import {TreeView} from "./abstract.js"; export class BitArrayTreeView extends TreeView> implements BitArray { private readonly bitArray: BitArray; - constructor(readonly type: CompositeType, protected tree: Tree) { + constructor( + readonly type: CompositeType, + protected tree: Tree + ) { super(); this.bitArray = type.tree_toValue(tree.rootNode); diff --git a/packages/ssz/src/view/container.ts b/packages/ssz/src/view/container.ts index ee10a4b54..5a8164822 100644 --- a/packages/ssz/src/view/container.ts +++ b/packages/ssz/src/view/container.ts @@ -1,9 +1,9 @@ -import {getNodeAtDepth, Gindex, LeafNode, Node, toGindexBitstring, Tree} from "@chainsafe/persistent-merkle-tree"; +import {Gindex, LeafNode, Node, Tree, getNodeAtDepth, toGindexBitstring} from "@chainsafe/persistent-merkle-tree"; import {Type, ValueOf} from "../type/abstract.js"; -import {isBasicType, BasicType} from "../type/basic.js"; -import {isCompositeType, CompositeType} from "../type/composite.js"; -import {TreeView} from "./abstract.js"; +import {BasicType, isBasicType} from "../type/basic.js"; +import {CompositeType, isCompositeType} from "../type/composite.js"; import {NonOptionalFields} from "../type/optional.js"; +import {TreeView} from "./abstract.js"; export type FieldEntry>> = { fieldName: keyof Fields; @@ -33,9 +33,9 @@ export type FieldsView>> = { ? // If composite, return view. MAY propagate changes updwards TV : // If basic, return struct value. Will NOT propagate changes upwards - Fields[K] extends BasicType - ? V - : never; + Fields[K] extends BasicType + ? V + : never; }; export type ContainerTreeViewType>> = FieldsView & @@ -60,7 +60,10 @@ export type ContainerTreeViewTypeConstructor>> extends TreeView> { - constructor(readonly type: ContainerTypeGeneric, readonly tree: Tree) { + constructor( + readonly type: ContainerTypeGeneric, + readonly tree: Tree + ) { super(); } diff --git a/packages/ssz/src/view/containerNodeStruct.ts b/packages/ssz/src/view/containerNodeStruct.ts index ee26f9e94..6399f3c73 100644 --- a/packages/ssz/src/view/containerNodeStruct.ts +++ b/packages/ssz/src/view/containerNodeStruct.ts @@ -1,11 +1,9 @@ import {Node, Tree} from "@chainsafe/persistent-merkle-tree"; +import {BranchNodeStruct} from "../branchNodeStruct.js"; import {Type, ValueOf} from "../type/abstract.js"; import {isCompositeType} from "../type/composite.js"; -import {BranchNodeStruct} from "../branchNodeStruct.js"; -import {ContainerTreeViewTypeConstructor, ContainerTypeGeneric, ValueOfFields} from "./container.js"; import {TreeView} from "./abstract.js"; - -/* eslint-disable @typescript-eslint/member-ordering */ +import {ContainerTreeViewTypeConstructor, ContainerTypeGeneric, ValueOfFields} from "./container.js"; /** * Intented usage: @@ -23,7 +21,10 @@ import {TreeView} from "./abstract.js"; * */ class ContainerTreeView>> extends TreeView> { - constructor(readonly type: ContainerTypeGeneric, readonly tree: Tree) { + constructor( + readonly type: ContainerTypeGeneric, + readonly tree: Tree + ) { super(); } @@ -60,6 +61,7 @@ export function getContainerTreeViewClass; + // biome-ignore lint/complexity/useLiteralKeys: The key `valueToNode` is private field this.tree.rootNode = new BranchNodeStruct(node["valueToNode"], newNodeValue); }, }); @@ -86,6 +88,7 @@ export function getContainerTreeViewClass; + // biome-ignore lint/complexity/useLiteralKeys: The key `valueToNode` is private field this.tree.rootNode = new BranchNodeStruct(node["valueToNode"], newNodeValue); }, }); diff --git a/packages/ssz/src/view/listBasic.ts b/packages/ssz/src/view/listBasic.ts index c526141d7..db451c968 100644 --- a/packages/ssz/src/view/listBasic.ts +++ b/packages/ssz/src/view/listBasic.ts @@ -9,7 +9,10 @@ export type ListBasicType> = ArrayBasicTy }; export class ListBasicTreeView> extends ArrayBasicTreeView { - constructor(readonly type: ListBasicType, protected tree: Tree) { + constructor( + readonly type: ListBasicType, + protected tree: Tree + ) { super(type, tree); } diff --git a/packages/ssz/src/view/listComposite.ts b/packages/ssz/src/view/listComposite.ts index b841e55b4..b4cac3cd7 100644 --- a/packages/ssz/src/view/listComposite.ts +++ b/packages/ssz/src/view/listComposite.ts @@ -5,15 +5,18 @@ import {ArrayCompositeTreeView, ArrayCompositeType} from "./arrayComposite.js"; /** Expected API of this View's type. This interface allows to break a recursive dependency between types and views */ export type ListCompositeType< - ElementType extends CompositeType, CompositeViewDU> + ElementType extends CompositeType, CompositeViewDU>, > = ArrayCompositeType & { readonly limit: number; }; export class ListCompositeTreeView< - ElementType extends CompositeType, CompositeView, CompositeViewDU> + ElementType extends CompositeType, CompositeView, CompositeViewDU>, > extends ArrayCompositeTreeView { - constructor(readonly type: ListCompositeType, protected tree: Tree) { + constructor( + readonly type: ListCompositeType, + protected tree: Tree + ) { super(type, tree); } diff --git a/packages/ssz/src/view/profile.ts b/packages/ssz/src/view/profile.ts index f71e46578..5b2c28c64 100644 --- a/packages/ssz/src/view/profile.ts +++ b/packages/ssz/src/view/profile.ts @@ -1,18 +1,18 @@ import { - getNodeAtDepth, Gindex, - zeroNode, LeafNode, Node, - toGindexBitstring, Tree, + getNodeAtDepth, + toGindexBitstring, + zeroNode, } from "@chainsafe/persistent-merkle-tree"; import {Type, ValueOf} from "../type/abstract.js"; -import {isBasicType, BasicType} from "../type/basic.js"; -import {isCompositeType, CompositeType} from "../type/composite.js"; -import {TreeView} from "./abstract.js"; -import {BitArray} from "../value/bitArray.js"; +import {BasicType, isBasicType} from "../type/basic.js"; +import {CompositeType, isCompositeType} from "../type/composite.js"; import {NonOptionalFields} from "../type/optional.js"; +import {BitArray} from "../value/bitArray.js"; +import {TreeView} from "./abstract.js"; export type FieldEntry>> = { fieldName: keyof Fields; @@ -42,9 +42,9 @@ export type FieldsView>> = { ? // If composite, return view. MAY propagate changes updwards TV : // If basic, return struct value. Will NOT propagate changes upwards - Fields[K] extends BasicType - ? V - : never; + Fields[K] extends BasicType + ? V + : never; }; export type ContainerTreeViewType>> = FieldsView & @@ -69,7 +69,10 @@ export type ContainerTreeViewTypeConstructor>> extends TreeView> { - constructor(readonly type: ContainerTypeGeneric, readonly tree: Tree) { + constructor( + readonly type: ContainerTypeGeneric, + readonly tree: Tree + ) { super(); } @@ -193,10 +196,8 @@ export function computeSerdesData>>( let optionalIndex = 0; for (const {optional, fieldType} of fields) { - if (optional) { - if (!optionalFields.get(optionalIndex++)) { - continue; - } + if (optional && !optionalFields.get(optionalIndex++)) { + continue; } isFixedLen.push(fieldType.fixedSize !== null); diff --git a/packages/ssz/src/view/stableContainer.ts b/packages/ssz/src/view/stableContainer.ts index 2308719d2..f3aee156b 100644 --- a/packages/ssz/src/view/stableContainer.ts +++ b/packages/ssz/src/view/stableContainer.ts @@ -1,18 +1,18 @@ import { - getNodeAtDepth, Gindex, LeafNode, Node, - toGindexBitstring, Tree, + getNodeAtDepth, + toGindexBitstring, zeroNode, } from "@chainsafe/persistent-merkle-tree"; import {Type, ValueOf} from "../type/abstract.js"; -import {isBasicType, BasicType} from "../type/basic.js"; -import {isCompositeType, CompositeType} from "../type/composite.js"; -import {TreeView} from "./abstract.js"; +import {BasicType, isBasicType} from "../type/basic.js"; +import {CompositeType, isCompositeType} from "../type/composite.js"; import {NonOptionalFields, OptionalType} from "../type/optional.js"; import {BitArray} from "../value/bitArray.js"; +import {TreeView} from "./abstract.js"; // some code is here to break the circular dependency between type, view, and viewDU @@ -45,17 +45,17 @@ export type ViewType> = T extends CompositeType - ? V - : never; + T extends BasicType + ? V + : never; export type OptionalViewType> = T extends CompositeType ? // If composite, return view. MAY propagate changes updwards if not nullish TV | null | undefined : // If basic, return struct value or nullish. Will NOT propagate changes upwards - T extends BasicType - ? V | null | undefined - : never; + T extends BasicType + ? V | null | undefined + : never; export type FieldsView>> = { [K in keyof Fields]: Fields[K] extends OptionalType ? OptionalViewType : ViewType; @@ -85,7 +85,10 @@ export type ContainerTreeViewTypeConstructor>> extends TreeView< StableContainerTypeGeneric > { - constructor(readonly type: StableContainerTypeGeneric, readonly tree: Tree) { + constructor( + readonly type: StableContainerTypeGeneric, + readonly tree: Tree + ) { super(); } diff --git a/packages/ssz/src/viewDU/abstract.ts b/packages/ssz/src/viewDU/abstract.ts index 36e033491..f97d82477 100644 --- a/packages/ssz/src/viewDU/abstract.ts +++ b/packages/ssz/src/viewDU/abstract.ts @@ -1,4 +1,4 @@ -import {HashComputationLevel, executeHashComputations, HashComputationGroup} from "@chainsafe/persistent-merkle-tree"; +import {HashComputationGroup, HashComputationLevel, executeHashComputations} from "@chainsafe/persistent-merkle-tree"; import {ByteViews, CompositeType} from "../type/composite.js"; import {TreeView} from "../view/abstract.js"; @@ -12,8 +12,6 @@ export type NodeWithCachedTreeRoot = { [symbolCachedTreeRoot]?: Uint8Array; }; -/* eslint-disable @typescript-eslint/member-ordering */ - /** * A Deferred Update Tree View (`ViewDU`) is a wrapper around a type and * a SSZ Node that contains: @@ -111,12 +109,10 @@ export abstract class TreeViewDU, CompositeView, CompositeViewDU> + ElementType extends CompositeType, CompositeView, CompositeViewDU>, > extends TreeViewDU> { protected nodes: Node[]; protected caches: unknown[]; diff --git a/packages/ssz/src/viewDU/bitArray.ts b/packages/ssz/src/viewDU/bitArray.ts index 7bdacd38b..33f04c980 100644 --- a/packages/ssz/src/viewDU/bitArray.ts +++ b/packages/ssz/src/viewDU/bitArray.ts @@ -1,6 +1,6 @@ import {HashComputationLevel, Node, getHashComputations} from "@chainsafe/persistent-merkle-tree"; -import {BitArray} from "../value/bitArray.js"; import {CompositeType} from "../type/composite.js"; +import {BitArray} from "../value/bitArray.js"; import {TreeViewDU} from "./abstract.js"; /** @@ -10,7 +10,10 @@ export class BitArrayTreeViewDU extends TreeViewDU, protected _rootNode: Node) { + constructor( + readonly type: CompositeType, + protected _rootNode: Node + ) { super(); } @@ -19,6 +22,7 @@ export class BitArrayTreeViewDU extends TreeViewDU>> = { [K in keyof Fields]: Fields[K] extends CompositeType ? // If composite, return view. MAY propagate changes updwards TVDU : // If basic, return struct value. Will NOT propagate changes upwards - Fields[K] extends BasicType - ? V - : never; + Fields[K] extends BasicType + ? V + : never; }; export type ContainerTreeViewDUType>> = FieldsViewDU & @@ -268,7 +266,6 @@ export function getContainerTreeViewDUClass>> extends TreeViewDU< ContainerTypeGeneric @@ -14,7 +12,10 @@ export class ContainerNodeStructTreeViewDU | null = null; protected _rootNode: BranchNodeStruct>; - constructor(readonly type: ContainerTypeGeneric, node: Node) { + constructor( + readonly type: ContainerTypeGeneric, + node: Node + ) { super(); this._rootNode = node as BranchNodeStruct>; } @@ -24,6 +25,7 @@ export class ContainerNodeStructTreeViewDU { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return return (this.valueChanged || this._rootNode.value)[fieldName]; }, diff --git a/packages/ssz/src/viewDU/listBasic.ts b/packages/ssz/src/viewDU/listBasic.ts index a815a476b..5e689534b 100644 --- a/packages/ssz/src/viewDU/listBasic.ts +++ b/packages/ssz/src/viewDU/listBasic.ts @@ -7,13 +7,17 @@ import { zeroNode, } from "@chainsafe/persistent-merkle-tree"; import {ByteViews, ValueOf} from "../type/abstract.js"; +import {tree_serializeToBytesArrayBasic} from "../type/arrayBasic.js"; import {BasicType} from "../type/basic.js"; import {ListBasicType} from "../view/listBasic.js"; import {ArrayBasicTreeViewDU, ArrayBasicTreeViewDUCache} from "./arrayBasic.js"; -import {tree_serializeToBytesArrayBasic} from "../type/arrayBasic.js"; export class ListBasicTreeViewDU> extends ArrayBasicTreeViewDU { - constructor(readonly type: ListBasicType, protected _rootNode: Node, cache?: ArrayBasicTreeViewDUCache) { + constructor( + readonly type: ListBasicType, + protected _rootNode: Node, + cache?: ArrayBasicTreeViewDUCache + ) { super(type, _rootNode, cache); } diff --git a/packages/ssz/src/viewDU/listComposite.ts b/packages/ssz/src/viewDU/listComposite.ts index 3c6c0225c..3ed7f57d2 100644 --- a/packages/ssz/src/viewDU/listComposite.ts +++ b/packages/ssz/src/viewDU/listComposite.ts @@ -1,14 +1,14 @@ -import {Node, subtreeFillToContents, treeZeroAfterIndex, zeroNode, toSnapshot} from "@chainsafe/persistent-merkle-tree"; +import {Node, subtreeFillToContents, toSnapshot, treeZeroAfterIndex, zeroNode} from "@chainsafe/persistent-merkle-tree"; import {ByteViews, ValueOf} from "../type/abstract.js"; +import {tree_serializeToBytesArrayComposite} from "../type/arrayComposite.js"; import {CompositeType, CompositeView, CompositeViewDU} from "../type/composite.js"; +import {zeroSnapshot} from "../util/snapshot.js"; +import {Snapshot} from "../util/types.js"; import {ListCompositeType} from "../view/listComposite.js"; import {ArrayCompositeTreeViewDU, ArrayCompositeTreeViewDUCache} from "./arrayComposite.js"; -import {tree_serializeToBytesArrayComposite} from "../type/arrayComposite.js"; -import {Snapshot} from "../util/types.js"; -import {zeroSnapshot} from "../util/snapshot.js"; export class ListCompositeTreeViewDU< - ElementType extends CompositeType, CompositeView, CompositeViewDU> + ElementType extends CompositeType, CompositeView, CompositeViewDU>, > extends ArrayCompositeTreeViewDU { constructor( readonly type: ListCompositeType, @@ -94,8 +94,8 @@ export class ListCompositeTreeViewDU< return this; } - let newChunksNode; - let newLength; + let newChunksNode: Node; + let newLength: number; if (index >= this.nodes.length) { newChunksNode = zeroNode(this.type.chunkDepth); diff --git a/packages/ssz/src/viewDU/partialListComposite.ts b/packages/ssz/src/viewDU/partialListComposite.ts index 48a1f19f0..d64ffc08a 100644 --- a/packages/ssz/src/viewDU/partialListComposite.ts +++ b/packages/ssz/src/viewDU/partialListComposite.ts @@ -1,11 +1,11 @@ -import {Node, zeroNode, subtreeFillToContents, getNodesAtDepth} from "@chainsafe/persistent-merkle-tree"; +import {Node, getNodesAtDepth, subtreeFillToContents, zeroNode} from "@chainsafe/persistent-merkle-tree"; import {ValueOf} from "../type/abstract.js"; import {CompositeType, CompositeView, CompositeViewDU} from "../type/composite.js"; -import {ArrayCompositeTreeViewDUCache} from "./arrayComposite.js"; -import {ListCompositeTreeViewDU} from "./listComposite.js"; import {PartialListCompositeType} from "../type/partialListComposite.js"; -import {Snapshot} from "../util/types.js"; import {zeroSnapshot} from "../util/snapshot.js"; +import {Snapshot} from "../util/types.js"; +import {ArrayCompositeTreeViewDUCache} from "./arrayComposite.js"; +import {ListCompositeTreeViewDU} from "./listComposite.js"; /** * Similar to ListCompositeTreeViewDU but this is created from a snapshot so some methods are not supported @@ -13,7 +13,7 @@ import {zeroSnapshot} from "../util/snapshot.js"; * Note that the backed tree is not a full tree, but a partial tree created from a snapshot. */ export class PartialListCompositeTreeViewDU< - ElementType extends CompositeType, CompositeView, CompositeViewDU> + ElementType extends CompositeType, CompositeView, CompositeViewDU>, > extends ListCompositeTreeViewDU { private snapshot: Snapshot; @@ -63,7 +63,7 @@ export class PartialListCompositeTreeViewDU< throw new Error(`Cannot set index ${index} less than existing snapshot count ${this.snapshot.count}`); } - return super.set(index, view); + super.set(index, view); } getAllReadonly(): CompositeViewDU[] { @@ -115,8 +115,8 @@ export class PartialListCompositeTreeViewDU< // Commit before getting rootNode to ensure all pending data is in the rootNode this.commit(); - let newChunksNode; - let newLength; + let newChunksNode: Node; + let newLength: number; if (index >= this.length) { newChunksNode = zeroNode(this.type.chunkDepth); @@ -154,13 +154,11 @@ export class PartialListCompositeTreeViewDU< * Clone using rootNodeToViewDU() instead of getViewDU(). */ clone(dontTransferCache?: boolean): this { - if (dontTransferCache) { - return this.rootNodeToViewDU(this.node) as this; - } else { - const cache = this.cache; - this.clearCache(); - return this.rootNodeToViewDU(this.node, cache) as this; - } + if (dontTransferCache) return this.rootNodeToViewDU(this.node) as this; + + const cache = this.cache; + this.clearCache(); + return this.rootNodeToViewDU(this.node, cache) as this; } /** diff --git a/packages/ssz/src/viewDU/profile.ts b/packages/ssz/src/viewDU/profile.ts index d98e36d26..1f6de54f9 100644 --- a/packages/ssz/src/viewDU/profile.ts +++ b/packages/ssz/src/viewDU/profile.ts @@ -1,30 +1,28 @@ -import {getNodeAtDepth, LeafNode, Node, zeroNode} from "@chainsafe/persistent-merkle-tree"; +import {LeafNode, Node, getNodeAtDepth, zeroNode} from "@chainsafe/persistent-merkle-tree"; import {ByteViews, Type} from "../type/abstract.js"; import {BasicType, isBasicType} from "../type/basic.js"; import {CompositeType, isCompositeType} from "../type/composite.js"; -import {computeSerdesData, ContainerTypeGeneric} from "../view/profile.js"; -import {TreeViewDU} from "./abstract.js"; -import {BasicContainerTreeViewDU, ChangedNode} from "./container.js"; import {OptionalType} from "../type/optional.js"; import {BitArray} from "../value/bitArray.js"; - -/* eslint-disable @typescript-eslint/member-ordering */ +import {ContainerTypeGeneric, computeSerdesData} from "../view/profile.js"; +import {TreeViewDU} from "./abstract.js"; +import {BasicContainerTreeViewDU, ChangedNode} from "./container.js"; export type ViewDUValue> = T extends CompositeType ? // If composite, return view. MAY propagate changes updwards TVDU : // If basic, return struct value. Will NOT propagate changes upwards - T extends BasicType - ? V - : never; + T extends BasicType + ? V + : never; export type OptionalViewDUValue> = T extends CompositeType ? // If composite, return view. MAY propagate changes updwards TVDU | null | undefined : // If basic, return struct value. Will NOT propagate changes upwards - T extends BasicType - ? V | null | undefined - : never; + T extends BasicType + ? V | null | undefined + : never; export type FieldsViewDU>> = { [K in keyof Fields]: Fields[K] extends OptionalType ? OptionalViewDUValue : ViewDUValue; @@ -194,7 +192,6 @@ export function getProfileTreeViewDUClass> = T extends CompositeType ? // If composite, return view. MAY propagate changes updwards TVDU : // If basic, return struct value. Will NOT propagate changes upwards - T extends BasicType - ? V - : never; + T extends BasicType + ? V + : never; export type OptionalViewDUValue> = T extends CompositeType ? // If composite, return view. MAY propagate changes updwards TVDU | null | undefined : // If basic, return struct value. Will NOT propagate changes upwards - T extends BasicType - ? V | null | undefined - : never; + T extends BasicType + ? V | null | undefined + : never; export type FieldsViewDU>> = { [K in keyof Fields]: Fields[K] extends OptionalType ? OptionalViewDUValue : ViewDUValue; @@ -201,7 +199,6 @@ export function getContainerTreeViewDUClass { window.ssz = ssz; })(window); diff --git a/packages/ssz/test/lodestarTypes/allForks/sszTypes.ts b/packages/ssz/test/lodestarTypes/allForks/sszTypes.ts index 023d7bc86..84aebe8bf 100644 --- a/packages/ssz/test/lodestarTypes/allForks/sszTypes.ts +++ b/packages/ssz/test/lodestarTypes/allForks/sszTypes.ts @@ -1,8 +1,8 @@ -import {ssz as phase0} from "../phase0/index.js"; import {ssz as altair} from "../altair/index.js"; import {ssz as bellatrix} from "../bellatrix/index.js"; import {ssz as capella} from "../capella/index.js"; import {ssz as deneb} from "../deneb/index.js"; +import {ssz as phase0} from "../phase0/index.js"; /** * Index the ssz types that differ by fork diff --git a/packages/ssz/test/lodestarTypes/allForks/types.ts b/packages/ssz/test/lodestarTypes/allForks/types.ts index ec78694ee..c03cc15cc 100644 --- a/packages/ssz/test/lodestarTypes/allForks/types.ts +++ b/packages/ssz/test/lodestarTypes/allForks/types.ts @@ -1,15 +1,15 @@ -import {CompositeType, ContainerType, ValueOf, CompositeView, CompositeViewDU} from "../../../src/index.js"; -import {ts as phase0} from "../phase0/index.js"; +import {CompositeType, CompositeView, CompositeViewDU, ContainerType, ValueOf} from "../../../src/index.js"; import {ts as altair} from "../altair/index.js"; import {ts as bellatrix} from "../bellatrix/index.js"; import {ts as capella} from "../capella/index.js"; import {ts as deneb} from "../deneb/index.js"; +import {ts as phase0} from "../phase0/index.js"; -import {ssz as phase0Ssz} from "../phase0/index.js"; import {ssz as altairSsz} from "../altair/index.js"; import {ssz as bellatrixSsz} from "../bellatrix/index.js"; import {ssz as capellaSsz} from "../capella/index.js"; import {ssz as denebSsz} from "../deneb/index.js"; +import {ssz as phase0Ssz} from "../phase0/index.js"; // Re-export union types for types that are _known_ to differ @@ -149,7 +149,7 @@ export type AllForksExecution = { * phase0.BeaconState | altair.BeaconState | bellatrix.BeaconState * ``` */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any + type AllForksTypeOf> = CompositeType< ValueOf, CompositeView, diff --git a/packages/ssz/test/lodestarTypes/altair/sszTypes.ts b/packages/ssz/test/lodestarTypes/altair/sszTypes.ts index a4d4de793..5a1754fbd 100644 --- a/packages/ssz/test/lodestarTypes/altair/sszTypes.ts +++ b/packages/ssz/test/lodestarTypes/altair/sszTypes.ts @@ -5,7 +5,7 @@ import { ListCompositeType, VectorCompositeType, } from "../../../src/index.js"; -import {preset, FINALIZED_ROOT_DEPTH, NEXT_SYNC_COMMITTEE_DEPTH, SYNC_COMMITTEE_SUBNET_COUNT} from "../params.js"; +import {FINALIZED_ROOT_DEPTH, NEXT_SYNC_COMMITTEE_DEPTH, SYNC_COMMITTEE_SUBNET_COUNT, preset} from "../params.js"; const { SYNC_COMMITTEE_SIZE, HISTORICAL_ROOTS_LIMIT, diff --git a/packages/ssz/test/lodestarTypes/bellatrix/sszTypes.ts b/packages/ssz/test/lodestarTypes/bellatrix/sszTypes.ts index 1f90566ce..fb5a4a24a 100644 --- a/packages/ssz/test/lodestarTypes/bellatrix/sszTypes.ts +++ b/packages/ssz/test/lodestarTypes/bellatrix/sszTypes.ts @@ -1,8 +1,8 @@ import {ByteListType, ByteVectorType, ContainerType, ListCompositeType} from "../../../src/index.js"; +import {ssz as altairSsz} from "../altair/index.js"; import {preset} from "../params.js"; -import {ssz as primitiveSsz} from "../primitive/index.js"; import {ssz as phase0Ssz} from "../phase0/index.js"; -import {ssz as altairSsz} from "../altair/index.js"; +import {ssz as primitiveSsz} from "../primitive/index.js"; import {stringType} from "../utils/StringType.js"; const { BYTES_PER_LOGS_BLOOM, diff --git a/packages/ssz/test/lodestarTypes/capella/sszTypes.ts b/packages/ssz/test/lodestarTypes/capella/sszTypes.ts index 0d8840eed..83a080111 100644 --- a/packages/ssz/test/lodestarTypes/capella/sszTypes.ts +++ b/packages/ssz/test/lodestarTypes/capella/sszTypes.ts @@ -1,9 +1,9 @@ import {ContainerType, ListCompositeType, VectorCompositeType} from "../../../src/index.js"; -import {preset, BLOCK_BODY_EXECUTION_PAYLOAD_DEPTH as EXECUTION_PAYLOAD_DEPTH} from "../params.js"; -import {ssz as primitiveSsz} from "../primitive/index.js"; -import {ssz as phase0Ssz} from "../phase0/index.js"; import {ssz as altairSsz} from "../altair/index.js"; import {ssz as bellatrixSsz} from "../bellatrix/index.js"; +import {BLOCK_BODY_EXECUTION_PAYLOAD_DEPTH as EXECUTION_PAYLOAD_DEPTH, preset} from "../params.js"; +import {ssz as phase0Ssz} from "../phase0/index.js"; +import {ssz as primitiveSsz} from "../primitive/index.js"; const { HISTORICAL_ROOTS_LIMIT, MAX_WITHDRAWALS_PER_PAYLOAD, diff --git a/packages/ssz/test/lodestarTypes/deneb/sszTypes.ts b/packages/ssz/test/lodestarTypes/deneb/sszTypes.ts index 4fd26bc75..3ee82691a 100644 --- a/packages/ssz/test/lodestarTypes/deneb/sszTypes.ts +++ b/packages/ssz/test/lodestarTypes/deneb/sszTypes.ts @@ -1,15 +1,15 @@ -import {ContainerType, ListCompositeType, ByteVectorType, VectorCompositeType} from "../../../src/index.js"; +import {ByteVectorType, ContainerType, ListCompositeType, VectorCompositeType} from "../../../src/index.js"; +import {ssz as altairSsz} from "../altair/index.js"; +import {ssz as bellatrixSsz} from "../bellatrix/index.js"; +import {ssz as capellaSsz} from "../capella/index.js"; import { - preset, BYTES_PER_FIELD_ELEMENT, BLOCK_BODY_EXECUTION_PAYLOAD_DEPTH as EXECUTION_PAYLOAD_DEPTH, MAX_REQUEST_BLOCKS_DENEB, + preset, } from "../params.js"; -import {ssz as primitiveSsz} from "../primitive/index.js"; import {ssz as phase0Ssz} from "../phase0/index.js"; -import {ssz as altairSsz} from "../altair/index.js"; -import {ssz as bellatrixSsz} from "../bellatrix/index.js"; -import {ssz as capellaSsz} from "../capella/index.js"; +import {ssz as primitiveSsz} from "../primitive/index.js"; const { HISTORICAL_ROOTS_LIMIT, MAX_BLOB_COMMITMENTS_PER_BLOCK, diff --git a/packages/ssz/test/lodestarTypes/phase0/sszTypes.ts b/packages/ssz/test/lodestarTypes/phase0/sszTypes.ts index f1afe4d20..1156e64bd 100644 --- a/packages/ssz/test/lodestarTypes/phase0/sszTypes.ts +++ b/packages/ssz/test/lodestarTypes/phase0/sszTypes.ts @@ -10,11 +10,11 @@ import { import {ListUintNum64Type} from "../../../src/type/listUintNum64.js"; import {PartialListCompositeType} from "../../../src/type/partialListComposite.js"; import { - preset, - MAX_REQUEST_BLOCKS, + ATTESTATION_SUBNET_COUNT, DEPOSIT_CONTRACT_TREE_DEPTH, JUSTIFICATION_BITS_LENGTH, - ATTESTATION_SUBNET_COUNT, + MAX_REQUEST_BLOCKS, + preset, } from "../params.js"; import * as primitiveSsz from "../primitive/sszTypes.js"; import {ListValidatorType} from "./listValidator.js"; @@ -39,6 +39,7 @@ const { } = preset; const { + // biome-ignore lint/suspicious/noShadowRestrictedNames: It is required to use `Boolean` name as type Boolean, Bytes32, UintNum64, diff --git a/packages/ssz/test/lodestarTypes/phase0/validator.ts b/packages/ssz/test/lodestarTypes/phase0/validator.ts index 81b2b5a41..c14e93361 100644 --- a/packages/ssz/test/lodestarTypes/phase0/validator.ts +++ b/packages/ssz/test/lodestarTypes/phase0/validator.ts @@ -3,6 +3,7 @@ import {ContainerNodeStructType} from "../../../src/type/containerNodeStruct.js" import {ValueOfFields} from "../../../src/view/container.js"; import * as primitiveSsz from "../primitive/sszTypes.js"; +// biome-ignore lint/suspicious/noShadowRestrictedNames: It is required to use `Boolean` name as type const {Boolean, Bytes32, UintNum64, BLSPubkey, EpochInf} = primitiveSsz; // this is to work with uint32, see https://github.com/ChainSafe/ssz/blob/ssz-v0.15.1/packages/ssz/src/type/uint.ts @@ -115,7 +116,7 @@ export function validatorToChunkBytes( } function writeEpochInf(dataView: DataView, offset: number, value: number): number { - if (value === Infinity) { + if (value === Number.POSITIVE_INFINITY) { dataView.setUint32(offset, 0xffffffff, true); offset += UINT32_SIZE; dataView.setUint32(offset, 0xffffffff, true); diff --git a/packages/ssz/test/lodestarTypes/phase0/viewDU/listValidator.ts b/packages/ssz/test/lodestarTypes/phase0/viewDU/listValidator.ts index 16fbeb678..e4a4a2bc1 100644 --- a/packages/ssz/test/lodestarTypes/phase0/viewDU/listValidator.ts +++ b/packages/ssz/test/lodestarTypes/phase0/viewDU/listValidator.ts @@ -1,12 +1,12 @@ import {byteArrayIntoHashObject} from "@chainsafe/as-sha256"; import {HashComputationLevel, Node, digestNLevel, setNodesAtDepth} from "@chainsafe/persistent-merkle-tree"; +import {ByteViews} from "../../../../src/type/abstract.js"; import {ListCompositeType} from "../../../../src/type/listComposite.js"; import {ArrayCompositeTreeViewDUCache} from "../../../../src/viewDU/arrayComposite.js"; -import {ListCompositeTreeViewDU} from "../../../../src/viewDU/listComposite.js"; -import {ValidatorNodeStructType, ValidatorType, validatorToChunkBytes} from "../validator.js"; -import {ByteViews} from "../../../../src/type/abstract.js"; import {ContainerNodeStructTreeViewDU} from "../../../../src/viewDU/containerNodeStruct.js"; +import {ListCompositeTreeViewDU} from "../../../../src/viewDU/listComposite.js"; import {ValidatorIndex} from "../../primitive/types.js"; +import {ValidatorNodeStructType, ValidatorType, validatorToChunkBytes} from "../validator.js"; /** * hashtree has a MAX_SIZE of 1024 bytes = 32 chunks @@ -58,7 +58,8 @@ export class ListValidatorTreeViewDU extends ListCompositeTreeViewDU unknown convergeFactor: 0.2 / 100, }); - // eslint-disable-next-line no-console console.log(`${id.padEnd(longestId)} - ${bpi.toFixed(1)} bytes / instance`); } } diff --git a/packages/ssz/test/memory/hooks.test.ts b/packages/ssz/test/memory/hooks.test.ts index 8f6314759..5e5877456 100644 --- a/packages/ssz/test/memory/hooks.test.ts +++ b/packages/ssz/test/memory/hooks.test.ts @@ -11,8 +11,6 @@ import {testRunnerMemory} from "./testRunnerMemory.js"; // SignedBeaconBlockPhase0 struct - 210580.6 bytes / instance // SignedBeaconBlockPhase0 tree - 278512.7 bytes / instance -/* eslint-disable @typescript-eslint/explicit-function-return-type */ - const map = new Map(); function getClosureWithMap(i: number) { @@ -50,7 +48,6 @@ function testRunnerMemoryBpi(testCases: {getInstance: (bytes: number) => unknown convergeFactor: 0.2 / 100, }); - // eslint-disable-next-line no-console console.log(`${id.padEnd(longestId)} - ${bpi.toFixed(1)} bytes / instance`); } } diff --git a/packages/ssz/test/memory/index.ts b/packages/ssz/test/memory/index.ts index 855c10bf9..f5a428a73 100644 --- a/packages/ssz/test/memory/index.ts +++ b/packages/ssz/test/memory/index.ts @@ -1,4 +1,4 @@ -import {StringDecoder} from "string_decoder"; +import {StringDecoder} from "node:string_decoder"; const refs: any[] = []; const xs: number[] = []; @@ -9,28 +9,28 @@ const heapUsed: number[] = []; const rss: number[] = []; enum TestType { - EmptyObject, - ArrayOfNumbers, - BufferAlloc, - BufferFromString, - Uint8Array, - ArrayBuffer, - Number, + EmptyObject = 0, + ArrayOfNumbers = 1, + BufferAlloc = 2, + BufferFromString = 3, + Uint8Array = 4, + ArrayBuffer = 5, + Number = 6, // From Proto - FixedObject8, - FixedObject4, - FixedArray, - FixedObject4BigInt, - String32BytesHex, - NativeBinding32Bytes, - BlstPublicKey, - StringDecoder, - BigInt, - FinalizationRegistry, + FixedObject8 = 7, + FixedObject4 = 8, + FixedArray = 9, + FixedObject4BigInt = 10, + String32BytesHex = 11, + NativeBinding32Bytes = 12, + BlstPublicKey = 13, + StringDecoder = 14, + BigInt = 15, + FinalizationRegistry = 16, // Bitlist alternatives - BitListArrayOfBools, - BitListUint8Array, - BitListArrayOfBytes, + BitListArrayOfBools = 17, + BitListUint8Array = 18, + BitListArrayOfBytes = 19, } const testType = TestType.BitListUint8Array; @@ -211,7 +211,6 @@ for (let i = 0; i < 1e8; i++) { const heapUsedM = linearRegression(xs, heapUsed).m; const rssM = linearRegression(xs, rss).m; - // eslint-disable-next-line no-console console.log(i, {arrayBuffersM, externalM, heapTotalM, heapUsedM, rssM}); } } diff --git a/packages/ssz/test/memory/testRunnerMemory.ts b/packages/ssz/test/memory/testRunnerMemory.ts index 7aacfbd78..fde612d07 100644 --- a/packages/ssz/test/memory/testRunnerMemory.ts +++ b/packages/ssz/test/memory/testRunnerMemory.ts @@ -57,7 +57,7 @@ export async function testRunnerMemoryGc(opts: TestRunnerMemoryOpts): Prom usedMemoryArr.push(totalUsedMemoryDiff); const usedMemoryReg = linearRegression(xs, usedMemoryArr); - // eslint-disable-next-line no-console + console.log("totalUsedMemoryDiff", totalUsedMemoryDiff, usedMemoryReg); } } @@ -76,7 +76,7 @@ export function testRunnerMemory(opts: TestRunnerMemoryOpts): number { /** * Stop after creating `maxInstances` instances. */ - maxInstances = Infinity, + maxInstances = Number.POSITIVE_INFINITY, /** * How to compute the total memory usage. * Defaults to `heapUsed + external`. @@ -141,7 +141,6 @@ export function testRunnerMemory(opts: TestRunnerMemoryOpts): number { } if (logEachSample) { - // eslint-disable-next-line no-console console.log(i, memoryUsage.rss / maxRssBytes, {m}); } diff --git a/packages/ssz/test/memory/treeView.test.ts b/packages/ssz/test/memory/treeView.test.ts index 48a71fd58..14f7812dd 100644 --- a/packages/ssz/test/memory/treeView.test.ts +++ b/packages/ssz/test/memory/treeView.test.ts @@ -81,7 +81,6 @@ function testRunnerMemoryBpi(testCases: TestCase[]): void { convergeFactor: 0.2 / 100, }); - // eslint-disable-next-line no-console console.log(`${id.padEnd(longestId)} - ${bpi.toFixed(1)} bytes / instance`); } } diff --git a/packages/ssz/test/perf/bitlist.test.ts b/packages/ssz/test/perf/bitlist.test.ts index c0199c519..f1846c74b 100644 --- a/packages/ssz/test/perf/bitlist.test.ts +++ b/packages/ssz/test/perf/bitlist.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import {BitArray, BitListType} from "../../src/index.js"; // running zipIndexesCommitteeBits() on `bitLen: 2048, bitsSet: 2048` takes 50.904 us/op diff --git a/packages/ssz/test/perf/byType/listBasic.test.ts b/packages/ssz/test/perf/byType/listBasic.test.ts index c56dc97c2..81faf6a3b 100644 --- a/packages/ssz/test/perf/byType/listBasic.test.ts +++ b/packages/ssz/test/perf/byType/listBasic.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import {ListBasicType, UintNumberType} from "../../../src/index.js"; const byteType = new UintNumberType(1); diff --git a/packages/ssz/test/perf/byType/listComposite.test.ts b/packages/ssz/test/perf/byType/listComposite.test.ts index f9c7508d0..46fcba9fd 100644 --- a/packages/ssz/test/perf/byType/listComposite.test.ts +++ b/packages/ssz/test/perf/byType/listComposite.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import {ContainerNodeStructType, ContainerType, ListCompositeType, UintNumberType} from "../../../src/index.js"; const byteType = new UintNumberType(1); diff --git a/packages/ssz/test/perf/bytelist.test.ts b/packages/ssz/test/perf/bytelist.test.ts index 7a0f9e977..f518d8487 100644 --- a/packages/ssz/test/perf/bytelist.test.ts +++ b/packages/ssz/test/perf/bytelist.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import {ByteListType, ListBasicType, UintNumberType} from "../../src/index.js"; describe("ByteListType vs BasicListType", () => { diff --git a/packages/ssz/test/perf/cacheMutableRootStruct.test.ts b/packages/ssz/test/perf/cacheMutableRootStruct.test.ts index 7e1bacc2d..c8f2bc501 100644 --- a/packages/ssz/test/perf/cacheMutableRootStruct.test.ts +++ b/packages/ssz/test/perf/cacheMutableRootStruct.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import {BitVectorType, ContainerType, UintBigintType, ValueOf} from "../../src/index.js"; describe("cachePermanentRootStruct", () => { diff --git a/packages/ssz/test/perf/epochStatuses.test.ts b/packages/ssz/test/perf/epochStatuses.test.ts index f7117352a..fc4b14e72 100644 --- a/packages/ssz/test/perf/epochStatuses.test.ts +++ b/packages/ssz/test/perf/epochStatuses.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import {CompositeViewDU} from "../../src/index.js"; import {EpochParticipation} from "../lodestarTypes/altair/sszTypes.js"; import {fillArray, linspace} from "../utils/misc.js"; diff --git a/packages/ssz/test/perf/eth2/beaconBlock.test.ts b/packages/ssz/test/perf/eth2/beaconBlock.test.ts index 740792e4c..0964f3625 100644 --- a/packages/ssz/test/perf/eth2/beaconBlock.test.ts +++ b/packages/ssz/test/perf/eth2/beaconBlock.test.ts @@ -1,11 +1,11 @@ -import {describe, bench, setBenchOpts} from "@chainsafe/benchmark"; +import {bench, describe, setBenchOpts} from "@chainsafe/benchmark"; +import {BitArray, toHexString} from "../../../src/index.js"; import {ValueWithCachedPermanentRoot, symbolCachedPermanentRoot} from "../../../src/util/merkleize.js"; import {deneb, ssz} from "../../lodestarTypes/index.js"; import {preset} from "../../lodestarTypes/params.js"; -import {BitArray, toHexString} from "../../../src/index.js"; const {MAX_ATTESTATIONS, MAX_DEPOSITS, MAX_VOLUNTARY_EXITS, MAX_BLS_TO_EXECUTION_CHANGES} = preset; -describe("Benchmark BeaconBlock.hashTreeRoot()", function () { +describe("Benchmark BeaconBlock.hashTreeRoot()", () => { setBenchOpts({ minMs: 10_000, }); diff --git a/packages/ssz/test/perf/eth2/beaconState.test.ts b/packages/ssz/test/perf/eth2/beaconState.test.ts index 17953f799..4629005f8 100644 --- a/packages/ssz/test/perf/eth2/beaconState.test.ts +++ b/packages/ssz/test/perf/eth2/beaconState.test.ts @@ -1,7 +1,7 @@ -import {describe, bench, setBenchOpts} from "@chainsafe/benchmark"; -import {HashComputationLevel, executeHashComputations, HashComputationGroup} from "@chainsafe/persistent-merkle-tree"; -import {BeaconState} from "../../lodestarTypes/altair/sszTypes.js"; +import {bench, describe, setBenchOpts} from "@chainsafe/benchmark"; +import {HashComputationGroup, HashComputationLevel, executeHashComputations} from "@chainsafe/persistent-merkle-tree"; import {BitArray, CompositeViewDU, toHexString} from "../../../src/index.js"; +import {BeaconState} from "../../lodestarTypes/altair/sszTypes.js"; import {preset} from "../../lodestarTypes/params.js"; const {SLOTS_PER_HISTORICAL_ROOT, EPOCHS_PER_ETH1_VOTING_PERIOD, SLOTS_PER_EPOCH} = preset; @@ -17,7 +17,7 @@ const expectedRoot = "0xb0780ec0d44bff1ae8a351e98e37a9d8c3e28edb38c9d5a6312656e0 * cannot compute HashComputationGroup again. * Increasing number of validators could be OOM since we have to create BeaconState every time */ -describe(`BeaconState ViewDU partially modified tree vc=${vc} numModified=${numModified}`, function () { +describe(`BeaconState ViewDU partially modified tree vc=${vc} numModified=${numModified}`, () => { setBenchOpts({ minMs: 20_000, }); diff --git a/packages/ssz/test/perf/eth2/deserialize.test.ts b/packages/ssz/test/perf/eth2/deserialize.test.ts index a5835f1ff..f1f02d4e6 100644 --- a/packages/ssz/test/perf/eth2/deserialize.test.ts +++ b/packages/ssz/test/perf/eth2/deserialize.test.ts @@ -1,17 +1,17 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; +import {CompositeType, TreeViewDU, ValueOf, isCompositeType} from "../../../src/index.js"; +import * as sszAltair from "../../lodestarTypes/altair/sszTypes.js"; import {BeaconState} from "../../lodestarTypes/altair/types.js"; import * as sszPhase0 from "../../lodestarTypes/phase0/sszTypes.js"; -import * as sszAltair from "../../lodestarTypes/altair/sszTypes.js"; import { getAttestation, getOnce, getRandomState, getSignedAggregateAndProof, - getSyncCommitteeMessage, - getSignedContributionAndProof, getSignedBeaconBlockPhase0, + getSignedContributionAndProof, + getSyncCommitteeMessage, } from "../../utils/generateEth2Objs.js"; -import {CompositeType, isCompositeType, TreeViewDU, ValueOf} from "../../../src/index.js"; describe("Deserialize frequent eth2 objects", () => { benchDeserialize(sszPhase0.Attestation, getAttestation(0)); diff --git a/packages/ssz/test/perf/eth2/hashTreeRoot.test.ts b/packages/ssz/test/perf/eth2/hashTreeRoot.test.ts index 05c3b2fb8..3808e12be 100644 --- a/packages/ssz/test/perf/eth2/hashTreeRoot.test.ts +++ b/packages/ssz/test/perf/eth2/hashTreeRoot.test.ts @@ -1,29 +1,29 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {HashObject} from "@chainsafe/as-sha256"; +import {bench, describe} from "@chainsafe/benchmark"; import {HashComputationGroup, hasher, uint8ArrayToHashObject} from "@chainsafe/persistent-merkle-tree"; -import * as sszPhase0 from "../../lodestarTypes/phase0/sszTypes.js"; +import { + CompositeType, + CompositeView, + CompositeViewDU, + TreeView, + TreeViewDU, + ValueOf, + hash64, + isCompositeType, +} from "../../../src/index.js"; +import {CompositeTypeAny} from "../../../src/type/composite.js"; import * as sszAltair from "../../lodestarTypes/altair/sszTypes.js"; +import * as sszPhase0 from "../../lodestarTypes/phase0/sszTypes.js"; import { getAttestation, getOnce, getRandomState, getSignedAggregateAndProof, - getSyncCommitteeMessage, - getSignedContributionAndProof, getSignedBeaconBlockPhase0, + getSignedContributionAndProof, + getSyncCommitteeMessage, getValidator, } from "../../utils/generateEth2Objs.js"; -import { - CompositeType, - isCompositeType, - TreeView, - TreeViewDU, - ValueOf, - CompositeView, - CompositeViewDU, - hash64, -} from "../../../src/index.js"; -import {CompositeTypeAny} from "../../../src/type/composite.js"; -import {HashObject} from "@chainsafe/as-sha256"; describe("HashTreeRoot frequent eth2 objects", () => { benchHashTreeRoot(sszPhase0.Attestation, getAttestation(0)); diff --git a/packages/ssz/test/perf/eth2/validators.test.ts b/packages/ssz/test/perf/eth2/validators.test.ts index 571fa23c7..4f55e14ab 100644 --- a/packages/ssz/test/perf/eth2/validators.test.ts +++ b/packages/ssz/test/perf/eth2/validators.test.ts @@ -1,10 +1,10 @@ -import {describe, bench} from "@chainsafe/benchmark"; -import {Validator} from "../../lodestarTypes/phase0/types.js"; -import {ValidatorContainer, ValidatorNodeStruct, Validators} from "../../lodestarTypes/phase0/sszTypes.js"; +import {bench, describe} from "@chainsafe/benchmark"; import {BranchNodeStruct, CompositeViewDU, ContainerNodeStructTreeViewDU} from "../../../src/index.js"; -import {ValidatorIndex} from "../../lodestarTypes/types.js"; +import {ValidatorContainer, ValidatorNodeStruct, Validators} from "../../lodestarTypes/phase0/sszTypes.js"; +import {Validator} from "../../lodestarTypes/phase0/types.js"; import {ValidatorType} from "../../lodestarTypes/phase0/validator.js"; import {doBatchHashTreeRootValidators} from "../../lodestarTypes/phase0/viewDU/listValidator.js"; +import {ValidatorIndex} from "../../lodestarTypes/types.js"; const validatorStruct: Validator = { pubkey: Buffer.alloc(48, 0xdd), @@ -13,8 +13,8 @@ const validatorStruct: Validator = { slashed: false, activationEligibilityEpoch: 134530, activationEpoch: 134532, - exitEpoch: Infinity, - withdrawableEpoch: Infinity, + exitEpoch: Number.POSITIVE_INFINITY, + withdrawableEpoch: Number.POSITIVE_INFINITY, }; describe("Validator vs ValidatorLeafNodeStruct", () => { @@ -33,7 +33,9 @@ describe("Validator vs ValidatorLeafNodeStruct", () => { (treeBacked: CompositeViewDU, type: typeof ValidatorContainer) => unknown > = { get_exitEpoch: (tb) => tb.exitEpoch, - set_exitEpoch: (tb) => (tb.exitEpoch = 6435), + set_exitEpoch: (tb) => { + tb.exitEpoch = 6435; + }, get_pubkey: (tb) => tb.pubkey, hashTreeRoot: (tb) => tb.hashTreeRoot(), createProof: (tb) => tb.createProof([["exitEpoch"]]), diff --git a/packages/ssz/test/perf/iterate.test.ts b/packages/ssz/test/perf/iterate.test.ts index 47c193d33..113a0551f 100644 --- a/packages/ssz/test/perf/iterate.test.ts +++ b/packages/ssz/test/perf/iterate.test.ts @@ -1,4 +1,4 @@ -import {bench, setBenchOpts, describe} from "@chainsafe/benchmark"; +import {bench, describe, setBenchOpts} from "@chainsafe/benchmark"; import {ListBasicType, UintNumberType} from "../../src/index.js"; import {Validators} from "../lodestarTypes/phase0/sszTypes.js"; @@ -13,15 +13,14 @@ describe("iterate", () => { bench("Array - for of", () => { for (const a of arr) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const x = a.foo; + const _x = a.foo; } }); bench("Array - for(;;)", () => { for (let i = 0; i < arr.length; i++) { const a = arr[i]; - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const x = a.foo; + + const _x = a.foo; } }); }); @@ -55,7 +54,6 @@ describe("readonly values - iterator vs array", () => { }); }); -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type function createBalanceList(count: number) { const VALIDATOR_REGISTRY_LIMIT = 1099511627776; @@ -64,7 +62,6 @@ function createBalanceList(count: number) { return balancesList.toViewDU(balancesStruct); } -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type function createValidatorList(count: number) { const validatorsStruct = Array.from({length: count}, () => ({ pubkey: new Uint8Array(48), diff --git a/packages/ssz/test/perf/list.test.ts b/packages/ssz/test/perf/list.test.ts index 53ecdd65b..29a9fcba1 100644 --- a/packages/ssz/test/perf/list.test.ts +++ b/packages/ssz/test/perf/list.test.ts @@ -1,6 +1,6 @@ -import {LeafNode, subtreeFillToContents, Node} from "@chainsafe/persistent-merkle-tree"; -import {describe, bench} from "@chainsafe/benchmark"; -import {UintNumberType, ListBasicType} from "../../src/index.js"; +import {bench, describe} from "@chainsafe/benchmark"; +import {LeafNode, Node, subtreeFillToContents} from "@chainsafe/persistent-merkle-tree"; +import {ListBasicType, UintNumberType} from "../../src/index.js"; describe("list", () => { const numBalances = 250_000; @@ -50,7 +50,7 @@ describe("list", () => { }); }); -describe("subtreeFillToContents", function () { +describe("subtreeFillToContents", () => { const numBalances = 250_000; const tbBalances64 = createBalanceList(numBalances); @@ -82,7 +82,6 @@ describe("subtreeFillToContents", function () { }); }); -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type function createBalanceList(count: number) { const VALIDATOR_REGISTRY_LIMIT = 1099511627776; diff --git a/packages/ssz/test/perf/merkleize.test.ts b/packages/ssz/test/perf/merkleize.test.ts index 12864a960..cc623e69f 100644 --- a/packages/ssz/test/perf/merkleize.test.ts +++ b/packages/ssz/test/perf/merkleize.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import {merkleizeBlockArray, merkleizeBlocksBytes} from "@chainsafe/persistent-merkle-tree"; import {bitLength, merkleize} from "../../src/util/merkleize.js"; diff --git a/packages/ssz/test/perf/misc/math_floor.test.ts b/packages/ssz/test/perf/misc/math_floor.test.ts index 21fba4f36..cccc720af 100644 --- a/packages/ssz/test/perf/misc/math_floor.test.ts +++ b/packages/ssz/test/perf/misc/math_floor.test.ts @@ -1,4 +1,4 @@ -import {bench, setBenchOpts, describe} from "@chainsafe/benchmark"; +import {bench, describe, setBenchOpts} from "@chainsafe/benchmark"; describe("Math.floor hacks", () => { setBenchOpts({noThreshold: true}); diff --git a/packages/ssz/test/perf/misc/switch_if_cost.test.ts b/packages/ssz/test/perf/misc/switch_if_cost.test.ts index afb2924c5..34fb0e025 100644 --- a/packages/ssz/test/perf/misc/switch_if_cost.test.ts +++ b/packages/ssz/test/perf/misc/switch_if_cost.test.ts @@ -1,20 +1,20 @@ -import {bench, setBenchOpts, describe} from "@chainsafe/benchmark"; +import {bench, describe, setBenchOpts} from "@chainsafe/benchmark"; describe("big if vs obj", () => { setBenchOpts({noThreshold: true}); function fnIf(n: number): number { if (n === 0) return 0; - else if (n === 1) return 1; - else if (n === 2) return 2; - else if (n === 3) return 3; - else if (n === 4) return 4; - else if (n === 5) return 5; - else if (n === 6) return 6; - else if (n === 7) return 7; - else if (n === 8) return 8; - else if (n === 9) return 9; - else throw Error("bad n"); + if (n === 1) return 1; + if (n === 2) return 2; + if (n === 3) return 3; + if (n === 4) return 4; + if (n === 5) return 5; + if (n === 6) return 6; + if (n === 7) return 7; + if (n === 8) return 8; + if (n === 9) return 9; + throw Error("bad n"); } function fnSwitch(n: number): number { diff --git a/packages/ssz/test/perf/propertyGet.test.ts b/packages/ssz/test/perf/propertyGet.test.ts index ff0106af9..869ce8e76 100644 --- a/packages/ssz/test/perf/propertyGet.test.ts +++ b/packages/ssz/test/perf/propertyGet.test.ts @@ -1,5 +1,5 @@ -import {describe, bench} from "@chainsafe/benchmark"; -import {UintNumberType, ContainerType, VectorBasicType} from "../../src/index.js"; +import {bench, describe} from "@chainsafe/benchmark"; +import {ContainerType, UintNumberType, VectorBasicType} from "../../src/index.js"; describe("SSZ get property", () => { const Gwei = new UintNumberType(8); diff --git a/packages/ssz/test/perf/proxy.test.ts b/packages/ssz/test/perf/proxy.test.ts index d871256ff..c7025f30b 100644 --- a/packages/ssz/test/perf/proxy.test.ts +++ b/packages/ssz/test/perf/proxy.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; describe("Access object properties in generated objects", () => { const rawObject = { @@ -16,6 +16,7 @@ describe("Access object properties in generated objects", () => { class CustomObj {} for (const key in rawObject) { + if (!Object.hasOwn(rawObject, key)) continue; Object.defineProperty(CustomObj.prototype, key, { value: rawObject[key as keyof typeof rawObject] as unknown, writable: true, diff --git a/packages/ssz/test/perf/serdes.test.ts b/packages/ssz/test/perf/serdes.test.ts index dc2b5c48e..4afa33375 100644 --- a/packages/ssz/test/perf/serdes.test.ts +++ b/packages/ssz/test/perf/serdes.test.ts @@ -1,18 +1,18 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; import { - UintBigintType, + BitArray, BitListType, + ByteVectorType, CompositeType, ContainerType, ListBasicType, ListCompositeType, - VectorCompositeType, - ValueOf, TreeView, TreeViewDU, - BitArray, + UintBigintType, UintNumberType, - ByteVectorType, + ValueOf, + VectorCompositeType, } from "../../src/index.js"; import {ValidatorContainer, ValidatorNodeStruct} from "../lodestarTypes/phase0/sszTypes.js"; @@ -95,10 +95,9 @@ describe("SSZ (de)serialize", () => { type: T, getValue?: () => ValueOf ): void { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const struct = getValue ? getValue() : type.defaultValue(); const bytes = type.serialize(struct); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + const view = type.toView(struct); bench(`${id} binary -> struct`, () => { diff --git a/packages/ssz/test/perf/stateTransitionOps/processAttestations.test.ts b/packages/ssz/test/perf/stateTransitionOps/processAttestations.test.ts index ccf1d42fa..e088c3e93 100644 --- a/packages/ssz/test/perf/stateTransitionOps/processAttestations.test.ts +++ b/packages/ssz/test/perf/stateTransitionOps/processAttestations.test.ts @@ -1,6 +1,6 @@ -import {describe, bench, beforeAll} from "@chainsafe/benchmark"; +import {beforeAll, bench, describe} from "@chainsafe/benchmark"; import {MutableVector} from "@chainsafe/persistent-ts"; -import {ListBasicType, UintNumberType, CompositeViewDU} from "../../../src/index.js"; +import {CompositeViewDU, ListBasicType, UintNumberType} from "../../../src/index.js"; describe("processAttestations", () => { const vc = 250_000; diff --git a/packages/ssz/test/perf/tree.test.ts b/packages/ssz/test/perf/tree.test.ts index b79aca8eb..c64f6ffe1 100644 --- a/packages/ssz/test/perf/tree.test.ts +++ b/packages/ssz/test/perf/tree.test.ts @@ -1,4 +1,4 @@ -import {describe, bench} from "@chainsafe/benchmark"; +import {bench, describe} from "@chainsafe/benchmark"; describe("tree", () => { const n = 4264957196; diff --git a/packages/ssz/test/perf/uint.test.ts b/packages/ssz/test/perf/uint.test.ts index d028d7b1c..302bca45a 100644 --- a/packages/ssz/test/perf/uint.test.ts +++ b/packages/ssz/test/perf/uint.test.ts @@ -1,5 +1,5 @@ -import {describe, bench} from "@chainsafe/benchmark"; -import {ContainerType, UintNumberType, UintBigintType} from "../../src/index.js"; +import {bench, describe} from "@chainsafe/benchmark"; +import {ContainerType, UintBigintType, UintNumberType} from "../../src/index.js"; describe("Uint64 types", () => { const ContainerNumber = new ContainerType({ diff --git a/packages/ssz/test/perf/uintFromBytes.test.ts b/packages/ssz/test/perf/uintFromBytes.test.ts index 4ec0bc687..f910b39e7 100644 --- a/packages/ssz/test/perf/uintFromBytes.test.ts +++ b/packages/ssz/test/perf/uintFromBytes.test.ts @@ -1,6 +1,6 @@ +import {beforeAll, bench, describe} from "@chainsafe/benchmark"; import {LeafNode} from "@chainsafe/persistent-merkle-tree"; -import {describe, bench, beforeAll} from "@chainsafe/benchmark"; -import {UintNumberType, UintBigintType, uintNumberByteLens, uintBigintByteLens} from "../../src/type/uint.js"; +import {UintBigintType, UintNumberType, uintBigintByteLens, uintNumberByteLens} from "../../src/type/uint.js"; const POW_32 = 2 ** 32; diff --git a/packages/ssz/test/spec/downloadTests.ts b/packages/ssz/test/spec/downloadTests.ts index 09a4a9669..6d3b207a7 100644 --- a/packages/ssz/test/spec/downloadTests.ts +++ b/packages/ssz/test/spec/downloadTests.ts @@ -1,8 +1,6 @@ import {downloadTests} from "@lodestar/spec-test-util/downloadTests"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; -/* eslint-disable no-console */ - for (const downloadTestOpts of [ethereumConsensusSpecsTests]) { downloadTests(downloadTestOpts, console.log).catch((e: Error) => { console.error(e); diff --git a/packages/ssz/test/spec/eip-4881/eip4881.test.ts b/packages/ssz/test/spec/eip-4881/eip4881.test.ts index e002b1490..a417d49c3 100644 --- a/packages/ssz/test/spec/eip-4881/eip4881.test.ts +++ b/packages/ssz/test/spec/eip-4881/eip4881.test.ts @@ -1,12 +1,12 @@ import fs from "node:fs"; -import url from "node:url"; import path from "node:path"; +import url from "node:url"; import jsyaml from "js-yaml"; -import {describe, it, expect, vi} from "vitest"; +import {describe, expect, it, vi} from "vitest"; import {ContainerType, ListCompositeType} from "../../../src/index.js"; +import {ListCompositeTreeViewDU} from "../../../src/viewDU/listComposite.js"; import {ssz} from "../../lodestarTypes/index.js"; import {DepositDataRootFullList, DepositDataRootPartialList} from "../../lodestarTypes/phase0/sszTypes.js"; -import {ListCompositeTreeViewDU} from "../../../src/viewDU/listComposite.js"; const EIP4881TestDataArrayItem = new ContainerType( { diff --git a/packages/ssz/test/spec/generic/index.test.ts b/packages/ssz/test/spec/generic/index.test.ts index 4a4cbe6c4..7aad49f6d 100644 --- a/packages/ssz/test/spec/generic/index.test.ts +++ b/packages/ssz/test/spec/generic/index.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect} from "vitest"; -import path from "node:path"; import fs from "node:fs"; +import path from "node:path"; +import {describe, expect, it} from "vitest"; import {ethereumConsensusSpecsTests} from "../../specTestVersioning.js"; -import {parseSszGenericValidTestcase, parseSszGenericInvalidTestcase} from "../testRunner.js"; import {runValidSszTest} from "../runValidTest.js"; +import {parseSszGenericInvalidTestcase, parseSszGenericValidTestcase} from "../testRunner.js"; import {getTestType} from "./types.js"; const rootGenericSszPath = path.join( @@ -35,7 +35,6 @@ for (const testType of fs.readdirSync(rootGenericSszPath)) { const type = getTestType(testType, invalidCase); const testData = parseSszGenericInvalidTestcase(path.join(invalidCasesPath, invalidCase)); - /* eslint-disable no-console */ if (process.env.DEBUG) { console.log({serialized: Buffer.from(testData.serialized).toString("hex")}); } diff --git a/packages/ssz/test/spec/generic/types.ts b/packages/ssz/test/spec/generic/types.ts index 74e6684e1..fbf98e23d 100644 --- a/packages/ssz/test/spec/generic/types.ts +++ b/packages/ssz/test/spec/generic/types.ts @@ -1,12 +1,12 @@ import { - Type, - BooleanType, - UintBigintType, - UintNumberType, - BitVectorType, BitListType, + BitVectorType, + BooleanType, ContainerType, ListBasicType, + Type, + UintBigintType, + UintNumberType, VectorBasicType, VectorCompositeType, } from "../../../src/index.js"; @@ -21,8 +21,6 @@ const uint64 = new UintBigintType(8); const uint128 = new UintBigintType(16); const uint256 = new UintBigintType(32); -/* eslint-disable @typescript-eslint/naming-convention */ - // class SingleFieldTestStruct(Container): // A: byte const SingleFieldTestStruct = new ContainerType({ @@ -118,8 +116,8 @@ export function getTestType(testType: string, testCase: string): Type { const [, elementTypeStr, lengthStr] = match || []; const elementType = vecElementTypes[elementTypeStr as keyof typeof vecElementTypes]; if (elementType === undefined) throw Error(`No vecElementType for ${elementTypeStr}: '${testCase}'`); - const length = parseInt(lengthStr); - if (isNaN(length)) throw Error(`Bad length ${length}: '${testCase}'`); + const length = Number.parseInt(lengthStr); + if (Number.isNaN(length)) throw Error(`Bad length ${length}: '${testCase}'`); return new VectorBasicType(elementType, length); } @@ -170,7 +168,7 @@ export function getTestType(testType: string, testCase: string): Type { */ function parseSecondNum(str: string, id: string): number { const match = str.match(/[^\W_]+_([0-9]+)/); - const num = parseInt((match || [])[1]); - if (isNaN(num)) throw Error(`Bad ${id} ${str}`); + const num = Number.parseInt((match || [])[1]); + if (Number.isNaN(num)) throw Error(`Bad ${id} ${str}`); return num; } diff --git a/packages/ssz/test/spec/replaceUintTypeWithUintBigintType.ts b/packages/ssz/test/spec/replaceUintTypeWithUintBigintType.ts index 2fd098088..dec7904b6 100644 --- a/packages/ssz/test/spec/replaceUintTypeWithUintBigintType.ts +++ b/packages/ssz/test/spec/replaceUintTypeWithUintBigintType.ts @@ -1,19 +1,16 @@ -/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment -, @typescript-eslint/no-explicit-any */ - // ####################################### // # MUST NOT IMPORT FROM @chainsafe/ssz # // ####################################### import { - Type, - UintNumberType, - UintBigintType, + ContainerNodeStructType, ContainerType, ListBasicType, ListCompositeType, + Type, + UintBigintType, + UintNumberType, VectorBasicType, VectorCompositeType, - ContainerNodeStructType, } from "../../src/index.js"; /** @@ -35,9 +32,8 @@ export function replaceUintTypeWithUintBigintType>(type: T): if (type instanceof ContainerNodeStructType) { return new ContainerNodeStructType(fields, type.opts) as unknown as T; - } else { - return new ContainerType(fields, type.opts) as unknown as T; } + return new ContainerType(fields, type.opts) as unknown as T; } // For List or vectors replace the subType diff --git a/packages/ssz/test/spec/runValidTest.ts b/packages/ssz/test/spec/runValidTest.ts index d91006f54..2fe93fefb 100644 --- a/packages/ssz/test/spec/runValidTest.ts +++ b/packages/ssz/test/spec/runValidTest.ts @@ -1,11 +1,11 @@ -import {expect} from "vitest"; import {LeafNode, Node} from "@chainsafe/persistent-merkle-tree"; +import {expect} from "vitest"; +import {TreeViewDU} from "../../src/index.js"; import {Type} from "../../src/type/abstract.js"; -import {fromHexString, toHexString} from "../../src/util/byteArray.js"; -import {CompositeType, isCompositeType} from "../../src/type/composite.js"; import {isBasicType} from "../../src/type/basic.js"; +import {CompositeType, isCompositeType} from "../../src/type/composite.js"; +import {fromHexString, toHexString} from "../../src/util/byteArray.js"; import {wrapErr} from "../utils/error.js"; -import {TreeViewDU} from "../../src/index.js"; type ValidTestCaseData = { root: string; @@ -13,8 +13,6 @@ type ValidTestCaseData = { jsonValue: unknown; }; -/* eslint-disable no-console */ - export function runValidSszTest(type: Type, testData: ValidTestCaseData): {node: Node; json: unknown} { const testDataRootHex = testData.root; const testDataSerialized = @@ -26,7 +24,7 @@ export function runValidSszTest(type: Type, testData: ValidTestCaseData console.log( JSON.stringify( testData.jsonValue, - (key, value: unknown) => (typeof value === "bigint" ? value.toString() : value), + (_key, value: unknown) => (typeof value === "bigint" ? value.toString() : value), 2 ) ); @@ -103,6 +101,7 @@ export function runValidSszTest(type: Type, testData: ValidTestCaseData if (type.isBasic) { console.log("Chunk Bytes Basic", toHexString(type.serialize(testDataValue))); } else { + // biome-ignore lint/complexity/useLiteralKeys: The function `getBlocksBytes` is private const blocksBytes = (type as CompositeType)["getBlocksBytes"](testDataValue); console.log("Blocks Bytes Composite", toHexString(blocksBytes)); } @@ -121,9 +120,8 @@ export function runValidSszTest(type: Type, testData: ValidTestCaseData const viewDU = type.getViewDU(node); if (viewDU instanceof TreeViewDU) { return viewDU.batchHashTreeRoot(); - } else { - return type.hashTreeRoot(testDataValue); } + return type.hashTreeRoot(testDataValue); }, "type.hashTreeRoot()"); assertRoot(root, "ViewDU.batchHashTreeRoot()"); } @@ -215,9 +213,8 @@ function copy(buf: Uint8Array): Uint8Array { export function toJsonOrString(value: unknown): unknown { if (typeof value === "number" || typeof value === "bigint") { return value.toString(10); - } else { - return value; } + return value; } function renderTree(node: Node): void { diff --git a/packages/ssz/test/spec/sszYamlSchema.ts b/packages/ssz/test/spec/sszYamlSchema.ts index 73644e5db..f7bd1f04c 100644 --- a/packages/ssz/test/spec/sszYamlSchema.ts +++ b/packages/ssz/test/spec/sszYamlSchema.ts @@ -7,13 +7,12 @@ import jsYaml from "js-yaml"; const {Schema} = jsYaml; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import nullType from "js-yaml/lib/js-yaml/type/null.js"; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore import boolType from "js-yaml/lib/js-yaml/type/bool.js"; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore import floatType from "js-yaml/lib/js-yaml/type/float.js"; // Forked from https://github.com/nodeca/js-yaml/blob/master/lib/js-yaml/type/int.js @@ -43,7 +42,7 @@ function resolveYamlInteger(data: string): boolean { if (data === null) return false; const max = data.length; - let ch, + let ch: string, index = 0, hasDigits = false; @@ -127,7 +126,7 @@ function resolveYamlInteger(data: string): boolean { function constructYamlInteger(data: string): bigint { let value: string | bigint = data, sign = 1, - ch, + ch: string, base: number | bigint; const digits: number[] = []; @@ -152,7 +151,7 @@ function constructYamlInteger(data: string): bigint { if (value.indexOf(":") !== -1) { for (const v of value.split(":")) { - digits.unshift(parseInt(v, 10)); + digits.unshift(Number.parseInt(v, 10)); } value = BigInt(0); base = BigInt(1); @@ -178,25 +177,24 @@ const intType = new Type("tag:yaml.org,2002:int", { construct: constructYamlInteger, predicate: isInteger, instanceOf: BigInt, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore represent: { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore binary: function binary(obj: number) { return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1); }, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore octal: function octal(obj: number) { return obj >= 0 ? "0" + obj.toString(8) : "-0" + obj.toString(8).slice(1); }, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore decimal: function decimal(obj: number) { return obj.toString(10); }, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore hexadecimal: function hexadecimal(obj: number) { return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1); diff --git a/packages/ssz/test/spec/ssz_static.ts b/packages/ssz/test/spec/ssz_static.ts index b291589c1..aadcce2d8 100644 --- a/packages/ssz/test/spec/ssz_static.ts +++ b/packages/ssz/test/spec/ssz_static.ts @@ -1,15 +1,15 @@ import fs from "node:fs"; import path from "node:path"; import {describe, it, vi} from "vitest"; -import {isCompositeType, Type} from "../../src/index.js"; +import {Type, isCompositeType} from "../../src/index.js"; import {ssz} from "../lodestarTypes/index.js"; +import {ACTIVE_PRESET} from "../lodestarTypes/params.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; +import {runProofTestOnAllJsonPaths} from "../unit/byType/runTypeProofTest.js"; +import {ForkName} from "../utils/fork.js"; import {replaceUintTypeWithUintBigintType} from "./replaceUintTypeWithUintBigintType.js"; -import {parseSszStaticTestcase} from "./testRunner.js"; import {runValidSszTest} from "./runValidTest.js"; -import {ForkName} from "../utils/fork.js"; -import {ACTIVE_PRESET} from "../lodestarTypes/params.js"; -import {runProofTestOnAllJsonPaths} from "../unit/byType/runTypeProofTest.js"; +import {parseSszStaticTestcase} from "./testRunner.js"; // ssz_static // | Attestation @@ -20,15 +20,6 @@ import {runProofTestOnAllJsonPaths} from "../unit/byType/runTypeProofTest.js"; // // Docs: https://github.com/ethereum/consensus-specs/blob/master/tests/formats/ssz_static/core.md -/* eslint-disable - @typescript-eslint/naming-convention, - @typescript-eslint/no-unsafe-assignment, - @typescript-eslint/no-unsafe-call, - @typescript-eslint/no-unsafe-member-access, - no-console -*/ - -// eslint-disable-next-line type Types = Record>; export function sszStatic(fork: ForkName): void { @@ -59,7 +50,7 @@ function testStatic(typeName: string, sszType: Type, forkName: ForkName continue; } - it(testId, function () { + it(testId, () => { // Mainnet must deal with big full states and hash each one multiple times if (preset === "mainnet") { vi.setConfig({testTimeout: 30 * 1000}); diff --git a/packages/ssz/test/spec/testRunner.ts b/packages/ssz/test/spec/testRunner.ts index e5f2a527f..117cdfb09 100644 --- a/packages/ssz/test/spec/testRunner.ts +++ b/packages/ssz/test/spec/testRunner.ts @@ -1,14 +1,9 @@ -import path from "node:path"; import fs from "node:fs"; -import {uncompress} from "snappyjs"; +import path from "node:path"; import jsyaml from "js-yaml"; +import {uncompress} from "snappyjs"; import {schema} from "./sszYamlSchema.js"; -/* eslint-disable - @typescript-eslint/explicit-module-boundary-types, - @typescript-eslint/explicit-function-return-type -*/ - export type ValidTestCaseData = { root: string; serialized: Uint8Array; diff --git a/packages/ssz/test/specTestVersioning.ts b/packages/ssz/test/specTestVersioning.ts index b9c564dcf..9ba028834 100644 --- a/packages/ssz/test/specTestVersioning.ts +++ b/packages/ssz/test/specTestVersioning.ts @@ -1,5 +1,5 @@ import path from "node:path"; -import url from "url"; +import url from "node:url"; import {DownloadTestsOptions} from "@lodestar/spec-test-util/downloadTests"; // WARNING! Don't move or rename this file !!! diff --git a/packages/ssz/test/unit/byType/bitArray/tree.test.ts b/packages/ssz/test/unit/byType/bitArray/tree.test.ts index 5dad8e69d..d7821ac88 100644 --- a/packages/ssz/test/unit/byType/bitArray/tree.test.ts +++ b/packages/ssz/test/unit/byType/bitArray/tree.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {BitVectorType, BitListType, BitArray} from "../../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {BitArray, BitListType, BitVectorType} from "../../../../src/index.js"; import {runViewTestMutation} from "../runViewTestMutation.js"; for (const type of [new BitVectorType(4), new BitListType(4)]) { diff --git a/packages/ssz/test/unit/byType/bitList/invalid.test.ts b/packages/ssz/test/unit/byType/bitList/invalid.test.ts index e8d3f62d4..85a1875f6 100644 --- a/packages/ssz/test/unit/byType/bitList/invalid.test.ts +++ b/packages/ssz/test/unit/byType/bitList/invalid.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {BitListType} from "../../../../src/index.js"; import {runTypeTestInvalid} from "../runTypeTestInvalid.js"; diff --git a/packages/ssz/test/unit/byType/bitList/valid.test.ts b/packages/ssz/test/unit/byType/bitList/valid.test.ts index ca17b1f71..0721e2b84 100644 --- a/packages/ssz/test/unit/byType/bitList/valid.test.ts +++ b/packages/ssz/test/unit/byType/bitList/valid.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {BitListType, BitArray, toHexString} from "../../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {BitArray, BitListType, toHexString} from "../../../../src/index.js"; import {runTypeTestValid} from "../runTypeTestValid.js"; runTypeTestValid({ diff --git a/packages/ssz/test/unit/byType/bitVector/invalid.test.ts b/packages/ssz/test/unit/byType/bitVector/invalid.test.ts index 0b8aa1e59..1d1329b6a 100644 --- a/packages/ssz/test/unit/byType/bitVector/invalid.test.ts +++ b/packages/ssz/test/unit/byType/bitVector/invalid.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {BitVectorType} from "../../../../src/index.js"; import {runTypeTestInvalid} from "../runTypeTestInvalid.js"; diff --git a/packages/ssz/test/unit/byType/bitVector/tree.test.ts b/packages/ssz/test/unit/byType/bitVector/tree.test.ts index ae060a07a..69ae1e9ef 100644 --- a/packages/ssz/test/unit/byType/bitVector/tree.test.ts +++ b/packages/ssz/test/unit/byType/bitVector/tree.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {BitVectorType, BitArray} from "../../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {BitArray, BitVectorType} from "../../../../src/index.js"; import {runViewTestMutation} from "../runViewTestMutation.js"; runViewTestMutation({ diff --git a/packages/ssz/test/unit/byType/bitVector/valid.test.ts b/packages/ssz/test/unit/byType/bitVector/valid.test.ts index 0c39da479..f03f769fb 100644 --- a/packages/ssz/test/unit/byType/bitVector/valid.test.ts +++ b/packages/ssz/test/unit/byType/bitVector/valid.test.ts @@ -1,4 +1,4 @@ -import {BitVectorType, BitArray} from "../../../../src/index.js"; +import {BitArray, BitVectorType} from "../../../../src/index.js"; import {runTypeTestValid} from "../runTypeTestValid.js"; runTypeTestValid({ diff --git a/packages/ssz/test/unit/byType/boolean/tree.test.ts b/packages/ssz/test/unit/byType/boolean/tree.test.ts index f36f07049..1426ba74e 100644 --- a/packages/ssz/test/unit/byType/boolean/tree.test.ts +++ b/packages/ssz/test/unit/byType/boolean/tree.test.ts @@ -1,7 +1,7 @@ import {LeafNode} from "@chainsafe/persistent-merkle-tree"; -import {describe, it, expect} from "vitest"; -import {toHexString} from "../../../../src/util/byteArray.js"; +import {describe, expect, it} from "vitest"; import {BooleanType} from "../../../../src/index.js"; +import {toHexString} from "../../../../src/util/byteArray.js"; describe("BooleanType / tree", () => { const booleanType = new BooleanType(); diff --git a/packages/ssz/test/unit/byType/byteList/invalid.test.ts b/packages/ssz/test/unit/byType/byteList/invalid.test.ts index 1ca08e5cb..39e558e14 100644 --- a/packages/ssz/test/unit/byType/byteList/invalid.test.ts +++ b/packages/ssz/test/unit/byType/byteList/invalid.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ByteListType} from "../../../../src/index.js"; import {runTypeTestInvalid} from "../runTypeTestInvalid.js"; diff --git a/packages/ssz/test/unit/byType/byteList/valid.test.ts b/packages/ssz/test/unit/byType/byteList/valid.test.ts index 89cbf89e6..36c498f24 100644 --- a/packages/ssz/test/unit/byType/byteList/valid.test.ts +++ b/packages/ssz/test/unit/byType/byteList/valid.test.ts @@ -1,5 +1,5 @@ -import {ListBasicType, ByteListType, fromHexString, UintNumberType} from "../../../../src/index.js"; -import {runTypeTestValid, TypeTestValid} from "../runTypeTestValid.js"; +import {ByteListType, ListBasicType, UintNumberType, fromHexString} from "../../../../src/index.js"; +import {TypeTestValid, runTypeTestValid} from "../runTypeTestValid.js"; runTypeTestValid({ type: new ByteListType(256), diff --git a/packages/ssz/test/unit/byType/byteList/value.test.ts b/packages/ssz/test/unit/byType/byteList/value.test.ts index 7f76fae7b..2aaff9f0d 100644 --- a/packages/ssz/test/unit/byType/byteList/value.test.ts +++ b/packages/ssz/test/unit/byType/byteList/value.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ByteListType} from "../../../../src/index.js"; describe("ByteListValue", () => { diff --git a/packages/ssz/test/unit/byType/byteVector/invalid.test.ts b/packages/ssz/test/unit/byType/byteVector/invalid.test.ts index 26b6cfc79..7d624a8ef 100644 --- a/packages/ssz/test/unit/byType/byteVector/invalid.test.ts +++ b/packages/ssz/test/unit/byType/byteVector/invalid.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ByteVectorType} from "../../../../src/index.js"; import {runTypeTestInvalid} from "../runTypeTestInvalid.js"; diff --git a/packages/ssz/test/unit/byType/byteVector/tree.test.ts b/packages/ssz/test/unit/byType/byteVector/tree.test.ts index 3b15025e4..83c4cfb94 100644 --- a/packages/ssz/test/unit/byType/byteVector/tree.test.ts +++ b/packages/ssz/test/unit/byType/byteVector/tree.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ByteVectorType, ContainerType} from "../../../../src/index.js"; describe("ByteVectorType proofs", () => { diff --git a/packages/ssz/test/unit/byType/composite/tree.test.ts b/packages/ssz/test/unit/byType/composite/tree.test.ts index c69203d58..f9147abf2 100644 --- a/packages/ssz/test/unit/byType/composite/tree.test.ts +++ b/packages/ssz/test/unit/byType/composite/tree.test.ts @@ -1,16 +1,16 @@ import { + BitArray, + BitVectorType, BooleanType, + ByteVectorType, ContainerType, - UintNumberType, - UintBigintType, ListBasicType, - ByteVectorType, - UnionType, NoneType, - BitVectorType, - BitArray, + UintBigintType, + UintNumberType, + UnionType, } from "../../../../src/index.js"; -import {uintNumberByteLens, uintBigintByteLens} from "../../../../src/type/uint.js"; +import {uintBigintByteLens, uintNumberByteLens} from "../../../../src/type/uint.js"; import {runViewTestCompositeSwap} from "../runViewTestCompositeSwap.js"; // Swap properties tests. Because swaping uses the same property names you can write many more tests @@ -32,7 +32,7 @@ for (const byteLen of uintBigintByteLens) { // Special case for Uint64Inf const uint64NumInfType = new UintNumberType(8, {clipInfinity: true}); runViewTestCompositeSwap(uint64NumInfType, 1, 2); -runViewTestCompositeSwap(uint64NumInfType, 1, Infinity); +runViewTestCompositeSwap(uint64NumInfType, 1, Number.POSITIVE_INFINITY); for (const bytes of [32, 48, 96]) { runViewTestCompositeSwap(new ByteVectorType(bytes), Buffer.alloc(bytes, 1), Buffer.alloc(bytes, 2)); diff --git a/packages/ssz/test/unit/byType/container/invalid.test.ts b/packages/ssz/test/unit/byType/container/invalid.test.ts index 07b2fc3b2..ab9b4a41c 100644 --- a/packages/ssz/test/unit/byType/container/invalid.test.ts +++ b/packages/ssz/test/unit/byType/container/invalid.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ContainerNodeStructType, ContainerType, ListBasicType, UintNumberType} from "../../../../src/index.js"; import {byteType, uint16NumType} from "../../../utils/primitiveTypes.js"; import {runTypeTestInvalid} from "../runTypeTestInvalid.js"; diff --git a/packages/ssz/test/unit/byType/container/tree.test.ts b/packages/ssz/test/unit/byType/container/tree.test.ts index d60087e59..d2bbbd906 100644 --- a/packages/ssz/test/unit/byType/container/tree.test.ts +++ b/packages/ssz/test/unit/byType/container/tree.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { BitArray, BitListType, @@ -11,12 +11,12 @@ import { ListBasicType, ListCompositeType, NoneType, - toHexString, UintNumberType, UnionType, ValueOf, VectorBasicType, VectorCompositeType, + toHexString, } from "../../../../src/index.js"; import {uint64NumInfType, uint64NumType} from "../../../utils/primitiveTypes.js"; import {runViewTestMutation} from "../runViewTestMutation.js"; @@ -227,7 +227,7 @@ runViewTestMutation({ ], }); -describe("ContainerViewDU batchHashTreeRoot", function () { +describe("ContainerViewDU batchHashTreeRoot", () => { const childContainerType = new ContainerType({f0: uint64NumInfType, f1: uint64NumInfType}); const unionType = new UnionType([new NoneType(), uint64NumType]); const listBasicType = new ListBasicType(uint64NumType, 10); @@ -590,7 +590,7 @@ describe("ContainerViewDU batchHashTreeRoot", function () { }); }); -describe("ContainerNodeStruct batchHashTreeRoot", function () { +describe("ContainerNodeStruct batchHashTreeRoot", () => { const EpochInf = new UintNumberType(8, {clipInfinity: true}); // Ethereum consensus validator type diff --git a/packages/ssz/test/unit/byType/container/valid.test.ts b/packages/ssz/test/unit/byType/container/valid.test.ts index 8436a8d2d..2457512d6 100644 --- a/packages/ssz/test/unit/byType/container/valid.test.ts +++ b/packages/ssz/test/unit/byType/container/valid.test.ts @@ -1,6 +1,6 @@ -import {ContainerType, ContainerNodeStructType, ListBasicType, ByteVectorType} from "../../../../src/index.js"; -import {ssz} from "../../../lodestarTypes/index.js"; +import {ByteVectorType, ContainerNodeStructType, ContainerType, ListBasicType} from "../../../../src/index.js"; import {SignedContributionAndProof} from "../../../lodestarTypes/altair/sszTypes.js"; +import {ssz} from "../../../lodestarTypes/index.js"; import {replaceUintTypeWithUintBigintType} from "../../../spec/replaceUintTypeWithUintBigintType.js"; import {uint64NumInfType} from "../../../utils/primitiveTypes.js"; import {runTypeTestValid} from "../runTypeTestValid.js"; diff --git a/packages/ssz/test/unit/byType/listBasic/invalid.test.ts b/packages/ssz/test/unit/byType/listBasic/invalid.test.ts index 7d76eaf5f..cba9216af 100644 --- a/packages/ssz/test/unit/byType/listBasic/invalid.test.ts +++ b/packages/ssz/test/unit/byType/listBasic/invalid.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ListBasicType} from "../../../../src/index.js"; import {byteType} from "../../../utils/primitiveTypes.js"; import {runTypeTestInvalid} from "../runTypeTestInvalid.js"; diff --git a/packages/ssz/test/unit/byType/listBasic/misc.test.ts b/packages/ssz/test/unit/byType/listBasic/misc.test.ts index cb81a8bdc..f5c4ee3ee 100644 --- a/packages/ssz/test/unit/byType/listBasic/misc.test.ts +++ b/packages/ssz/test/unit/byType/listBasic/misc.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ListBasicType, UintNumberType} from "../../../../src/index.js"; describe("To hit 100% coverage", () => { diff --git a/packages/ssz/test/unit/byType/listBasic/mutation.test.ts b/packages/ssz/test/unit/byType/listBasic/mutation.test.ts index b590efdf7..ca1c77d98 100644 --- a/packages/ssz/test/unit/byType/listBasic/mutation.test.ts +++ b/packages/ssz/test/unit/byType/listBasic/mutation.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ListBasicType, UintNumberType} from "../../../../src/index.js"; describe("BasicList", () => { diff --git a/packages/ssz/test/unit/byType/listBasic/tree.test.ts b/packages/ssz/test/unit/byType/listBasic/tree.test.ts index b5d6c0dba..de487dc38 100644 --- a/packages/ssz/test/unit/byType/listBasic/tree.test.ts +++ b/packages/ssz/test/unit/byType/listBasic/tree.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; -import {ListBasicType, toHexString, UintNumberType} from "../../../../src/index.js"; -import {runViewTestMutation, TreeMutation} from "../runViewTestMutation.js"; +import {describe, expect, it} from "vitest"; +import {ListBasicType, UintNumberType, toHexString} from "../../../../src/index.js"; import {ListUintNum64Type} from "../../../../src/type/listUintNum64.js"; +import {TreeMutation, runViewTestMutation} from "../runViewTestMutation.js"; const limit = 100; const uint64NumInf = new UintNumberType(8, {clipInfinity: true}); @@ -241,7 +241,7 @@ describe("ListBasicType.sliceTo", () => { } }); -describe("ListBasicType batchHashTreeRoot", function () { +describe("ListBasicType batchHashTreeRoot", () => { const value = [1, 2, 3, 4]; const expectedRoot = ListN64Uint64NumberType.toView(value).hashTreeRoot(); diff --git a/packages/ssz/test/unit/byType/listComposite/invalid.test.ts b/packages/ssz/test/unit/byType/listComposite/invalid.test.ts index 0bf820440..f061ee4a6 100644 --- a/packages/ssz/test/unit/byType/listComposite/invalid.test.ts +++ b/packages/ssz/test/unit/byType/listComposite/invalid.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {ListCompositeType, UintNumberType, ContainerType, ListBasicType} from "../../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {ContainerType, ListBasicType, ListCompositeType, UintNumberType} from "../../../../src/index.js"; import {runTypeTestInvalid} from "../runTypeTestInvalid.js"; const uint16 = new UintNumberType(2); diff --git a/packages/ssz/test/unit/byType/listComposite/tree.test.ts b/packages/ssz/test/unit/byType/listComposite/tree.test.ts index cf7939fb9..fef6ae960 100644 --- a/packages/ssz/test/unit/byType/listComposite/tree.test.ts +++ b/packages/ssz/test/unit/byType/listComposite/tree.test.ts @@ -1,18 +1,18 @@ -import {describe, it, expect, beforeEach} from "vitest"; +import {beforeEach, describe, expect, it} from "vitest"; import { ByteVectorType, CompositeView, ContainerNodeStructType, ContainerType, ListCompositeType, - toHexString, UintNumberType, ValueOf, + toHexString, } from "../../../../src/index.js"; import {ArrayCompositeTreeViewDU} from "../../../../src/viewDU/arrayComposite.js"; +import {ListCompositeTreeViewDU} from "../../../../src/viewDU/listComposite.js"; import {ssz} from "../../../lodestarTypes/primitive/index.js"; import {runViewTestMutation} from "../runViewTestMutation.js"; -import {ListCompositeTreeViewDU} from "../../../../src/viewDU/listComposite.js"; const uint64NumInfType = new UintNumberType(8, {clipInfinity: true}); const containerUintsType = new ContainerType( @@ -423,7 +423,9 @@ describe("ListCompositeType", () => { // this is equivalent to getAllReadonly() // but consumer can break in the middle to improve performance while (start < listLength) { - listView.getReadonlyByRange(start, count).forEach((item) => total.push(item as Buffer)); + for (const item of listView.getReadonlyByRange(start, count)) { + total.push(item as Buffer); + } start += count; } diff --git a/packages/ssz/test/unit/byType/listComposite/valid.test.ts b/packages/ssz/test/unit/byType/listComposite/valid.test.ts index 4a0db93e1..ea0816a4f 100644 --- a/packages/ssz/test/unit/byType/listComposite/valid.test.ts +++ b/packages/ssz/test/unit/byType/listComposite/valid.test.ts @@ -1,9 +1,9 @@ import { + ByteVectorType, ContainerType, + ListBasicType, ListCompositeType, UintNumberType, - ByteVectorType, - ListBasicType, } from "../../../../src/index.js"; import {runTypeTestValid} from "../runTypeTestValid.js"; diff --git a/packages/ssz/test/unit/byType/none/misc.test.ts b/packages/ssz/test/unit/byType/none/misc.test.ts index c440c46e8..483c5f630 100644 --- a/packages/ssz/test/unit/byType/none/misc.test.ts +++ b/packages/ssz/test/unit/byType/none/misc.test.ts @@ -1,5 +1,5 @@ import {LeafNode} from "@chainsafe/persistent-merkle-tree"; -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {NoneType, toHexString} from "../../../../src/index.js"; describe("None type", () => { diff --git a/packages/ssz/test/unit/byType/optional/invalid.test.ts b/packages/ssz/test/unit/byType/optional/invalid.test.ts index 583788045..dafdfbe2e 100644 --- a/packages/ssz/test/unit/byType/optional/invalid.test.ts +++ b/packages/ssz/test/unit/byType/optional/invalid.test.ts @@ -1,4 +1,4 @@ -import {UintNumberType, OptionalType} from "../../../../src/index.js"; +import {OptionalType, UintNumberType} from "../../../../src/index.js"; import {runTypeTestInvalid} from "../runTypeTestInvalid.js"; const byteType = new UintNumberType(1); diff --git a/packages/ssz/test/unit/byType/optional/tree.test.ts b/packages/ssz/test/unit/byType/optional/tree.test.ts index 673716a4b..8960796ea 100644 --- a/packages/ssz/test/unit/byType/optional/tree.test.ts +++ b/packages/ssz/test/unit/byType/optional/tree.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {OptionalType, ContainerType, UintNumberType, ValueOf, toHexString} from "../../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {ContainerType, OptionalType, UintNumberType, ValueOf, toHexString} from "../../../../src/index.js"; const byteType = new UintNumberType(1); const SimpleObject = new ContainerType({ @@ -9,7 +9,7 @@ const SimpleObject = new ContainerType({ describe("Optional view tests", () => { // TODO: implement - // eslint-disable-next-line @typescript-eslint/no-unsafe-call + it.skip("optional simple type", () => { const type = new OptionalType(byteType); const value: ValueOf = 9; @@ -23,7 +23,7 @@ describe("Optional view tests", () => { }); // TODO: implement - // eslint-disable-next-line @typescript-eslint/no-unsafe-call + it.skip("optional composite type", () => { const type = new OptionalType(SimpleObject); const value: ValueOf = {a: 9, b: 11}; diff --git a/packages/ssz/test/unit/byType/optional/valid.test.ts b/packages/ssz/test/unit/byType/optional/valid.test.ts index c35c91f7b..85f33926d 100644 --- a/packages/ssz/test/unit/byType/optional/valid.test.ts +++ b/packages/ssz/test/unit/byType/optional/valid.test.ts @@ -1,4 +1,4 @@ -import {OptionalType, UintNumberType, ListBasicType, ContainerType, ListCompositeType} from "../../../../src/index.js"; +import {ContainerType, ListBasicType, ListCompositeType, OptionalType, UintNumberType} from "../../../../src/index.js"; import {runTypeTestValid} from "../runTypeTestValid.js"; const number8Type = new UintNumberType(1); diff --git a/packages/ssz/test/unit/byType/partialListComposite/tree.test.ts b/packages/ssz/test/unit/byType/partialListComposite/tree.test.ts index 75a574302..4aecc24c2 100644 --- a/packages/ssz/test/unit/byType/partialListComposite/tree.test.ts +++ b/packages/ssz/test/unit/byType/partialListComposite/tree.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ContainerType, ListCompositeType, UintNumberType} from "../../../../src/index.js"; import {PartialListCompositeType} from "../../../../src/type/partialListComposite.js"; @@ -19,7 +19,7 @@ const partialListType = new PartialListCompositeType(containerUintsType, maxItem * Also serialize(), toViewDU() does not work for this type. */ -describe("PartialListCompositeType ViewDU", function () { +describe("PartialListCompositeType ViewDU", () => { const fullList = fullListType.defaultViewDU(); for (let i = 0; i < maxItem; i++) { fullList.push(containerUintsType.toViewDU({a: i, b: i * 2})); @@ -27,7 +27,7 @@ describe("PartialListCompositeType ViewDU", function () { describe("push then compare value", () => { for (let snapshotCount = 1; snapshotCount <= maxItem; snapshotCount++) { - it(`snapshotCount=${snapshotCount}`, function () { + it(`snapshotCount=${snapshotCount}`, () => { const snapshot = fullList.toSnapshot(snapshotCount); const partialList = partialListType.toPartialViewDU(snapshot); expect(partialList.hashTreeRoot()).to.deep.equal(fullList.sliceTo(snapshotCount - 1).hashTreeRoot()); @@ -50,7 +50,7 @@ describe("PartialListCompositeType ViewDU", function () { describe("push then get snapshot", () => { for (let snapshotCount = 1; snapshotCount <= maxItem; snapshotCount++) { - it(`snapshotCount=${snapshotCount}`, function () { + it(`snapshotCount=${snapshotCount}`, () => { const snapshot = fullList.toSnapshot(snapshotCount); const partialList = partialListType.toPartialViewDU(snapshot); expect(partialList.hashTreeRoot()).to.deep.equal(fullList.sliceTo(snapshotCount - 1).hashTreeRoot()); @@ -69,7 +69,7 @@ describe("PartialListCompositeType ViewDU", function () { describe("push then sliceTo()", () => { for (let snapshotCount = 1; snapshotCount <= maxItem; snapshotCount++) { - it(`snapshotCount=${snapshotCount}`, function () { + it(`snapshotCount=${snapshotCount}`, () => { const snapshot = fullList.toSnapshot(snapshotCount); const partialList = partialListType.toPartialViewDU(snapshot); expect(partialList.hashTreeRoot()).to.deep.equal(fullList.sliceTo(snapshotCount - 1).hashTreeRoot()); @@ -92,7 +92,7 @@ describe("PartialListCompositeType ViewDU", function () { describe("push then sliceFrom()", () => { for (let snapshotCount = 1; snapshotCount <= maxItem; snapshotCount++) { - it(`snapshotCount=${snapshotCount}`, function () { + it(`snapshotCount=${snapshotCount}`, () => { const snapshot = fullList.toSnapshot(snapshotCount); const partialList = partialListType.toPartialViewDU(snapshot); expect(partialList.hashTreeRoot()).to.deep.equal(fullList.sliceTo(snapshotCount - 1).hashTreeRoot()); @@ -118,7 +118,7 @@ describe("PartialListCompositeType ViewDU", function () { describe("push then clone() and set()", () => { for (let snapshotCount = 1; snapshotCount <= maxItem; snapshotCount++) { - it(`snapshotCount=${snapshotCount}`, function () { + it(`snapshotCount=${snapshotCount}`, () => { const snapshot = fullList.toSnapshot(snapshotCount); const partialList = partialListType.toPartialViewDU(snapshot); expect(partialList.hashTreeRoot()).to.deep.equal(fullList.sliceTo(snapshotCount - 1).hashTreeRoot()); diff --git a/packages/ssz/test/unit/byType/profile/tree.test.ts b/packages/ssz/test/unit/byType/profile/tree.test.ts index 00c8f85ba..9b14dd57e 100644 --- a/packages/ssz/test/unit/byType/profile/tree.test.ts +++ b/packages/ssz/test/unit/byType/profile/tree.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {Tree} from "@chainsafe/persistent-merkle-tree"; +import {describe, expect, it} from "vitest"; import { BitArray, BitListType, @@ -15,11 +15,11 @@ import { OptionalType, ProfileType, StableContainerType, - toHexString, UnionType, ValueOf, VectorBasicType, VectorCompositeType, + toHexString, } from "../../../../src/index.js"; import {uint64NumInfType, uint64NumType} from "../../../utils/primitiveTypes.js"; import {runViewTestMutation} from "../runViewTestMutation.js"; @@ -239,7 +239,7 @@ runViewTestMutation({ ], }); -describe("ProfileViewDU batchHashTreeRoot", function () { +describe("ProfileViewDU batchHashTreeRoot", () => { const childContainerType = new ContainerType({f0: uint64NumInfType, f1: uint64NumInfType}); const unionType = new UnionType([new NoneType(), uint64NumType]); const listBasicType = new ListBasicType(uint64NumType, 10); diff --git a/packages/ssz/test/unit/byType/runTypeProofTest.ts b/packages/ssz/test/unit/byType/runTypeProofTest.ts index 6c1ce6ea1..90dfa62ad 100644 --- a/packages/ssz/test/unit/byType/runTypeProofTest.ts +++ b/packages/ssz/test/unit/byType/runTypeProofTest.ts @@ -3,12 +3,12 @@ import {expect} from "vitest"; import { BitArray, ContainerType, - fromHexString, JsonPath, OptionalType, ProfileType, StableContainerType, Type, + fromHexString, } from "../../../src/index.js"; import {CompositeTypeAny, isCompositeType} from "../../../src/type/composite.js"; import {ArrayBasicTreeView} from "../../../src/view/arrayBasic.js"; @@ -34,30 +34,33 @@ export function runProofTestOnAllJsonPaths({ continue; } - wrapErr(() => { - if (type.tree_createProofGindexes(node, [jsonPath]).length === 0) { - return; - } + wrapErr( + () => { + if (type.tree_createProofGindexes(node, [jsonPath]).length === 0) { + return; + } - const proof = type.tree_createProof(node, [jsonPath]); - const viewFromProof = type.createFromProof(proof, root); + const proof = type.tree_createProof(node, [jsonPath]); + const viewFromProof = type.createFromProof(proof, root); - const typeLeaf = getJsonPathType(type, jsonPath); - const viewLeafFromProof = getJsonPathView(type, viewFromProof, jsonPath); - const jsonLeaf = getJsonPathValue(type, json, jsonPath); + const typeLeaf = getJsonPathType(type, jsonPath); + const viewLeafFromProof = getJsonPathView(type, viewFromProof, jsonPath); + const jsonLeaf = getJsonPathValue(type, json, jsonPath); - const jsonLeafFromProof = - viewLeafFromProof == null - ? viewLeafFromProof - : typeLeaf.toJson( - isCompositeType(typeLeaf) ? typeLeaf.toValueFromView(viewLeafFromProof) : viewLeafFromProof - ); + const jsonLeafFromProof = + viewLeafFromProof == null + ? viewLeafFromProof + : typeLeaf.toJson( + isCompositeType(typeLeaf) ? typeLeaf.toValueFromView(viewLeafFromProof) : viewLeafFromProof + ); - expect(jsonLeafFromProof).to.deep.equal(jsonLeaf, "Wrong value fromProof"); + expect(jsonLeafFromProof).to.deep.equal(jsonLeaf, "Wrong value fromProof"); - // TODO: Ensure the value is the same - viewFromProof; - }, `Proof JSON path ${JSON.stringify(jsonPath)}`); + // TODO: Ensure the value is the same + viewFromProof; + }, + `Proof JSON path ${JSON.stringify(jsonPath)}` + ); } } @@ -114,7 +117,6 @@ function getJsonPathType(type: CompositeTypeAny, jsonPath: JsonPath): Type, view: unknown, jsonPath: JsonPath): unknown { for (const jsonProp of jsonPath) { if (type instanceof OptionalType) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment type = type.elementType; } if (typeof jsonProp === "number") { @@ -123,6 +125,7 @@ function getJsonPathView(type: Type, view: unknown, jsonPath: JsonPath) if (type instanceof ContainerType || type instanceof StableContainerType || type instanceof ProfileType) { // Coerce jsonProp to a fieldName. JSON paths may be in JSON notation or fieldName notation const fieldName = + // biome-ignore lint/complexity/useLiteralKeys: The key `jsonKeyToFieldName` is protected field (type as ContainerType>>)["jsonKeyToFieldName"][jsonProp] ?? jsonProp; view = (view as Record)[fieldName as string]; } else { @@ -146,13 +149,13 @@ function getJsonPathView(type: Type, view: unknown, jsonPath: JsonPath) function getJsonPathValue(type: Type, json: unknown, jsonPath: JsonPath): unknown { for (const jsonProp of jsonPath) { if (type instanceof OptionalType) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment type = type.elementType; } if (typeof jsonProp === "number") { json = (json as unknown[])[jsonProp]; } else if (typeof jsonProp === "string") { if (type instanceof ContainerType || type instanceof StableContainerType || type instanceof ProfileType) { + // biome-ignore lint/complexity/useLiteralKeys: The key `jsonKeyToFieldName` is protected field if ((type as ContainerType>>)["jsonKeyToFieldName"][jsonProp] === undefined) { throw Error(`Unknown jsonProp ${jsonProp} for type ${type.typeName}`); } diff --git a/packages/ssz/test/unit/byType/runTypeTestInvalid.ts b/packages/ssz/test/unit/byType/runTypeTestInvalid.ts index f9fe92058..0ab3c05be 100644 --- a/packages/ssz/test/unit/byType/runTypeTestInvalid.ts +++ b/packages/ssz/test/unit/byType/runTypeTestInvalid.ts @@ -1,7 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {CompositeType, fromHexString, Type} from "../../../src/index.js"; - -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +import {describe, expect, it} from "vitest"; +import {CompositeType, Type, fromHexString} from "../../../src/index.js"; // For better typesafety outside export type InvalidValue = InvalidValueMeta & diff --git a/packages/ssz/test/unit/byType/runTypeTestValid.ts b/packages/ssz/test/unit/byType/runTypeTestValid.ts index 7654d2d33..1413de71f 100644 --- a/packages/ssz/test/unit/byType/runTypeTestValid.ts +++ b/packages/ssz/test/unit/byType/runTypeTestValid.ts @@ -1,12 +1,10 @@ -import {describe, it, expect} from "vitest"; -import {toHexString, TreeViewDU, UnionType} from "../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {TreeViewDU, UnionType, toHexString} from "../../../src/index.js"; import {Type} from "../../../src/type/abstract.js"; import {isCompositeType} from "../../../src/type/composite.js"; import {runValidSszTest, toJsonOrString} from "../../spec/runValidTest.js"; import {runProofTestOnAllJsonPaths} from "./runTypeProofTest.js"; -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ - export type TypeTestValid = { id?: string; serialized: string; diff --git a/packages/ssz/test/unit/byType/runViewTestCompositeSwap.ts b/packages/ssz/test/unit/byType/runViewTestCompositeSwap.ts index 2fe1e69c0..17f851aaa 100644 --- a/packages/ssz/test/unit/byType/runViewTestCompositeSwap.ts +++ b/packages/ssz/test/unit/byType/runViewTestCompositeSwap.ts @@ -1,4 +1,4 @@ -import {Type, ValueOf, TreeView, BasicType} from "../../../src/index.js"; +import {BasicType, TreeView, Type, ValueOf} from "../../../src/index.js"; import { ContainerType, ListBasicType, diff --git a/packages/ssz/test/unit/byType/runViewTestMutation.ts b/packages/ssz/test/unit/byType/runViewTestMutation.ts index f55fb8061..43915347c 100644 --- a/packages/ssz/test/unit/byType/runViewTestMutation.ts +++ b/packages/ssz/test/unit/byType/runViewTestMutation.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; +import {CompositeType, CompositeViewDU, TreeViewDU, ValueOf} from "../../../src/index.js"; import {toHexString} from "../../../src/util/byteArray.js"; -import {CompositeType, ValueOf, TreeViewDU, CompositeViewDU} from "../../../src/index.js"; export type TreeMutation> = { id: string; @@ -50,7 +50,6 @@ const runViewTestMutationFn = function runViewTestMutation { diff --git a/packages/ssz/test/unit/byType/stableContainer/tree.test.ts b/packages/ssz/test/unit/byType/stableContainer/tree.test.ts index 6beb2392d..8f22c92cd 100644 --- a/packages/ssz/test/unit/byType/stableContainer/tree.test.ts +++ b/packages/ssz/test/unit/byType/stableContainer/tree.test.ts @@ -1,4 +1,5 @@ -import {describe, it, expect} from "vitest"; +import {Tree, getNodesAtDepth, zeroHash} from "@chainsafe/persistent-merkle-tree"; +import {describe, expect, it} from "vitest"; import { BitArray, BitListType, @@ -13,15 +14,14 @@ import { NoneType, OptionalType, StableContainerType, - toHexString, UnionType, ValueOf, VectorBasicType, VectorCompositeType, + toHexString, } from "../../../../src/index.js"; import {uint64NumInfType, uint64NumType} from "../../../utils/primitiveTypes.js"; import {runViewTestMutation} from "../runViewTestMutation.js"; -import {getNodesAtDepth, Tree, zeroHash} from "@chainsafe/persistent-merkle-tree"; // Test both ContainerType, ContainerNodeStructType only if // - All fields are immutable @@ -232,7 +232,7 @@ runViewTestMutation({ ], }); -describe("StableContainerViewDU batchHashTreeRoot", function () { +describe("StableContainerViewDU batchHashTreeRoot", () => { const childContainerType = new ContainerType({f0: uint64NumInfType, f1: uint64NumInfType}); const unionType = new UnionType([new NoneType(), uint64NumType]); const listBasicType = new ListBasicType(uint64NumType, 10); diff --git a/packages/ssz/test/unit/byType/uint/invalid.test.ts b/packages/ssz/test/unit/byType/uint/invalid.test.ts index f2aba989d..b806f20fa 100644 --- a/packages/ssz/test/unit/byType/uint/invalid.test.ts +++ b/packages/ssz/test/unit/byType/uint/invalid.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; -import {UintNumberType, UintBigintType} from "../../../../src/index.js"; -import {UintNumberByteLen, uintNumberByteLens, uintBigintByteLens} from "../../../../src/type/uint.js"; -import {runTypeTestInvalid, InvalidValue} from "../runTypeTestInvalid.js"; +import {describe, expect, it} from "vitest"; +import {UintBigintType, UintNumberType} from "../../../../src/index.js"; +import {UintNumberByteLen, uintBigintByteLens, uintNumberByteLens} from "../../../../src/type/uint.js"; +import {InvalidValue, runTypeTestInvalid} from "../runTypeTestInvalid.js"; for (const byteLen of uintNumberByteLens) { runTypeTestInvalid({ diff --git a/packages/ssz/test/unit/byType/uint/tree.test.ts b/packages/ssz/test/unit/byType/uint/tree.test.ts index fa1291565..933f79cb9 100644 --- a/packages/ssz/test/unit/byType/uint/tree.test.ts +++ b/packages/ssz/test/unit/byType/uint/tree.test.ts @@ -1,6 +1,6 @@ import {LeafNode} from "@chainsafe/persistent-merkle-tree"; -import {describe, it, expect} from "vitest"; -import {toHexString, fromHexString} from "../../../../src/util/byteArray.js"; +import {describe, expect, it} from "vitest"; +import {fromHexString, toHexString} from "../../../../src/util/byteArray.js"; import {byteType, uint64NumInfType} from "../../../utils/primitiveTypes.js"; describe("UintNumberType / tree", () => { @@ -34,23 +34,23 @@ describe("UintType - Infinity with clipInfinity", () => { it("Infinity getFromNode", () => { const node = LeafNode.fromRoot(fromHexString(hexOffset0)); - expect(uint64NumInfType.tree_getFromNode(node)).to.equal(Infinity); + expect(uint64NumInfType.tree_getFromNode(node)).to.equal(Number.POSITIVE_INFINITY); }); it("Infinity getFromPackedNode", () => { const node = LeafNode.fromRoot(fromHexString(hexOffset2)); - expect(uint64NumInfType.tree_getFromPackedNode(node, 2)).to.equal(Infinity); + expect(uint64NumInfType.tree_getFromPackedNode(node, 2)).to.equal(Number.POSITIVE_INFINITY); }); it("Infinity setToNode", () => { const node = LeafNode.fromRoot(Buffer.alloc(32, 0)); - uint64NumInfType.tree_setToNode(node, Infinity); + uint64NumInfType.tree_setToNode(node, Number.POSITIVE_INFINITY); expect(toHexString(node.root)).to.equal(hexOffset0); }); it("Infinity setToPackedNode", () => { const node = LeafNode.fromRoot(Buffer.alloc(32, 0)); - uint64NumInfType.tree_setToPackedNode(node, 2, Infinity); + uint64NumInfType.tree_setToPackedNode(node, 2, Number.POSITIVE_INFINITY); expect(toHexString(node.root)).to.equal(hexOffset2); }); }); diff --git a/packages/ssz/test/unit/byType/union/invalid.test.ts b/packages/ssz/test/unit/byType/union/invalid.test.ts index 5a715ed2c..103623f39 100644 --- a/packages/ssz/test/unit/byType/union/invalid.test.ts +++ b/packages/ssz/test/unit/byType/union/invalid.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {UintNumberType, UnionType, NoneType} from "../../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {NoneType, UintNumberType, UnionType} from "../../../../src/index.js"; import {runTypeTestInvalid} from "../runTypeTestInvalid.js"; const byteType = new UintNumberType(1); diff --git a/packages/ssz/test/unit/byType/union/tree.test.ts b/packages/ssz/test/unit/byType/union/tree.test.ts index 06f92df3b..78cd3a0b5 100644 --- a/packages/ssz/test/unit/byType/union/tree.test.ts +++ b/packages/ssz/test/unit/byType/union/tree.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {UnionType, UintNumberType, NoneType, ValueOf, toHexString} from "../../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {NoneType, UintNumberType, UnionType, ValueOf, toHexString} from "../../../../src/index.js"; const byteType = new UintNumberType(1); const noneType = new NoneType(); diff --git a/packages/ssz/test/unit/byType/union/valid.test.ts b/packages/ssz/test/unit/byType/union/valid.test.ts index a0b4e7738..96d815ae6 100644 --- a/packages/ssz/test/unit/byType/union/valid.test.ts +++ b/packages/ssz/test/unit/byType/union/valid.test.ts @@ -1,4 +1,4 @@ -import {ContainerType, UintNumberType, UnionType, NoneType} from "../../../../src/index.js"; +import {ContainerType, NoneType, UintNumberType, UnionType} from "../../../../src/index.js"; import {runTypeTestValid} from "../runTypeTestValid.js"; const number16Type = new UintNumberType(2); diff --git a/packages/ssz/test/unit/byType/vector/invalid.test.ts b/packages/ssz/test/unit/byType/vector/invalid.test.ts index 17c52b042..29f379858 100644 --- a/packages/ssz/test/unit/byType/vector/invalid.test.ts +++ b/packages/ssz/test/unit/byType/vector/invalid.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {VectorBasicType, VectorCompositeType} from "../../../../src/index.js"; import {byteType, uint16NumType} from "../../../utils/primitiveTypes.js"; import {runTypeTestInvalid} from "../runTypeTestInvalid.js"; diff --git a/packages/ssz/test/unit/byType/vector/valid.test.ts b/packages/ssz/test/unit/byType/vector/valid.test.ts index 20c6deb5c..243e91a4e 100644 --- a/packages/ssz/test/unit/byType/vector/valid.test.ts +++ b/packages/ssz/test/unit/byType/vector/valid.test.ts @@ -1,10 +1,10 @@ import { + ByteVectorType, ContainerType, + ListBasicType, + UintNumberType, VectorBasicType, VectorCompositeType, - UintNumberType, - ByteVectorType, - ListBasicType, } from "../../../../src/index.js"; import {runTypeTestValid} from "../runTypeTestValid.js"; diff --git a/packages/ssz/test/unit/byType/vectorBasic/tree.test.ts b/packages/ssz/test/unit/byType/vectorBasic/tree.test.ts index 4fad5a315..4bbb93d1a 100644 --- a/packages/ssz/test/unit/byType/vectorBasic/tree.test.ts +++ b/packages/ssz/test/unit/byType/vectorBasic/tree.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {UintNumberType, VectorBasicType} from "../../../../src/index.js"; import {runViewTestMutation} from "../runViewTestMutation.js"; diff --git a/packages/ssz/test/unit/byType/vectorComposite/tree.test.ts b/packages/ssz/test/unit/byType/vectorComposite/tree.test.ts index 04d39b147..6a545770e 100644 --- a/packages/ssz/test/unit/byType/vectorComposite/tree.test.ts +++ b/packages/ssz/test/unit/byType/vectorComposite/tree.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { ContainerNodeStructType, ContainerType, diff --git a/packages/ssz/test/unit/byValue/bitArray.test.ts b/packages/ssz/test/unit/byValue/bitArray.test.ts index 34894eb46..2d2929396 100644 --- a/packages/ssz/test/unit/byValue/bitArray.test.ts +++ b/packages/ssz/test/unit/byValue/bitArray.test.ts @@ -1,11 +1,9 @@ -import {describe, it, expect} from "vitest"; -import {getUint8ByteToBitBooleanArray, BitArray} from "../../../src/value/bitArray.js"; +import {describe, expect, it} from "vitest"; import {BitVectorType} from "../../../src/index.js"; +import {BitArray, getUint8ByteToBitBooleanArray} from "../../../src/value/bitArray.js"; import {linspace} from "../../utils/misc.js"; -const BITS_PER_BYTE = 8; - -describe("aggregationBits", function () { +describe("aggregationBits", () => { it("getUint8ByteToBitBooleanArray", () => { expect(getUint8ByteToBitBooleanArray(1)).toEqual([true, false, false, false, false, false, false, false]); expect(getUint8ByteToBitBooleanArray(5)).toEqual([true, false, true, false, false, false, false, false]); @@ -215,14 +213,3 @@ describe("BitArray helper get unparticipants", () => { }); } }); - -/** - * Get aggregation bit (true/false) from an aggregation bytes array and validator index in committee. - * Notice: If we want to access the bit in batch, using this method is not efficient, check the performance - * test for an example of how to do that. - */ -export function getAggregationBit(attBytes: number[] | Uint8Array, indexInCommittee: number): boolean { - const byteIndex = Math.floor(indexInCommittee / BITS_PER_BYTE); - const indexInByte = indexInCommittee % BITS_PER_BYTE; - return getUint8ByteToBitBooleanArray(attBytes[byteIndex])[indexInByte]; -} diff --git a/packages/ssz/test/unit/cachePermanentRootStruct.test.ts b/packages/ssz/test/unit/cachePermanentRootStruct.test.ts index ee7f9dfbc..e3dd48590 100644 --- a/packages/ssz/test/unit/cachePermanentRootStruct.test.ts +++ b/packages/ssz/test/unit/cachePermanentRootStruct.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ContainerType, UintNumberType} from "../../src/index.js"; describe("cachePermanentRootStruct", () => { diff --git a/packages/ssz/test/unit/dataView.test.ts b/packages/ssz/test/unit/dataView.test.ts index 15e769d71..89baf4720 100644 --- a/packages/ssz/test/unit/dataView.test.ts +++ b/packages/ssz/test/unit/dataView.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; describe("DataView", () => { it("Test results of multiple sets", () => { diff --git a/packages/ssz/test/unit/eth2/allForks.test.ts b/packages/ssz/test/unit/eth2/allForks.test.ts index 9fe0e749e..4515e43b5 100644 --- a/packages/ssz/test/unit/eth2/allForks.test.ts +++ b/packages/ssz/test/unit/eth2/allForks.test.ts @@ -1,5 +1,5 @@ -import {describe, it} from "vitest"; import {Node, Tree} from "@chainsafe/persistent-merkle-tree"; +import {describe, it} from "vitest"; import {CompositeView, CompositeViewDU, ContainerType, ValueOf} from "../../../src/index.js"; import {allForks, altair, bellatrix, phase0, ssz} from "../../lodestarTypes/index.js"; import {ForkName} from "../../utils/fork.js"; @@ -378,28 +378,28 @@ describe("Eth2 allForks BeaconState, non-cached and cached", () => { genericArgCachedBeaconStateAllForks(getCachedBeaconState(typeMashup.defaultViewDU())); genericArgBeaconStateAllForks(getCachedBeaconState(typeMashup.defaultViewDU())); - function assertValue(state: phase0.BeaconState | altair.BeaconState | bellatrix.BeaconState): void { - state; + function assertValue(_state: phase0.BeaconState | altair.BeaconState | bellatrix.BeaconState): void { + _state; } function assertView( - state: + _state: | CompositeView | CompositeView | CompositeView | CompositeView | CompositeView ): void { - state; + _state; } function assertViewDU( - state: + _state: | CompositeViewDU | CompositeViewDU | CompositeViewDU | CompositeViewDU | CompositeViewDU ): void { - state; + _state; } }); }); diff --git a/packages/ssz/test/unit/eth2/beaconState.test.ts b/packages/ssz/test/unit/eth2/beaconState.test.ts index f5d71beff..068ddcec9 100644 --- a/packages/ssz/test/unit/eth2/beaconState.test.ts +++ b/packages/ssz/test/unit/eth2/beaconState.test.ts @@ -1,13 +1,13 @@ -import {describe, it, expect} from "vitest"; -import {BeaconState} from "../../lodestarTypes/deneb/sszTypes.js"; +import {describe, expect, it} from "vitest"; +import {BitArray, fromHexString} from "../../../src/index.js"; import {ListUintNum64Type} from "../../../src/type/listUintNum64.js"; +import {BeaconState} from "../../lodestarTypes/deneb/sszTypes.js"; import {altair, phase0, ssz} from "../../lodestarTypes/index.js"; -import {BitArray, fromHexString} from "../../../src/index.js"; const VALIDATOR_REGISTRY_LIMIT = 1099511627776; -export const Balances = new ListUintNum64Type(VALIDATOR_REGISTRY_LIMIT); +const Balances = new ListUintNum64Type(VALIDATOR_REGISTRY_LIMIT); -describe("BeaconState ViewDU batchHashTreeRoot", function () { +describe("BeaconState ViewDU batchHashTreeRoot", () => { const view = BeaconState.defaultView(); const viewDU = BeaconState.defaultViewDU(); diff --git a/packages/ssz/test/unit/eth2/caseEth2.test.ts b/packages/ssz/test/unit/eth2/caseEth2.test.ts index c6a652cc0..436cf5af9 100644 --- a/packages/ssz/test/unit/eth2/caseEth2.test.ts +++ b/packages/ssz/test/unit/eth2/caseEth2.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {precomputeJsonKey} from "../../../src/type/container.js"; describe("JSON case eth2", () => { diff --git a/packages/ssz/test/unit/eth2/minMaxSize.test.ts b/packages/ssz/test/unit/eth2/minMaxSize.test.ts index 336427a23..41df4cc4a 100644 --- a/packages/ssz/test/unit/eth2/minMaxSize.test.ts +++ b/packages/ssz/test/unit/eth2/minMaxSize.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {ssz} from "../../lodestarTypes/index.js"; +import {describe, expect, it} from "vitest"; import {Type} from "../../../src/index.js"; +import {ssz} from "../../lodestarTypes/index.js"; enum ForkName { phase0 = "phase0", diff --git a/packages/ssz/test/unit/eth2/regressions.test.ts b/packages/ssz/test/unit/eth2/regressions.test.ts index 04bf464cb..3cbe9ec27 100644 --- a/packages/ssz/test/unit/eth2/regressions.test.ts +++ b/packages/ssz/test/unit/eth2/regressions.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ssz} from "../../lodestarTypes/index.js"; describe("Various issues and regressions of Eth2 types", () => { diff --git a/packages/ssz/test/unit/eth2/validators.test.ts b/packages/ssz/test/unit/eth2/validators.test.ts index 0f7554934..2ea555405 100644 --- a/packages/ssz/test/unit/eth2/validators.test.ts +++ b/packages/ssz/test/unit/eth2/validators.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect, vi} from "vitest"; -import {toHexString, ListCompositeType, ValueOf, CompositeViewDU} from "../../../src/index.js"; +import {describe, expect, it, vi} from "vitest"; +import {CompositeViewDU, ListCompositeType, ValueOf, toHexString} from "../../../src/index.js"; import {ValidatorContainer, ValidatorNodeStruct} from "../../lodestarTypes/phase0/sszTypes.js"; type Validator = ValueOf; diff --git a/packages/ssz/test/unit/lodestarTypes/phase0/listValidator.test.ts b/packages/ssz/test/unit/lodestarTypes/phase0/listValidator.test.ts index c26c779a0..d86872f52 100644 --- a/packages/ssz/test/unit/lodestarTypes/phase0/listValidator.test.ts +++ b/packages/ssz/test/unit/lodestarTypes/phase0/listValidator.test.ts @@ -1,17 +1,17 @@ +import {describe, expect, it} from "vitest"; +import {ContainerType} from "../../../../src/type/container.js"; import {ListCompositeType} from "../../../../src/type/listComposite.js"; -import {ValidatorType} from "../../../lodestarTypes/phase0/validator.js"; -import {preset} from "../../../lodestarTypes/params.js"; import {ssz} from "../../../lodestarTypes/index.js"; -import {describe, it, expect} from "vitest"; -import {ContainerType} from "../../../../src/type/container.js"; +import {preset} from "../../../lodestarTypes/params.js"; import {Validator} from "../../../lodestarTypes/phase0/index.js"; +import {ValidatorType} from "../../../lodestarTypes/phase0/validator.js"; const {VALIDATOR_REGISTRY_LIMIT} = preset; -describe("ListValidator ssz type", function () { +describe("ListValidator ssz type", () => { const seedValidator = { activationEligibilityEpoch: 10, activationEpoch: 11, - exitEpoch: Infinity, + exitEpoch: Number.POSITIVE_INFINITY, slashed: false, withdrawableEpoch: 13, pubkey: Buffer.alloc(48, 100), diff --git a/packages/ssz/test/unit/lodestarTypes/phase0/validator.test.ts b/packages/ssz/test/unit/lodestarTypes/phase0/validator.test.ts index f66b65367..08ee7798c 100644 --- a/packages/ssz/test/unit/lodestarTypes/phase0/validator.test.ts +++ b/packages/ssz/test/unit/lodestarTypes/phase0/validator.test.ts @@ -1,17 +1,17 @@ import {digestNLevel} from "@chainsafe/persistent-merkle-tree"; +import {describe, expect, it} from "vitest"; import {ContainerType} from "../../../../../ssz/src/type/container.js"; import {ssz} from "../../../lodestarTypes/index.js"; -import {ValidatorNodeStruct, ValidatorType, validatorToChunkBytes} from "../../../lodestarTypes/phase0/validator.js"; -import {describe, it, expect} from "vitest"; import {Validator} from "../../../lodestarTypes/phase0/sszTypes.js"; +import {ValidatorNodeStruct, ValidatorType, validatorToChunkBytes} from "../../../lodestarTypes/phase0/validator.js"; const ValidatorContainer = new ContainerType(ValidatorType, {typeName: "Validator", jsonCase: "eth2"}); -describe("Validator ssz types", function () { +describe("Validator ssz types", () => { const seedValidator = { activationEligibilityEpoch: 10, activationEpoch: 11, - exitEpoch: Infinity, + exitEpoch: Number.POSITIVE_INFINITY, slashed: false, withdrawableEpoch: 13, pubkey: Buffer.alloc(48, 100), @@ -43,11 +43,11 @@ describe("Validator ssz types", function () { }); }); -describe("validatorToChunkBytes", function () { +describe("validatorToChunkBytes", () => { const seedValidator = { activationEligibilityEpoch: 10, activationEpoch: 11, - exitEpoch: Infinity, + exitEpoch: Number.POSITIVE_INFINITY, slashed: false, withdrawableEpoch: 13, pubkey: Buffer.alloc(48, 100), diff --git a/packages/ssz/test/unit/merkleize.test.ts b/packages/ssz/test/unit/merkleize.test.ts index e3c054d92..76cca076f 100644 --- a/packages/ssz/test/unit/merkleize.test.ts +++ b/packages/ssz/test/unit/merkleize.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; +import {LeafNode, merkleizeBlockArray, merkleizeBlocksBytes, zeroHash} from "@chainsafe/persistent-merkle-tree"; +import {describe, expect, it} from "vitest"; import {bitLength, maxChunksToDepth, merkleize, mixInLength, nextPowerOf2} from "../../src/util/merkleize.js"; -import {merkleizeBlocksBytes, LeafNode, zeroHash, merkleizeBlockArray} from "@chainsafe/persistent-merkle-tree"; describe("util / merkleize / bitLength", () => { const bitLengthByIndex = [0, 1, 2, 2, 3, 3, 3, 3, 4, 4]; diff --git a/packages/ssz/test/unit/named.test.ts b/packages/ssz/test/unit/named.test.ts index 4ebfc71d6..e6e00aff5 100644 --- a/packages/ssz/test/unit/named.test.ts +++ b/packages/ssz/test/unit/named.test.ts @@ -1,16 +1,16 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { BitListType, BitVectorType, BooleanType, ByteListType, ByteVectorType, - ContainerType, ContainerNodeStructType, + ContainerType, ListBasicType, ListCompositeType, - UintNumberType, UintBigintType, + UintNumberType, UnionType, VectorBasicType, VectorCompositeType, diff --git a/packages/ssz/test/unit/packing.test.ts b/packages/ssz/test/unit/packing.test.ts index 9aa16c43c..5b644dab1 100644 --- a/packages/ssz/test/unit/packing.test.ts +++ b/packages/ssz/test/unit/packing.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {UintBigintType, toHexString, VectorBasicType} from "../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {UintBigintType, VectorBasicType, toHexString} from "../../src/index.js"; describe("uint packing", () => { const uint8 = new UintBigintType(1); diff --git a/packages/ssz/test/unit/regressions.test.ts b/packages/ssz/test/unit/regressions.test.ts index d35dc9769..749c0e7b8 100644 --- a/packages/ssz/test/unit/regressions.test.ts +++ b/packages/ssz/test/unit/regressions.test.ts @@ -1,31 +1,29 @@ -import {describe, it, expect} from "vitest"; -import {uint32NumType, uint64NumType} from "../utils/primitiveTypes.js"; +import {describe, expect, it} from "vitest"; import { - VectorBasicType, - ListBasicType, + BitArray, BitListType, BitVectorType, - fromHexString, - toHexString, - BitArray, - ContainerType, BooleanType, + ContainerType, + ListBasicType, UintBigintType, ValueOf, + VectorBasicType, + fromHexString, + toHexString, } from "../../src/index.js"; +import {uint32NumType, uint64NumType} from "../utils/primitiveTypes.js"; // Compilation of various issues from SSZ and Lodestar libs -/* eslint-disable max-len */ - describe("Regressions / known issues", () => { - it("SyncCommitteeBits hashTreeRoot consistency", function () { + it("SyncCommitteeBits hashTreeRoot consistency", () => { const SyncCommitteeBits = new BitVectorType(512); const bitStr = "00001110011100101010100110111001111011110111001110110010101000010010011110000110001101111100100100011011001001010000111010010011100100111010111101110110001000000011011001011000011101010111111011000110000101100111111000110011110010010110101011111110111010101111110010011111101001011110001101111110111001100110110001100010100010101110110010100100001011000101101000011010111010111000100100101000101100001100011001110100100111110011100111001100101001011011111001111010111011000100100000010000000111010010100000000111"; const bitArray = BitArray.fromBitLen(512); for (let i = 0; i < 512; i++) { - bitArray.set(i, bitStr.charAt(i) === "0" ? false : true); + bitArray.set(i, bitStr.charAt(i) !== "0"); } const rootByStruct = SyncCommitteeBits.hashTreeRoot(bitArray); @@ -36,7 +34,7 @@ describe("Regressions / known issues", () => { expect(toHexString(rootByStruct)).to.be.equal(toHexString(rootByBatch), "Inconsistent hashTreeRoot"); }); - it("converts bit arrays to tree", function () { + it("converts bit arrays to tree", () => { const CommitteeBits = new BitListType(2048); const CommitteeBitsVector = new BitVectorType(2048); @@ -47,7 +45,7 @@ describe("Regressions / known issues", () => { expect(() => CommitteeBitsVector.toViewDU(bitArray)).to.not.throw(); }); - it("converts Uint8Array to tree", function () { + it("converts Uint8Array to tree", () => { const CommitteeBits = new BitListType(32); const CommitteeBitsVector = new BitVectorType(32); const validBytes = fromHexString("0xffffffff"); @@ -61,7 +59,7 @@ describe("Regressions / known issues", () => { expect(() => CommitteeBitsVector2.deserializeToViewDU(invalidBytes)).toThrow("BitVector: nonzero bits past length"); }); - it("converts basic vector and list from json", function () { + it("converts basic vector and list from json", () => { const Vec = new VectorBasicType(uint32NumType, 4); const Lis = new ListBasicType(uint32NumType, 4); const arr = [1, 2, 3, 4]; diff --git a/packages/ssz/test/unit/snapshot.test.ts b/packages/ssz/test/unit/snapshot.test.ts index 7b8a336ff..66f473060 100644 --- a/packages/ssz/test/unit/snapshot.test.ts +++ b/packages/ssz/test/unit/snapshot.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect} from "vitest"; -import {ByteVectorType} from "../../src/type/byteVector.js"; +import {Tree, toGindex} from "@chainsafe/persistent-merkle-tree"; +import {describe, expect, it} from "vitest"; import {ListCompositeType} from "../../src/index.js"; +import {ByteVectorType} from "../../src/type/byteVector.js"; import {PartialListCompositeType} from "../../src/type/partialListComposite.js"; -import {Tree, toGindex} from "@chainsafe/persistent-merkle-tree"; describe("snapshot", () => { const depth = 4; diff --git a/packages/ssz/test/unit/specTestYamlLoader.test.ts b/packages/ssz/test/unit/specTestYamlLoader.test.ts index 7bc3333f5..2c4ed8747 100644 --- a/packages/ssz/test/unit/specTestYamlLoader.test.ts +++ b/packages/ssz/test/unit/specTestYamlLoader.test.ts @@ -1,10 +1,8 @@ -import {describe, it, expect} from "vitest"; import jsyaml from "js-yaml"; -import {readYamlNumbersAsStrings} from "../spec/testRunner.js"; -import {BeaconBlockHeader} from "../lodestarTypes/phase0/sszTypes.js"; +import {describe, expect, it} from "vitest"; import {toHexString} from "../../src/index.js"; - -/* eslint-disable quotes */ +import {BeaconBlockHeader} from "../lodestarTypes/phase0/sszTypes.js"; +import {readYamlNumbersAsStrings} from "../spec/testRunner.js"; describe("Spec test YAML loader", () => { it("Load YAML string number", () => { diff --git a/packages/ssz/test/unit/strings.test.ts b/packages/ssz/test/unit/strings.test.ts index c69a34bca..53d3547f5 100644 --- a/packages/ssz/test/unit/strings.test.ts +++ b/packages/ssz/test/unit/strings.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; -import {Case} from "../../src/util/strings.js"; import {KeyCase} from "../../src/type/container.js"; +import {Case} from "../../src/util/strings.js"; const testCases = ["fooBar", "foo1Bar", "fooBarBaz", "foo1Bar2Baz", "fooBar1"]; const expectedResults: {[key in KeyCase]: string[]} = { snake: ["foo_bar", "foo1_bar", "foo_bar_baz", "foo1_bar2_baz", "foo_bar1"], diff --git a/packages/ssz/test/unit/uint8Array.test.ts b/packages/ssz/test/unit/uint8Array.test.ts index a3de45281..b35e68b9d 100644 --- a/packages/ssz/test/unit/uint8Array.test.ts +++ b/packages/ssz/test/unit/uint8Array.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; describe("Mutability Buffer, Uint8Array", () => { it("Ensure Uint8Array.slice copies memory", () => { diff --git a/packages/ssz/test/unit/unchangedViewDUs.test.ts b/packages/ssz/test/unit/unchangedViewDUs.test.ts index e7733be0a..3e2c80f45 100644 --- a/packages/ssz/test/unit/unchangedViewDUs.test.ts +++ b/packages/ssz/test/unit/unchangedViewDUs.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import * as sszAltair from "../lodestarTypes/altair/sszTypes.js"; import {getRandomState} from "../utils/generateEth2Objs.js"; diff --git a/packages/ssz/test/unit/util/errorPath.test.ts b/packages/ssz/test/unit/util/errorPath.test.ts index 262daf592..4a4bb646a 100644 --- a/packages/ssz/test/unit/util/errorPath.test.ts +++ b/packages/ssz/test/unit/util/errorPath.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ContainerType, ListBasicType, ListCompositeType, Type} from "../../../src/index.js"; import {byteType} from "../../utils/primitiveTypes.js"; @@ -34,7 +34,6 @@ describe.skip("error path", () => { for (const {type, value} of testCases) { it(`should print the error path deserializing ${type.constructor.name}`, () => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return expect(() => type.deserialize(Buffer.from(value, "hex"))).toThrow("v: Offset out of bounds"); }); } diff --git a/packages/ssz/test/unit/util/hexString.test.ts b/packages/ssz/test/unit/util/hexString.test.ts index c4def9cfe..4eda9a04e 100644 --- a/packages/ssz/test/unit/util/hexString.test.ts +++ b/packages/ssz/test/unit/util/hexString.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {fromHexString, toHexString} from "../../../src/index.js"; describe("util / byteArray / toHexString + fromHexString", () => { diff --git a/packages/ssz/test/unit/util/proof.test.ts b/packages/ssz/test/unit/util/proof.test.ts index 3a6a11050..4b49cf2e7 100644 --- a/packages/ssz/test/unit/util/proof.test.ts +++ b/packages/ssz/test/unit/util/proof.test.ts @@ -1,9 +1,9 @@ import {Tree} from "@chainsafe/persistent-merkle-tree"; -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ContainerNodeStructType, ContainerType, ListCompositeType} from "../../../src/index.js"; -import {bytes32Type, uint16NumType} from "../../utils/primitiveTypes.js"; -import {treePartialToJsonPaths, TreeDataTypeCode} from "../../../src/util/proof/treePartialToJsonPaths.js"; +import {TreeDataTypeCode, treePartialToJsonPaths} from "../../../src/util/proof/treePartialToJsonPaths.js"; import {treePostProcessFromProofNode} from "../../../src/util/proof/treePostProcessFromProofNode.js"; +import {bytes32Type, uint16NumType} from "../../utils/primitiveTypes.js"; describe("Create proof of Array of Objects", () => { const SimpleObject = new ContainerType({a: uint16NumType, b: uint16NumType}, {typeName: "SimpleObject"}); diff --git a/packages/ssz/test/unit/util/proofs.test.ts b/packages/ssz/test/unit/util/proofs.test.ts index b9d767ad8..7a9c389c1 100644 --- a/packages/ssz/test/unit/util/proofs.test.ts +++ b/packages/ssz/test/unit/util/proofs.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {BitVectorType, BitListType, ContainerType} from "../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {BitListType, BitVectorType, ContainerType} from "../../../src/index.js"; /** Pick bitLen to fill 2 nodes */ const bitLen2Nodes = 8 * 32 * 2; diff --git a/packages/ssz/test/utils/generateEth2Objs.ts b/packages/ssz/test/utils/generateEth2Objs.ts index c1ab58fd1..c7e9da872 100644 --- a/packages/ssz/test/utils/generateEth2Objs.ts +++ b/packages/ssz/test/utils/generateEth2Objs.ts @@ -1,7 +1,7 @@ +import {BitArray} from "../../src/index.js"; import * as sszAltair from "../lodestarTypes/altair/sszTypes.js"; +import {BeaconState, SignedContributionAndProof, SyncCommitteeMessage} from "../lodestarTypes/altair/types.js"; import {Attestation, SignedAggregateAndProof, SignedBeaconBlock, Validator} from "../lodestarTypes/phase0/types.js"; -import {SignedContributionAndProof, BeaconState, SyncCommitteeMessage} from "../lodestarTypes/altair/types.js"; -import {BitArray} from "../../src/index.js"; // Typical mainnet numbers const BITS_PER_ATTESTATION = 90; @@ -21,8 +21,8 @@ export function getRandomState(validatorCount: number): BeaconState { slashed: false, activationEligibilityEpoch: i, activationEpoch: i, - exitEpoch: Infinity, - withdrawableEpoch: Infinity, + exitEpoch: Number.POSITIVE_INFINITY, + withdrawableEpoch: Number.POSITIVE_INFINITY, }); } return state; @@ -122,8 +122,8 @@ export function getValidator(i: number): Validator { slashed: false, activationEligibilityEpoch: 1e6 + i, activationEpoch: 1e6 + i, - exitEpoch: Infinity, - withdrawableEpoch: Infinity, + exitEpoch: Number.POSITIVE_INFINITY, + withdrawableEpoch: Number.POSITIVE_INFINITY, }; } @@ -155,7 +155,7 @@ function randomBytes(bytes: number): Uint8Array { export function getOnce(fn: () => T): () => T { let value: T | null = null; - return function () { + return () => { if (value === null) { value = fn(); } diff --git a/packages/ssz/test/utils/primitiveTypes.ts b/packages/ssz/test/utils/primitiveTypes.ts index 2bf85e3bf..1aa25acad 100644 --- a/packages/ssz/test/utils/primitiveTypes.ts +++ b/packages/ssz/test/utils/primitiveTypes.ts @@ -1,5 +1,5 @@ // Adapted from https://github.com/prysmaticlabs/prysm/blob/master/shared/ssz/encode_test.go#L296 -import {UintBigintType, ByteVectorType, UintNumberType} from "../../src/index.js"; +import {ByteVectorType, UintBigintType, UintNumberType} from "../../src/index.js"; export const byteType = new UintNumberType(1); export const bytes2Type = new ByteVectorType(2); diff --git a/yarn.lock b/yarn.lock index d5bd6c6ad..615952950 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1346,6 +1346,60 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz#bbe12dca5b4ef983a0d0af4b07b9bc90ea0ababa" integrity sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA== +"@biomejs/biome@^1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/biome/-/biome-1.9.4.tgz#89766281cbc3a0aae865a7ff13d6aaffea2842bf" + integrity sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog== + optionalDependencies: + "@biomejs/cli-darwin-arm64" "1.9.4" + "@biomejs/cli-darwin-x64" "1.9.4" + "@biomejs/cli-linux-arm64" "1.9.4" + "@biomejs/cli-linux-arm64-musl" "1.9.4" + "@biomejs/cli-linux-x64" "1.9.4" + "@biomejs/cli-linux-x64-musl" "1.9.4" + "@biomejs/cli-win32-arm64" "1.9.4" + "@biomejs/cli-win32-x64" "1.9.4" + +"@biomejs/cli-darwin-arm64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz#dfa376d23a54a2d8f17133c92f23c1bf2e62509f" + integrity sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw== + +"@biomejs/cli-darwin-x64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.9.4.tgz#eafc2ce3849d385fc02238aad1ca4a73395a64d9" + integrity sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg== + +"@biomejs/cli-linux-arm64-musl@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.9.4.tgz#d780c3e01758fc90f3268357e3f19163d1f84fca" + integrity sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA== + +"@biomejs/cli-linux-arm64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.9.4.tgz#8ed1dd0e89419a4b66a47f95aefb8c46ae6041c9" + integrity sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g== + +"@biomejs/cli-linux-x64-musl@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz#f36982b966bd671a36671e1de4417963d7db15fb" + integrity sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg== + +"@biomejs/cli-linux-x64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz#a0a7f56680c76b8034ddc149dbf398bdd3a462e8" + integrity sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg== + +"@biomejs/cli-win32-arm64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.9.4.tgz#e2ef4e0084e76b7e26f0fc887c5ef1265ea56200" + integrity sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg== + +"@biomejs/cli-win32-x64@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@biomejs/cli-win32-x64/-/cli-win32-x64-1.9.4.tgz#4c7afa90e3970213599b4095e62f87e5972b2340" + integrity sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA== + "@bundled-es-modules/cookie@^2.0.1": version "2.0.1" resolved "https://registry.yarnpkg.com/@bundled-es-modules/cookie/-/cookie-2.0.1.tgz#b41376af6a06b3e32a15241d927b840a9b4de507"