From b6799e86b8695e48b3951923fa31267adaadabcc Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Thu, 3 Oct 2024 12:46:32 -0300 Subject: [PATCH 1/3] refactor(docs): send funds to aligned using CLI --- docs/3_guides/0_submitting_proofs.md | 81 ++++++++++++---------------- 1 file changed, 33 insertions(+), 48 deletions(-) diff --git a/docs/3_guides/0_submitting_proofs.md b/docs/3_guides/0_submitting_proofs.md index 53db3c80d7..bb1253964a 100644 --- a/docs/3_guides/0_submitting_proofs.md +++ b/docs/3_guides/0_submitting_proofs.md @@ -58,43 +58,41 @@ This will create the ECDSA keystore file in `~/.aligned_keystore/keystore0` - If you have the EigenLayer CLI installed, the keystore can be generated following [these](https://docs.eigenlayer.xyz/eigenlayer/operator-guides/operator-installation#import-keys) instructions. The key will be stored into `~/.eigenlayer/operator_keys`. -## 2. Fund the batcher +## 2. Send funds to Aligned -To be able to send proofs to Aligned using the Batcher, the user must fund its transactions. For this, there is a simple Batcher Payment System. +To send proofs to Aligned using the Batcher, the user must first deposit some funds in Aligned to pay for the verification of his proofs. To use it, you can use the `aligned` CLI, as shown with the following example: ```bash aligned deposit-to-batcher \ ---payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 \ --rpc_url https://ethereum-holesky-rpc.publicnode.com \ ---chain holesky \ +--network holesky \ --keystore_path \ --amount 0.1ether ``` -These commands allow the usage of the following flags: +This command allows the usage of the following flags: -- `--payment_service_addr` to specify the address of the Batcher Payment Service smart contract. - `--rpc_url` to specify the rpc url to be used. -- `--chain` to specify the chain id to be used. Could be holesky or devnet. +- `--network` to specify the netowrk to be used. Can be `devnet`, `holesky-stage` or `holesky`. - `--keystore_path` the path to the keystore. - `--amount` the number of ethers to transfer to the Batcher. -- Note: `--amount` flag parameter must be with the shown format. The amount followed by the `ether` keyword to specify how many ethers you wish to deposit to the Batcher. +- Note: `--amount` flag parameter must be with the shown format, `XX.XXether`. After depositing funds, you can verify the Service has correctly received them by executing the following command: ```bash aligned get-user-balance \ ---payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 \ --rpc_url https://ethereum-holesky-rpc.publicnode.com \ +--network holesky \ --user_addr ``` These commands allow the usage of the following flags: -- `--payment_service_addr` to specify the address of the Batcher Payment Service smart contract. - `--rpc_url` to specify the rpc url to be used. +- `--network` to specify the netowrk to be used. Can be `devnet`, `holesky-stage` or `holesky`. - `--user_addr` the address of the user that funded the Batcher. ## 3. Submit your proof to the batcher @@ -108,9 +106,8 @@ Proof submission is done via the `submit` command of the Aligned CLI. The argume * `vm_program`: When the proving system involves the execution of a program in a zkVM, this argument is associated with the compiled program or some other identifier of the program. * `pub_input`: The path to the file with the public input associated with the proof. * `batcher_url`: The batcher websocket URL. -* `chain` to specify the chain id to be used. Could be holesky or devnet. +* `network` to specify the netowrk to be used. Can be `devnet`, `holesky-stage` or `holesky`. * `rpc_url`: The RPC Ethereum node URL. -* `payment_service_addr`: The Ethereum address of the Batcher Payments System contract. * `proof_generator_addr`: An optional parameter that can be used in some applications to avoid front-running. * `batch_inclusion_data_directory_path`: An optional parameter indicating the directory where to store the batcher response data. If not provided, the folder with the responses will be created in the current directory. @@ -130,9 +127,8 @@ aligned submit \ --proof_generator_addr [proof_generator_addr] \ --batch_inclusion_data_directory_path [batch_inclusion_data_directory_path] \ --keystore_path \ ---chain holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com \ ---payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 +--network holesky \ +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` **Example** @@ -145,9 +141,8 @@ aligned submit \ --vm_program ./scripts/test_files/sp1/sp1_fibonacci.elf \ --batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ ---chain holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com \ ---payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 +--network holesky \ +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` ### Risc0 proof @@ -167,9 +162,8 @@ aligned submit \ --proof_generator_addr [proof_generator_addr] \ --batch_inclusion_data_directory_path [batch_inclusion_data_directory_path] \ --keystore_path \ ---chain holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com \ ---payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 +--network holesky \ +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` **NOTE**: As said above, Aligned currently supports Risc0 proofs from `risc0-zkvm` version `v1.0.1`. For generating proofs using `cargo risc-zero` please ensure you are using `v1.0.1` or your proof will not be verified. @@ -194,9 +188,8 @@ aligned submit \ --batcher_url wss://batcher.alignedlayer.com \ --aligned_verification_data_path ~/.aligned/aligned_verification_data \ --keystore_path ~/.aligned_keystore/keystore0 \ ---chain holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com \ ---payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 +--network holesky \ +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` ### GnarkPlonkBn254, GnarkPlonkBls12_381 and Groth16Bn254 @@ -214,9 +207,8 @@ aligned submit \ --proof_generator_addr [proof_generator_addr] \ --batch_inclusion_data_directory_path [batch_inclusion_data_directory_path] \ --keystore_path \ ---chain holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com \ ---payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 +--network holesky \ +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` **Examples**: @@ -230,9 +222,8 @@ aligned submit \ --vk ./scripts/test_files/gnark_plonk_bn254_script/plonk.vk \ --batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ ---chain holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com \ ---payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 +--network holesky \ +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` ```bash @@ -244,9 +235,8 @@ aligned submit \ --vk ./scripts/test_files/gnark_plonk_bls12_381_script/plonk.vk \ --batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ ---chain holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com \ ---payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 +--network holesky \ +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` ```bash @@ -258,9 +248,8 @@ aligned submit \ --vk ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/ineq_1_groth16.vk \ --batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ ---chain holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com \ ---payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 +--network holesky \ +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` ### Halo2 KZG and Halo2 IPA @@ -279,9 +268,8 @@ aligned submit \ --batcher_url wss://batcher.alignedlayer.com \ --keystore_path \ --proof_generator_addr \ - --chain holesky \ - --rpc_url https://ethereum-holesky-rpc.publicnode.com \ - --payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 \ + --network holesky \ + --rpc_url https://ethereum-holesky-rpc.publicnode.com ``` If you are using the Halo2PlonkIpa proving system, you need to specify the `--proving_system Halo2IPA` flag. @@ -296,9 +284,8 @@ aligned submit \ --batcher_url wss://batcher.alignedlayer.com \ --keystore_path \ --proof_generator_addr \ - --chain holesky \ - --rpc_url https://ethereum-holesky-rpc.publicnode.com \ - --payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 + --network holesky \ + --rpc_url https://ethereum-holesky-rpc.publicnode.com ``` **Examples**: @@ -313,9 +300,8 @@ aligned submit \ --batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ --proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \ - --chain holesky \ - --rpc_url https://ethereum-holesky-rpc.publicnode.com \ - --payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 + --network holesky \ + --rpc_url https://ethereum-holesky-rpc.publicnode.com ``` ```bash @@ -328,7 +314,6 @@ aligned submit \ --batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ --proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \ - --chain holesky \ - --rpc_url https://ethereum-holesky-rpc.publicnode.com \ - --payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 + --network holesky \ + --rpc_url https://ethereum-holesky-rpc.publicnode.com ``` From 212c77d5309abcc2e9066f2210ec4d017b91e5fb Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:07:39 -0300 Subject: [PATCH 2/3] docs: SDK adding of new funcs --- docs/3_guides/1.2_SDK_api_reference.md | 66 +++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/docs/3_guides/1.2_SDK_api_reference.md b/docs/3_guides/1.2_SDK_api_reference.md index 9df3507a71..1b1a0a9c99 100644 --- a/docs/3_guides/1.2_SDK_api_reference.md +++ b/docs/3_guides/1.2_SDK_api_reference.md @@ -290,7 +290,7 @@ Should be used before submitting proofs to the batcher. Wallet chain id needs to wallet = wallet.with_chain_id(chain_id); ``` -### Arguments +#### Arguments - `eth_rpc_url` - The URL of the Ethereum RPC node. @@ -303,7 +303,7 @@ wallet = wallet.with_chain_id(chain_id); - `EthereumProviderError` if there is an error in the connection with the RPC provider. - `EthereumCallError` if there is an error in the Ethereum call. -## `estimate_fee` +### `estimate_fee` Estimates the fee the user would have to pay for submitting a proof to Aligned. Depending on the priority the user wants to have in the batch, the `estimate` parameter can be set. @@ -315,7 +315,7 @@ pub async fn estimate_fee( ) -> Result ``` -### Arguments +#### Arguments - `eth_rpc_url` - The URL of the Ethereum RPC node. - `estimate` - The parameter to set the priority for the proof to be included in the batch. It can be one @@ -330,7 +330,7 @@ pub async fn estimate_fee( - `EthereumProviderError` if there is an error in the connection with the RPC provider. - `EthereumCallError` if there is an error in the Ethereum call. -## `compute_max_fee` +### `compute_max_fee` Computes `max_fee` for a proof based on the number of proofs in a batch (`num_proofs_per_batch`) and number of proofs (`num_proofs`) in that batch the user would pay for i.e (`num_proofs` / `num_proofs_per_batch`). @@ -342,7 +342,7 @@ pub async fn compute_max_fee( ) -> Result ``` -### Arguments +#### Arguments - `eth_rpc_url` - The URL of the Ethereum RPC node. - `num_proofs` - The number of proofs in a batch the user would pay for. @@ -357,7 +357,7 @@ pub async fn compute_max_fee( - `EthereumProviderError` if there is an error in the connection with the RPC provider. - `EthereumCallError` if there is an error in the Ethereum call. -## `fee_per_proof` +### `fee_per_proof` Returns the `fee_per_proof` based on the current gas price for a batch compromised of `num_proofs_per_batch` i.e. (1 / `num_proofs_per_batch`). @@ -368,7 +368,7 @@ pub async fn fee_per_proof( ) -> Result ``` -### Arguments +#### Arguments - `eth_rpc_url` - The URL of the users Ethereum RPC node. - `num_proofs_per_batch` - The number of proofs within a batch. @@ -381,3 +381,55 @@ pub async fn fee_per_proof( - `EthereumProviderError` if there is an error in the connection with the RPC provider. - `EthereumCallError` if there is an error in the Ethereum call. + + +### `deposit_to_aligned` + +Funds the batcher payment service in name of the signer + +pub async fn deposit_to_aligned( + amount: U256, + signer: SignerMiddleware, LocalWallet>, + network: Network, +) -> Result { + +#### Arguments +`amount` - The amount to be paid. +`signer` - The signer middleware of the payer. +`network` - The network on which the payment will be done. + +#### Returns +The receipt of the payment transaction. + +#### Errors +`SendError` if there is an error sending the transaction. +`SubmitError` if there is an error submitting the transaction. +`PaymentFailed` if the payment failed. + + +### `get_balance_in_aligned` + +Queries a User's balance that was deposited in Aligned + +```rust +pub async fn get_balance_in_aligned( + user: Address, + eth_rpc_url: &str, + network: Network, +) -> Result { +``` + +#### Arguments + +`user` - The address of the user. +`eth_rpc_url` - The URL of the Ethereum RPC node. +`network` - The network on which the balance will be checked. + +#### Returns + +- `Result` - The balance of the user in the payment service. + +#### Errors + +- `EthereumProviderError` if there is an error in the connection with the RPC provider. +- `EthereumCallError` if there is an error in the Ethereum call. From da19601d558663422b6ccf3656b3f4f6147d94ee Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:17:59 -0300 Subject: [PATCH 3/3] fix: typos on arquitecture payment service --- docs/2_architecture/components/2_payment_service_contract.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/2_architecture/components/2_payment_service_contract.md b/docs/2_architecture/components/2_payment_service_contract.md index f03fcf5c45..b401cfde13 100644 --- a/docs/2_architecture/components/2_payment_service_contract.md +++ b/docs/2_architecture/components/2_payment_service_contract.md @@ -3,9 +3,9 @@ The Payment Service handles users payments to fund the verification of their proofs. To be able to use the batcher, a user must fund its transactions. -For this, there is a simple Batcher Payment System. +For this, there is a simple Payment Service. -The Batcher has an associated Batcher Payments smart contract, +The Batcher has an associated `Batcher Payments` smart contract, which is in charge of receiving user's payments, and it guarantees that it can only spend these funds to send users' proofs to Aligned.