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 verified batch should display results of processing #1675

Open
wants to merge 8 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_PRIVATE_KEY>
  • 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

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

batcher/aligned-batcher/src/lib.rs Show resolved Hide resolved
batcher/aligned-sdk/src/communication/messaging.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/communication/messaging.rs Outdated Show resolved Hide resolved
batcher/aligned-batcher/src/lib.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/communication/messaging.rs Outdated Show resolved Hide resolved
batcher/aligned-batcher/src/lib.rs Show resolved Hide resolved
batcher/aligned-sdk/src/core/errors.rs Show resolved Hide resolved
Comment on lines 130 to 148
if let SubmitError::InsufficientBalance(_, last_valid_nonce) = e {
aligned_submitted_data.push(Err(e));
if last_valid_nonce < last_proof_nonce {
last_proof_nonce = last_valid_nonce;
}

if last_proof_nonce < first_nonce {
break;
}

continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this goes inside handle_batcher_response.

@PatStiles PatStiles force-pushed the fix/partially-verified-batch-should-display-batches branch from fff41d9 to 7b86ef7 Compare December 23, 2024 19:42
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.

3 participants