From 5ceb20233f7a2ea3c6df18e512a0a21be46102b2 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Mon, 4 Nov 2024 09:47:51 +0700 Subject: [PATCH] chore: remove height conditions --- .../src/abci/handler/finalize_block.rs | 24 ++++---------- .../rs-drive-abci/src/abci/handler/info.rs | 31 ++++++------------- .../src/abci/handler/prepare_proposal.rs | 31 ++++++------------- .../src/abci/handler/process_proposal.rs | 31 ++++++------------- 4 files changed, 33 insertions(+), 84 deletions(-) diff --git a/packages/rs-drive-abci/src/abci/handler/finalize_block.rs b/packages/rs-drive-abci/src/abci/handler/finalize_block.rs index 84d7c07cdbe..5148257f3e6 100644 --- a/packages/rs-drive-abci/src/abci/handler/finalize_block.rs +++ b/packages/rs-drive-abci/src/abci/handler/finalize_block.rs @@ -67,24 +67,12 @@ where )); } - // We had a chain halt on mainnet on block 32326. Compaction happened - // and transaction.commit() returned an error. Due to a bug in tenderdash, - // validators just proceeded on next block without committing data but keeping - // updated cache. To keep consistency with mainnet chain we have to skip - // commit of this block now on. - let config = &app.platform().config; - - if !(app.platform().config.network == Network::Dash - && config.abci.chain_id == "evo1" - && block_height == 32326) - { - // This is simplified solution until we have a better way to handle - // We still have caches in memory that corresponds to the data that - // we weren't able to commit. Solution is to restart the Drive, so all caches - // will be restored from the disk and try to process this block again - app.commit_transaction(platform_version) - .expect("commit transaction"); - } + // This is simplified solution until we have a better way to handle + // We still have caches in memory that corresponds to the data that + // we weren't able to commit. Solution is to restart the Drive, so all caches + // will be restored from the disk and try to process this block again + app.commit_transaction(platform_version) + .expect("commit transaction"); app.platform() .committed_block_height_guard diff --git a/packages/rs-drive-abci/src/abci/handler/info.rs b/packages/rs-drive-abci/src/abci/handler/info.rs index f8a9cd9dffd..570fedb6ffa 100644 --- a/packages/rs-drive-abci/src/abci/handler/info.rs +++ b/packages/rs-drive-abci/src/abci/handler/info.rs @@ -41,28 +41,15 @@ where .root_hash(None, grove_version) .unwrap()?; - // We had a chain halt on mainnet on block 32326. Compaction happened - // and transaction.commit() returned an error. Due to a bug in tenderdash, - // validators just proceeded on next block without committing data but keeping - // updated cache. To keep consistency with mainnet chain we allow app hashes to be - // different for this block. - let config = &app.platform().config; - - #[allow(clippy::collapsible_if)] - if !(config.network == Network::Dash - && config.abci.chain_id == "evo1" - && last_block_height == 32326) - { - // App hash in memory must be equal to app hash on disk - if drive_storage_root_hash != platform_state_app_hash { - // We panic because we can't recover from this situation. - // Better to restart the Drive, so we might self-heal the node - // reloading state form the disk - panic!( - "drive and platform state app hash mismatch: drive_storage_root_hash: {:?}, platform_state_app_hash: {:?}", - drive_storage_root_hash, platform_state_app_hash - ); - } + // App hash in memory must be equal to app hash on disk + if drive_storage_root_hash != platform_state_app_hash { + // We panic because we can't recover from this situation. + // Better to restart the Drive, so we might self-heal the node + // reloading state form the disk + panic!( + "drive and platform state app hash mismatch: drive_storage_root_hash: {:?}, platform_state_app_hash: {:?}", + drive_storage_root_hash, platform_state_app_hash + ); } let desired_protocol_version = DESIRED_PLATFORM_VERSION.protocol_version; diff --git a/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs b/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs index 219b012355d..8048e1018be 100644 --- a/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs +++ b/packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs @@ -53,28 +53,15 @@ where .root_hash(None, grove_version) .unwrap()?; - // We had a chain halt on mainnet on block 32326. Compaction happened - // and transaction.commit() returned an error. Due to a bug in tenderdash, - // validators just proceeded on next block without committing data but keeping - // updated cache. To keep consistency with mainnet chain we allow app hashes to be - // different for this block. - let config = &app.platform().config; - - #[allow(clippy::collapsible_if)] - if !(config.network == Network::Dash - && config.abci.chain_id == "evo1" - && request.height == 32327) - { - // App hash in memory must be equal to app hash on disk - if drive_storage_root_hash != platform_state_app_hash { - // We panic because we can't recover from this situation. - // Better to restart the Drive, so we might self-heal the node - // reloading state form the disk - panic!( - "drive and platform state app hash mismatch: drive_storage_root_hash: {:?}, platform_state_app_hash: {:?}", - drive_storage_root_hash, platform_state_app_hash - ); - } + // App hash in memory must be equal to app hash on disk + if drive_storage_root_hash != platform_state_app_hash { + // We panic because we can't recover from this situation. + // Better to restart the Drive, so we might self-heal the node + // reloading state form the disk + panic!( + "drive and platform state app hash mismatch: drive_storage_root_hash: {:?}, platform_state_app_hash: {:?}", + drive_storage_root_hash, platform_state_app_hash + ); } let last_committed_core_height = platform_state.last_committed_core_height(); diff --git a/packages/rs-drive-abci/src/abci/handler/process_proposal.rs b/packages/rs-drive-abci/src/abci/handler/process_proposal.rs index e20bb0a9ca8..bff4352be06 100644 --- a/packages/rs-drive-abci/src/abci/handler/process_proposal.rs +++ b/packages/rs-drive-abci/src/abci/handler/process_proposal.rs @@ -197,28 +197,15 @@ where .root_hash(None, grove_version) .unwrap()?; - // We had a chain halt on mainnet on block 32326. Compaction happened - // and transaction.commit() returned an error. Due to a bug in tenderdash, - // validators just proceeded on next block without committing data but keeping - // updated cache. To keep consistency with mainnet chain we allow app hashes to be - // different for this block. - let config = &app.platform().config; - - #[allow(clippy::collapsible_if)] - if !(app.platform().config.network == Network::Dash - && config.abci.chain_id == "evo1" - && request.height == 32327) - { - // App hash in memory must be equal to app hash on disk - if drive_storage_root_hash != platform_state_app_hash { - // We panic because we can't recover from this situation. - // Better to restart the Drive, so we might self-heal the node - // reloading state form the disk - panic!( - "drive and platform state app hash mismatch: drive_storage_root_hash: {:?}, platform_state_app_hash: {:?}", - drive_storage_root_hash, platform_state_app_hash - ); - } + // App hash in memory must be equal to app hash on disk + if drive_storage_root_hash != platform_state_app_hash { + // We panic because we can't recover from this situation. + // Better to restart the Drive, so we might self-heal the node + // reloading state form the disk + panic!( + "drive and platform state app hash mismatch: drive_storage_root_hash: {:?}, platform_state_app_hash: {:?}", + drive_storage_root_hash, platform_state_app_hash + ); } let starting_platform_version = platform_state.current_platform_version()?;