-
Notifications
You must be signed in to change notification settings - Fork 29
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
Improve contract recompilation #475
Changes from 1 commit
4517d45
708c0cf
05ba0a7
d0aa6fb
bb531ff
d51b0bd
53828bf
35cb7d7
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 |
---|---|---|
|
@@ -2159,3 +2159,20 @@ export const getContractIdFromUnsignedTx = async ( | |
|
||
// This function only works in the simple case where a single non-subcontract is created in the tx | ||
export const getTokenIdFromUnsignedTx = getContractIdFromUnsignedTx | ||
|
||
export async function getContractByCodeHash( | ||
nodeProvider: NodeProvider, | ||
codeHash: HexString | ||
): Promise<HexString | undefined> { | ||
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. We need to consider 429 errors due to rate limiting, and retry a few times if 429 hits 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. @Lbqds It seems this one is not resolved yet? 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. It was resolved in the last commit. Since we don’t want to introduce a retry mechanism in web3, the retry on failure will be done in the cli. |
||
if (isHexString(codeHash) && codeHash.length === 64) { | ||
try { | ||
return await nodeProvider.contracts.getContractsCodeHashCode(codeHash) | ||
} catch (error) { | ||
if (error instanceof Error && error.message.includes('not found')) { | ||
return undefined | ||
} | ||
throw new TraceableError(`Failed to get contract by code hash ${codeHash}`, error) | ||
} | ||
} | ||
throw new Error(`Invalid code hash: ${codeHash}`) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we enable
skipRecompileOnDeployment
by default?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit hesitant about this because most of the contract compilation occurs during the development phase. Once the contract is deployed to the mainnet, the number of compilations should be much less.
If it's enabled by default, unnecessary checks could also be made on the mainnet during the development phase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Let's not enable it by default.