aligned_layer icon indicating copy to clipboard operation
aligned_layer copied to clipboard

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

Open PatStiles opened this issue 1 year ago • 0 comments

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.

  • [x] 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
    • Link to the open issue addressing it
  • [ ] 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 avatar Dec 21 '24 00:12 PatStiles