From 1b543eb0ba09ebe424d802d91d389ab2a0e6b2f9 Mon Sep 17 00:00:00 2001 From: Trung Nguyen Date: Mon, 3 Dec 2018 11:10:55 -0500 Subject: [PATCH] separated consts for Quorum and those used in upstream Geth --- consensus/ethash/consensus.go | 6 +++--- params/protocol_params.go | 15 +++++++++------ tests/init_test.go | 9 --------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 28950e749..76a865635 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -31,7 +31,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" - set "gopkg.in/fatih/set.v0" + "gopkg.in/fatih/set.v0" ) // Ethash proof-of-work protocol constants. @@ -285,9 +285,9 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent * if diff < 0 { diff *= -1 } - limit := parent.GasLimit / params.GasLimitBoundDivisor + limit := parent.GasLimit / params.OriginalGasLimitBoundDivisor - if uint64(diff) >= limit || header.GasLimit < params.MinGasLimit { + if uint64(diff) >= limit || header.GasLimit < params.OriginnalMinGasLimit { return fmt.Errorf("invalid gas limit: have %d, want %d += %d", header.GasLimit, parent.GasLimit, limit) } // Verify that the block number is parent's +1 diff --git a/params/protocol_params.go b/params/protocol_params.go index c0cb7294a..2ba50e967 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -21,15 +21,18 @@ import "math/big" var ( TargetGasLimit = GenesisGasLimit // The artificial target - // the followings are modified by Quorum and purposely moved from `const` section - // so to faclitate the execution of Ethereum Tests - // @see tests/init_test.go#TestMain - GasLimitBoundDivisor uint64 = 4096 // The bound divisor of the gas limit, used in update calculations. - MinGasLimit uint64 = 700000000 // Minimum the gas limit may ever be. - GenesisGasLimit uint64 = 800000000 // Gas limit of the Genesis block. ) const ( + // these are original values from upstream Geth, used in ethash consensus + OriginnalMinGasLimit uint64 = 5000 // The bound divisor of the gas limit, used in update calculations. + OriginalGasLimitBoundDivisor uint64 = 1024 // Minimum the gas limit may ever be. + + // modified values for Quorum + GasLimitBoundDivisor uint64 = 4096 // The bound divisor of the gas limit, used in update calculations. + MinGasLimit uint64 = 700000000 // Minimum the gas limit may ever be. + GenesisGasLimit uint64 = 800000000 // Gas limit of the Genesis block. + MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis. ExpByteGas uint64 = 10 // Times ceil(log256(exponent)) for the EXP instruction. SloadGas uint64 = 50 // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. diff --git a/tests/init_test.go b/tests/init_test.go index fda1aa82b..26e919d24 100644 --- a/tests/init_test.go +++ b/tests/init_test.go @@ -261,12 +261,3 @@ func runTestFunc(runTest interface{}, t *testing.T, name string, m reflect.Value m.MapIndex(reflect.ValueOf(key)), }) } - -func TestMain(m *testing.M) { - params.GasLimitBoundDivisor = 1024 - params.MinGasLimit = 5000 - params.GenesisGasLimit = 4712388 - - retCode := m.Run() - os.Exit(retCode) -}