diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0fd5f05672f..d1d31d6613f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,11 +73,17 @@ jobs: run: cargo binstall wasm-bindgen-cli@0.2.99 if: ${{ steps.check-artifact.outputs.exists != 'true' }} + - name: Install Binaryen + run: | + wget https://github.com/WebAssembly/binaryen/releases/download/version_121/binaryen-version_121-x86_64-linux.tar.gz -P /tmp + tar -xzf /tmp/binaryen-version_121-x86_64-linux.tar.gz -C /tmp + sudo cp -r /tmp/binaryen-version_121/* /usr/local/ + if: ${{ steps.check-artifact.outputs.exists != 'true' }} + - name: Build packages run: yarn build env: CARGO_BUILD_PROFILE: release - if: ${{ steps.check-artifact.outputs.exists != 'true' }} - name: Set suffix diff --git a/.github/workflows/tests-build-js.yml b/.github/workflows/tests-build-js.yml index 0efd75fc7ce..3223203e297 100644 --- a/.github/workflows/tests-build-js.yml +++ b/.github/workflows/tests-build-js.yml @@ -53,6 +53,13 @@ jobs: run: cargo binstall wasm-bindgen-cli@0.2.99 if: ${{ steps.check-artifact.outputs.exists != 'true' }} + - name: Install Binaryen + run: | + wget https://github.com/WebAssembly/binaryen/releases/download/version_121/binaryen-version_121-x86_64-linux.tar.gz -P /tmp + tar -xzf /tmp/binaryen-version_121-x86_64-linux.tar.gz -C /tmp + sudo cp -r /tmp/binaryen-version_121/* /usr/local/ + if: ${{ steps.check-artifact.outputs.exists != 'true' }} + - name: Build JS packages run: yarn build if: ${{ steps.check-artifact.outputs.exists != 'true' }} diff --git a/packages/dashmate/configs/defaults/getBaseConfigFactory.js b/packages/dashmate/configs/defaults/getBaseConfigFactory.js index 17932abdeda..8b7e3b7fdcf 100644 --- a/packages/dashmate/configs/defaults/getBaseConfigFactory.js +++ b/packages/dashmate/configs/defaults/getBaseConfigFactory.js @@ -118,7 +118,6 @@ export default function getBaseConfigFactory() { miner: { enable: false, interval: '2.5m', - mediantime: null, address: null, }, devnet: { diff --git a/packages/dashmate/configs/getConfigFileMigrationsFactory.js b/packages/dashmate/configs/getConfigFileMigrationsFactory.js index 41132a61859..5bfe0315dc0 100644 --- a/packages/dashmate/configs/getConfigFileMigrationsFactory.js +++ b/packages/dashmate/configs/getConfigFileMigrationsFactory.js @@ -1059,6 +1059,8 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs) '1.8.0': (configFile) => { Object.entries(configFile.configs) .forEach(([, options]) => { + delete options.core.miner.mediantime; + options.platform.drive.abci.docker.image = 'dashpay/drive:1-dev'; options.platform.dapi.api.docker.image = 'dashpay/dapi:1-dev'; }); diff --git a/packages/dashmate/src/config/configJsonSchema.js b/packages/dashmate/src/config/configJsonSchema.js index a48a8c5e68f..0a99465e105 100644 --- a/packages/dashmate/src/config/configJsonSchema.js +++ b/packages/dashmate/src/config/configJsonSchema.js @@ -349,15 +349,11 @@ export default { interval: { $ref: '#/definitions/duration', }, - mediantime: { - type: ['integer', 'null'], - minimum: 0, - }, address: { type: ['string', 'null'], }, }, - required: ['enable', 'interval', 'mediantime', 'address'], + required: ['enable', 'interval', 'address'], additionalProperties: false, }, devnet: { diff --git a/packages/dashmate/src/core/quorum/waitForMasternodeProbes.js b/packages/dashmate/src/core/quorum/waitForMasternodeProbes.js index b16197dcaf1..5e6ccb40851 100644 --- a/packages/dashmate/src/core/quorum/waitForMasternodeProbes.js +++ b/packages/dashmate/src/core/quorum/waitForMasternodeProbes.js @@ -1,14 +1,14 @@ import { LLMQ_TYPE_TEST } from '../../constants.js'; +import wait from '../../util/wait.js'; /** * Checks all mastrenodoes probes to incterconnected masternodes * * @param {RpcClient[]} rpcClients - * @param {Function} bumpMockTime * * @return {Promise} */ -async function checkProbes(rpcClients, bumpMockTime) { +async function checkProbes(rpcClients) { let masternodes = await Promise.all( rpcClients.map((rpc) => { const promise = rpc.masternode('status'); @@ -30,8 +30,6 @@ async function checkProbes(rpcClients, bumpMockTime) { .find((connection) => connection.llmqType === LLMQ_TYPE_TEST); if (!llmqConnection) { - await bumpMockTime(); - return false; } @@ -49,16 +47,12 @@ async function checkProbes(rpcClients, bumpMockTime) { // probe is not too old. Probes are retried after 50 minutes, while DKGs consider // a probe as failed after 60 minutes if (mnInfo.metaInfo.lastOutboundSuccessElapsed > 55 * 60) { - await bumpMockTime(); - return false; } // MN is expected to be offline, so let's only check that // the last probe is not too long ago } else if (mnInfo.metaInfo.lastOutboundAttemptElapsed > 55 * 60 && mnInfo.metaInfo.lastOutboundSuccessElapsed > 55 * 60) { - await bumpMockTime(); - return false; } } @@ -72,20 +66,21 @@ async function checkProbes(rpcClients, bumpMockTime) { /** * * @param {RpcClient[]} rpcClients - * @param {Function} bumpMockTime * @param {number} [timeout] * @return {Promise} */ -export default async function waitForMasternodeProbes(rpcClients, bumpMockTime, timeout = 30000) { +export default async function waitForMasternodeProbes(rpcClients, timeout = 30000) { const deadline = Date.now() + timeout; let isReady = false; while (!isReady) { - isReady = await checkProbes(rpcClients, bumpMockTime); + isReady = await checkProbes(rpcClients); if (Date.now() > deadline) { throw new Error(`waitForMasternodeProbes deadline of ${timeout} exceeded`); } + + await wait(100); } } diff --git a/packages/dashmate/src/core/quorum/waitForQuorumConnections.js b/packages/dashmate/src/core/quorum/waitForQuorumConnections.js index 465ab84c197..90d512f77d8 100644 --- a/packages/dashmate/src/core/quorum/waitForQuorumConnections.js +++ b/packages/dashmate/src/core/quorum/waitForQuorumConnections.js @@ -31,14 +31,12 @@ async function checkQuorumConnections(rpcClient, expectedConnectionsCount) { * * @param {RpcClient[]} rpcClients * @param {number} expectedConnectionsCount - * @param {Function} bumpMockTime * @param {number} [timeout] * @return {Promise} */ export default async function waitForQuorumConnections( rpcClients, expectedConnectionsCount, - bumpMockTime, timeout = 300000, ) { const deadline = Date.now() + timeout; @@ -58,8 +56,6 @@ export default async function waitForQuorumConnections( })); if (readyNodes.size < nodesToWait) { - await bumpMockTime(); - await wait(1000); } diff --git a/packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js b/packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js index 7be7a5263a7..7002f354bad 100644 --- a/packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js @@ -215,15 +215,6 @@ export default function configureCoreTaskFactory( )); ctx.seedRpcClient = ctx.seedCoreService.getRpcClient(); - - ctx.mockTime = 0; - ctx.bumpMockTime = async (time = 1) => { - ctx.mockTime += time; - - await Promise.all( - ctx.rpcClients.map((rpcClient) => rpcClient.setMockTime(ctx.mockTime)), - ); - }; }, }, { @@ -235,26 +226,6 @@ export default function configureCoreTaskFactory( ))); }, }, - { - title: 'Set initial mock time', - task: async () => { - // TODO: We want to get rid of mock time - // Set initial mock time from the last block - const { result: bestBlockHash } = await ctx.seedRpcClient.getBestBlockHash(); - const { result: bestBlock } = await ctx.seedRpcClient.getBlock(bestBlockHash); - - await ctx.bumpMockTime(bestBlock.time); - - // Sync nodes - await ctx.bumpMockTime(); - - await generateBlocks( - ctx.seedCoreService, - 1, - NETWORK_LOCAL, - ); - }, - }, { title: 'Wait for nodes to have the same height', task: () => waitForNodesToHaveTheSameHeight( diff --git a/packages/dashmate/src/listr/tasks/setup/local/enableMultiCoreQuorumsTaskFactory.js b/packages/dashmate/src/listr/tasks/setup/local/enableMultiCoreQuorumsTaskFactory.js index 3c7cee0c40b..91ddbbfacac 100644 --- a/packages/dashmate/src/listr/tasks/setup/local/enableMultiCoreQuorumsTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/setup/local/enableMultiCoreQuorumsTaskFactory.js @@ -50,8 +50,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) { // move forward to next DKG const blocksUntilNextDKG = 24 - (bestBlockHeight % 24); if (blocksUntilNextDKG !== 0) { - await ctx.bumpMockTime(); - await generateBlocks( ctx.seedCoreService, blocksUntilNextDKG, @@ -82,7 +80,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) { await waitForQuorumConnections( ctx.masternodeRpcClients, ctx.expectedConnections, - ctx.bumpMockTime, ); const { result: sporks } = await ctx.seedRpcClient.spork('show'); @@ -91,12 +88,9 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) { if (isSpork21Active) { await waitForMasternodeProbes( ctx.masternodeRpcClients, - ctx.bumpMockTime, ); } - await ctx.bumpMockTime(); - await generateBlocks( ctx.seedCoreService, 2, @@ -119,8 +113,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) { ctx.expectedMembers, ); - await ctx.bumpMockTime(); - await generateBlocks( ctx.seedCoreService, 2, @@ -145,8 +137,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) { ctx.expectedComplaints, ); - await ctx.bumpMockTime(); - await generateBlocks( ctx.seedCoreService, 2, @@ -171,8 +161,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) { ctx.expectedJustifications, ); - await ctx.bumpMockTime(); - await generateBlocks( ctx.seedCoreService, 2, @@ -197,8 +185,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) { ctx.expectedCommitments, ); - await ctx.bumpMockTime(); - await generateBlocks( ctx.seedCoreService, 2, @@ -232,8 +218,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) { { title: 'Mining final commitment', task: async (ctx, task) => { - await ctx.bumpMockTime(); - await generateBlocks( ctx.seedCoreService, 1, @@ -246,8 +230,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) { while (!testPlatformQuorumEnabled) { await wait(300); - await ctx.bumpMockTime(); - await generateBlocks( ctx.seedCoreService, 1, diff --git a/packages/dashmate/src/listr/tasks/setup/setupLocalPresetTaskFactory.js b/packages/dashmate/src/listr/tasks/setup/setupLocalPresetTaskFactory.js index e1e11e84ffa..f8cdb128fd3 100644 --- a/packages/dashmate/src/listr/tasks/setup/setupLocalPresetTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/setup/setupLocalPresetTaskFactory.js @@ -143,10 +143,6 @@ export default function setupLocalPresetTaskFactory( config.set('core.log.debug.enabled', true); } - // Although not all nodes are miners, all nodes should be aware of - // the miner interval to be able to sync mocked time - config.set('core.miner.interval', ctx.minerInterval); - config.set('dashmate.helper.api.port', config.get('dashmate.helper.api.port') + (i * 100)); // We use single node quorums by default @@ -175,6 +171,8 @@ export default function setupLocalPresetTaskFactory( } if (config.getName() === 'local_seed') { + config.set('core.miner.interval', ctx.minerInterval); + config.set('description', 'seed node for local network'); config.set('core.masternode.enable', false); diff --git a/packages/dashmate/src/listr/tasks/startGroupNodesTaskFactory.js b/packages/dashmate/src/listr/tasks/startGroupNodesTaskFactory.js index eae01bd49e4..53b6762ee1e 100644 --- a/packages/dashmate/src/listr/tasks/startGroupNodesTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/startGroupNodesTaskFactory.js @@ -82,46 +82,6 @@ export default function startGroupNodesTaskFactory( return new Listr(tasks, { concurrent: true }); }, }, - { - title: 'Mock core node time', - enabled: () => minerConfig && minerConfig.get('network') === NETWORK_LOCAL, - task: async () => { - // TASK RATIONALE: - // During DKG sessions, nodes can make only 1 quorum request per 10 minutes. - // If mocktime is not adjusted, quorums will start failing to form after some time. - const minerInterval = minerConfig.get('core.miner.interval'); - // 2.5 minutes - mimics the behaviour of the real network - const secondsToAdd = 150; - - const tasks = configGroup.map((config) => ({ - title: `Adjust ${config.getName()} mock time`, - task: async () => { - /* eslint-disable no-useless-escape */ - await dockerCompose.execCommand( - config, - 'core', - [ - 'bash', - '-c', - ` - response=\$(dash-cli getblockchaininfo); - mocktime=\$(echo \${response} | grep -o -E '\"mediantime\"\: [0-9]+' | cut -d ' ' -f2); - while true; do - mocktime=\$((mocktime + ${secondsToAdd})); - dash-cli setmocktime \$mocktime; - sleep ${minerInterval}; - done - `, - ], - ['--detach'], - ); - /* eslint-enable no-useless-escape */ - }, - })); - - return new Listr(tasks, { concurrent: true }); - }, - }, { title: 'Start a miner', enabled: () => minerConfig && minerConfig.get('network') === NETWORK_LOCAL, diff --git a/packages/dashmate/templates/core/dash.conf.dot b/packages/dashmate/templates/core/dash.conf.dot index bb3c0a027b1..35531e5568a 100644 --- a/packages/dashmate/templates/core/dash.conf.dot +++ b/packages/dashmate/templates/core/dash.conf.dot @@ -95,7 +95,6 @@ regtest=1 testactivationheight=mn_rr@1000 {{? it.core.spork.address}}sporkaddr={{=it.core.spork.address}}{{?}} {{? it.core.spork.privateKey}}sporkkey={{=it.core.spork.privateKey}}{{?}} -{{? it.core.miner.mediantime}}mocktime={{=it.core.miner.mediantime}}{{?}} {{? it.platform.drive.abci.instantLock.quorum.llmqType == 111 }} llmqtestinstantsenddip0024=llmq_1_100 {{??}} diff --git a/packages/wasm-dpp/Cargo.toml b/packages/wasm-dpp/Cargo.toml index c84743b3fb4..6722ced8eba 100644 --- a/packages/wasm-dpp/Cargo.toml +++ b/packages/wasm-dpp/Cargo.toml @@ -54,6 +54,6 @@ async-trait = "0.1.59" bincode = "2.0.0-rc.3" [profile.release] lto = true -opt-level = 's' +opt-level = 'z' [package.metadata.cargo-machete] ignored = ["wasm-bindgen-futures"] diff --git a/packages/wasm-dpp/lib/index.ts b/packages/wasm-dpp/lib/index.ts index 8027f069bed..b4031ee4144 100644 --- a/packages/wasm-dpp/lib/index.ts +++ b/packages/wasm-dpp/lib/index.ts @@ -35,7 +35,7 @@ const loadDppModule = async () => { let wasmUrl = URL.createObjectURL(blob); await init(wasmUrl); } else { - dpp_module.initSync(bytes); + dpp_module.initSync({ module: bytes }); } } diff --git a/packages/wasm-dpp/scripts/build-wasm.sh b/packages/wasm-dpp/scripts/build-wasm.sh index 0c154372bae..b7ada5425ef 100755 --- a/packages/wasm-dpp/scripts/build-wasm.sh +++ b/packages/wasm-dpp/scripts/build-wasm.sh @@ -47,8 +47,9 @@ fi # EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry" cargo build --target=wasm32-unknown-emscripten --release # EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry" wasm-bindgen --out-dir=wasm --target=web --omit-default-module-path ../../target/wasm32-unknown-emscripten/release/wasm_dpp.wasm -# TODO: Must be somehow preinstalled? -#if [ "$PROFILE" == "release" ]; then -# echo "Optimizing wasm using Binaryen" -# wasm-opt -Os "$OUTPUT_FILE" -o "$OUTPUT_FILE" -#fi +if command -v wasm-opt &> /dev/null; then + echo "Optimizing wasm using Binaryen" + wasm-opt -Oz "$OUTPUT_FILE" -o "$OUTPUT_FILE" +else + echo "wasm-opt command not found. Skipping wasm optimization." +fi