Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
12cc268
build(dashmate): update tenderdash to 0.12-dev.2
lklimek Apr 19, 2023
04d770d
build(rs-drive-abci): use same dashcore version as dashcore-rpc
lklimek Apr 20, 2023
567521b
feat(dashmate): enable sccache for rs-drive-abci
lklimek Apr 20, 2023
8439e13
build: fix yarn deps
lklimek Apr 20, 2023
226dc13
chore: integrate most recent changes from dashcore-rpc
lklimek Apr 20, 2023
b50c033
build(rs-drive-abci): fix sccache memcache in docker
lklimek Apr 21, 2023
e121d09
fix(rs-drive-abci): workaround: pubkey not hex-decoded
lklimek Apr 21, 2023
cfb5c2a
Merge remote-tracking branch 'origin/v0.25-dev' into fix/rs-drive-abci
lklimek Apr 21, 2023
a3c676b
chore: hex decode of pubkey not needed anymore
lklimek Apr 21, 2023
7a2fffa
Merge remote-tracking branch 'origin/v0.25-dev' into fix/rs-drive-abci
lklimek Apr 21, 2023
b320e41
build: updated yarn deps
lklimek Apr 21, 2023
c781ca2
build(rs-drive-abci): docker runs very verbosely (-vvvv)
lklimek Apr 21, 2023
1dfb4f6
Merge remote-tracking branch 'origin/v0.25-dev' into fix/rs-drive-abci
lklimek Apr 24, 2023
7522efc
build: cargo update
lklimek Apr 24, 2023
98dac52
fix(dashmate): add missing genesis fields to base conf
lklimek Apr 24, 2023
25cc27b
fix(rs-drive-abci): invalid v20 fork name
lklimek Apr 24, 2023
41df075
fix(dashmate): use fallbackfee=0.00001 for core
lklimek Apr 24, 2023
25fa358
fix(rs-drive-abci): minimum core height is 1, not 0
lklimek Apr 24, 2023
bd7607f
feat(rs-drive-abci): enable logging of dashcore-rpc issues
lklimek Apr 24, 2023
cd80522
chore: rustfmt
lklimek Apr 24, 2023
c8ce5ce
fix(rs-drive-abci): pub_key_operator is not hex-decoded
lklimek Apr 25, 2023
1fb71b4
fix(rs-drive-abci): init_chain not returning validator set
lklimek Apr 25, 2023
622e77a
fix(rs-drive-abci): quorum hash and protxhash must be reversed when s…
lklimek Apr 25, 2023
e897396
Merge remote-tracking branch 'origin/v0.25-dev' into fix/rs-drive-abci
lklimek Apr 25, 2023
b4df9c0
Merge remote-tracking branch 'origin/v0.25-dev' into fix/rs-drive-abci
lklimek Apr 25, 2023
54d7708
feat(dashmate): wait for v20 fork to activate
lklimek Apr 25, 2023
ffedd8c
build: use dash core 20.0.0-alpha.assetlocks.3
lklimek Apr 25, 2023
e5e5203
chore(dashmate): fix linter issue
lklimek Apr 26, 2023
27c62ad
Merge remote-tracking branch 'origin/v0.25-dev' into fix/rs-drive-abci
lklimek Apr 26, 2023
56a755a
fix(rs-drive-abci): hash and state id can be empty at genesis
lklimek Apr 26, 2023
153e6ff
Merge remote-tracking branch 'origin/v0.25-dev' into rs-drive-abci-bl…
lklimek Apr 26, 2023
90f5b5a
fix(rs-drive-abci): compare block hash with hash from commit
lklimek Apr 26, 2023
d89c238
chore(rs-drive-abci): BlockStateInfo: rename commit_hash to app_hash
lklimek Apr 26, 2023
cc24074
build(dashmate): use tenderdash with hotfix
lklimek Apr 26, 2023
9971cf8
fix(rs-drive-abci): quorum hash should be reversed
lklimek Apr 26, 2023
84dfa0f
feat(rs-drive-abci): verify core height received from Tenderdash
lklimek Apr 27, 2023
c98a383
Merge remote-tracking branch 'origin/v0.25-dev' into rs-drive-abci-bl…
lklimek Apr 27, 2023
a12446d
chore: fix build issues
lklimek Apr 27, 2023
bd0626a
chore(rs-drive-abci): update to newer rs-tenderdash-abci lib
lklimek Apr 27, 2023
3057cc7
feat(rs-drive-abci): add --color option to force colorized output
lklimek Apr 27, 2023
dd5fefb
fix(rs-drive-abci): fork_info not considered when determining core ch…
lklimek Apr 27, 2023
b626f08
fix(rs-drive-abci): quorum hash must be un-revesed before commit veri…
lklimek Apr 27, 2023
1a617ee
Merge remote-tracking branch 'origin/v0.25-dev' into rs-drive-abci-bl…
lklimek Apr 27, 2023
92b54c1
chore: apply review feedback
lklimek Apr 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 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/dashmate/configs/system/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ module.exports = {
},
tenderdash: {
docker: {
image: 'dashpay/tenderdash:0.12.0-dev.2',
image: 'dashpay/tenderdash:fix-CoreChainLockedHeight',
},
p2p: {
port: 26656,
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 @@ -43,7 +43,7 @@ tracing-subscriber = { version = "0.3.16", default-features = false, features =
"ansi",
], optional = true }
atty = { version = "0.2.14", optional = true }
tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", optional = true }
tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", branch = "fix/signatures", optional = true }
# tenderdash-abci = { path = "../../../rs-tenderdash-abci/abci", optional = true }
anyhow = { version = "1.0.70" }
lazy_static = "1.4.0"
Expand Down
20 changes: 12 additions & 8 deletions packages/rs-drive-abci/src/abci/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use crate::execution::finalize_block_cleaned_request::{CleanedBlockId, CleanedCo
use dashcore_rpc::dashcore_rpc_json::QuorumType;
use dpp::bls_signatures;
use dpp::validation::{SimpleValidationResult, ValidationResult};
use tenderdash_abci::proto;
use tenderdash_abci::proto::abci::CommitInfo;
use tenderdash_abci::proto::types::BlockId;
use tenderdash_abci::proto::{self, signatures::SignDigest};
use tenderdash_abci::signatures::SignDigest;

use super::AbciError;

Expand Down Expand Up @@ -34,7 +35,8 @@ impl Commit {
block_id: Some(block_id.try_into().expect("cannot convert block id")),
height: height as i64,
round: ci.round as i32,
quorum_hash: ci.quorum_hash.to_vec(),
// we need to "un-reverse" quorum hash, as it was reversed in [CleanedCommitInfo::try_from]
quorum_hash: ci.quorum_hash.iter().rev().cloned().collect(),
threshold_block_signature: ci.block_signature.to_vec(),
threshold_vote_extensions: ci.threshold_vote_extensions.to_vec(),
},
Expand Down Expand Up @@ -94,16 +96,20 @@ impl Commit {

//todo: maybe cache this to lower the chance of a hashing based attack (forcing the
// same calculation each time)
let quorum_hash = &self.inner.quorum_hash[..]
.try_into()
.expect("invalid quorum hash length");
Comment thread
lklimek marked this conversation as resolved.

let hash = match self
.inner
.sign_digest(
&self.chain_id,
self.quorum_type as u8,
&self.inner.quorum_hash,
quorum_hash,
self.inner.height,
self.inner.round,
)
.map_err(AbciError::TenderdashProto)
.map_err(AbciError::Tenderdash)
{
Ok(hash) => hash,
Err(e) => return ValidationResult::new_with_error(e),
Expand All @@ -128,10 +134,8 @@ mod test {
dashcore::hashes::sha256, dashcore::hashes::Hash, dashcore_rpc_json::QuorumType,
};
use dpp::bls_signatures::PublicKey;
use tenderdash_abci::proto::{
signatures::{SignBytes, SignDigest},
types::{BlockId, PartSetHeader, StateId},
};
use tenderdash_abci::proto::types::{BlockId, PartSetHeader, StateId};
use tenderdash_abci::signatures::{SignBytes, SignDigest};

/// Given a commit info and a signature, check that the signature is verified correctly
#[test]
Expand Down
34 changes: 22 additions & 12 deletions packages/rs-drive-abci/src/abci/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
//!

use crate::abci::server::AbciApplication;
use crate::error::execution::ExecutionError;
use crate::error::Error;
use crate::execution::block_proposal::BlockProposal;
use crate::execution::engine::BlockExecutionOutcome;
use crate::rpc::core::CoreRPCLike;
use dashcore_rpc::dashcore::hashes::hex::ToHex;
use dpp::errors::consensus::codes::ErrorWithCode;
use drive::fee::credits::SignedCredits;
use tenderdash_abci::proto::abci::response_verify_vote_extension::VerifyStatus;
Expand All @@ -44,12 +49,7 @@ use tenderdash_abci::proto::abci::{
RequestProcessProposal, RequestQuery, ResponseCheckTx, ResponseFinalizeBlock,
ResponseInitChain, ResponsePrepareProposal, ResponseProcessProposal, ResponseQuery, TxRecord,
};
use tenderdash_abci::proto::types::{CoreChainLock, VoteExtensionType};

use crate::error::execution::ExecutionError;
use crate::error::Error;
use crate::execution::block_proposal::BlockProposal;
use crate::execution::engine::BlockExecutionOutcome;
use tenderdash_abci::proto::types::VoteExtensionType;

use super::withdrawal::WithdrawalTxs;
use super::AbciError;
Expand Down Expand Up @@ -261,10 +261,15 @@ where

let block_state_info = &block_execution_context.block_state_info;

if !block_state_info.matches_current_block(height as u64, round as u32, block_hash)? {
if !block_state_info.matches_current_block(
height as u64,
round as u32,
block_hash.clone(),
)? {
return Err(Error::from(AbciError::RequestForWrongBlockReceived(format!(
"received request for height: {} round: {}, expected height: {} round: {}",
height, round, block_state_info.height, block_state_info.round
"received request for height: {} round: {}, block: {}; expected height: {} round: {}, block: {}",
height, round, block_hash.to_hex(),
block_state_info.height, block_state_info.round, block_state_info.block_hash.to_hex()
)))
.into());
} else {
Expand Down Expand Up @@ -306,10 +311,15 @@ where

let block_state_info = &block_execution_context.block_state_info;

if !block_state_info.matches_current_block(height as u64, round as u32, block_hash)? {
if !block_state_info.matches_current_block(
height as u64,
round as u32,
block_hash.clone(),
)? {
return Err(Error::from(AbciError::RequestForWrongBlockReceived(format!(
"received request for height: {} round: {}, expected height: {} round: {}",
height, round, block_state_info.height, block_state_info.round
"received request for height: {} round: {}, block: {}; expected height: {} round: {}, block: {}",
height, round,block_hash.to_hex(),
block_state_info.height, block_state_info.round, block_state_info.block_hash.to_hex()
)))
.into());
}
Expand Down
37 changes: 31 additions & 6 deletions packages/rs-drive-abci/src/abci/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,47 @@ use drive::fee::result::FeeResult;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use tenderdash_abci::proto::abci::RequestInitChain;
use tenderdash_abci::proto::google::protobuf::Timestamp;
use tenderdash_abci::proto::serializers::timestamp::ToMilis;

use super::AbciError;

/// A struct for handling chain initialization requests
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InitChainRequest {
/// The genesis time in milliseconds
pub genesis_time_ms: TimestampMillis,
/// The system identity public keys
pub system_identity_public_keys: SystemIdentityPublicKeys,
pub genesis_time: TimestampMillis,

/// Initial core chain lock height.
pub initial_core_height: Option<u32>,
}

impl TryFrom<RequestInitChain> for InitChainRequest {
type Error = AbciError;
fn try_from(request: RequestInitChain) -> Result<Self, Self::Error> {
let genesis_time = request
.time
.ok_or(AbciError::BadRequest(
"genesis time is required in init chain".to_string(),
))?
.to_milis() as TimestampMillis;
let initial_core_height = match request.initial_core_height {
0 => None,
h => Some(h),
};

Ok(Self {
genesis_time,
initial_core_height,
})
}
}

impl From<InitChainRequest> for RequestInitChain {
fn from(value: InitChainRequest) -> Self {
let InitChainRequest {
genesis_time_ms,
system_identity_public_keys: _,
genesis_time: genesis_time_ms,
initial_core_height,
} = value;
RequestInitChain {
time: Some(Timestamp {
Expand All @@ -72,7 +97,7 @@ impl From<InitChainRequest> for RequestInitChain {
validator_set: None,
app_state_bytes: vec![],
initial_height: 0,
initial_core_height: 0,
initial_core_height: initial_core_height.unwrap_or_default(),
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions packages/rs-drive-abci/src/abci/mimic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ use tenderdash_abci::proto::google::protobuf::Timestamp;
use tenderdash_abci::proto::types::{
Block, BlockId, Data, EvidenceList, Header, PartSetHeader, VoteExtension, VoteExtensionType,
};
use tenderdash_abci::proto::version::Consensus;
use tenderdash_abci::{
proto::{self, signatures::SignDigest},
Application,
signatures::SignDigest,
proto::{self, version::Consensus},
Application
};

/// The outcome struct when mimicking block execution
Expand Down Expand Up @@ -243,11 +243,12 @@ impl<'a, C: CoreRPCLike> AbciApplication<'a, C> {

//if not in testing this will default to true
if self.platform.config.testing_configs.block_signing {
let quorum_hash:[u8;32] = current_quorum.quorum_hash[..].try_into().expect("wrong quorum hash len");
Comment thread
lklimek marked this conversation as resolved.
let digest = commit
.sign_digest(
&chain_id,
quorum_type as u8,
&current_quorum.quorum_hash,
&quorum_hash,
height as i64,
0,
)
Expand Down
8 changes: 3 additions & 5 deletions packages/rs-drive-abci/src/abci/withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use drive::{
use std::fmt::Display;
use tenderdash_abci::proto::{
abci::ExtendVoteExtension,
signatures::SignDigest,
types::{VoteExtension, VoteExtensionType},
};
use tenderdash_abci::signatures::SignDigest;

use super::AbciError;

Expand Down Expand Up @@ -130,14 +130,12 @@ impl<'a> WithdrawalTxs<'a> {
let hash = match s.sign_digest(
chain_id,
quorum_type as u8,
quorum_hash,
quorum_hash.try_into().expect("invalid quorum hash length"),
Comment thread
lklimek marked this conversation as resolved.
height as i64,
round as i32,
) {
Ok(h) => h,
Err(e) => {
return SimpleValidationResult::new_with_error(AbciError::TenderdashProto(e))
}
Err(e) => return SimpleValidationResult::new_with_error(AbciError::Tenderdash(e)),
};

let signature = match bls_signatures::Signature::from_bytes(&s.signature) {
Expand Down
Loading