Skip to content

Conversation

@tuhalf
Copy link
Collaborator

@tuhalf tuhalf commented Nov 19, 2025

This pull request introduces a ticket expiration and garbage collection system for P2P objects, primarily focusing on cleaning up stale ticket objects from the database. It modifies the storage and retrieval logic for objects, adds new periodic cleanup jobs, and includes supporting tests to ensure stale tickets are properly expired and removed.

I am not sure about if I delete tickets that's used for payments or not. I need you to check that @dominicletz

@tuhalf tuhalf requested a review from dominicletz November 19, 2025 07:41
@gemini-code-assist
Copy link

Summary of Changes

Hello @tuhalf, 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 establishes a robust system for managing the lifecycle of P2P ticket objects within the database. By introducing automatic garbage collection and defining clear criteria for ticket staleness, it ensures that the system remains efficient and free of outdated data, improving overall database health and performance. The changes encompass schema modifications, new background jobs, and integrated staleness checks during object retrieval.

Highlights

  • Automated Ticket Garbage Collection: Introduced a new hourly cron job named 'Ticket GC' that automatically prunes stale P2P ticket objects from the database, preventing the accumulation of expired data.
  • Staleness Criteria for Tickets: Implemented logic to determine if a ticket is 'stale' based on two criteria: a time-to-live (TTL) of 24 hours since storage, and an epoch-based check to ensure tickets are not significantly older than the current blockchain epoch.
  • Database Schema and Object Handling Updates: Modified the p2p_objects table to include a stored_at timestamp. Object storage (put_object) now records this timestamp, and object retrieval functions (object, scan, objects) now automatically filter out and delete stale objects upon access.
  • Comprehensive Testing: Added new unit tests to verify the correct behavior of stale ticket expiration based on TTL and the functionality of the garbage collection process.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 introduces a valuable ticket expiration and garbage collection system for P2P objects, which will help maintain the database by cleaning up stale ticket objects. The implementation includes a database migration for a stored_at timestamp, a new cron job for periodic cleanup, and logic to filter stale objects on read. My review focuses on potential performance improvements and enhancing code clarity. I've identified that the prune_stale_objects function could lead to high memory usage with a large database and have suggested a more scalable batching approach. Additionally, I've provided suggestions to make some parts of the code more idiomatic and concise. Regarding your question about deleting tickets used for payments, the current logic correctly implements a cleanup strategy for a distributed cache. It assumes that tickets that are old (by time or epoch) are no longer relevant, which is a reasonable approach as submitted tickets are recorded on-chain.

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.

3 participants