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

Feat/fee logic #969

Open
wants to merge 26 commits into
base: release/galactica
Choose a base branch
from
Open

Feat/fee logic #969

wants to merge 26 commits into from

Conversation

paologalligit
Copy link
Member

Description

This PR introduces the logic to calculate the fees dynamically based on the VIP-Dynamic Fee Market.

GHIssue

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • New and existing E2E tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have not added any vulnerable dependencies to my code

@codecov-commenter
Copy link

codecov-commenter commented Feb 3, 2025

Codecov Report

Attention: Patch coverage is 85.04673% with 32 lines in your changes missing coverage. Please review.

Please upload report for BASE (release/galactica@2a83abe). Learn more about missing BASE report.

Files with missing lines Patch % Lines
runtime/resolved_tx.go 14.28% 4 Missing and 2 partials ⚠️
tx/tx_dynamic_fee.go 40.00% 4 Missing and 2 partials ⚠️
txpool/validation.go 88.00% 4 Missing and 2 partials ⚠️
packer/packer.go 75.00% 3 Missing and 2 partials ⚠️
tx/transaction.go 73.33% 3 Missing and 1 partial ⚠️
packer/flow.go 81.25% 1 Missing and 2 partials ⚠️
cmd/thor/main.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##             release/galactica     #969   +/-   ##
====================================================
  Coverage                     ?   61.29%           
====================================================
  Files                        ?      226           
  Lines                        ?    24075           
  Branches                     ?        0           
====================================================
  Hits                         ?    14756           
  Misses                       ?     8136           
  Partials                     ?     1183           

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

Comment on lines 66 to 69
forkConfig := thor.NoFork
forkConfig.VIP191 = 1
forkConfig.BLOCKLIST = 0
forkConfig.VIP214 = 2
Copy link
Member

Choose a reason for hiding this comment

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

Is having VIP24 on block2 something we need to address ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the result of a refactoring: this function is called by already existing tests with this fork config. Actually, I might remove this function and move this fork config inside the test, passing it to the new function

consensus/fork/galactica.go Outdated Show resolved Hide resolved
consensus/fork/galactica.go Outdated Show resolved Hide resolved
@@ -121,6 +124,11 @@ func (p *Packer) Schedule(parent *chain.BlockSummary, nowTimestamp uint64) (flow
}
}

var baseFee *big.Int
Copy link
Member

Choose a reason for hiding this comment

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

Would it be worth adding a log saying that we've entered galactica ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, sounds like a good idea

@@ -113,7 +113,6 @@ func TestP(t *testing.T) {

best := repo.BestBlockSummary()
fmt.Println(best.Header.Number(), best.Header.GasUsed())
Copy link
Member

Choose a reason for hiding this comment

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

Might want to change this print to log ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually I had no idea of this line, it looks like some leftover print statement from couple of years ago. I'll replace it with some assert on the best block

Comment on lines +48 to +52
if tx.MaxFeePerGas() == nil {
return nil, errors.New("max fee per gas is required")
}
if tx.MaxPriorityFeePerGas() == nil {
return nil, errors.New("max priority fee per gas is required")
Copy link
Member

Choose a reason for hiding this comment

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

This will be set elsewhere, even it its a legacy tx correct ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is to make sure we have not nil pointer dereference. For the legacy it's impossible this scenario since they use the gasPriceCoef in combination with the old GasPrice func, and gasPriceCoef cannot be nil

runtime/runtime.go Outdated Show resolved Hide resolved
@paologalligit paologalligit marked this pull request as ready for review February 11, 2025 15:54
@paologalligit paologalligit requested a review from a team as a code owner February 11, 2025 15:54
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.

3 participants