dipdup-io / dipdup

Modular framework for creating selective indexers and featureful backends for dapps
https://dipdup.io
MIT License
97 stars 52 forks source link

Method for updating index state #1099

Open droserasprout opened 2 months ago

droserasprout commented 2 months ago

Implement ability to update index (properties and status) of working indexer, add update_index to DipDupContext and control API endpoint. New IndexStatus members:

Dprof-in-tech commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello, i am Dprof-in-tech, an experienced Full Stack Blockchain Developer and I am excited to contribute my skills to this project in this ODHACK 8. With a strong background in Next.js, TypeScript, JavaScript, React, Node.js, Python, Rust and Cairo, I've honed my technical skills across the blockchain development landscape.

My journey with OnlyDust began at Edition 2, and I've since made 34 contributions across 11 projects. This extensive experience on the platform has allowed me to develop a keen understanding of delivering high-quality solutions under tight deadlines. I bring a unique blend of technical prowess and user-centric design to every project, whether I'm crafting immersive 3D experiences or developing innovative smart contracts.

My track record demonstrates my ability to adapt quickly and contribute effectively to diverse challenges. I'm confident in my capacity to tackle new problems and drive innovation in the blockchain space. As we begin ODHACK 8, I'm eager to leverage my hackathon experience and technical skills to push the boundaries of what's possible in blockchain development.

Below is a link to my OnlyDust public profile. https://app.onlydust.com/u/Dprof-in-tech

How I plan on tackling this issue

Approach for Updating Index State (#1099):

  1. Review the Current Indexer and State Management I will begin by reviewing the current architecture of the indexer, particularly how the index state (properties and status) is managed within the application. This will include analyzing how states such as "active", "syncing", and "stopped" are handled. I will also examine how the application interacts with the DipDupContext and the control API endpoint. Understanding how to modify this context will allow us to implement updates in an efficient manner.

  2. Identify the Properties to be Updated I will identify the key properties that need to be updated within an index's state, such as: Index status: Whether it is active, disabled, or completed. Last indexed block/level: The latest block/level the indexer processed. New statuses to implement: Disabled: When the user disables the indexer manually. Completed: When the index has reached the latest block/level and completed indexing successfully.

  3. Implement update_index Method in DipDupContext I will add the update_index method to the DipDupContext, allowing updates to be made to the index's state. This method will be responsible for: Accepting the index name, new status, and any property updates. Applying the changes to the in-memory state and persisting them to the appropriate data store (e.g., database, cache). I will ensure that this method is flexible enough to handle updates across various properties of the index, not just the status.

  4. Update the Control API Endpoint I will modify the control API endpoint to allow users to trigger index updates through the API. This will involve: Adding a new route, likely named /update_index, that accepts a POST request. The API request body will include the index name and the updates to apply (e.g., setting the status to disabled or completed). I will ensure proper validation of incoming requests, confirming the index exists and that the provided properties are valid.

  5. Handle New IndexStatus Members I will implement the two new members of IndexStatus: Disabled: This status will indicate that an index has been disabled by a user action. I will update the application logic to ensure the index stops processing when in this state. Completed: This status will indicate that an index has successfully finished processing up to the latest available level. For both statuses, I will ensure that: Disabled: The indexer halts and does not attempt further processing. Completed: No further indexing occurs unless new blocks/levels are available.

  6. Discuss and Implement Polling for Pseudo-Realtime Updates I will consult with the team on whether to implement polling as a fallback mechanism when the WebSocket URL is missing. This would enable pseudo-realtime updates where the system periodically checks for new data if WebSockets are unavailable. If polling is decided as the approach, I will: Implement a polling mechanism within the indexer, where it checks for new data at configurable intervals. Ensure this process is efficient and doesn't cause unnecessary load on the system or network.

  7. Test the Implementation I will create unit and integration tests for the following: Updating index state: Ensuring the update_index method correctly updates the status and properties. Control API endpoint: Validating that the API allows index state updates and handles errors (e.g., invalid index or properties). Disabled and Completed statuses: Ensuring the application behaves correctly when an index is marked as disabled or completed. Polling (if implemented): Ensuring that the polling mechanism works as intended and provides near-real-time updates when WebSockets are unavailable.

  8. Documentation I will update the project documentation to include details on how to use the new control API endpoint for updating index states. I will also document the possible statuses for IndexStatus (active, disabled, completed, etc.), and how the application handles each state.

  9. Submit the Changes for Review After implementation and testing, I will submit a pull request with the following: The update_index method in DipDupContext. The updated control API endpoint for modifying index state. The new IndexStatus members (disabled and completed). Any relevant tests and documentation updates.

I will request feedback from the team, make any adjustments as needed, and ensure the implementation aligns with the overall project requirements.

  1. Estimated Timeline Start Date: Immediately upon assignment. Estimated Completion Date: 2-3 days from the start date.
martinvibes commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

hello i am a frontend dev and blockchain developer please can i work on this issue :) and would love to be a contributor

How I plan on tackling this issue

Update Index Method:

Add a method called update_index to DipDupContext that allows updating the index's properties and status. Control API Endpoint:

Implement an API endpoint to control and manage the index updates. New IndexStatus Members:

Add two new status members: disabled: Indicates the index has been disabled by the user. completed: Indicates the index had a last_level and was successfully indexed. Discussion Point:

Consider implementing polling for pseudo-realtime updates when the WebSocket URL is missing.

tosoham commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a python dev. A new-comer here, willing and ready to contribute to solve this issue.

t0fudev commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Helloo, my name is Hellen. I´m currently a computer science student and a web3 developer. I have been working on different exercises on different platforms like Exercism and Starklings in the past weeks so I can get my knowledge about the different languages better . I am hopeful to contribute on this repository!!

How I plan on tackling this issue

To fix this issue I would do the following:

I would ask the maintainers for any help if I get problems while working on this!

t0fudev commented 1 month ago

Hello DipDup maintainers, I hope you're doing great. I'm unassignning myself from this issue due to my current university workload. I really appreaciate the opportunity to contribute on this repo, and I hope I can participate in future events.

Thank you for understanding!

suhas-sensei commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have a strong background in designing functions for managing system states and user permissions, ensuring secure and authorized actions. This task of implementing index updates, adding update_index to DipDupContext, and managing control through an API aligns well with my expertise, and I am confident in delivering precise and efficient results.

How I plan on tackling this issue

I would approach this by first integrating the update_index function into the DipDupContext, ensuring it accurately updates the index properties and status. The function will handle new IndexStatus members like disabled (set by the user) and completed (successfully indexed with the last level). I will implement an API control endpoint to facilitate seamless updates, while ensuring robust error handling and security. Additionally, I would address the polling mechanism for pseudo-realtime updates when the WebSocket URL is unavailable, ensuring smooth operation in such cases. Comprehensive testing will validate all scenarios.

ooochoche commented 4 weeks ago

@droserasprout can I take on this issue