hyper-multisig-cli 1.4.0 → 1.6.0
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/README.md +12 -0
- package/bin.js +23 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -173,3 +173,15 @@ Do as the logs instruct, and add your target key to 2 or more seeders. For this
|
|
|
173
173
|
Once the program detects at least 2 seeders have fully downloaded the multisig drive, it will inform you it is done. Shut down with ctrl-c.
|
|
174
174
|
|
|
175
175
|
Note: for any future updates to your multisig core, remove the `first-commit` flag.
|
|
176
|
+
|
|
177
|
+
## Recovering From Incompletely Seeded Commit (Advanced)
|
|
178
|
+
|
|
179
|
+
If the committer's process ends prematurely, after committing but before the commit got fully seeded, the multisig drive ends up in an incomplete state: the swarm knows its length has been updated, but does not have all new blocks.
|
|
180
|
+
|
|
181
|
+
Re-committing will trigger a 'TARGET_CORE_NOT_FULLY_SEEDED' error, which needs to be skipped for this recovery. But no other checks should be skipped.
|
|
182
|
+
|
|
183
|
+
Use the `--skip-target-well-seeded` flag to re-commit the drive. Note: re-committing is also possible from another machine.
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
hyper-multisig commit --skip-target-well-seeded ...
|
|
187
|
+
```
|
package/bin.js
CHANGED
|
@@ -33,6 +33,8 @@ const cmdVerify = command(
|
|
|
33
33
|
'--first-commit',
|
|
34
34
|
'Set when this is the first commit to the multisig target, so it skips those checks'
|
|
35
35
|
),
|
|
36
|
+
flag('--skip-target-well-seeded', 'Skip checking multisig target is well seeded'),
|
|
37
|
+
|
|
36
38
|
flag('--peer-update-timeout <ms>', 'Peer update timeout in ms'),
|
|
37
39
|
arg('request', 'Signing request'),
|
|
38
40
|
rest('[...responses]', 'Signing responses'),
|
|
@@ -42,10 +44,12 @@ const cmdVerify = command(
|
|
|
42
44
|
const cmdCommit = command(
|
|
43
45
|
'commit',
|
|
44
46
|
description('Commit multisig'),
|
|
47
|
+
flag('--swarm-client-only', 'Swarm in client mode only'),
|
|
45
48
|
flag(
|
|
46
49
|
'--first-commit',
|
|
47
50
|
'Set when this is the first commit to the multisig target, so it skips those checks'
|
|
48
51
|
),
|
|
52
|
+
flag('--skip-target-well-seeded', 'Skip checking multisig target is well seeded'),
|
|
49
53
|
flag('--force-dangerous', 'Advanced option, it might break the core on misuse'),
|
|
50
54
|
flag('--peer-update-timeout <ms>', 'Peer update timeout in ms'),
|
|
51
55
|
arg('request', 'Signing request'),
|
|
@@ -137,11 +141,11 @@ async function request() {
|
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
async function verify() {
|
|
140
|
-
const { firstCommit, peerUpdateTimeout } = cmdVerify.flags
|
|
144
|
+
const { firstCommit, peerUpdateTimeout, skipTargetWellSeeded } = cmdVerify.flags
|
|
141
145
|
const request = cmdVerify.args.request
|
|
142
146
|
const responses = cmdVerify.rest || []
|
|
143
147
|
if (!request) throw new Error('Invalid command')
|
|
144
|
-
console.info(`
|
|
148
|
+
console.info(`Verifying request ${request}`)
|
|
145
149
|
console.info(`Responses:\n -${responses.join('\n -')}`)
|
|
146
150
|
|
|
147
151
|
const { type, publicKeys, namespace, srcKey, quorum, store, swarm } = await setup()
|
|
@@ -153,7 +157,9 @@ async function verify() {
|
|
|
153
157
|
runner = multisig.commitCore(publicKeys, namespace, srcCore, request, responses, {
|
|
154
158
|
dryRun: true,
|
|
155
159
|
skipTargetChecks: firstCommit,
|
|
160
|
+
skipTargetWellSeeded,
|
|
156
161
|
peerUpdateTimeout: peerUpdateTimeout,
|
|
162
|
+
swarmAsServer: false,
|
|
157
163
|
quorum
|
|
158
164
|
})
|
|
159
165
|
} else {
|
|
@@ -161,11 +167,13 @@ async function verify() {
|
|
|
161
167
|
runner = multisig.commitDrive(publicKeys, namespace, srcDrive, request, responses, {
|
|
162
168
|
dryRun: true,
|
|
163
169
|
skipTargetChecks: firstCommit,
|
|
170
|
+
skipTargetWellSeeded,
|
|
164
171
|
peerUpdateTimeout: peerUpdateTimeout,
|
|
172
|
+
swarmAsServer: false,
|
|
165
173
|
quorum
|
|
166
174
|
})
|
|
167
175
|
}
|
|
168
|
-
setupProgressLogs(runner, type, firstCommit)
|
|
176
|
+
setupProgressLogs(runner, type, firstCommit, true)
|
|
169
177
|
|
|
170
178
|
const res = await runner.done()
|
|
171
179
|
|
|
@@ -178,7 +186,9 @@ async function verify() {
|
|
|
178
186
|
async function commit() {
|
|
179
187
|
const request = cmdCommit.args.request
|
|
180
188
|
const responses = cmdCommit.rest || []
|
|
181
|
-
const { firstCommit, forceDangerous, peerUpdateTimeout } =
|
|
189
|
+
const { swarmClientOnly, firstCommit, skipTargetWellSeeded, forceDangerous, peerUpdateTimeout } =
|
|
190
|
+
cmdCommit.flags
|
|
191
|
+
|
|
182
192
|
if (!request || !responses?.length) throw new Error('Invalid command')
|
|
183
193
|
|
|
184
194
|
console.info(`Committing request ${request}`)
|
|
@@ -191,7 +201,9 @@ async function commit() {
|
|
|
191
201
|
if (type === 'core') {
|
|
192
202
|
const srcCore = store.get({ key: idEnc.decode(srcKey) })
|
|
193
203
|
runner = multisig.commitCore(publicKeys, namespace, srcCore, request, responses, {
|
|
204
|
+
swarmAsServer: !swarmClientOnly,
|
|
194
205
|
skipTargetChecks: firstCommit,
|
|
206
|
+
skipTargetWellSeeded,
|
|
195
207
|
force: forceDangerous,
|
|
196
208
|
peerUpdateTimeout: peerUpdateTimeout,
|
|
197
209
|
quorum
|
|
@@ -199,13 +211,15 @@ async function commit() {
|
|
|
199
211
|
} else {
|
|
200
212
|
const srcDrive = new Hyperdrive(store, idEnc.decode(srcKey))
|
|
201
213
|
runner = multisig.commitDrive(publicKeys, namespace, srcDrive, request, responses, {
|
|
214
|
+
swarmAsServer: !swarmClientOnly,
|
|
202
215
|
skipTargetChecks: firstCommit,
|
|
216
|
+
skipTargetWellSeeded,
|
|
203
217
|
force: forceDangerous,
|
|
204
218
|
peerUpdateTimeout: peerUpdateTimeout,
|
|
205
219
|
quorum
|
|
206
220
|
})
|
|
207
221
|
}
|
|
208
|
-
setupProgressLogs(runner, type, firstCommit)
|
|
222
|
+
setupProgressLogs(runner, type, firstCommit, false)
|
|
209
223
|
|
|
210
224
|
const res = await runner.done()
|
|
211
225
|
|
|
@@ -301,14 +315,14 @@ async function seed() {
|
|
|
301
315
|
goodbye(() => clearInterval(interval))
|
|
302
316
|
}
|
|
303
317
|
|
|
304
|
-
function setupProgressLogs(req, name, firstCommit) {
|
|
318
|
+
function setupProgressLogs(req, name, firstCommit, dryRun) {
|
|
305
319
|
req.on('verify-committable-start', (srcKey, tgtKey) => {
|
|
306
320
|
console.log(
|
|
307
321
|
`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')})`
|
|
308
322
|
)
|
|
309
323
|
})
|
|
310
324
|
req.on('commit-start', () => {
|
|
311
|
-
console.log(`Committing the ${name}...`)
|
|
325
|
+
console.log(dryRun ? `Dry running the ${name} commit` : `Committing the ${name}...`)
|
|
312
326
|
})
|
|
313
327
|
req.on('verify-committed-start', (key) => {
|
|
314
328
|
console.log(`Committed the ${name}, key ${idEnc.normalize(key)} (hex: ${key.toString('hex')})`)
|
|
@@ -328,7 +342,8 @@ function printRequest(request) {
|
|
|
328
342
|
key: runner.id,
|
|
329
343
|
keyHex: runner.key.toString('hex'),
|
|
330
344
|
length: runner.length,
|
|
331
|
-
treeHash: idEnc.normalize(runner.treeHash)
|
|
345
|
+
treeHash: idEnc.normalize(runner.treeHash),
|
|
346
|
+
treeHashHex: runner.treeHash.toString('hex')
|
|
332
347
|
}
|
|
333
348
|
console.log('Request:', JSON.stringify(reqMsg, null, 2))
|
|
334
349
|
console.log('To sign, run:', `\nhypercore-sign ${reqStr}`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyper-multisig-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
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.3.0",
|
|
25
25
|
"hypercore-id-encoding": "^1.3.0",
|
|
26
26
|
"hypercore-signing-request": "^5.0.1",
|
|
27
27
|
"hyperdrive": "^13.2.1",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"bare-subprocess": "^5.2.2",
|
|
37
37
|
"brittle": "^3.19.1",
|
|
38
38
|
"hypercore-crypto": "^3.6.1",
|
|
39
|
-
"hypercore-sign": "^
|
|
39
|
+
"hypercore-sign-lib": "^1.1.0",
|
|
40
40
|
"hyperdht": "^6.29.0",
|
|
41
41
|
"lunte": "^1.6.0",
|
|
42
42
|
"newline-decoder": "^1.0.2",
|