Skip to content

Commit f66a9d2

Browse files
committed
Fixed config usage.
1 parent 4a89f05 commit f66a9d2

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

consensus/misc/eip1559/eip1559.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,26 @@
1717
package eip1559
1818

1919
import (
20+
"fmt"
2021
"math/big"
2122

2223
"github.com/ethereum/go-ethereum/common"
24+
"github.com/ethereum/go-ethereum/consensus/misc"
2325
"github.com/harmony-one/harmony/block"
2426
"github.com/harmony-one/harmony/internal/params"
27+
"github.com/pkg/errors"
2528
)
2629

27-
/*
2830
// VerifyEIP1559Header verifies some header attributes which were changed in EIP-1559,
2931
// - gas limit check
3032
// - basefee check
31-
func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Header) error {
33+
func VerifyEIP1559Header(config *params.ChainConfig, parent, header *block.Header) error {
3234
// Verify that the gas limit remains within allowed bounds
33-
parentGasLimit := parent.GasLimit
34-
if !config.IsLondon(parent.Number) {
35-
parentGasLimit = parent.GasLimit * config.ElasticityMultiplier()
35+
parentGasLimit := parent.GasLimit()
36+
if !config.IsLondon(parent.Number()) {
37+
parentGasLimit = parent.GasLimit() * config.ElasticityMultiplier()
3638
}
37-
if err := misc.VerifyGaslimit(parentGasLimit, header.GasLimit); err != nil {
39+
if err := misc.VerifyGaslimit(parentGasLimit, header.GasLimit()); err != nil {
3840
return err
3941
}
4042
// Verify the header is not malformed
@@ -43,13 +45,12 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade
4345
}
4446
// Verify the baseFee is correct based on the parent header.
4547
expectedBaseFee := CalcBaseFee(config, parent)
46-
if header.BaseFee.Cmp(expectedBaseFee) != 0 {
48+
if header.BaseFee().Cmp(expectedBaseFee) != 0 {
4749
return fmt.Errorf("invalid baseFee: have %s, want %s, parentBaseFee %s, parentGasUsed %d",
48-
header.BaseFee, expectedBaseFee, parent.BaseFee, parent.GasUsed)
50+
header.BaseFee(), expectedBaseFee, parent.BaseFee(), parent.GasUsed())
4951
}
5052
return nil
5153
}
52-
*/
5354

5455
// CalcBaseFee calculates the basefee of the header.
5556
func CalcBaseFee(config *params.ChainConfig, parent *block.Header) *big.Int {

consensus/misc/eip1559/eip1559_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ import (
2222

2323
"github.com/ethereum/go-ethereum/common"
2424
"github.com/ethereum/go-ethereum/core/types"
25-
"github.com/ethereum/go-ethereum/params"
25+
"github.com/harmony-one/harmony/internal/params"
26+
27+
"github.com/harmony-one/harmony/block"
28+
v4 "github.com/harmony-one/harmony/block/v4"
2629
)
2730

2831
// copyConfig does a _shallow_ copy of a given config. Safe to set new values, but
@@ -51,7 +54,7 @@ func copyConfig(original *params.ChainConfig) *params.ChainConfig {
5154

5255
func config() *params.ChainConfig {
5356
config := copyConfig(params.TestChainConfig)
54-
config.LondonBlock = big.NewInt(5)
57+
config.EIP1559Epoch = big.NewInt(1)
5558
return config
5659
}
5760

@@ -83,7 +86,7 @@ func TestBlockGasLimits(t *testing.T) {
8386
{40000000, 5, 39960939, true}, // lower limit
8487
{40000000, 5, 39960938, false}, // Lower limit -1
8588
} {
86-
parent := &types.Header{
89+
parent := &block.Header{
8790
GasUsed: tc.pGasLimit / 2,
8891
GasLimit: tc.pGasLimit,
8992
BaseFee: initial,
@@ -118,7 +121,7 @@ func TestCalcBaseFee(t *testing.T) {
118121
{params.InitialBaseFee, 20000000, 11000000, 1012500000}, // usage above target
119122
}
120123
for i, test := range tests {
121-
parent := &types.Header{
124+
parent := &v4.Header{
122125
Number: common.Big32,
123126
GasLimit: test.parentGasLimit,
124127
GasUsed: test.parentGasUsed,

internal/params/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ var (
328328
MaxRateEpoch: EpochTBD,
329329
DevnetExternalEpoch: EpochTBD,
330330
TestnetExternalEpoch: EpochTBD,
331+
EIP1559Epoch: big.NewInt(1),
331332
IsOneSecondEpoch: big.NewInt(4),
332333
}
333334

@@ -913,7 +914,7 @@ func (c *ChainConfig) IsOneEpochBeforeHIP30(epoch *big.Int) bool {
913914
}
914915

915916
func (c *ChainConfig) IsLondon(epoch *big.Int) bool {
916-
panic("unimplemented")
917+
return false
917918
}
918919

919920
// BaseFeeChangeDenominator

0 commit comments

Comments
 (0)