feat: optimize bulk account cloning with collect-then-push strategy - #183
Merged
Conversation
Implements 4-phase collect-then-push strategy to reduce cloning ~650 accounts from ~1 hour to ~2-5 minutes by eliminating O(n²) ESDT module fetches, reducing Elasticsearch inserts from O(n) to O(1), and smart-batching set_state calls by payload size. Changes: - AccountBatchCloneStep: new step accepting list of addresses with cache-aware rate limiting, single ESDT reconciliation, and payload-aware batching - Extracted 8 reusable functions from AccountCloneStep: _fetch_account_clone_data, _fetch_source_storage, _get_storage_clone_data, _find_missing_esdt_identifiers, _fetch_missing_esdt_entries, _get_esdt_module_clone_data, _fetch_with_backoff, _insert_tokens_in_elasticsearch - set_states_batched: groups accounts by estimated payload size (target ~2MB per call) with retry resilience - _set_state_with_retry: exponential backoff wrapper (3 retries at 1s/2s/4s) - _estimate_account_bytes: payload estimation including metadata fields - Chain simulator config: API_RATE_LIMIT=100 (from 2), STORAGE_ITERATION_BATCH_SIZE=5000 (from 1000)
Updates: - docs/source/user_documentation/steps.md: Add full AccountBatchCloneStep section with YAML example, feature bullets, and 4-phase execution description - docs/source/dev_documentation/changelog.md: Added AccountBatchCloneStep, set_states_batched, _set_state_with_retry to Unreleased Added section; added Changed section for config updates and extracted functions - CLAUDE.md: Updated step count from 28 to 29, added AccountBatchClone to Setup list
Changes: - .gitignore: Changed bare 'temp' to '/temp/' to only ignore top-level temp directory - docs/dictionary/custom_wordlist.txt: Added 'AccountBatchCloneStep' to spell check dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces
AccountBatchCloneStepto optimize cloning multiple accounts in a single operation. This reduces cloning ~650 Ashswap/X-Exchange pools from ~1 hour to an estimated ~2-5 minutes by eliminating redundant operations and smart-batching HTTP calls.Changes
Core Implementation:
AccountBatchCloneStep: New step accepting a list of addresses with 4-phase collect-then-push strategyset_states_batched(): Groups multiple accounts by estimated payload size (~2MB target per call) with automatic batching and retry resilience_set_state_with_retry(): Exponential backoff wrapper (3 retries at 1s/2s/4s) for transient failures_estimate_account_bytes(): Estimates account payload including metadata fieldsExtracted 8 reusable functions from
AccountCloneStepfor code reuseConfiguration:
API_RATE_LIMIT=100(from 2),STORAGE_ITERATION_BATCH_SIZE=5000(from 1000)Documentation:
AccountBatchCloneStepTesting
AccountCloneStepunchanged (backward compatible)