Skip to content

Commit

Permalink
Additional instances
Browse files Browse the repository at this point in the history
  • Loading branch information
pxrl committed Oct 24, 2023
1 parent 7939670 commit e4ba8b4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/utils/ProviderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {
if (!results.every(isPromiseFulfilled)) {
// Format the error so that it's very clear which providers failed and succeeded.
const errorTexts = errors.map(([provider, errorText]) => formatProviderError(provider, errorText));
const successfulProviderUrls = results.filter(isPromiseFulfilled).map((result) => result.value[0].connection.url);
const successfulProviderUrls = results
.filter(isPromiseFulfilled)
.map((result) => getOriginFromURL(result.value[0].connection.url));
throw createSendErrorWithMessage(
`Not enough providers succeeded. Errors:\n${errorTexts.join("\n")}\n` +
`Successful Providers:\n${successfulProviderUrls.join("\n")}`,
Expand All @@ -324,13 +326,13 @@ export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {

const throwQuorumError = () => {
const errorTexts = errors.map(([provider, errorText]) => formatProviderError(provider, errorText));
const successfulProviderUrls = values.map(([provider]) => provider.connection.url);
const successfulProviderUrls = values.map(([provider]) => getOriginFromURL(provider.connection.url));
throw new Error(
"Not enough providers agreed to meet quorum.\n" +
"Providers that errored:\n" +
`${errorTexts.join("\n")}\n` +
"Providers that succeeded, but some failed to match:\n" +
successfulProviderUrls.join("\n")
successfulProviderUrls.map((url) => getOriginFromURL(url)).join("\n")
);
};

Expand Down Expand Up @@ -390,11 +392,11 @@ export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {
const mismatchedProviders = Object.fromEntries(
[...values, ...fallbackValues]
.filter(([, result]) => !compareRpcResults(method, result, quorumResult))
.map(([provider, result]) => [provider.connection.url, result])
.map(([provider, result]) => [getOriginFromURL(provider.connection.url), result])
);
const quorumProviders = [...values, ...fallbackValues]
.filter(([, result]) => compareRpcResults(method, result, quorumResult))
.map(([provider]) => provider.connection.url);
.map(([provider]) => getOriginFromURL(provider.connection.url));
if (Object.keys(mismatchedProviders).length > 0 || errors.length > 0) {
logger.warn({
at: "ProviderUtils",
Expand Down

0 comments on commit e4ba8b4

Please sign in to comment.