Skip to content

Commit

Permalink
chore: remove height conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Nov 4, 2024
1 parent 2a3532b commit 5ceb202
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 84 deletions.
24 changes: 6 additions & 18 deletions packages/rs-drive-abci/src/abci/handler/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 9 additions & 22 deletions packages/rs-drive-abci/src/abci/handler/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 9 additions & 22 deletions packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
31 changes: 9 additions & 22 deletions packages/rs-drive-abci/src/abci/handler/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down

0 comments on commit 5ceb202

Please sign in to comment.