diff --git a/devnets/devnet.init.mjs b/devnets/devnet.init.mjs index d5c51a22c85..587cefd0630 100644 --- a/devnets/devnet.init.mjs +++ b/devnets/devnet.init.mjs @@ -1,6 +1,6 @@ -import { env } from 'node:process' +import { env, getuid } from 'node:process' import { spawn, exec, execSync } from 'node:child_process' -import { existsSync, writeFileSync, chmodSync } from 'node:fs' +import { existsSync, readFileSync, writeFileSync, chmodSync } from 'node:fs' const { VERBOSE = false, @@ -40,8 +40,15 @@ function start () { function spawnLcp () { console.info('Configuring the node to support lcp (CORS proxy)...') - run(`perl -i -pe 's;address = "tcp://0.0.0.0:1317";address = "tcp://0.0.0.0:1316";' ${appToml}`) - run(`perl -i -pe 's/enable-unsafe-cors = false/enable-unsafe-cors = true/' ${appToml}`) + if (DAEMON === 'secretd') { + //let appTomlData = readFileSync(appToml) + run(`perl -i -pe 's;address = "tcp://0.0.0.0:1317";address = "tcp://0.0.0.0:1316";' ${appToml}`) + run(`perl -i -pe 's/enable-unsafe-cors = false/enable-unsafe-cors = true/' ${appToml}`) + } + //let appTomlData = readFileSync(appToml) + //appTomlData = appTomlData.replace('address = "tcp://0.0.0.0:1317"', 'address = "tcp://0.0.0.0:1316') + //appTomlData = appTomlData.replace('enable-unsafe-cors = false', 'enable-unsafe-cors = false') + //writeFileSync(appToml, appTomlData) const lcpArgs = [ `--proxyUrl`, 'http://localhost:1316', `--port`, LCP_PORT, @@ -54,12 +61,26 @@ function spawnLcp () { function launchNode () { console.info('Launching the node...') - const command = `source /opt/sgxsdk/environment && RUST_BACKTRACE=1 ${DAEMON} start --bootstrap` + let command + if (DAEMON === 'secretd') { + command = `source /opt/sgxsdk/environment && RUST_BACKTRACE=1 ${DAEMON} start --bootstrap` + + ` --rpc.laddr ${RPC_ADDR}` + + ` --grpc.address ${GRPC_ADDR}` + + ` --grpc-web.address ${GRPC_WEB_ADDR}` + } else { + command = `${DAEMON} start` + } + command += '' + ` --rpc.laddr ${RPC_ADDR}` + ` --grpc.address ${GRPC_ADDR}` + ` --grpc-web.address ${GRPC_WEB_ADDR}` console.info(`$`, command) - execSync(command, { shell: '/bin/bash', stdio: 'inherit' }) + try { + execSync(command, { shell: '/bin/bash', stdio: 'inherit' }) + } catch (e) { + console.log('ERROR:', e.message) + process.exit(1) + } } function performGenesis () { @@ -78,7 +99,10 @@ function performGenesis () { function preGenesisCleanup () { console.info('\nEnsuring a clean slate...') - run(`rm -rf ${daemonDir} ~/.secretcli /opt/secret/.sgx-secrets`) + run(`rm -rf ${daemonDir}`) + if (DAEMON === 'secretd') { + run(`~/.secretcli /opt/secret/.sgx-secrets`) + } } function preGenesisConfig () { @@ -91,6 +115,7 @@ function preGenesisConfig () { if (DAEMON === 'secretd') { run(`cp ~/node_key.json ${nodeKey}`) } + console.log('Patching', genesis) run(`perl -i -pe 's/"stake"/ "${TOKEN}"/g' ${genesis}`) } @@ -116,7 +141,11 @@ function bootstrapChain () { console.info('\nBootstrapping chain...') daemon(`collect-gentxs`) daemon(`validate-genesis`) - daemon(`init-bootstrap`) + if (DAEMON === 'secretd') { + daemon(`init-bootstrap`) + }/* else { + daemon(`init ${CHAIN_ID}`) + }*/ daemon(`validate-genesis`) } diff --git a/devnets/okp4_5_0.Dockerfile b/devnets/okp4_5_0.Dockerfile index deea6a893ba..f7ae796d7ea 100644 --- a/devnets/okp4_5_0.Dockerfile +++ b/devnets/okp4_5_0.Dockerfile @@ -1,6 +1,6 @@ FROM okp4/okp4d:5.0.0@sha256:b197462e61c068ea094ec9b5693c88c2850606f9eaf53fcbe08a0aa4f6ff90b9 #RUN okp4d init fadroma-devnet --chain-id fadroma-devnet-okp4-v5.0 -RUN apk add nodejs +RUN apk add nodejs perl bash ENTRYPOINT [ "/usr/bin/node" ] ADD devnet.init.mjs / CMD [ "/devnet.init.mjs" ] diff --git a/fadroma-devnet.ts b/fadroma-devnet.ts index 8c0d4fa4e2a..dcc9da5d3a6 100644 --- a/fadroma-devnet.ts +++ b/fadroma-devnet.ts @@ -500,7 +500,7 @@ export class Devnet implements DevnetHandle { 'scrt_1.7': 'indexed block', 'scrt_1.8': 'Done verifying block height', 'scrt_1.9': 'Validating proposal', - 'okp4_5.0': 'NOT KNOWN YET', + 'okp4_5.0': 'indexed block', } static daemonBinary: Record = {