Skip to content

perf(drive): do not call process proposal after prepare#656

Merged
shumkov merged 5 commits into
v0.24-devfrom
skip_process-proposal
Dec 7, 2022
Merged

perf(drive): do not call process proposal after prepare#656
shumkov merged 5 commits into
v0.24-devfrom
skip_process-proposal

Conversation

@shuplenkov
Copy link
Copy Markdown

Issue being fixed or feature implemented

Don't need to process transactions twice in case process proposal called after prepare proposal on the same node

What was done?

Skip process proposal if prepare proposal is already called

How Has This Been Tested?

With tests

Breaking Changes

No

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@shuplenkov shuplenkov added this to the v0.24.0 milestone Dec 6, 2022
# Conflicts:
#	packages/js-drive/test/unit/abci/handlers/prepareProposalHandlerFactory.spec.js
@shumkov shumkov changed the title feat(drive): skip process proposal if prepare proposal is already called pref(drive): do not call process proposal after prepare Dec 6, 2022
@shumkov shumkov changed the title pref(drive): do not call process proposal after prepare peff(drive): do not call process proposal after prepare Dec 6, 2022
@shumkov shumkov changed the title peff(drive): do not call process proposal after prepare perf(drive): do not call process proposal after prepare Dec 6, 2022
Konstantin Shuplenkov added 2 commits December 6, 2022 20:53
shumkov
shumkov previously approved these changes Dec 7, 2022
Copy link
Copy Markdown
Collaborator

@shumkov shumkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Copy Markdown
Collaborator

@shumkov shumkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@shumkov shumkov merged commit 6eef0eb into v0.24-dev Dec 7, 2022
@shumkov shumkov deleted the skip_process-proposal branch December 7, 2022 15:00
QuantumExplorer added a commit that referenced this pull request May 9, 2026
…ange)

Brings in dashpay/grovedb#654 (Element::NonCounted wrapper) and #656
(QueryItem::AggregateCountOnRange + Node::HashWithCount). Both are
prerequisites for the `range_countable` index property that the
parallel design work in `book/src/drive/indexes.md` depends on:

- `Element::NonCounted(Box<Element>)` — wrapper variant whose count
  contributes 0 to a parent count tree's aggregate. Lets a count tree
  hold housekeeping rows / sibling sub-property continuations without
  polluting the count. Only insertable into count-bearing trees;
  nested wrappers rejected at construction / serialize / deserialize.
- `QueryItem::AggregateCountOnRange(Box<QueryItem>)` — count-only proof
  shape returning `(CryptoHash, u64)` in O(log n) bytes. Backed by a
  new self-verifying `Node::HashWithCount(kv_hash, l, r, count)` proof
  node so the count is bound by the proof, not trusted on faith.
  Restricted to `ProvableCountTree` / `ProvableCountSumTree` (and
  their `NonCounted*` wrappers) at proof time. Verified via
  `GroveDb::verify_aggregate_count_query`.

Together these unblock implementing `range_countable` indexes (per-
node counts on the property-name tree, NonCounted wrappers for
sibling continuations) and `return_distinct_counts_in_range` /
range count queries on the no-prove and prove paths — both currently
gated as "not yet supported" in the unified count handler.

Workspace fixups required by the bump:

- `wasm-drive-verify` JS shim: add a `QueryItem::AggregateCountOnRange`
  arm in `serialize_query_item` (descriptive type, no recursion into
  the inner range — the wasm verify path doesn't drive these queries
  today, but the variant must be matched for the workspace to compile).
- `rs-sdk-ffi` path-elements display: add `Element::NonCounted(_)` arm
  reporting `"non_counted"` (placeholder display; we'll inflate it
  to describe the inner element when the wrapper is actually used in
  contracts).
- `rs-drive-abci` shielded common: orchard's transitive bump made
  `Action::from_parts` return `Option<Action>`. Wrap with `.ok_or_else`
  surfacing `InvalidShieldedProofError("invalid action parts")` rather
  than panicking; otherwise behaviorally unchanged.

Tests: 14 rs-drive count-query lib tests, 5 drive-abci handler tests,
3079 rs-drive lib tests, and 3435 dpp lib tests all still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
QuantumExplorer added a commit that referenced this pull request May 10, 2026
…ing)

Per-index `rangeCountable: bool` flag, additive on top of `countable`.
When true, the index is laid out so that range-count queries on the
indexed property can be answered in O(log n):

- Property-name level: `ProvableCountTree` (per-node counts let a range
  query walk just the boundary path).
- Each value tree under it: `CountTree` (count-bearing so the
  property-name aggregate sums per-value counts cleanly).
- Sibling continuations inside a value tree: wrapped with
  `Element::NonCounted` so their counts don't pollute the value
  tree's count.

Depends on the grovedb features bumped in the previous commit
(`Element::NonCounted` + `QueryItem::AggregateCountOnRange` from
dashpay/grovedb#654 + #656).

This commit lands the schema-level plumbing only:

- `Index.range_countable: bool` field + serde derive.
- Index parser reads `"rangeCountable"` (boolean only — no enum form
  needed).
- Cross-field validation in `Index::try_from`: `range_countable: true`
  requires `countable.is_countable()`. Without that, it would change
  layout of a non-count-bearing tree, which is meaningless.
- v1 meta-schema schema entry under each index in `documentSchemas`.
- Protocol-version gate in `try_from_schema/v1`: `range_countable: true`
  on protocol_version < 12 raises `UnsupportedFeatureError`. Pre-v12
  nodes therefore reject the contract at validation time, before any
  state mutation. Mirrors the existing v12 gate on countable indexes.
- `IndexLevelTypeInfo.range_countable` populated from the source index
  so the insert/delete walkers can reach it (used in a follow-up).
- `random_index` default + ~16 IndexLevel test-init sites updated.

Storage layout change (the actual `NonCounted` wrapping +
`ProvableCountTree`/`CountTree` selection in the insert / delete
walkers) is **deferred to a follow-up commit**. Until that lands,
`IndexLevelTypeInfo.range_countable` is read but not yet acted on —
the on-disk layout is unchanged, so the schema gate is the only gate
in effect right now. Combined with the v12 protocol gate, no v11 node
ever sees a `range_countable` contract, and no v12 node yet emits
NonCounted-wrapped writes.

Tests: 79 dpp index tests, 14 rs-drive count-query lib tests, 5
drive-abci handler tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
QuantumExplorer added a commit that referenced this pull request May 10, 2026
The v12 protocol transition was still parenting the main shielded credit
pool under AddressBalances and creating only 4 of the 8 inner subtrees,
which would diverge from a fresh genesis-12 chain (created by v3 init) on
any node that actually migrated from v11. Rewrite it to mirror v3 init:

- Insert RootTree::ShieldedBalances as a top-level SumTree.
- Parent the main pool under [ShieldedBalances] / "M".
- Insert all 8 inner subtrees in BFS order: notes, nullifiers,
  anchors_in_pool, total_balance, anchors_by_height, recent_nullifiers
  (wrapped in NotSummed), compacted_nullifiers, expiration_time.
- Update the two post-condition assertions in the in-file tests.

Also fix CI: the grovedb bump (PR #659/#656) added a new
QueryItem::AggregateCountOnRange variant. wasm-drive-verify wasn't in my
local check set and had a non-exhaustive match in
token_transition.rs that broke the macOS workspace build. Reject the
variant with a clear error message.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants