-
Notifications
You must be signed in to change notification settings - Fork 88
LIT-3748 - Naga price support #784
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
Merged
Ansonhkg
merged 24 commits into
feat/naga-fix-bls-wasm-cleanup
from
feature/lit-3748-naga-user-set-maxprice
Feb 3, 2025
Merged
LIT-3748 - Naga price support #784
Ansonhkg
merged 24 commits into
feat/naga-fix-bls-wasm-cleanup
from
feature/lit-3748-naga-user-set-maxprice
Feb 3, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… and associated error
…sort, and retrieve prices for all product IDs in all cases - We never want to only update one price since it costs us the same amount of RPC time, and getting a subset will be error prone since the indexes won't match our product IDs anymore - Updated type signatures to be correct (the keys on the price map by node URL are arrays of prices) and added a type for ValidatorStruct with prices for simplicity - Fixed some other eslint errors - Simplified the building of the networkPriceMap - Removed the networkPrices.arr, as it is unused
…om `getSessionSigs()` - Pricing hash will be provided to the function as an argument. - Add pass-through of `product` to `getPkpSessionSigs()` and `getLitActionSessionSigs()`, and update `getPkpSessionSigs` to provide `maxPricesBytNodeUrl` to `getSessionSigs()` call
…essionSigs()` and `getPkpSessionSigs()` with `getXXXAuthContext()` methods
…nalizing sessionSigs in LitNodeClient, lit-auth-client, and pkp-base - Removed now-unused IPFS-hash-specific lit action rather than refactor the function to use authContext (it was marked deprecated already) - Log error responses when errors encountered getting signing shares from nodes properly in lit-core handling - Update `decryptFromJson` to use authContext - Refactor lit-auth-client BaseProvider to no longer use sessionSigs - Remove LitClientSessionManager interface, as it is parasitic and entwined with SessionSigs - Remove controllerXXXXX (authsig authmods and sessionSigs) and replace with AuthContext in pkp-base
…ests to use authContext - Log error stacks in tinny-operations - Use `StaticJsonRpcProvider` in tinny-environment `getFunds()` so it works in nodeJS without throwing network not found error - Export auth context helpers where sessionSig helpers used to be exported - Disable raw authSig tests until Naga supports raw authSigs for encryption_sign endpoint
…ngleResponse` to use authContext and add it to `test.ts` for consistency w/ `tests.ts`
- Remove unused types & interfaces - Add common AuthenticationContext type - Remove nested `getSessionSigsProps` key on AuthContext used by pkp-base and use the same type there as on `lit-node-client-nodejs` - Add eslint-disable-rule for `any` usages in interfaces.ts so that we can tell if we've introduced actual, new errors easily - Update types usage in `lit-node-client-nodejs` appropriately - Remove unused imports in `BaseProvider`
…kpEthers tests - Also remove from pkp-walletconnect.spec.ts - Make resourceAbilityRequests optional array on AuthenticationContext since we default it all over the place :(
…s in types.ts so we can easily see if we're introducing new errors
…` to match `test.ts`
…until AuthManager
…on logic.
- Only return networkPrices as a sorted array of {url, prices[]}
- Updated tests to work with networkPrices array structure
- Eliminate some more eslint errors
…ar to configure lit node client that is used by Tinny tests - Modify key from 'LA' to 'LIT_ACTION' on PRODUCT_IDS constant mapper for clarity
… `userMaxPrice` argument to litNodeClient
…races and VError.Info() where relevant
…parse undefined' if an attempt to run node commands has misconfigured maxNodeCount vs. threshold count
….minNodeCount and handle case where we have only claim data but no signed data (testUseValidLitActionCodeGeneratedSessionSigsToExecuteJsClaimKeys fixed) - Also re-added missing realmId in call to `getNodesForRequest()` (git merge regression)
… so we can work from a clean file in contracts-sdk
Ansonhkg
approved these changes
Feb 3, 2025
Collaborator
Ansonhkg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LFG
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR implements 'complete' price support for Naga.
Setting the max price for a request
There are two ways SDK consumers can set the max price they want to pay for a request.
decrypt,executeJsandpkpSign) have a new optional argument,userMaxPrice: bigint. If auserMaxPriceis provided when calling those methods, it will be used to calculate how much themaxPriceshould be for each node.litNodeClient.setDefaultMaxPrice(product: keyof typeof PRODUCT_IDS, price: bigint). If the LitNodeClient is configured with a specific default max price for a particular product, and nouserMaxPriceis provided when the user calls that product method, the default will be used instead.DEFAULT_MAX_PRICES, which is an array of strings that will be parsed as bigint.userMaxPrice, the LitNodeClient will throw aMaxPriceTooLowerror with context.SessionSigs are no longer consumer-facing
sessionSigsto our behaviour methods, users pass anAuthenticationContextobject, which contains the parameters to be used to generate session sigs. The LitNodeClient then uses theAuthenticationContextto create session sigs with the appropriate maxPrice for each node just before it sends the requests to the nodes.getSessionSigs()is now a private method on the LitNodeClient (_getSessionSigs()). It is not expected for SDK consumers to need to create sessionSigs during typical usage from now on.Details
{url: string, prices: bigint[] }objectsSessionSigsrelated types, and replaced them withAuthenticationContextpkp-baseandauthClientcontrollerAuthMethods,controllerSessionSigsandcontrollerAuthSigwith justAuthenticationContextmaxUserPricetopkp-base(and objects that extend from it) behavioural methods. I am keen for feedback on whether we think being able to usesetDefaultMaxPrice()on the LitNodeClient instance will be sufficient for usage of these objects. cc: @Ansonhkg @FedericoAmuratinny-operationsso that we log VErrors appropriately when tests fail, both in-line where the test failed, and at the end when showing test failure results, and include VError.info() in printed output when it exists on the error that we catch.AuthenticationContextpattern instead of usinggetSessionSigs().anydatatypes. Files likeinterfaces,types,contracts-sdkare now "clean", so if you see errors in your IDE gutter in those files you can be confident your changes have introduced them :)timestamp2Date(), which had a dynamicarequire()of thedate-and-timepackage. I couldn't find anywhere we use the function.import/orderrule in that file now that it's not being dynamically built. This should help a lot with conflicts while merging/rebasing code in that file from here on outnodeSetprovided to those nodes) is now dynamic; we use the required # of nodes for consensus that are also the cheapest priced nodes.authenticate()abstract method. I removed theextends AuthenticateOptionswhich was a pass-through for an empty interface.get-max-prices-for-node-productrunOnTargetedNodes()method that we haven't used in quite some time; this allowed us to also removegetIpfsId()from LitNodeClient - I couldn't find anywhere other thanrunOnTargetedNodes()that it was actually used, and I would think that ipfsIds should be able to be computed client-side without running a LIT action anyway (right?)Notes:
LitClientSessionManagerinterface; it was very sticky with SessionSigs, and I think it will be replaced entirely with our AuthManager patternType of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: