diff --git a/forester-utils/src/instructions/address_batch_update.rs b/forester-utils/src/instructions/address_batch_update.rs index 810dc7de08..73c247f983 100644 --- a/forester-utils/src/instructions/address_batch_update.rs +++ b/forester-utils/src/instructions/address_batch_update.rs @@ -29,6 +29,7 @@ pub struct AddressUpdateConfig { pub rpc_pool: Arc>, pub merkle_tree_pubkey: Pubkey, pub prover_url: String, + pub prover_api_key: Option, pub polling_interval: Duration, pub max_wait_time: Duration, pub ixs_per_tx: usize, @@ -39,6 +40,7 @@ async fn stream_instruction_data<'a, R: Rpc>( rpc_pool: Arc>, merkle_tree_pubkey: Pubkey, prover_url: String, + prover_api_key: Option, polling_interval: Duration, max_wait_time: Duration, leaves_hash_chains: Vec<[u8; 32]>, @@ -49,7 +51,7 @@ async fn stream_instruction_data<'a, R: Rpc>( ) -> impl Stream, ForesterUtilsError>> + Send + 'a { stream! { - let proof_client = Arc::new(ProofClient::with_config(prover_url, polling_interval, max_wait_time)); + let proof_client = Arc::new(ProofClient::with_config(prover_url, polling_interval, max_wait_time, prover_api_key)); let max_zkp_batches_per_call = calculate_max_zkp_batches_per_call(zkp_batch_size); let total_chunks = leaves_hash_chains.len().div_ceil(max_zkp_batches_per_call); @@ -324,6 +326,7 @@ pub async fn get_address_update_instruction_stream<'a, R: Rpc>( config.rpc_pool, config.merkle_tree_pubkey, config.prover_url, + config.prover_api_key, config.polling_interval, config.max_wait_time, leaves_hash_chains, diff --git a/forester-utils/src/instructions/state_batch_append.rs b/forester-utils/src/instructions/state_batch_append.rs index 823f649225..44c81e4d75 100644 --- a/forester-utils/src/instructions/state_batch_append.rs +++ b/forester-utils/src/instructions/state_batch_append.rs @@ -48,6 +48,7 @@ pub async fn get_append_instruction_stream<'a, R: Rpc>( rpc_pool: Arc>, merkle_tree_pubkey: Pubkey, prover_url: String, + prover_api_key: Option, polling_interval: Duration, max_wait_time: Duration, merkle_tree_data: ParsedMerkleTreeData, @@ -126,7 +127,7 @@ pub async fn get_append_instruction_stream<'a, R: Rpc>( } let mut all_changelogs: Vec> = Vec::new(); - let proof_client = Arc::new(ProofClient::with_config(prover_url.clone(), polling_interval, max_wait_time)); + let proof_client = Arc::new(ProofClient::with_config(prover_url.clone(), polling_interval, max_wait_time, prover_api_key.clone())); let mut futures_ordered = FuturesOrdered::new(); let mut pending_count = 0; diff --git a/forester-utils/src/instructions/state_batch_nullify.rs b/forester-utils/src/instructions/state_batch_nullify.rs index 6737ff9540..42174a4c0a 100644 --- a/forester-utils/src/instructions/state_batch_nullify.rs +++ b/forester-utils/src/instructions/state_batch_nullify.rs @@ -47,6 +47,7 @@ pub async fn get_nullify_instruction_stream<'a, R: Rpc>( rpc_pool: Arc>, merkle_tree_pubkey: Pubkey, prover_url: String, + prover_api_key: Option, polling_interval: Duration, max_wait_time: Duration, merkle_tree_data: ParsedMerkleTreeData, @@ -125,7 +126,7 @@ pub async fn get_nullify_instruction_stream<'a, R: Rpc>( } let mut all_changelogs = Vec::new(); - let proof_client = Arc::new(ProofClient::with_config(prover_url.clone(), polling_interval, max_wait_time)); + let proof_client = Arc::new(ProofClient::with_config(prover_url.clone(), polling_interval, max_wait_time, prover_api_key.clone())); let mut futures_ordered = FuturesOrdered::new(); let mut pending_count = 0; diff --git a/forester/src/cli.rs b/forester/src/cli.rs index 1e80cbaf24..0a63861ad5 100644 --- a/forester/src/cli.rs +++ b/forester/src/cli.rs @@ -34,6 +34,30 @@ pub struct StartArgs { #[arg(long, env = "FORESTER_PROVER_URL")] pub prover_url: Option, + #[arg( + long, + env = "FORESTER_PROVER_APPEND_URL", + help = "Prover URL for append operations. If not specified, uses prover_url" + )] + pub prover_append_url: Option, + + #[arg( + long, + env = "FORESTER_PROVER_UPDATE_URL", + help = "Prover URL for update operations. If not specified, uses prover_url" + )] + pub prover_update_url: Option, + + #[arg( + long, + env = "FORESTER_PROVER_ADDRESS_APPEND_URL", + help = "Prover URL for address-append operations. If not specified, uses prover_url" + )] + pub prover_address_append_url: Option, + + #[arg(long, env = "FORESTER_PROVER_API_KEY")] + pub prover_api_key: Option, + #[arg(long, env = "FORESTER_PAYER")] pub payer: Option, diff --git a/forester/src/config.rs b/forester/src/config.rs index d4ae01f1e9..452ca58259 100644 --- a/forester/src/config.rs +++ b/forester/src/config.rs @@ -35,6 +35,10 @@ pub struct ExternalServicesConfig { pub ws_rpc_url: Option, pub indexer_url: Option, pub prover_url: Option, + pub prover_append_url: Option, + pub prover_update_url: Option, + pub prover_address_append_url: Option, + pub prover_api_key: Option, pub photon_api_key: Option, pub pushgateway_url: Option, pub pagerduty_routing_key: Option, @@ -210,6 +214,19 @@ impl ForesterConfig { ws_rpc_url: args.ws_rpc_url.clone(), indexer_url: args.indexer_url.clone(), prover_url: args.prover_url.clone(), + prover_append_url: args + .prover_append_url + .clone() + .or_else(|| args.prover_url.clone()), + prover_update_url: args + .prover_update_url + .clone() + .or_else(|| args.prover_url.clone()), + prover_address_append_url: args + .prover_address_append_url + .clone() + .or_else(|| args.prover_url.clone()), + prover_api_key: args.prover_api_key.clone(), photon_api_key: args.photon_api_key.clone(), pushgateway_url: args.push_gateway_url.clone(), pagerduty_routing_key: args.pagerduty_routing_key.clone(), @@ -280,6 +297,10 @@ impl ForesterConfig { ws_rpc_url: None, indexer_url: None, prover_url: None, + prover_append_url: None, + prover_update_url: None, + prover_address_append_url: None, + prover_api_key: None, photon_api_key: None, pushgateway_url: args.push_gateway_url.clone(), pagerduty_routing_key: args.pagerduty_routing_key.clone(), diff --git a/forester/src/epoch_manager.rs b/forester/src/epoch_manager.rs index 4e6a4a618c..b6d5121749 100644 --- a/forester/src/epoch_manager.rs +++ b/forester/src/epoch_manager.rs @@ -1185,6 +1185,7 @@ impl EpochManager { } async fn process_v2(&self, epoch_info: &Epoch, tree_accounts: &TreeAccounts) -> Result { + let default_prover_url = "http://127.0.0.1:3001".to_string(); let batch_context = BatchContext { rpc_pool: self.rpc_pool.clone(), authority: self.config.payer_keypair.insecure_clone(), @@ -1193,12 +1194,25 @@ impl EpochManager { merkle_tree: tree_accounts.merkle_tree, output_queue: tree_accounts.queue, ixs_per_tx: self.config.transaction_config.batch_ixs_per_tx, - prover_url: self + prover_append_url: self .config .external_services - .prover_url + .prover_append_url .clone() - .unwrap_or_else(|| "http://127.0.0.1:3001".to_string()), + .unwrap_or_else(|| default_prover_url.clone()), + prover_update_url: self + .config + .external_services + .prover_update_url + .clone() + .unwrap_or_else(|| default_prover_url.clone()), + prover_address_append_url: self + .config + .external_services + .prover_address_append_url + .clone() + .unwrap_or_else(|| default_prover_url.clone()), + prover_api_key: self.config.external_services.prover_api_key.clone(), prover_polling_interval: Duration::from_secs(1), prover_max_wait_time: Duration::from_secs(120), ops_cache: self.ops_cache.clone(), diff --git a/forester/src/processor/v2/address.rs b/forester/src/processor/v2/address.rs index a8c2cafb7b..52477bcca5 100644 --- a/forester/src/processor/v2/address.rs +++ b/forester/src/processor/v2/address.rs @@ -27,7 +27,8 @@ where let config = AddressUpdateConfig { rpc_pool: ctx.rpc_pool.clone(), merkle_tree_pubkey: ctx.merkle_tree, - prover_url: ctx.prover_url.clone(), + prover_url: ctx.prover_address_append_url.clone(), + prover_api_key: ctx.prover_api_key.clone(), polling_interval: ctx.prover_polling_interval, max_wait_time: ctx.prover_max_wait_time, ixs_per_tx: ctx.ixs_per_tx, diff --git a/forester/src/processor/v2/common.rs b/forester/src/processor/v2/common.rs index d7790299d2..3632305682 100644 --- a/forester/src/processor/v2/common.rs +++ b/forester/src/processor/v2/common.rs @@ -40,7 +40,10 @@ pub struct BatchContext { pub merkle_tree: Pubkey, pub output_queue: Pubkey, pub ixs_per_tx: usize, - pub prover_url: String, + pub prover_append_url: String, + pub prover_update_url: String, + pub prover_address_append_url: String, + pub prover_api_key: Option, pub prover_polling_interval: Duration, pub prover_max_wait_time: Duration, pub ops_cache: Arc>, diff --git a/forester/src/processor/v2/state.rs b/forester/src/processor/v2/state.rs index e99c5439a2..9f767a3124 100644 --- a/forester/src/processor/v2/state.rs +++ b/forester/src/processor/v2/state.rs @@ -32,7 +32,8 @@ where let (stream, size) = get_nullify_instruction_stream( ctx.rpc_pool.clone(), ctx.merkle_tree, - ctx.prover_url.clone(), + ctx.prover_update_url.clone(), + ctx.prover_api_key.clone(), ctx.prover_polling_interval, ctx.prover_max_wait_time, merkle_tree_data, @@ -58,7 +59,8 @@ where let (stream, size) = get_append_instruction_stream( ctx.rpc_pool.clone(), ctx.merkle_tree, - ctx.prover_url.clone(), + ctx.prover_append_url.clone(), + ctx.prover_api_key.clone(), ctx.prover_polling_interval, ctx.prover_max_wait_time, merkle_tree_data, diff --git a/forester/tests/e2e_test.rs b/forester/tests/e2e_test.rs index 9f7d86e7d8..57bad425d9 100644 --- a/forester/tests/e2e_test.rs +++ b/forester/tests/e2e_test.rs @@ -114,13 +114,20 @@ fn get_prover_url() -> String { } } -fn get_api_key() -> Option { +fn get_photon_api_key() -> Option { match TestMode::from_env() { TestMode::Local => None, TestMode::Devnet => Some(get_env_var("PHOTON_API_KEY")), } } +fn get_prover_api_key() -> Option { + match TestMode::from_env() { + TestMode::Local => None, + TestMode::Devnet => Some(get_env_var("PROVER_API_KEY")), + } +} + fn get_forester_keypair() -> Keypair { match TestMode::from_env() { TestMode::Local => Keypair::new(), @@ -189,7 +196,11 @@ async fn e2e_test() { ws_rpc_url: Some(get_ws_rpc_url()), indexer_url: Some(get_indexer_url()), prover_url: Some(get_prover_url()), - photon_api_key: get_api_key(), + prover_append_url: None, + prover_update_url: None, + prover_address_append_url: None, + prover_api_key: get_prover_api_key(), + photon_api_key: get_photon_api_key(), pushgateway_url: None, pagerduty_routing_key: None, rpc_rate_limit: None, @@ -453,7 +464,7 @@ async fn setup_rpc_connection(forester: &Keypair) -> LightClient { let mut rpc = LightClient::new(if TestMode::from_env() == TestMode::Local { LightClientConfig::local() } else { - LightClientConfig::new(get_rpc_url(), Some(get_indexer_url()), get_api_key()) + LightClientConfig::new(get_rpc_url(), Some(get_indexer_url()), get_photon_api_key()) }) .await .unwrap(); diff --git a/forester/tests/priority_fee_test.rs b/forester/tests/priority_fee_test.rs index 1cce599015..10d050c855 100644 --- a/forester/tests/priority_fee_test.rs +++ b/forester/tests/priority_fee_test.rs @@ -38,6 +38,10 @@ async fn test_priority_fee_request() { std::env::var("FORESTER_PROVER_URL") .expect("FORESTER_PROVER_URL must be set in environment"), ), + prover_append_url: None, + prover_update_url: None, + prover_address_append_url: None, + prover_api_key: None, payer: Some( std::env::var("FORESTER_PAYER").expect("FORESTER_PAYER must be set in environment"), ), diff --git a/forester/tests/test_utils.rs b/forester/tests/test_utils.rs index 8bf48c3a40..be939a6f7d 100644 --- a/forester/tests/test_utils.rs +++ b/forester/tests/test_utils.rs @@ -84,6 +84,10 @@ pub fn forester_config() -> ForesterConfig { ws_rpc_url: Some("ws://localhost:8900".to_string()), indexer_url: Some("http://localhost:8784".to_string()), prover_url: Some("http://localhost:3001".to_string()), + prover_append_url: None, + prover_update_url: None, + prover_address_append_url: None, + prover_api_key: None, photon_api_key: None, pushgateway_url: None, pagerduty_routing_key: None, diff --git a/js/compressed-token/CHANGELOG.md b/js/compressed-token/CHANGELOG.md index 5908f2f8fc..35beb46c54 100644 --- a/js/compressed-token/CHANGELOG.md +++ b/js/compressed-token/CHANGELOG.md @@ -1,9 +1,9 @@ ## [0.22.0] -- `CreateMint` action now allows passing a non-payer mint and freeze authority. -- More efficient computebudgets for actions. -- Better DX: Parameter lookup in call signatures of CompressedTokenProgram instructions -- QoL: improved typedocs. +- `CreateMint` action now allows passing a non-payer mint and freeze authority. +- More efficient computebudgets for actions. +- Better DX: Parameter lookup in call signatures of CompressedTokenProgram instructions +- QoL: improved typedocs. ## [0.21.0] @@ -58,25 +58,23 @@ const ix = await CompressedTokenProgram.decompress({ ### Overview -- new type: TokenPoolInfo -- Instruction Changes: +- new type: TokenPoolInfo +- Instruction Changes: + - `compress`, `mintTo`, `approveAndMintTo`, `compressSplTokenAccount` now require valid TokenPoolInfo + - `decompress` now requires an array of one or more TokenPoolInfos. + - `decompress`, `transfer` now do not allow state tree overrides. - - `compress`, `mintTo`, `approveAndMintTo`, `compressSplTokenAccount` now require valid TokenPoolInfo - - `decompress` now requires an array of one or more TokenPoolInfos. - - `decompress`, `transfer` now do not allow state tree overrides. +- Action Changes: + - Removed optional tokenProgramId: PublicKey + - removed optional merkleTree: PublicKey + - removed optional outputStateTree: PublicKey + - added optional stateTreeInfo: StateTreeInfo + - added optional tokenPoolInfo: TokenPoolInfo -- Action Changes: - - - Removed optional tokenProgramId: PublicKey - - removed optional merkleTree: PublicKey - - removed optional outputStateTree: PublicKey - - added optional stateTreeInfo: StateTreeInfo - - added optional tokenPoolInfo: TokenPoolInfo - -- new instructions: - - `approve`, `revoke`: delegated transfer support. - - `addTokenPools`: you can now register additional token pool pdas. Use - this if you need very high concurrency. +- new instructions: + - `approve`, `revoke`: delegated transfer support. + - `addTokenPools`: you can now register additional token pool pdas. Use + this if you need very high concurrency. ### Why the Changes are helpful @@ -96,32 +94,32 @@ accounts. ### Changed -- improved documentation and error messages. +- improved documentation and error messages. ## [0.20.4] - 2025-02-19 ### Breaking Changes -- `selectMinCompressedTokenAccountsForTransfer` and - `selectSmartCompressedTokenAccountsForTransfer` now throw an error - if not enough accounts are found. In most cases this is not a breaking - change, because a proof request would fail anyway. This just makes the error - message more informative. +- `selectMinCompressedTokenAccountsForTransfer` and + `selectSmartCompressedTokenAccountsForTransfer` now throw an error + if not enough accounts are found. In most cases this is not a breaking + change, because a proof request would fail anyway. This just makes the error + message more informative. ### Added -- `selectSmartCompressedTokenAccountsForTransfer` and - `selectSmartCompressedTokenAccountsForTransferOrPartial` +- `selectSmartCompressedTokenAccountsForTransfer` and + `selectSmartCompressedTokenAccountsForTransferOrPartial` ### Changed -- `selectMinCompressedTokenAccountsForTransfer` and - `selectMinCompressedTokenAccountsForTransferorPartial` now accept an optional - `maxInputs` parameter, defaulting to 4. +- `selectMinCompressedTokenAccountsForTransfer` and + `selectMinCompressedTokenAccountsForTransferorPartial` now accept an optional + `maxInputs` parameter, defaulting to 4. ### Security -- N/A +- N/A For previous release notes, check: https://www.zkcompression.com/release-notes/1.0.0-mainnet-beta diff --git a/js/compressed-token/README.md b/js/compressed-token/README.md index b7ae02a3d5..ebbc5e423e 100644 --- a/js/compressed-token/README.md +++ b/js/compressed-token/README.md @@ -28,8 +28,8 @@ npm install --save \ ### Documentation and examples -- [Latest Source code](https://github.com/lightprotocol/light-protocol/tree/main/js/compressed-token) -- [Creating and sending compressed tokens](https://www.zkcompression.com/developers/typescript-client#creating-minting-and-transferring-a-compressed-token) +- [Latest Source code](https://github.com/lightprotocol/light-protocol/tree/main/js/compressed-token) +- [Creating and sending compressed tokens](https://www.zkcompression.com/developers/typescript-client#creating-minting-and-transferring-a-compressed-token) ### Getting help @@ -38,9 +38,9 @@ Check out the [Light](https://discord.gg/CYvjBgzRFP) and [Helius](https://discor When asking for help, please include: -- A detailed description of what you're trying to achieve -- Source code, if possible -- The text of any errors you encountered, with stacktraces if available +- A detailed description of what you're trying to achieve +- Source code, if possible +- The text of any errors you encountered, with stacktraces if available ### Contributing diff --git a/js/stateless.js/CHANGELOG.md b/js/stateless.js/CHANGELOG.md index 92fa94e707..0b853bd9eb 100644 --- a/js/stateless.js/CHANGELOG.md +++ b/js/stateless.js/CHANGELOG.md @@ -36,15 +36,15 @@ migrating. ### Breaking changes -- Renamed `ActiveTreeBundle` to `StateTreeInfo` -- Updated `StateTreeInfo` internal structure: `{ tree: PublicKey, queue: PublicKey, cpiContext: PublicKey | null, treeType: TreeType }` -- Replaced `pickRandomTreeAndQueue` with `selectStateTreeInfo` -- Use `selectStateTreeInfo` for tree selection instead of `pickRandomTreeAndQueue` +- Renamed `ActiveTreeBundle` to `StateTreeInfo` +- Updated `StateTreeInfo` internal structure: `{ tree: PublicKey, queue: PublicKey, cpiContext: PublicKey | null, treeType: TreeType }` +- Replaced `pickRandomTreeAndQueue` with `selectStateTreeInfo` +- Use `selectStateTreeInfo` for tree selection instead of `pickRandomTreeAndQueue` ### Deprecations -- `rpc.getValidityProof` is now deprecated, use `rpc.getValidityProofV0` instead. -- `CompressedProof` and `CompressedProofWithContext` were renamed to `ValidityProof` and `ValidityProofWithContext` +- `rpc.getValidityProof` is now deprecated, use `rpc.getValidityProofV0` instead. +- `CompressedProof` and `CompressedProofWithContext` were renamed to `ValidityProof` and `ValidityProofWithContext` ### Migration Guide @@ -163,44 +163,43 @@ Fixed a bug where we lose precision on token amounts if compressed token account ### Breaking Changes -- ActiveTreeBundle is now a tuple of `tree`, `queue`, `cpiContext`, and `treeType`. `treeType` is a new enum ensuring forward compatibility. -- Updated LUT addresses for Mainnet and Devnet: - - stateTreeLookupTableMainnet = '7i86eQs3GSqHjN47WdWLTCGMW6gde1q96G2EVnUyK2st'; - - nullifiedStateTreeLookupTableMainnet = 'H9QD4u1fG7KmkAzn2tDXhheushxFe1EcrjGGyEFXeMqT'; - - stateTreeLookupTableDevnet = '8n8rH2bFRVA6cSGNDpgqcKHCndbFCT1bXxAQG89ejVsh'; - - nullifiedStateTreeLookupTableDevnet = '5dhaJLBjnVBQFErr8oiCJmcVsx3Zj6xDekGB2zULPsnP'; +- ActiveTreeBundle is now a tuple of `tree`, `queue`, `cpiContext`, and `treeType`. `treeType` is a new enum ensuring forward compatibility. +- Updated LUT addresses for Mainnet and Devnet: + - stateTreeLookupTableMainnet = '7i86eQs3GSqHjN47WdWLTCGMW6gde1q96G2EVnUyK2st'; + - nullifiedStateTreeLookupTableMainnet = 'H9QD4u1fG7KmkAzn2tDXhheushxFe1EcrjGGyEFXeMqT'; + - stateTreeLookupTableDevnet = '8n8rH2bFRVA6cSGNDpgqcKHCndbFCT1bXxAQG89ejVsh'; + - nullifiedStateTreeLookupTableDevnet = '5dhaJLBjnVBQFErr8oiCJmcVsx3Zj6xDekGB2zULPsnP'; ### Changed -- `createRpc` can now also be called with only the `rpcEndpoint` parameter. In - this case, `compressionApiEndpoint` and `proverEndpoint` will default to the - same value. If no parameters are provided, default localnet values are used. +- `createRpc` can now also be called with only the `rpcEndpoint` parameter. In + this case, `compressionApiEndpoint` and `proverEndpoint` will default to the + same value. If no parameters are provided, default localnet values are used. ## [0.19.0] - 2025-01-20 ### Breaking Changes -- Instruction methods (eg `LightSystemProgram.createAccount` and `CompressedTokenProgram.mintTo`) now require an explicit output state tree pubkey or input account, otherwise they will throw an error. +- Instruction methods (eg `LightSystemProgram.createAccount` and `CompressedTokenProgram.mintTo`) now require an explicit output state tree pubkey or input account, otherwise they will throw an error. ### Added -- Multiple State Tree support. Allows you to pass non-default state tree pubkeys to actions and instructions. Comes out of the box with public state trees. +- Multiple State Tree support. Allows you to pass non-default state tree pubkeys to actions and instructions. Comes out of the box with public state trees. + - `pickRandomStateTreeAndQueue` + - `getLightStateTreeInfo` - - `pickRandomStateTreeAndQueue` - - `getLightStateTreeInfo` - -- createMint allows passing of freezeAuthority in action +- createMint allows passing of freezeAuthority in action ### Changed -- `createMint`action now lets you pass tokenprogramId explicitly. is backward compatible with boolean flag for t22. +- `createMint`action now lets you pass tokenprogramId explicitly. is backward compatible with boolean flag for t22. ### Deprecated -- `rpc.getValidityProof`. Now does another rpc round trip to fetch tree info. use `rpc.getValidityProofV0` and pass tree info explicitly instead. +- `rpc.getValidityProof`. Now does another rpc round trip to fetch tree info. use `rpc.getValidityProofV0` and pass tree info explicitly instead. ### Security -- N/A +- N/A For previous release notes, check: https://www.zkcompression.com/release-notes/1.0.0-mainnet-beta diff --git a/js/stateless.js/README.md b/js/stateless.js/README.md index b25fada4d2..2765b9b65b 100644 --- a/js/stateless.js/README.md +++ b/js/stateless.js/README.md @@ -32,18 +32,18 @@ For a more detailed documentation on usage, please check [the respective section For example implementations, including web and Node, refer to the respective repositories: -- [Web application example implementation](https://github.com/Lightprotocol/example-web-client) +- [Web application example implementation](https://github.com/Lightprotocol/example-web-client) -- [Node server example implementation](https://github.com/Lightprotocol/example-nodejs-client) +- [Node server example implementation](https://github.com/Lightprotocol/example-nodejs-client) ## Troubleshooting Have a question or a problem? Feel free to ask in the [Light](https://discord.gg/CYvjBgzRFP) and [Helius](https://discord.gg/Uzzf6a7zKr) developer Discord servers. Please, include the following information: -- A detailed description or context of the issue or what you are trying to achieve. -- A code example that we can use to test and debug (if possible). Use [CodeSandbox](https://codesandbox.io/p/sandbox/vanilla-ts) or any other live environment provider. -- A description or context of any errors you are encountering with stacktraces if available. +- A detailed description or context of the issue or what you are trying to achieve. +- A code example that we can use to test and debug (if possible). Use [CodeSandbox](https://codesandbox.io/p/sandbox/vanilla-ts) or any other live environment provider. +- A description or context of any errors you are encountering with stacktraces if available. ### Source Maps @@ -57,14 +57,14 @@ We provide `index.js.map` for debugging. Exclude in production: Light and ZK Compression are open source protocols and very much welcome contributions. If you have a contribution, do not hesitate to send a PR to the respective repository or discuss in the linked developer Discord servers. -- 🐞 For bugs or feature requests, please open an - [issue](https://github.com/lightprotocol/light-protocol/issues/new). -- 🔒 For security vulnerabilities, please follow the [security policy](https://github.com/Lightprotocol/light-protocol/blob/main/SECURITY.md). +- 🐞 For bugs or feature requests, please open an + [issue](https://github.com/lightprotocol/light-protocol/issues/new). +- 🔒 For security vulnerabilities, please follow the [security policy](https://github.com/Lightprotocol/light-protocol/blob/main/SECURITY.md). ## Additional Resources -- [Light Protocol Repository](https://github.com/Lightprotocol/light-protocol) -- [ZK Compression Official Documentation](https://www.zkcompression.com/) +- [Light Protocol Repository](https://github.com/Lightprotocol/light-protocol) +- [ZK Compression Official Documentation](https://www.zkcompression.com/) ## Disclaimer diff --git a/prover/client/src/proof_client.rs b/prover/client/src/proof_client.rs index 61e60295b2..89215f7d3f 100644 --- a/prover/client/src/proof_client.rs +++ b/prover/client/src/proof_client.rs @@ -51,6 +51,7 @@ pub struct ProofClient { server_address: String, polling_interval: Duration, max_wait_time: Duration, + api_key: Option, } impl ProofClient { @@ -60,6 +61,7 @@ impl ProofClient { server_address: DEFAULT_LOCAL_SERVER.to_string(), polling_interval: Duration::from_secs(DEFAULT_POLLING_INTERVAL_SECS), max_wait_time: Duration::from_secs(DEFAULT_MAX_WAIT_TIME_SECS), + api_key: None, } } @@ -68,12 +70,14 @@ impl ProofClient { server_address: String, polling_interval: Duration, max_wait_time: Duration, + api_key: Option, ) -> Self { Self { client: Client::new(), server_address, polling_interval, max_wait_time, + api_key, } } @@ -157,9 +161,16 @@ impl ProofClient { ) -> Result { let url = format!("{}{}", self.server_address, PROVE_PATH); - self.client + let mut request = self + .client .post(&url) - .header("Content-Type", "application/json") + .header("Content-Type", "application/json"); + + if let Some(api_key) = &self.api_key { + request = request.header("X-API-Key", api_key); + } + + request .body(inputs_json.to_string()) .send() .await @@ -369,7 +380,13 @@ impl ProofClient { job_id: &str, poll_count: u32, ) -> Result { - let response = self.client.get(status_url).send().await.map_err(|e| { + let mut request = self.client.get(status_url); + + if let Some(api_key) = &self.api_key { + request = request.header("X-API-Key", api_key); + } + + let response = request.send().await.map_err(|e| { error!("Failed to send status request for job {}: {}", job_id, e); ProverClientError::ProverServerError(format!("Failed to check job status: {}", e)) })?;