Skip to content

Commit f299bd7

Browse files
test(drive-abci): give block fixtures a non-zero signature and verify contestant vote proofs in their query direction
The proof-metadata guard treats an all-zero block signature as a state restored via state sync and refuses proofs until the next block finalizes. The hand-built ExtendedBlockInfo fixtures in fast_forward_to_block, the masternode vote tests and the document query v1 tests all used an all-zero signature and started failing on that guard; they now share a TEST_BLOCK_SIGNATURE placeholder. Also: get_proved_contestant_votes verified every proof with an ascending query even when the request was descending; the re-pinned grovedb enforces that a layer proof is encoded in its walk direction's family, so the verifier now uses the same order_ascending as the request. offer_snapshot drops a duplicated 'db bound clippy flagged. Stale doc comments that described the old grovedb pin and the pre-#840 refetch ladder are cleaned up, and sync_snapshot's doc comment is moved back onto the function. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 2d2cbbc commit f299bd7

7 files changed

Lines changed: 64 additions & 60 deletions

File tree

‎packages/rs-drive-abci/src/abci/handler/apply_snapshot_chunk.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ where
6868
// These are TRANSFER faults, not reasons to abort state sync: an application
6969
// error here would reach Tenderdash as an ABCI exception, killing the whole
7070
// restore and leaving the node on the wiped database the offer created (with the
71-
// restore sentinel still set). Both caps are therefore answered with the same
72-
// recoverable ladder the other malformed-chunk paths use.
71+
// restore sentinel still set). Both caps are therefore answered with a
72+
// recoverable response; they run before grovedb sees the chunk, so unlike a
73+
// chunk grovedb rejects (below) they leave the session usable.
7374
if request.chunk.len() > MAX_STATE_SYNC_CHUNK_SIZE {
7475
// Oversized chunk DATA: the chunk id itself is still fine, so ban the sender
7576
// and have Tenderdash refetch exactly this chunk from someone else.

‎packages/rs-drive-abci/src/abci/handler/offer_snapshot.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ use tenderdash_abci::proto::abci::response_offer_snapshot;
1717
/// Accepting an offer wipes the local grovedb and opens a grovedb state sync session
1818
/// targeting the light-client-verified app hash. Any accepted-format offer replaces a
1919
/// session already in progress (also answered with Accept), whatever height it carries.
20-
pub fn offer_snapshot<'a, 'db: 'a, A, C: 'db>(
20+
pub fn offer_snapshot<'a, 'db: 'a, A, C>(
2121
app: &'a A,
2222
request: proto::RequestOfferSnapshot,
2323
) -> Result<proto::ResponseOfferSnapshot, Error>
2424
where
2525
A: StateSyncApplication<'db, C> + 'db,
26-
C: CoreRPCLike,
26+
C: CoreRPCLike + 'db,
2727
{
2828
let request_app_hash: [u8; 32] = request.app_hash.try_into().map_err(|_| {
2929
AbciError::StateSyncBadRequest("offer_snapshot invalid app_hash length".to_string())

‎packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs‎

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ impl StateTransitionStateValidation for MasternodeVoteTransition {
9494

9595
#[cfg(test)]
9696
mod tests {
97+
use crate::test::helpers::fast_forward_to_block::TEST_BLOCK_SIGNATURE;
9798
use crate::test::helpers::setup::TestPlatformBuilder;
9899
use dpp::block::block_info::BlockInfo;
99100
use dpp::dash_to_credits;
@@ -3065,7 +3066,7 @@ mod tests {
30653066
offset: None,
30663067
limit: None,
30673068
start_at: None,
3068-
order_ascending: true,
3069+
order_ascending,
30693070
};
30703071

30713072
let (_, voters) = resolved_contested_document_vote_poll_drive_query
@@ -4214,7 +4215,7 @@ mod tests {
42144215
quorum_hash: [0u8; 32],
42154216
block_id_hash: [0u8; 32],
42164217
proposer_pro_tx_hash: [0u8; 32],
4217-
signature: [0u8; 96],
4218+
signature: TEST_BLOCK_SIGNATURE,
42184219
round: 0,
42194220
}
42204221
.into(),
@@ -4406,7 +4407,7 @@ mod tests {
44064407
quorum_hash: [0u8; 32],
44074408
block_id_hash: [0u8; 32],
44084409
proposer_pro_tx_hash: [0u8; 32],
4409-
signature: [0u8; 96],
4410+
signature: TEST_BLOCK_SIGNATURE,
44104411
round: 0,
44114412
}
44124413
.into(),
@@ -4561,7 +4562,7 @@ mod tests {
45614562
quorum_hash: [0u8; 32],
45624563
block_id_hash: [0u8; 32],
45634564
proposer_pro_tx_hash: [0u8; 32],
4564-
signature: [0u8; 96],
4565+
signature: TEST_BLOCK_SIGNATURE,
45654566
round: 0,
45664567
}
45674568
.into(),
@@ -4604,7 +4605,7 @@ mod tests {
46044605
quorum_hash: [0u8; 32],
46054606
block_id_hash: [0u8; 32],
46064607
proposer_pro_tx_hash: [0u8; 32],
4607-
signature: [0u8; 96],
4608+
signature: TEST_BLOCK_SIGNATURE,
46084609
round: 0,
46094610
}
46104611
.into(),
@@ -4823,7 +4824,7 @@ mod tests {
48234824
quorum_hash: [0u8; 32],
48244825
block_id_hash: [0u8; 32],
48254826
proposer_pro_tx_hash: [0u8; 32],
4826-
signature: [0u8; 96],
4827+
signature: TEST_BLOCK_SIGNATURE,
48274828
round: 0,
48284829
}
48294830
.into(),
@@ -4866,7 +4867,7 @@ mod tests {
48664867
quorum_hash: [0u8; 32],
48674868
block_id_hash: [0u8; 32],
48684869
proposer_pro_tx_hash: [0u8; 32],
4869-
signature: [0u8; 96],
4870+
signature: TEST_BLOCK_SIGNATURE,
48704871
round: 0,
48714872
}
48724873
.into(),
@@ -4987,7 +4988,7 @@ mod tests {
49874988
quorum_hash: [0u8; 32],
49884989
block_id_hash: [0u8; 32],
49894990
proposer_pro_tx_hash: [0u8; 32],
4990-
signature: [0u8; 96],
4991+
signature: TEST_BLOCK_SIGNATURE,
49914992
round: 0,
49924993
}
49934994
.into(),
@@ -5030,7 +5031,7 @@ mod tests {
50305031
quorum_hash: [0u8; 32],
50315032
block_id_hash: [0u8; 32],
50325033
proposer_pro_tx_hash: [0u8; 32],
5033-
signature: [0u8; 96],
5034+
signature: TEST_BLOCK_SIGNATURE,
50345035
round: 0,
50355036
}
50365037
.into(),
@@ -5148,7 +5149,7 @@ mod tests {
51485149
quorum_hash: [0u8; 32],
51495150
block_id_hash: [0u8; 32],
51505151
proposer_pro_tx_hash: [0u8; 32],
5151-
signature: [0u8; 96],
5152+
signature: TEST_BLOCK_SIGNATURE,
51525153
round: 0,
51535154
}
51545155
.into(),
@@ -5191,7 +5192,7 @@ mod tests {
51915192
quorum_hash: [0u8; 32],
51925193
block_id_hash: [0u8; 32],
51935194
proposer_pro_tx_hash: [0u8; 32],
5194-
signature: [0u8; 96],
5195+
signature: TEST_BLOCK_SIGNATURE,
51955196
round: 0,
51965197
}
51975198
.into(),
@@ -5325,7 +5326,7 @@ mod tests {
53255326
quorum_hash: [0u8; 32],
53265327
block_id_hash: [0u8; 32],
53275328
proposer_pro_tx_hash: [0u8; 32],
5328-
signature: [0u8; 96],
5329+
signature: TEST_BLOCK_SIGNATURE,
53295330
round: 0,
53305331
}
53315332
.into(),
@@ -5995,7 +5996,7 @@ mod tests {
59955996
quorum_hash: [0u8; 32],
59965997
block_id_hash: [0u8; 32],
59975998
proposer_pro_tx_hash: [0u8; 32],
5998-
signature: [0u8; 96],
5999+
signature: TEST_BLOCK_SIGNATURE,
59996000
round: 0,
60006001
}
60016002
.into(),
@@ -6218,7 +6219,7 @@ mod tests {
62186219
quorum_hash: [0u8; 32],
62196220
block_id_hash: [0u8; 32],
62206221
proposer_pro_tx_hash: [0u8; 32],
6221-
signature: [0u8; 96],
6222+
signature: TEST_BLOCK_SIGNATURE,
62226223
round: 0,
62236224
}
62246225
.into(),
@@ -6505,7 +6506,7 @@ mod tests {
65056506
quorum_hash: [0u8; 32],
65066507
block_id_hash: [0u8; 32],
65076508
proposer_pro_tx_hash: [0u8; 32],
6508-
signature: [0u8; 96],
6509+
signature: TEST_BLOCK_SIGNATURE,
65096510
round: 0,
65106511
}
65116512
.into(),
@@ -6951,7 +6952,7 @@ mod tests {
69516952
quorum_hash: [0u8; 32],
69526953
block_id_hash: [0u8; 32],
69536954
proposer_pro_tx_hash: [0u8; 32],
6954-
signature: [0u8; 96],
6955+
signature: TEST_BLOCK_SIGNATURE,
69556956
round: 0,
69566957
}
69576958
.into(),
@@ -7074,7 +7075,7 @@ mod tests {
70747075
quorum_hash: [0u8; 32],
70757076
block_id_hash: [0u8; 32],
70767077
proposer_pro_tx_hash: [0u8; 32],
7077-
signature: [0u8; 96],
7078+
signature: TEST_BLOCK_SIGNATURE,
70787079
round: 0,
70797080
}
70807081
.into(),
@@ -7434,7 +7435,7 @@ mod tests {
74347435
quorum_hash: [0u8; 32],
74357436
block_id_hash: [0u8; 32],
74367437
proposer_pro_tx_hash: [0u8; 32],
7437-
signature: [0u8; 96],
7438+
signature: TEST_BLOCK_SIGNATURE,
74387439
round: 0,
74397440
}
74407441
.into(),
@@ -7652,7 +7653,7 @@ mod tests {
76527653
quorum_hash: [0u8; 32],
76537654
block_id_hash: [0u8; 32],
76547655
proposer_pro_tx_hash: [0u8; 32],
7655-
signature: [0u8; 96],
7656+
signature: TEST_BLOCK_SIGNATURE,
76567657
round: 0,
76577658
}
76587659
.into(),
@@ -7865,7 +7866,7 @@ mod tests {
78657866
quorum_hash: [0u8; 32],
78667867
block_id_hash: [0u8; 32],
78677868
proposer_pro_tx_hash: [0u8; 32],
7868-
signature: [0u8; 96],
7869+
signature: TEST_BLOCK_SIGNATURE,
78697870
round: 0,
78707871
}
78717872
.into(),
@@ -8067,7 +8068,7 @@ mod tests {
80678068
quorum_hash: [0u8; 32],
80688069
block_id_hash: [0u8; 32],
80698070
proposer_pro_tx_hash: [0u8; 32],
8070-
signature: [0u8; 96],
8071+
signature: TEST_BLOCK_SIGNATURE,
80718072
round: 0,
80728073
}
80738074
.into(),
@@ -8285,7 +8286,7 @@ mod tests {
82858286
quorum_hash: [0u8; 32],
82868287
block_id_hash: [0u8; 32],
82878288
proposer_pro_tx_hash: [0u8; 32],
8288-
signature: [0u8; 96],
8289+
signature: TEST_BLOCK_SIGNATURE,
82898290
round: 0,
82908291
}
82918292
.into(),
@@ -8499,7 +8500,7 @@ mod tests {
84998500
quorum_hash: [0u8; 32],
85008501
block_id_hash: [0u8; 32],
85018502
proposer_pro_tx_hash: [0u8; 32],
8502-
signature: [0u8; 96],
8503+
signature: TEST_BLOCK_SIGNATURE,
85038504
round: 0,
85048505
}
85058506
.into(),
@@ -8694,7 +8695,7 @@ mod tests {
86948695
quorum_hash: [0u8; 32],
86958696
block_id_hash: [0u8; 32],
86968697
proposer_pro_tx_hash: [0u8; 32],
8697-
signature: [0u8; 96],
8698+
signature: TEST_BLOCK_SIGNATURE,
86988699
round: 0,
86998700
}
87008701
.into(),
@@ -8889,7 +8890,7 @@ mod tests {
88898890
quorum_hash: [0u8; 32],
88908891
block_id_hash: [0u8; 32],
88918892
proposer_pro_tx_hash: [0u8; 32],
8892-
signature: [0u8; 96],
8893+
signature: TEST_BLOCK_SIGNATURE,
88938894
round: 0,
88948895
}
88958896
.into(),
@@ -9193,7 +9194,7 @@ mod tests {
91939194
quorum_hash: [0u8; 32],
91949195
block_id_hash: [0u8; 32],
91959196
proposer_pro_tx_hash: [0u8; 32],
9196-
signature: [0u8; 96],
9197+
signature: TEST_BLOCK_SIGNATURE,
91979198
round: 0,
91989199
}
91999200
.into(),
@@ -9383,7 +9384,7 @@ mod tests {
93839384
quorum_hash: [0u8; 32],
93849385
block_id_hash: [0u8; 32],
93859386
proposer_pro_tx_hash: [0u8; 32],
9386-
signature: [0u8; 96],
9387+
signature: TEST_BLOCK_SIGNATURE,
93879388
round: 0,
93889389
}
93899390
.into(),
@@ -9448,7 +9449,7 @@ mod tests {
94489449
quorum_hash: [0u8; 32],
94499450
block_id_hash: [0u8; 32],
94509451
proposer_pro_tx_hash: [0u8; 32],
9451-
signature: [0u8; 96],
9452+
signature: TEST_BLOCK_SIGNATURE,
94529453
round: 0,
94539454
}
94549455
.into(),
@@ -9718,7 +9719,7 @@ mod tests {
97189719
quorum_hash: [0u8; 32],
97199720
block_id_hash: [0u8; 32],
97209721
proposer_pro_tx_hash: [0u8; 32],
9721-
signature: [0u8; 96],
9722+
signature: TEST_BLOCK_SIGNATURE,
97229723
round: 0,
97239724
}
97249725
.into(),
@@ -9777,7 +9778,7 @@ mod tests {
97779778
quorum_hash: [0u8; 32],
97789779
block_id_hash: [0u8; 32],
97799780
proposer_pro_tx_hash: [0u8; 32],
9780-
signature: [0u8; 96],
9781+
signature: TEST_BLOCK_SIGNATURE,
97819782
round: 0,
97829783
}
97839784
.into(),
@@ -9971,7 +9972,7 @@ mod tests {
99719972
quorum_hash: [0u8; 32],
99729973
block_id_hash: [0u8; 32],
99739974
proposer_pro_tx_hash: [0u8; 32],
9974-
signature: [0u8; 96],
9975+
signature: TEST_BLOCK_SIGNATURE,
99759976
round: 0,
99769977
}
99779978
.into(),
@@ -10289,7 +10290,7 @@ mod tests {
1028910290
quorum_hash: [0u8; 32],
1029010291
block_id_hash: [0u8; 32],
1029110292
proposer_pro_tx_hash: [0u8; 32],
10292-
signature: [0u8; 96],
10293+
signature: TEST_BLOCK_SIGNATURE,
1029310294
round: 0,
1029410295
}
1029510296
.into(),
@@ -10481,7 +10482,7 @@ mod tests {
1048110482
quorum_hash: [0u8; 32],
1048210483
block_id_hash: [0u8; 32],
1048310484
proposer_pro_tx_hash: [0u8; 32],
10484-
signature: [0u8; 96],
10485+
signature: TEST_BLOCK_SIGNATURE,
1048510486
round: 0,
1048610487
}
1048710488
.into(),
@@ -10558,7 +10559,7 @@ mod tests {
1055810559
quorum_hash: [0u8; 32],
1055910560
block_id_hash: [0u8; 32],
1056010561
proposer_pro_tx_hash: [0u8; 32],
10561-
signature: [0u8; 96],
10562+
signature: TEST_BLOCK_SIGNATURE,
1056210563
round: 0,
1056310564
}
1056410565
.into(),
@@ -10757,7 +10758,7 @@ mod tests {
1075710758
quorum_hash: [0u8; 32],
1075810759
block_id_hash: [0u8; 32],
1075910760
proposer_pro_tx_hash: [0u8; 32],
10760-
signature: [0u8; 96],
10761+
signature: TEST_BLOCK_SIGNATURE,
1076110762
round: 0,
1076210763
}
1076310764
.into(),
@@ -10984,7 +10985,7 @@ mod tests {
1098410985
quorum_hash: [0u8; 32],
1098510986
block_id_hash: [0u8; 32],
1098610987
proposer_pro_tx_hash: [0u8; 32],
10987-
signature: [0u8; 96],
10988+
signature: TEST_BLOCK_SIGNATURE,
1098810989
round: 0,
1098910990
}
1099010991
.into(),
@@ -11502,7 +11503,7 @@ mod tests {
1150211503
quorum_hash: [0u8; 32],
1150311504
block_id_hash: [0u8; 32],
1150411505
proposer_pro_tx_hash: [0u8; 32],
11505-
signature: [0u8; 96],
11506+
signature: TEST_BLOCK_SIGNATURE,
1150611507
round: 0,
1150711508
}
1150811509
.into(),

‎packages/rs-drive-abci/src/query/document_query/v1/tests.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1212
use super::*;
1313
use crate::query::tests::{setup_platform, store_data_contract, store_document};
14+
use crate::test::helpers::fast_forward_to_block::TEST_BLOCK_SIGNATURE;
1415
use dapi_grpc::platform::v0::get_documents_request::get_documents_request_v1::{
1516
select as v1_select, Select as V1Select, Start as V1Start,
1617
};
@@ -4549,7 +4550,7 @@ mod time_range_proof_verification {
45494550
quorum_hash: [0u8; 32],
45504551
block_id_hash: [0u8; 32],
45514552
proposer_pro_tx_hash: [0u8; 32],
4552-
signature: [0u8; 96],
4553+
signature: TEST_BLOCK_SIGNATURE,
45534554
round: 0,
45544555
}
45554556
.into(),

0 commit comments

Comments
 (0)