Skip to content

Commit 7972eb6

Browse files
chore: adopt zero-cost grove v4 gates and restore released fee constants
Bumps grovedb to develop b5bd7ef, which makes the v4 cleanup gates derive their inspection from data the merk apply already loads (dashpay/grovedb#790, on top of the estimator parity in #789). The gates keep their semantics — indexed-tree overwrite/delete-tree cleanup — at zero marginal cost, so every fee constant returns to its released value and the protocol v13/v14 test pairs now assert identical fees across the boundary. The ranked-trees book chapter's cost section is rewritten accordingly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c973313 commit 7972eb6

23 files changed

Lines changed: 96 additions & 97 deletions

File tree

Cargo.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

book/src/drive/document-ranked-trees.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ Indexed trees need two batch behaviours that earlier grove versions don't have,
244244

245245
Without them, a batch overwrite of a ranked index would orphan its per-axis secondary storage. Indexed trees only exist from protocol v14, so activating the stricter cleanup alongside them costs older versions nothing.
246246

247-
Both gates cost **one extra stored-element read per overwrite-capable operation** — which is why they could not be applied to released versions, and why v14's fee constants move. The shape of the change is worth internalising because it is easy to misread as a general fee increase:
247+
Both gates are **cost-neutral**: they derive the old element from data the merk apply already loads when it rewrites or deletes a key, so no extra stored-element read is charged and v14's fee constants match v13's. Three facts pin this:
248248

249-
- **Fresh-key inserts pay nothing extra.** There is no stored element to inspect. In the address-funds-transfer fee regression suite the pins for simple single-input/single-output transfers, multisig spends and the user-fee-increase case are all **unchanged**; only the cases that overwrite existing keys move.
250-
- **Gated operations pay one stored-element read each: a seek (2 000 credits) plus 20 credits per byte of the element loaded**so the delta varies with the size of the element at the overwritten key. The identity-balance and token-balance update pins both move by `+4 300` processing credits (`385 160 → 389 460`, `260 540 → 264 840`): one seek plus a 115-byte element. Storage fees are unchanged throughout — the delta is pure read cost.
251-
- **The boundary itself is pinned.** `run_chain_one_identity_in_solitude` sits exactly **2 000 credits** below its new protocol-version-13 sibling, which asserts the pre-grove-v4 figure — the gate cost for that run's single gated operation. The pair brackets the v13 → v14 transition, so a future change that moves either side has to say which one it meant to move.
249+
- **Fees are identical across the boundary.** The identity-balance, token-balance and state-transition processing-fee pins carry the same values at protocol v13 and v14, and `run_chain_one_identity_in_solitude` has a protocol-version-13 sibling asserting the identical end balance — the pair proves the v13 → v14 transition changes nothing about those runs' fees.
250+
- **Storage fees are untouched everywhere** — the gates only observe, never write.
251+
- **Cleanup still happens.** A batch overwrite of an indexed tree schedules its per-axis secondary storage for cleanup (or refuses the ambiguous case), and `DeleteTree` uses the actual stored type — covered by grovedb's own overwrite and delete-tree suites at the pinned revision.
252252

253253
## Interaction With the Shared-Prefix Aggregate Fix
254254

packages/rs-dpp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ strum = { version = "0.26", features = ["derive"] }
7171
json-schema-compatibility-validator = { path = '../rs-json-schema-compatibility-validator', optional = true }
7272
once_cell = "1.19.0"
7373
tracing = { version = "0.1.41" }
74-
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "d473818154dac668676fcb54678287845032d9a7", optional = true }
74+
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "b5bd7efd65a3cc6bbe22ef9ccc098c4396dcf636", optional = true }
7575

7676
[dev-dependencies]
7777
tokio = { version = "1.40", features = ["full"] }

packages/rs-drive-abci/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ derive_more = { version = "1.0", features = ["from", "deref", "deref_mut"] }
8282
async-trait = "0.1.77"
8383
console-subscriber = { version = "0.4", optional = true }
8484
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "0842b17583888e8f46c252a4ee84cdfd58e0546f", optional = true }
85-
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "d473818154dac668676fcb54678287845032d9a7" }
85+
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "b5bd7efd65a3cc6bbe22ef9ccc098c4396dcf636" }
8686
nonempty = "0.11"
8787
# Shielded-pool snapshot needs raw RocksDB SstFileWriter + ingest_external_file_cf
8888
# bindings, and blake3 for the snapshot-file checksum.
@@ -107,7 +107,7 @@ dpp = { path = "../rs-dpp", default-features = false, features = [
107107
drive = { path = "../rs-drive", features = ["fixtures-and-mocks"] }
108108
drive-proof-verifier = { path = "../rs-drive-proof-verifier" }
109109
strategy-tests = { path = "../strategy-tests" }
110-
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "d473818154dac668676fcb54678287845032d9a7", features = ["client"] }
110+
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "b5bd7efd65a3cc6bbe22ef9ccc098c4396dcf636", features = ["client"] }
111111
assert_matches = "1.5.0"
112112
drive-abci = { path = ".", features = ["testing-config", "mocks", "shielded_test_data"] }
113113
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "0842b17583888e8f46c252a4ee84cdfd58e0546f" }
@@ -121,8 +121,8 @@ integer-encoding = { version = "4.0.0" }
121121

122122
# For dump_only_default_and_aux_cfs_under_shielded_subtree_prefix — same
123123
# subtree-prefix algorithm grovedb uses internally.
124-
grovedb-path = { git = "https://github.com/dashpay/grovedb", rev = "d473818154dac668676fcb54678287845032d9a7" }
125-
grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "d473818154dac668676fcb54678287845032d9a7" }
124+
grovedb-path = { git = "https://github.com/dashpay/grovedb", rev = "b5bd7efd65a3cc6bbe22ef9ccc098c4396dcf636" }
125+
grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "b5bd7efd65a3cc6bbe22ef9ccc098c4396dcf636" }
126126

127127
[features]
128128
default = ["bls-signatures"]

packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ mod tests {
644644

645645
assert_eq!(
646646
processing_result.aggregated_fees().processing_fee,
647-
24002492770
647+
24002489210
648648
);
649649

650650
let check_result = platform
@@ -849,7 +849,7 @@ mod tests {
849849
// We have one invalid paid for state transition
850850
assert_eq!(processing_result.invalid_paid_count(), 1);
851851

852-
assert_eq!(processing_result.aggregated_fees().processing_fee, 350220);
852+
assert_eq!(processing_result.aggregated_fees().processing_fee, 346660);
853853

854854
let check_result = platform
855855
.check_tx(
@@ -1159,7 +1159,7 @@ mod tests {
11591159
// Plus we have 24_000_000_000 in base costs
11601160
assert_eq!(
11611161
processing_result.aggregated_fees().processing_fee,
1162-
24004985540
1162+
24004978420
11631163
);
11641164

11651165
let check_result = platform
@@ -1634,7 +1634,7 @@ mod tests {
16341634

16351635
assert_eq!(
16361636
processing_result.aggregated_fees().processing_fee,
1637-
24002492770
1637+
24002489210
16381638
);
16391639

16401640
platform
@@ -1721,7 +1721,7 @@ mod tests {
17211721

17221722
assert_eq!(
17231723
update_processing_result.aggregated_fees().processing_fee,
1724-
27002568170
1724+
27002504030
17251725
);
17261726

17271727
let check_result = platform
@@ -2093,7 +2093,7 @@ mod tests {
20932093

20942094
assert_eq!(
20952095
processing_result.aggregated_fees().processing_fee,
2096-
24002492770
2096+
24002489210
20972097
);
20982098

20992099
platform

packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funds_transfer/tests.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7769,8 +7769,8 @@ mod tests {
77697769

77707770
// Assert exact values - 2 inputs should cost more processing than 1 input
77717771
assert_eq!(
7772-
processing_fee, 593080,
7773-
"Processing fee changed! Was 593080, now {}",
7772+
processing_fee, 589280,
7773+
"Processing fee changed! Was 589280, now {}",
77747774
processing_fee
77757775
);
77767776
assert_eq!(
@@ -7779,8 +7779,8 @@ mod tests {
77797779
storage_fee
77807780
);
77817781
assert_eq!(
7782-
total_fee, 6668080,
7783-
"Total fee changed! Was 6668080, now {}",
7782+
total_fee, 6664280,
7783+
"Total fee changed! Was 6664280, now {}",
77847784
total_fee
77857785
);
77867786
}
@@ -8239,8 +8239,8 @@ mod tests {
82398239

82408240
// Assert exact values
82418241
assert_eq!(
8242-
processing_fee, 3035320,
8243-
"Processing fee changed! Was 3035320, now {}",
8242+
processing_fee, 2959680,
8243+
"Processing fee changed! Was 2959680, now {}",
82448244
processing_fee
82458245
);
82468246
assert_eq!(
@@ -8249,8 +8249,8 @@ mod tests {
82498249
storage_fee
82508250
);
82518251
assert_eq!(
8252-
total_fee, 9110320,
8253-
"Total fee changed! Was 9110320, now {}",
8252+
total_fee, 9034680,
8253+
"Total fee changed! Was 9034680, now {}",
82548254
total_fee
82558255
);
82568256
}
@@ -8394,8 +8394,8 @@ mod tests {
83948394

83958395
// Assert exact values for existing address (much cheaper - only updates balance)
83968396
assert_eq!(
8397-
total_fee_existing, 451180,
8398-
"Total fee to existing address changed! Was 451180, now {}",
8397+
total_fee_existing, 447400,
8398+
"Total fee to existing address changed! Was 447400, now {}",
83998399
total_fee_existing
84008400
);
84018401
}

packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/deletion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod deletion_tests {
1010
async fn test_document_delete_on_document_type_that_is_mutable_and_can_be_deleted() {
1111
run_document_delete_on_document_type_that_is_mutable_and_can_be_deleted_at_protocol_version(
1212
PlatformVersion::latest().protocol_version,
13-
1699540,
13+
1678920,
1414
)
1515
.await;
1616
}
@@ -370,7 +370,7 @@ mod deletion_tests {
370370
async fn test_document_delete_on_document_type_that_is_not_mutable_and_can_be_deleted() {
371371
run_document_delete_on_document_type_that_is_not_mutable_and_can_be_deleted_at_protocol_version(
372372
PlatformVersion::latest().protocol_version,
373-
2838880,
373+
2778700,
374374
)
375375
.await;
376376
}

packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/dpns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod dpns_tests {
2323
async fn test_dpns_contract_references_with_no_contested_unique_index() {
2424
run_dpns_contract_references_with_no_contested_unique_index_at_protocol_version(
2525
PlatformVersion::latest().protocol_version,
26-
6_014_380,
26+
6_010_380,
2727
)
2828
.await;
2929
}

packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/nft.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ mod nft_tests {
408408
PlatformVersion::latest().protocol_version,
409409
126440160,
410410
2485600,
411-
4126900,
411+
4092360,
412412
)
413413
.await;
414414
}
@@ -829,7 +829,7 @@ mod nft_tests {
829829
141238960,
830830
2729120,
831831
2733160,
832-
4397020,
832+
4357440,
833833
)
834834
.await;
835835
}
@@ -1407,7 +1407,7 @@ mod nft_tests {
14071407
PlatformVersion::latest().protocol_version,
14081408
126440160,
14091409
2485600,
1410-
4126900,
1410+
4092360,
14111411
)
14121412
.await;
14131413
}

packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/transfer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ mod transfer_tests {
213213
async fn test_document_transfer_on_document_type_that_is_transferable_before_creator_id() {
214214
run_document_transfer_on_document_type_that_is_transferable_before_creator_id_at_protocol_version(
215215
PlatformVersion::latest().protocol_version,
216-
3403080,
216+
3380960,
217217
)
218218
.await;
219219
}
@@ -496,7 +496,7 @@ mod transfer_tests {
496496
async fn test_document_transfer_on_document_type_that_is_transferable() {
497497
run_document_transfer_on_document_type_that_is_transferable_at_protocol_version(
498498
PlatformVersion::latest().protocol_version,
499-
3665520,
499+
3643400,
500500
)
501501
.await;
502502
}
@@ -779,7 +779,7 @@ mod transfer_tests {
779779
async fn test_document_transfer_on_document_type_that_is_transferable_contract_v0() {
780780
run_document_transfer_on_document_type_that_is_transferable_contract_v0_at_protocol_version(
781781
PlatformVersion::latest().protocol_version,
782-
3403080,
782+
3380960,
783783
)
784784
.await;
785785
}
@@ -1467,7 +1467,7 @@ mod transfer_tests {
14671467
async fn test_document_delete_after_transfer() {
14681468
run_document_delete_after_transfer_at_protocol_version(
14691469
PlatformVersion::latest().protocol_version,
1470-
4035120,
1470+
4004260,
14711471
)
14721472
.await;
14731473
}

0 commit comments

Comments
 (0)