hyper-multisig-cli 1.6.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.js +56 -8
- package/package.json +2 -2
package/bin.js
CHANGED
|
@@ -14,6 +14,7 @@ const z32 = require('z32')
|
|
|
14
14
|
const DEFAULT_CONFIG_PATH = './multisig.json'
|
|
15
15
|
const DEFAULT_STORAGE_PATH = './storage'
|
|
16
16
|
const DEFAULT_SEED_LOG_INTERVAL = 15000
|
|
17
|
+
const DEFAULT_PROGRESS_LOG_INTERVAL = 2000
|
|
17
18
|
|
|
18
19
|
const cmdLink = command('link', description('Create multisig key'), wrapErrHandler(link))
|
|
19
20
|
|
|
@@ -29,6 +30,8 @@ const cmdRequest = command(
|
|
|
29
30
|
const cmdVerify = command(
|
|
30
31
|
'verify',
|
|
31
32
|
description('Verify multisig'),
|
|
33
|
+
flag('--start <start>', 'Start length'),
|
|
34
|
+
flag('--blobs-start <blobsStart>', 'Blobs start length'),
|
|
32
35
|
flag(
|
|
33
36
|
'--first-commit',
|
|
34
37
|
'Set when this is the first commit to the multisig target, so it skips those checks'
|
|
@@ -36,6 +39,9 @@ const cmdVerify = command(
|
|
|
36
39
|
flag('--skip-target-well-seeded', 'Skip checking multisig target is well seeded'),
|
|
37
40
|
|
|
38
41
|
flag('--peer-update-timeout <ms>', 'Peer update timeout in ms'),
|
|
42
|
+
flag('--progress-log-interval <ms>', 'Minimum interval in ms between progress logs').default(
|
|
43
|
+
DEFAULT_PROGRESS_LOG_INTERVAL
|
|
44
|
+
),
|
|
39
45
|
arg('request', 'Signing request'),
|
|
40
46
|
rest('[...responses]', 'Signing responses'),
|
|
41
47
|
wrapErrHandler(verify)
|
|
@@ -52,6 +58,9 @@ const cmdCommit = command(
|
|
|
52
58
|
flag('--skip-target-well-seeded', 'Skip checking multisig target is well seeded'),
|
|
53
59
|
flag('--force-dangerous', 'Advanced option, it might break the core on misuse'),
|
|
54
60
|
flag('--peer-update-timeout <ms>', 'Peer update timeout in ms'),
|
|
61
|
+
flag('--progress-log-interval <ms>', 'Minimum interval in ms between progress logs').default(
|
|
62
|
+
DEFAULT_PROGRESS_LOG_INTERVAL
|
|
63
|
+
),
|
|
55
64
|
arg('request', 'Signing request'),
|
|
56
65
|
rest('[...responses]', 'Signing responses'),
|
|
57
66
|
wrapErrHandler(commit)
|
|
@@ -141,7 +150,9 @@ async function request() {
|
|
|
141
150
|
}
|
|
142
151
|
|
|
143
152
|
async function verify() {
|
|
144
|
-
const { firstCommit, peerUpdateTimeout, skipTargetWellSeeded } =
|
|
153
|
+
const { start, blobsStart, firstCommit, peerUpdateTimeout, skipTargetWellSeeded } =
|
|
154
|
+
cmdVerify.flags
|
|
155
|
+
const progressLogInterval = +cmdVerify.flags.progressLogInterval
|
|
145
156
|
const request = cmdVerify.args.request
|
|
146
157
|
const responses = cmdVerify.rest || []
|
|
147
158
|
if (!request) throw new Error('Invalid command')
|
|
@@ -154,8 +165,9 @@ async function verify() {
|
|
|
154
165
|
let runner
|
|
155
166
|
if (type === 'core') {
|
|
156
167
|
const srcCore = store.get({ key: idEnc.decode(srcKey) })
|
|
157
|
-
|
|
158
|
-
|
|
168
|
+
logDownloadProgress(srcCore, progressLogInterval)
|
|
169
|
+
runner = multisig.verifyCore(publicKeys, namespace, srcCore, request, responses, {
|
|
170
|
+
start,
|
|
159
171
|
skipTargetChecks: firstCommit,
|
|
160
172
|
skipTargetWellSeeded,
|
|
161
173
|
peerUpdateTimeout: peerUpdateTimeout,
|
|
@@ -164,8 +176,11 @@ async function verify() {
|
|
|
164
176
|
})
|
|
165
177
|
} else {
|
|
166
178
|
const srcDrive = new Hyperdrive(store, idEnc.decode(srcKey))
|
|
167
|
-
|
|
168
|
-
|
|
179
|
+
logDownloadProgress(srcDrive.core, progressLogInterval)
|
|
180
|
+
srcDrive.once('blobs', (blobs) => logDownloadProgress(blobs.core, progressLogInterval))
|
|
181
|
+
runner = multisig.verifyDrive(publicKeys, namespace, srcDrive, request, responses, {
|
|
182
|
+
start,
|
|
183
|
+
blobsStart,
|
|
169
184
|
skipTargetChecks: firstCommit,
|
|
170
185
|
skipTargetWellSeeded,
|
|
171
186
|
peerUpdateTimeout: peerUpdateTimeout,
|
|
@@ -173,7 +188,7 @@ async function verify() {
|
|
|
173
188
|
quorum
|
|
174
189
|
})
|
|
175
190
|
}
|
|
176
|
-
setupProgressLogs(runner, type, firstCommit, true)
|
|
191
|
+
setupProgressLogs(runner, type, firstCommit, true, progressLogInterval)
|
|
177
192
|
|
|
178
193
|
const res = await runner.done()
|
|
179
194
|
|
|
@@ -188,6 +203,7 @@ async function commit() {
|
|
|
188
203
|
const responses = cmdCommit.rest || []
|
|
189
204
|
const { swarmClientOnly, firstCommit, skipTargetWellSeeded, forceDangerous, peerUpdateTimeout } =
|
|
190
205
|
cmdCommit.flags
|
|
206
|
+
const progressLogInterval = +cmdCommit.flags.progressLogInterval
|
|
191
207
|
|
|
192
208
|
if (!request || !responses?.length) throw new Error('Invalid command')
|
|
193
209
|
|
|
@@ -200,6 +216,7 @@ async function commit() {
|
|
|
200
216
|
let runner
|
|
201
217
|
if (type === 'core') {
|
|
202
218
|
const srcCore = store.get({ key: idEnc.decode(srcKey) })
|
|
219
|
+
logDownloadProgress(srcCore, progressLogInterval)
|
|
203
220
|
runner = multisig.commitCore(publicKeys, namespace, srcCore, request, responses, {
|
|
204
221
|
swarmAsServer: !swarmClientOnly,
|
|
205
222
|
skipTargetChecks: firstCommit,
|
|
@@ -210,6 +227,8 @@ async function commit() {
|
|
|
210
227
|
})
|
|
211
228
|
} else {
|
|
212
229
|
const srcDrive = new Hyperdrive(store, idEnc.decode(srcKey))
|
|
230
|
+
logDownloadProgress(srcDrive.core, progressLogInterval)
|
|
231
|
+
srcDrive.once('blobs', (blobs) => logDownloadProgress(blobs.core, progressLogInterval))
|
|
213
232
|
runner = multisig.commitDrive(publicKeys, namespace, srcDrive, request, responses, {
|
|
214
233
|
swarmAsServer: !swarmClientOnly,
|
|
215
234
|
skipTargetChecks: firstCommit,
|
|
@@ -219,7 +238,7 @@ async function commit() {
|
|
|
219
238
|
quorum
|
|
220
239
|
})
|
|
221
240
|
}
|
|
222
|
-
setupProgressLogs(runner, type, firstCommit, false)
|
|
241
|
+
setupProgressLogs(runner, type, firstCommit, false, progressLogInterval)
|
|
223
242
|
|
|
224
243
|
const res = await runner.done()
|
|
225
244
|
|
|
@@ -315,7 +334,7 @@ async function seed() {
|
|
|
315
334
|
goodbye(() => clearInterval(interval))
|
|
316
335
|
}
|
|
317
336
|
|
|
318
|
-
function setupProgressLogs(req, name, firstCommit, dryRun) {
|
|
337
|
+
function setupProgressLogs(req, name, firstCommit, dryRun, progressLogInterval) {
|
|
319
338
|
req.on('verify-committable-start', (srcKey, tgtKey) => {
|
|
320
339
|
console.log(
|
|
321
340
|
`Verifying the ${name} is safe to commit: source ${idEnc.normalize(srcKey)} (hex: ${srcKey.toString('hex')}) to multisig target ${idEnc.normalize(tgtKey)} (hex: ${tgtKey.toString('hex')})`
|
|
@@ -324,6 +343,11 @@ function setupProgressLogs(req, name, firstCommit, dryRun) {
|
|
|
324
343
|
req.on('commit-start', () => {
|
|
325
344
|
console.log(dryRun ? `Dry running the ${name} commit` : `Committing the ${name}...`)
|
|
326
345
|
})
|
|
346
|
+
req.on('commit-blobs-progress', logBatchProgress('blobs batch', progressLogInterval))
|
|
347
|
+
req.on(
|
|
348
|
+
'commit-progress',
|
|
349
|
+
logBatchProgress(name === 'drive' ? 'db batch' : 'batch', progressLogInterval)
|
|
350
|
+
)
|
|
327
351
|
req.on('verify-committed-start', (key) => {
|
|
328
352
|
console.log(`Committed the ${name}, key ${idEnc.normalize(key)} (hex: ${key.toString('hex')})`)
|
|
329
353
|
console.log('Waiting for remote seeders to pick up the changes...')
|
|
@@ -335,6 +359,30 @@ function setupProgressLogs(req, name, firstCommit, dryRun) {
|
|
|
335
359
|
})
|
|
336
360
|
}
|
|
337
361
|
|
|
362
|
+
function logBatchProgress(label, interval) {
|
|
363
|
+
let lastLog = 0
|
|
364
|
+
return ({ processed, total }) => {
|
|
365
|
+
const now = Date.now()
|
|
366
|
+
if (processed < total && now - lastLog < interval) return
|
|
367
|
+
lastLog = now
|
|
368
|
+
console.log(`Preparing ${label}: ${processed} / ${total} blocks`)
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function logDownloadProgress(core, interval) {
|
|
373
|
+
let downloaded = 0
|
|
374
|
+
let lastLog = 0
|
|
375
|
+
core.on('download', () => {
|
|
376
|
+
downloaded++
|
|
377
|
+
const now = Date.now()
|
|
378
|
+
if (now - lastLog < interval) return
|
|
379
|
+
lastLog = now
|
|
380
|
+
console.log(
|
|
381
|
+
`Downloading source core ${idEnc.normalize(core.key)}: ${downloaded} blocks downloaded`
|
|
382
|
+
)
|
|
383
|
+
})
|
|
384
|
+
}
|
|
385
|
+
|
|
338
386
|
function printRequest(request) {
|
|
339
387
|
const runner = SignRequest.decode(request)
|
|
340
388
|
const reqStr = z32.encode(request)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyper-multisig-cli",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "CLI of hyper-multisig",
|
|
5
5
|
"main": "bin.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"bare-fs": "^4.5.4",
|
|
22
22
|
"corestore": "^7.8.0",
|
|
23
23
|
"graceful-goodbye": "^1.3.3",
|
|
24
|
-
"hyper-multisig": "^2.
|
|
24
|
+
"hyper-multisig": "^2.5.0",
|
|
25
25
|
"hypercore-id-encoding": "^1.3.0",
|
|
26
26
|
"hypercore-signing-request": "^5.0.1",
|
|
27
27
|
"hyperdrive": "^13.2.1",
|