diff --git a/.changeset/stale-houses-drive.md b/.changeset/stale-houses-drive.md new file mode 100644 index 0000000000..2c330bd5b4 --- /dev/null +++ b/.changeset/stale-houses-drive.md @@ -0,0 +1,5 @@ +--- +'@chainlink/glv-token-adapter': patch +--- + +RPC Timeout + timing debug logs diff --git a/packages/composites/glv-token/README.md b/packages/composites/glv-token/README.md index fe27d779ad..d2bb5ba465 100644 --- a/packages/composites/glv-token/README.md +++ b/packages/composites/glv-token/README.md @@ -10,6 +10,7 @@ This document was generated automatically. Please see [README Generator](../../s | :-------: | :--------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----: | :-----: | :------------------------------------------: | | ✅ | ARBITRUM_RPC_URL | RPC url of Arbitrum node | string | | | | ✅ | ARBITRUM_CHAIN_ID | The chain id to connect to | number | | `42161` | +| | ARBITRUM_RPC_TIMEOUT_MS | The amount of time the RPC request to the Arbitrum node should wait before timing out. | number | | `5000` | | ✅ | DATASTORE_CONTRACT_ADDRESS | Address of Data Store contract | string | | `0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8` | | ✅ | GLV_READER_CONTRACT_ADDRESS | Address of Glv Reader Contract | string | | `0x6a9505D0B44cFA863d9281EA5B0b34cB36243b45` | | ✅ | TIINGO_ADAPTER_URL | URL of Tiingo EA | string | | | diff --git a/packages/composites/glv-token/src/config/index.ts b/packages/composites/glv-token/src/config/index.ts index 68ef164bc5..f0b4177117 100644 --- a/packages/composites/glv-token/src/config/index.ts +++ b/packages/composites/glv-token/src/config/index.ts @@ -8,6 +8,12 @@ export const config = new AdapterConfig( type: 'string', required: true, }, + ARBITRUM_RPC_TIMEOUT_MS: { + description: + 'The amount of time the RPC request to the Arbitrum node should wait before timing out.', + type: 'number', + default: 5_000, + }, ARBITRUM_CHAIN_ID: { description: 'The chain id to connect to', type: 'number', diff --git a/packages/composites/glv-token/src/transport/base.ts b/packages/composites/glv-token/src/transport/base.ts index e79a7ea28b..7248a0b85b 100644 --- a/packages/composites/glv-token/src/transport/base.ts +++ b/packages/composites/glv-token/src/transport/base.ts @@ -70,10 +70,11 @@ export abstract class BaseGlvTransport< ): Promise { await super.initialize(dependencies, adapterSettings, endpointName, transportName) this.settings = adapterSettings - this.provider = new ethers.providers.JsonRpcProvider( - adapterSettings.ARBITRUM_RPC_URL, - adapterSettings.ARBITRUM_CHAIN_ID, - ) + const conn = { + url: adapterSettings.ARBITRUM_RPC_URL, + timeout: adapterSettings.ARBITRUM_RPC_TIMEOUT_MS, + } + this.provider = new ethers.providers.JsonRpcProvider(conn, adapterSettings.ARBITRUM_CHAIN_ID) this.requester = dependencies.requester this.glvReaderContract = new ethers.Contract( @@ -148,10 +149,13 @@ export abstract class BaseGlvTransport< const providerDataRequestedUnixMs = Date.now() const glv_address = param.glv + let start = Date.now() const glvInfo = await this.glvReaderContract.getGlvInfo( this.settings.DATASTORE_CONTRACT_ADDRESS, glv_address, ) + let end = Date.now() - start + logger.debug(`Fetched glv info in ${end}ms`) const glv: glvInformation = { glvToken: glvInfo.glv.glvToken, @@ -190,10 +194,13 @@ export abstract class BaseGlvTransport< glv_address, ] + start = Date.now() const [[maximizedPriceRaw], [minimizedPriceRaw]] = await Promise.all([ this.glvReaderContract.getGlvTokenPrice(...glvTokenPriceContractParams, true), this.glvReaderContract.getGlvTokenPrice(...glvTokenPriceContractParams, false), ]) + end = Date.now() - start + logger.info(`Fetched glv token price in ${end}ms`) const maximizedPrice = Number(utils.formatUnits(maximizedPriceRaw, SIGNED_PRICE_DECIMALS)) const minimizedPrice = Number(utils.formatUnits(minimizedPriceRaw, SIGNED_PRICE_DECIMALS)) @@ -226,6 +233,7 @@ export abstract class BaseGlvTransport< const priceProviders: Record = {} const promises = [] + const start = Date.now() for (let i = 0; i < sources.length; i++) { const source = sources[i] const assetPromises = assets.map(async (asset) => { @@ -270,6 +278,8 @@ export abstract class BaseGlvTransport< } await Promise.all(promises) + const end = Date.now() - start + logger.debug(`Fetched prices in ${end}ms`) this.validateRequiredResponses(priceProviders, sources, assets, dataRequestedTimestamp)