Skip to content

Commit

Permalink
chore: update rs-tenderdash-abci to v0.14.0-dev.6 and tenderdash to v…
Browse files Browse the repository at this point in the history
…0.14.0-dev.2 (#1686)
  • Loading branch information
lklimek authored Feb 1, 2024
1 parent 0e78075 commit 63e5366
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 34 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/dapi-grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/configs/defaults/getBaseConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-drive-abci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 2 additions & 0 deletions packages/rs-drive-abci/src/abci/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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::<Vec<_>>()
.into();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,7 +99,7 @@ where
} = block;

let block_id_hash = Into::<ProtoBlockId>::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");
Expand Down
11 changes: 6 additions & 5 deletions packages/rs-drive-abci/src/mimic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down
21 changes: 12 additions & 9 deletions packages/rs-drive-abci/src/platform_types/commit/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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();

Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -39,6 +39,7 @@ impl<'a> WithdrawalTxs<'a> {
r#type: VoteExtensionType::ThresholdRecover.into(),
extension: v,
signature: Default::default(),
sign_request_id: None,
})
.collect::<Vec<VoteExtension>>();

Expand Down Expand Up @@ -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::<Vec<ExtendVoteExtension>>()
}
Expand All @@ -106,6 +108,7 @@ impl<'a> WithdrawalTxs<'a> {
.map(|v| ExtendVoteExtension {
r#type: v.r#type,
extension: v.extension,
sign_request_id: None,
})
.collect::<Vec<ExtendVoteExtension>>()
}
Expand Down Expand Up @@ -190,6 +193,7 @@ impl<'a> From<Vec<ExtendVoteExtension>> for WithdrawalTxs<'a> {
r#type: v.r#type,
extension: v.extension,
signature: Default::default(),
sign_request_id: None,
})
.collect::<Vec<VoteExtension>>(),
drive_operations: Vec::<DriveOperation>::new(),
Expand Down Expand Up @@ -261,6 +265,7 @@ mod test {
.into(),
signature,
r#type: VoteExtensionType::ThresholdRecover.into(),
sign_request_id: None,
});

assert!(wt
Expand Down
11 changes: 6 additions & 5 deletions packages/rs-drive-abci/tests/strategy_tests/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<AbciError> {
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(),
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-drive-proof-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions packages/rs-drive-proof-verifier/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 63e5366

Please sign in to comment.