Skip to content

Commit

Permalink
chore: ignore app hash validation for failed block
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Nov 2, 2024
1 parent e357b4c commit bc6d8d4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
4 changes: 3 additions & 1 deletion packages/rs-drive-abci/src/abci/handler/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::execution::types::block_execution_context::v0::BlockExecutionContextV
use crate::platform_types::cleaned_abci_messages::finalized_block_cleaned_request::v0::FinalizeBlockCleanedRequest;
use crate::platform_types::platform_state::v0::PlatformStateV0Methods;
use crate::rpc::core::CoreRPCLike;
use dpp::dashcore::Network;
use std::sync::atomic::Ordering;
use tenderdash_abci::proto::abci as proto;

Expand Down Expand Up @@ -67,7 +68,8 @@ where
}

// TODO: document this
if block_height == 32326 {
// TODO: verify that chain id is evo1
if !(app.platform().config.network == Network::Dash && block_height == 32326) {
app.commit_transaction(platform_version)?;
}

Expand Down
22 changes: 15 additions & 7 deletions packages/rs-drive-abci/src/abci/handler/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::abci::AbciError;
use crate::error::Error;
use crate::platform_types::platform_state::v0::PlatformStateV0Methods;
use crate::rpc::core::CoreRPCLike;
use dpp::dashcore::Network;
use dpp::version::DESIRED_PLATFORM_VERSION;
use tenderdash_abci::proto::abci as proto;

Expand All @@ -21,6 +22,8 @@ where

let platform_state = app.platform().state.load();

let last_block_height = platform_state.last_committed_block_height() as i64;

// Verify that Platform State corresponds to Drive commited state
let drive_storage_root_hash = platform_state
.last_committed_block_app_hash()
Expand All @@ -39,20 +42,25 @@ where
)
.unwrap()?;

if drive_storage_root_hash != platform_state_app_hash {
return Err(AbciError::AppHashMismatch {
drive_storage_root_hash,
platform_state_app_hash,
// TODO: Document this
// TODO: verify that chain id is evo1
#[allow(clippy::collapsible_if)]
if !(app.platform().config.network == Network::Dash && last_block_height == 32326) {
if drive_storage_root_hash != platform_state_app_hash {
return Err(AbciError::AppHashMismatch {
drive_storage_root_hash,
platform_state_app_hash,
}
.into());
}
.into());
}

let desired_protocol_version = DESIRED_PLATFORM_VERSION.protocol_version;

let response = proto::ResponseInfo {
data: "".to_string(),
app_version: desired_protocol_version as u64,
last_block_height: platform_state.last_committed_block_height() as i64,
last_block_height,
version: env!("CARGO_PKG_VERSION").to_string(),
last_block_app_hash: platform_state_app_hash.to_vec(),
};
Expand All @@ -63,7 +71,7 @@ where
block_version = request.block_version,
p2p_version = request.p2p_version,
app_hash = hex::encode(platform_state_app_hash),
height = platform_state.last_committed_block_height(),
last_block_height,
"Handshake with consensus engine",
);

Expand Down
16 changes: 11 additions & 5 deletions packages/rs-drive-abci/src/abci/handler/prepare_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::platform_types::platform_state::v0::PlatformStateV0Methods;
use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult;
use crate::rpc::core::CoreRPCLike;
use dpp::dashcore::hashes::Hash;
use dpp::dashcore::Network;
use dpp::version::TryIntoPlatformVersioned;
use drive::grovedb_storage::Error::RocksDBError;
use tenderdash_abci::proto::abci as proto;
Expand Down Expand Up @@ -53,12 +54,17 @@ where
)
.unwrap()?;

if drive_storage_root_hash != platform_state_app_hash {
return Err(AbciError::AppHashMismatch {
drive_storage_root_hash,
platform_state_app_hash,
// TODO: Document this
// TODO: verify that chain id is evo1
#[allow(clippy::collapsible_if)]
if !(app.platform().config.network == Network::Dash && request.height == 32327) {
if drive_storage_root_hash != platform_state_app_hash {
return Err(AbciError::AppHashMismatch {
drive_storage_root_hash,
platform_state_app_hash,
}
.into());
}
.into());
}

let last_committed_core_height = platform_state.last_committed_core_height();
Expand Down
16 changes: 11 additions & 5 deletions packages/rs-drive-abci/src/abci/handler/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::platform_types::block_execution_outcome;
use crate::platform_types::platform_state::v0::PlatformStateV0Methods;
use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult;
use crate::rpc::core::CoreRPCLike;
use dpp::dashcore::Network;
use dpp::version::TryIntoPlatformVersioned;
use drive::grovedb_storage::Error::RocksDBError;
use tenderdash_abci::proto::abci as proto;
Expand Down Expand Up @@ -197,12 +198,17 @@ where
)
.unwrap()?;

if drive_storage_root_hash != platform_state_app_hash {
return Err(AbciError::AppHashMismatch {
drive_storage_root_hash,
platform_state_app_hash,
// TODO: Document this
// TODO: verify that chain id is evo1
#[allow(clippy::collapsible_if)]
if !(app.platform().config.network == Network::Dash && request.height == 32327) {
if drive_storage_root_hash != platform_state_app_hash {
return Err(AbciError::AppHashMismatch {
drive_storage_root_hash,
platform_state_app_hash,
}
.into());
}
.into());
}

let starting_platform_version = platform_state.current_platform_version()?;
Expand Down
6 changes: 0 additions & 6 deletions packages/rs-drive-abci/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ struct PlatformConfigIntermediate {
#[serde(flatten)]
pub instant_lock: InstantLockConfig,
pub block_spacing_ms: u64,
#[serde(default = "PlatformConfig::default_initial_protocol_version")]
pub initial_protocol_version: ProtocolVersion,
pub db_path: PathBuf,
#[serde(default)]
pub rejections_path: Option<PathBuf>,
Expand Down Expand Up @@ -624,10 +622,6 @@ impl ExecutionConfig {
}

impl PlatformConfig {
fn default_initial_protocol_version() -> ProtocolVersion {
INITIAL_PROTOCOL_VERSION
}

fn default_network() -> Network {
Network::Dash
}
Expand Down

0 comments on commit bc6d8d4

Please sign in to comment.