-
Notifications
You must be signed in to change notification settings - Fork 308
refactor(apps/price_pusher): crash on RPC failures #1730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1f71eae
5548e14
1fa60fa
59a41eb
4c1a946
6384680
8de8d28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,12 +112,6 @@ export class SuiPricePusher implements IPricePusher { | |
| private readonly provider: SuiClient, | ||
| private logger: Logger, | ||
| private priceServiceConnection: PriceServiceConnection, | ||
| private pythPackageId: string, | ||
| private pythStateId: string, | ||
| private wormholePackageId: string, | ||
| private wormholeStateId: string, | ||
| endpoint: string, | ||
| keypair: Ed25519Keypair, | ||
| private gasBudget: number, | ||
| private gasPool: SuiObjectRef[], | ||
| private pythClient: SuiPythClient | ||
|
|
@@ -180,14 +174,6 @@ export class SuiPricePusher implements IPricePusher { | |
| } | ||
|
|
||
| const provider = new SuiClient({ url: endpoint }); | ||
| const pythPackageId = await SuiPricePusher.getPackageId( | ||
| provider, | ||
| pythStateId | ||
| ); | ||
| const wormholePackageId = await SuiPricePusher.getPackageId( | ||
| provider, | ||
| wormholeStateId | ||
| ); | ||
|
|
||
| const gasPool = await SuiPricePusher.initializeGasPool( | ||
| keypair, | ||
|
|
@@ -208,12 +194,6 @@ export class SuiPricePusher implements IPricePusher { | |
| provider, | ||
| logger, | ||
| priceServiceConnection, | ||
| pythPackageId, | ||
| pythStateId, | ||
| wormholePackageId, | ||
| wormholeStateId, | ||
| endpoint, | ||
| keypair, | ||
|
Comment on lines
-211
to
-216
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. drive-by: linter |
||
| gasBudget, | ||
| gasPool, | ||
| pythClient | ||
|
|
@@ -337,7 +317,7 @@ export class SuiPricePusher implements IPricePusher { | |
| ignoreGasObjects: string[], | ||
| logger: Logger | ||
| ): Promise<SuiObjectRef[]> { | ||
| const signerAddress = await signer.toSuiAddress(); | ||
| const signerAddress = signer.toSuiAddress(); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. drive-by: linter |
||
|
|
||
| if (ignoreGasObjects.length > 0) { | ||
| logger.info( | ||
|
|
@@ -383,25 +363,20 @@ export class SuiPricePusher implements IPricePusher { | |
| } | ||
|
|
||
| // Attempt to refresh the version of the provided object reference to point to the current version | ||
| // of the object. Return the provided object reference if an error occurs or the object could not | ||
| // be retrieved. | ||
| // of the object. Throws an error if the object cannot be refreshed. | ||
| private static async tryRefreshObjectReference( | ||
| provider: SuiClient, | ||
| ref: SuiObjectRef | ||
| ): Promise<SuiObjectRef> { | ||
| try { | ||
| const objectResponse = await provider.getObject({ id: ref.objectId }); | ||
| if (objectResponse.data !== undefined) { | ||
| return { | ||
| digest: objectResponse.data!.digest, | ||
| objectId: objectResponse.data!.objectId, | ||
| version: objectResponse.data!.version, | ||
| }; | ||
| } else { | ||
| return ref; | ||
| } | ||
| } catch (error) { | ||
| return ref; | ||
| const objectResponse = await provider.getObject({ id: ref.objectId }); | ||
| if (objectResponse.data !== undefined) { | ||
| return { | ||
| digest: objectResponse.data!.digest, | ||
| objectId: objectResponse.data!.objectId, | ||
| version: objectResponse.data!.version, | ||
| }; | ||
| } else { | ||
| throw new Error("Failed to refresh object reference"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how often this may happen, but if it fails frequently and causes crashes, there is a higher chance that we lock all the gas price objects
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. During my experiments I think I've resolved the issue of locked gases. It seems that it happens when we reuse a gas coin upon crash/restarts. I changed our deployment configuration to never allow to live instances at the same time and wait 10s before starting a new instance to make sure older ones are settled. No locking issues since this change. I'll also run this code for sui for a day or so before merging to see how it works. |
||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.