From d360b0b678a6bfd5db943b4aa8b6a598becfae78 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Tue, 19 Nov 2024 13:42:14 +0100 Subject: [PATCH 01/13] fix audit default --- lib/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core.js b/lib/core.js index 14947cf3..1265dfd4 100644 --- a/lib/core.js +++ b/lib/core.js @@ -530,7 +530,7 @@ module.exports = class Autocore extends ReadyResource { await core.setUserData('referrer', this.base.key) const buf = await core.getUserData('autobase/view') - const record = (buf !== null && buf[0] === 0) ? c.decode(ViewRecord, buf) : { name: null, migrated: null, audits: 0 } + const record = (buf !== null && buf[0] === 0) ? c.decode(ViewRecord, buf) : { name: null, migrated: null, audits: 1 } if (record.audits === 0) { // old core, audit it real quick From 7137dcb83bbb5a2c8d933d69f2bfeff8a4653e2a Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Tue, 19 Nov 2024 13:42:39 +0100 Subject: [PATCH 02/13] 6.5.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0abd6f14..4329a12b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "autobase", - "version": "6.5.9", + "version": "6.5.10", "description": "", "main": "index.js", "scripts": { From b779c29df84f28dd99526c4437015366ebe6916c Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Tue, 19 Nov 2024 13:51:17 +0100 Subject: [PATCH 03/13] fix test --- test/upgrade.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/upgrade.js b/test/upgrade.js index d1f50813..93cfe2dc 100644 --- a/test/upgrade.js +++ b/test/upgrade.js @@ -1027,7 +1027,7 @@ function open (store) { async function applyv0 (batch, view, base) { for (const { value } of batch) { - await view.version.append(value.version) + await view.version.append(value.version || 0) if (value.version > 0) { throw new Error('Upgrade required') From 679d3da5f29e9242140823ee9235ecba26a16fef Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Sat, 23 Nov 2024 17:28:28 +0100 Subject: [PATCH 04/13] slowly mode extensions to primary core instead so its stable --- index.js | 5 +++++ lib/extension.js | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index feab47c4..6bdf2d47 100644 --- a/index.js +++ b/index.js @@ -19,6 +19,8 @@ const ActiveWriters = require('./lib/active-writers') const CorePool = require('./lib/core-pool') const AutoWakeup = require('./lib/wakeup') +const WakeupExtension = require('./lib/extension') + const inspect = Symbol.for('nodejs.util.inspect.custom') const INTERRUPT = new Error('Apply interrupted') @@ -56,6 +58,7 @@ module.exports = class Autobase extends ReadyResource { this._primaryBootstrap = null if (this.bootstrap) { this._primaryBootstrap = this.store.get({ key: this.bootstrap, compat: false, active: false, encryptionKey: this.encryptionKey }) + this.wakeupExtension = new WakeupExtension(this, this._primaryBootstrap, true) this.store = this.store.namespace(this._primaryBootstrap, { detach: false }) } @@ -277,6 +280,7 @@ module.exports = class Autobase extends ReadyResource { const ref = await this.local.getUserData('referrer') if (ref && !b4a.equals(ref, this.local.key) && !this._primaryBootstrap) { this._primaryBootstrap = this.store.get({ key: ref, compat: false, active: false, encryptionKey: this.encryptionKey }) + this.wakeupExtension = new WakeupExtension(this, this._primaryBootstrap, true) this.store = this.store.namespace(this._primaryBootstrap, { detach: false }) } @@ -288,6 +292,7 @@ module.exports = class Autobase extends ReadyResource { if (this.encryptionKey) await this._primaryBootstrap.setUserData('autobase/encryption', this.encryptionKey) } else { this.local.setUserData('autobase/local', this.local.key) + this.wakeupExtension = new WakeupExtension(this, this.local, true) } const { bootstrap, system, heads } = await this._loadSystemInfo() diff --git a/lib/extension.js b/lib/extension.js index 70217e4c..f103b61b 100644 --- a/lib/extension.js +++ b/lib/extension.js @@ -5,7 +5,7 @@ const { Wakeup } = require('./messages') const VERSION = 1 module.exports = class WakeupExtension { - constructor (base, core) { + constructor (base, core, passive) { this.base = base this.core = core @@ -19,8 +19,10 @@ module.exports = class WakeupExtension { this.extension.send(req, peer) }) - for (const peer of this.core.peers) { - this.extension.send(req, peer) + if (!passive) { + for (const peer of this.core.peers) { + this.extension.send(req, peer) + } } } From 6683144368fef67fe93840ecfc2b51ea9e2e1bcc Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Sat, 23 Nov 2024 17:30:22 +0100 Subject: [PATCH 05/13] 6.5.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4329a12b..85a9a657 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "autobase", - "version": "6.5.10", + "version": "6.5.11", "description": "", "main": "index.js", "scripts": { From b6bb796a6fe6374b880a0fa0410da38c9b0c68b5 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Mon, 2 Dec 2024 10:31:44 +0100 Subject: [PATCH 06/13] support encrypt option for stateless generation --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index 6bdf2d47..7f81a059 100644 --- a/index.js +++ b/index.js @@ -52,6 +52,7 @@ module.exports = class Autobase extends ReadyResource { this.store = store this.globalCache = store.globalCache || null this.encrypted = handlers.encrypted || !!handlers.encryptionKey + this.encrypt = !!handlers.encrypt this.encryptionKey = handlers.encryptionKey || null this._tryLoadingLocal = true @@ -272,6 +273,11 @@ module.exports = class Autobase extends ReadyResource { } } + if (this.encrypt && this.encryptionKey === null) { + this.encryptionKey = (await this.store.createKeyPair('autobase/encryption')).secretKey.subarray(0, 32) + await this.local.setUserData('autobase/encryption', this.encryptionKey) + } + if (this.encrypted) { assert(this.encryptionKey !== null, 'Encryption key is expected') } From 4223a7d43c2d716fe5cba69689c21209b80c34ca Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Mon, 2 Dec 2024 10:32:19 +0100 Subject: [PATCH 07/13] 6.5.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 85a9a657..5245b4b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "autobase", - "version": "6.5.11", + "version": "6.5.12", "description": "", "main": "index.js", "scripts": { From 96452ac5ce8d527f89b376b9344c11458afb378c Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Mon, 2 Dec 2024 12:06:29 +0100 Subject: [PATCH 08/13] move up auto gen of enc key --- index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 7f81a059..3d56a19c 100644 --- a/index.js +++ b/index.js @@ -266,6 +266,10 @@ module.exports = class Autobase extends ReadyResource { await this.local.setUserData('autobase/encryption', this.encryptionKey) } else { this.encryptionKey = await this.local.getUserData('autobase/encryption') + if (this.encrypt && this.encryptionKey === null) { + this.encryptionKey = (await this.store.createKeyPair('autobase/encryption')).secretKey.subarray(0, 32) + await this.local.setUserData('autobase/encryption', this.encryptionKey) + } if (this.encryptionKey) { await this.local.setEncryptionKey(this.encryptionKey) // not needed but, just for good meassure @@ -273,11 +277,6 @@ module.exports = class Autobase extends ReadyResource { } } - if (this.encrypt && this.encryptionKey === null) { - this.encryptionKey = (await this.store.createKeyPair('autobase/encryption')).secretKey.subarray(0, 32) - await this.local.setUserData('autobase/encryption', this.encryptionKey) - } - if (this.encrypted) { assert(this.encryptionKey !== null, 'Encryption key is expected') } From fe2931392738f6fcc158ca575ec5ed1d66f1f431 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Mon, 2 Dec 2024 12:06:31 +0100 Subject: [PATCH 09/13] 6.5.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5245b4b6..efe89abf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "autobase", - "version": "6.5.12", + "version": "6.5.13", "description": "", "main": "index.js", "scripts": { From 92dd139c64f819e11fcb7c545aa37f14d4e50ada Mon Sep 17 00:00:00 2001 From: HDegroote <75906619+HDegroote@users.noreply.github.com> Date: Fri, 6 Dec 2024 17:51:38 +0100 Subject: [PATCH 10/13] Temp skip flaky autoack test (#196) --- test/autoack.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/autoack.js b/test/autoack.js index 15101be4..d513fa5d 100644 --- a/test/autoack.js +++ b/test/autoack.js @@ -41,7 +41,8 @@ test('autoack - simple', async t => { }, 100) }) -test('autoack - 5 writers', async t => { +// TODO: unflake this test (skipping to avoid false positives on canary) +test.skip('autoack - 5 writers', async t => { t.plan(21) const ackInterval = 50 From 4e8eff5c92ba7c47186287dc4eab5e8834c16154 Mon Sep 17 00:00:00 2001 From: HDegroote <75906619+HDegroote@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:07:19 +0100 Subject: [PATCH 11/13] Temp skip flaky test (#197) --- test/fast-forward.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/fast-forward.js b/test/fast-forward.js index 05825db3..94002154 100644 --- a/test/fast-forward.js +++ b/test/fast-forward.js @@ -125,7 +125,10 @@ test('fast-forward - fast forward after migrate', async t => { t.comment('percentage: ' + (sparse / core.length * 100).toFixed(2) + '%') }) -test('fast-forward - multiple writers added', async t => { +// TODO: re-enable this test when rocks is in. +// Skipping because it is flaky: around 10% of the time it hangs forever +// (So make sure to verify that it no longer flakes when re-enabling) +test.skip('fast-forward - multiple writers added', async t => { t.plan(2) const MESSAGES_PER_ROUND = 200 From b74e23a94f06a6d9775c59a1d8514fec813d42d4 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 12 Dec 2024 19:14:43 +1100 Subject: [PATCH 12/13] Update ci.yaml (#198) --- .github/workflows/ci.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d54dbac7..a86ca352 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,8 +9,7 @@ on: pull_request: branches: - main -env: - BRITTLE_TIMEOUT: 60000 + jobs: test: if: ${{ !startsWith(github.ref, 'refs/tags/')}} # Already runs for the push of the commit, no need to run again for the tag From 775699f95fea019be71e801d79f4bec51b295478 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 12 Dec 2024 19:15:09 +1100 Subject: [PATCH 13/13] remove-BRITTLE_TIMEOUT (#199) remove-BRITTLE_TIMEOUT --- .github/workflows/manual.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/manual.yaml b/.github/workflows/manual.yaml index 85d93b83..dba8bcc4 100644 --- a/.github/workflows/manual.yaml +++ b/.github/workflows/manual.yaml @@ -7,8 +7,6 @@ on: required: true type: string -env: - BRITTLE_TIMEOUT: 60000 jobs: deploy: runs-on: ${{ matrix.os }}