Skip to content

Shared data structures and algorithms crate#19388

Merged
vineethk merged 3 commits intomainfrom
vk/shared-dsa
Apr 14, 2026
Merged

Shared data structures and algorithms crate#19388
vineethk merged 3 commits intomainfrom
vk/shared-dsa

Conversation

@vineethk
Copy link
Copy Markdown
Contributor

@vineethk vineethk commented Apr 10, 2026

Description

We implement and expose a fast, non-cryptographic, non-hash-DoS-resistant hashmap and hashset, without exposing the arbitrary iteration over keys/key-value pairs. This is what we want in a number of places in our codebase, but we end up using the slower default hashmap, which is non-deterministic, or various other hashmap implementations.

Currently, this implementation wraps rustc_hash's FxHash[Map|Set] , used by the rust compiler.

How Has This Been Tested?

  • added some simple tests

Type of Change

  • New feature

Note

Medium Risk
Introduces new collection types backed by non-DoS-resistant hashing; if adopted in code paths that accept untrusted keys, it could create performance-attack risk despite being unused in this PR.

Overview
Adds a new workspace crate, third_party/move/shared-dsa, exposing UnorderedMap and UnorderedSet wrappers around rustc_hash’s FxHashMap/FxHashSet while intentionally not exposing iteration APIs to avoid reliance on non-deterministic ordering.

Wires the crate into the workspace (Cargo.toml) and lockfile, adds a workspace dependency on rustc-hash, and includes unit tests covering basic map/set operations and trait behavior.

Reviewed by Cursor Bugbot for commit 13019da. Bugbot is set up for automated code reviews on this repo. Configure here.

@vineethk vineethk changed the title Implement a crate containing shared data structures and algorithms for use in other crates. Shared data structures and algorithms crate Apr 10, 2026
@vineethk vineethk requested a review from Copilot April 10, 2026 01:28
@vineethk vineethk marked this pull request as ready for review April 10, 2026 01:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new shared-dsa crate to the Move workspace that provides fast, non-cryptographic hash-based collections (UnorderedMap / UnorderedSet) intended to discourage reliance on nondeterministic iteration order.

Changes:

  • Introduces UnorderedMap and UnorderedSet wrappers around rustc_hash::FxHashMap/FxHashSet, exposing common map/set operations while avoiding iteration APIs.
  • Adds basic unit tests for the new collections.
  • Registers the new crate in the workspace and adds the rustc-hash workspace dependency.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
third_party/move/shared-dsa/src/unordered_set.rs New UnorderedSet wrapper and tests
third_party/move/shared-dsa/src/unordered_map.rs New UnorderedMap wrapper (incl. entry) and tests
third_party/move/shared-dsa/src/lib.rs Crate module wiring + public re-exports
third_party/move/shared-dsa/Cargo.toml New crate manifest
Cargo.toml Adds crate to workspace + adds rustc-hash workspace dependency
Cargo.lock Locks new shared-dsa crate dependency graph

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread third_party/move/shared-dsa/src/unordered_set.rs
Comment thread third_party/move/shared-dsa/src/unordered_map.rs
@vineethk vineethk enabled auto-merge (squash) April 13, 2026 15:42
Copy link
Copy Markdown
Contributor

@calintat calintat left a comment

Choose a reason for hiding this comment

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

Nice!

Comment thread third_party/move/shared-dsa/src/unordered_map.rs
Comment thread third_party/move/shared-dsa/src/unordered_map.rs Outdated
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

✅ Forge suite realistic_env_max_load success on 13019daf01024ad4491ecc300413b5b1193aa032

two traffics test: inner traffic : committed: 14392.02 txn/s, latency: 1251.10 ms, (p50: 1200 ms, p70: 1300, p90: 1500 ms, p99: 1900 ms), latency samples: 5367820
two traffics test : committed: 100.00 txn/s, latency: 657.27 ms, (p50: 600 ms, p70: 700, p90: 800 ms, p99: 1200 ms), latency samples: 1700
Latency breakdown for phase 0: ["MempoolToBlockCreation: max: 0.519, avg: 0.456", "ConsensusProposalToOrdered: max: 0.116, avg: 0.110", "ConsensusOrderedToCommit: max: 0.191, avg: 0.183", "ConsensusProposalToCommit: max: 0.306, avg: 0.293"]
Max non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.95s no progress at version 11242 (avg 0.06s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.31s no progress at version 2599347 (avg 0.31s) [limit 16].
Test Ok

@github-actions
Copy link
Copy Markdown
Contributor

✅ Forge suite compat success on 1ccf655f27971b762e4c90fc1606e3a8ba4ed7fb ==> 13019daf01024ad4491ecc300413b5b1193aa032

Compatibility test results for 1ccf655f27971b762e4c90fc1606e3a8ba4ed7fb ==> 13019daf01024ad4491ecc300413b5b1193aa032 (PR)
1. Check liveness of validators at old version: 1ccf655f27971b762e4c90fc1606e3a8ba4ed7fb
compatibility::simple-validator-upgrade::liveness-check : committed: 13255.93 txn/s, latency: 2617.48 ms, (p50: 2700 ms, p70: 2900, p90: 3300 ms, p99: 3700 ms), latency samples: 434760
2. Upgrading first Validator to new version: 13019daf01024ad4491ecc300413b5b1193aa032
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 6234.69 txn/s, latency: 5413.94 ms, (p50: 5900 ms, p70: 6000, p90: 6100 ms, p99: 6300 ms), latency samples: 218940
3. Upgrading rest of first batch to new version: 13019daf01024ad4491ecc300413b5b1193aa032
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 6331.90 txn/s, latency: 5373.17 ms, (p50: 5900 ms, p70: 5900, p90: 6200 ms, p99: 6300 ms), latency samples: 220440
4. upgrading second batch to new version: 13019daf01024ad4491ecc300413b5b1193aa032
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 10576.48 txn/s, latency: 3099.74 ms, (p50: 2900 ms, p70: 3800, p90: 4300 ms, p99: 4600 ms), latency samples: 351440
5. check swarm health
Compatibility test for 1ccf655f27971b762e4c90fc1606e3a8ba4ed7fb ==> 13019daf01024ad4491ecc300413b5b1193aa032 passed
Test Ok

@github-actions
Copy link
Copy Markdown
Contributor

✅ Forge suite framework_upgrade success on 1ccf655f27971b762e4c90fc1606e3a8ba4ed7fb ==> 13019daf01024ad4491ecc300413b5b1193aa032

Compatibility test results for 1ccf655f27971b762e4c90fc1606e3a8ba4ed7fb ==> 13019daf01024ad4491ecc300413b5b1193aa032 (PR)
Upgrade the nodes to version: 13019daf01024ad4491ecc300413b5b1193aa032
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 2434.67 txn/s, submitted: 2442.76 txn/s, failed submission: 8.10 txn/s, expired: 8.10 txn/s, latency: 1192.68 ms, (p50: 1200 ms, p70: 1200, p90: 1500 ms, p99: 2100 ms), latency samples: 222520
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 2255.88 txn/s, submitted: 2263.80 txn/s, failed submission: 7.92 txn/s, expired: 7.92 txn/s, latency: 1278.26 ms, (p50: 1200 ms, p70: 1200, p90: 1800 ms, p99: 2700 ms), latency samples: 205200
5. check swarm health
Compatibility test for 1ccf655f27971b762e4c90fc1606e3a8ba4ed7fb ==> 13019daf01024ad4491ecc300413b5b1193aa032 passed
Upgrade the remaining nodes to version: 13019daf01024ad4491ecc300413b5b1193aa032
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 2042.32 txn/s, submitted: 2050.71 txn/s, failed submission: 8.39 txn/s, expired: 8.39 txn/s, latency: 1565.29 ms, (p50: 1200 ms, p70: 1200, p90: 2100 ms, p99: 11100 ms), latency samples: 170360
Test Ok

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.

4 participants