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

Draft
wants to merge 23 commits into
base: release/galactica
Choose a base branch
from
Draft

Feat/fee logic #969

wants to merge 23 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 Report

Attention: Patch coverage is 74.05660% with 55 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
consensus/fork/galactica.go 6.66% 28 Missing ⚠️
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 ⚠️
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.18%           
====================================================
  Files                        ?      226           
  Lines                        ?    24073           
  Branches                     ?        0           
====================================================
  Hits                         ?    14730           
  Misses                       ?     8162           
  Partials                     ?     1181           

☔ 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 ?

@@ -78,9 +84,57 @@ func CalcBaseFee(config *thor.ForkConfig, parent *block.Header) *big.Int {
y := x.Div(x, parentGasTargetBig)
baseFeeDelta := x.Div(y, baseFeeChangeDenominator)

// Setting the minimun baseFee to InitialBaseFee
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Setting the minimun baseFee to InitialBaseFee
// Setting the minimum baseFee to InitialBaseFee

)
}
}

func GalacticaTxGasPriceAdapater(tr *tx.Transaction, gasPrice *big.Int) *GalacticaFeeMarketItems {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func GalacticaTxGasPriceAdapater(tr *tx.Transaction, gasPrice *big.Int) *GalacticaFeeMarketItems {
func GalacticaTxGasPriceAdapter(tr *tx.Transaction, gasPrice *big.Int) *GalacticaFeeMarketItems {

@@ -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 ?

@@ -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 ?

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 ?

Comment on lines +94 to +96
// ErrMaxFeePerGasTooLow is returned if the transaction fee cap is less than the
// the base fee of the block.
ErrMaxFeePerGasTooLow = errors.New("max fee per gas is less than block base fee")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// ErrMaxFeePerGasTooLow is returned if the transaction fee cap is less than the
// the base fee of the block.
ErrMaxFeePerGasTooLow = errors.New("max fee per gas is less than block base fee")
// ErrMaxFeePerGasTooLow is returned if the transaction fee cap is less than
// the base fee of the block.
ErrMaxFeePerGasTooLow = errors.New("max fee per gas is less than block base fee")

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