Skip to content

perf(bridge): replace validator signature vecs with bitmap storage#544

Merged
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
AJ0070:fix/514
Jun 24, 2026
Merged

perf(bridge): replace validator signature vecs with bitmap storage#544
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
AJ0070:fix/514

Conversation

@AJ0070

@AJ0070 AJ0070 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR optimizes bridge validator signature tracking by replacing per-request Vec<AccountId> signer storage with a 256-bit bitmap representation.

Changes

  • Added bitmap-backed signature storage for bridge requests using [u8; 32]
  • Added stable validator bit-position tracking so historical request bitmaps remain readable
  • Added get_signature_bitmap(request_id) for raw bitmap queries
  • Added get_signer_list(request_id) for human-readable signer reconstruction
  • Preserved backward compatibility by decoding legacy Vec<AccountId>-based requests
  • Normalized legacy signature storage to bitmap form when legacy requests are mutated
  • Updated bridge signing, execution, retry, and rollback flows to use bitmap helpers
  • Moved bitmap coverage into contracts/bridge/src/tests.rs
  • Fixed existing bridge test wiring so tests.rs is compiled and executed in the bridge crate

Backward Compatibility

Existing bridge requests stored with the legacy signature format remain readable.
New requests are stored using the bitmap representation.

Test Coverage

Added and/or validated tests for:

  • bitmap signature tracking
  • signer list reconstruction from bitmap
  • signature count from bitmap matching monitoring/query results
  • legacy signature format decode compatibility
  • encoded-size benchmark comparison for 24 validator signatures
  • existing bridge request and cross-chain status flows

Benchmark Note

The included test benchmark shows the bitmap encoding is smaller than the legacy Vec<AccountId> encoding for 24 validator signatures, which is the expected storage/gas improvement target for larger validator sets.

fixes #514

@drips-wave

drips-wave Bot commented Jun 23, 2026

Copy link
Copy Markdown

@AJ0070 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@AJ0070

AJ0070 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

@nanaf6203-bit Failures are not related to my changes.

@nanaf6203-bit nanaf6203-bit merged commit a86e748 into MettaChain:main Jun 24, 2026
1 of 14 checks passed
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.

perf: Optimize bridge validator signature storage with bitmap encoding

2 participants