Skip to content

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

Merged
JuArce merged 51 commits into
stagingfrom
1541-get-first-nonce-in-queue
Jan 21, 2025
Merged

feat(cli): add get-user-first-nonce + get-user-number-queued-proofs cli commands#1553
JuArce merged 51 commits into
stagingfrom
1541-get-first-nonce-in-queue

Conversation

@PatStiles

@PatStilesPatStiles commented Dec 3, 2024

Copy link
Copy Markdown
Contributor

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

Comment threadbatcher/aligned/src/main.rs Outdated
Comment threadbatcher/aligned/src/main.rs
@MarcosNicolau
MarcosNicolauforce-pushed the 1541-get-first-nonce-in-queue branch from c8fe0c4 to f86cd63CompareDecember 5, 2024 14:20
@MarcosNicolau
MarcosNicolau changed the base branch from testnet to stagingDecember 5, 2024 14:20
@github-actions

Copy link
Copy Markdown

Changes to gas cost

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

🧾 Summary (10% most significant diffs)

ContractMethodAvg (+/-)%
AlignedLayerServiceManagercreateNewTask+302 ❌+0.40%

Full diff report 👇
ContractDeployment Cost (+/-)MethodMin (+/-)%Avg (+/-)%Median (+/-)%Max (+/-)%# Calls (+/-)
AlignedLayerServiceManager5,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)

@avilagaston9avilagaston9 left a comment

Copy link
Copy Markdown
Contributor

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
MarcosNicolauforce-pushed the 1541-get-first-nonce-in-queue branch from f86cd63 to 3f61db1CompareDecember 5, 2024 15:31
@uri-99uri-99 changed the title feat(cli): add get-user-first-nonce commandfeat(cli): add get-nonce cli commandsDec 5, 2024
Comment threadbatcher/aligned/src/main.rs Outdated
Comment threadbatcher/aligned/src/main.rs Outdated

@JulianVenturaJulianVentura left a comment

Copy link
Copy Markdown
Contributor

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

Comment threadbatcher/aligned/src/main.rs Outdated
@JulianVentura

Copy link
Copy Markdown
Contributor

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

@JulianVenturaJulianVentura left a comment

Copy link
Copy Markdown
Contributor

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

@avilagaston9avilagaston9 left a comment

Copy link
Copy Markdown
Contributor

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!

@uri-99
uri-99 requested a review from JuArceJanuary 17, 2025 17:43
@uri-99
uri-99 changed the base branch from staging to feat/deprecate-batcher-urlJanuary 17, 2025 21:19
Base automatically changed from feat/deprecate-batcher-url to stagingJanuary 17, 2025 23:05

@JuArceJuArce left a comment

Copy link
Copy Markdown
Collaborator

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 queueJan 21, 2025
Merged via the queue into staging with commit 4b73027Jan 21, 2025
@JuArce
JuArce deleted the 1541-get-first-nonce-in-queue branch January 21, 2025 19:11
@JuArceJuArce linked an issue Mar 27, 2025 that may be closed by this pull request
Sign up for freeto 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.

feat(aligned cli): get first nonce in queue for the user

7 participants

@PatStiles@JulianVentura@Oppen@uri-99@JuArce@avilagaston9@MarcosNicolau