- 
                Notifications
    
You must be signed in to change notification settings  - Fork 12
 
feat: remove unused keys from redis #609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @mateuszaaa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request implements a strategy for removing stale data from Redis. It modifies the pool rates and price processing services to track the latest processed timestamps and introduces a function to remove keys older than a certain threshold. This process is integrated into the block synchronization service to ensure regular cleanup.
Highlights
- Redis Key Management: Introduces a mechanism to remove unused keys from Redis, improving performance and reducing storage costs.
 - Asynchronous Processing: Modifies 
PoolRatesProcessorServiceandPriceProcessorServiceto return the latest processed timestamps, enabling the removal of old data. - Integration with Block Sync: Integrates the key removal process into the 
SyncBlockServiceto run after each block is processed. 
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description | 
|---|---|---|
| Code Review | /gemini review | 
Performs a code review for the current pull request in its current state. | 
| Pull Request Summary | /gemini summary | 
Provides a summary of the current pull request in its current state. | 
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. | 
| Help | /gemini help | 
Displays a list of available commands. | 
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
- 
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors data processing for pool rates and prices to occur per block within SyncBlockService. It introduces a mechanism to remove older, "unused" data from Redis sorted sets based on the latest processing timestamps. Key changes include modifying PoolRatesProcessorService and PriceProcessorService to return processed timestamps and adding removeUnusedKeys in ChainRepository. The review focuses on improving maintainability by addressing magic numbers and enhancing the clarity of the timestamp merging logic.
| }) | ||
| // | ||
| let processedByPoolRates = await poolRatesService.processRates(); | ||
| let processedByPriceService = await priceService.processPrices(1); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base argument 1 passed to priceService.processPrices(1) is a magic number. It likely refers to the BASE_TOKEN. It's recommended to use the named constant BASE_TOKEN for clarity and maintainability.
| let processedByPriceService = await priceService.processPrices(1); | |
| let processedByPriceService = await priceService.processPrices(1); // TODO: Use BASE_TOKEN constant | 
          
Run report for c8520c50 
 | 
    
| Action | Time | Status | Info | |
|---|---|---|---|---|
| 🟩 | SyncWorkspace | 
54.4ms | Passed | |
| 🟩 | SetupToolchain(node:22.14.0) | 
6s | Passed | |
| 🟩 | SyncProject(node, stash) | 
0.5ms | Passed | |
| 🟩 | InstallProjectDeps(node:22.14.0, stash) | 
31.9s | Passed | |
| 🟩 | RunTask(stash:lint) | 
201.7ms | Passed | |
| 🟩 | RunTask(stash:format) | 
263.3ms | Passed | |
| 🟩 | RunTask(stash:test) | 
53.1s | Passed | 
Environment
OS: Linux
Matrix:
prefix = format-lint-test
name = Format, lint and test
runner = beast-gke
buildkit-enable = false
buildkit-replicas = 1
command = moon ci :format :lint :test :benchmark-tests-gasp-node
Variables:
MOON_COLOR = 2
MOON_DEBUG_PROTO_INSTALL = false
MOON_CACHE = read-write
MOON_VERSION = 1.34.0
Touched files
stash/package.json
stash/src/processing/PoolRatesProcessorService.ts
stash/src/processing/PriceProcessorService.ts
stash/src/repository/ChainRepository.ts
stash/src/scraper/BlockScraper.ts
stash/src/scraper/L1LogScraper.ts
stash/src/scraper/PoolsScraper.ts
stash/src/scraper/SwapScraper.ts
stash/src/scraper/WithdrawalScraper.ts
stash/src/server.ts
stash/src/service/SyncBlockService.ts
stash/src/service/TokenPriceService.ts
stash/src/util/Logger.ts
stash/test/l1.scraper.test.ts
stash/test/swapScraper.test.ts
stash/yarn.lock
          
Run report for c8520c50 
 | 
    
| Action | Time | Status | Info | |
|---|---|---|---|---|
| 🟩 | SyncWorkspace | 
214.8ms | Passed | |
| 🟩 | SetupToolchain(node:18.20.7) | 
4.6s | Passed | |
| ⬛️ | SetupToolchain(system) | 
4.6s | Skipped | |
| 🟩 | SyncProject(node, ferry-withdrawal) | 
1ms | Passed | |
| 🟩 | SyncProject(system, updater) | 
1.3ms | Passed | |
| 🟩 | SyncProject(node, ferry-deposit) | 
1.4ms | Passed | |
| 🟩 | SyncProject(system, avs-aggregator) | 
0.9ms | Passed | |
| 🟩 | SyncProject(system, gasp-avs) | 
1.9ms | Passed | |
| 🟩 | SyncProject(system, sequencer) | 
0.9ms | Passed | |
| 🟩 | SyncProject(system, contracts) | 
2.7ms | Passed | |
| 🟩 | SyncProject(system, gasp-node) | 
6.4ms | Passed | |
| 🟦 | RunTask(ferry-withdrawal:buildkit-build-and-push-image-digests) | 
594.1ms | Cached | |
| 🟦 | RunTask(ferry-deposit:buildkit-build-and-push-image-digests) | 
588.1ms | Cached | |
| 🟦 | RunTask(updater:buildkit-build-and-push-image-digests) | 
685.4ms | Cached | |
| 🟦 | RunTask(avs-aggregator:buildkit-build-and-push-image-digests) | 
311.8ms | Cached | |
| 🟦 | RunTask(gasp-avs:buildkit-build-and-push-image-digests) | 
311.8ms | Cached | |
| 🟦 | RunTask(sequencer:buildkit-build-and-push-image-digests) | 
220.1ms | Cached | |
| 🟦 | RunTask(contracts:buildkit-build-and-push-image-digests) | 
218.1ms | Cached | |
| 🟦 | RunTask(gasp-node:buildkit-build-and-push-image-digests-fast-runtime) | 
335.8ms | Cached | |
| 🟦 | RunTask(gasp-node:buildkit-build-and-push-image-digests-standard-runtime) | 
335.8ms | Cached | |
| And 12 more... | 
Expanded report
| Action | Time | Status | Info | |
|---|---|---|---|---|
| 🟩 | SetupToolchain(node:22.14.0) | 
7.8s | Passed | |
| 🟩 | RunTask(updater:build-image-ci) | 
7s | Passed | |
| 🟩 | RunTask(ferry-withdrawal:build-image-ci) | 
7.5s | Passed | |
| 🟩 | RunTask(ferry-deposit:build-image-ci) | 
7.5s | Passed | |
| 🟩 | RunTask(sequencer:build-image-ci) | 
7.9s | Passed | |
| 🟩 | RunTask(contracts:build-image-ci) | 
5.8s | Passed | |
| 🟩 | SyncProject(node, stash) | 
0.8ms | Passed | |
| 🟩 | RunTask(avs-aggregator:build-image-ci) | 
6.7s | Passed | |
| 🟩 | RunTask(gasp-avs:build-image-ci) | 
7.3s | Passed | |
| 🟩 | RunTask(gasp-node:build-image-ci) | 
13.5s | Passed | |
| 🟩 | RunTask(stash:buildkit-build-and-push-image-digests) | 
1m 41s | Passed | |
| 🟩 | RunTask(stash:build-image-ci) | 
12.2s | Passed | 
Environment
OS: Linux
Matrix:
prefix = build-docker-images
name = Build docker images
runner = ubuntu-24.04
buildkit-enable = true
buildkit-replicas = 5
command = moon :build-image-ci
Variables:
MOON_COLOR = 2
MOON_DEBUG_PROTO_INSTALL = false
MOON_CACHE = read-write
MOON_VERSION = 1.34.0
Touched files
stash/package.json
stash/src/processing/PoolRatesProcessorService.ts
stash/src/processing/PriceProcessorService.ts
stash/src/repository/ChainRepository.ts
stash/src/scraper/BlockScraper.ts
stash/src/scraper/L1LogScraper.ts
stash/src/scraper/PoolsScraper.ts
stash/src/scraper/SwapScraper.ts
stash/src/scraper/WithdrawalScraper.ts
stash/src/server.ts
stash/src/service/SyncBlockService.ts
stash/src/service/TokenPriceService.ts
stash/src/util/Logger.ts
stash/test/l1.scraper.test.ts
stash/test/swapScraper.test.ts
stash/yarn.lock
e018a4b    to
    c8520c5      
    Compare
  
    
No description provided.