diff --git a/nx.json b/nx.json index 816559d48..3729decc9 100644 --- a/nx.json +++ b/nx.json @@ -17,6 +17,7 @@ "prisma:generate": { "inputs": [ "{projectRoot}/package.json", + "{projectRoot}/prisma/*", "{projectRoot}/prisma/**/*" ] }, diff --git a/package-lock.json b/package-lock.json index 9638f6787..e080255ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1144,6 +1144,8 @@ }, "node_modules/@ioredis/commands": { "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz", + "integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==", "license": "MIT", "peer": true }, @@ -2534,6 +2536,8 @@ }, "node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64": { "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-arm64/-/msgpackr-extract-darwin-arm64-3.0.3.tgz", + "integrity": "sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw==", "cpu": [ "arm64" ], @@ -2544,6 +2548,76 @@ ], "peer": true }, + "node_modules/@msgpackr-extract/msgpackr-extract-darwin-x64": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-x64/-/msgpackr-extract-darwin-x64-3.0.3.tgz", + "integrity": "sha512-mdzd3AVzYKuUmiWOQ8GNhl64/IoFGol569zNRdkLReh6LRLHOXxU4U8eq0JwaD8iFHdVGqSy4IjFL4reoWCDFw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true + }, + "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm/-/msgpackr-extract-linux-arm-3.0.3.tgz", + "integrity": "sha512-fg0uy/dG/nZEXfYilKoRe7yALaNmHoYeIoJuJ7KJ+YyU2bvY8vPv27f7UKhGRpY6euFYqEVhxCFZgAUNQBM3nw==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm64": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm64/-/msgpackr-extract-linux-arm64-3.0.3.tgz", + "integrity": "sha512-YxQL+ax0XqBJDZiKimS2XQaf+2wDGVa1enVRGzEvLLVFeqa5kx2bWbtcSXgsxjQB7nRqqIGFIcLteF/sHeVtQg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@msgpackr-extract/msgpackr-extract-linux-x64": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-x64/-/msgpackr-extract-linux-x64-3.0.3.tgz", + "integrity": "sha512-cvwNfbP07pKUfq1uH+S6KJ7dT9K8WOE4ZiAcsrSes+UY55E/0jLYc+vq+DO7jlmqRb5zAggExKm0H7O/CBaesg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@msgpackr-extract/msgpackr-extract-win32-x64": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-win32-x64/-/msgpackr-extract-win32-x64-3.0.3.tgz", + "integrity": "sha512-x0fWaQtYp4E6sktbsdAqnehxDgEc/VwM7uLsRCYWaiGu0ykYdZPiS8zCWdnjHwyiumousxfBm4SO31eXqwEZhQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "license": "MIT", @@ -4674,10 +4748,11 @@ } }, "node_modules/@prisma/client": { - "version": "5.21.1", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.21.1.tgz", - "integrity": "sha512-3n+GgbAZYjaS/k0M03yQsQfR1APbr411r74foknnsGpmhNKBG49VuUkxIU6jORgvJPChoD4WC4PqoHImN1FP0w==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.22.0.tgz", + "integrity": "sha512-M0SVXfyHnQREBKxCgyo7sffrKttwE6R8PMq330MIUF0pTwjUhLbW84pFDlf06B27XyCR++VtjugEnIHdr07SVA==", "hasInstallScript": true, + "license": "Apache-2.0", "engines": { "node": ">=16.13" }, @@ -4691,84 +4766,93 @@ } }, "node_modules/@prisma/debug": { - "version": "5.21.1", - "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.21.1.tgz", - "integrity": "sha512-uY8SAhcnORhvgtOrNdvWS98Aq/nkQ9QDUxrWAgW8XrCZaI3j2X7zb7Xe6GQSh6xSesKffFbFlkw0c2luHQviZA==" + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.22.0.tgz", + "integrity": "sha512-AUt44v3YJeggO2ZU5BkXI7M4hu9BF2zzH2iF2V5pyXT/lRTyWiElZ7It+bRH1EshoMRxHgpYg4VB6rCM+mG5jQ==", + "license": "Apache-2.0" }, "node_modules/@prisma/engines": { - "version": "5.21.1", - "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.21.1.tgz", - "integrity": "sha512-hGVTldUkIkTwoV8//hmnAAiAchi4oMEKD3aW5H2RrnI50tTdwza7VQbTTAyN3OIHWlK5DVg6xV7X8N/9dtOydA==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.22.0.tgz", + "integrity": "sha512-UNjfslWhAt06kVL3CjkuYpHAWSO6L4kDCVPegV6itt7nD1kSJavd3vhgAEhjglLJJKEdJ7oIqDJ+yHk6qO8gPA==", "hasInstallScript": true, + "license": "Apache-2.0", "dependencies": { - "@prisma/debug": "5.21.1", - "@prisma/engines-version": "5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36", - "@prisma/fetch-engine": "5.21.1", - "@prisma/get-platform": "5.21.1" + "@prisma/debug": "5.22.0", + "@prisma/engines-version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", + "@prisma/fetch-engine": "5.22.0", + "@prisma/get-platform": "5.22.0" } }, "node_modules/@prisma/engines-version": { - "version": "5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36.tgz", - "integrity": "sha512-qvnEflL0//lh44S/T9NcvTMxfyowNeUxTunPcDfKPjyJNrCNf2F1zQLcUv5UHAruECpX+zz21CzsC7V2xAeM7Q==" + "version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2.tgz", + "integrity": "sha512-2PTmxFR2yHW/eB3uqWtcgRcgAbG1rwG9ZriSvQw+nnb7c4uCr3RAcGMb6/zfE88SKlC1Nj2ziUvc96Z379mHgQ==", + "license": "Apache-2.0" }, "node_modules/@prisma/fetch-engine": { - "version": "5.21.1", - "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.21.1.tgz", - "integrity": "sha512-70S31vgpCGcp9J+mh/wHtLCkVezLUqe/fGWk3J3JWZIN7prdYSlr1C0niaWUyNK2VflLXYi8kMjAmSxUVq6WGQ==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.22.0.tgz", + "integrity": "sha512-bkrD/Mc2fSvkQBV5EpoFcZ87AvOgDxbG99488a5cexp5Ccny+UM6MAe/UFkUC0wLYD9+9befNOqGiIJhhq+HbA==", + "license": "Apache-2.0", "dependencies": { - "@prisma/debug": "5.21.1", - "@prisma/engines-version": "5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36", - "@prisma/get-platform": "5.21.1" + "@prisma/debug": "5.22.0", + "@prisma/engines-version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", + "@prisma/get-platform": "5.22.0" } }, "node_modules/@prisma/generator-helper": { - "version": "5.21.1", - "resolved": "https://registry.npmjs.org/@prisma/generator-helper/-/generator-helper-5.21.1.tgz", - "integrity": "sha512-56+FLaNGO7uKIEjN5asV7L0cAWqTc+IoyFbtafYnzfvBS3HURgT+l9UGHrHfPO5EWFiot3my3UOJ/hGZfhNPbA==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@prisma/generator-helper/-/generator-helper-5.22.0.tgz", + "integrity": "sha512-LwqcBQ5/QsuAaLNQZAIVIAJDJBMjHwMwn16e06IYx/3Okj/xEEfw9IvrqB2cJCl3b2mCBlh3eVH0w9WGmi4aHg==", + "license": "Apache-2.0", "peer": true, "dependencies": { - "@prisma/debug": "5.21.1" + "@prisma/debug": "5.22.0" } }, "node_modules/@prisma/get-platform": { - "version": "5.21.1", - "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.21.1.tgz", - "integrity": "sha512-sRxjL3Igst3ct+e8ya/x//cDXmpLbZQ5vfps2N4tWl4VGKQAmym77C/IG/psSMsQKszc8uFC/q1dgmKFLUgXZQ==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.22.0.tgz", + "integrity": "sha512-pHhpQdr1UPFpt+zFfnPazhulaZYCUqeIcPpJViYoq9R+D/yw4fjE+CtnsnKzPYm0ddUbeXUzjGVGIRVgPDCk4Q==", + "license": "Apache-2.0", "dependencies": { - "@prisma/debug": "5.21.1" + "@prisma/debug": "5.22.0" } }, "node_modules/@prisma/internals": { - "version": "5.21.1", - "resolved": "https://registry.npmjs.org/@prisma/internals/-/internals-5.21.1.tgz", - "integrity": "sha512-XCjJUUDBwT0ioLrTfUKA/YsVs5gtWtMisxRssGS5tgqVaVzc8XEY01avtYIzyhz8RDLn7QlecTQGHW+5J9+w6Q==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@prisma/internals/-/internals-5.22.0.tgz", + "integrity": "sha512-Rsjw2ARB9VQzDczzEimUriSBdXmYG/Z5tNRer2IEwof/O8Q6A9cqV3oNVUpJ52TgWfQqMAq5K/KEf8LvvYLLOw==", + "license": "Apache-2.0", "peer": true, "dependencies": { - "@prisma/debug": "5.21.1", - "@prisma/engines": "5.21.1", - "@prisma/fetch-engine": "5.21.1", - "@prisma/generator-helper": "5.21.1", - "@prisma/get-platform": "5.21.1", - "@prisma/prisma-schema-wasm": "5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36", - "@prisma/schema-files-loader": "5.21.1", + "@prisma/debug": "5.22.0", + "@prisma/engines": "5.22.0", + "@prisma/fetch-engine": "5.22.0", + "@prisma/generator-helper": "5.22.0", + "@prisma/get-platform": "5.22.0", + "@prisma/prisma-schema-wasm": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", + "@prisma/schema-files-loader": "5.22.0", "arg": "5.0.2", "prompts": "2.4.2" } }, "node_modules/@prisma/prisma-schema-wasm": { - "version": "5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36", - "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36.tgz", - "integrity": "sha512-JJnZ7A0CSW4SNFSWe2/GexJ/Z5s69+3UqbsBuGxJe7EQyVgw/hmskmhFmM4gccihh9PA2hlDip5kmraAfO7vSA==", + "version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", + "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2.tgz", + "integrity": "sha512-WPNB7SgTxF/rSHMa5o5/9AIINy4oVnRhvUkRzqR4Nfp8Hu9Q2IyUptxuiDuzRVJdjJBRi/U82sHTxyiD3oBBhQ==", + "license": "Apache-2.0", "peer": true }, "node_modules/@prisma/schema-files-loader": { - "version": "5.21.1", - "resolved": "https://registry.npmjs.org/@prisma/schema-files-loader/-/schema-files-loader-5.21.1.tgz", - "integrity": "sha512-rcZgI4rSq5tlieWQ5e+AfyjquwQ+d2vCecvbf9qvfcvs/Nw5FbjAPTLEx9l4g/iW4qgc0CTPLr19azD3npwHQw==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/@prisma/schema-files-loader/-/schema-files-loader-5.22.0.tgz", + "integrity": "sha512-/TNAJXvMSk6mCgZa+gIBM6sp5OUQBnb7rbjiSQm88gvcSibxEuKkVV/2pT3RmQpEAn1yiabvS4+dOvIotYe3ww==", + "license": "Apache-2.0", "peer": true, "dependencies": { - "@prisma/prisma-schema-wasm": "5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36", + "@prisma/prisma-schema-wasm": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", "fs-extra": "11.1.1" } }, @@ -4776,6 +4860,7 @@ "version": "11.1.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.1.tgz", "integrity": "sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==", + "license": "MIT", "peer": true, "dependencies": { "graceful-fs": "^4.2.0", @@ -5187,6 +5272,7 @@ "version": "0.24.0", "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.24.0.tgz", "integrity": "sha512-c1xMmNHWpNselmpIqursHeOHHBTIsJLbB+NuovbTTRCNiTLEr/U9dbJ8qy0jd/O2x5pc3seWuOUN5R2IoOTp8A==", + "license": "MIT", "peer": true, "dependencies": { "fast-glob": "^3.3.2", @@ -5199,6 +5285,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "license": "MIT", "peer": true, "bin": { "mkdirp": "dist/cjs/src/bin.js" @@ -5404,6 +5491,7 @@ "version": "1.3.9", "resolved": "https://registry.npmjs.org/@types/graphql-fields/-/graphql-fields-1.3.9.tgz", "integrity": "sha512-HynTnp1HrE58uYcFcAK5UOfdrHSOIHDLCjvMU4yCmQLMj21uo7ZiZqnDGrD27pgCgHH5a1e8GYNK98Ndmma7ig==", + "license": "MIT", "peer": true, "dependencies": { "graphql": "*" @@ -6328,6 +6416,7 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", + "license": "MIT", "peer": true }, "node_modules/argparse": { @@ -6804,6 +6893,8 @@ }, "node_modules/blakejs": { "version": "1.2.1", + "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", + "integrity": "sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==", "license": "MIT", "peer": true }, @@ -6972,7 +7063,9 @@ } }, "node_modules/bullmq": { - "version": "3.15.8", + "version": "3.16.2", + "resolved": "https://registry.npmjs.org/bullmq/-/bullmq-3.16.2.tgz", + "integrity": "sha512-wZIsCdI2H6lza6GdePquCWbrslhYHS7GnDPpP0hzoHkvKiBOt/5jHcsHcHhJi/fob+dfo8dazWKTSLlGLFFqUw==", "license": "MIT", "peer": true, "dependencies": { @@ -6988,6 +7081,9 @@ }, "node_modules/bullmq/node_modules/glob": { "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", "license": "ISC", "peer": true, "dependencies": { @@ -7006,6 +7102,8 @@ }, "node_modules/bullmq/node_modules/minimatch": { "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "license": "ISC", "peer": true, "dependencies": { @@ -7017,6 +7115,8 @@ }, "node_modules/bullmq/node_modules/uuid": { "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" @@ -7522,6 +7622,7 @@ "version": "13.0.3", "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-13.0.3.tgz", "integrity": "sha512-Oofo0pq3IKnsFtuHqSF7TqBfr71aeyZDVJ0HpmqB7FBM2qEigL0iPONSCZSO9pE9dZTAxANe5XHG9Uy0YMv8cg==", + "license": "MIT", "peer": true }, "node_modules/code-excerpt": { @@ -8081,6 +8182,8 @@ }, "node_modules/cron-parser": { "version": "4.9.0", + "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-4.9.0.tgz", + "integrity": "sha512-p0SaNjrHOnQeR8/VnfGbmg9te2kfyYSQ7Sc/j/6DtPL3JQvKxmjO9TSjNFpujqV3vEYYBvNNvXSxzyksBWAx1Q==", "license": "MIT", "peer": true, "dependencies": { @@ -8392,6 +8495,8 @@ }, "node_modules/denque": { "version": "2.1.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", + "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==", "license": "Apache-2.0", "peer": true, "engines": { @@ -8446,6 +8551,8 @@ }, "node_modules/detect-libc": { "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", "license": "Apache-2.0", "optional": true, "peer": true, @@ -10601,6 +10708,7 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/graphql-fields/-/graphql-fields-2.0.3.tgz", "integrity": "sha512-x3VE5lUcR4XCOxPIqaO4CE+bTK8u6gVouOdpQX9+EKHr+scqtK5Pp/l8nIGqIpN1TUlkKE6jDCCycm/WtLRAwA==", + "license": "MIT", "peer": true }, "node_modules/graphql-query-complexity": { @@ -11914,7 +12022,9 @@ } }, "node_modules/ioredis": { - "version": "5.4.1", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.5.0.tgz", + "integrity": "sha512-7CutT89g23FfSa8MDoIFs2GYYa0PaNiW/OrT+nRyjRXHDZd17HmIgy+reOQ/yhh72NznNjGuS8kbCAcA4Ro4mw==", "license": "MIT", "peer": true, "dependencies": { @@ -12402,6 +12512,8 @@ }, "node_modules/isomorphic-fetch": { "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz", + "integrity": "sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==", "license": "MIT", "peer": true, "dependencies": { @@ -14210,6 +14322,8 @@ }, "node_modules/js-sha256": { "version": "0.9.0", + "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", + "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==", "license": "MIT", "peer": true }, @@ -15281,6 +15395,8 @@ }, "node_modules/lodash.defaults": { "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", + "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==", "license": "MIT", "peer": true }, @@ -15297,6 +15413,8 @@ }, "node_modules/lodash.isarguments": { "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==", "license": "MIT", "peer": true }, @@ -15563,7 +15681,9 @@ "license": "MIT" }, "node_modules/luxon": { - "version": "3.4.4", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.5.0.tgz", + "integrity": "sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==", "license": "MIT", "peer": true, "engines": { @@ -16474,7 +16594,9 @@ "license": "MIT" }, "node_modules/msgpackr": { - "version": "1.10.2", + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-1.11.2.tgz", + "integrity": "sha512-F9UngXRlPyWCDEASDpTf6c9uNhGPTqnTeLVt7bN+bU1eajoR/8V9ys2BRaV5C/e5ihE6sJ9uPIKaYt6bFuO32g==", "license": "MIT", "peer": true, "optionalDependencies": { @@ -16483,6 +16605,8 @@ }, "node_modules/msgpackr-extract": { "version": "3.0.3", + "resolved": "https://registry.npmjs.org/msgpackr-extract/-/msgpackr-extract-3.0.3.tgz", + "integrity": "sha512-P0efT1C9jIdVRefqjzOQ9Xml57zpOXnIuS+csaB4MdZbTdmGDLo8XhzBG1N7aO11gKDDkJvBLULeFTo46wwreA==", "hasInstallScript": true, "license": "MIT", "optional": true, @@ -16628,6 +16752,8 @@ }, "node_modules/node-gyp-build-optional-packages": { "version": "5.2.2", + "resolved": "https://registry.npmjs.org/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.2.2.tgz", + "integrity": "sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==", "license": "MIT", "optional": true, "peer": true, @@ -17745,6 +17871,8 @@ }, "node_modules/o1js/node_modules/cachedir": { "version": "2.4.0", + "resolved": "https://registry.npmjs.org/cachedir/-/cachedir-2.4.0.tgz", + "integrity": "sha512-9EtFOZR8g22CL7BWjJ9BUx1+A/djkofnyW3aOXZORNW2kxoUpx2h+uN2cOqwPmFhnpVmxg+KW2OjOSgChTEvsQ==", "license": "MIT", "peer": true, "engines": { @@ -18434,6 +18562,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", + "license": "MIT", "peer": true }, "node_modules/path-exists": { @@ -18630,6 +18759,7 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "license": "MIT", "peer": true, "engines": { "node": ">=4" @@ -18750,12 +18880,13 @@ } }, "node_modules/prisma": { - "version": "5.21.1", - "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.21.1.tgz", - "integrity": "sha512-PB+Iqzld/uQBPaaw2UVIk84kb0ITsLajzsxzsadxxl54eaU5Gyl2/L02ysivHxK89t7YrfQJm+Ggk37uvM70oQ==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.22.0.tgz", + "integrity": "sha512-vtpjW3XuYCSnMsNVBjLMNkTj6OZbudcPPTPYHqX0CJfpcdWciI1dM8uHETwmDxxiqEwCIE6WvXucWUetJgfu/A==", "hasInstallScript": true, + "license": "Apache-2.0", "dependencies": { - "@prisma/engines": "5.21.1" + "@prisma/engines": "5.22.0" }, "bin": { "prisma": "build/index.js" @@ -19440,6 +19571,8 @@ }, "node_modules/redis-errors": { "version": "1.2.0", + "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", + "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==", "license": "MIT", "peer": true, "engines": { @@ -19448,6 +19581,8 @@ }, "node_modules/redis-parser": { "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", + "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==", "license": "MIT", "peer": true, "dependencies": { @@ -20340,6 +20475,8 @@ }, "node_modules/standard-as-callback": { "version": "2.1.0", + "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", + "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==", "license": "MIT", "peer": true }, @@ -20908,6 +21045,7 @@ "version": "23.0.0", "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-23.0.0.tgz", "integrity": "sha512-FcvFx7a9E8TUe6T3ShihXJLiJOiqyafzFKUO4aqIHDUCIvADdGNShcbc2W5PMr3LerXRv7mafvFZ9lRENxJmug==", + "license": "MIT", "peer": true, "dependencies": { "@ts-morph/common": "~0.24.0", @@ -21050,6 +21188,8 @@ }, "node_modules/tsyringe": { "version": "4.8.0", + "resolved": "https://registry.npmjs.org/tsyringe/-/tsyringe-4.8.0.tgz", + "integrity": "sha512-YB1FG+axdxADa3ncEtRnQCFq/M0lALGLxSZeVNbTU8NqhOVc51nnv2CISTcvc1kyv6EGPtXVr0v6lWeDxiijOA==", "license": "MIT", "peer": true, "dependencies": { @@ -21061,6 +21201,8 @@ }, "node_modules/tsyringe/node_modules/tslib": { "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "license": "0BSD", "peer": true }, @@ -21384,6 +21526,7 @@ "version": "0.28.0", "resolved": "https://registry.npmjs.org/typegraphql-prisma/-/typegraphql-prisma-0.28.0.tgz", "integrity": "sha512-LMTsYEAteeXhnJRmH2sBWarR8Jc9Um13mtSpi8Vh6G8QUTlp5tRfqMjd+Fw06HS6SBshU6NilZJlsPaz26SQCw==", + "license": "MIT", "peer": true, "dependencies": { "@prisma/generator-helper": "^5.18.0", @@ -21805,6 +21948,8 @@ }, "node_modules/whatwg-fetch": { "version": "3.6.20", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz", + "integrity": "sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==", "license": "MIT", "peer": true }, @@ -22385,7 +22530,7 @@ "dependencies": { "@envelop/extended-validation": "^4.1.0", "@inkjs/ui": "^1.0.0", - "@prisma/client": "^5.18.0", + "@prisma/client": "^5.22.0", "@types/yargs": "^17.0.29", "figlet": "^1.7.0", "ink": "^4.4.1", @@ -22475,9 +22620,9 @@ "version": "0.1.1-develop.833+397881ed", "license": "MIT", "dependencies": { - "@prisma/client": "^5.18.0", + "@prisma/client": "^5.22.0", "lodash": "^4.17.21", - "prisma": "^5.18.0", + "prisma": "^5.22.0", "redis": "^4.6.12", "reflect-metadata": "^0.1.13" }, @@ -22500,7 +22645,7 @@ "license": "MIT", "dependencies": { "@inkjs/ui": "^1.0.0", - "@prisma/client": "^5.19.1", + "@prisma/client": "^5.22.0", "@types/yargs": "^17.0.29", "figlet": "^1.7.0", "ink": "^4.4.1", diff --git a/packages/indexer/package.json b/packages/indexer/package.json index 76d942113..fe42eeef9 100644 --- a/packages/indexer/package.json +++ b/packages/indexer/package.json @@ -22,7 +22,7 @@ "dependencies": { "@envelop/extended-validation": "^4.1.0", "@inkjs/ui": "^1.0.0", - "@prisma/client": "^5.18.0", + "@prisma/client": "^5.22.0", "@types/yargs": "^17.0.29", "figlet": "^1.7.0", "ink": "^4.4.1", diff --git a/packages/persistance/package.json b/packages/persistance/package.json index 1d2e7d640..235f08cb5 100644 --- a/packages/persistance/package.json +++ b/packages/persistance/package.json @@ -20,9 +20,9 @@ "access": "public" }, "dependencies": { - "@prisma/client": "^5.18.0", + "@prisma/client": "^5.22.0", "lodash": "^4.17.21", - "prisma": "^5.18.0", + "prisma": "^5.22.0", "redis": "^4.6.12", "reflect-metadata": "^0.1.13" }, diff --git a/packages/persistance/prisma/migrations/20250129151707_state_masking/migration.sql b/packages/persistance/prisma/migrations/20250129151707_state_masking/migration.sql new file mode 100644 index 000000000..bb4f4821c --- /dev/null +++ b/packages/persistance/prisma/migrations/20250129151707_state_masking/migration.sql @@ -0,0 +1,29 @@ +/* + Warnings: + + - The primary key for the `State` table will be changed. If it partially fails, the table could be left without primary key constraint. + - You are about to drop the column `mask` on the `State` table. All the data in the column will be lost. + - Added the required column `maskId` to the `State` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +TRUNCATE TABLE "State"; +ALTER TABLE "State" DROP CONSTRAINT "State_pkey", +DROP COLUMN "mask", +ADD COLUMN "maskId" INTEGER NOT NULL, +ADD CONSTRAINT "State_pkey" PRIMARY KEY ("path", "maskId"); + +-- CreateTable +CREATE TABLE "Mask" ( + "id" SERIAL NOT NULL, + "name" VARCHAR(256) NOT NULL, + "parent" INTEGER, + + CONSTRAINT "Mask_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "State" ADD CONSTRAINT "State_maskId_fkey" FOREIGN KEY ("maskId") REFERENCES "Mask"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Mask" ADD CONSTRAINT "Mask_parent_fkey" FOREIGN KEY ("parent") REFERENCES "Mask"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/packages/persistance/prisma/schema.prisma b/packages/persistance/prisma/schema.prisma index 58c214477..24ce7059a 100644 --- a/packages/persistance/prisma/schema.prisma +++ b/packages/persistance/prisma/schema.prisma @@ -3,9 +3,6 @@ generator client { provider = "prisma-client-js" - // output = "./../node_modules/.prisma/client" - // Enable after upgrade to 5.9.0 - // previewFeatures = ["relationJoins"] } datasource db { @@ -16,9 +13,21 @@ datasource db { model State { path Decimal @db.Decimal(78, 0) values Decimal[] @db.Decimal(78, 0) - mask String @db.VarChar(256) - @@id([path, mask]) + maskId Int + mask Mask @relation(fields: [maskId], references: [id]) + + @@id([path, maskId]) +} + +model Mask { + id Int @id @default(autoincrement()) + name String @db.VarChar(256) + + parent Int? + parentMask Mask? @relation("ParentMasks", fields: [parent], references: [id]) + children Mask[] @relation("ParentMasks") + State State[] } model Transaction { diff --git a/packages/persistance/src/PrismaDatabaseConnection.ts b/packages/persistance/src/PrismaDatabaseConnection.ts index 234f7977a..07b56f6db 100644 --- a/packages/persistance/src/PrismaDatabaseConnection.ts +++ b/packages/persistance/src/PrismaDatabaseConnection.ts @@ -69,9 +69,6 @@ export class PrismaDatabaseConnection blockStorage: { useClass: PrismaBlockStorage, }, - unprovenStateService: { - useFactory: () => new PrismaStateService(this, this.tracer, "block"), - }, settlementStorage: { useClass: PrismaSettlementStorage, }, @@ -81,6 +78,9 @@ export class PrismaDatabaseConnection transactionStorage: { useClass: PrismaTransactionStorage, }, + unprovenStateService: { + useFactory: () => new PrismaStateService(this, this.tracer, "block"), + }, }; } @@ -95,6 +95,7 @@ export class PrismaDatabaseConnection "Settlement", "IncomingMessageBatch", "IncomingMessageBatchTransaction", + "Mask", ]; await this.prismaClient.$transaction( diff --git a/packages/persistance/src/services/prisma/PrismaStateService.ts b/packages/persistance/src/services/prisma/PrismaStateService.ts index 73881127d..2a0d00f70 100644 --- a/packages/persistance/src/services/prisma/PrismaStateService.ts +++ b/packages/persistance/src/services/prisma/PrismaStateService.ts @@ -11,6 +11,10 @@ import { injectable } from "tsyringe"; import type { PrismaConnection } from "../../PrismaDatabaseConnection"; +import { readState } from "./sql/readState"; +import { deleteCollisionsFromParentMask } from "./sql/deleteCollisionsFromParentMask"; +import { mergeIntoParent } from "./sql/mergeIntoParent"; + // We need to create a correctly configured Decimal constructor // with our parameters const Decimal = Prisma.Decimal.clone({ @@ -21,27 +25,63 @@ const Decimal = Prisma.Decimal.clone({ export class PrismaStateService implements AsyncStateService { private cache: StateEntry[] = []; + private maskId?: number; + /** * @param connection - * @param mask A indicator to which masking level the values belong * @param tracer + * @param mask A indicator to which masking level the values belong. + * This name has to be unique + * @param parent */ public constructor( private readonly connection: PrismaConnection, public readonly tracer: Tracer, - private readonly mask: string + private readonly mask: string, + private readonly parent?: number ) {} + private async getMaskId(): Promise { + if (this.maskId === undefined) { + this.maskId = await this.initializeMask(this.mask, this.parent); + } + return this.maskId; + } + + private async initializeMask(mask: string, parent?: number): Promise { + const { prismaClient } = this.connection; + + const found = await prismaClient.mask.findFirst({ + where: { + name: mask, + parent, + }, + }); + + if (found === null) { + const createdMask = await prismaClient.mask.create({ + data: { + parent, + name: mask, + }, + }); + return createdMask.id; + } + return found.id; + } + @trace("db.state.commit") public async commit(): Promise { const { prismaClient } = this.connection; + const maskId = await this.getMaskId(); + const data = this.cache .filter((entry) => entry.value !== undefined) .map((entry) => ({ path: new Decimal(entry.key.toString()), values: entry.value!.map((field) => new Decimal(field.toString())), - mask: this.mask, + maskId, })); await prismaClient.state.deleteMany({ @@ -49,7 +89,7 @@ export class PrismaStateService implements AsyncStateService { path: { in: this.cache.map((x) => new Decimal(x.key.toString())), }, - mask: this.mask, + maskId, }, }); await prismaClient.state.createMany({ @@ -60,23 +100,20 @@ export class PrismaStateService implements AsyncStateService { } public async getMany(keys: Field[]): Promise { - const records = await this.connection.prismaClient.state.findMany({ - where: { - AND: [ - { - path: { - in: keys.map((key) => new Decimal(key.toString())), - }, - }, - { - mask: this.mask, - }, - ], - }, - }); + const maskId = await this.getMaskId(); + const paths = keys.map((key) => new Decimal(key.toString())); + + const records: { + path: Prisma.Decimal; + values: Prisma.Decimal[] | null; + }[] = await this.connection.prismaClient.$queryRaw( + readState(maskId, paths) + ); + return records.map((record) => ({ key: Field(record.path.toFixed()), - value: record.values.map((x) => Field(x.toFixed())), + // TODO Figure out why that is nullable + value: record.values?.map((x) => Field(x.toFixed())) ?? [], })); } @@ -92,4 +129,62 @@ export class PrismaStateService implements AsyncStateService { public writeStates(entries: StateEntry[]): void { this.cache.push(...entries); } + + public async createMask(name: string): Promise { + const maskId = await this.getMaskId(); + return new PrismaStateService(this.connection, this.tracer, name, maskId); + } + + public async mergeIntoParent(): Promise { + const maskId = await this.getMaskId(); + + const client = this.connection.prismaClient; + + if (this.parent !== undefined) { + // Rough strategy here: + // 1. Delete all entries that are bound to be overwritten from the parent mask + // 2. Update this mask's entries to parent mask id + // 3. Re-link all children of this mask to this mask's parent + // 4. Delete mask + + await client.$transaction([ + client.$queryRaw(deleteCollisionsFromParentMask(maskId)), + // MergeIntoParent could be a prisma query, but it isn't, because eventually, + // this Service should be stateless, therefore the parentId wouldn't be on hand + // anymore, so we need to inline it's retrieval into the query + client.$queryRaw(mergeIntoParent(maskId)), + client.mask.updateMany({ + where: { + parent: maskId, + }, + data: { + parent: this.parent, + }, + }), + client.mask.delete({ + where: { + id: maskId, + }, + }), + ]); + } else { + throw new Error("Can't merge into parent without a parent"); + } + } + + public async drop(): Promise { + const maskId = await this.getMaskId(); + + await this.connection.prismaClient.state.deleteMany({ + where: { + maskId, + }, + }); + + await this.connection.prismaClient.mask.delete({ + where: { + id: maskId, + }, + }); + } } diff --git a/packages/persistance/src/services/prisma/sql/deleteCollisionsFromParentMask.ts b/packages/persistance/src/services/prisma/sql/deleteCollisionsFromParentMask.ts new file mode 100644 index 000000000..c711180f5 --- /dev/null +++ b/packages/persistance/src/services/prisma/sql/deleteCollisionsFromParentMask.ts @@ -0,0 +1,24 @@ +import { Prisma } from "@prisma/client"; + +/* + DELETE PATHS FROM PARENT MASK + + Strategy on this query: + 1. Find the mask we are interested in, as a record with the id and it's parent id + 2. Select all paths that exist on that mask + 3. Delete all records whose mask is the parent of (1), and whose path is contained in (2) + */ + +export function deleteCollisionsFromParentMask(maskId: number) { + return Prisma.sql` + WITH mask AS ( + SELECT id, parent FROM "Mask" m WHERE m.id = ${maskId}), + paths AS ( + SELECT path FROM "State" s + JOIN mask m on s."maskId" = m.id + ) + DELETE FROM "State" s + WHERE s."maskId" IN (SELECT parent FROM mask) + AND s.path IN (SELECT path FROM paths) + `; +} diff --git a/packages/persistance/src/services/prisma/sql/mergeIntoParent.ts b/packages/persistance/src/services/prisma/sql/mergeIntoParent.ts new file mode 100644 index 000000000..17e752d7e --- /dev/null +++ b/packages/persistance/src/services/prisma/sql/mergeIntoParent.ts @@ -0,0 +1,16 @@ +import { Prisma } from "@prisma/client"; + +/* +Strategy: + 1. Find the mask we are interested in, as a record with the id and it's parent id + 2. Update the maskId to the masks parent for all the entries of that particular mask +*/ + +export function mergeIntoParent(maskId: number) { + return Prisma.sql` + WITH mask AS ( + SELECT id, parent FROM "Mask" m WHERE m.id = ${maskId}) + UPDATE "State" SET "maskId" = (SELECT parent FROM mask) + WHERE "maskId" = (SELECT id FROM mask) + `; +} diff --git a/packages/persistance/src/services/prisma/sql/readState.ts b/packages/persistance/src/services/prisma/sql/readState.ts new file mode 100644 index 000000000..f39306d85 --- /dev/null +++ b/packages/persistance/src/services/prisma/sql/readState.ts @@ -0,0 +1,16 @@ +import { Prisma } from "@prisma/client"; + +export function readState(maskId: number, paths: Prisma.Decimal[]) { + return Prisma.sql` + WITH RECURSIVE find_masks(id, parent) AS ( + SELECT m.id, m.parent FROM "Mask" m WHERE m.id = ${maskId} + UNION ALL + SELECT s.id, s.parent FROM "Mask" s, find_masks f + WHERE f.parent = s.id + ) + SELECT distinct on (state.path) state.path, state.values FROM find_masks + JOIN "State" state ON state."maskId" = find_masks.id + WHERE state.path = ANY(${paths}) + ORDER BY state.path, state."maskId" DESC; + `; +} diff --git a/packages/processor/package.json b/packages/processor/package.json index 63a5a9848..2be7e77bf 100644 --- a/packages/processor/package.json +++ b/packages/processor/package.json @@ -24,7 +24,7 @@ "main": "dist/index.js", "dependencies": { "@inkjs/ui": "^1.0.0", - "@prisma/client": "^5.19.1", + "@prisma/client": "^5.22.0", "@types/yargs": "^17.0.29", "figlet": "^1.7.0", "ink": "^4.4.1", diff --git a/packages/protocol/src/index.ts b/packages/protocol/src/index.ts index d161590a2..5c34b007e 100644 --- a/packages/protocol/src/index.ts +++ b/packages/protocol/src/index.ts @@ -39,7 +39,7 @@ export * from "./state/context/RuntimeMethodExecutionContext"; export * from "./state/protocol/ProtocolState"; export * from "./state/State"; export * from "./state/StateMap"; -export * from "./state/StateService"; +export * from "./state/SimpleAsyncStateService"; export * from "./state/StateServiceProvider"; export * from "./state/assert/assert"; export * from "./settlement/contracts/authorizations/ContractAuthorization"; diff --git a/packages/protocol/src/protocol/Protocol.ts b/packages/protocol/src/protocol/Protocol.ts index 8d7c9e021..e3ec89f32 100644 --- a/packages/protocol/src/protocol/Protocol.ts +++ b/packages/protocol/src/protocol/Protocol.ts @@ -13,7 +13,7 @@ import { DependencyContainer, Lifecycle } from "tsyringe"; import { BlockProvable } from "../prover/block/BlockProvable"; import { StateTransitionProvable } from "../prover/statetransition/StateTransitionProvable"; import { StateServiceProvider } from "../state/StateServiceProvider"; -import { SimpleAsyncStateService } from "../state/StateService"; +import { SimpleAsyncStateService } from "../state/SimpleAsyncStateService"; import { NoopBlockHook } from "../hooks/NoopBlockHook"; import { BlockHeightHook } from "../hooks/BlockHeightHook"; import { LastStateRootBlockHook } from "../hooks/LastStateRootBlockHook"; diff --git a/packages/protocol/src/protocol/ProtocolEnvironment.ts b/packages/protocol/src/protocol/ProtocolEnvironment.ts index f6a291de7..5203694b1 100644 --- a/packages/protocol/src/protocol/ProtocolEnvironment.ts +++ b/packages/protocol/src/protocol/ProtocolEnvironment.ts @@ -1,6 +1,6 @@ import { AreProofsEnabled } from "@proto-kit/common"; -import { SimpleAsyncStateService } from "../state/StateService"; +import { SimpleAsyncStateService } from "../state/SimpleAsyncStateService"; import { StateServiceProvider } from "../state/StateServiceProvider"; export interface ProtocolEnvironment { diff --git a/packages/protocol/src/state/StateService.ts b/packages/protocol/src/state/SimpleAsyncStateService.ts similarity index 100% rename from packages/protocol/src/state/StateService.ts rename to packages/protocol/src/state/SimpleAsyncStateService.ts diff --git a/packages/protocol/src/state/StateServiceProvider.ts b/packages/protocol/src/state/StateServiceProvider.ts index d39fea612..40d54717b 100644 --- a/packages/protocol/src/state/StateServiceProvider.ts +++ b/packages/protocol/src/state/StateServiceProvider.ts @@ -1,7 +1,7 @@ import { injectable } from "tsyringe"; import { log } from "@proto-kit/common"; -import { SimpleAsyncStateService } from "./StateService"; +import { SimpleAsyncStateService } from "./SimpleAsyncStateService"; const errors = { stateServiceNotSet: () => diff --git a/packages/sequencer/src/state/async/AsyncStateService.ts b/packages/sequencer/src/state/async/AsyncStateService.ts index b5420abc3..b5e7a1be0 100644 --- a/packages/sequencer/src/state/async/AsyncStateService.ts +++ b/packages/sequencer/src/state/async/AsyncStateService.ts @@ -11,13 +11,19 @@ export interface StateEntry { * CachedStateService to preload keys for In-Circuit usage. */ export interface AsyncStateService { - openTransaction: () => Promise; + openTransaction(): Promise; - commit: () => Promise; + commit(): Promise; - writeStates: (entries: StateEntry[]) => void; + writeStates(entries: StateEntry[]): void; - getMany: (keys: Field[]) => Promise; + getMany(keys: Field[]): Promise; - get: (key: Field) => Promise; + get(key: Field): Promise; + + createMask(name: string): Promise; + + mergeIntoParent(): Promise; + + drop(): Promise; } diff --git a/packages/sequencer/src/state/state/CachedStateService.ts b/packages/sequencer/src/state/state/CachedStateService.ts index 2824ba418..5af85e235 100644 --- a/packages/sequencer/src/state/state/CachedStateService.ts +++ b/packages/sequencer/src/state/state/CachedStateService.ts @@ -15,10 +15,22 @@ export class CachedStateService { private writes: StateEntry[] = []; - public constructor(private readonly parent: AsyncStateService | undefined) { + public constructor( + private readonly parent: AsyncStateService | undefined, + public readonly name?: string + ) { super(); } + public async createMask(name: string): Promise { + return new CachedStateService(this, name); + } + + public async drop(): Promise { + this.writes = []; + this.values = {}; + } + /** * Works like get(), but if a value is in this store, * but is known to be empty, this will return null @@ -43,6 +55,7 @@ export class CachedStateService await mapSequential(this.writes, async ({ key, value }) => { await this.set(key, value); }); + this.writes = []; } public async openTransaction(): Promise {