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

Feat/dune #100

Draft
wants to merge 57 commits into
base: master
Choose a base branch
from
Draft

Feat/dune #100

wants to merge 57 commits into from

Conversation

alexshchur
Copy link
Member

@alexshchur alexshchur commented Oct 2, 2023

  • makes the process of fetching transactions potentially eligible for gas refunds rely on Dune instead of Covalent and Subgraph
  • adds axios-curlize to make it more obvious what API calls are made during script execution
  • adds a draft retry logic (TBC: use default ethers logic) to prevent the script halting too often during development
  • adds script that generates dune query (TBC: there should be a better approach, some engine / API / templating lib?)
  • adds script for indexing dune transactions pulled from API into a local DB

How to test:

  1. generate dune query
yarn gas-refund:generate-dune-query
  1. fetch the result of that query into a local file
curl  -X GET \
  'https://api.dune.com/api/v1/query/{queryId}/results' \
  --header 'x-dune-api-key: {API_KEY}' > dune-transactions.json
  1. index Dune transactions into the DB
cat dune-transactions.json | yarn gas-refund:index-dune-transactions
  1. delete all transactions of the 38 epoch:
delete from "GasRefundTransactions" where epoch >= 38
  1. reindex GasRefundTransactions with Dune data:
yarn gas-refund:dev:compute-gas-refund-save-db
  1. generate roots for epoch 38:
yarn gas-refund:compute-merkle-tree-save-file

The roots would match the published one

Current state:

  • it generates correct roots for the previous distributions, so presumably works correctly
  • indexing one epoch takes 300 seconds with Dune (vs > 30 mins previously)
  • it took ~8.5K dune credits to fetch the data (on the basic / free plan)
Screenshot 2023-10-02 at 09 24 01

Details on credits calc

data amount for prev epoch is: 24 columns x 300K rows ~= 7.5 mil datapoints
which takes ~7500 credits. The "Plus" plan allows 25,000 credits

@alexshchur alexshchur marked this pull request as draft October 2, 2023 09:36
to: contractAddress,
block_timestamp: {
[Op.gte]: startTimestamp,
[Op.lte]: endTimestamp,
Copy link
Member

@mwamedacen mwamedacen Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor but I'd be strict on one of the side to prevent double spending across epochs

Copy link
Member Author

@alexshchur alexshchur Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just faced a duplicate, so that is what would happen instead of double spending, will add fix

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.

2 participants