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

[KGA-34] feat: update base fee starting from next block only #1606

Merged
merged 4 commits into from
Nov 14, 2024

Conversation

enitrat
Copy link
Collaborator

@enitrat enitrat commented Nov 13, 2024

https://github.com/code-423n4/2024-09-kakarot-findings/issues/28

Updates the base fee mechanism.

In the EVM there can only be one base fee for a given block.
Thus, we use an index to manage two different base fees:
- The base fee to use for the current block (index: 'current_block')
- The base fee to use for the next block (index: 'next_block')

The startegy is:

  • when getting the base fee, check if you can get the one from the 'next_block' (if block_number > next_fee_start_block_number)
  • if yes, then update the value in current_block and return the new value
  • otherwise, return the value from current_block

When setting the base_fee, it will be applicable starting from block_number + 1.

Note: for tests we have to manually patch both addr and addr+1 as we'restoring two values.


This change is Reviewable

Copy link

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 63.7%. Comparing base (289c2e8) to head (3fb7fed).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
cairo_zero/kakarot/library.cairo 90.9% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1606   +/-   ##
=====================================
  Coverage   63.6%   63.7%           
=====================================
  Files         44      44           
  Lines       8343    8364   +21     
=====================================
+ Hits        5309    5328   +19     
- Misses      3034    3036    +2     

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

@ClementWalter ClementWalter merged commit cbe1c81 into main Nov 14, 2024
16 checks passed
@ClementWalter ClementWalter deleted the feat/basefee-block-based branch November 14, 2024 18:05
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