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

feat(cli): add get-user-first-nonce + get-user-number-queued-proofs cli commands #1553

Merged
merged 51 commits into from
Jan 21, 2025

Conversation

PatStiles
Copy link
Contributor

@PatStiles PatStiles commented Dec 3, 2024

Add get-user-first-nonce to cli

Description

Adds a function to the aligned-cli get-user-first-nonce to retrieve the users nonce from ethereum. This is useful in scenarios where you need to replace your proofs with higher fees. For that, you'll need the first proof's nonce corresponding to the value in the BatcherPaymentService contract.

Adds a function to the aligned-cli get-user-number-queued-proofs to retrieve the number of proofs a user has in the batcher queue.

To Test:

  • Setup a local devnet.
  • Fund a wallet:
cast send <YOUR_WALLET_ADDRESS> --private-key <ANVIL_RICH_ACCOUNT> --value 1ether
  • cd into aligned cli: cd batcher/aligned
  • Fund wallet on batcher wallet:
cargo run --release -- deposit-to-batcher --network devnet --amount 0.1ether --keystore_path <KEYSTORE_PATH>
  • Send some proofs with a low max fee to the batcher so that they are not submitted:
cargo run --release -- submit  --proving_system Risc0 --proof ../../scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.proof  --vm_program ../../scripts/test_files/risc_zero/fibonacci_proof_generator/fibonacci_id.bin --public_input ../../scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.pub --repetitions <BURST_SIZE> --keystore_path <YOUR_KEYSTORE_PATH> --network devnet  --max_fee 10  --nonce "0"
  • Get the nonce from ethereum:
cargo run --release -- get-user-nonce-from-ethereum --user_addr <YOUR_WALLET_ADDRESS>

You should see it is 0.

  • Get the nonce from the Batcher:
cargo run --release -- get-user-nonce --user_addr <YOUR_WALLET_ADDRESS>

You should see it is <BURST_SIZE>

  • Get the amount of proofs in batcher queue:
cargo run --release -- get-amount-of-proofs-in-batcher-queue --user_addr <YOUR_WALLET_ADDRESS>
  • Bump the fees using the nonce you got from the Ethereum:
cargo run --release -- submit  --proving_system Risc0 --proof ../../scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.proof  --vm_program ../../scripts/test_files/risc_zero/fibonacci_proof_generator/fibonacci_id.bin --public_input ../../scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.pub --repetitions 3 --keystore_path <YOUR_KEYSTORE_PATH> --network devnet  --max_fee 1000000000000  --nonce "0"

Type of change

Please delete options that are not relevant.

  • New feature

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

@MarcosNicolau MarcosNicolau force-pushed the 1541-get-first-nonce-in-queue branch from c8fe0c4 to f86cd63 Compare December 5, 2024 14:20
@MarcosNicolau MarcosNicolau changed the base branch from testnet to staging December 5, 2024 14:20
Copy link

github-actions bot commented Dec 5, 2024

Changes to gas cost

Generated at commit: 069fea945ca651ff7906b3d4e58ef3fd011665d6, compared to commit: 8b6ef0c71f65d1233d392c2d58f2f1442ba27fab

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
AlignedLayerServiceManager createNewTask +302 ❌ +0.40%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
AlignedLayerServiceManager 5,231,234 (0) createNewTask
receive
56,083 (0)
23,317 (0)
0.00%
0.00%
76,066 (+302)
46,915 (+373)
+0.40%
+0.80%
76,217 (-24)
47,195 (0)
-0.03%
0.00%
77,030 (0)
47,195 (0)
0.00%
0.00%
256 (0)
256 (0)

Copy link
Collaborator

@avilagaston9 avilagaston9 left a comment

Choose a reason for hiding this comment

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

As discussed offline, we have to use get_nonce_from_ethereum in batcher/aligned-sdk/src/sdk.rs:633, which returns the next nonce from Ethereum for a given address. This will simplify the code a lot and we should update the docs explaining how this method can be useful.

@MarcosNicolau MarcosNicolau force-pushed the 1541-get-first-nonce-in-queue branch from f86cd63 to 3f61db1 Compare December 5, 2024 15:31
@uri-99 uri-99 changed the title feat(cli): add get-user-first-nonce command feat(cli): add get-nonce cli commands Dec 5, 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.

Got some unexpected behavior while testing it locally that should be discussed offline

@JulianVentura
Copy link
Collaborator

Got some unexpected behavior while testing it locally that should be discussed offline

This error was related to the usage of non paying addresses. It works as expected for paying addresses

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.

Looks good and works as expected locally

Copy link
Collaborator

@avilagaston9 avilagaston9 left a comment

Choose a reason for hiding this comment

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

Code looks good and works in my machine!

Copy link
Collaborator

@JuArce JuArce left a comment

Choose a reason for hiding this comment

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

There is missing to update the docs

@uri-99 uri-99 requested a review from JuArce January 17, 2025 17:43
@uri-99 uri-99 changed the base branch from staging to feat/deprecate-batcher-url January 17, 2025 21:19
Base automatically changed from feat/deprecate-batcher-url to staging January 17, 2025 23:05
Copy link
Collaborator

@JuArce JuArce left a comment

Choose a reason for hiding this comment

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

Docs is outdated

@JuArce JuArce added this pull request to the merge queue Jan 21, 2025
Merged via the queue into staging with commit 4b73027 Jan 21, 2025
3 checks passed
@JuArce JuArce deleted the 1541-get-first-nonce-in-queue branch January 21, 2025 19:11
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.

7 participants