mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
fix : jaipurFork & baseFeeChangeDenom hardfork num to bigInt
This commit is contained in:
parent
f768136102
commit
7d92be2f17
9 changed files with 23 additions and 23 deletions
|
|
@ -169,7 +169,7 @@ func encodeSigHeader(w io.Writer, header *types.Header, c *params.BorConfig) {
|
||||||
header.Nonce,
|
header.Nonce,
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.IsJaipur(header.Number.Uint64()) {
|
if c.IsJaipur(header.Number) {
|
||||||
if header.BaseFee != nil {
|
if header.BaseFee != nil {
|
||||||
enc = append(enc, header.BaseFee)
|
enc = append(enc, header.BaseFee)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,20 +125,20 @@ func TestEncodeSigHeaderJaipur(t *testing.T) {
|
||||||
)
|
)
|
||||||
|
|
||||||
// Jaipur NOT enabled and BaseFee not set
|
// Jaipur NOT enabled and BaseFee not set
|
||||||
hash := SealHash(h, ¶ms.BorConfig{JaipurBlock: 10})
|
hash := SealHash(h, ¶ms.BorConfig{JaipurBlock: big.NewInt(10)})
|
||||||
require.Equal(t, hash, hashWithoutBaseFee)
|
require.Equal(t, hash, hashWithoutBaseFee)
|
||||||
|
|
||||||
// Jaipur enabled (Jaipur=0) and BaseFee not set
|
// Jaipur enabled (Jaipur=0) and BaseFee not set
|
||||||
hash = SealHash(h, ¶ms.BorConfig{JaipurBlock: 0})
|
hash = SealHash(h, ¶ms.BorConfig{JaipurBlock: common.Big0})
|
||||||
require.Equal(t, hash, hashWithoutBaseFee)
|
require.Equal(t, hash, hashWithoutBaseFee)
|
||||||
|
|
||||||
h.BaseFee = big.NewInt(2)
|
h.BaseFee = big.NewInt(2)
|
||||||
|
|
||||||
// Jaipur enabled (Jaipur=Header block) and BaseFee set
|
// Jaipur enabled (Jaipur=Header block) and BaseFee set
|
||||||
hash = SealHash(h, ¶ms.BorConfig{JaipurBlock: 1})
|
hash = SealHash(h, ¶ms.BorConfig{JaipurBlock: common.Big1})
|
||||||
require.Equal(t, hash, hashWithBaseFee)
|
require.Equal(t, hash, hashWithBaseFee)
|
||||||
|
|
||||||
// Jaipur NOT enabled and BaseFee set
|
// Jaipur NOT enabled and BaseFee set
|
||||||
hash = SealHash(h, ¶ms.BorConfig{JaipurBlock: 10})
|
hash = SealHash(h, ¶ms.BorConfig{JaipurBlock: big.NewInt(10)})
|
||||||
require.Equal(t, hash, hashWithoutBaseFee)
|
require.Equal(t, hash, hashWithoutBaseFee)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
|
||||||
var (
|
var (
|
||||||
parentGasTarget = parent.GasLimit / params.ElasticityMultiplier
|
parentGasTarget = parent.GasLimit / params.ElasticityMultiplier
|
||||||
parentGasTargetBig = new(big.Int).SetUint64(parentGasTarget)
|
parentGasTargetBig = new(big.Int).SetUint64(parentGasTarget)
|
||||||
baseFeeChangeDenominatorUint64 = params.BaseFeeChangeDenominator(config.Bor, parent.Number.Uint64())
|
baseFeeChangeDenominatorUint64 = params.BaseFeeChangeDenominator(config.Bor, parent.Number)
|
||||||
baseFeeChangeDenominator = new(big.Int).SetUint64(baseFeeChangeDenominatorUint64)
|
baseFeeChangeDenominator = new(big.Int).SetUint64(baseFeeChangeDenominatorUint64)
|
||||||
)
|
)
|
||||||
// If the parent gasUsed is the same as the target, the baseFee remains unchanged.
|
// If the parent gasUsed is the same as the target, the baseFee remains unchanged.
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ func copyConfig(original *params.ChainConfig) *params.ChainConfig {
|
||||||
func config() *params.ChainConfig {
|
func config() *params.ChainConfig {
|
||||||
config := copyConfig(params.TestChainConfig)
|
config := copyConfig(params.TestChainConfig)
|
||||||
config.LondonBlock = big.NewInt(5)
|
config.LondonBlock = big.NewInt(5)
|
||||||
config.Bor.DelhiBlock = 8
|
config.Bor.DelhiBlock = big.NewInt(8)
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ var mainnetBor = &Chain{
|
||||||
BerlinBlock: big.NewInt(14750000),
|
BerlinBlock: big.NewInt(14750000),
|
||||||
LondonBlock: big.NewInt(23850000),
|
LondonBlock: big.NewInt(23850000),
|
||||||
Bor: ¶ms.BorConfig{
|
Bor: ¶ms.BorConfig{
|
||||||
JaipurBlock: 23850000,
|
JaipurBlock: big.NewInt(23850000),
|
||||||
DelhiBlock: 36507200,
|
DelhiBlock: big.NewInt(36507200),
|
||||||
Period: map[string]uint64{
|
Period: map[string]uint64{
|
||||||
"0": 2,
|
"0": 2,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ var mumbaiTestnet = &Chain{
|
||||||
BerlinBlock: big.NewInt(13996000),
|
BerlinBlock: big.NewInt(13996000),
|
||||||
LondonBlock: big.NewInt(22640000),
|
LondonBlock: big.NewInt(22640000),
|
||||||
Bor: ¶ms.BorConfig{
|
Bor: ¶ms.BorConfig{
|
||||||
JaipurBlock: 22770000,
|
JaipurBlock: big.NewInt(22770000),
|
||||||
DelhiBlock: 29392500,
|
DelhiBlock: big.NewInt(29392500),
|
||||||
Period: map[string]uint64{
|
Period: map[string]uint64{
|
||||||
"0": 2,
|
"0": 2,
|
||||||
"25275000": 5,
|
"25275000": 5,
|
||||||
|
|
|
||||||
|
|
@ -349,8 +349,8 @@ var (
|
||||||
BerlinBlock: big.NewInt(13996000),
|
BerlinBlock: big.NewInt(13996000),
|
||||||
LondonBlock: big.NewInt(22640000),
|
LondonBlock: big.NewInt(22640000),
|
||||||
Bor: &BorConfig{
|
Bor: &BorConfig{
|
||||||
JaipurBlock: 22770000,
|
JaipurBlock: big.NewInt(22770000),
|
||||||
DelhiBlock: 29392500,
|
DelhiBlock: big.NewInt(29392500),
|
||||||
Period: map[string]uint64{
|
Period: map[string]uint64{
|
||||||
"0": 2,
|
"0": 2,
|
||||||
"25275000": 5,
|
"25275000": 5,
|
||||||
|
|
@ -399,8 +399,8 @@ var (
|
||||||
BerlinBlock: big.NewInt(14750000),
|
BerlinBlock: big.NewInt(14750000),
|
||||||
LondonBlock: big.NewInt(23850000),
|
LondonBlock: big.NewInt(23850000),
|
||||||
Bor: &BorConfig{
|
Bor: &BorConfig{
|
||||||
JaipurBlock: 23850000,
|
JaipurBlock: big.NewInt(23850000),
|
||||||
DelhiBlock: 36507200,
|
DelhiBlock: big.NewInt(36507200),
|
||||||
Period: map[string]uint64{
|
Period: map[string]uint64{
|
||||||
"0": 2,
|
"0": 2,
|
||||||
},
|
},
|
||||||
|
|
@ -578,8 +578,8 @@ type BorConfig struct {
|
||||||
OverrideStateSyncRecords map[string]int `json:"overrideStateSyncRecords"` // override state records count
|
OverrideStateSyncRecords map[string]int `json:"overrideStateSyncRecords"` // override state records count
|
||||||
BlockAlloc map[string]interface{} `json:"blockAlloc"`
|
BlockAlloc map[string]interface{} `json:"blockAlloc"`
|
||||||
BurntContract map[string]string `json:"burntContract"` // governance contract where the token will be sent to and burnt in london fork
|
BurntContract map[string]string `json:"burntContract"` // governance contract where the token will be sent to and burnt in london fork
|
||||||
JaipurBlock uint64 `json:"jaipurBlock"` // Jaipur switch block (nil = no fork, 0 = already on jaipur)
|
JaipurBlock *big.Int `json:"jaipurBlock"` // Jaipur switch block (nil = no fork, 0 = already on jaipur)
|
||||||
DelhiBlock uint64 `json:"delhiBlock"` // Delhi switch block (nil = no fork, 0 = already on delhi)
|
DelhiBlock *big.Int `json:"delhiBlock"` // Delhi switch block (nil = no fork, 0 = already on delhi)
|
||||||
}
|
}
|
||||||
|
|
||||||
// String implements the stringer interface, returning the consensus engine details.
|
// String implements the stringer interface, returning the consensus engine details.
|
||||||
|
|
@ -603,12 +603,12 @@ func (c *BorConfig) CalculatePeriod(number uint64) uint64 {
|
||||||
return c.calculateBorConfigHelper(c.Period, number)
|
return c.calculateBorConfigHelper(c.Period, number)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *BorConfig) IsJaipur(number uint64) bool {
|
func (c *BorConfig) IsJaipur(number *big.Int) bool {
|
||||||
return number >= c.JaipurBlock
|
return isForked(c.JaipurBlock, number)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *BorConfig) IsDelhi(number uint64) bool {
|
func (c *BorConfig) IsDelhi(number *big.Int) bool {
|
||||||
return number >= c.DelhiBlock
|
return isForked(c.DelhiBlock, number)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *BorConfig) calculateBorConfigHelper(field map[string]uint64, number uint64) uint64 {
|
func (c *BorConfig) calculateBorConfigHelper(field map[string]uint64, number uint64) uint64 {
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ var (
|
||||||
DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not.
|
DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not.
|
||||||
)
|
)
|
||||||
|
|
||||||
func BaseFeeChangeDenominator(borConfig *BorConfig, number uint64) uint64 {
|
func BaseFeeChangeDenominator(borConfig *BorConfig, number *big.Int) uint64 {
|
||||||
if borConfig.IsDelhi(number) {
|
if borConfig.IsDelhi(number) {
|
||||||
return BaseFeeChangeDenominatorPostDelhi
|
return BaseFeeChangeDenominatorPostDelhi
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1109,7 +1109,7 @@ func testEncodeSigHeader(w io.Writer, header *types.Header, c *params.BorConfig)
|
||||||
header.MixDigest,
|
header.MixDigest,
|
||||||
header.Nonce,
|
header.Nonce,
|
||||||
}
|
}
|
||||||
if c.IsJaipur(header.Number.Uint64()) {
|
if c.IsJaipur(header.Number) {
|
||||||
if header.BaseFee != nil {
|
if header.BaseFee != nil {
|
||||||
enc = append(enc, header.BaseFee)
|
enc = append(enc, header.BaseFee)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue