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

feat: add support of BEP-440 #530

Merged
merged 4 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 7 additions & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (
"cmp"
"encoding/json"
"fmt"
"github.com/erigontech/erigon/core/systemcontracts"
"reflect"
"slices"
"time"

"github.com/erigontech/erigon/core/systemcontracts"

"golang.org/x/crypto/sha3"

"github.com/erigontech/erigon-lib/chain"
Expand All @@ -39,6 +40,7 @@ import (
"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/common/u256"
"github.com/erigontech/erigon/consensus"
"github.com/erigontech/erigon/consensus/misc"
"github.com/erigontech/erigon/core/state"
"github.com/erigontech/erigon/core/tracing"
"github.com/erigontech/erigon/core/types"
Expand Down Expand Up @@ -510,6 +512,10 @@ func InitializeBlockExecution(engine consensus.Engine, chain consensus.ChainHead
systemcontracts.UpgradeBuildInSystemContract(cc, header.Number, parent.Time, header.Time, ibs, logger)
}

if cc.IsPrague(header.Time) {
misc.StoreBlockHashesEip2935(header, ibs, cc, chain)
}

noop := state.NewNoopWriter()
ibs.FinalizeTx(cc.Rules(header.Number.Uint64(), header.Time), noop)
return nil
Expand Down
5 changes: 3 additions & 2 deletions core/systemcontracts/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ package systemcontracts

import (
"fmt"
"math/big"
"strconv"

"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/log/v3"
"github.com/erigontech/erigon/core/state"
"github.com/erigontech/erigon/core/types"
"math/big"
"strconv"
)

type UpgradeConfig struct {
Expand Down
10 changes: 5 additions & 5 deletions erigon-lib/chain/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func (c *Config) IsHaber(num uint64, time uint64) bool {
return c.IsLondon(num) && isForked(c.HaberTime, time)
}

// IsHaber returns whether time is either equal to the Haber fork time or greater.
// IsHaber returns whether time is either equal to the HaberFix fork time or greater.
func (c *Config) IsHaberFix(num uint64, time uint64) bool {
return c.IsLondon(num) && isForked(c.HaberFixTime, time)
}
Expand All @@ -513,12 +513,12 @@ func (c *Config) IsOnHaberFix(currentBlockNumber *big.Int, lastBlockTime uint64,
return !c.IsHaberFix(lastBlockNumber.Uint64(), lastBlockTime) && c.IsHaberFix(currentBlockNumber.Uint64(), currentBlockTime)
}

// IsBohr returns whether time is either equal to the Haber fork time or greater.
// IsBohr returns whether time is either equal to the Bohr fork time or greater.
func (c *Config) IsBohr(num uint64, time uint64) bool {
return c.IsLondon(num) && isForked(c.BohrTime, time)
}

// IsOnBohr returns whether currentBlockTime is either equal to the HaberFix fork time or greater firstly.
// IsOnBohr returns whether currentBlockTime is either equal to the Bohr fork time or greater firstly.
func (c *Config) IsOnBohr(currentBlockNumber *big.Int, lastBlockTime uint64, currentBlockTime uint64) bool {
lastBlockNumber := new(big.Int)
if currentBlockNumber.Cmp(big.NewInt(1)) >= 0 {
Expand All @@ -527,12 +527,12 @@ func (c *Config) IsOnBohr(currentBlockNumber *big.Int, lastBlockTime uint64, cur
return !c.IsBohr(lastBlockNumber.Uint64(), lastBlockTime) && c.IsBohr(currentBlockNumber.Uint64(), currentBlockTime)
}

// IsPascal returns whether time is either equal to the Haber fork time or greater.
// IsPascal returns whether time is either equal to the Pascal fork time or greater.
func (c *Config) IsPascal(num uint64, time uint64) bool {
return c.IsLondon(num) && isForked(c.PascalTime, time)
}

// IsOnPascal returns whether currentBlockTime is either equal to the HaberFix fork time or greater firstly.
// IsOnPascal returns whether currentBlockTime is either equal to the Pascal fork time or greater firstly.
func (c *Config) IsOnPascal(currentBlockNumber *big.Int, lastBlockTime uint64, currentBlockTime uint64) bool {
lastBlockNumber := new(big.Int)
if currentBlockNumber.Cmp(big.NewInt(1)) >= 0 {
Expand Down
8 changes: 7 additions & 1 deletion params/chainspecs/bsc.json

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion params/chainspecs/chapel.json

Large diffs are not rendered by default.