@agoric/cosmic-swingset 0.41.4-dev-af62279.0 → 0.41.4-dev-22cbeb1.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/package.json +10 -10
- package/src/chain-main.js +78 -64
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cosmic-swingset",
|
|
3
|
-
"version": "0.41.4-dev-
|
|
3
|
+
"version": "0.41.4-dev-22cbeb1.0+22cbeb1",
|
|
4
4
|
"description": "Agoric's Cosmos blockchain integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/assert": "0.6.1-dev-
|
|
26
|
-
"@agoric/cosmos": "0.34.2-dev-
|
|
27
|
-
"@agoric/deploy-script-support": "0.10.4-dev-
|
|
28
|
-
"@agoric/internal": "0.3.3-dev-
|
|
29
|
-
"@agoric/store": "0.9.3-dev-
|
|
30
|
-
"@agoric/swing-store": "0.9.2-dev-
|
|
31
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
32
|
-
"@agoric/telemetry": "0.6.3-dev-
|
|
25
|
+
"@agoric/assert": "0.6.1-dev-22cbeb1.0+22cbeb1",
|
|
26
|
+
"@agoric/cosmos": "0.34.2-dev-22cbeb1.0+22cbeb1",
|
|
27
|
+
"@agoric/deploy-script-support": "0.10.4-dev-22cbeb1.0+22cbeb1",
|
|
28
|
+
"@agoric/internal": "0.3.3-dev-22cbeb1.0+22cbeb1",
|
|
29
|
+
"@agoric/store": "0.9.3-dev-22cbeb1.0+22cbeb1",
|
|
30
|
+
"@agoric/swing-store": "0.9.2-dev-22cbeb1.0+22cbeb1",
|
|
31
|
+
"@agoric/swingset-vat": "0.32.3-dev-22cbeb1.0+22cbeb1",
|
|
32
|
+
"@agoric/telemetry": "0.6.3-dev-22cbeb1.0+22cbeb1",
|
|
33
33
|
"@endo/far": "^0.2.18",
|
|
34
34
|
"@endo/import-bundle": "^0.3.4",
|
|
35
35
|
"@endo/init": "^0.5.56",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
],
|
|
61
61
|
"timeout": "20m"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "22cbeb145d1b74d9d5ceecce7cd4253ba23d534a"
|
|
64
64
|
}
|
package/src/chain-main.js
CHANGED
|
@@ -240,11 +240,11 @@ export default async function main(progname, args, { env, homedir, agcc }) {
|
|
|
240
240
|
/** @type {((obj: object) => void) | undefined} */
|
|
241
241
|
let writeSlogObject;
|
|
242
242
|
|
|
243
|
-
//
|
|
244
|
-
// so
|
|
245
|
-
//
|
|
243
|
+
// the storagePort used to change for every single message. It's defined out
|
|
244
|
+
// here so 'sendToChainStorage' can close over the single mutable instance,
|
|
245
|
+
// when we updated the 'portNums.storage' value each time toSwingSet was called.
|
|
246
246
|
async function launchAndInitializeSwingSet(bootMsg) {
|
|
247
|
-
const
|
|
247
|
+
const sendToChainStorage = msg => chainSend(portNums.storage, msg);
|
|
248
248
|
// this object is used to store the mailbox state.
|
|
249
249
|
const fromBridgeMailbox = data => {
|
|
250
250
|
const ack = toNumber(data.ack);
|
|
@@ -253,7 +253,7 @@ export default async function main(progname, args, { env, homedir, agcc }) {
|
|
|
253
253
|
};
|
|
254
254
|
const mailboxStorage = makeReadCachingStorage(
|
|
255
255
|
makePrefixedBridgeStorage(
|
|
256
|
-
|
|
256
|
+
sendToChainStorage,
|
|
257
257
|
`${STORAGE_PATH.MAILBOX}.`,
|
|
258
258
|
'legacySet',
|
|
259
259
|
val => fromBridgeMailbox(JSON.parse(val)),
|
|
@@ -263,7 +263,7 @@ export default async function main(progname, args, { env, homedir, agcc }) {
|
|
|
263
263
|
const makeQueueStorage = queuePath => {
|
|
264
264
|
const { kvStore, commit, abort } = makeBufferedStorage(
|
|
265
265
|
makePrefixedBridgeStorage(
|
|
266
|
-
|
|
266
|
+
sendToChainStorage,
|
|
267
267
|
`${queuePath}.`,
|
|
268
268
|
'setWithoutNotify',
|
|
269
269
|
x => x,
|
|
@@ -305,7 +305,7 @@ export default async function main(progname, args, { env, homedir, agcc }) {
|
|
|
305
305
|
}
|
|
306
306
|
return [path, value];
|
|
307
307
|
});
|
|
308
|
-
|
|
308
|
+
sendToChainStorage(
|
|
309
309
|
stringify({
|
|
310
310
|
method: 'setWithoutNotify',
|
|
311
311
|
args: entries,
|
|
@@ -493,6 +493,9 @@ export default async function main(progname, args, { env, homedir, agcc }) {
|
|
|
493
493
|
};
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
+
/** @type {Awaited<ReturnType<typeof launch>>['blockingSend'] | undefined} */
|
|
497
|
+
let blockingSend;
|
|
498
|
+
|
|
496
499
|
async function handleCosmosSnapshot(blockHeight, request, requestArgs) {
|
|
497
500
|
await null;
|
|
498
501
|
switch (request) {
|
|
@@ -501,6 +504,9 @@ export default async function main(progname, args, { env, homedir, agcc }) {
|
|
|
501
504
|
if (typeof exportDir !== 'string') {
|
|
502
505
|
throw Fail`Invalid exportDir argument ${q(exportDir)}`;
|
|
503
506
|
}
|
|
507
|
+
!stateSyncExport ||
|
|
508
|
+
Fail`Snapshot already in progress for ${stateSyncExport.blockHeight}`;
|
|
509
|
+
!blockingSend || Fail`Cannot restore snapshot after init`;
|
|
504
510
|
console.info(
|
|
505
511
|
'Restoring SwingSet state from snapshot at block height',
|
|
506
512
|
blockHeight,
|
|
@@ -607,74 +613,82 @@ export default async function main(progname, args, { env, homedir, agcc }) {
|
|
|
607
613
|
}
|
|
608
614
|
}
|
|
609
615
|
|
|
610
|
-
/** @type {Awaited<ReturnType<typeof launch>>['blockingSend'] | undefined} */
|
|
611
|
-
let blockingSend;
|
|
612
|
-
|
|
613
616
|
async function toSwingSet(action, _replier) {
|
|
614
617
|
// console.log(`toSwingSet`, action);
|
|
615
|
-
if (action.vibcPort) {
|
|
616
|
-
portNums.dibc = action.vibcPort;
|
|
617
|
-
}
|
|
618
618
|
|
|
619
|
-
|
|
620
|
-
// Initialize the storage for this particular transaction.
|
|
621
|
-
// console.log(` setting portNums.storage to`, action.storagePort);
|
|
622
|
-
portNums.storage = action.storagePort;
|
|
623
|
-
}
|
|
619
|
+
await null;
|
|
624
620
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
621
|
+
switch (action.type) {
|
|
622
|
+
case AG_COSMOS_INIT: {
|
|
623
|
+
// console.error('got AG_COSMOS_INIT', action);
|
|
628
624
|
|
|
629
|
-
|
|
630
|
-
portNums.lien = action.lienPort;
|
|
631
|
-
}
|
|
625
|
+
!blockingSend || Fail`Swingset already initialized`;
|
|
632
626
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
writeSlogObject?.({
|
|
637
|
-
type: 'cosmic-swingset-snapshot-start',
|
|
638
|
-
blockHeight,
|
|
639
|
-
request,
|
|
640
|
-
args: requestArgs,
|
|
641
|
-
});
|
|
627
|
+
if (action.vibcPort) {
|
|
628
|
+
portNums.dibc = action.vibcPort;
|
|
629
|
+
}
|
|
642
630
|
|
|
643
|
-
|
|
631
|
+
if (action.storagePort) {
|
|
632
|
+
portNums.storage = action.storagePort;
|
|
633
|
+
}
|
|
644
634
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
type: 'cosmic-swingset-snapshot-finish',
|
|
649
|
-
blockHeight,
|
|
650
|
-
request,
|
|
651
|
-
args: requestArgs,
|
|
652
|
-
result,
|
|
653
|
-
});
|
|
654
|
-
},
|
|
655
|
-
error => {
|
|
656
|
-
writeSlogObject?.({
|
|
657
|
-
type: 'cosmic-swingset-snapshot-finish',
|
|
658
|
-
blockHeight,
|
|
659
|
-
request,
|
|
660
|
-
args: requestArgs,
|
|
661
|
-
error,
|
|
662
|
-
});
|
|
663
|
-
},
|
|
664
|
-
);
|
|
635
|
+
if (action.vbankPort) {
|
|
636
|
+
portNums.bank = action.vbankPort;
|
|
637
|
+
}
|
|
665
638
|
|
|
666
|
-
|
|
667
|
-
|
|
639
|
+
if (action.lienPort) {
|
|
640
|
+
portNums.lien = action.lienPort;
|
|
641
|
+
}
|
|
642
|
+
harden(portNums);
|
|
668
643
|
|
|
669
|
-
|
|
670
|
-
|
|
644
|
+
// Ensure that initialization has completed.
|
|
645
|
+
blockingSend = await launchAndInitializeSwingSet(action);
|
|
671
646
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
647
|
+
return true;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// Snapshot actions are specific to cosmos chains and handled here
|
|
651
|
+
case ActionType.COSMOS_SNAPSHOT: {
|
|
652
|
+
const { blockHeight, request, args: requestArgs } = action;
|
|
653
|
+
writeSlogObject?.({
|
|
654
|
+
type: 'cosmic-swingset-snapshot-start',
|
|
655
|
+
blockHeight,
|
|
656
|
+
request,
|
|
657
|
+
args: requestArgs,
|
|
658
|
+
});
|
|
676
659
|
|
|
677
|
-
|
|
678
|
-
|
|
660
|
+
const resultP = handleCosmosSnapshot(blockHeight, request, requestArgs);
|
|
661
|
+
|
|
662
|
+
resultP.then(
|
|
663
|
+
result => {
|
|
664
|
+
writeSlogObject?.({
|
|
665
|
+
type: 'cosmic-swingset-snapshot-finish',
|
|
666
|
+
blockHeight,
|
|
667
|
+
request,
|
|
668
|
+
args: requestArgs,
|
|
669
|
+
result,
|
|
670
|
+
});
|
|
671
|
+
},
|
|
672
|
+
error => {
|
|
673
|
+
writeSlogObject?.({
|
|
674
|
+
type: 'cosmic-swingset-snapshot-finish',
|
|
675
|
+
blockHeight,
|
|
676
|
+
request,
|
|
677
|
+
args: requestArgs,
|
|
678
|
+
error,
|
|
679
|
+
});
|
|
680
|
+
},
|
|
681
|
+
);
|
|
682
|
+
|
|
683
|
+
return resultP;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
default: {
|
|
687
|
+
if (!blockingSend) throw Fail`Swingset not initialized`;
|
|
688
|
+
|
|
689
|
+
// Block related actions are processed by `blockingSend`
|
|
690
|
+
return blockingSend(action);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
679
693
|
}
|
|
680
694
|
}
|