Skip to content

Commit

Permalink
Merge branch 'v1.8-dev' into standalone-node
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js
#	packages/dashmate/templates/core/dash.conf.dot
  • Loading branch information
shumkov committed Dec 18, 2024
2 parents 6aa8791 + 01a5b7a commit 5230090
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 121 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,17 @@ jobs:
run: cargo binstall [email protected]
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
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/tests-build-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ jobs:
run: cargo binstall [email protected]
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' }}
Expand Down
1 change: 0 additions & 1 deletion packages/dashmate/configs/defaults/getBaseConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export default function getBaseConfigFactory() {
miner: {
enable: false,
interval: '2.5m',
mediantime: null,
address: null,
},
devnet: {
Expand Down
2 changes: 2 additions & 0 deletions packages/dashmate/configs/getConfigFileMigrationsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
});
Expand Down
6 changes: 1 addition & 5 deletions packages/dashmate/src/config/configJsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
17 changes: 6 additions & 11 deletions packages/dashmate/src/core/quorum/waitForMasternodeProbes.js
Original file line number Diff line number Diff line change
@@ -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<boolean>}
*/
async function checkProbes(rpcClients, bumpMockTime) {
async function checkProbes(rpcClients) {
let masternodes = await Promise.all(
rpcClients.map((rpc) => {
const promise = rpc.masternode('status');
Expand All @@ -30,8 +30,6 @@ async function checkProbes(rpcClients, bumpMockTime) {
.find((connection) => connection.llmqType === LLMQ_TYPE_TEST);

if (!llmqConnection) {
await bumpMockTime();

return false;
}

Expand All @@ -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;
}
}
Expand All @@ -72,20 +66,21 @@ async function checkProbes(rpcClients, bumpMockTime) {
/**
*
* @param {RpcClient[]} rpcClients
* @param {Function} bumpMockTime
* @param {number} [timeout]
* @return {Promise<void>}
*/
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);
}
}
4 changes: 0 additions & 4 deletions packages/dashmate/src/core/quorum/waitForQuorumConnections.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ async function checkQuorumConnections(rpcClient, expectedConnectionsCount) {
*
* @param {RpcClient[]} rpcClients
* @param {number} expectedConnectionsCount
* @param {Function} bumpMockTime
* @param {number} [timeout]
* @return {Promise<void>}
*/
export default async function waitForQuorumConnections(
rpcClients,
expectedConnectionsCount,
bumpMockTime,
timeout = 300000,
) {
const deadline = Date.now() + timeout;
Expand All @@ -58,8 +56,6 @@ export default async function waitForQuorumConnections(
}));

if (readyNodes.size < nodesToWait) {
await bumpMockTime();

await wait(1000);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
);
};
},
},
{
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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');
Expand All @@ -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,
Expand All @@ -119,8 +113,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) {
ctx.expectedMembers,
);

await ctx.bumpMockTime();

await generateBlocks(
ctx.seedCoreService,
2,
Expand All @@ -145,8 +137,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) {
ctx.expectedComplaints,
);

await ctx.bumpMockTime();

await generateBlocks(
ctx.seedCoreService,
2,
Expand All @@ -171,8 +161,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) {
ctx.expectedJustifications,
);

await ctx.bumpMockTime();

await generateBlocks(
ctx.seedCoreService,
2,
Expand All @@ -197,8 +185,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) {
ctx.expectedCommitments,
);

await ctx.bumpMockTime();

await generateBlocks(
ctx.seedCoreService,
2,
Expand Down Expand Up @@ -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,
Expand All @@ -246,8 +230,6 @@ export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) {
while (!testPlatformQuorumEnabled) {
await wait(300);

await ctx.bumpMockTime();

await generateBlocks(
ctx.seedCoreService,
1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
40 changes: 0 additions & 40 deletions packages/dashmate/src/listr/tasks/startGroupNodesTaskFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion packages/dashmate/templates/core/dash.conf.dot
Original file line number Diff line number Diff line change
Expand Up @@ -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
{{??}}
Expand Down
2 changes: 1 addition & 1 deletion packages/wasm-dpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion packages/wasm-dpp/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}

11 changes: 6 additions & 5 deletions packages/wasm-dpp/scripts/build-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5230090

Please sign in to comment.