Skip to content

Fix/1179 1180 1181 1182 router registry optimization - #1228

Merged
Maki-Zeninn merged 4 commits into
Maki-Zeninn:mainfrom
OZILSOLAR:fix/1179-1180-1181-1182-router-registry-optimization
Aug 30, 2026
Merged

Fix/1179 1180 1181 1182 router registry optimization#1228
Maki-Zeninn merged 4 commits into
Maki-Zeninn:mainfrom
OZILSOLAR:fix/1179-1180-1181-1182-router-registry-optimization

Conversation

@OZILSOLAR

Copy link
Copy Markdown
Contributor

Summary

This pull request addresses four interconnected GitHub issues related to router-registry performance optimization and integration test signature
updates. All changes maintain backward compatibility while improving performance and test coverage.

Changes Implemented

1. Issue #1179 - Registry Performance Optimization

Problem: The register_entry function in router-registry was performing an O(n) linear scan on every contract registration by calling
Vec::contains() to check if a name already exists in the ContractNames storage.

Solution: Replace the expensive vector scan with an is_empty() check on the versions list, which is already being fetched and processed. This
optimization:

  • Reduces registration operation from O(n) to O(1)
  • Eliminates redundant lookups when processing the same data
  • Improves performance as the number of registered contract names grows

Files Changed:

  • contracts/router-registry/src/lib.rs: Modified register_entry() method (lines 740-760)

2. Issue #1180 - Test Coverage for bulk_register

Problem: The bulk_register function implemented admin authorization checks but lacked dedicated test coverage for unauthorized caller rejection.
This created a security risk: accidental removal of the authorization gate could go undetected.

Solution: Add test_bulk_register_unauthorized_caller_fails() test that:

  • Attempts to call bulk_register with an unauthorized address
  • Verifies the call fails with Unauthorized error
  • Confirms no registry modifications occur on failed authorization

Files Changed:

  • contracts/router-registry/src/lib.rs: Added test at line 1389-1406

3. Issue #1181 - RouterCore::initialize() Signature Update

Problem: Integration test files contained stale RouterCore::initialize() calls that were missing the newly-added max_routes: Option<u32>
parameter, causing compilation failures.

Solution: Update all RouterCoreClient::initialize() invocations to include the max_routes parameter set to None, consistent with the
router-core test suite's implementation.

Files Changed:

  • integration-tests/tests/cross_contract_tests.rs: 1 call updated (line 51)
  • integration-tests/tests/failure_scenarios.rs: 6 calls updated (lines 36, 47, 64, 81, 98, 113)
  • integration-tests/tests/quote_execution_multicall_pipeline.rs: 1 call updated (line 98)

Total Call Sites: 8 locations across 3 test files


4. Issue #1182 - RouterMiddleware::configure_route() Signature Update

Problem: Integration test files contained stale RouterMiddleware::configure_route() calls missing the newly-added burst_allowance: u32
parameter, causing compilation failures.

Solution: Update all RouterMiddlewareClient::configure_route() invocations to include the burst_allowance parameter set to 0.

Files Changed:

  • integration-tests/tests/cross_contract_tests.rs: 6 calls updated (lines 163, 178, 194, 222, 248, 276)
  • integration-tests/tests/quote_execution_multicall_pipeline.rs: 2 calls updated (lines 137, 508)
  • integration-tests/tests/failure_scenarios.rs: 4 calls updated (lines 258, 276, 308, 328)

Total Call Sites: 12 locations across 3 test files


Impact Analysis

Performance

Test Coverage

Compilation

Backward Compatibility

  • No breaking changes to public APIs
  • All contract functionality preserved
  • Test additions are non-breaking

Testing

All changes have been tested:

Commits

This PR contains 4 sequential commits:

  1. 2eccfe9 - fix(1179): optimize register_entry O(n) linear scan with is_empty() check
  2. 70a98f7 - test(1180): add unauthorized-caller test coverage for bulk_register
  3. 4d98910 - fix(1181): update RouterCore::initialize() calls with missing max_routes parameter
  4. 7f2091e - fix(1182): update RouterMiddleware::configure_route() calls with missing burst_allowance parameter

Closes #1179
Closes #1180
Closes #1181
Closes #1182


…heck

Replace the expensive Vec::contains scan on ContractNames with an is_empty()
check on the versions list that is already being fetched and processed.

Only add the name to ContractNames if this is a new registration (empty
versions list before adding the version).
Add test_bulk_register_unauthorized_caller_fails to verify that
unauthorized callers are properly rejected when attempting to call
bulk_register. This test also ensures that no registry modifications
occur when authorization fails.
…tes parameter

Update all RouterCore::initialize() calls in integration tests to include
the max_routes: Option<u32> parameter. Pass None for all cases.

Affected files:
- cross_contract_tests.rs (1 call)
- failure_scenarios.rs (6 calls)
- quote_execution_multicall_pipeline.rs (1 call)
…ing burst_allowance parameter

Update all RouterMiddleware::configure_route() calls in integration tests to include
the burst_allowance: u32 parameter. Pass 0 for all cases.

Affected files:
- cross_contract_tests.rs (6 call sites)
- quote_execution_multicall_pipeline.rs (2 call sites)
- failure_scenarios.rs (4 call sites)
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@OZILSOLAR 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

@Maki-Zeninn
Maki-Zeninn merged commit 2ab948b into Maki-Zeninn:main Aug 30, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment