@@ -14,19 +14,13 @@ import { makeBridgeManager } from './bridge';
14
14
15
15
const NUM_IBC_PORTS = 3 ;
16
16
17
- // The old way of provisioning used an environment variable that
18
- // was an account ACL. The new way uses "provisionpass", a
19
- // "bearer token" that is checked in handler.go before a provision
20
- // transaction is even sent to the JS side.
21
- const FIXME_DEPRECATED_BOOT_ADDRESS = true ;
22
-
23
17
console . debug ( `loading bootstrap.js` ) ;
24
18
25
19
function parseArgs ( argv ) {
26
20
let ROLE ;
27
21
let gotRoles = false ;
28
- let bootAddress ;
29
- const additionalAddresses = [ ] ;
22
+ const hardcodedClientAddresses = [ ] ;
23
+ let giveMeAllTheAgoricPowers = false ;
30
24
argv . forEach ( arg => {
31
25
const match = arg . match ( / ^ - - r o l e = ( .* ) $ / ) ;
32
26
if ( match ) {
@@ -35,24 +29,22 @@ function parseArgs(argv) {
35
29
}
36
30
[ , ROLE ] = match ;
37
31
gotRoles = true ;
38
- } else if ( ! arg . match ( / ^ - / ) ) {
39
- if ( ! bootAddress ) {
40
- bootAddress = arg ;
41
- } else {
42
- additionalAddresses . push ( arg ) ;
43
- }
32
+ } else if ( arg === `--give-me-all-the-agoric-powers` ) {
33
+ console . warn ( `Giving all the Agoric powers to the client!` ) ;
34
+ giveMeAllTheAgoricPowers = true ;
35
+ } else if ( arg . match ( / ^ - / ) ) {
36
+ throw Error ( `Unrecognized option ${ arg } ` ) ;
37
+ } else {
38
+ hardcodedClientAddresses . push ( arg ) ;
44
39
}
45
40
} ) ;
46
41
if ( ! gotRoles ) {
47
42
ROLE = 'three_client' ;
48
43
}
49
44
50
- return [ ROLE , bootAddress , additionalAddresses ] ;
45
+ return { ROLE , giveMeAllTheAgoricPowers , hardcodedClientAddresses } ;
51
46
}
52
47
53
- // Used in scenario 1 for coordinating on an index for registering public keys
54
- // while requesting provisioning.
55
- const KEY_REG_INDEX = 1 ;
56
48
// Used for coordinating on an index in comms for the provisioning service
57
49
const PROVISIONER_INDEX = 1 ;
58
50
@@ -75,7 +67,12 @@ export function buildRootObject(vatPowers) {
75
67
}
76
68
77
69
// Make services that are provided on the real or virtual chain side
78
- async function makeChainBundler ( vats , timerDevice , vatAdminSvc ) {
70
+ async function makeChainBundler (
71
+ vats ,
72
+ timerDevice ,
73
+ vatAdminSvc ,
74
+ giveMeAllTheAgoricPowers = false ,
75
+ ) {
79
76
// Create singleton instances.
80
77
const [
81
78
sharingService ,
@@ -112,15 +109,31 @@ export function buildRootObject(vatPowers) {
112
109
) ;
113
110
114
111
return harden ( {
115
- async createUserBundle ( _nickname ) {
112
+ async createUserBundle ( _nickname , powerFlags = [ ] ) {
116
113
// Bind to some fresh ports (unspecified name) on the IBC implementation
117
114
// and provide them for the user to have.
118
115
const ibcport = [ ] ;
119
116
for ( let i = 0 ; i < NUM_IBC_PORTS ; i += 1 ) {
120
117
// eslint-disable-next-line no-await-in-loop
121
118
ibcport . push ( await E ( vats . network ) . bind ( '/ibc-port/' ) ) ;
122
119
}
120
+
121
+ const additionalPowers = { } ;
122
+ const { vattp, comms } = vats ;
123
+ if (
124
+ giveMeAllTheAgoricPowers ||
125
+ powerFlags . includes ( 'agoric.vattp.makeNetworkHost' )
126
+ ) {
127
+ // Give the authority to create a new host for vattp to share objects with.
128
+ additionalPowers . vattp = {
129
+ makeNetworkHost ( allegedName ) {
130
+ return E ( vattp ) . makeNetworkHost ( allegedName , comms ) ;
131
+ } ,
132
+ } ;
133
+ }
134
+
123
135
const bundle = harden ( {
136
+ ...additionalPowers ,
124
137
chainTimerService,
125
138
sharingService,
126
139
contractHost,
@@ -287,7 +300,11 @@ export function buildRootObject(vatPowers) {
287
300
async bootstrap ( argv , vats , devices ) {
288
301
const bridgeManager =
289
302
devices . bridge && makeBridgeManager ( E , D , devices . bridge ) ;
290
- const [ ROLE , bootAddress , additionalAddresses ] = parseArgs ( argv ) ;
303
+ const {
304
+ ROLE ,
305
+ giveMeAllTheAgoricPowers,
306
+ hardcodedClientAddresses,
307
+ } = parseArgs ( argv ) ;
291
308
292
309
async function addRemote ( addr ) {
293
310
const { transmitter, setReceiver } = await E ( vats . vattp ) . addRemote (
@@ -298,12 +315,6 @@ export function buildRootObject(vatPowers) {
298
315
299
316
D ( devices . mailbox ) . registerInboundHandler ( vats . vattp ) ;
300
317
await E ( vats . vattp ) . registerMailboxDevice ( devices . mailbox ) ;
301
- if ( FIXME_DEPRECATED_BOOT_ADDRESS && bootAddress ) {
302
- // FIXME: The old way: register egresses for the addresses.
303
- await Promise . all (
304
- [ bootAddress , ...additionalAddresses ] . map ( addr => addRemote ( addr ) ) ,
305
- ) ;
306
- }
307
318
308
319
const vatAdminSvc = await E ( vats . vatAdmin ) . createVatAdminService (
309
320
devices . vatAdmin ,
@@ -315,6 +326,7 @@ export function buildRootObject(vatPowers) {
315
326
// client (python) on localhost, which creates client solo node on
316
327
// localhost, with HTML frontend. Multi-player mode.
317
328
switch ( ROLE ) {
329
+ // REAL VALIDATORS run this.
318
330
case 'chain' :
319
331
case 'one_chain' : {
320
332
// provisioning vat can ask the demo server for bundles, and can
@@ -327,56 +339,9 @@ export function buildRootObject(vatPowers) {
327
339
328
340
// Must occur after makeChainBundler.
329
341
await registerNetworkProtocols ( vats , bridgeManager ) ;
330
-
331
- if ( FIXME_DEPRECATED_BOOT_ADDRESS && bootAddress ) {
332
- // accept provisioning requests from the controller
333
- const provisioner = harden ( {
334
- pleaseProvision ( nickname , pubkey ) {
335
- console . debug ( 'Provisioning' , nickname , pubkey ) ;
336
- return E ( vats . provisioning ) . pleaseProvision (
337
- nickname ,
338
- pubkey ,
339
- PROVISIONER_INDEX ,
340
- ) ;
341
- } ,
342
- } ) ;
343
- // bootAddress holds the pubkey of controller
344
- await E ( vats . comms ) . addEgress (
345
- bootAddress ,
346
- KEY_REG_INDEX ,
347
- provisioner ,
348
- ) ;
349
- }
350
- break ;
351
- }
352
- case 'controller' :
353
- case 'one_controller' : {
354
- if ( ! GCI ) {
355
- throw new Error ( `controller must be given GCI` ) ;
356
- }
357
-
358
- await registerNetworkProtocols ( vats , bridgeManager ) ;
359
-
360
- // Wire up the http server.
361
- await setupCommandDevice ( vats . http , devices . command , {
362
- controller : true ,
363
- } ) ;
364
- // Create a presence for the on-chain provisioner.
365
- await addRemote ( GCI ) ;
366
- const chainProvisioner = await E ( vats . comms ) . addIngress (
367
- GCI ,
368
- KEY_REG_INDEX ,
369
- ) ;
370
- // Allow web requests from the provisioning server to call our
371
- // provisioner object.
372
- const provisioner = harden ( {
373
- pleaseProvision ( nickname , pubkey ) {
374
- return E ( chainProvisioner ) . pleaseProvision ( nickname , pubkey ) ;
375
- } ,
376
- } ) ;
377
- await E ( vats . http ) . setProvisioner ( provisioner ) ;
378
342
break ;
379
343
}
344
+ // ag-setup-solo runs this.
380
345
case 'client' :
381
346
case 'one_client' : {
382
347
if ( ! GCI ) {
@@ -421,6 +386,7 @@ export function buildRootObject(vatPowers) {
421
386
vats ,
422
387
devices . timer ,
423
388
vatAdminSvc ,
389
+ giveMeAllTheAgoricPowers ,
424
390
) ;
425
391
426
392
// Allow manual provisioning requests via `agoric cosmos`.
@@ -431,19 +397,30 @@ export function buildRootObject(vatPowers) {
431
397
) ;
432
398
433
399
await registerNetworkProtocols ( vats , bridgeManager ) ;
434
- if ( FIXME_DEPRECATED_BOOT_ADDRESS && bootAddress ) {
435
- const demoProvider = harden ( {
436
- // build a chain-side bundle for a client.
437
- async getDemoBundle ( nickname ) {
438
- return chainBundler . createUserBundle ( nickname ) ;
439
- } ,
440
- } ) ;
441
- await Promise . all (
442
- [ bootAddress , ...additionalAddresses ] . map ( addr =>
443
- E ( vats . comms ) . addEgress ( addr , PROVISIONER_INDEX , demoProvider ) ,
444
- ) ,
445
- ) ;
446
- }
400
+
401
+ // Allow some hardcoded client address connections into the chain.
402
+ // This is necessary for fake-chain, which does not have Cosmos SDK
403
+ // transactions to provision its client.
404
+ const demoProvider = harden ( {
405
+ // build a chain-side bundle for a client.
406
+ async getDemoBundle ( nickname ) {
407
+ return chainBundler . createUserBundle ( nickname ) ;
408
+ } ,
409
+ } ) ;
410
+ await Promise . all (
411
+ hardcodedClientAddresses . map ( async addr => {
412
+ const { transmitter, setReceiver } = await E (
413
+ vats . vattp ,
414
+ ) . addRemote ( addr ) ;
415
+ await E ( vats . comms ) . addRemote ( addr , transmitter , setReceiver ) ;
416
+ await E ( vats . comms ) . addEgress (
417
+ addr ,
418
+ PROVISIONER_INDEX ,
419
+ demoProvider ,
420
+ ) ;
421
+ } ) ,
422
+ ) ;
423
+
447
424
break ;
448
425
}
449
426
case 'two_client' : {
0 commit comments