trac-peer 0.2.12-rc.1 → 0.2.12
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/.github/workflows/publish.yml +1 -1
- package/package.json +1 -3
- package/scripts/run-peer.mjs +1 -1
- package/peer.mjs +0 -5
- package/scripts/smoke-msb-sync.mjs +0 -113
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trac-peer",
|
|
3
3
|
"main": "src/index.js",
|
|
4
|
-
"version": "0.2.12
|
|
4
|
+
"version": "0.2.12",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"pear": {
|
|
7
7
|
"name": "trac-peer",
|
|
@@ -13,11 +13,9 @@
|
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
|
-
"bare": "./peer.mjs",
|
|
17
16
|
"node": "./src/index.js",
|
|
18
17
|
"default": "./src/index.js"
|
|
19
18
|
},
|
|
20
|
-
"./peer": "./peer.mjs",
|
|
21
19
|
"./src/*": "./src/*"
|
|
22
20
|
},
|
|
23
21
|
"scripts": {
|
package/scripts/run-peer.mjs
CHANGED
|
@@ -218,7 +218,7 @@ if (!subnetBootstrap) {
|
|
|
218
218
|
|
|
219
219
|
console.log("");
|
|
220
220
|
console.log("==================== TRAC-PEER RUNNER ====================");
|
|
221
|
-
console.log("MSB network bootstrap:", msb.config.bootstrap
|
|
221
|
+
console.log("MSB network bootstrap:", b4a.toString(msb.config.bootstrap, "hex") ?? null);
|
|
222
222
|
console.log("MSB channel:", b4a.toString(msb.config.channel, "utf8"));
|
|
223
223
|
console.log("MSB wallet address:", msb.wallet?.address ?? null);
|
|
224
224
|
console.log("----------------------------------------------------------");
|
package/peer.mjs
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import b4a from "b4a";
|
|
2
|
-
import PeerWallet from "trac-wallet";
|
|
3
|
-
|
|
4
|
-
import { Peer, Wallet, Protocol, Contract } from "../src/index.js";
|
|
5
|
-
import { deploySubnet } from "../src/functions.js";
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
initTemporaryDirectory,
|
|
9
|
-
removeTemporaryDirectory,
|
|
10
|
-
setupMsbAdmin,
|
|
11
|
-
setupMsbWriter,
|
|
12
|
-
setupMsbPeer,
|
|
13
|
-
tryToSyncWriters,
|
|
14
|
-
randomBytes,
|
|
15
|
-
initDirectoryStructure,
|
|
16
|
-
fundPeer,
|
|
17
|
-
} from "trac-msb/tests/helpers/setupApplyTests.js";
|
|
18
|
-
import {
|
|
19
|
-
testKeyPair1,
|
|
20
|
-
testKeyPair2,
|
|
21
|
-
testKeyPair3,
|
|
22
|
-
testKeyPair4,
|
|
23
|
-
} from "trac-msb/tests/fixtures/apply.fixtures.js";
|
|
24
|
-
import { getDeploymentCommand } from "trac-msb/src/utils/cliCommands.js";
|
|
25
|
-
import { $TNK } from "trac-msb/src/core/state/utils/balance.js";
|
|
26
|
-
|
|
27
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
28
|
-
|
|
29
|
-
let tmp = null;
|
|
30
|
-
let admin = null;
|
|
31
|
-
let writer = null;
|
|
32
|
-
let reader = null;
|
|
33
|
-
let peer = null;
|
|
34
|
-
|
|
35
|
-
async function cleanupAndExit(code) {
|
|
36
|
-
await Promise.allSettled([
|
|
37
|
-
peer?.close?.(),
|
|
38
|
-
reader?.msb?.close?.(),
|
|
39
|
-
writer?.msb?.close?.(),
|
|
40
|
-
admin?.msb?.close?.(),
|
|
41
|
-
]);
|
|
42
|
-
if (tmp) await removeTemporaryDirectory(tmp).catch(() => {});
|
|
43
|
-
process.exit(code);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
process.on("SIGINT", () => cleanupAndExit(130));
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
tmp = await initTemporaryDirectory();
|
|
50
|
-
|
|
51
|
-
const opts = {
|
|
52
|
-
bootstrap: b4a.toString(randomBytes(32), "hex"),
|
|
53
|
-
channel: b4a.toString(randomBytes(32), "hex"),
|
|
54
|
-
enable_role_requester: false,
|
|
55
|
-
enable_wallet: true,
|
|
56
|
-
enable_validator_observer: true,
|
|
57
|
-
enable_interactive_mode: false,
|
|
58
|
-
disable_rate_limit: true,
|
|
59
|
-
enable_tx_apply_logs: false,
|
|
60
|
-
enable_error_apply_logs: false,
|
|
61
|
-
stores_directory: `${tmp}/stores/`,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
admin = await setupMsbAdmin(testKeyPair1, tmp, opts);
|
|
65
|
-
writer = await setupMsbWriter(admin, "writer", testKeyPair2, tmp, admin.options);
|
|
66
|
-
reader = await setupMsbPeer("reader", testKeyPair3, tmp, admin.options);
|
|
67
|
-
await tryToSyncWriters(admin, writer, reader);
|
|
68
|
-
|
|
69
|
-
// Fund a non-validator account that will be used as the subnet deployer.
|
|
70
|
-
const deployerWallet = new PeerWallet(testKeyPair4);
|
|
71
|
-
await deployerWallet.ready;
|
|
72
|
-
await fundPeer(admin, { wallet: deployerWallet }, $TNK(10n));
|
|
73
|
-
await sleep(250);
|
|
74
|
-
await tryToSyncWriters(admin, writer, reader);
|
|
75
|
-
|
|
76
|
-
// Create a Peer keypair file for the same deployer account.
|
|
77
|
-
const peerDir = await initDirectoryStructure("subnetpeer", testKeyPair4, tmp);
|
|
78
|
-
|
|
79
|
-
peer = new Peer({
|
|
80
|
-
stores_directory: peerDir.storesDirectory,
|
|
81
|
-
store_name: peerDir.storeName,
|
|
82
|
-
msb: reader.msb,
|
|
83
|
-
wallet: new Wallet(),
|
|
84
|
-
protocol: Protocol,
|
|
85
|
-
contract: Contract,
|
|
86
|
-
bootstrap: randomBytes(32),
|
|
87
|
-
channel: "subnet-peer-test",
|
|
88
|
-
enable_interactive_mode: false,
|
|
89
|
-
replicate: false,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
await peer.ready();
|
|
93
|
-
|
|
94
|
-
const subnetBootstrapHex = b4a.isBuffer(peer.bootstrap)
|
|
95
|
-
? b4a.toString(peer.bootstrap, "hex")
|
|
96
|
-
: String(peer.bootstrap);
|
|
97
|
-
|
|
98
|
-
console.log("Peer ready.");
|
|
99
|
-
console.log("Subnet bootstrap:", subnetBootstrapHex);
|
|
100
|
-
|
|
101
|
-
const payload = await deploySubnet("/deploy_subnet", peer);
|
|
102
|
-
console.log("deploySubnet tx:", payload?.bdo?.tx ?? null);
|
|
103
|
-
|
|
104
|
-
await sleep(2000);
|
|
105
|
-
await reader.msb.state.base.view.update();
|
|
106
|
-
|
|
107
|
-
await getDeploymentCommand(reader.msb.state, subnetBootstrapHex);
|
|
108
|
-
|
|
109
|
-
await cleanupAndExit(0);
|
|
110
|
-
} catch (e) {
|
|
111
|
-
console.error(e);
|
|
112
|
-
await cleanupAndExit(1);
|
|
113
|
-
}
|