-
Notifications
You must be signed in to change notification settings - Fork 324
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
feat: contract instance/class cache for current tx - ensure that later txs in block cannot wipe out contracts created earlier #12261
Conversation
Math.ceil(publicContractClass.packedBytecode.length / 32) + 1, | ||
Math.ceil(publicContractClass.packedBytecode.length / 31) + 1, | ||
), |
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 copied this code only to realize that this 32 was wrong. Doesn't matter here because the bytecode is fake, but it mattered for real bytecode.
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.
LGTM! One question though: are the ContractsDataSourcePublicDB
getters for classes and instances used from both public setup and public app? If so, should we disallow loading a contract class/instance created in a private revertible phase in the public setup? Otherwise, if the app logic reverts, the contract will never have been deployed, and public setup would be running on unpublished code. Does this make sense?
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.
LGTM 🚀
const siloedNonRevertibleContractClassLogs = tx.data.forPublic | ||
? await tx.filterContractClassLogs( | ||
tx.data.forPublic!.nonRevertibleAccumulatedData.contractClassLogsHashes, | ||
/*siloed=*/ true, | ||
) | ||
: await tx.filterContractClassLogs(tx.data.forRollup!.end.contractClassLogsHashes, /*siloed=*/ true); | ||
const siloedRevertibleContractClassLogs = tx.data.forPublic | ||
? await tx.filterContractClassLogs( | ||
tx.data.forPublic!.revertibleAccumulatedData.contractClassLogsHashes, | ||
/*siloed=*/ true, | ||
) | ||
: []; |
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.
This looks good! If it's easier/cleaner I can change tx.data.getNonEmptyContractClassLogsHashes()
to a pair of fns like get(Non)RevertibleContractClassLogsHashes()
? IIRC I added the original to make this code clearer, and have some cc log cleanup to do anyway (#12325). LMK!
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 think that would help clean this up! Can be done after this PR though
@spalladino good catch! I updated it so that we can add non-revertible contract infos separately from revertibles. Also note that before this PR, none of the contract classes/instances from a private-only TX were ever added to |
Ensures that contracts only get wiped out of the cache when they really should.
What's included
ContractDataSourcePublicDB
as follows:TxContractCache
.simulator/src/public
into subfoldersIssues
I discovered during this work, that if you run certain test-cases in

deploy_method.test.ts
on their own (without running earlier test cases, they fail as follows (happens on master):This holds true for the new test. This might mean that contracts cannot be properly called after deployment in the same block! More investigation is needed in another ticket/pr.
Also, I can run all of the

deploy_method.test.ts
tests locally and they pass, but in CI, the new one fails: