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): Price Estimates in Aligned CLI #1577

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

Conversation

PatStiles
Copy link
Contributor

@PatStiles PatStiles commented Dec 4, 2024

Price Estimates in Aligned CLI

Description

Addresses No. 1 in #1570. Adds a new pricing parameter for the cli using PriceEstimate from the sdk. Refactors some parts of the sdk.

Type of change

Please delete options that are not relevant.

  • New feature
  • Bug fix
  • Optimization
  • Refactor

To Test:

  • Start local devnet
  • If you prefer to use a paying address run the following:
cast send --rpc-url http://localhost:8545 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --value 9999.9999999ether --private-key 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a
  • Try submitting proofs with the following commands and observe the following edge cases are successfully submit a proof to the batcher:

Not specifying a fee should use the default.

cargo run --release -- submit \
                --proving_system SP1 \
                --proof ../../scripts/test_files/sp1/sp1_fibonacci.proof \
                --vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \
                --repetitions 20 \
                --proof_generator_addr 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 \
                --rpc_url http://localhost:8545 \
                --network devnet --private_key 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a
Screenshot 2024-12-05 at 20 30 24

--max_fee

cargo run --release -- submit \
                --proving_system SP1 \
                --proof ../../scripts/test_files/sp1/sp1_fibonacci.proof \
                --vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \
                --repetitions 20 \
                --proof_generator_addr 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 \
                --rpc_url http://localhost:8545 \
                --network devnet --max_fee 100000000 --private_key 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a

--default_fee_estimate

cargo run --release -- submit \
                --proving_system SP1 \
                --proof ../../scripts/test_files/sp1/sp1_fibonacci.proof \
                --vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \
                --repetitions 20 \
                --proof_generator_addr 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 \
                --rpc_url http://localhost:8545 \
                --network devnet --default_fee_estimate --private_key 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a

--instant_fee_estimate

cargo run --release -- submit \
                --proving_system SP1 \
                --proof ../../scripts/test_files/sp1/sp1_fibonacci.proof \
                --vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \
                --repetitions 20 \
                --proof_generator_addr 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 \
                --rpc_url http://localhost:8545 \
                --network devnet --instant_fee_estimate --private_key 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a

`--custom_fee_estimate <NUM_PROOFS_IN_BATCH>"

cargo run --release -- submit \
                --proving_system SP1 \
                --proof ../../scripts/test_files/sp1/sp1_fibonacci.proof \
                --vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \
                --repetitions 20 \
                --proof_generator_addr 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 \
                --rpc_url http://localhost:8545 \
                --network devnet --custom_fee_estimate <NUM_PROOFS_IN_BATCH> --private_key 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a
  • Try submitting proofs with the following commands and observe the following edge cases are triggered:

max_fee and default_fee_estimate/instant_fee_estimate/custom_fee_estimate should not be displayed.

cargo run --release -- submit \
                --proving_system SP1 \
                --proof ../../scripts/test_files/sp1/sp1_fibonacci.proof \
                --vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \
                --repetitions 20 \
                --proof_generator_addr 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 \
                --rpc_url http://localhost:8545 \
                --network devnet --max_fee 1000000000 --custom_fee_estimate --private_key 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a
Screenshot 2024-12-05 at 20 28 45

Clap errors if custom does not have <NUM_PROOFS_PER_BATCH>

cargo run --release -- submit \
                --proving_system SP1 \
                --proof ../../scripts/test_files/sp1/sp1_fibonacci.proof \
                --vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \
                --repetitions 20 \
                --proof_generator_addr 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 \
                --rpc_url http://localhost:8545 \
                --network devnet --custom_fee_estimate --private_key 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a
Screenshot 2024-12-05 at 20 29 20

Parsing errors for "--custom_fee_estimate" if incorrect value is supplied for num_proofs_in_batch

cargo run --release -- submit \
                --proving_system SP1 \
                --proof ../../scripts/test_files/sp1/sp1_fibonacci.proof \
                --vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \
                --repetitions 20 \
                --proof_generator_addr 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 \
                --rpc_url http://localhost:8545 \
                --network devnet --price_estimate "custom u" --private_key 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a
Screenshot 2024-12-05 at 20 29 44

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 changed the title feat(sdk): sdk pricing feat(cli): Price Estimates in Aligned CLI Dec 4, 2024
Copy link
Collaborator

@MarcosNicolau MarcosNicolau left a comment

Choose a reason for hiding this comment

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

Working nicely!

Copy link
Collaborator

@MarcosNicolau MarcosNicolau left a comment

Choose a reason for hiding this comment

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

Other than the minor comments, everything is working correctly.

@MarcosNicolau MarcosNicolau requested a review from Oppen December 6, 2024 18:00
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.

Haven't finished reviewing yet. Left some comments for now.

batcher/aligned-sdk/src/core/constants.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/sdk.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/sdk.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/sdk.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/sdk.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/sdk.rs Show resolved Hide resolved
batcher/aligned-sdk/src/sdk.rs Outdated Show resolved Hide resolved
batcher/aligned/src/main.rs Show resolved Hide resolved
batcher/aligned/src/main.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@uri-99 uri-99 left a comment

Choose a reason for hiding this comment

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

This PR was quite difficult to follow. I think it is more about the chosen functions/variables names rather than the actual logic.

Please take more time in defining good functions and variable names. This is more important than what most people think. Code should be written as if an external person with no context wants to read it. You need to be more precise on what a function does and what a variable represents.

Better code clarity = less bugs & better maintainability.

batcher/aligned-sdk/src/core/constants.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/core/constants.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/sdk.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/sdk.rs Show resolved Hide resolved
batcher/aligned-sdk/src/sdk.rs Outdated Show resolved Hide resolved
batcher/aligned/src/main.rs Outdated Show resolved Hide resolved
batcher/aligned/src/main.rs Outdated Show resolved Hide resolved
batcher/aligned/src/main.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/core/types.rs Outdated Show resolved Hide resolved
batcher/aligned-sdk/src/sdk.rs Outdated Show resolved Hide resolved
batcher/aligned/src/main.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@uri-99 uri-99 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 way better, wip testing

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