From 1a1037095f999ae9366dd3f03d44b43a3bb25c04 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:16:32 +0100 Subject: [PATCH 1/2] chore: update rs-tenderdash-abci to v0.14.0-dev.6 --- Cargo.lock | 12 +++++------ packages/dapi-grpc/Cargo.toml | 2 +- packages/rs-drive-abci/Cargo.toml | 2 +- .../rs-drive-abci/src/abci/handler/mod.rs | 2 ++ .../engine/finalize_block_proposal/v0/mod.rs | 4 ++-- packages/rs-drive-abci/src/mimic/mod.rs | 11 +++++----- .../src/platform_types/commit/v0/mod.rs | 21 +++++++++++-------- .../withdrawal/withdrawal_txs/v0/mod.rs | 7 ++++++- .../tests/strategy_tests/query.rs | 11 +++++----- packages/rs-drive-proof-verifier/Cargo.toml | 2 +- .../rs-drive-proof-verifier/src/verify.rs | 4 ++-- 11 files changed, 45 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7ff029c4a6..1f32aa20cba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4132,8 +4132,8 @@ dependencies = [ [[package]] name = "tenderdash-abci" -version = "0.14.0-dev.5" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.5#556f3a9b6724bdbe44acf8045cd87144a997bccb" +version = "0.14.0-dev.6" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?rev=251386f9e4109c89ca628226c981c489b80aed80#251386f9e4109c89ca628226c981c489b80aed80" dependencies = [ "bytes", "futures", @@ -4153,8 +4153,8 @@ dependencies = [ [[package]] name = "tenderdash-proto" -version = "0.14.0-dev.5" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.5#556f3a9b6724bdbe44acf8045cd87144a997bccb" +version = "0.14.0-dev.6" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?rev=251386f9e4109c89ca628226c981c489b80aed80#251386f9e4109c89ca628226c981c489b80aed80" dependencies = [ "bytes", "chrono", @@ -4171,8 +4171,8 @@ dependencies = [ [[package]] name = "tenderdash-proto-compiler" -version = "0.14.0-dev.5" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.5#556f3a9b6724bdbe44acf8045cd87144a997bccb" +version = "0.14.0-dev.6" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?rev=251386f9e4109c89ca628226c981c489b80aed80#251386f9e4109c89ca628226c981c489b80aed80" dependencies = [ "fs_extra", "prost-build 0.12.3", diff --git a/packages/dapi-grpc/Cargo.toml b/packages/dapi-grpc/Cargo.toml index 5936b3fce84..e16b24b1f36 100644 --- a/packages/dapi-grpc/Cargo.toml +++ b/packages/dapi-grpc/Cargo.toml @@ -30,7 +30,7 @@ tonic = { version = "0.9.2", features = [ ], default-features = false } serde = { version = "1.0.171", optional = true, features = ["derive"] } serde_bytes = { version = "0.11.12", optional = true } -tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v0.14.0-dev.5" } +tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", rev = "251386f9e4109c89ca628226c981c489b80aed80" } dapi-grpc-macros = { path = "../rs-dapi-grpc-macros" } platform-version = { path = "../rs-platform-version" } diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index ea9f1bf5658..10f1ec47447 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -58,7 +58,7 @@ tracing-subscriber = { version = "0.3.16", default-features = false, features = "tracing-log", ], optional = false } atty = { version = "0.2.14", optional = false } -tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v0.14.0-dev.5" } +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", rev = "251386f9e4109c89ca628226c981c489b80aed80" } lazy_static = "1.4.0" itertools = { version = "0.10.5" } file-rotate = { version = "0.7.3" } diff --git a/packages/rs-drive-abci/src/abci/handler/mod.rs b/packages/rs-drive-abci/src/abci/handler/mod.rs index fc935446f65..514f046b870 100644 --- a/packages/rs-drive-abci/src/abci/handler/mod.rs +++ b/packages/rs-drive-abci/src/abci/handler/mod.rs @@ -644,6 +644,7 @@ where .map(|tx_id| proto::ExtendVoteExtension { r#type: VoteExtensionType::ThresholdRecover as i32, extension: tx_id.to_byte_array().to_vec(), + sign_request_id: None, }) .collect(); Ok(proto::ResponseExtendVote { @@ -693,6 +694,7 @@ where .map(|tx_id| proto::ExtendVoteExtension { r#type: VoteExtensionType::ThresholdRecover as i32, extension: tx_id.to_byte_array().to_vec(), + sign_request_id: None, }) .collect::>() .into(); diff --git a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs index 51b6db63523..b949f9c7603 100644 --- a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs @@ -10,7 +10,7 @@ use dpp::version::PlatformVersion; use tenderdash_abci::{ proto::{serializers::timestamp::ToMilis, types::BlockId as ProtoBlockId}, - signatures::SignBytes, + signatures::Hashable, }; use crate::abci::AbciError; @@ -99,7 +99,7 @@ where } = block; let block_id_hash = Into::::into(block_id.clone()) - .sha256(&self.config.abci.chain_id, height as i64, round as i32) + .calculate_msg_hash(&self.config.abci.chain_id, height as i64, round as i32) .map_err(AbciError::from)? .try_into() .expect("invalid sha256 length"); diff --git a/packages/rs-drive-abci/src/mimic/mod.rs b/packages/rs-drive-abci/src/mimic/mod.rs index 640a6baa1ad..a3942c779fc 100644 --- a/packages/rs-drive-abci/src/mimic/mod.rs +++ b/packages/rs-drive-abci/src/mimic/mod.rs @@ -26,8 +26,8 @@ use tenderdash_abci::proto::serializers::timestamp::ToMilis; use tenderdash_abci::proto::types::{ Block, BlockId, Data, EvidenceList, Header, PartSetHeader, VoteExtension, VoteExtensionType, StateId, CanonicalVote, SignedMsgType, }; -use tenderdash_abci::signatures::SignBytes; -use tenderdash_abci::{signatures::SignDigest, proto::version::Consensus, Application}; +use tenderdash_abci::signatures::Hashable; +use tenderdash_abci::{signatures::Signable, proto::version::Consensus, Application}; use tenderdash_abci::proto::abci::tx_record::TxAction; use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0Getters; use crate::execution::types::block_state_info::v0::BlockStateInfoV0Getters; @@ -205,7 +205,7 @@ impl<'a, C: CoreRPCLike> AbciApplication<'a, C> { time: time.to_milis(), }; let state_id_hash = state_id - .sha256(CHAIN_ID, height as i64, round as i32) + .calculate_msg_hash(CHAIN_ID, height as i64, round as i32) .expect("cannot hash state id"); let block_header_hash: [u8; 32] = rng.gen(); @@ -218,7 +218,7 @@ impl<'a, C: CoreRPCLike> AbciApplication<'a, C> { state_id: state_id_hash, }; let block_id_hash = block_id - .sha256(CHAIN_ID, height as i64, round as i32) + .calculate_msg_hash(CHAIN_ID, height as i64, round as i32) .expect("cannot hash block id"); let request_process_proposal = RequestProcessProposal { @@ -410,6 +410,7 @@ impl<'a, C: CoreRPCLike> AbciApplication<'a, C> { r#type: VoteExtensionType::ThresholdRecover as i32, extension: tx_id.to_byte_array().to_vec(), signature: vec![], //todo: signature + sign_request_id: None, } }) .collect(); @@ -448,7 +449,7 @@ impl<'a, C: CoreRPCLike> AbciApplication<'a, C> { let quorum_type = self.platform.config.validator_set_quorum_type(); let state_id_hash = state_id - .sha256(CHAIN_ID, height as i64, round as i32) + .calculate_msg_hash(CHAIN_ID, height as i64, round as i32) .expect("cannot calculate state id hash"); let commit = CanonicalVote { diff --git a/packages/rs-drive-abci/src/platform_types/commit/v0/mod.rs b/packages/rs-drive-abci/src/platform_types/commit/v0/mod.rs index a85505b57c7..07bb19c51b2 100644 --- a/packages/rs-drive-abci/src/platform_types/commit/v0/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/commit/v0/mod.rs @@ -10,7 +10,7 @@ use dpp::validation::{SimpleValidationResult, ValidationResult}; use tenderdash_abci::proto; use tenderdash_abci::proto::abci::CommitInfo; use tenderdash_abci::proto::types::BlockId; -use tenderdash_abci::signatures::SignDigest; +use tenderdash_abci::signatures::Signable; /// Represents block commit #[derive(Clone, Debug)] @@ -141,7 +141,7 @@ mod test { use dpp::bls_signatures::PublicKey; use tenderdash_abci::proto::types::{BlockId, PartSetHeader, StateId}; - use tenderdash_abci::signatures::{SignBytes, SignDigest}; + use tenderdash_abci::signatures::{Hashable, Signable}; /// Given a commit info and a signature, check that the signature is verified correctly #[test] @@ -178,7 +178,9 @@ mod test { .to_byte_array() .to_vec(), }), - state_id: state_id.sha256(CHAIN_ID, HEIGHT, ROUND as i32).unwrap(), + state_id: state_id + .calculate_msg_hash(CHAIN_ID, HEIGHT, ROUND as i32) + .unwrap(), }; let pubkey = hex::decode("8d63d603fe858be4d7c14a8f308936bd3447c1f361148ad508a04df92f48cd3b2f2b374ef5d1ee8a75f5aeda2f6f3418").unwrap(); @@ -192,27 +194,28 @@ mod test { QuorumType::LlmqTest, CHAIN_ID, ); - let expect_sign_bytes = hex::decode( + let expect_msg = hex::decode( "020000003930000000000000020000000000000035117edfe49351da1e81d1b0f2edfa0b984a7508\ 958870337126efb352f1210715e56fe9d267359b4b437a52636174ac64aa9a021671aabc9985023695bc6e3\ 6746573745f636861696e5f6964", ) .unwrap(); - let expect_sign_id = + let expect_msg_hash = sha256::Hash::hash(&expect_msg).to_byte_array().to_vec(); + let expect_sign_hash = hex::decode("58fb34b03f9028e6ac181418c753f33e471ae223bb66b2bef7b46732a15b7eac") .unwrap(); assert_eq!( - expect_sign_bytes, + expect_msg_hash, commit .inner - .sign_bytes(CHAIN_ID, HEIGHT, ROUND as i32) + .calculate_msg_hash(CHAIN_ID, HEIGHT, ROUND as i32) .unwrap() ); assert_eq!( - expect_sign_id, + expect_sign_hash, commit .inner - .sign_digest( + .calculate_sign_hash( CHAIN_ID, QuorumType::LlmqTest as u8, &QUORUM_HASH, diff --git a/packages/rs-drive-abci/src/platform_types/withdrawal/withdrawal_txs/v0/mod.rs b/packages/rs-drive-abci/src/platform_types/withdrawal/withdrawal_txs/v0/mod.rs index 0293eb65f12..a1e129a4b5f 100644 --- a/packages/rs-drive-abci/src/platform_types/withdrawal/withdrawal_txs/v0/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/withdrawal/withdrawal_txs/v0/mod.rs @@ -15,7 +15,7 @@ use tenderdash_abci::proto::{ abci::ExtendVoteExtension, types::{VoteExtension, VoteExtensionType}, }; -use tenderdash_abci::signatures::SignDigest; +use tenderdash_abci::signatures::Signable; const MAX_WITHDRAWAL_TXS: u16 = 16; @@ -39,6 +39,7 @@ impl<'a> WithdrawalTxs<'a> { r#type: VoteExtensionType::ThresholdRecover.into(), extension: v, signature: Default::default(), + sign_request_id: None, }) .collect::>(); @@ -96,6 +97,7 @@ impl<'a> WithdrawalTxs<'a> { .map(|v| ExtendVoteExtension { r#type: v.r#type, extension: v.extension.clone(), + sign_request_id: None, }) .collect::>() } @@ -106,6 +108,7 @@ impl<'a> WithdrawalTxs<'a> { .map(|v| ExtendVoteExtension { r#type: v.r#type, extension: v.extension, + sign_request_id: None, }) .collect::>() } @@ -190,6 +193,7 @@ impl<'a> From> for WithdrawalTxs<'a> { r#type: v.r#type, extension: v.extension, signature: Default::default(), + sign_request_id: None, }) .collect::>(), drive_operations: Vec::::new(), @@ -261,6 +265,7 @@ mod test { .into(), signature, r#type: VoteExtensionType::ThresholdRecover.into(), + sign_request_id: None, }); assert!(wt diff --git a/packages/rs-drive-abci/tests/strategy_tests/query.rs b/packages/rs-drive-abci/tests/strategy_tests/query.rs index 17ae1ce383a..9ecef4c7145 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/query.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/query.rs @@ -26,7 +26,7 @@ use strategy_tests::frequency::Frequency; use tenderdash_abci::proto::google::protobuf::Timestamp; use tenderdash_abci::proto::serializers::timestamp::ToMilis; use tenderdash_abci::proto::types::{CanonicalVote, SignedMsgType, StateId}; -use tenderdash_abci::signatures::{SignBytes, SignDigest}; +use tenderdash_abci::signatures::{Hashable, Signable}; #[derive(Clone, Debug, Default)] pub struct QueryStrategy { @@ -80,10 +80,11 @@ impl<'a> ProofVerification<'a> { /// Implements algorithm described at: /// https://github.com/dashpay/tenderdash/blob/v0.12-dev/spec/consensus/signing.md#block-signature-verification-on-light-client fn verify_signature(&self, state_id: StateId, round: u32) -> SimpleValidationResult { - let state_id_hash = match state_id.sha256(&self.chain_id, self.height, round as i32) { - Ok(s) => s, - Err(e) => return SimpleValidationResult::new_with_error(AbciError::from(e)), - }; + let state_id_hash = + match state_id.calculate_msg_hash(&self.chain_id, self.height, round as i32) { + Ok(s) => s, + Err(e) => return SimpleValidationResult::new_with_error(AbciError::from(e)), + }; let v = CanonicalVote { block_id: self.block_hash.to_vec(), diff --git a/packages/rs-drive-proof-verifier/Cargo.toml b/packages/rs-drive-proof-verifier/Cargo.toml index 3b42107d9e7..45a8a436ee1 100644 --- a/packages/rs-drive-proof-verifier/Cargo.toml +++ b/packages/rs-drive-proof-verifier/Cargo.toml @@ -20,7 +20,7 @@ drive = { path = "../rs-drive", default-features = false, features = [ "verify", ] } dpp = { path = "../rs-dpp" } -tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v0.14.0-dev.5" } +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", rev = "251386f9e4109c89ca628226c981c489b80aed80" } # tenderdash-abci = { path = "../../../rs-tenderdash-abci/abci" } tracing = { version = "0.1.37" } serde = { version = "1.0.171", default-features = false, optional = true } diff --git a/packages/rs-drive-proof-verifier/src/verify.rs b/packages/rs-drive-proof-verifier/src/verify.rs index 70ea4406601..51cb55d909b 100644 --- a/packages/rs-drive-proof-verifier/src/verify.rs +++ b/packages/rs-drive-proof-verifier/src/verify.rs @@ -3,7 +3,7 @@ use dpp::bls_signatures; pub use drive::drive::verify::RootHash; use tenderdash_abci::{ proto::types::{CanonicalVote, SignedMsgType, StateId}, - signatures::{SignBytes, SignDigest}, + signatures::{Hashable, Signable}, }; use crate::Error; @@ -61,7 +61,7 @@ pub(crate) fn verify_tenderdash_proof( }; let state_id_hash = state_id - .sha256(&chain_id, mtd.height as i64, proof.round as i32) + .calculate_msg_hash(&chain_id, mtd.height as i64, proof.round as i32) .expect("failed to calculate state id hash"); let commit = CanonicalVote { From b6f9ee4d28dfccc0e0e43507c6cd9489eb69db9a Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:36:44 +0100 Subject: [PATCH 2/2] build: bump tenderdash in dashmate to 0.14.0-dev.2 --- packages/dashmate/configs/defaults/getBaseConfigFactory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dashmate/configs/defaults/getBaseConfigFactory.js b/packages/dashmate/configs/defaults/getBaseConfigFactory.js index e7d67da2552..ab4227806da 100644 --- a/packages/dashmate/configs/defaults/getBaseConfigFactory.js +++ b/packages/dashmate/configs/defaults/getBaseConfigFactory.js @@ -178,7 +178,7 @@ export default function getBaseConfigFactory(homeDir) { tenderdash: { mode: 'full', docker: { - image: 'dashpay/tenderdash:fix-ordered-map', + image: 'dashpay/tenderdash:0.14.0-dev.2', }, p2p: { host: '0.0.0.0',