chore(sdk): add rpcUrl, chainId, and method(params) to smart provider logging (#4146)

### Description

- adds rpcUrl, chainId, and method(params) to smart provider logging

### Drive-by changes

- none

### Related issues

- none

### Backward compatibility

- yes

### Testing

- manual
pull/4163/head
Noah Bayindirli 🥂 3 months ago committed by GitHub
parent 4fa75a4bd8
commit 7265a40875
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/gold-seals-burn.md
  2. 5
      typescript/cli/README.md
  3. 31
      typescript/sdk/src/deploy/verify/ContractVerifier.ts
  4. 30
      typescript/sdk/src/providers/SmartProvider/SmartProvider.ts

@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': patch
---
Add rpcUrl, chainId, and method(params) to smart provider logging.

@ -59,4 +59,7 @@ Send test message: `hyperlane send message`
## Logging
The logging format can be toggled between human-readable vs JSON-structured logs using the `LOG_FORMAT` environment variable or the `--log <pretty|json>` flag.
The logging verbosity can be configured using the `LOG_LEVEL` environment variable or the `--verbosity <debug|info|warn|error|off>` flag.
Note: If you are unable to see color output after setting `LOG_FORMAT`, you may set the `FORCE_COLOR=true` environment variable as a last resort. See https://force-color.org/ & https://github.com/chalk for more info.
The logging verbosity can be configured using the `LOG_LEVEL` environment variable or the `--verbosity <trace|debug|info|warn|error|off>` flag.

@ -102,7 +102,7 @@ export class ContractVerifier {
url.searchParams.set('action', action);
}
let response;
let response: Response;
if (isGetRequest) {
response = await fetch(url.toString(), {
method: 'GET',
@ -123,20 +123,22 @@ export class ContractVerifier {
switch (result.result) {
case ExplorerApiErrors.VERIFICATION_PENDING:
await sleep(5000); // wait 5 seconds
await sleep(5000);
verificationLogger.trace(
{
result: result.result,
},
'Verification still pending',
);
return this.submitForm(chain, action, verificationLogger, options);
case ExplorerApiErrors.ALREADY_VERIFIED:
case ExplorerApiErrors.ALREADY_VERIFIED_ALT:
return;
case ExplorerApiErrors.PROXY_FAILED:
errorMessage = 'Proxy verification failed, try manually?';
break;
case ExplorerApiErrors.BYTECODE_MISMATCH:
errorMessage =
'Compiled bytecode does not match deployed bytecode, check constructor arguments?';
errorMessage = `${result.message}: ${result.result}`;
break;
default:
errorMessage = `Verification failed. ${
errorMessage = `Verification failed: ${
JSON.stringify(result.result) ?? response.statusText
}`;
break;
@ -181,7 +183,8 @@ export class ContractVerifier {
return !!result[0]?.SourceCode;
} catch (error) {
verificationLogger.debug(
`Error checking if contract is already verified: ${error}`,
{ error },
'Error checking if contract is already verified',
);
return false;
}
@ -215,11 +218,15 @@ export class ContractVerifier {
input.address,
);
verificationLogger.debug(
`✅ Successfully verified proxy ${addressUrl}#readProxyContract`,
{
url: `${addressUrl}#readProxyContract`,
},
`✅ Successfully verified proxy`,
);
} catch (error) {
verificationLogger.debug(
`Verification of proxy at ${input.address} failed: ${error}`,
{ error },
`Verification of proxy at ${input.address} failed`,
);
throw error;
}
@ -339,7 +346,7 @@ export class ContractVerifier {
verificationLogger.debug(
`Contract already verified at ${addressUrl}#code`,
);
await sleep(200); // There is a rate limit of 5 requests per second
await sleep(200); // 5 calls/s (https://info.etherscan.com/api-return-errors/)
return;
}

@ -264,26 +264,40 @@ export class HyperlaneSmartProvider
);
const result = await Promise.race([resultPromise, timeoutPromise]);
const providerMetadata = {
providerIndex: pIndex,
rpcUrl: provider.getBaseUrl(),
method: `${method}(${JSON.stringify(params)})`,
chainId: this.network.chainId,
};
if (result.status === ProviderStatus.Success) {
return result.value;
} else if (result.status === ProviderStatus.Timeout) {
this.logger.trace(
`Slow response from provider #${pIndex}.${
!isLastProvider ? ' Triggering next provider.' : ''
}`,
this.logger.debug(
{ ...providerMetadata },
`Slow response from provider:`,
isLastProvider ? '' : 'Triggering next provider.',
);
providerResultPromises.push(resultPromise);
pIndex += 1;
} else if (result.status === ProviderStatus.Error) {
this.logger.debug(
`Error from provider #${pIndex}: ${result.error} - ${
!isLastProvider ? ' Triggering next provider.' : ''
}`,
{
error: result.error,
...providerMetadata,
},
`Error from provider.`,
isLastProvider ? '' : 'Triggering next provider.',
);
providerResultErrors.push(result.error);
pIndex += 1;
} else {
throw new Error('Unexpected result from provider');
throw new Error(
`Unexpected result from provider: ${JSON.stringify(
providerMetadata,
)}`,
);
}
// All providers already triggered, wait for one to complete or all to fail/timeout

Loading…
Cancel
Save