@@ -16,7 +16,7 @@ assert(dirname);
1616const CONFIG_DIR = path . relative ( Deno . cwd ( ) , path . resolve ( dirname , "../config" ) ) ;
1717const EXECUTOR = path . resolve ( dirname , "executor.wasm" ) ;
1818
19- const IROHA_IMAGE = `hyperledger/iroha:experimental-xx-8c67c3eb749af3b9c468d5b601d6fd40e1d8a453 ` ;
19+ const IROHA_IMAGE = `hyperledger/iroha:experimental-xx-858df795cc8ea480a214ff73f3087a3bbf5f7d85 ` ;
2020const CHAINS = [ "aaa" , "bbb" , "ccc" ] . slice ( 0 , 1 ) ;
2121const PEERS_ON_CHAIN = 1 ;
2222const ACCOUNTS_ON_CHAIN = 3 ;
@@ -30,8 +30,9 @@ const ASSETS = [
3030
3131const CONFIG_MOUNT = "/config" ;
3232
33+ const EXECUTOR_BUILDER_SERVICE_NAME = "executor-builder" ;
3334const TRIGGER_BUILDER_SERVICE_NAME = "trigger-builder" ;
34- const TRIGGER_WASM_NAME = "hub_chain_trigger.opt. wasm" ;
35+ const TRIGGER_WASM_NAME = "hub_chain_trigger.wasm" ;
3536
3637const Hub = Symbol ( "hub-chain" ) ;
3738type ChainId = typeof Hub | string ;
@@ -76,10 +77,6 @@ const relayAccounts = new Map(CHAINS.map((chain) => {
7677 } ] ;
7778} ) ) ;
7879
79- const genesisKeys = new Map < ChainId , iroha . KeyPair > (
80- ( [ ...CHAINS , Hub ] as const ) . map ( ( chain ) => [ chain , iroha . KeyPair . random ( ) ] ) ,
81- ) ;
82-
8380const peerKeys = new Map < ChainId , iroha . KeyPair [ ] > (
8481 ( [ ...CHAINS , Hub ] as const ) . map (
8582 chain => [ chain , Array . from ( { length : PEERS_ON_CHAIN } , ( ) => iroha . KeyPair . random ( ) ) ] ,
@@ -225,8 +222,9 @@ function genesisFor(chain: ChainId) {
225222 const topology = peerKeys . get ( chain ) ! . map ( x => x . publicKey ( ) ) ;
226223
227224 return {
225+ creation_time : new Date ( ) . toISOString ( ) ,
228226 chain : chainToStr ( chain ) ,
229- executor : "executor.wasm" ,
227+ executor : "wasm/ executor.wasm" ,
230228 instructions,
231229 wasm_dir : "." ,
232230 wasm_triggers : [
@@ -247,6 +245,10 @@ function genesisFor(chain: ChainId) {
247245 commit_time_ms : 1000 ,
248246 max_clock_drift_ms : 1000 ,
249247 } ,
248+ smart_contract : {
249+ fuel : 200_000_000 ,
250+ memory : 200_000_000 ,
251+ } ,
250252 } ,
251253 } ;
252254}
@@ -263,7 +265,6 @@ function chainPublicPort(chain: ChainId): number {
263265
264266function peerComposeService ( chain : ChainId , i : number ) {
265267 const peerKey = peerKeys . get ( chain ) ! . at ( i ) ! ;
266- const genesisKey = genesisKeys . get ( chain ) ! ;
267268
268269 const id = peerServiceId ( chain , i ) ;
269270 const trustedPeers = JSON . stringify (
@@ -276,31 +277,15 @@ function peerComposeService(chain: ChainId, i: number) {
276277
277278 const environment = {
278279 CHAIN : chainToStr ( chain ) ,
280+ GENESIS : `${ CONFIG_MOUNT } /chain-${ chainToStr ( chain ) } -genesis.json` ,
279281 PUBLIC_KEY : peerKey . publicKey ( ) . multihash ( ) ,
280282 PRIVATE_KEY : peerKey . privateKey ( ) . multihash ( ) ,
281- GENESIS_PUBLIC_KEY : genesisKey . publicKey ( ) . multihash ( ) ,
282283 P2P_PUBLIC_ADDRESS : `${ id } :1337` ,
283284 TRUSTED_PEERS : trustedPeers ,
284285 TERMINAL_COLORS : "true" ,
285286 } ;
286287
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` ;
288+ const command = `irohad --config ${ CONFIG_MOUNT } /irohad.toml` ;
304289
305290 const ports = i === 0 ? [ `${ chainPublicPort ( chain ) } :8080` ] : [ ] ;
306291
@@ -318,6 +303,9 @@ function peerComposeService(chain: ChainId, i: number) {
318303 [ TRIGGER_BUILDER_SERVICE_NAME ] : {
319304 condition : "service_completed_successfully" ,
320305 } ,
306+ [ EXECUTOR_BUILDER_SERVICE_NAME ] : {
307+ condition : "service_completed_successfully" ,
308+ } ,
321309 } ,
322310 healthcheck : {
323311 test : "test $(curl -s http://127.0.0.1:8080/status/blocks) -gt 0" ,
@@ -419,13 +407,25 @@ function triggerBuilderService() {
419407 build : {
420408 context : "../trigger" ,
421409 } ,
422- volumes : [ `../config/wasm:/app/outputs` ] ,
410+ volumes : [ `../config/wasm:/usr/wasm` ] ,
411+ command : `\
412+ sh -c "
413+ cp /app/outputs/* /usr/wasm/ &&
414+ echo 'Copied WASMs'
415+ "` ,
423416 } ;
424417}
425418
419+ function defaultExecutorBuilderService ( ) {
420+ const cfg = triggerBuilderService ( ) ;
421+ cfg . build . context = `../executor` ;
422+ return cfg ;
423+ }
424+
426425const dockerCompose = {
427426 services : {
428427 [ TRIGGER_BUILDER_SERVICE_NAME ] : triggerBuilderService ( ) ,
428+ [ EXECUTOR_BUILDER_SERVICE_NAME ] : defaultExecutorBuilderService ( ) ,
429429 ...peerServices ( ) ,
430430 ...relayServices ( ) ,
431431 // ui: uiService(),
@@ -449,10 +449,6 @@ for (const chain of ALL_CHAINS) {
449449 }
450450}
451451
452- const executorDest = path . join ( CONFIG_DIR , "executor.wasm" ) ;
453- $ . logStep ( "Writing" , executorDest ) ;
454- await Deno . copyFile ( EXECUTOR , executorDest ) ;
455-
456452await writeConfig ( "ui.json" , JSON . stringify ( uiConfig ( ) , null , 2 ) ) ;
457453
458454$ . logStep ( "Completed!" , `Now you can run "docker-compose -f ${ path . join ( CONFIG_DIR , "docker-compose.yml" ) } up"` ) ;
0 commit comments