From 019b5b76318e6df57f8598e44c18670950c257e0 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 26 Oct 2021 16:32:59 +0200 Subject: [PATCH 01/12] add skyd config checks to health checks --- packages/health-check/src/checks/critical.js | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index daa261f3..94aef448 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -7,6 +7,31 @@ const { SkynetClient, genKeyPairAndSeed } = require("skynet-js"); const skynetClient = new SkynetClient(process.env.SKYNET_PORTAL_API); const exampleSkylink = "AACogzrAimYPG42tDOKhS3lXZD8YvlF8Q8R17afe95iV2Q"; +// check that any relevant configuration is properly set in skyd +async function skydConfigCheck(done) { + const time = process.hrtime(); + const data = { up: false }; + + try { + const response = await got(`http://10.10.10.10:9980/renter`, { headers: { "User-Agent": "Sia-Agent" } }).json(); + + // make sure initial funding is set to a non zero value + if (BigInt(response.settings.allowance.paymentcontractinitialfunding) > 0) { + throw new Error("Skynet Portal Per-Contract Budget is not set!"); + } + + data.up = true; + data.ip = response.ip; + } catch (error) { + data.statusCode = error.response?.statusCode || error.statusCode || error.status; + data.errorMessage = error.message; + data.errorResponseContent = getResponseContent(error.response); + data.ip = error?.response?.ip ?? null; + } + + done({ name: "skyd_config", time: calculateElapsedTime(time), ...data }); +} + // uploadCheck returns the result of uploading a sample file async function uploadCheck(done) { const time = process.hrtime(); @@ -164,6 +189,7 @@ async function genericAccessCheck(name, url) { } const checks = [ + skydConfigCheck, uploadCheck, websiteCheck, websiteSkylinkCheck, From cd95dc2f4ba3a2eae41513d242717f0451ca4691 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 26 Oct 2021 16:34:49 +0200 Subject: [PATCH 02/12] changelog for feature --- changelog/items/other/1332-skyd-config-health-check.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/items/other/1332-skyd-config-health-check.md diff --git a/changelog/items/other/1332-skyd-config-health-check.md b/changelog/items/other/1332-skyd-config-health-check.md new file mode 100644 index 00000000..534c7590 --- /dev/null +++ b/changelog/items/other/1332-skyd-config-health-check.md @@ -0,0 +1 @@ +- add new critical health check that scans config and makes sure that all relevant configurations are set From 7004ea0dfef10ba4ef6904622f103880557eff6f Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 26 Oct 2021 16:39:19 +0200 Subject: [PATCH 03/12] fix condition --- packages/health-check/src/checks/critical.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index 94aef448..c3fbf74d 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -16,7 +16,7 @@ async function skydConfigCheck(done) { const response = await got(`http://10.10.10.10:9980/renter`, { headers: { "User-Agent": "Sia-Agent" } }).json(); // make sure initial funding is set to a non zero value - if (BigInt(response.settings.allowance.paymentcontractinitialfunding) > 0) { + if (BigInt(response.settings.allowance.paymentcontractinitialfunding) === 0) { throw new Error("Skynet Portal Per-Contract Budget is not set!"); } From f9567a4aa126635c059e95ed2b3d2790a84914f3 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 26 Oct 2021 16:56:48 +0200 Subject: [PATCH 04/12] fix website check --- packages/health-check/src/checks/critical.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index c3fbf74d..dfdfec21 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -86,8 +86,9 @@ async function handshakeSubdomainCheck(done) { // websiteSkylinkCheck returns the result of accessing siasky.net website through skylink async function websiteSkylinkCheck(done) { const websiteSkylink = "0404dsjvti046fsua4ktor9grrpe76erq9jot9cvopbhsvsu76r4r30"; + const url = await skynetClient.getSkylinkUrl(websiteSkylink, { subdomain: true }); - return done(await genericAccessCheck("website_skylink", websiteSkylink)); + return done(await genericAccessCheck("website_skylink", url)); } // accountWebsiteCheck returns the result of accessing account dashboard website From 4fbbc144c87e0f3dc10b50122144cdd40b0d3ea9 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 26 Oct 2021 17:01:10 +0200 Subject: [PATCH 05/12] remove website skylink check for now --- packages/health-check/src/checks/critical.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index dfdfec21..cdc9e9cb 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -84,12 +84,12 @@ async function handshakeSubdomainCheck(done) { } // websiteSkylinkCheck returns the result of accessing siasky.net website through skylink -async function websiteSkylinkCheck(done) { - const websiteSkylink = "0404dsjvti046fsua4ktor9grrpe76erq9jot9cvopbhsvsu76r4r30"; - const url = await skynetClient.getSkylinkUrl(websiteSkylink, { subdomain: true }); +// async function websiteSkylinkCheck(done) { +// const websiteSkylink = "0404dsjvti046fsua4ktor9grrpe76erq9jot9cvopbhsvsu76r4r30"; +// const url = await skynetClient.getSkylinkUrl(websiteSkylink, { subdomain: true }); - return done(await genericAccessCheck("website_skylink", url)); -} +// return done(await genericAccessCheck("website_skylink", url)); +// } // accountWebsiteCheck returns the result of accessing account dashboard website async function accountWebsiteCheck(done) { @@ -193,7 +193,7 @@ const checks = [ skydConfigCheck, uploadCheck, websiteCheck, - websiteSkylinkCheck, + // websiteSkylinkCheck, downloadCheck, skylinkSubdomainCheck, handshakeSubdomainCheck, From 0a4e3b3f4505dae1ca3643478a251f343e2f949b Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 26 Oct 2021 17:01:51 +0200 Subject: [PATCH 06/12] fix --- packages/health-check/src/checks/critical.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index cdc9e9cb..3e2c8552 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -84,12 +84,12 @@ async function handshakeSubdomainCheck(done) { } // websiteSkylinkCheck returns the result of accessing siasky.net website through skylink -// async function websiteSkylinkCheck(done) { -// const websiteSkylink = "0404dsjvti046fsua4ktor9grrpe76erq9jot9cvopbhsvsu76r4r30"; -// const url = await skynetClient.getSkylinkUrl(websiteSkylink, { subdomain: true }); +async function websiteSkylinkCheck(done) { + const websiteSkylink = "0404dsjvti046fsua4ktor9grrpe76erq9jot9cvopbhsvsu76r4r30"; + const url = await skynetClient.getSkylinkUrl(websiteSkylink); -// return done(await genericAccessCheck("website_skylink", url)); -// } + return done(await genericAccessCheck("website_skylink", url)); +} // accountWebsiteCheck returns the result of accessing account dashboard website async function accountWebsiteCheck(done) { @@ -193,7 +193,7 @@ const checks = [ skydConfigCheck, uploadCheck, websiteCheck, - // websiteSkylinkCheck, + websiteSkylinkCheck, downloadCheck, skylinkSubdomainCheck, handshakeSubdomainCheck, From d4482e60258b6c8886e9622ebb9ec9bef4a1a77e Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 26 Oct 2021 17:03:59 +0200 Subject: [PATCH 07/12] fix --- packages/health-check/src/checks/critical.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index 3e2c8552..e1ab808f 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -85,8 +85,8 @@ async function handshakeSubdomainCheck(done) { // websiteSkylinkCheck returns the result of accessing siasky.net website through skylink async function websiteSkylinkCheck(done) { - const websiteSkylink = "0404dsjvti046fsua4ktor9grrpe76erq9jot9cvopbhsvsu76r4r30"; - const url = await skynetClient.getSkylinkUrl(websiteSkylink); + const websiteSkylink = "AQBG8n_sgEM_nlEp3G0w3vLjmdvSZ46ln8ZXHn-eObZNjA"; + const url = await skynetClient.getSkylinkUrl(websiteSkylink, { subdomain: true }); return done(await genericAccessCheck("website_skylink", url)); } From 5dc357b3d1c9ee2208b195ec4fd7c57fb06a135b Mon Sep 17 00:00:00 2001 From: Matthew Sevey Date: Tue, 26 Oct 2021 12:17:44 -0400 Subject: [PATCH 08/12] Fix BigInt use --- packages/health-check/src/checks/critical.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index e1ab808f..0aac235d 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -16,7 +16,9 @@ async function skydConfigCheck(done) { const response = await got(`http://10.10.10.10:9980/renter`, { headers: { "User-Agent": "Sia-Agent" } }).json(); // make sure initial funding is set to a non zero value - if (BigInt(response.settings.allowance.paymentcontractinitialfunding) === 0) { + let actual = BigInt(response.settings.allowance.paymentcontractinitialfunding); + let expected = BigInt(10000000000000000000000000); // 10 SC + if (actual !== expected) { throw new Error("Skynet Portal Per-Contract Budget is not set!"); } From f6febd04b34aaa154dd88ba9266e1a0934e81b28 Mon Sep 17 00:00:00 2001 From: Matthew Sevey Date: Tue, 26 Oct 2021 12:18:56 -0400 Subject: [PATCH 09/12] Fix error message --- packages/health-check/src/checks/critical.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index 0aac235d..b6d64772 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -19,7 +19,7 @@ async function skydConfigCheck(done) { let actual = BigInt(response.settings.allowance.paymentcontractinitialfunding); let expected = BigInt(10000000000000000000000000); // 10 SC if (actual !== expected) { - throw new Error("Skynet Portal Per-Contract Budget is not set!"); + throw new Error("Skynet Portal Per-Contract Budget is not set correctly!"); } data.up = true; From 2fc92fb3e2f6c475acebb95bee8f056916f2e852 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Wed, 27 Oct 2021 14:50:54 +0200 Subject: [PATCH 10/12] update skynet-js and fix critical checks --- packages/health-check/package.json | 2 +- packages/health-check/src/checks/critical.js | 6 +- packages/health-check/yarn.lock | 151 ++++++++++++++++--- 3 files changed, 132 insertions(+), 27 deletions(-) diff --git a/packages/health-check/package.json b/packages/health-check/package.json index 7657ae05..c7020969 100644 --- a/packages/health-check/package.json +++ b/packages/health-check/package.json @@ -13,7 +13,7 @@ "http-status-codes": "^2.1.2", "lodash": "^4.17.21", "lowdb": "^1.0.0", - "skynet-js": "^3.0.2", + "skynet-js": "^4.0.18-beta", "write-file-atomic": "^3.0.3", "yargs": "^17.2.1" }, diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index b6d64772..1e2e8a43 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -15,10 +15,8 @@ async function skydConfigCheck(done) { try { const response = await got(`http://10.10.10.10:9980/renter`, { headers: { "User-Agent": "Sia-Agent" } }).json(); - // make sure initial funding is set to a non zero value - let actual = BigInt(response.settings.allowance.paymentcontractinitialfunding); - let expected = BigInt(10000000000000000000000000); // 10 SC - if (actual !== expected) { + // make sure initial funding is set to 10SC + if (response.settings.allowance.paymentcontractinitialfunding !== "10000000000000000000000000") { throw new Error("Skynet Portal Per-Contract Budget is not set correctly!"); } diff --git a/packages/health-check/yarn.lock b/packages/health-check/yarn.lock index 3cd5fcc4..436dfa6e 100644 --- a/packages/health-check/yarn.lock +++ b/packages/health-check/yarn.lock @@ -2,13 +2,6 @@ # yarn lockfile v1 -"@babel/runtime@^7.11.2": - version "7.14.8" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.8.tgz#7119a56f421018852694290b9f9148097391b446" - integrity sha512-twj3L8Og5SaCRCErB4x4ajbvBIVV77CGeFglHpeg5WC5FF8TZzBWXtTJ4MqaD9QszLYTtr+IsaAL2rEUevb+eg== - dependencies: - regenerator-runtime "^0.13.4" - "@sindresorhus/is@^4.0.0": version "4.0.1" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.0.1.tgz#d26729db850fa327b7cacc5522252194404226f5" @@ -85,13 +78,18 @@ asynckit@^0.4.0: resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= -axios@^0.21.0: +axios@^0.21.1: version "0.21.4" resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== dependencies: follow-redirects "^1.14.0" +base32-decode@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/base32-decode/-/base32-decode-1.0.0.tgz#2a821d6a664890c872f20aa9aca95a4b4b80e2a7" + integrity sha512-KNWUX/R7wKenwE/G/qFMzGScOgVntOmbE27vvc6GrniDGYb6a5+qWcuoXl8WIOQL7q0TpK7nZDm1Y04Yi3Yn5g== + base32-encode@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/base32-encode/-/base32-encode-1.2.0.tgz#e150573a5e431af0a998e32bdfde7045725ca453" @@ -125,6 +123,11 @@ body-parser@1.19.0: raw-body "2.4.0" type-is "~1.6.17" +buffer-from@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-0.1.2.tgz#15f4b9bcef012044df31142c14333caf6e0260d0" + integrity sha512-RiWIenusJsmI2KcvqQABB83tLxCByE3upSP8QU3rJDMVFGPWLvPQJt/O1Su9moRWeH7d+Q2HYb68f6+v+tw2vg== + buffer@^6.0.1: version "6.0.3" resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" @@ -184,6 +187,14 @@ color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +combine-errors@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/combine-errors/-/combine-errors-3.0.3.tgz#f4df6740083e5703a3181110c2b10551f003da86" + integrity sha1-9N9nQAg+VwOjGBEQwrEFUfAD2oY= + dependencies: + custom-error-instance "2.1.1" + lodash.uniqby "4.5.0" + combined-stream@^1.0.8: version "1.0.8" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" @@ -213,6 +224,11 @@ cookie@0.4.0: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== +custom-error-instance@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/custom-error-instance/-/custom-error-instance-2.1.1.tgz#3cf6391487a6629a6247eb0ca0ce00081b7e361a" + integrity sha1-PPY5FIemYppiR+sMoM4ACBt+Nho= + debug@2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -391,7 +407,7 @@ got@^11.8.2: p-cancelable "^2.0.0" responselike "^2.0.0" -graceful-fs@^4.1.3, graceful-fs@^4.2.8: +graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.2.8: version "4.2.8" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a" integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg== @@ -496,6 +512,11 @@ is-typedarray@^1.0.0: resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= +js-base64@^2.6.1: + version "2.6.4" + resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4" + integrity sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ== + json-buffer@3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" @@ -508,6 +529,56 @@ keyv@^4.0.0: dependencies: json-buffer "3.0.1" +lodash._baseiteratee@~4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/lodash._baseiteratee/-/lodash._baseiteratee-4.7.0.tgz#34a9b5543572727c3db2e78edae3c0e9e66bd102" + integrity sha1-NKm1VDVycnw9sueO2uPA6eZr0QI= + dependencies: + lodash._stringtopath "~4.8.0" + +lodash._basetostring@~4.12.0: + version "4.12.0" + resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-4.12.0.tgz#9327c9dc5158866b7fa4b9d42f4638e5766dd9df" + integrity sha1-kyfJ3FFYhmt/pLnUL0Y45XZt2d8= + +lodash._baseuniq@~4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8" + integrity sha1-DrtE5FaBSveQXGIS+iybLVG4Qeg= + dependencies: + lodash._createset "~4.0.0" + lodash._root "~3.0.0" + +lodash._createset@~4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26" + integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY= + +lodash._root@~3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" + integrity sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI= + +lodash._stringtopath@~4.8.0: + version "4.8.0" + resolved "https://registry.yarnpkg.com/lodash._stringtopath/-/lodash._stringtopath-4.8.0.tgz#941bcf0e64266e5fc1d66fed0a6959544c576824" + integrity sha1-lBvPDmQmbl/B1m/tCmlZVExXaCQ= + dependencies: + lodash._basetostring "~4.12.0" + +lodash.throttle@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" + integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ= + +lodash.uniqby@4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.uniqby/-/lodash.uniqby-4.5.0.tgz#a3a17bbf62eeb6240f491846e97c1c4e2a5e1e21" + integrity sha1-o6F7v2LutiQPSRhG6XwcTipeHiE= + dependencies: + lodash._baseiteratee "~4.7.0" + lodash._baseuniq "~4.6.0" + lodash@4, lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" @@ -635,11 +706,24 @@ pify@^3.0.0: resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= +post-me@^0.4.5: + version "0.4.5" + resolved "https://registry.yarnpkg.com/post-me/-/post-me-0.4.5.tgz#6171b721c7b86230c51cfbe48ddea047ef8831ce" + integrity sha512-XgPdktF/2M5jglgVDULr9NUb/QNv3bY3g6RG22iTb5MIMtB07/5FJB5fbVmu5Eaopowc6uZx7K3e7x1shPwnXw== + prettier@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c" integrity sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA== +proper-lockfile@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/proper-lockfile/-/proper-lockfile-2.0.1.tgz#159fb06193d32003f4b3691dd2ec1a634aa80d1d" + integrity sha1-FZ+wYZPTIAP0s2kd0uwaY0qoDR0= + dependencies: + graceful-fs "^4.1.2" + retry "^0.10.0" + proxy-addr@~2.0.5: version "2.0.7" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" @@ -693,11 +777,6 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" -regenerator-runtime@^0.13.4: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -720,6 +799,11 @@ responselike@^2.0.0: dependencies: lowercase-keys "^2.0.0" +retry@^0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/retry/-/retry-0.10.1.tgz#e76388d217992c252750241d3d3956fed98d8ff4" + integrity sha1-52OI0heZLCUnUCQdPTlW/tmNj/Q= + safe-buffer@5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" @@ -779,24 +863,34 @@ sjcl@^1.0.8: resolved "https://registry.yarnpkg.com/sjcl/-/sjcl-1.0.8.tgz#f2ec8d7dc1f0f21b069b8914a41a8f236b0e252a" integrity sha512-LzIjEQ0S0DpIgnxMEayM1rq9aGwGRG4OnZhCdjx7glTaJtf4zRfpg87ImfjSJjoW9vKpagd82McDOwbRT5kQKQ== -skynet-js@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/skynet-js/-/skynet-js-3.0.2.tgz#d08a33066ee85b86e4ffc7c31591239a88da6fbe" - integrity sha512-rbmpOGbDwg2FcsZ7HkmGhVaUwWO6kaysRFKTBC3yGiV+b6fbnpPPNCskvh8kWwbTsj+koWkSRUFYqG7cc+eTuA== +skynet-js@^4.0.18-beta: + version "4.0.18-beta" + resolved "https://registry.yarnpkg.com/skynet-js/-/skynet-js-4.0.18-beta.tgz#4683f0837ae552802f39c0e7081a1b978b79ef4a" + integrity sha512-7mE9xrejTpRacZfhhCqx+dm7k1y6ITLZMWZnsPp13D2N9CNroyzB75Yi7033qwPtdo9i6BEzIDolZl66j+uALw== dependencies: - "@babel/runtime" "^7.11.2" - axios "^0.21.0" + axios "^0.21.1" + base32-decode "^1.0.0" base32-encode "^1.1.1" base64-js "^1.3.1" blakejs "^1.1.0" buffer "^6.0.1" mime "^2.5.2" path-browserify "^1.0.1" + post-me "^0.4.5" randombytes "^2.1.0" sjcl "^1.0.8" + skynet-mysky-utils "^0.3.0" + tus-js-client "^2.2.0" tweetnacl "^1.0.3" url-join "^4.0.1" - url-parse "^1.4.7" + url-parse "^1.5.1" + +skynet-mysky-utils@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/skynet-mysky-utils/-/skynet-mysky-utils-0.3.0.tgz#87fdc0a5f8547cf660280ef86b7a762269919bad" + integrity sha512-X9L6SrVTdwTUFook/E6zUWCOpXHdyspLAu0elQbbPkZCWeFpr/XXTMbiyPV3m1liYsesngAKxzaSqylaTWOGUA== + dependencies: + post-me "^0.4.5" "statuses@>= 1.5.0 < 2", statuses@~1.5.0: version "1.5.0" @@ -836,6 +930,19 @@ toidentifier@1.0.0: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== +tus-js-client@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/tus-js-client/-/tus-js-client-2.3.0.tgz#5d76145476cea46a4e7c045a0054637cddf8dc39" + integrity sha512-I4cSwm6N5qxqCmBqenvutwSHe9ntf81lLrtf6BmLpG2v4wTl89atCQKqGgqvkodE6Lx+iKIjMbaXmfvStTg01g== + dependencies: + buffer-from "^0.1.1" + combine-errors "^3.0.3" + is-stream "^2.0.0" + js-base64 "^2.6.1" + lodash.throttle "^4.1.1" + proper-lockfile "^2.0.1" + url-parse "^1.4.3" + tweetnacl@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" @@ -871,7 +978,7 @@ url-join@^4.0.1: resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.1.tgz#b642e21a2646808ffa178c4c5fda39844e12cde7" integrity sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA== -url-parse@^1.4.7: +url-parse@^1.4.3, url-parse@^1.5.1: version "1.5.3" resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.3.tgz#71c1303d38fb6639ade183c2992c8cc0686df862" integrity sha512-IIORyIQD9rvj0A4CLWsHkBBJuNqWpFQe224b6j9t/ABmquIS0qDU2pY6kl6AuOrL5OkCXHMCFNe1jBcuAggjvQ== From 121dbee1c23a2b9e22941724e600be75a5ecca22 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Wed, 27 Oct 2021 14:59:08 +0200 Subject: [PATCH 11/12] change datakey to dataKey --- packages/health-check/src/checks/critical.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index 1e2e8a43..2d95f210 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -103,7 +103,7 @@ async function registryWriteAndReadCheck(done) { const time = process.hrtime(); const data = { name: "registry_write_and_read", up: false }; const { privateKey, publicKey } = genKeyPairAndSeed(); - const expected = { datakey: "foo-key", data: "foo-data", revision: BigInt(0) }; + const expected = { dataKey: "foo-key", data: "foo-data", revision: BigInt(0) }; try { await skynetClient.registry.setEntry(privateKey, expected); From a5674c8d1fc6e4bb30b6123ece7472928bd04424 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Thu, 28 Oct 2021 15:12:14 +0200 Subject: [PATCH 12/12] adjust tests --- packages/health-check/src/checks/critical.js | 8 +-- packages/health-check/yarn.lock | 72 ++++++++++---------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index 2d95f210..d5527b50 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -2,7 +2,7 @@ const got = require("got"); const FormData = require("form-data"); const { isEqual } = require("lodash"); const { calculateElapsedTime, getResponseContent } = require("../utils"); -const { SkynetClient, genKeyPairAndSeed } = require("skynet-js"); +const { SkynetClient, stringToUint8ArrayUtf8, genKeyPairAndSeed } = require("skynet-js"); const skynetClient = new SkynetClient(process.env.SKYNET_PORTAL_API); const exampleSkylink = "AACogzrAimYPG42tDOKhS3lXZD8YvlF8Q8R17afe95iV2Q"; @@ -103,11 +103,11 @@ async function registryWriteAndReadCheck(done) { const time = process.hrtime(); const data = { name: "registry_write_and_read", up: false }; const { privateKey, publicKey } = genKeyPairAndSeed(); - const expected = { dataKey: "foo-key", data: "foo-data", revision: BigInt(0) }; + const expected = { dataKey: "foo-key", data: stringToUint8ArrayUtf8("foo-data"), revision: BigInt(0) }; try { await skynetClient.registry.setEntry(privateKey, expected); - const { entry } = await skynetClient.registry.getEntry(publicKey, expected.datakey); + const { entry } = await skynetClient.registry.getEntry(publicKey, expected.dataKey); if (isEqual(expected, entry)) { data.up = true; @@ -115,7 +115,7 @@ async function registryWriteAndReadCheck(done) { data.errors = [{ message: "Data mismatch in registry (read after write)", entry, expected }]; } } catch (error) { - data.errors = [{ message: error.message }]; + data.errors = [{ message: error?.response?.data?.message ?? error.message }]; } return done({ ...data, time: calculateElapsedTime(time) }); diff --git a/packages/health-check/yarn.lock b/packages/health-check/yarn.lock index 436dfa6e..ca7aeabf 100644 --- a/packages/health-check/yarn.lock +++ b/packages/health-check/yarn.lock @@ -3,9 +3,9 @@ "@sindresorhus/is@^4.0.0": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.0.1.tgz#d26729db850fa327b7cacc5522252194404226f5" - integrity sha512-Qm9hBEBu18wt1PO2flE7LPb30BHMQt1eQgbV76YntdNk73XZGpn3izvGTYxbGgzXKgbCjiia0uxTd3aTNQrY/g== + version "4.2.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.2.0.tgz#667bfc6186ae7c9e0b45a08960c551437176e1ca" + integrity sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw== "@szmarczak/http-timer@^4.0.5": version "4.0.6" @@ -30,16 +30,16 @@ integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ== "@types/keyv@*": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.2.tgz#5d97bb65526c20b6e0845f6b0d2ade4f28604ee5" - integrity sha512-/FvAK2p4jQOaJ6CGDHJTqZcUtbZe820qIeTg7o0Shg7drB4JHeL+V/dhSaly7NXx6u8eSee+r7coT+yuJEvDLg== + version "3.1.3" + resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.3.tgz#1c9aae32872ec1f20dcdaee89a9f3ba88f465e41" + integrity sha512-FXCJgyyN3ivVgRoml4h94G/p3kY+u/B86La+QptcqJaWtBWtmc6TtkNfS40n9bIvyLteHh7zXOtgbobORKPbDg== dependencies: "@types/node" "*" "@types/node@*": - version "16.4.3" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.4.3.tgz#c01c1a215721f6dec71b47d88b4687463601ba48" - integrity sha512-GKM4FLMkWDc0sfx7tXqPWkM6NBow1kge0fgQh0bOnlqo4iT1kvTvMEKE0c1RtUGnbLlGRXiAA8SumE//90uKAg== + version "16.11.6" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae" + integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w== "@types/responselike@*", "@types/responselike@^1.0.0": version "1.0.0" @@ -56,7 +56,7 @@ accepts@~1.3.7: mime-types "~2.1.24" negotiator "0.6.2" -ansi-regex@^5.0.0: +ansi-regex@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== @@ -355,9 +355,9 @@ finalhandler@~1.1.2: unpipe "~1.0.0" follow-redirects@^1.14.0: - version "1.14.3" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.3.tgz#6ada78118d8d24caee595595accdc0ac6abd022e" - integrity sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw== + version "1.14.4" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379" + integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g== form-data@^4.0.0: version "4.0.0" @@ -615,17 +615,17 @@ methods@~1.1.2: resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= -mime-db@1.48.0: - version "1.48.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.48.0.tgz#e35b31045dd7eada3aaad537ed88a33afbef2d1d" - integrity sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ== +mime-db@1.50.0: + version "1.50.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.50.0.tgz#abd4ac94e98d3c0e185016c67ab45d5fde40c11f" + integrity sha512-9tMZCDlYHqeERXEHO9f/hKfNXhre5dK2eE/krIvUjZbS2KPcqGDfNShIWS1uW9XOTKQKqK6qbeOci18rbfW77A== mime-types@^2.1.12, mime-types@~2.1.24: - version "2.1.31" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.31.tgz#a00d76b74317c61f9c2db2218b8e9f8e9c5c9e6b" - integrity sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg== + version "2.1.33" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.33.tgz#1fa12a904472fafd068e48d9e8401f74d3f70edb" + integrity sha512-plLElXp7pRDd0bNZHw+nMd52vRYjLwQjygaNg7ddJ2uJtTlmnTCjWuPKxVu6//AdaRuME84SvLW91sIkBqGT0g== dependencies: - mime-db "1.48.0" + mime-db "1.50.0" mime@1.6.0: version "1.6.0" @@ -788,9 +788,9 @@ requires-port@^1.0.0: integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= resolve-alpn@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.0.tgz#058bb0888d1cd4d12474e9a4b6eb17bdd5addc44" - integrity sha512-e4FNQs+9cINYMO5NMFc6kOUCdohjqFPSgMuwuZAOUWqrfWsen+Yjy5qZFkV5K7VO7tFSLKcUL97olkED7sCBHA== + version "1.2.1" + resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9" + integrity sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g== responselike@^2.0.0: version "2.0.0" @@ -854,9 +854,9 @@ setprototypeof@1.1.1: integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw== signal-exit@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" - integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== + version "3.0.5" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.5.tgz#9e3e8cc0c75a99472b44321033a7702e7738252f" + integrity sha512-KWcOiKeQj6ZyXx7zq4YxSMgHRlod4czeBQZrPb8OKcohcqAXShm7E20kEMle9WBt26hFcAf0qLOcp5zmY7kOqQ== sjcl@^1.0.8: version "1.0.8" @@ -905,20 +905,20 @@ steno@^0.4.1: graceful-fs "^4.1.3" string-width@^4.1.0, string-width@^4.2.0: - version "4.2.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5" - integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA== + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== dependencies: emoji-regex "^8.0.0" is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" + strip-ansi "^6.0.1" -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== dependencies: - ansi-regex "^5.0.0" + ansi-regex "^5.0.1" to-data-view@^1.1.0: version "1.1.0"