Skip to content
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

Fix class cache serving non-declared classes in some edge cases #1571

Merged
merged 1 commit into from
Dec 18, 2023

Conversation

omerfirmak
Copy link
Contributor

The initial assumption here was that self.height uniquely identifies and strictly orders the underlying state instances. The first assumption doesn't necessarily hold, because we can pass different state instaces with the same height. This most commonly happens with call/estimate/simulate and trace flows. Trace flow calls the VM for block number N with the state at the beginning of the block, while call/estimate/simulate flows call the VM with the same block number but with the state at the end of that block. That is why, we cannot use classes from cache if they are cached on the same height that we are executing on. Because they might be cached using a state instance that is in the future compared to the state that we are currently executing on, even tho they have the same height.

@omerfirmak omerfirmak requested a review from joshklop December 18, 2023 08:24
Copy link
Contributor

@joshklop joshklop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. A comment explaining why it's < and not <= might be helpful.

@omerfirmak
Copy link
Contributor Author

Nice. A comment explaining why it's < and not <= might be helpful.

Above explanation is in the commit message as well. If you think that is not enough, I can copy it as a comment as well.

@joshklop
Copy link
Contributor

Above explanation is in the commit message as well. If you think that is not enough, I can copy it as a comment as well.

I feel a comment is warranted here since it's kind of counter-intuitive and not explained by the code immediately surrounding the change.

@omerfirmak omerfirmak force-pushed the omerfirmak/class-cache branch from 340d0a3 to eab2ee5 Compare December 18, 2023 11:59
The initial assumption here was that `self.height` uniquely identifies and strictly orders the underlying state
instances. The first assumption doesn't necessarily hold, because we can pass different state instaces with the
same height. This most commonly happens with call/estimate/simulate and trace flows. Trace flow calls the VM
for block number N with the state at the beginning of the block, while call/estimate/simulate flows call the VM
with the same block number but with the state at the end of that block. That is why, we cannot use classes from cache
if they are cached on the same height that we are executing on. Because they might be cached using a state instance that
is in the future compared to the state that we are currently executing on, even tho they have the same height.
@omerfirmak omerfirmak force-pushed the omerfirmak/class-cache branch from eab2ee5 to b94cdf9 Compare December 18, 2023 12:00
Copy link

codecov bot commented Dec 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7684cbd) 72.97% compared to head (b94cdf9) 72.98%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1571   +/-   ##
=======================================
  Coverage   72.97%   72.98%           
=======================================
  Files          97       97           
  Lines       10017    10017           
=======================================
+ Hits         7310     7311    +1     
+ Misses       2165     2164    -1     
  Partials      542      542           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@omerfirmak omerfirmak merged commit eee0a32 into main Dec 18, 2023
10 checks passed
@omerfirmak omerfirmak deleted the omerfirmak/class-cache branch December 18, 2023 12:14
wojciechos pushed a commit that referenced this pull request Dec 18, 2023
The initial assumption here was that `self.height` uniquely identifies and strictly orders the underlying state
instances. The first assumption doesn't necessarily hold, because we can pass different state instaces with the
same height. This most commonly happens with call/estimate/simulate and trace flows. Trace flow calls the VM
for block number N with the state at the beginning of the block, while call/estimate/simulate flows call the VM
with the same block number but with the state at the end of that block. That is why, we cannot use classes from cache
if they are cached on the same height that we are executing on. Because they might be cached using a state instance that
is in the future compared to the state that we are currently executing on, even tho they have the same height.
wojciechos pushed a commit that referenced this pull request Dec 18, 2023
The initial assumption here was that `self.height` uniquely identifies and strictly orders the underlying state
instances. The first assumption doesn't necessarily hold, because we can pass different state instaces with the
same height. This most commonly happens with call/estimate/simulate and trace flows. Trace flow calls the VM
for block number N with the state at the beginning of the block, while call/estimate/simulate flows call the VM
with the same block number but with the state at the end of that block. That is why, we cannot use classes from cache
if they are cached on the same height that we are executing on. Because they might be cached using a state instance that
is in the future compared to the state that we are currently executing on, even tho they have the same height.
joshklop pushed a commit that referenced this pull request Dec 21, 2023
The initial assumption here was that `self.height` uniquely identifies and strictly orders the underlying state
instances. The first assumption doesn't necessarily hold, because we can pass different state instaces with the
same height. This most commonly happens with call/estimate/simulate and trace flows. Trace flow calls the VM
for block number N with the state at the beginning of the block, while call/estimate/simulate flows call the VM
with the same block number but with the state at the end of that block. That is why, we cannot use classes from cache
if they are cached on the same height that we are executing on. Because they might be cached using a state instance that
is in the future compared to the state that we are currently executing on, even tho they have the same height.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants