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

fix(sdk): Partially sent batch should display results of processing #1675

Open
wants to merge 60 commits into
base: staging
Choose a base branch
from

Conversation

PatStiles
Copy link
Contributor

@PatStiles PatStiles commented Dec 21, 2024

Partially verified batch should display result of processing

Description

When submitting multiple proofs of the same max_fee there is a possible case that the user's balance in the BatcherPaymentService has some but not all of the needed balance to pay cover submission. In this case a InsufficientBalance error will be thrown and some proofs will be processed while over error. Currently this is not displayed to the user and this pr seeks to shown this information by modifying the sdk and error message.

Test Cases:

  • Start a local devnet and send proofs
  • fund the batcher with ~ 0.09 eth:
cast send --rpc-url http://localhost:8545 0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650 --value 0.09ether --private-key <DEVNET_WALLET_PRIVATE_KEY>
aligned get-user-balance --user_addr <DEVNET_WALLET_ADDRESS>
  • cd batcher/aligned

Submit proofs with the relevant test cases and observe the results deascribed in the images below.

All Proofs Fails w/ InsufficientBalance:

cargo run --release -- submit \
--proving_system GnarkPlonkBn254 \
--proof ../../scripts/test_files/gnark_plonk_bn254_script/plonk.proof \
--public_input ../../scripts/test_files/gnark_plonk_bn254_script/plonk_pub_input.pub \
--vk ../../scripts/test_files/gnark_plonk_bn254_script/plonk.vk \
--batcher_url ws://localhost:8080 \
--private_key <DEVNET_PRIVATE_KEY> \
--network devnet \
--max_fee 1ether --repetitions 9
Screenshot 2024-12-20 at 21 52 18

One Proof Fails w/ InsufficientBalance:

cargo run --release -- submit \
--proving_system GnarkPlonkBn254 \
--proof ../../scripts/test_files/gnark_plonk_bn254_script/plonk.proof \
--public_input ../../scripts/test_files/gnark_plonk_bn254_script/plonk_pub_input.pub \
--vk ../../scripts/test_files/gnark_plonk_bn254_script/plonk.vk \
--batcher_url ws://localhost:8080 \
--private_key <DEVNET_PRIVATE_KEY> \
--network devnet \
--max_fee 1ether --repetitions 1
Screenshot 2024-12-20 at 21 51 53

All Proofs are processed:

cargo run --release -- submit \
--proving_system GnarkPlonkBn254 \
--proof ../../scripts/test_files/gnark_plonk_bn254_script/plonk.proof \
--public_input ../../scripts/test_files/gnark_plonk_bn254_script/plonk_pub_input.pub \
--vk ../../scripts/test_files/gnark_plonk_bn254_script/plonk.vk \
--batcher_url ws://localhost:8080 \
--private_key <DEVNET_PRIVATE_KEY> \
--network devnet \
--max_fee 0.01ether --repetitions 8
Screenshot 2024-12-20 at 21 54 14

Some proofs fail with w/ InsufficientBalance:

cargo run --release -- submit \
--proving_system GnarkPlonkBn254 \
--proof ../../scripts/test_files/gnark_plonk_bn254_script/plonk.proof \
--public_input ../../scripts/test_files/gnark_plonk_bn254_script/plonk_pub_input.pub \
--vk ../../scripts/test_files/gnark_plonk_bn254_script/plonk.vk \
--batcher_url ws://localhost:8080 \
--private_key <DEVNET_PRIVATE_KEY> \
--network devnet \
--max_fee 0.01ether --repetitions 10
Screenshot 2024-12-20 at 21 55 40

Insufficient Balance with no funds

  • Start local devnet
  • Do not fund the batcher
  • submit proofs and verify that there is no overflow and an InsufficientBalance error is thrown
cargo run --release -- submit \
--proving_system GnarkPlonkBn254 \
--proof ../../scripts/test_files/gnark_plonk_bn254_script/plonk.proof \
--public_input ../../scripts/test_files/gnark_plonk_bn254_script/plonk_pub_input.pub \
--vk ../../scripts/test_files/gnark_plonk_bn254_script/plonk.vk \
--batcher_url ws://localhost:8080 \
--private_key <DEVNET_PRIVATE_KEY> \
--network devnet \
--max_fee 0.01ether --repetitions 10

Type of change

Please delete options that are not relevant.

  • Bug fix

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

@PatStiles PatStiles self-assigned this Dec 23, 2024
Copy link
Collaborator

@JulianVentura JulianVentura left a comment

Choose a reason for hiding this comment

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

Didn't test, left you some comments

@PatStiles PatStiles force-pushed the fix/partially-verified-batch-should-display-batches branch from fff41d9 to 7b86ef7 Compare December 23, 2024 19:42
@uri-99 uri-99 changed the base branch from staging to feat/deprecate-batcher-url January 17, 2025 21:44
Base automatically changed from feat/deprecate-batcher-url to staging January 17, 2025 23:05
@uri-99 uri-99 requested a review from JuArce January 22, 2025 19:08
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