Skip to content

Conversation

@RonTuretzky
Copy link

Summary

This PR addresses issue #2 by adding comprehensive gas usage tests for the updateState function in RegistryCoordinatorMimic. The tests reveal that the function exceeds Ethereum block gas limits with realistic operator counts.

Changes

  • Added RegistryCoordinatorMimicGas.t.sol with comprehensive gas testing suite
  • Created detailed gas analysis report documenting findings
  • Tested various scenarios with different operator counts and history lengths

Key Findings

🔴 Critical Issue Identified

The updateState function exceeds block gas limits with just 50+ operators:

Operators Gas Used % of Block Limit
10 6.4M 21% ✅
50 29.6M 98% ⚠️
100 59.5M 198%
200 121.6M 405%
500 324.7M 1082%

Gas Breakdown (100 operators, 50 history entries)

  • Stake History updates: 46.6% of gas
  • Bitmap History updates: 46.8% of gas
  • APK Updates: 0.5% of gas

Recommendations

  1. Implement incremental updates - Don't pass entire history each time
  2. Batch processing - Split updates across multiple transactions
  3. State compression - Store only deltas or use merkle trees
  4. Optimize storage patterns - Review assembly usage and packing

Test Plan

  • Run gas tests with varying operator counts
  • Run gas tests with varying history lengths
  • Analyze component-wise gas consumption
  • Document findings and recommendations

To reproduce tests:

forge test --match-path test/RegistryCoordinatorMimicGas.t.sol -vv

Impact

This analysis confirms that the current implementation is not suitable for production with realistic AVS operator sets. The findings should inform the design of an incremental update mechanism as suggested in the issue description.

Closes #2

🤖 Generated with Claude Code

- Created comprehensive gas tests to measure updateState gas consumption
- Tested with varying operator counts (10-2000) and history lengths (10-1000)
- Added component breakdown analysis to identify gas bottlenecks
- Generated detailed report with findings and recommendations

Key findings:
- Function exceeds block gas limit with >50 operators
- Gas usage grows linearly with operator count and history length
- Stake and bitmap history updates consume ~93% of gas

Recommendations include implementing incremental updates and batch processing.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <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.

Check that updateState function won't pass gas block limit

1 participant