Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gray glacier upgrade #124

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ var ETH4345_HEIGHT = map[uint32]uint64{
NETWORK_ID_MAIN_NET: constants.ETH4345_HEIGHT_MAINNET,
}

var ETH5113_HEIGHT = map[uint32]uint64{
NETWORK_ID_MAIN_NET: constants.ETH5113_HEIGHT_MAINNET,
}

var HECO120_HEIGHT = map[uint32]uint64{
NETWORK_ID_MAIN_NET: constants.HECO120_HEIGHT_MAINNET,
NETWORK_ID_TEST_NET: constants.HECO120_HEIGHT_TESTNET,
Expand Down Expand Up @@ -145,6 +149,11 @@ func GetEth4345Height(id uint32) uint64 {
return height
}

func GetEth5113Height(id uint32) uint64 {
height := ETH5113_HEIGHT[id]
return height
}

func GetEth1559Height(id uint32) uint64 {
height := ETH1559_HEIGHT[id]
if height == 0 {
Expand Down
3 changes: 3 additions & 0 deletions common/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ const POLYGON_SNAP_CHAINID_MAINNET = 16

// eth arrow glacier upgrade
const ETH4345_HEIGHT_MAINNET = 13_773_000

// eth gray glacier upgrade
const ETH5113_HEIGHT_MAINNET = 15_050_000
8 changes: 8 additions & 0 deletions native/service/header_sync/eth/header1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ func isArrowGlacier(h *Header) bool {
return h.Number.Uint64() >= forkHeight
}

func isGrayGlacier(h *Header) bool {
forkHeight := config.GetEth5113Height(config.DefConfig.P2PNode.NetworkId)
if forkHeight == 0 {
return false
}
return h.Number.Uint64() >= forkHeight
}

// VerifyGaslimit verifies the header gas limit according increase/decrease
// in relation to the parent gas limit.
func VerifyGaslimit(parentGasLimit, headerGasLimit uint64) error {
Expand Down
4 changes: 3 additions & 1 deletion native/service/header_sync/eth/header_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ func (this *ETHHandler) SyncBlockHeader(native *native.NativeService) error {

//verify difficulty
var expected *big.Int
if isArrowGlacier(&header) {
if isGrayGlacier(&header) {
expected = makeDifficultyCalculator(big.NewInt(11_400_000))(header.Time, parentHeader)
} else if isArrowGlacier(&header) {
expected = makeDifficultyCalculator(big.NewInt(10_700_000))(header.Time, parentHeader)
} else if isLondon(&header) {
expected = makeDifficultyCalculator(big.NewInt(9700000))(header.Time, parentHeader)
Expand Down
Loading