diff --git a/framework/dist/lisk-service-framework-1.4.22.tgz b/framework/dist/lisk-service-framework-1.4.22.tgz new file mode 100644 index 0000000000..61a6e3f369 Binary files /dev/null and b/framework/dist/lisk-service-framework-1.4.22.tgz differ diff --git a/framework/package-lock.json b/framework/package-lock.json index 4fba7e8c72..4ce2d5389b 100644 --- a/framework/package-lock.json +++ b/framework/package-lock.json @@ -1,12 +1,12 @@ { "name": "lisk-service-framework", - "version": "1.4.21", + "version": "1.4.22", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lisk-service-framework", - "version": "1.4.21", + "version": "1.4.22", "license": "Apache-2.0", "dependencies": { "@keyv/redis": "^2.1.2", @@ -1102,9 +1102,9 @@ } }, "node_modules/@types/node": { - "version": "20.4.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.2.tgz", - "integrity": "sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw==" + "version": "20.4.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.5.tgz", + "integrity": "sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg==" }, "node_modules/@types/prettier": { "version": "2.7.3", @@ -1826,9 +1826,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001516", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001516.tgz", - "integrity": "sha512-Wmec9pCBY8CWbmI4HsjBeQLqDTqV91nFVR83DnZpYyRnPI1wePDsTg0bGLPC5VU/3OIZV1fmxEea1b+tFKe86g==", + "version": "1.0.30001517", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001517.tgz", + "integrity": "sha512-Vdhm5S11DaFVLlyiKu4hiUTkpZu+y1KA/rZZqVQfOD5YdDT/eQKlkt7NaE0WGOFgX32diqt9MiP9CAiFeRklaA==", "dev": true, "funding": [ { @@ -2263,9 +2263,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.463", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.463.tgz", - "integrity": "sha512-fT3hvdUWLjDbaTGzyOjng/CQhQJSQP8ThO3XZAoaxHvHo2kUXiRQVMj9M235l8uDFiNPsPa6KHT1p3RaR6ugRw==", + "version": "1.4.471", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.471.tgz", + "integrity": "sha512-GpmGRC1vTl60w/k6YpQ18pSiqnmr0j3un//5TV1idPi6aheNfkT1Ye71tMEabWyNDO6sBMgAR+95Eb0eUUr1tA==", "dev": true }, "node_modules/emittery": { @@ -3542,17 +3542,17 @@ } }, "node_modules/istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", "dev": true, "dependencies": { "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^3.0.0", + "make-dir": "^4.0.0", "supports-color": "^7.1.0" }, "engines": { - "node": ">=8" + "node": ">=10" } }, "node_modules/istanbul-lib-source-maps": { @@ -3570,9 +3570,9 @@ } }, "node_modules/istanbul-reports": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", - "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.6.tgz", + "integrity": "sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg==", "dev": true, "dependencies": { "html-escaper": "^2.0.0", @@ -4681,29 +4681,20 @@ } }, "node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", "dev": true, "dependencies": { - "semver": "^6.0.0" + "semver": "^7.5.3" }, "engines": { - "node": ">=8" + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/make-dir/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/makeerror": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", diff --git a/framework/package.json b/framework/package.json index 54c05a973b..643fbcbdac 100644 --- a/framework/package.json +++ b/framework/package.json @@ -1,6 +1,6 @@ { "name": "lisk-service-framework", - "version": "1.4.21", + "version": "1.4.22", "description": "Lisk Service Framework", "keywords": [ "lisk", diff --git a/framework/src/database/sqlite3.js b/framework/src/database/sqlite3.js index 502a414f3f..85c5daf104 100644 --- a/framework/src/database/sqlite3.js +++ b/framework/src/database/sqlite3.js @@ -102,7 +102,9 @@ const getTableInstance = async (tableConfig, dbDataDir = DB_DATA_DIR) => { isDefaultTrx = true; } - const query = trx.raw(queryStatement); + const query = trx + .raw(queryStatement) + .transacting(trx); if (isDefaultTrx) return query .then(async result => { diff --git a/framework/src/database/util.js b/framework/src/database/util.js index bd40c40008..0f7deb8054 100644 --- a/framework/src/database/util.js +++ b/framework/src/database/util.js @@ -114,10 +114,10 @@ const getTableInstance = (tableConfig, knex) => { // Create all queries for `INSERT or UPDATE on Duplicate keys` const queries = rows.map(row => knex(tableName) - .transacting(trx) .insert(row) .onConflict(primaryKey) - .merge(), + .merge() + .transacting(trx), ); // Perform all queries within a batch together @@ -133,8 +133,8 @@ const getTableInstance = (tableConfig, knex) => { return Promise.all(queries); }; - const queryBuilder = (params, columns, isCountQuery, trx) => { - const query = knex(tableName).transacting(trx); + const queryBuilder = (params, columns, isCountQuery) => { + const query = knex(tableName); const queryParams = resolveQueryParams(params); if (isCountQuery) { @@ -326,7 +326,10 @@ const getTableInstance = (tableConfig, knex) => { isDefaultTrx = true; } - const query = queryBuilder(params, tableConfig.primaryKey, false, trx).del(); + const query = queryBuilder(params, tableConfig.primaryKey, false) + .del() + .transacting(trx); + if (isDefaultTrx) return query .then(async result => { await trx.commit(); @@ -347,7 +350,10 @@ const getTableInstance = (tableConfig, knex) => { } ids = Array.isArray(ids) ? ids : [ids]; - const query = knex(tableName).transacting(trx).whereIn(primaryKey, ids).del(); + const query = knex(tableName).whereIn(primaryKey, ids) + .del() + .transacting(trx); + if (isDefaultTrx) return query .then(async result => { await trx.commit(); @@ -368,8 +374,9 @@ const getTableInstance = (tableConfig, knex) => { } const { where, updates } = params; - const query = queryBuilder({ ...where }, tableConfig.primaryKey, false, trx) - .update({ ...updates }); + const query = queryBuilder({ ...where }, tableConfig.primaryKey, false) + .update({ ...updates }) + .transacting(trx); if (isDefaultTrx) return query .then(async result => { @@ -395,7 +402,8 @@ const getTableInstance = (tableConfig, knex) => { columns = Array.isArray(tableConfig.primaryKey) ? tableConfig.primaryKey : [tableConfig.primaryKey]; } - const query = queryBuilder(params, columns, false, trx); + const query = queryBuilder(params, columns, false) + .transacting(trx); const debugSql = query.toSQL().toNative(); logger.debug(`${debugSql.sql}; bindings: ${debugSql.bindings}.`); @@ -427,7 +435,8 @@ const getTableInstance = (tableConfig, knex) => { column = Array.isArray(column) ? [column[0]] : [column]; } - const query = queryBuilder(params, column, true, trx); + const query = queryBuilder(params, column, true) + .transacting(trx); const debugSql = query.toSQL().toNative(); logger.debug(`${debugSql.sql}; bindings: ${debugSql.bindings}.`); @@ -452,7 +461,9 @@ const getTableInstance = (tableConfig, knex) => { isDefaultTrx = true; } - const query = trx.raw(queryStatement); + const query = trx + .raw(queryStatement) + .transacting(trx); if (isDefaultTrx) return query .then(async result => { @@ -475,7 +486,9 @@ const getTableInstance = (tableConfig, knex) => { isDefaultTrx = true; } - const query = queryBuilder(params, false, false, trx).increment(params.increment); + const query = queryBuilder(params, false, false) + .increment(params.increment) + .transacting(trx); if (isDefaultTrx) return query .then(async result => { @@ -496,7 +509,9 @@ const getTableInstance = (tableConfig, knex) => { isDefaultTrx = true; } - const query = queryBuilder(params, false, false, trx).decrement(params.decrement); + const query = queryBuilder(params, false, false) + .decrement(params.decrement) + .transacting(trx); if (isDefaultTrx) return query .then(async result => {