Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

removed london fork fix #1974

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions chain/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ const (
EIP155 = "EIP155"
QuorumCalcAlignment = "quorumcalcalignment"
TxHashWithType = "txHashWithType"
LondonFix = "londonfix"
)

// Forks is map which contains all forks and their starting blocks from genesis
Expand Down Expand Up @@ -125,7 +124,6 @@ func (f *Forks) At(block uint64) ForksInTime {
EIP155: f.IsActive(EIP155, block),
QuorumCalcAlignment: f.IsActive(QuorumCalcAlignment, block),
TxHashWithType: f.IsActive(TxHashWithType, block),
LondonFix: f.IsActive(LondonFix, block),
}
}

Expand Down Expand Up @@ -177,8 +175,7 @@ type ForksInTime struct {
EIP158,
EIP155,
QuorumCalcAlignment,
TxHashWithType,
LondonFix bool
TxHashWithType bool
}

// AllForksEnabled should contain all supported forks by current edge version
Expand All @@ -194,5 +191,4 @@ var AllForksEnabled = &Forks{
London: NewFork(0),
QuorumCalcAlignment: NewFork(0),
TxHashWithType: NewFork(0),
LondonFix: NewFork(0),
}
5 changes: 0 additions & 5 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1062,11 +1062,6 @@ func initForkManager(engineName string, config *chain.Chain) error {
return err
}

// Register Handler for London fork fix
if err := state.RegisterLondonFixFork(chain.LondonFix); err != nil {
return err
}

if factory := forkManagerFactory[ConsensusType(engineName)]; factory != nil {
if err := factory(config.Params.Forks); err != nil {
return err
Expand Down
45 changes: 40 additions & 5 deletions state/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func (t *Transition) ContextPtr() *runtime.TxContext {
}

func (t *Transition) subGasLimitPrice(msg *types.Transaction) error {
upfrontGasCost := GetLondonFixHandler(uint64(t.ctx.Number)).getUpfrontGasCost(msg, t.ctx.BaseFee)
upfrontGasCost := new(big.Int).Mul(new(big.Int).SetUint64(msg.Gas), msg.GetGasPrice(t.ctx.BaseFee.Uint64()))

if err := t.state.SubBalance(msg.From, upfrontGasCost); err != nil {
if errors.Is(err, runtime.ErrNotEnoughFunds) {
Expand All @@ -470,7 +470,39 @@ func (t *Transition) nonceCheck(msg *types.Transaction) error {
// checkDynamicFees checks correctness of the EIP-1559 feature-related fields.
// Basically, makes sure gas tip cap and gas fee cap are good for dynamic and legacy transactions
func (t *Transition) checkDynamicFees(msg *types.Transaction) error {
return GetLondonFixHandler(uint64(t.ctx.Number)).checkDynamicFees(msg, t)
if !t.config.London {
return nil
}

if msg.Type == types.DynamicFeeTx {
if msg.GasFeeCap.BitLen() == 0 && msg.GasTipCap.BitLen() == 0 {
return nil
}

if l := msg.GasFeeCap.BitLen(); l > 256 {
return fmt.Errorf("%w: address %v, GasFeeCap bit length: %d", ErrFeeCapVeryHigh,
msg.From.String(), l)
}

if l := msg.GasTipCap.BitLen(); l > 256 {
return fmt.Errorf("%w: address %v, GasTipCap bit length: %d", ErrTipVeryHigh,
msg.From.String(), l)
}

if msg.GasFeeCap.Cmp(msg.GasTipCap) < 0 {
return fmt.Errorf("%w: address %v, GasTipCap: %s, GasFeeCap: %s", ErrTipAboveFeeCap,
msg.From.String(), msg.GasTipCap, msg.GasFeeCap)
}
}

// This will panic if baseFee is nil, but basefee presence is verified
// as part of header validation.
if gasFeeCap := msg.GetGasFeeCap(); gasFeeCap.Cmp(t.ctx.BaseFee) < 0 {
return fmt.Errorf("%w: address %v, GasFeeCap/GasPrice: %s, BaseFee: %s", ErrFeeCapTooLow,
msg.From.String(), gasFeeCap, t.ctx.BaseFee)
}

return nil
}

// errors that can originate in the consensus rules checks of the apply method below
Expand Down Expand Up @@ -596,9 +628,12 @@ func (t *Transition) apply(msg *types.Transaction) (*runtime.ExecutionResult, er
// Define effective tip based on tx type.
// We use EIP-1559 fields of the tx if the london hardfork is enabled.
// Effective tip became to be either gas tip cap or (gas fee cap - current base fee)
effectiveTip := GetLondonFixHandler(uint64(t.ctx.Number)).getEffectiveTip(
msg, gasPrice, t.ctx.BaseFee, t.config.London,
)
var effectiveTip *big.Int
if t.config.London {
effectiveTip = msg.EffectiveGasTip(t.ctx.BaseFee)
} else {
effectiveTip = new(big.Int).Set(gasPrice)
}

// Pay the coinbase fee as a miner reward using the calculated effective tip.
coinbaseFee := new(big.Int).Mul(new(big.Int).SetUint64(result.GasUsed), effectiveTip)
Expand Down
164 changes: 0 additions & 164 deletions state/londonFix_fork.go

This file was deleted.