From a7ccdc9e8cf61d5124c6af05dff0ca9f4709bcc1 Mon Sep 17 00:00:00 2001 From: buddh0 Date: Tue, 4 Mar 2025 10:51:20 +0800 Subject: [PATCH] adapt GasLimitBoundDivisor --- consensus/parlia/parlia.go | 8 +++++++- params/protocol_params.go | 2 +- tests/0001-diff-go-ethereum.patch | 25 ++++++------------------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/consensus/parlia/parlia.go b/consensus/parlia/parlia.go index b88f26813f..04f1719dc3 100644 --- a/consensus/parlia/parlia.go +++ b/consensus/parlia/parlia.go @@ -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 ( @@ -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) diff --git a/params/protocol_params.go b/params/protocol_params.go index 800c8578cd..be15a336d2 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. diff --git a/tests/0001-diff-go-ethereum.patch b/tests/0001-diff-go-ethereum.patch index 10a946c6bd..176f79e9af 100644 --- a/tests/0001-diff-go-ethereum.patch +++ b/tests/0001-diff-go-ethereum.patch @@ -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 -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 @@ -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