Skip to content

Conversation

@JulianVentura
Copy link
Contributor

@JulianVentura JulianVentura commented Jan 7, 2025

Batch stats endpoint should return an array of summarized batches information

Description

This PR does the following changes:

  • Rename the /api/proofs_verified_last_24h to api/verified_batches_summary
  • Modifies the endpoint to return an array of batches summarized data
  • Add config values to be used in batch gas cost calculation

The summarized data has the following format:

{
  "batches": [
    {
      "date": "2025-01-07",
      "amount_of_proofs": 12,
      "gas_cost": 3249000
    },
    {
      "date": "2025-01-08",
      "amount_of_proofs": 826,
      "gas_cost": 223639500
    }
  ]
}

How to test

  1. Start a devnet
  2. Send a fixed amount of proofs
  3. Visit /api/verified_batches_summary
  4. Check that the amount of proofs matches the ones shown in the explorer
  5. Check that the gas cost calculation is correct

How to calculate the gas cost

The gas cost for each batch is derived from the following formula:

CONSTANT_GAS_COST = AGGREGATOR_GAS_COST * AGGREGATOR_MULTIPLIER) / PERCENTAGE_DIVIDER + BATCHER_SUBMISSION_GAS_COST

BATCH_GAS_COST = CONSTANT_GAS_COST + amount_of_proofs * ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF

By using the following values:

config :explorer,
  batcher_submission_gas_cost: 125000,
  aggregator_gas_cost: 330000,
  additional_submission_gas_cost_per_proof: 2000,
  aggregator_fee_percentage_multiplier: 125,
  percentage_divider: 100

The calculation is:

BATCH_GAS_COST = (330000 * 125 / 100 + 125000) + 2000 * amount_of_proofs

Type of change

  • New feature
  • Bug fix
  • Optimization
  • Refactor

Checklist

  • “Hotfix” to testnet, everything else to staging
  • Linked to Github Issue
  • This change depends on code or research by an external entity
    • Acknowledgements were updated to give credit
  • Unit tests added
  • This change requires new documentation.
    • Documentation has been added/updated.
  • This change is an Optimization
    • Benchmarks added/run
  • Has a known issue
  • If your PR changes the Operator compatibility (Ex: Upgrade prover versions)
    • This PR adds compatibility for operator for both versions and do not change batcher/docs/examples
    • This PR updates batcher and docs/examples to the newer version. This requires the operator are already updated to be compatible

@JulianVentura JulianVentura marked this pull request as ready for review January 7, 2025 21:46
@JulianVentura JulianVentura self-assigned this Jan 7, 2025
Copy link
Collaborator

@JuArce JuArce left a comment

Choose a reason for hiding this comment

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

It does not work fine with stage or testnet. There are 500k batches. It takes 1.3 minutes to return the data (and the transfer data is 70MB) Maybe we should return only the last 24h batches

@JulianVentura JulianVentura changed the title fix(explorer): Batch stats endpoint should return an array of batches information fix(explorer): (WIP) Batch stats endpoint should return an array of batches information Jan 8, 2025
@JulianVentura JulianVentura changed the title fix(explorer): (WIP) Batch stats endpoint should return an array of batches information fix(explorer): Batch stats endpoint should return an array of batches information Jan 8, 2025
@JulianVentura JulianVentura changed the title fix(explorer): Batch stats endpoint should return an array of batches information fix(explorer): Batch stats endpoint should return an array of summarized batches information Jan 8, 2025
Copy link
Contributor

@avilagaston9 avilagaston9 left a comment

Choose a reason for hiding this comment

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

Works as expected!

@JuArce JuArce merged commit 281b246 into testnet Jan 8, 2025
1 check passed
@JuArce JuArce deleted the 1719-fixexplorer-proof-stats-endpoint-should-return-an-array-of-verified-proofs branch January 8, 2025 21:53
PatStiles pushed a commit that referenced this pull request Jan 9, 2025
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.

fix(explorer): Proof stats endpoint should return an array of verified proofs

5 participants