Skip to content

Conversation

@JulianVentura
Copy link
Contributor

@JulianVentura JulianVentura commented Dec 17, 2024

Modify how spent amount is calculated on task sender

Description

We have the task sender configured to send proofs periodically. After a new batch of proofs is verified, a slack message is sent notifying the cost of this submission and verification. The reported cost is associated with the Fee per proof variable, which is alright for the users, but not in this case. We just want to know how much did we spend only by creating the task and responding to it, without any fee to the batcher. This PR accomplishes that, by fetching the transaction receipts and calculating the exact fees.

At the same time, some environment variables were added so it's easy to test this feature on different environments

How to test

  1. Modify the send_slack_message function on sender_with_alert.sh with the following:
# Function so send Slack message
# @param message
function send_slack_message() {
    echo "$1"
}
  1. Fund a wallet or use a rich wallet as the task sender (don't use a non-paying one)
  2. Create an .env file under alerts directory, using .env.example as a template
  3. Start all services, including the explorer.
  4. Execute the task sender by running ./alerts/sender_with_alert.sh ./alerts/.env
  5. You should see the following logs
image
  1. You should do some checks on the calculated spent amount:
  • It should be lower than the fee_per_proof * number_of_proofs, which you can see on the explorer
  • You should be able to get the same value calculating it by hand
  1. You should also test with multiple batches submissions.
  • For that, you can modify the max_batch_proof_qty variable under the try_build_batch function on the batcher, so that the amount of proofs sent is split between two batches.
  • You should send a lower number of proofs than the double of your chosen vale for the max_batch_proof_qty, so the second batch doesn't have the same merkle root as the first one. For example, max_batch_proof_qty=7, repetitions=12.

How to calculate by hand

  1. Go to the explorer and open the batch on which you want to make the calculation off
  2. Copy the "Submission Transaction Hash"
  3. Do the following RPC call and copy the gasUsed and effectiveGasPrice
cast receipt --rpc-url <RPC_URL> <TX_HASH>
  1. Calculate the fee by doing
(gasUsed * effectiveGasPrice) / 1e18
  1. Repeat the process from step (2) for the "Response Transaction Hash"
  2. Sum the two values and compare them to the script, they should be almost the same (floating point error)

Type of change

Please delete options that are not relevant.

  • 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 self-assigned this Dec 18, 2024
@JulianVentura
Copy link
Contributor Author

@uri-99 @JuArce please review again

@JuArce JuArce changed the base branch from 1552-feat-task-sender-that-sends-alerts-to-pager-duty-on-failed-tasks to testnet December 19, 2024 23:08
@JuArce JuArce changed the title refactor: modify how spent amount is calculated on task sender feat: task sender with slack updates and pager duty alerts Dec 19, 2024
@JuArce JuArce merged commit e26c62f into testnet Dec 19, 2024
1 check passed
@JuArce JuArce deleted the 1552-feat-task-sender-that-sends-alerts-to-pager-duty-on-failed-tasks-v2 branch December 19, 2024 23:19
PatStiles pushed a commit that referenced this pull request Jan 10, 2025
PatStiles pushed a commit that referenced this pull request Jan 10, 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.

5 participants