Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

fix: mocktime adjustement #370

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/listr/tasks/startGroupNodesTaskFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ function startGroupNodesTaskFactory(
title: 'Adjust Core mock 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) => ({
Expand All @@ -99,15 +103,14 @@ function startGroupNodesTaskFactory(
'bash',
'-c',
`
while true
do
response=\$(dash-cli getblockchaininfo)
mediantime=\$(echo \${response} | grep -o -E '\"mediantime\"\: [0-9]+' | cut -d ' ' -f2)
mocktime=\$((mediantime + ${secondsToAdd}))
dash-cli setmocktime \$mocktime
sleep ${minerInterval}
done
`,
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'],
);
Expand Down Expand Up @@ -139,7 +142,10 @@ function startGroupNodesTaskFactory(
[
'bash',
'-c',
`while true; do dash-cli generatetoaddress 1 ${minerAddress}; sleep ${minerInterval}; done`,
`while true; do
dash-cli generatetoaddress 1 ${minerAddress};
sleep ${minerInterval};
done`,
],
['--detach'],
);
Expand Down