Skip to content

Commit

Permalink
adapt GasLimitBoundDivisor
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 committed Mar 4, 2025
1 parent ab82c97 commit a7ccdc9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
8 changes: 7 additions & 1 deletion consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ const (
systemRewardPercent = 4 // it means 1/2^4 = 1/16 percentage of gas fee incoming will be distributed to system

collectAdditionalVotesRewardRatio = 100 // ratio of additional reward for collecting more votes than needed, the denominator is 100

GasLimitBoundDivisorBeforeLorentz uint64 = 256 // The bound divisor of the gas limit, used in update calculations.
)

var (
Expand Down Expand Up @@ -705,7 +707,11 @@ func (p *Parlia) verifyCascadingFields(chain consensus.ChainHeaderReader, header
if diff < 0 {
diff *= -1
}
limit := parent.GasLimit / params.GasLimitBoundDivisor
gasLimitBoundDivisor := GasLimitBoundDivisorBeforeLorentz
if p.chainConfig.IsLorentz(header.Number, header.Time) {
gasLimitBoundDivisor = params.GasLimitBoundDivisor
}
limit := parent.GasLimit / gasLimitBoundDivisor

if uint64(diff) >= limit || header.GasLimit < params.MinGasLimit {
return fmt.Errorf("invalid gas limit: have %d, want %d += %d", header.GasLimit, parent.GasLimit, limit-1)
Expand Down
2 changes: 1 addition & 1 deletion params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

const (
GasLimitBoundDivisor uint64 = 256 // The bound divisor of the gas limit, used in update calculations.
GasLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations.
MinGasLimit uint64 = 5000 // Minimum the gas limit may ever be.
MaxGasLimit uint64 = 0x7fffffffffffffff // Maximum the gas limit (2^63-1).
GenesisGasLimit uint64 = 4712388 // Gas limit of the Genesis block.
Expand Down
25 changes: 6 additions & 19 deletions tests/0001-diff-go-ethereum.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
From dba05084d6425657211702dd690ebef0c9c45448 Mon Sep 17 00:00:00 2001
0001-diff-go-ethereum.patch
bdaa06d694bf10297 Mon Sep 17 00:00:00 2001
From: buddh0 <galaxystroller@gmail.com>
Date: Wed, 5 Feb 2025 20:34:36 +0800
Date: Tue, 4 Mar 2025 11:22:17 +0800
Subject: [PATCH] diff go ethereum

---
core/vm/contracts.go | 19 -------------------
core/vm/jump_table.go | 2 +-
params/protocol_params.go | 2 +-
3 files changed, 2 insertions(+), 21 deletions(-)
core/vm/contracts.go | 19 -------------------
core/vm/jump_table.go | 2 +-
2 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/core/vm/contracts.go b/core/vm/contracts.go
index ddde8b0c9..39065b2f7 100644
Expand Down Expand Up @@ -66,19 +66,6 @@ index 299ee4c55..6610fa7f9 100644
enable3855(&instructionSet) // PUSH0 instruction
enable3860(&instructionSet) // Limit and meter initcode

diff --git a/params/protocol_params.go b/params/protocol_params.go
index c83e330a8..903e758df 100644
--- a/params/protocol_params.go
+++ b/params/protocol_params.go
@@ -23,7 +23,7 @@ import (
)

const (
- GasLimitBoundDivisor uint64 = 256 // The bound divisor of the gas limit, used in update calculations.
+ GasLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations.
MinGasLimit uint64 = 5000 // Minimum the gas limit may ever be.
MaxGasLimit uint64 = 0x7fffffffffffffff // Maximum the gas limit (2^63-1).
GenesisGasLimit uint64 = 4712388 // Gas limit of the Genesis block.
--
2.41.0

0 comments on commit a7ccdc9

Please sign in to comment.