Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: activate platform on EHF fork #1972

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
207 changes: 207 additions & 0 deletions packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions packages/dashmate/src/core/activateCoreSpork.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* @typedef activateCoreSpork
* @param {RpcClient} rpcClient
* @param {string} spork
* @param {number} height
* @returns {Promise<void>}
*/
export default async function activateCoreSpork(rpcClient, spork) {
await rpcClient.sporkupdate(spork, 0);
export default async function activateCoreSpork(rpcClient, spork, height = 0) {
await rpcClient.sporkupdate(spork, height);
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ export default function configureCoreTaskFactory(
'SPORK_9_SUPERBLOCKS_ENABLED',
'SPORK_17_QUORUM_DKG_ENABLED',
'SPORK_19_CHAINLOCKS_ENABLED',
'SPORK_24_TEST_EHF',
];

await Promise.all(
Expand Down Expand Up @@ -348,18 +347,6 @@ export default function configureCoreTaskFactory(
title: 'Wait for quorums to be enabled',
task: () => enableCoreQuorumsTask(),
},
{
title: 'Setting initial core chain locked height',
task: async (_, task) => {
const rpcClient = ctx.seedCoreService.getRpcClient();
const { result: initialCoreChainLockedHeight } = await rpcClient.getBlockCount();

ctx.initialCoreChainLockedHeight = initialCoreChainLockedHeight;

// eslint-disable-next-line no-param-reassign
task.output = `Initial chain locked core height is set to: ${ctx.initialCoreChainLockedHeight}`;
},
},
{
title: 'Activating V20 fork',
task: () => new Observable(async (observer) => {
Expand Down Expand Up @@ -401,6 +388,74 @@ export default function configureCoreTaskFactory(
return this;
}),
},
{
title: 'Wait for nodes to have the same height',
task: () => waitForNodesToHaveTheSameHeight(
ctx.rpcClients,
WAIT_FOR_NODES_TIMEOUT,
),
},
{
title: 'Enable EHF spork',
task: async () => new Observable(async (observer) => {
const seedRpcClient = ctx.seedCoreService.getRpcClient();
const {
result: initialCoreChainLockedHeight,
} = await seedRpcClient.getBlockCount();

await activateCoreSpork(
seedRpcClient,
'SPORK_24_TEST_EHF',
initialCoreChainLockedHeight,
);

let isEhfActivated = false;
let blockchainInfo;

let blocksGenerated = 0;

const blocksToGenerateInOneStep = 48;

do {
({
result: blockchainInfo,
} = await ctx.seedCoreService.getRpcClient().getBlockchainInfo());

isEhfActivated = blockchainInfo.softforks && blockchainInfo.softforks.mn_rr
&& blockchainInfo.softforks.mn_rr.active;
if (isEhfActivated) {
break;
}

await ctx.bumpMockTime(blocksToGenerateInOneStep);

await generateBlocks(
ctx.seedCoreService,
blocksToGenerateInOneStep,
NETWORK_LOCAL,
// eslint-disable-next-line no-loop-func
(blocks) => {
blocksGenerated += blocks;

observer.next(`${blocksGenerated} blocks generated`);
},
);
} while (!isEhfActivated);

observer.next(`EHF has been activated at height ${blockchainInfo.softforks.mn_rr.height}`);

observer.complete();

return this;
}),
},
{
title: 'Wait for nodes to have the same height',
task: () => waitForNodesToHaveTheSameHeight(
ctx.rpcClients,
WAIT_FOR_NODES_TIMEOUT,
),
},
{
title: 'Stopping nodes',
task: async () => (Promise.all(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
function configureTenderdashTask(configGroup) {
return new Listr([
{
task: async (ctx) => {

Check failure on line 15 in packages/dashmate/src/listr/tasks/setup/local/configureTenderdashTaskFactory.js

View workflow job for this annotation

GitHub Actions / JS packages (dashmate) / Linting

'ctx' is defined but never used
const platformConfigs = configGroup.filter((config) => config.get('platform.enable'));

const subTasks = [];
Expand All @@ -28,10 +28,6 @@
platformConfigs.forEach((config, index) => {
config.set('platform.drive.tenderdash.genesis.genesis_time', genesisTime);
config.set('platform.drive.tenderdash.genesis.chain_id', chainId);
config.set(
'platform.drive.tenderdash.genesis.initial_core_chain_locked_height',
ctx.initialCoreChainLockedHeight,
);

const p2pPeers = platformConfigs
.filter((_, i) => i !== index)
Expand Down
6 changes: 3 additions & 3 deletions packages/rs-drive-abci/src/error/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ pub enum ExecutionError {
InitializationForkNotActive(String),

/// Invalid core chain locked height
#[error("core chain locked height {requested} is invalid: {v20_fork} <= {requested} <= {best} is not true")]
#[error("core chain locked height {requested} is invalid: {mn_rr_fork} <= {requested} <= {best} is not true")]
InitializationBadCoreLockedHeight {
/// v20 fork height
v20_fork: u32,
/// mn_rr fork height
mn_rr_fork: u32,
/// requested core height
requested: u32,
/// best core lock height
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ where
request,
)?;

// We get core height early, as this also verifies v20 fork
// We get core height early, as this also verifies mn_rr fork
let core_height =
self.initial_core_height(request.initial_core_height, platform_version)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ where
/// Determine initial core height.
///
/// Use core height received from Tenderdash (from genesis.json) by default,
/// otherwise we go with height of v20 fork.
/// otherwise we go with height of mn_rr fork.
///
/// Core height is verified to ensure that it is both at or after v20 fork, and
/// Core height is verified to ensure that it is both at or after mn_rr fork, and
/// before or at last chain lock.
///
/// ## Error handling
///
/// This function will fail if:
///
/// * v20 fork is not yet active
/// * `requested` core height is before v20 fork
/// * mn_rr fork is not yet active
/// * `requested` core height is before mn_rr fork
/// * `requested` core height is after current best chain lock
///
pub(in crate::execution) fn initial_core_height(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,51 @@ where
/// Determine initial core height.
///
/// Use core height received from Tenderdash (from genesis.json) by default,
/// otherwise we go with height of v20 fork.
/// otherwise we go with height of mn_rr fork.
///
/// Core height is verified to ensure that it is both at or after v20 fork, and
/// Core height is verified to ensure that it is both at or after mn_rr fork, and
/// before or at last chain lock.
///
/// ## Error handling
///
/// This function will fail if:
///
/// * v20 fork is not yet active
/// * `requested` core height is before v20 fork
/// * mn_rr fork is not yet active
/// * `requested` core height is before mn_rr fork
/// * `requested` core height is after current best chain lock
///
pub(in crate::execution::platform_events) fn initial_core_height_v0(
&self,
requested: Option<u32>,
) -> Result<u32, Error> {
let fork_info = self.core_rpc.get_fork_info("v20")?.ok_or(
let fork_info = self.core_rpc.get_fork_info("mn_rr")?.ok_or(
ExecutionError::InitializationForkNotActive("fork is not yet known".to_string()),
)?;
if !fork_info.active || fork_info.height.is_none() {
// fork is not good yet
return Err(ExecutionError::InitializationForkNotActive(format!(
"fork is not yet known (currently {:?})",
fork_info.bip9.unwrap()
fork_info
))
.into());
} else {
tracing::debug!(?fork_info, "core fork v20 is active");
tracing::debug!(?fork_info, "core fork mn_rr is active");
};
// We expect height to present if the fork is active
let v20_fork = fork_info.height.unwrap();
let mn_rr_fork = fork_info.height.unwrap();

if let Some(requested) = requested {
let best = self.core_rpc.get_best_chain_lock()?.block_height;

tracing::trace!(
requested,
v20_fork,
mn_rr_fork,
best,
"selecting initial core lock height"
);
// TODO in my opinion, the condition should be:
//
// `v20_fork <= requested && requested <= best`
// `mn_rr_fork <= requested && requested <= best`
//
// but it results in 1440 <= 1243 <= 1545
//
Expand All @@ -65,13 +65,13 @@ where
Err(ExecutionError::InitializationBadCoreLockedHeight {
requested,
best,
v20_fork,
mn_rr_fork,
}
.into())
}
} else {
tracing::trace!(v20_fork, "used fork height as initial core lock height");
Ok(v20_fork)
tracing::trace!(mn_rr_fork, "used fork height as initial core lock height");
Ok(mn_rr_fork)
}
}
}
Loading