@@ -14,9 +14,8 @@ const dirname = import.meta.dirname;
1414assert ( dirname ) ;
1515
1616const CONFIG_DIR = path . relative ( Deno . cwd ( ) , path . resolve ( dirname , "../config" ) ) ;
17- const EXECUTOR = path . resolve ( dirname , "executor.wasm" ) ;
1817
19- const IROHA_IMAGE = `hyperledger/iroha:experimental-xx-8c67c3eb749af3b9c468d5b601d6fd40e1d8a453 ` ;
18+ const IROHA_IMAGE = `hyperledger/iroha:experimental-xx-858df795cc8ea480a214ff73f3087a3bbf5f7d85 ` ;
2019const CHAINS = [ "aaa" , "bbb" , "ccc" ] . slice ( 0 , 1 ) ;
2120const PEERS_ON_CHAIN = 1 ;
2221const ACCOUNTS_ON_CHAIN = 3 ;
@@ -30,8 +29,9 @@ const ASSETS = [
3029
3130const CONFIG_MOUNT = "/config" ;
3231
32+ const EXECUTOR_BUILDER_SERVICE_NAME = "executor-builder" ;
3333const TRIGGER_BUILDER_SERVICE_NAME = "trigger-builder" ;
34- const TRIGGER_WASM_NAME = "hub_chain_trigger.opt. wasm" ;
34+ const TRIGGER_WASM_NAME = "hub_chain_trigger.wasm" ;
3535
3636const Hub = Symbol ( "hub-chain" ) ;
3737type ChainId = typeof Hub | string ;
@@ -76,10 +76,6 @@ const relayAccounts = new Map(CHAINS.map((chain) => {
7676 } ] ;
7777} ) ) ;
7878
79- const genesisKeys = new Map < ChainId , iroha . KeyPair > (
80- ( [ ...CHAINS , Hub ] as const ) . map ( ( chain ) => [ chain , iroha . KeyPair . random ( ) ] ) ,
81- ) ;
82-
8379const peerKeys = new Map < ChainId , iroha . KeyPair [ ] > (
8480 ( [ ...CHAINS , Hub ] as const ) . map (
8581 chain => [ chain , Array . from ( { length : PEERS_ON_CHAIN } , ( ) => iroha . KeyPair . random ( ) ) ] ,
@@ -225,8 +221,9 @@ function genesisFor(chain: ChainId) {
225221 const topology = peerKeys . get ( chain ) ! . map ( x => x . publicKey ( ) ) ;
226222
227223 return {
224+ creation_time : new Date ( ) . toISOString ( ) ,
228225 chain : chainToStr ( chain ) ,
229- executor : "executor.wasm" ,
226+ executor : "wasm/ executor.wasm" ,
230227 instructions,
231228 wasm_dir : "." ,
232229 wasm_triggers : [
@@ -247,6 +244,10 @@ function genesisFor(chain: ChainId) {
247244 commit_time_ms : 1000 ,
248245 max_clock_drift_ms : 1000 ,
249246 } ,
247+ smart_contract : {
248+ fuel : 200_000_000 ,
249+ memory : 200_000_000 ,
250+ } ,
250251 } ,
251252 } ;
252253}
@@ -263,7 +264,6 @@ function chainPublicPort(chain: ChainId): number {
263264
264265function peerComposeService ( chain : ChainId , i : number ) {
265266 const peerKey = peerKeys . get ( chain ) ! . at ( i ) ! ;
266- const genesisKey = genesisKeys . get ( chain ) ! ;
267267
268268 const id = peerServiceId ( chain , i ) ;
269269 const trustedPeers = JSON . stringify (
@@ -276,31 +276,15 @@ function peerComposeService(chain: ChainId, i: number) {
276276
277277 const environment = {
278278 CHAIN : chainToStr ( chain ) ,
279+ GENESIS : `${ CONFIG_MOUNT } /chain-${ chainToStr ( chain ) } -genesis.json` ,
279280 PUBLIC_KEY : peerKey . publicKey ( ) . multihash ( ) ,
280281 PRIVATE_KEY : peerKey . privateKey ( ) . multihash ( ) ,
281- GENESIS_PUBLIC_KEY : genesisKey . publicKey ( ) . multihash ( ) ,
282282 P2P_PUBLIC_ADDRESS : `${ id } :1337` ,
283283 TRUSTED_PEERS : trustedPeers ,
284284 TERMINAL_COLORS : "true" ,
285285 } ;
286286
287- const isGenesis = i === 0 ;
288- if ( isGenesis ) {
289- Object . assign ( environment , {
290- GENESIS : "/tmp/genesis.signed.scale" ,
291- GENESIS_PRIVATE_KEY : genesisKey . privateKey ( ) . multihash ( ) ,
292- } ) ;
293- }
294-
295- const command = isGenesis
296- ? `/bin/sh -c "
297- kagami genesis sign ${ CONFIG_MOUNT } /chain-${ chainToStr ( chain ) } -genesis.json \\\n\
298- --public-key $GENESIS_PUBLIC_KEY \\\n\
299- --private-key $GENESIS_PRIVATE_KEY \\\n\
300- --out-file /tmp/genesis.signed.scale \\\n\
301- && irohad --config ${ CONFIG_MOUNT } /irohad.toml
302- "`
303- : `irohad --config ${ CONFIG_MOUNT } /irohad.toml` ;
287+ const command = `irohad --config ${ CONFIG_MOUNT } /irohad.toml` ;
304288
305289 const ports = i === 0 ? [ `${ chainPublicPort ( chain ) } :8080` ] : [ ] ;
306290
@@ -318,6 +302,9 @@ function peerComposeService(chain: ChainId, i: number) {
318302 [ TRIGGER_BUILDER_SERVICE_NAME ] : {
319303 condition : "service_completed_successfully" ,
320304 } ,
305+ [ EXECUTOR_BUILDER_SERVICE_NAME ] : {
306+ condition : "service_completed_successfully" ,
307+ } ,
321308 } ,
322309 healthcheck : {
323310 test : "test $(curl -s http://127.0.0.1:8080/status/blocks) -gt 0" ,
@@ -419,13 +406,25 @@ function triggerBuilderService() {
419406 build : {
420407 context : "../trigger" ,
421408 } ,
422- volumes : [ `../config/wasm:/app/outputs` ] ,
409+ volumes : [ `../config/wasm:/usr/wasm` ] ,
410+ command : `\
411+ sh -c "
412+ cp /app/outputs/* /usr/wasm/ &&
413+ echo 'Copied WASMs'
414+ "` ,
423415 } ;
424416}
425417
418+ function defaultExecutorBuilderService ( ) {
419+ const cfg = triggerBuilderService ( ) ;
420+ cfg . build . context = `../executor` ;
421+ return cfg ;
422+ }
423+
426424const dockerCompose = {
427425 services : {
428426 [ TRIGGER_BUILDER_SERVICE_NAME ] : triggerBuilderService ( ) ,
427+ [ EXECUTOR_BUILDER_SERVICE_NAME ] : defaultExecutorBuilderService ( ) ,
429428 ...peerServices ( ) ,
430429 ...relayServices ( ) ,
431430 // ui: uiService(),
@@ -449,10 +448,6 @@ for (const chain of ALL_CHAINS) {
449448 }
450449}
451450
452- const executorDest = path . join ( CONFIG_DIR , "executor.wasm" ) ;
453- $ . logStep ( "Writing" , executorDest ) ;
454- await Deno . copyFile ( EXECUTOR , executorDest ) ;
455-
456451await writeConfig ( "ui.json" , JSON . stringify ( uiConfig ( ) , null , 2 ) ) ;
457452
458453$ . logStep ( "Completed!" , `Now you can run "docker-compose -f ${ path . join ( CONFIG_DIR , "docker-compose.yml" ) } up"` ) ;
0 commit comments