Skip to content

fix(explorer): Batch stats endpoint should return an array of summarized batches information - #1721

Merged
JuArce merged 2 commits into
testnetfrom
1719-fixexplorer-proof-stats-endpoint-should-return-an-array-of-verified-proofs
Jan 8, 2025
Merged

fix(explorer): Batch stats endpoint should return an array of summarized batches information#1721
JuArce merged 2 commits into
testnetfrom
1719-fixexplorer-proof-stats-endpoint-should-return-an-array-of-verified-proofs

Conversation

@JulianVentura

@JulianVenturaJulianVentura commented Jan 7, 2025

Copy link
Copy Markdown
Contributor

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
@JulianVenturaJulianVentura self-assigned this Jan 7, 2025

@JuArceJuArce left a comment

Copy link
Copy Markdown
Collaborator

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

@JulianVenturaJulianVentura changed the title fix(explorer): Batch stats endpoint should return an array of batches informationfix(explorer): (WIP) Batch stats endpoint should return an array of batches informationJan 8, 2025
@JulianVenturaJulianVentura changed the title fix(explorer): (WIP) Batch stats endpoint should return an array of batches informationfix(explorer): Batch stats endpoint should return an array of batches informationJan 8, 2025
@JulianVenturaJulianVentura changed the title fix(explorer): Batch stats endpoint should return an array of batches informationfix(explorer): Batch stats endpoint should return an array of summarized batches informationJan 8, 2025

@avilagaston9avilagaston9 left a comment

Copy link
Copy Markdown
Contributor

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 testnetJan 8, 2025
@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
…zed batches information (#1721)
Co-authored-by: Julian Ventura <julian.ventura@lambdaclass.com>
Sign up for freeto 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

4 participants

@JulianVentura@uri-99@JuArce@avilagaston9