From 29962799f13715e6d55fd042618005237a8c3c39 Mon Sep 17 00:00:00 2001 From: Josh Long Date: Wed, 7 Feb 2024 18:16:03 -0500 Subject: [PATCH 1/7] support re connect after active node set change --- packages/core/src/lib/lit-core.ts | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/packages/core/src/lib/lit-core.ts b/packages/core/src/lib/lit-core.ts index d1610d676b..f4c8c3992d 100644 --- a/packages/core/src/lib/lit-core.ts +++ b/packages/core/src/lib/lit-core.ts @@ -301,7 +301,41 @@ export class LitCore { stakingContract.on('StateChanged', async (state: StakingStates) => { log(`New state detected: "${state}"`); if (state === StakingStates.NextValidatorSetLocked) { + log( + 'State found to be new validator set locked, checking validator set' + ); + let oldNodeUrls: string[] = [...this.config.bootstrapUrls].sort(); await this.setNewConfig(); + let currentNodeUrls: string[] = this.config.bootstrapUrls.sort(); + let delta: string[] = currentNodeUrls.filter( + (item) => oldNodeUrls.indexOf(item) > -1 + ); + // if the sets differ we reconnect. + if (delta.length > 1) { + // check if the node sets are non matching and re connect if they do not. + /* + TODO: While this covers most cases where a node may come in or out of the active + set which we will need to re attest to the execution enviorments. + The sdk currently does not know if there is an active network operation pending. + Such that the state when the request was sent will now mutate when the response is sent back. + The sdk should be able to understand its current execution enviorment and wait on an active + network request to the previous epoch's node set before changing over. + + */ + log( + 'Active validator sets changed, new validators ', + delta, + 'starting node connection' + ); + await this._runHandshakeWithBootstrapUrls().catch( + (err: NodeClientErrorV0 | NodeClientErrorV1) => { + logError( + 'Error while attempting to reconnect to nodes after epoch transition: ', + err.message + ); + } + ); + } } }); } @@ -346,7 +380,15 @@ export class LitCore { // -- handshake with each node await this.setNewConfig(); await this.listenForNewEpoch(); + await this._runHandshakeWithBootstrapUrls(); + }; + + /** + * + * @returns {Promise} + */ + _runHandshakeWithBootstrapUrls = async (): Promise => { // -- handshake with each node const requestId = this.getRequestId(); From aefd3f19e275e7d4f4b6994b6ccb530f8bfb63c1 Mon Sep 17 00:00:00 2001 From: Josh Long Date: Wed, 7 Feb 2024 18:16:10 -0500 Subject: [PATCH 2/7] fmt --- README.md | 62 +++++++++---------- apps/html/index.html | 4 +- apps/react/src/app/app.tsx | 2 +- lit.config.json | 28 ++++----- .../src/lib/constants/autogen_internal.ts | 2 +- 5 files changed, 48 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 085b89a15a..c671e5bf02 100644 --- a/README.md +++ b/README.md @@ -67,41 +67,39 @@ For usage directly in the browser with a script tag -Package | Category | Version | Download ---- | --- | --- | --- -| [@lit-protocol/lit-node-client-nodejs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client-nodejs) | ![lit-node-client-nodejs](https://img.shields.io/badge/-nodejs-2E8B57 "lit-node-client-nodejs") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/lit-node-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client) | ![lit-node-client](https://img.shields.io/badge/-universal-8A6496 "lit-node-client") | 3.1.2 | npm
Vanilla JS (UMD) - +| Package | Category | Version | Download | +| -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [@lit-protocol/lit-node-client-nodejs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client-nodejs) | ![lit-node-client-nodejs](https://img.shields.io/badge/-nodejs-2E8B57 'lit-node-client-nodejs') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/lit-node-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client) | ![lit-node-client](https://img.shields.io/badge/-universal-8A6496 'lit-node-client') | 3.1.2 | npm
Vanilla JS (UMD) | If you're a tech-savvy user and wish to utilize only specific submodules that our main module relies upon, you can find individual packages listed below. This way, you can import only the necessary packages that cater to your specific use case:: - -Package | Category | Version | Download ---- | --- | --- | --- -| [@lit-protocol/access-control-conditions](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/access-control-conditions) | ![access-control-conditions](https://img.shields.io/badge/-universal-8A6496 "access-control-conditions") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/auth-helpers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-helpers) | ![auth-helpers](https://img.shields.io/badge/-universal-8A6496 "auth-helpers") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/bls-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/bls-sdk) | ![bls-sdk](https://img.shields.io/badge/-universal-8A6496 "bls-sdk") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/constants](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/constants) | ![constants](https://img.shields.io/badge/-universal-8A6496 "constants") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/contracts-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/contracts-sdk) | ![contracts-sdk](https://img.shields.io/badge/-universal-8A6496 "contracts-sdk") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/core](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/core) | ![core](https://img.shields.io/badge/-universal-8A6496 "core") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/crypto](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/crypto) | ![crypto](https://img.shields.io/badge/-universal-8A6496 "crypto") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/ecdsa-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/ecdsa-sdk) | ![ecdsa-sdk](https://img.shields.io/badge/-universal-8A6496 "ecdsa-sdk") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/encryption](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/encryption) | ![encryption](https://img.shields.io/badge/-universal-8A6496 "encryption") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/lit-third-party-libs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-third-party-libs) | ![lit-third-party-libs](https://img.shields.io/badge/-universal-8A6496 "lit-third-party-libs") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/logger](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/logger) | ![logger](https://img.shields.io/badge/-universal-8A6496 "logger") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/misc](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc) | ![misc](https://img.shields.io/badge/-universal-8A6496 "misc") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/nacl](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/nacl) | ![nacl](https://img.shields.io/badge/-universal-8A6496 "nacl") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/pkp-base](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-base) | ![pkp-base](https://img.shields.io/badge/-universal-8A6496 "pkp-base") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/pkp-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-client) | ![pkp-client](https://img.shields.io/badge/-universal-8A6496 "pkp-client") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/pkp-cosmos](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-cosmos) | ![pkp-cosmos](https://img.shields.io/badge/-universal-8A6496 "pkp-cosmos") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/pkp-ethers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-ethers) | ![pkp-ethers](https://img.shields.io/badge/-universal-8A6496 "pkp-ethers") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/pkp-sui](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-sui) | ![pkp-sui](https://img.shields.io/badge/-universal-8A6496 "pkp-sui") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/pkp-walletconnect](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-walletconnect) | ![pkp-walletconnect](https://img.shields.io/badge/-universal-8A6496 "pkp-walletconnect") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/sev-snp-utils-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/sev-snp-utils-sdk) | ![sev-snp-utils-sdk](https://img.shields.io/badge/-universal-8A6496 "sev-snp-utils-sdk") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/types](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/types) | ![types](https://img.shields.io/badge/-universal-8A6496 "types") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/uint8arrays](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/uint8arrays) | ![uint8arrays](https://img.shields.io/badge/-universal-8A6496 "uint8arrays") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/auth-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-browser) | ![auth-browser](https://img.shields.io/badge/-browser-E98869 "auth-browser") | 3.1.2 | npm
Vanilla JS (UMD) -| [@lit-protocol/misc-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc-browser) | ![misc-browser](https://img.shields.io/badge/-browser-E98869 "misc-browser") | 3.1.2 | npm
Vanilla JS (UMD) +| Package | Category | Version | Download | +| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [@lit-protocol/access-control-conditions](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/access-control-conditions) | ![access-control-conditions](https://img.shields.io/badge/-universal-8A6496 'access-control-conditions') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/auth-helpers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-helpers) | ![auth-helpers](https://img.shields.io/badge/-universal-8A6496 'auth-helpers') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/bls-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/bls-sdk) | ![bls-sdk](https://img.shields.io/badge/-universal-8A6496 'bls-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/constants](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/constants) | ![constants](https://img.shields.io/badge/-universal-8A6496 'constants') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/contracts-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/contracts-sdk) | ![contracts-sdk](https://img.shields.io/badge/-universal-8A6496 'contracts-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/core](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/core) | ![core](https://img.shields.io/badge/-universal-8A6496 'core') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/crypto](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/crypto) | ![crypto](https://img.shields.io/badge/-universal-8A6496 'crypto') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/ecdsa-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/ecdsa-sdk) | ![ecdsa-sdk](https://img.shields.io/badge/-universal-8A6496 'ecdsa-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/encryption](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/encryption) | ![encryption](https://img.shields.io/badge/-universal-8A6496 'encryption') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/lit-third-party-libs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-third-party-libs) | ![lit-third-party-libs](https://img.shields.io/badge/-universal-8A6496 'lit-third-party-libs') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/logger](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/logger) | ![logger](https://img.shields.io/badge/-universal-8A6496 'logger') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/misc](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc) | ![misc](https://img.shields.io/badge/-universal-8A6496 'misc') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/nacl](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/nacl) | ![nacl](https://img.shields.io/badge/-universal-8A6496 'nacl') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/pkp-base](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-base) | ![pkp-base](https://img.shields.io/badge/-universal-8A6496 'pkp-base') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/pkp-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-client) | ![pkp-client](https://img.shields.io/badge/-universal-8A6496 'pkp-client') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/pkp-cosmos](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-cosmos) | ![pkp-cosmos](https://img.shields.io/badge/-universal-8A6496 'pkp-cosmos') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/pkp-ethers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-ethers) | ![pkp-ethers](https://img.shields.io/badge/-universal-8A6496 'pkp-ethers') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/pkp-sui](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-sui) | ![pkp-sui](https://img.shields.io/badge/-universal-8A6496 'pkp-sui') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/pkp-walletconnect](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-walletconnect) | ![pkp-walletconnect](https://img.shields.io/badge/-universal-8A6496 'pkp-walletconnect') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/sev-snp-utils-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/sev-snp-utils-sdk) | ![sev-snp-utils-sdk](https://img.shields.io/badge/-universal-8A6496 'sev-snp-utils-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/types](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/types) | ![types](https://img.shields.io/badge/-universal-8A6496 'types') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/uint8arrays](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/uint8arrays) | ![uint8arrays](https://img.shields.io/badge/-universal-8A6496 'uint8arrays') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/auth-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-browser) | ![auth-browser](https://img.shields.io/badge/-browser-E98869 'auth-browser') | 3.1.2 | npm
Vanilla JS (UMD) | +| [@lit-protocol/misc-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc-browser) | ![misc-browser](https://img.shields.io/badge/-browser-E98869 'misc-browser') | 3.1.2 | npm
Vanilla JS (UMD) | diff --git a/apps/html/index.html b/apps/html/index.html index eee446ce2e..ec5a415de9 100644 --- a/apps/html/index.html +++ b/apps/html/index.html @@ -1,4 +1,4 @@ - + @@ -62,7 +62,7 @@ - (HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Tue, 06 Feb 2024 21:02:40 GMT + (HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Wed, 07 Feb 2024 22:19:11 GMT diff --git a/apps/react/src/app/app.tsx b/apps/react/src/app/app.tsx index dd9ad5ac5e..50852ec30b 100644 --- a/apps/react/src/app/app.tsx +++ b/apps/react/src/app/app.tsx @@ -1879,7 +1879,7 @@ pre { `, }} /> - (REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Tue, 06 Feb 2024 21:02:41 GMT + (REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Wed, 07 Feb 2024 22:19:11 GMT
diff --git a/lit.config.json b/lit.config.json index 707f9afc9c..343774b687 100644 --- a/lit.config.json +++ b/lit.config.json @@ -46,9 +46,9 @@ "debug": true, "sevAttestation": false, "CONTROLLER_AUTHSIG": { - "sig": "0x8234b6ab642c2f8d2edbd0adf7fafa25355c972bf5a5071035e4aad45eeba5f405ffbac757b07b8c9cbd073bc3589cad40af87373fa2a98278f45f3033a366b11b", + "sig": "0xa9307d3af0d7fbaebb9997405b85ee266d2aaffdee18a940301307b6123d661531a27d07ed4e7dc4cb9a9682a6608ab52a20ae3cebaab0811e7be42239ca45311b", "derivedVia": "web3.eth.personal.sign", - "signedMessage": "localhost wants you to sign in with your Ethereum account:\n0xeF71c2604f17Ec6Fc13409DF24EfdC440D240d37\n\nThis is a test statement. You can put anything you want here.\n\nURI: https://localhost/login\nVersion: 1\nChain ID: 1\nNonce: 0x1f89d12f7313557abbe9ef60f6cdb2fb3d276a05609dbf984f5ab881fa837b33\nIssued At: 2024-02-06T21:34:17.641Z\nExpiration Time: 2024-02-06T22:34:17.635Z", + "signedMessage": "localhost wants you to sign in with your Ethereum account:\n0xeF71c2604f17Ec6Fc13409DF24EfdC440D240d37\n\nThis is a test statement. You can put anything you want here.\n\nURI: https://localhost/login\nVersion: 1\nChain ID: 1\nNonce: 0xc34b7a10d2e99b93ec6976e42287bad2db18b81431ab39e1751f44cd82a83b61\nIssued At: 2024-02-07T22:49:11.088Z\nExpiration Time: 2024-02-07T23:49:11.083Z", "address": "0xeF71c2604f17Ec6Fc13409DF24EfdC440D240d37" }, "CONTROLLER_WALLET": { @@ -59,8 +59,8 @@ "_events": [], "_emitted": { "block": -2, - "t:0x24fc5489c0e792f4975646d89f3c96eccd621dcb688fdb97e06d5c45d1057e7e": 1711201, - "t:0x5690c38801ac95e7e14f5ea60e36cab6f91ba1314345b2c0bcc57878c27a9078": 1711204 + "t:0x3caf69c3067b37a6de80553c7fb79d04c4ca80bf9391d4eb19ae20250370628e": 1719289, + "t:0x3bd36a3b59f1f504eab0869f98be9bce1c4b0904fd95f0d18ccdb83ad660440f": 1719290 }, "disableCcipRead": false, "formatter": { @@ -77,15 +77,15 @@ }, "anyNetwork": false, "_networkPromise": {}, - "_maxInternalBlockNumber": 1711203, + "_maxInternalBlockNumber": 1719288, "_lastBlockNumber": -2, "_maxFilterBlockRange": 10, "_pollingInterval": 4000, - "_fastQueryDate": 1707255280186, + "_fastQueryDate": 1707346152736, "connection": { "url": "https://chain-rpc.litprotocol.com/http" }, - "_nextId": 75, + "_nextId": 73, "_eventLoopCache": { "detectNetwork": null, "eth_chainId": null, @@ -96,22 +96,22 @@ "name": "unknown" }, "_internalBlockNumber": {}, - "_fastBlockNumber": 1711203, + "_fastBlockNumber": 1719288, "_fastBlockNumberPromise": {} } }, "PKP_INFO": { - "tokenId": "0x6cafa5604d3dac3ed39533bd399609d15553e5063cf699432477d9c35784bb2d", - "publicKey": "0439068de07bcc4fed3a1192a7d3395b3834c71fb7f5dfd78c9e658cb3ad7a4c243960e7bc009cb7c47cbfced47d64b63361e61c506b2ddba3a73f1de4a41753d7", - "ethAddress": "0x3C7da8933788e1a293CA76Cb65B21174475e4A51" + "tokenId": "0x56eddc026ffe0a196d0cd52f89099c75064aee4dfb47b018361659f35b9b941b", + "publicKey": "04f824bcb46d9a2bc44a15f0ecfb2a00bf793d5d1133cf6ba4341ad9648d362fad4ea78c2003dd79e12f5f576ad889bd81d393841c75d8aa4e56fbca4e3cca2bc1", + "ethAddress": "0xb65e59Ccf736072c67c0cbd7b76d275732F0A9BD" }, "AUTH_METHOD_PKP_INFO": { - "publicKey": "04097dfb08502ed5a3217d04323ab86c3922bebe09a8917e226cb8664884c6bd31d2cd7c2ba4de9ea029b21280454473e78e596986a6bf981b867b62404971c12f", - "ethAddress": "0x577Bd2bF2069129013b8922dE2e02a28fe08c11f", + "publicKey": "048970ced45d315209a08927cb4b4b02fef41dc4c119e948d5a28081297223d8ea91010781854d2505341c891598641f0806888249d7d83a7df657cc8152549438", + "ethAddress": "0x0Df70921D2a2E2378E9B023c31FEDdb6D5a5b19B", "authMethod": { "authMethodId": "0x170d13600caea2933912f39a0334eca3d22e472be203f937c4bad0213d92ed71", "authMethodType": 1 } } } -} \ No newline at end of file +} diff --git a/packages/constants/src/lib/constants/autogen_internal.ts b/packages/constants/src/lib/constants/autogen_internal.ts index 8f4cf6d176..e36bd9fc2b 100644 --- a/packages/constants/src/lib/constants/autogen_internal.ts +++ b/packages/constants/src/lib/constants/autogen_internal.ts @@ -1,4 +1,4 @@ -// Last Modified: 2024-02-06 21:00:54 +// Last Modified: 2024-02-07 22:17:38 // This file is auto-generated by tools/scripts/gen-internal-dev.mjs export const INTERNAL_DEV = [ 'https://167.114.17.204:443', From 1055b8ebcc6cf18726bd990e9fdfbc19695a2ba9 Mon Sep 17 00:00:00 2001 From: Josh Long Date: Thu, 8 Feb 2024 10:28:08 -0500 Subject: [PATCH 3/7] pr review --- README.md | 62 ++++++++++--------- apps/html/index.html | 4 +- apps/react/src/app/app.tsx | 2 +- .../src/lib/constants/autogen_internal.ts | 2 +- packages/core/src/lib/lit-core.ts | 28 +++++---- 5 files changed, 52 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index c671e5bf02..085b89a15a 100644 --- a/README.md +++ b/README.md @@ -67,39 +67,41 @@ For usage directly in the browser with a script tag -| Package | Category | Version | Download | -| -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [@lit-protocol/lit-node-client-nodejs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client-nodejs) | ![lit-node-client-nodejs](https://img.shields.io/badge/-nodejs-2E8B57 'lit-node-client-nodejs') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/lit-node-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client) | ![lit-node-client](https://img.shields.io/badge/-universal-8A6496 'lit-node-client') | 3.1.2 | npm
Vanilla JS (UMD) | +Package | Category | Version | Download +--- | --- | --- | --- +| [@lit-protocol/lit-node-client-nodejs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client-nodejs) | ![lit-node-client-nodejs](https://img.shields.io/badge/-nodejs-2E8B57 "lit-node-client-nodejs") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/lit-node-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client) | ![lit-node-client](https://img.shields.io/badge/-universal-8A6496 "lit-node-client") | 3.1.2 | npm
Vanilla JS (UMD) + If you're a tech-savvy user and wish to utilize only specific submodules that our main module relies upon, you can find individual packages listed below. This way, you can import only the necessary packages that cater to your specific use case:: -| Package | Category | Version | Download | -| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [@lit-protocol/access-control-conditions](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/access-control-conditions) | ![access-control-conditions](https://img.shields.io/badge/-universal-8A6496 'access-control-conditions') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/auth-helpers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-helpers) | ![auth-helpers](https://img.shields.io/badge/-universal-8A6496 'auth-helpers') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/bls-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/bls-sdk) | ![bls-sdk](https://img.shields.io/badge/-universal-8A6496 'bls-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/constants](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/constants) | ![constants](https://img.shields.io/badge/-universal-8A6496 'constants') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/contracts-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/contracts-sdk) | ![contracts-sdk](https://img.shields.io/badge/-universal-8A6496 'contracts-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/core](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/core) | ![core](https://img.shields.io/badge/-universal-8A6496 'core') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/crypto](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/crypto) | ![crypto](https://img.shields.io/badge/-universal-8A6496 'crypto') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/ecdsa-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/ecdsa-sdk) | ![ecdsa-sdk](https://img.shields.io/badge/-universal-8A6496 'ecdsa-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/encryption](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/encryption) | ![encryption](https://img.shields.io/badge/-universal-8A6496 'encryption') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/lit-third-party-libs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-third-party-libs) | ![lit-third-party-libs](https://img.shields.io/badge/-universal-8A6496 'lit-third-party-libs') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/logger](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/logger) | ![logger](https://img.shields.io/badge/-universal-8A6496 'logger') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/misc](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc) | ![misc](https://img.shields.io/badge/-universal-8A6496 'misc') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/nacl](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/nacl) | ![nacl](https://img.shields.io/badge/-universal-8A6496 'nacl') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-base](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-base) | ![pkp-base](https://img.shields.io/badge/-universal-8A6496 'pkp-base') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-client) | ![pkp-client](https://img.shields.io/badge/-universal-8A6496 'pkp-client') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-cosmos](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-cosmos) | ![pkp-cosmos](https://img.shields.io/badge/-universal-8A6496 'pkp-cosmos') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-ethers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-ethers) | ![pkp-ethers](https://img.shields.io/badge/-universal-8A6496 'pkp-ethers') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-sui](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-sui) | ![pkp-sui](https://img.shields.io/badge/-universal-8A6496 'pkp-sui') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-walletconnect](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-walletconnect) | ![pkp-walletconnect](https://img.shields.io/badge/-universal-8A6496 'pkp-walletconnect') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/sev-snp-utils-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/sev-snp-utils-sdk) | ![sev-snp-utils-sdk](https://img.shields.io/badge/-universal-8A6496 'sev-snp-utils-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/types](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/types) | ![types](https://img.shields.io/badge/-universal-8A6496 'types') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/uint8arrays](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/uint8arrays) | ![uint8arrays](https://img.shields.io/badge/-universal-8A6496 'uint8arrays') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/auth-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-browser) | ![auth-browser](https://img.shields.io/badge/-browser-E98869 'auth-browser') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/misc-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc-browser) | ![misc-browser](https://img.shields.io/badge/-browser-E98869 'misc-browser') | 3.1.2 | npm
Vanilla JS (UMD) | + +Package | Category | Version | Download +--- | --- | --- | --- +| [@lit-protocol/access-control-conditions](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/access-control-conditions) | ![access-control-conditions](https://img.shields.io/badge/-universal-8A6496 "access-control-conditions") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/auth-helpers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-helpers) | ![auth-helpers](https://img.shields.io/badge/-universal-8A6496 "auth-helpers") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/bls-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/bls-sdk) | ![bls-sdk](https://img.shields.io/badge/-universal-8A6496 "bls-sdk") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/constants](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/constants) | ![constants](https://img.shields.io/badge/-universal-8A6496 "constants") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/contracts-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/contracts-sdk) | ![contracts-sdk](https://img.shields.io/badge/-universal-8A6496 "contracts-sdk") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/core](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/core) | ![core](https://img.shields.io/badge/-universal-8A6496 "core") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/crypto](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/crypto) | ![crypto](https://img.shields.io/badge/-universal-8A6496 "crypto") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/ecdsa-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/ecdsa-sdk) | ![ecdsa-sdk](https://img.shields.io/badge/-universal-8A6496 "ecdsa-sdk") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/encryption](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/encryption) | ![encryption](https://img.shields.io/badge/-universal-8A6496 "encryption") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/lit-third-party-libs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-third-party-libs) | ![lit-third-party-libs](https://img.shields.io/badge/-universal-8A6496 "lit-third-party-libs") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/logger](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/logger) | ![logger](https://img.shields.io/badge/-universal-8A6496 "logger") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/misc](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc) | ![misc](https://img.shields.io/badge/-universal-8A6496 "misc") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/nacl](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/nacl) | ![nacl](https://img.shields.io/badge/-universal-8A6496 "nacl") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-base](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-base) | ![pkp-base](https://img.shields.io/badge/-universal-8A6496 "pkp-base") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-client) | ![pkp-client](https://img.shields.io/badge/-universal-8A6496 "pkp-client") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-cosmos](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-cosmos) | ![pkp-cosmos](https://img.shields.io/badge/-universal-8A6496 "pkp-cosmos") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-ethers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-ethers) | ![pkp-ethers](https://img.shields.io/badge/-universal-8A6496 "pkp-ethers") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-sui](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-sui) | ![pkp-sui](https://img.shields.io/badge/-universal-8A6496 "pkp-sui") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-walletconnect](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-walletconnect) | ![pkp-walletconnect](https://img.shields.io/badge/-universal-8A6496 "pkp-walletconnect") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/sev-snp-utils-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/sev-snp-utils-sdk) | ![sev-snp-utils-sdk](https://img.shields.io/badge/-universal-8A6496 "sev-snp-utils-sdk") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/types](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/types) | ![types](https://img.shields.io/badge/-universal-8A6496 "types") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/uint8arrays](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/uint8arrays) | ![uint8arrays](https://img.shields.io/badge/-universal-8A6496 "uint8arrays") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/auth-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-browser) | ![auth-browser](https://img.shields.io/badge/-browser-E98869 "auth-browser") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/misc-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc-browser) | ![misc-browser](https://img.shields.io/badge/-browser-E98869 "misc-browser") | 3.1.2 | npm
Vanilla JS (UMD) diff --git a/apps/html/index.html b/apps/html/index.html index ec5a415de9..a4ff547f90 100644 --- a/apps/html/index.html +++ b/apps/html/index.html @@ -1,4 +1,4 @@ - + @@ -62,7 +62,7 @@ - (HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Wed, 07 Feb 2024 22:19:11 GMT + (HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Thu, 08 Feb 2024 15:20:37 GMT diff --git a/apps/react/src/app/app.tsx b/apps/react/src/app/app.tsx index 50852ec30b..fc1557f64a 100644 --- a/apps/react/src/app/app.tsx +++ b/apps/react/src/app/app.tsx @@ -1879,7 +1879,7 @@ pre { `, }} /> - (REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Wed, 07 Feb 2024 22:19:11 GMT + (REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Thu, 08 Feb 2024 15:20:37 GMT
diff --git a/packages/constants/src/lib/constants/autogen_internal.ts b/packages/constants/src/lib/constants/autogen_internal.ts index e36bd9fc2b..06d273983e 100644 --- a/packages/constants/src/lib/constants/autogen_internal.ts +++ b/packages/constants/src/lib/constants/autogen_internal.ts @@ -1,4 +1,4 @@ -// Last Modified: 2024-02-07 22:17:38 +// Last Modified: 2024-02-08 15:19:00 // This file is auto-generated by tools/scripts/gen-internal-dev.mjs export const INTERNAL_DEV = [ 'https://167.114.17.204:443', diff --git a/packages/core/src/lib/lit-core.ts b/packages/core/src/lib/lit-core.ts index f4c8c3992d..0173eabc61 100644 --- a/packages/core/src/lib/lit-core.ts +++ b/packages/core/src/lib/lit-core.ts @@ -304,11 +304,11 @@ export class LitCore { log( 'State found to be new validator set locked, checking validator set' ); - let oldNodeUrls: string[] = [...this.config.bootstrapUrls].sort(); + const oldNodeUrls: string[] = [...this.config.bootstrapUrls].sort(); await this.setNewConfig(); - let currentNodeUrls: string[] = this.config.bootstrapUrls.sort(); - let delta: string[] = currentNodeUrls.filter( - (item) => oldNodeUrls.indexOf(item) > -1 + const currentNodeUrls: string[] = this.config.bootstrapUrls.sort(); + const delta: string[] = currentNodeUrls.filter((item) => + oldNodeUrls.includes(item) ); // if the sets differ we reconnect. if (delta.length > 1) { @@ -327,14 +327,15 @@ export class LitCore { delta, 'starting node connection' ); - await this._runHandshakeWithBootstrapUrls().catch( - (err: NodeClientErrorV0 | NodeClientErrorV1) => { - logError( - 'Error while attempting to reconnect to nodes after epoch transition: ', - err.message - ); - } - ); + this.connectedNodes = + await this._runHandshakeWithBootstrapUrls().catch( + (err: NodeClientErrorV0 | NodeClientErrorV1) => { + logError( + 'Error while attempting to reconnect to nodes after epoch transition: ', + err.message + ); + } + ); } } }); @@ -392,6 +393,9 @@ export class LitCore { // -- handshake with each node const requestId = this.getRequestId(); + // reset connectedNodes for the new handshake operation + this.connectedNodes = new Set(); + if (this.config.bootstrapUrls.length <= 0) { throwError({ message: `Failed to get bootstrapUrls for network ${this.config.litNetwork}`, From 2546769af1be9821c03d5d1effc09779a9286c76 Mon Sep 17 00:00:00 2001 From: Josh Long Date: Thu, 8 Feb 2024 16:03:23 -0500 Subject: [PATCH 4/7] wip add timestamp on handshake with nodes --- packages/core/src/lib/lit-core.ts | 4 +++- .../src/lib/lit-node-client-nodejs.ts | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/core/src/lib/lit-core.ts b/packages/core/src/lib/lit-core.ts index 8952cddb44..92db7ffb1e 100644 --- a/packages/core/src/lib/lit-core.ts +++ b/packages/core/src/lib/lit-core.ts @@ -82,6 +82,7 @@ export class LitCore { networkPubKeySet: string | null; hdRootPubkeys: string[] | null; latestBlockhash: string | null; + lastblockHashRetrieved: number | null; // ========== Constructor ========== constructor(args: any[LitNodeClientConfig | CustomNetwork | any]) { @@ -151,6 +152,7 @@ export class LitCore { this.networkPubKeySet = null; this.hdRootPubkeys = null; this.latestBlockhash = null; + this.lastblockHashRetrieved = null; // -- set bootstrapUrls to match the network litNetwork unless it's set to custom this.setCustomBootstrapUrls(); @@ -499,7 +501,7 @@ export class LitCore { errorCode: LIT_ERROR.INVALID_ETH_BLOCKHASH.name, }); } - + this.lastblockHashRetrieved = Date.now(); this.ready = true; log( diff --git a/packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts b/packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts index 0e84b309f5..8e70fbbdbe 100644 --- a/packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts +++ b/packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts @@ -490,7 +490,13 @@ export class LitNodeClientNodeJs extends LitCore { return LitNodeClientNodeJs.getExpiration(); }; - getLatestBlockhash = () => { + + /** + * returns the latest block hash. + * will call {@link connect} if the block hash is expired + * @returns {Promise} latest block hash from `handhsake` with the lit network. + */ + getLatestBlockhash = async (): Promise => { return this.latestBlockhash; }; From 19c44fb6d7a635a2623d37ebc949b9677fbf9a60 Mon Sep 17 00:00:00 2001 From: Josh Long Date: Thu, 8 Feb 2024 18:50:30 -0500 Subject: [PATCH 5/7] update latest block hash to refresh aftrer expiration --- .../test-block-has-update-after-exp.mjs | 33 +++++++++++++++++++ e2e-nodejs/loader.mjs | 2 +- .../src/lib/lit-node-client-nodejs.ts | 23 ++++++++++--- 3 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 e2e-nodejs/group-latest-blockhash-update/test-block-has-update-after-exp.mjs diff --git a/e2e-nodejs/group-latest-blockhash-update/test-block-has-update-after-exp.mjs b/e2e-nodejs/group-latest-blockhash-update/test-block-has-update-after-exp.mjs new file mode 100644 index 0000000000..af77926980 --- /dev/null +++ b/e2e-nodejs/group-latest-blockhash-update/test-block-has-update-after-exp.mjs @@ -0,0 +1,33 @@ +import path from 'path'; +import { success, fail, testThis } from '../../tools/scripts/utils.mjs'; +import * as LitJsSdk from '@lit-protocol/lit-node-client'; +import { LocalStorage } from 'node-localstorage'; + +export async function main() { + const client = new LitNodeClient({ + litNetwork: globalThis.LitCI.network, + debug: globalThis.LitCI.debug, + minNodeCount: globalThis.LitCI.minNodeCount, + checkNodeAttestation: globalThis.LitCI.sevAttestation, + storageProvider: { + provider: new LocalStorage('./storage.test.db'), + }, + }); + + await client.connect(); + let blockhash = await client.getLatestBlockhash(); + await Promise.resolve( + new Promise((resolve, reject) => { + setTimeout(resolve, 40_000); + }) + ); + let updatedBlockhash = await client.getLatestBlockhash(); + + if (blockhash === updatedBlockhash) { + fail('block hash should be updated from handshake'); + } + console.log('block hashes: ', blockhash, updatedBlockhash); + return success('block hash updates after expiration period'); +} + +await testThis({ name: path.basename(import.meta.url), fn: main }); diff --git a/e2e-nodejs/loader.mjs b/e2e-nodejs/loader.mjs index a20fa72724..b106db4e61 100644 --- a/e2e-nodejs/loader.mjs +++ b/e2e-nodejs/loader.mjs @@ -35,7 +35,7 @@ if (loadEnv) { }); await litNodeClient.connect(); - let nonce = litNodeClient.getLatestBlockhash(); + let nonce = await litNodeClient.getLatestBlockhash(); console.log('GENERATED NONCE: ', nonce); const domain = 'localhost'; diff --git a/packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts b/packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts index 8e70fbbdbe..1c3c00995e 100644 --- a/packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts +++ b/packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts @@ -269,7 +269,7 @@ export class LitNodeClientNodeJs extends LitCore { throw new Error('Failed to verify capabilities for resource'); } - let nonce = this.getLatestBlockhash(); + let nonce = await this.getLatestBlockhash(); // -- get auth sig let siweMessage = new siwe.SiweMessage({ @@ -490,14 +490,29 @@ export class LitNodeClientNodeJs extends LitCore { return LitNodeClientNodeJs.getExpiration(); }; - /** * returns the latest block hash. - * will call {@link connect} if the block hash is expired + * will call refresh if the block hash is expired * @returns {Promise} latest block hash from `handhsake` with the lit network. */ getLatestBlockhash = async (): Promise => { - return this.latestBlockhash; + if (!this.ready) { + logError('Client not connected, remember to call connect'); + throwError({ + message: 'Client not connected', + errorKind: LIT_ERROR.LIT_NODE_CLIENT_NOT_READY_ERROR.kind, + errorCode: LIT_ERROR.LIT_NODE_CLIENT_NOT_READY_ERROR.code, + }); + } + + if (Date.now() - this.lastblockHashRetrieved! >= 30_000) { + await this._runHandshakeWithBootstrapUrls().catch((err: any) => { + logError('errror while attempting to update block hash ', err); + }); + } + + // we are confident in this value being non null so we return + return this.latestBlockhash!; }; /** From 490c2f800c03a27a19569bec3b92f3c598fa0e64 Mon Sep 17 00:00:00 2001 From: Josh Long Date: Thu, 8 Feb 2024 18:50:59 -0500 Subject: [PATCH 6/7] fix test --- .../test-block-has-update-after-exp.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-nodejs/group-latest-blockhash-update/test-block-has-update-after-exp.mjs b/e2e-nodejs/group-latest-blockhash-update/test-block-has-update-after-exp.mjs index af77926980..1ba9d82972 100644 --- a/e2e-nodejs/group-latest-blockhash-update/test-block-has-update-after-exp.mjs +++ b/e2e-nodejs/group-latest-blockhash-update/test-block-has-update-after-exp.mjs @@ -24,7 +24,7 @@ export async function main() { let updatedBlockhash = await client.getLatestBlockhash(); if (blockhash === updatedBlockhash) { - fail('block hash should be updated from handshake'); + return fail('block hash should be updated from handshake'); } console.log('block hashes: ', blockhash, updatedBlockhash); return success('block hash updates after expiration period'); From 4fdc534d0fb49e38c7919c77106f369a729cccf1 Mon Sep 17 00:00:00 2001 From: Josh Long Date: Thu, 8 Feb 2024 18:52:05 -0500 Subject: [PATCH 7/7] fmt --- README.md | 62 ++++++++++--------- apps/html/index.html | 4 +- apps/react/src/app/app.tsx | 2 +- .../src/lib/constants/autogen_internal.ts | 14 ++++- packages/core/src/lib/lit-core.ts | 1 + 5 files changed, 47 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 8968d15803..a2cd053073 100644 --- a/README.md +++ b/README.md @@ -67,39 +67,41 @@ For usage directly in the browser with a script tag -| Package | Category | Version | Download | -| -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [@lit-protocol/lit-node-client-nodejs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client-nodejs) | ![lit-node-client-nodejs](https://img.shields.io/badge/-nodejs-2E8B57 'lit-node-client-nodejs') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/lit-node-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client) | ![lit-node-client](https://img.shields.io/badge/-universal-8A6496 'lit-node-client') | 3.1.2 | npm
Vanilla JS (UMD) | +Package | Category | Version | Download +--- | --- | --- | --- +| [@lit-protocol/lit-node-client-nodejs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client-nodejs) | ![lit-node-client-nodejs](https://img.shields.io/badge/-nodejs-2E8B57 "lit-node-client-nodejs") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/lit-node-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client) | ![lit-node-client](https://img.shields.io/badge/-universal-8A6496 "lit-node-client") | 3.1.2 | npm
Vanilla JS (UMD) + If you're a tech-savvy user and wish to utilize only specific submodules that our main module relies upon, you can find individual packages listed below. This way, you can import only the necessary packages that cater to your specific use case:: -| Package | Category | Version | Download | -| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [@lit-protocol/access-control-conditions](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/access-control-conditions) | ![access-control-conditions](https://img.shields.io/badge/-universal-8A6496 'access-control-conditions') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/auth-helpers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-helpers) | ![auth-helpers](https://img.shields.io/badge/-universal-8A6496 'auth-helpers') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/bls-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/bls-sdk) | ![bls-sdk](https://img.shields.io/badge/-universal-8A6496 'bls-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/constants](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/constants) | ![constants](https://img.shields.io/badge/-universal-8A6496 'constants') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/contracts-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/contracts-sdk) | ![contracts-sdk](https://img.shields.io/badge/-universal-8A6496 'contracts-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/core](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/core) | ![core](https://img.shields.io/badge/-universal-8A6496 'core') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/crypto](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/crypto) | ![crypto](https://img.shields.io/badge/-universal-8A6496 'crypto') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/ecdsa-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/ecdsa-sdk) | ![ecdsa-sdk](https://img.shields.io/badge/-universal-8A6496 'ecdsa-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/encryption](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/encryption) | ![encryption](https://img.shields.io/badge/-universal-8A6496 'encryption') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/lit-third-party-libs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-third-party-libs) | ![lit-third-party-libs](https://img.shields.io/badge/-universal-8A6496 'lit-third-party-libs') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/logger](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/logger) | ![logger](https://img.shields.io/badge/-universal-8A6496 'logger') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/misc](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc) | ![misc](https://img.shields.io/badge/-universal-8A6496 'misc') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/nacl](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/nacl) | ![nacl](https://img.shields.io/badge/-universal-8A6496 'nacl') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-base](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-base) | ![pkp-base](https://img.shields.io/badge/-universal-8A6496 'pkp-base') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-client) | ![pkp-client](https://img.shields.io/badge/-universal-8A6496 'pkp-client') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-cosmos](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-cosmos) | ![pkp-cosmos](https://img.shields.io/badge/-universal-8A6496 'pkp-cosmos') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-ethers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-ethers) | ![pkp-ethers](https://img.shields.io/badge/-universal-8A6496 'pkp-ethers') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-sui](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-sui) | ![pkp-sui](https://img.shields.io/badge/-universal-8A6496 'pkp-sui') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/pkp-walletconnect](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-walletconnect) | ![pkp-walletconnect](https://img.shields.io/badge/-universal-8A6496 'pkp-walletconnect') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/sev-snp-utils-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/sev-snp-utils-sdk) | ![sev-snp-utils-sdk](https://img.shields.io/badge/-universal-8A6496 'sev-snp-utils-sdk') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/types](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/types) | ![types](https://img.shields.io/badge/-universal-8A6496 'types') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/uint8arrays](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/uint8arrays) | ![uint8arrays](https://img.shields.io/badge/-universal-8A6496 'uint8arrays') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/auth-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-browser) | ![auth-browser](https://img.shields.io/badge/-browser-E98869 'auth-browser') | 3.1.2 | npm
Vanilla JS (UMD) | -| [@lit-protocol/misc-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc-browser) | ![misc-browser](https://img.shields.io/badge/-browser-E98869 'misc-browser') | 3.1.2 | npm
Vanilla JS (UMD) | + +Package | Category | Version | Download +--- | --- | --- | --- +| [@lit-protocol/access-control-conditions](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/access-control-conditions) | ![access-control-conditions](https://img.shields.io/badge/-universal-8A6496 "access-control-conditions") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/auth-helpers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-helpers) | ![auth-helpers](https://img.shields.io/badge/-universal-8A6496 "auth-helpers") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/bls-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/bls-sdk) | ![bls-sdk](https://img.shields.io/badge/-universal-8A6496 "bls-sdk") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/constants](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/constants) | ![constants](https://img.shields.io/badge/-universal-8A6496 "constants") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/contracts-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/contracts-sdk) | ![contracts-sdk](https://img.shields.io/badge/-universal-8A6496 "contracts-sdk") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/core](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/core) | ![core](https://img.shields.io/badge/-universal-8A6496 "core") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/crypto](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/crypto) | ![crypto](https://img.shields.io/badge/-universal-8A6496 "crypto") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/ecdsa-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/ecdsa-sdk) | ![ecdsa-sdk](https://img.shields.io/badge/-universal-8A6496 "ecdsa-sdk") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/encryption](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/encryption) | ![encryption](https://img.shields.io/badge/-universal-8A6496 "encryption") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/lit-third-party-libs](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-third-party-libs) | ![lit-third-party-libs](https://img.shields.io/badge/-universal-8A6496 "lit-third-party-libs") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/logger](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/logger) | ![logger](https://img.shields.io/badge/-universal-8A6496 "logger") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/misc](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc) | ![misc](https://img.shields.io/badge/-universal-8A6496 "misc") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/nacl](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/nacl) | ![nacl](https://img.shields.io/badge/-universal-8A6496 "nacl") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-base](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-base) | ![pkp-base](https://img.shields.io/badge/-universal-8A6496 "pkp-base") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-client](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-client) | ![pkp-client](https://img.shields.io/badge/-universal-8A6496 "pkp-client") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-cosmos](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-cosmos) | ![pkp-cosmos](https://img.shields.io/badge/-universal-8A6496 "pkp-cosmos") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-ethers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-ethers) | ![pkp-ethers](https://img.shields.io/badge/-universal-8A6496 "pkp-ethers") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-sui](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-sui) | ![pkp-sui](https://img.shields.io/badge/-universal-8A6496 "pkp-sui") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/pkp-walletconnect](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-walletconnect) | ![pkp-walletconnect](https://img.shields.io/badge/-universal-8A6496 "pkp-walletconnect") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/sev-snp-utils-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/sev-snp-utils-sdk) | ![sev-snp-utils-sdk](https://img.shields.io/badge/-universal-8A6496 "sev-snp-utils-sdk") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/types](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/types) | ![types](https://img.shields.io/badge/-universal-8A6496 "types") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/uint8arrays](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/uint8arrays) | ![uint8arrays](https://img.shields.io/badge/-universal-8A6496 "uint8arrays") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/auth-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/auth-browser) | ![auth-browser](https://img.shields.io/badge/-browser-E98869 "auth-browser") | 3.1.2 | npm
Vanilla JS (UMD) +| [@lit-protocol/misc-browser](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc-browser) | ![misc-browser](https://img.shields.io/badge/-browser-E98869 "misc-browser") | 3.1.2 | npm
Vanilla JS (UMD) diff --git a/apps/html/index.html b/apps/html/index.html index a4ff547f90..dd2b1c547f 100644 --- a/apps/html/index.html +++ b/apps/html/index.html @@ -1,4 +1,4 @@ - + @@ -62,7 +62,7 @@ - (HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Thu, 08 Feb 2024 15:20:37 GMT + (HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Thu, 08 Feb 2024 23:45:57 GMT diff --git a/apps/react/src/app/app.tsx b/apps/react/src/app/app.tsx index fc1557f64a..f6746c7dc3 100644 --- a/apps/react/src/app/app.tsx +++ b/apps/react/src/app/app.tsx @@ -1879,7 +1879,7 @@ pre { `, }} /> - (REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Thu, 08 Feb 2024 15:20:37 GMT + (REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Thu, 08 Feb 2024 23:45:58 GMT
diff --git a/packages/constants/src/lib/constants/autogen_internal.ts b/packages/constants/src/lib/constants/autogen_internal.ts index 06d273983e..3a0d709585 100644 --- a/packages/constants/src/lib/constants/autogen_internal.ts +++ b/packages/constants/src/lib/constants/autogen_internal.ts @@ -1,8 +1,12 @@ -// Last Modified: 2024-02-08 15:19:00 +// Last Modified: 2024-02-08 23:44:16 // This file is auto-generated by tools/scripts/gen-internal-dev.mjs export const INTERNAL_DEV = [ + 'https://167.114.17.205:443', 'https://167.114.17.204:443', - 'https://199.115.117.115:443', + 'https://167.114.17.203:443', + 'https://64.131.85.106:443', + 'https://64.131.85.108:443', + 'https://167.114.17.201:443', 'https://167.114.17.202:443', ]; @@ -13,8 +17,12 @@ export const INTERNAL_DEFAULT_CONFIG = { minNodeCount: 2, debug: true, bootstrapUrls: [ + 'https://167.114.17.205:443', 'https://167.114.17.204:443', - 'https://199.115.117.115:443', + 'https://167.114.17.203:443', + 'https://64.131.85.106:443', + 'https://64.131.85.108:443', + 'https://167.114.17.201:443', 'https://167.114.17.202:443', ], litNetwork: 'internalDev', diff --git a/packages/core/src/lib/lit-core.ts b/packages/core/src/lib/lit-core.ts index b3b2ab6fa7..372a7c8ed5 100644 --- a/packages/core/src/lib/lit-core.ts +++ b/packages/core/src/lib/lit-core.ts @@ -547,6 +547,7 @@ export class LitCore { errorCode: LIT_ERROR.INVALID_ETH_BLOCKHASH.name, }); } + this.lastblockHashRetrieved = Date.now(); this.ready = true;