diff --git a/packages/rs-drive-abci/src/abci/handler/mod.rs b/packages/rs-drive-abci/src/abci/handler/mod.rs index 8a300768e1..f67d3f3581 100644 --- a/packages/rs-drive-abci/src/abci/handler/mod.rs +++ b/packages/rs-drive-abci/src/abci/handler/mod.rs @@ -46,7 +46,7 @@ use crate::rpc::core::CoreRPCLike; use dpp::errors::consensus::codes::ErrorWithCode; use tenderdash_abci::proto::abci::response_verify_vote_extension::VerifyStatus; use tenderdash_abci::proto::abci::tx_record::TxAction; -use tenderdash_abci::proto::abci::{self as proto}; +use tenderdash_abci::proto::abci::{self as proto, ResponseException}; use tenderdash_abci::proto::abci::{ ExecTxResult, RequestCheckTx, RequestFinalizeBlock, RequestInitChain, RequestPrepareProposal, RequestProcessProposal, RequestQuery, ResponseCheckTx, ResponseFinalizeBlock, @@ -200,13 +200,6 @@ where let transaction = transaction_guard.as_ref().unwrap(); - // Get current platform version - let state = self.platform.state.read().expect("expected to get state"); - let current_protocol_version = state.current_protocol_version_in_consensus(); - drop(state); - let platform_version = PlatformVersion::get(current_protocol_version) - .map_err(|e| proto::ResponseException::from(Error::from(e)))?; - // Running the proposal executes all the state transitions for the block let run_result = self .platform @@ -221,8 +214,12 @@ where app_hash, state_transition_results, validator_set_update, + protocol_version, } = run_result.into_data().map_err(Error::Protocol)?; + let platform_version = PlatformVersion::get(protocol_version) + .expect("must be set in run block proposal from existing protocol version"); + // We need to let Tenderdash know about the transactions we should remove from execution let mut tx_results = Vec::new(); let mut tx_records = Vec::new(); @@ -389,14 +386,11 @@ where app_hash, state_transition_results, validator_set_update, + protocol_version, } = run_result.into_data().map_err(Error::Protocol)?; - // Get current platform version - let state = self.platform.state.read().expect("expected to get state"); - let current_protocol_version = state.current_protocol_version_in_consensus(); - drop(state); - let platform_version = PlatformVersion::get(current_protocol_version) - .map_err(|e| proto::ResponseException::from(Error::from(e)))?; + let platform_version = PlatformVersion::get(protocol_version) + .expect("must be set in run block proposer from existing platform version"); let tx_results = state_transition_results .into_iter() diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index 059d24b1a3..fae5cce8e9 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -280,6 +280,7 @@ where app_hash: root_hash, state_transition_results, validator_set_update, + protocol_version: platform_version.protocol_version, }, )) } diff --git a/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs b/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs index d874054f1b..2bb7453355 100644 --- a/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/block_execution_outcome/v0/mod.rs @@ -1,5 +1,6 @@ use crate::abci::AbciError; use crate::platform_types::state_transition_execution_result::StateTransitionExecutionResult; +use dpp::util::deserializer::ProtocolVersion; use dpp::validation::SimpleValidationResult; use tenderdash_abci::proto::abci::ValidatorSetUpdate; @@ -14,6 +15,8 @@ pub struct BlockExecutionOutcome { /// The changes to the validator set // TODO We should use another DTO, only abci module should deal with Tenderdash proto structures pub validator_set_update: Option, + /// Current block protocol version + pub protocol_version: ProtocolVersion, } /// The outcome of the finalization of the block