Skip to content
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

Data tile BE: Transactions burning most steps by entrypoint ID #10

Closed
mazurroman opened this issue May 20, 2024 · 14 comments · May be fixed by walnuthq/starkflare-indexer#6
Closed

Data tile BE: Transactions burning most steps by entrypoint ID #10

mazurroman opened this issue May 20, 2024 · 14 comments · May be fixed by walnuthq/starkflare-indexer#6

Comments

@mazurroman
Copy link
Contributor

mazurroman commented May 20, 2024

Feel free to join our telegram to get latest updates: https://t.me/+DYI4FMia43I1NDI8

Create an API endpoint in the https://github.com/walnuthq/starkflare-indexer backend repo that accepts two parameters: contract hash and entrypoint selector. The endpoint should return a list of transactions for the given contract and entrypoint, sorted by the number of steps consumed in descending order.

The returned data for each transaction should include:

  • Transaction hash
  • Number of steps consumed
  • Timestamp of the transaction

Follow the guidelines outlined in the starkflare-indexer repository. Note that this endpoint should be implemented separately from the get_common_data endpoint as it requires specific arguments.

@mazurroman mazurroman changed the title Data tile BE: Entrypoints burning most steps Data tile BE: Transactions burning most steps May 20, 2024
@KeneePatel
Copy link

Hey @mazurroman,

I would like to tackle this issue. Just wanted some references to understand the entrypoints and on which language is the backend going to be implemented in? Can you give some directions, so then I will be able to come up with a strategy to handle the task.

@aweolumidedavid
Copy link

Hi, I will to take this up

@barabanovro barabanovro changed the title Data tile BE: Transactions burning most steps Data tile BE: Transactions burning most steps by entrypoint id May 21, 2024
@barabanovro barabanovro changed the title Data tile BE: Transactions burning most steps by entrypoint id Data tile BE: Transactions burning most steps by entrypoint ID May 21, 2024
@mazurroman mazurroman changed the title Data tile BE: Transactions burning most steps by entrypoint ID DRAFT: Data tile BE: Transactions burning most steps by entrypoint ID May 22, 2024
@mazurroman
Copy link
Contributor Author

@KeneePatel we updated the description and it now also contains a link to the backend repo for more context

@aweolumidedavid please check our contribution guidelines and update your comment accordingly #12

@aweolumidedavid
Copy link

@mazurroman hi, you can call me David.
I am a software engineer experienced in building scalable solutions. I have experience building NodeJs solutions either with expressJs, NestJs or fastify. I have also work with different type of database both NoSQL and Relational Databases like Postgres, MySql and MSSServer using typerOrm.

To implement the API, I will do the following

  • I will be working in the indexer/src module which have more that one responsibility as it contains the account interface, the db congiguration for postgres, and the methods/functions to call.
  • I will create new folder and a file in the folder for interface and move the account interface there
  • create a new folder for the configs and create a file and move the postgres connection function there
  • import the interface and the config in the account-call.ts
  • Write a function to query the PostgreSQL database for transactions matching the provided contractHash and entrypointSelector, sorting the results by the number of steps consumed in descending order.
    I will ensure that the response includes the transaction hash, number of steps consumed, and timestamp.
    -create a new folder called controller and create a new route for the API endpoint that will accept contractHash and entrypointSelector as query parameters.
  • I will ensure that validation by add the validation middleware method checks the query parameters.
  • for the validator, I can use joi package to validate accordingly
  • I will make sure the newly created files and routes follow the existing project structure and guidelines outlined in the starkflare-indexer repository.
    Thank you very much.

@mazurroman mazurroman changed the title DRAFT: Data tile BE: Transactions burning most steps by entrypoint ID Data tile BE: Transactions burning most steps by entrypoint ID May 23, 2024
@mazurroman
Copy link
Contributor Author

Assigning to @aweolumidedavid who provided the most detailed information on how to approach this issue

@mazurroman
Copy link
Contributor Author

mazurroman commented May 23, 2024

Apologies for a confusion here. @aweolumidedavid your comment is incorrect - you are suggesting to create a node.js endpoint; however, we state that we use PostgREST in the starkflare-indexer repo README

This issue remains open and unassigned. @KeneePatel if you are up for it can you add instructions on how would you solve this issue, according to our contributor guidelines

@KeneePatel
Copy link

I guess I lacked a proper structure on how the endpoint functions will be handled. To be honest, I will be learning it along the way, but looking at the current codebase, I guess I will need to create a model for the input and output. Maybe even write a migration SQL script to create necessary queries or tables. Write the implementation in a function similar to that of account-calls.ts which will have the logic for conversion and processing of the input data.

If I come across any doubts, I will be quick to mention the specifics in our TG group and ask for directions. And let me know if any more clarity is needed.

@aweolumidedavid
Copy link

@mazurroman I will like to give this another shot.
Following thex eisting structure of the codebase. I will solve this issue by doing the following:

  • I will add a new SQL Migration File by creating it the database/migration folder and I will used the name as follows 003_add_get_transactions_by_contract_and_entrypoint.up.sql
  • Next I will update the account-call.ts file because this file handles the data transformation for indexing and also ensure it aligns with the schema changes if necessary. No changes are needed here unless the schema or logic for storing data changes.

The sql code snippet look like this
CREATE OR REPLACE FUNCTION starkflare_api.get_transactions_by_contract_and_entrypoint(
contract_hash TEXT,
entrypoint_selector TEXT
) RETURNS TABLE (
tx_hash TEXT,
steps_consumed INTEGER,
timestamp TIMESTAMP
) AS $$
BEGIN
RETURN QUERY
SELECT
tx_hash,
steps_number AS steps_consumed,
to_timestamp(timestamp) AS timestamp
FROM
starkflare_api.account_calls
WHERE
contract_address = contract_hash
AND entrypoint_selector = entrypoint_selector
ORDER BY
steps_number DESC;
END;
$$ LANGUAGE plpgsql;

Finally, I am open to corrections and willing to learn. Thank you very much.

@barabanovro
Copy link
Contributor

Hi everyone! Thank you for your interest in this issue. @KeneePatel, your comment lacks the specific info we need according to our contribution guidelines. We expect details about you, your relevant experience, and detailed technical instructions on how you plan to tackle the task.

I have assigned this issue to @aweolumidedavid based on their last comment, which provided the necessary information and understanding of the problem and solution.

@aweolumidedavid
Copy link

Thank you very much, working on it right away @mazurroman @barabanovro

@saimeunt
Copy link
Contributor

Hey @aweolumidedavid are you still working on this?
@barabanovro Following up on my work on #23 and #28 I'd like to tackle this one over the weekend if possible.

@barabanovro
Copy link
Contributor

Hi @aweolumidedavid, I wanted to check in on the progress of this task. Could you please provide an update?

@aweolumidedavid
Copy link

@barabanovro @mazurroman I hope this message finds you well. I regret to inform you that I am currently unable to complete the issue assigned to me due to unforeseen circumstances that have taken me away for a while. Given the importance of timely progress on this matter, I kindly request that the issue be reassigned to another team member @saimeunt who can continue the work without delay.
I value the work we are doing and remain committed to contributing effectively. Once I am back, I will be more than happy to pick up new issues and continue supporting our projects.
Thank you for your understanding and support during this time.

@JoelVR17
Copy link

I'd like to tackle this issue for several reasons. Firstly, I have experience in developing RESTful APIs and working with some databases. Moreover, I've carefully reviewed the requirements of the problem and feel confident in implementing the API endpoint as specified. I'm committed to adhering to project guidelines and have the availability to efficiently complete this task. In summary, I believe I can effectively contribute to resolving this issue, and I'm excited about the opportunity to work on it.

@mazurroman mazurroman closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants