diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d05d8cee2..b36cafd8aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,7 @@ jobs: NETWORK: datil-dev DEBUG: true MAX_ATTEMPTS: 3 + CHUNK_SIZE: 9 steps: - name: Checkout repo uses: actions/checkout@v2 @@ -55,4 +56,4 @@ jobs: run: yarn build:dev - name: Run End to End Tests if: steps.build.outputs.exit_code == 0 - run: yarn test:local --filter=testUseEoaSessionSigsToExecuteJsSigning,testUseEoaSessionSigsToPkpSign,testUsePkpSessionSigsToExecuteJsSigning,testUsePkpSessionSigsToPkpSign,testUseValidLitActionCodeGeneratedSessionSigsToPkpSign,testUseValidLitActionCodeGeneratedSessionSigsToExecuteJsSigning,testDelegatingCapacityCreditsNFTToAnotherWalletToExecuteJs,testEthAuthSigToEncryptDecryptString,testExecuteJsSignAndCombineEcdsa,testExecutJsDecryptAndCombine,testExecuteJsBroadcastAndCollect --exclude=Parallel + run: yarn test:local --filter=testUseEoaSessionSigsToExecuteJsSigning,testUseEoaSessionSigsToPkpSign,testUsePkpSessionSigsToExecuteJsSigning,testUsePkpSessionSigsToPkpSign,testUseValidLitActionCodeGeneratedSessionSigsToPkpSign,testUseValidLitActionCodeGeneratedSessionSigsToExecuteJsSigning,testDelegatingCapacityCreditsNFTToAnotherWalletToExecuteJs,testEthAuthSigToEncryptDecryptString,testExecuteJsSignAndCombineEcdsa,testExecutJsDecryptAndCombine,testExecuteJsBroadcastAndCollect --exclude=Parallel diff --git a/packages/constants/src/lib/constants/constants.ts b/packages/constants/src/lib/constants/constants.ts index f5ab3ff489..22f74f7859 100644 --- a/packages/constants/src/lib/constants/constants.ts +++ b/packages/constants/src/lib/constants/constants.ts @@ -789,8 +789,8 @@ export const METAMASK_CHAIN_INFO_BY_NETWORK: Record< localhost: metamaskChainInfo.yellowstone, }; -const HTTP = 'http://'; -const HTTPS = 'https://'; +export const HTTP = 'http://'; +export const HTTPS = 'https://'; /** * Mapping of network values to corresponding http protocol. @@ -804,8 +804,9 @@ export const HTTP_BY_NETWORK: Record< habanero: HTTPS, 'datil-dev': HTTPS, 'datil-test': HTTPS, - custom: HTTP, - localhost: HTTP, + internalDev: HTTPS, + custom: HTTP, // default, can be changed by config + localhost: HTTP, // default, can be changed by config }; /** diff --git a/packages/contracts-sdk/src/lib/contracts-sdk.ts b/packages/contracts-sdk/src/lib/contracts-sdk.ts index 76df1a1530..42263170de 100644 --- a/packages/contracts-sdk/src/lib/contracts-sdk.ts +++ b/packages/contracts-sdk/src/lib/contracts-sdk.ts @@ -56,6 +56,8 @@ import { HTTP_BY_NETWORK, CENTRALISATION_BY_NETWORK, LIT_NETWORK, + HTTP, + HTTPS, } from '@lit-protocol/constants'; import { LogManager, Logger } from '@lit-protocol/logger'; import { computeAddress } from 'ethers/lib/utils'; @@ -888,7 +890,8 @@ export class LitContracts { public static getValidators = async ( network: LIT_NETWORKS_KEYS, context?: LitContractContext | LitContractResolverContext, - rpcUrl?: string + rpcUrl?: string, + nodeProtocol?: typeof HTTP | typeof HTTPS | null ): Promise => { const contract = await LitContracts.getStakingContract( network, @@ -941,13 +944,24 @@ export class LitContracts { }); const networks = activeValidatorStructs.map((item: ValidatorStruct) => { - const protocol = HTTP_BY_NETWORK[network]; const centralisation = CENTRALISATION_BY_NETWORK[network]; - const ip = intToIP(item.ip); - const port = item.port; + // Convert the integer IP to a string format + const ip = intToIP(item.ip); + let port = item.port; + + // Determine the protocol to use based on various conditions + const protocol = + // If nodeProtocol is defined, use it + nodeProtocol || + // If port is 443, use HTTPS, otherwise use network-specific HTTP + (port === 443 ? HTTPS : HTTP_BY_NETWORK[network]) || + // Fallback to HTTP if no other conditions are met + HTTP; + + // Check for specific conditions in centralised networks if (centralisation === 'centralised') { - // -- validate if it's cayenne AND port range is 8470 - 8479, if not, throw error + // Validate if it's cayenne AND port range is 8470 - 8479, if not, throw error if ( network === LIT_NETWORK.Cayenne && !port.toString().startsWith('8') diff --git a/packages/core/src/lib/lit-core.ts b/packages/core/src/lib/lit-core.ts index 9ddc414639..0ad8e06fb5 100644 --- a/packages/core/src/lib/lit-core.ts +++ b/packages/core/src/lib/lit-core.ts @@ -24,6 +24,8 @@ import { RPC_URL_BY_NETWORK, StakingStates, version, + HTTP, + HTTPS, } from '@lit-protocol/constants'; import { LitContracts } from '@lit-protocol/contracts-sdk'; import { @@ -99,6 +101,8 @@ export type LitNodeClientConfigWithDefaults = Required< Pick > & { bootstrapUrls: string[]; + } & { + nodeProtocol?: typeof HTTP | typeof HTTPS | null; }; // On epoch change, we wait this many seconds for the nodes to update to the new epoch before using the new epoch # @@ -131,6 +135,7 @@ export class LitCore { litNetwork: 'cayenne', // Default to cayenne network. will be replaced by custom config. minNodeCount: 2, // Default value, should be replaced bootstrapUrls: [], // Default value, should be replaced + nodeProtocol: null, }; connectedNodes = new Set(); serverKeys: Record = {}; @@ -234,7 +239,8 @@ export class LitCore { LitContracts.getValidators( this.config.litNetwork, this.config.contractContext, - this.config.rpcUrl + this.config.rpcUrl, + this.config.nodeProtocol ), ]);