Skip to content

Conversation

@spacesailor24
Copy link
Contributor

@spacesailor24 spacesailor24 commented Dec 17, 2025

Description

The main purpose of this PR is to migrate the tests from pkp-parallel-keygen to the JS SDK. These tests execution Lit Actions with varying uses of fetch, decryption, and execution time to give an example of cost for execution

  • packages/e2e/src/test-helpers/executeJs/paymentBenchmarks/paymentBenchmark.ts is the test suite the executes all of the Lit Actions
  • packages/e2e/src/test-helpers/executeJs/paymentBenchmarks/litActions/ contains the Lit Actions for each test case
  • packages/e2e/src/helper/createTestAccount.ts was updated to support providing a private key to use for the tests so a new account wasn't generated and required funding for every test run
    • Additionally, the generation of the eoaAuthContext was decoupled from the fundAccount flag for the scenario where the EOA already have sufficient funds deposited into the Ledger contract and didn't require funding

The output of running the benchmark suite looks like:

Decrypt within Lit Action
    ┌─────────┬─────────────────┬──────────┬──────────────────────┬────────────────┐
    │ (index) │ Component       │ Quantity │ Price (wei)          │ Price (tstLPX) │
    ├─────────┼─────────────────┼──────────┼──────────────────────┼────────────────┤
    │ 0       │ 'BaseAmount'    │ 3        │ '89704870974493920'  │ '0.0897048710' │
    │ 1       │ 'Broadcasts'    │ 3        │ '1794097419489876'   │ '0.0017940974' │
    │ 2       │ 'ContractCalls' │ 3        │ '8970487097449389'   │ '0.0089704871' │
    │ 3       │ 'Decrypts'      │ 3        │ '17940974194898781'  │ '0.0179409742' │
    │ 4       │ 'Fetches'       │ 3        │ '1794097419489876'   │ '0.0017940974' │
    │ 5       │ 'MemoryUsage'   │ 2198     │ '9389109828663653'   │ '0.0093891098' │
    │ 6       │ '**TOTAL**'     │ 0        │ '129593636934485495' │ '0.1295936369' │
    └─────────┴─────────────────┴──────────┴──────────────────────┴────────────────┘

Encrypt & Decrypt within Lit Action
    ┌─────────┬─────────────────┬──────────┬──────────────────────┬────────────────┐
    │ (index) │ Component       │ Quantity │ Price (wei)          │ Price (tstLPX) │
    ├─────────┼─────────────────┼──────────┼──────────────────────┼────────────────┤
    │ 0       │ 'BaseAmount'    │ 3        │ '89704870974493920'  │ '0.0897048710' │
    │ 1       │ 'Broadcasts'    │ 6        │ '3588194838979752'   │ '0.0035881948' │
    │ 2       │ 'ContractCalls' │ 3        │ '8970487097449389'   │ '0.0089704871' │
    │ 3       │ 'Decrypts'      │ 3        │ '17940974194898781'  │ '0.0179409742' │
    │ 4       │ 'Fetches'       │ 3        │ '1794097419489876'   │ '0.0017940974' │
    │ 5       │ 'MemoryUsage'   │ 2227     │ '9508716323296311'   │ '0.0095087163' │
    │ 6       │ '**TOTAL**'     │ 0        │ '131507340848608029' │ '0.1315073408' │
    └─────────┴─────────────────┴──────────┴──────────────────────┴────────────────┘

Verifiable Data Job
    ┌─────────┬───────────────┬──────────┬──────────────────────┬────────────────┐
    │ (index) │ Component     │ Quantity │ Price (wei)          │ Price (tstLPX) │
    ├─────────┼───────────────┼──────────┼──────────────────────┼────────────────┤
    │ 0       │ 'BaseAmount'  │ 3        │ '89704870974493920'  │ '0.0897048710' │
    │ 1       │ 'Broadcasts'  │ 3        │ '1794097419489876'   │ '0.0017940974' │
    │ 2       │ 'MemoryUsage' │ 11086    │ '45211254971144724'  │ '0.0452112550' │
    │ 3       │ 'Signatures'  │ 3        │ '89704870974493920'  │ '0.0897048710' │
    │ 4       │ '**TOTAL**'   │ 0        │ '226415094339622440' │ '0.2264150943' │
    └─────────┴───────────────┴──────────┴──────────────────────┴────────────────┘

Oracle Operation
    ┌─────────┬───────────────┬──────────┬──────────────────────┬────────────────┐
    │ (index) │ Component     │ Quantity │ Price (wei)          │ Price (tstLPX) │
    ├─────────┼───────────────┼──────────┼──────────────────────┼────────────────┤
    │ 0       │ 'BaseAmount'  │ 3        │ '89704870974493920'  │ '0.0897048710' │
    │ 1       │ 'Broadcasts'  │ 6        │ '3588194838979752'   │ '0.0035881948' │
    │ 2       │ 'Fetches'     │ 3        │ '1794097419489876'   │ '0.0017940974' │
    │ 3       │ 'MemoryUsage' │ 4719     │ '18838022904643635'  │ '0.0188380229' │
    │ 4       │ 'Signatures'  │ 3        │ '89704870974493920'  │ '0.0897048710' │
    │ 5       │ '**TOTAL**'   │ 0        │ '203630057112101103' │ '0.2036300571' │
    └─────────┴───────────────┴──────────┴──────────────────────┴────────────────┘

Cross-Chain Swap
    ┌─────────┬───────────────┬──────────┬──────────────────────┬────────────────┐
    │ (index) │ Component     │ Quantity │ Price (wei)          │ Price (tstLPX) │
    ├─────────┼───────────────┼──────────┼──────────────────────┼────────────────┤
    │ 0       │ 'BaseAmount'  │ 3        │ '89704870974493920'  │ '0.0897048710' │
    │ 1       │ 'Broadcasts'  │ 3        │ '1794097419489876'   │ '0.0017940974' │
    │ 2       │ 'Fetches'     │ 4        │ '2392129892653168'   │ '0.0023921299' │
    │ 3       │ 'MemoryUsage' │ 8913     │ '36778997099542335'  │ '0.0367789971' │
    │ 4       │ 'Signatures'  │ 6        │ '179409741948987840' │ '0.1794097419' │
    │ 5       │ '**TOTAL**'   │ 0        │ '310079837335167139' │ '0.3100798373' │
    └─────────┴───────────────┴──────────┴──────────────────────┴────────────────┘

GRAND TOTAL (ALL TESTS): 1001225966569984206 wei (1.0012259666 tstLPX)

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update (doc updates not included in this PR)

How Has This Been Tested?

  • Optionally specify TEST_ALICE_PRIVATE_KEY in root .env to reuse an EOA for each test run
  • Run the tests with NETWORK=naga-test pnpm test:target packages/e2e/src/tickets/payment-benchmark.spec.ts

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@spacesailor24 spacesailor24 changed the title Chore/payment benchmark tests Chore: Payment benchmarking tests Dec 17, 2025
Comment on lines +30 to +31
nativeFundingAmount: '0.8',
ledgerDepositAmount: '12',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bumped because of failing ci E2E tests running out of funds, could be reverted after @glitch003 reduces fees on naga-test

Comment on lines +43 to +45
const LIVE_NETWORK_FUNDING_AMOUNT = '0.2';
const LOCAL_NETWORK_FUNDING_AMOUNT = '1';
const LIVE_NETWORK_LEDGER_DEPOSIT_AMOUNT = '1';
const LIVE_NETWORK_LEDGER_DEPOSIT_AMOUNT = '1.2';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bumped because of failing ci E2E tests running out of funds, could be reverted after @glitch003 reduces fees on naga-test

@spacesailor24 spacesailor24 marked this pull request as ready for review December 19, 2025 03:18
Copilot AI review requested due to automatic review settings December 19, 2025 03:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates payment benchmarking tests from the pkp-parallel-keygen repository to the JS SDK. The tests execute various Lit Actions with different operations (encryption/decryption, fetch requests, data processing, signing) to benchmark execution costs and provide pricing examples.

Key changes:

  • New payment benchmark test suite executing 5 different Lit Action scenarios
  • Support for reusing test accounts across runs via private key configuration
  • Decoupled EOA auth context generation from account funding in test helpers
  • Increased funding amounts for live network testing to support benchmark execution

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/e2e/src/tickets/payment-benchmark.spec.ts Entry point for payment benchmark test suite
packages/e2e/src/test-helpers/executeJs/paymentBenchmarks/paymentBenchmark.ts Main test suite with 5 benchmark scenarios and payment detail logging
packages/e2e/src/test-helpers/executeJs/paymentBenchmarks/litActions/decryptWithinLitAction.ts Lit Action for decryption and fetch operations
packages/e2e/src/test-helpers/executeJs/paymentBenchmarks/litActions/encryptDecryptWithinLitAction.ts Lit Action for encryption/decryption within the action
packages/e2e/src/test-helpers/executeJs/paymentBenchmarks/litActions/verifiableDataJob.ts Lit Action for data processing and signing
packages/e2e/src/test-helpers/executeJs/paymentBenchmarks/litActions/oracleOperation.ts Lit Action for external data fetching and price medianization
packages/e2e/src/test-helpers/executeJs/paymentBenchmarks/litActions/crossChainSwap.ts Complex Lit Action simulating cross-chain swap with multiple signatures
packages/e2e/src/helper/createTestAccount.ts Updated to support optional private key parameter and decoupled EOA auth context from funding
packages/e2e/src/init.ts Increased funding amounts for live network testing
packages/e2e/src/helper/createTestEnv.ts Increased native funding and ledger deposit amounts
.env.sample Added documentation for optional TEST_ALICE_PRIVATE_KEY and TEST_BOB_PRIVATE_KEY

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sourceToken: 'ETH',
destToken: 'BTC',
amountIn: '1.0', // 1 ETH
userAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb', // Example address
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

This example address appears to be truncated (missing the last character for a valid Ethereum address, which should be 42 characters including '0x'). Valid Ethereum addresses have 40 hexadecimal characters after '0x'. Consider using a complete example address like '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0' or a well-known test address.

Suggested change
userAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb', // Example address
userAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0', // Example address

Copilot uses AI. Check for mistakes.
async function oracleOperation() {
// Helper function to calculate median
const median = (arr: number[]) => {
const arrSorted = arr.sort((a, b) => a - b);
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

The sorting operation here mutates the original array. This could cause unexpected side effects if the array is used elsewhere. Consider using a copy of the array by changing 'arr.sort' to '[...arr].sort' or 'arr.slice().sort()'.

Suggested change
const arrSorted = arr.sort((a, b) => a - b);
const arrSorted = [...arr].sort((a, b) => a - b);

Copilot uses AI. Check for mistakes.
});

// Parse the decrypted API key
const apiKey = JSON.parse(decryptedApiKey);
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

Unused variable apiKey.

Suggested change
const apiKey = JSON.parse(decryptedApiKey);
JSON.parse(decryptedApiKey);

Copilot uses AI. Check for mistakes.
Comment on lines +51 to +53
// Parse the decrypted API key
const apiKey = JSON.parse(decryptedApiKey);

Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

Unused variable apiKey.

Suggested change
// Parse the decrypted API key
const apiKey = JSON.parse(decryptedApiKey);

Copilot uses AI. Check for mistakes.
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.

2 participants