Skip to content
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
4 changes: 4 additions & 0 deletions cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
if chainConfig.IsFeynmanTransitionBlock(pre.Env.Timestamp, pre.Env.ParentTimestamp) {
misc.ApplyFeynmanHardFork(statedb)
}
// Apply GalileoV2 hard fork
if chainConfig.IsGalileoV2TransitionBlock(pre.Env.Timestamp, pre.Env.ParentTimestamp) {
misc.ApplyGalileoV2HardFork(statedb)
}
// Apply EIP-2935
if pre.Env.BlockHashes != nil && chainConfig.IsFeynman(pre.Env.Timestamp) {
var (
Expand Down
20 changes: 20 additions & 0 deletions consensus/misc/galileoV2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package misc

import (
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/state"
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/rollup/rcfg"
)

// ApplyGalileoV2HardFork modifies the state database according to the GalileoV2 hard-fork rules,
// updating the bytecode and storage of the L1GasPriceOracle contract.
func ApplyGalileoV2HardFork(statedb *state.StateDB) {
log.Info("Applying GalileoV2 hard fork")

// update contract byte code
statedb.SetCode(rcfg.L1GasPriceOracleAddress, rcfg.GalileoV2L1GasPriceOracleBytecode)

// initialize new storage slots
statedb.SetState(rcfg.L1GasPriceOracleAddress, rcfg.IsGalileoSlot, common.BytesToHash([]byte{1}))
}
3 changes: 3 additions & 0 deletions core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
if config.IsFeynmanTransitionBlock(b.Time(), parent.Time()) {
misc.ApplyFeynmanHardFork(statedb)
}
if config.IsGalileoV2TransitionBlock(b.Time(), parent.Time()) {
misc.ApplyGalileoV2HardFork(statedb)
}
// Execute any user modifications to the block
if gen != nil {
gen(i, b)
Expand Down
4 changes: 4 additions & 0 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
if p.config.IsFeynmanTransitionBlock(block.Time(), parent.Time) {
misc.ApplyFeynmanHardFork(statedb)
}
// Apply GalileoV2 hard fork
if p.config.IsGalileoV2TransitionBlock(block.Time(), parent.Time) {
misc.ApplyGalileoV2HardFork(statedb)
}
blockContext := NewEVMBlockContext(header, p.bc, p.config, nil)
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg)
processorBlockTransactionGauge.Update(int64(block.Transactions().Len()))
Expand Down
3 changes: 2 additions & 1 deletion eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,11 @@ func generateWitness(blockchain *core.BlockChain, block *types.Block) (*stateles
// Collect storage locations that prover needs but sequencer might not touch necessarily
statedb.GetState(rcfg.L2MessageQueueAddress, rcfg.WithdrawTrieRootSlot)

// Note: scroll-revm detects the Feynman transition block using this storage slot,
// Note: scroll-revm detects the Feynman and GalileoV2 transition blocks using these storage slots,
// since it does not have access to the parent block timestamp. We need to make
// sure that this is always present in the execution witness.
statedb.GetState(rcfg.L1GasPriceOracleAddress, rcfg.IsFeynmanSlot)
statedb.GetState(rcfg.L1GasPriceOracleAddress, rcfg.IsGalileoSlot)

// Ensure that all access list entries are included in the witness,
// as these are always loaded by revm.
Expand Down
5 changes: 5 additions & 0 deletions miner/scroll_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,11 @@ func (w *worker) handleForks(parent *types.Block) (bool, error) {
misc.ApplyFeynmanHardFork(w.current.state)
}

// Apply GalileoV2 hard fork
if w.chainConfig.IsGalileoV2TransitionBlock(w.current.header.Time, parent.Time()) {
misc.ApplyGalileoV2HardFork(w.current.state)
}

// Apply EIP-2935
if w.chainConfig.IsFeynman(w.current.header.Time) {
context := core.NewEVMBlockContext(w.current.header, w.chain, w.chainConfig, nil)
Expand Down
31 changes: 26 additions & 5 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ var (
EuclidV2Time: newUint64(1741852800),
FeynmanTime: newUint64(1753167600),
GalileoTime: newUint64(1764054000),
GalileoV2Time: nil,
Clique: &CliqueConfig{
Period: 3,
Epoch: 30000,
Expand Down Expand Up @@ -387,6 +388,8 @@ var (
EuclidTime: newUint64(1744815600),
EuclidV2Time: newUint64(1745305200),
FeynmanTime: newUint64(1755576000),
GalileoTime: nil,
GalileoV2Time: nil,
Clique: &CliqueConfig{
Period: 3,
Epoch: 30000,
Expand Down Expand Up @@ -672,6 +675,7 @@ type ChainConfig struct {
EuclidV2Time *uint64 `json:"euclidv2Time,omitempty"` // EuclidV2 switch time (nil = no fork, 0 = already on euclidv2)
FeynmanTime *uint64 `json:"feynmanTime,omitempty"` // Feynman switch time (nil = no fork, 0 = already on feynman)
GalileoTime *uint64 `json:"galileoTime,omitempty"` // Galileo switch time (nil = no fork, 0 = already on galileo)
GalileoV2Time *uint64 `json:"galileoV2Time,omitempty"` // GalileoV2 switch time (nil = no fork, 0 = already on galileoV2)

// TerminalTotalDifficulty is the amount of total difficulty reached by
// the network that triggers the consensus upgrade.
Expand Down Expand Up @@ -878,7 +882,11 @@ func (c *ChainConfig) String() string {
if c.GalileoTime != nil {
galileoTime = fmt.Sprintf("@%v", *c.GalileoTime)
}
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, Archimedes: %v, Shanghai: %v, Bernoulli: %v, Curie: %v, Darwin: %v, DarwinV2: %v, Euclid: %v, EuclidV2: %v, Feynman: %v, Galileo: %v, Engine: %v, Scroll config: %v}",
galileoV2Time := "<nil>"
if c.GalileoV2Time != nil {
galileoV2Time = fmt.Sprintf("@%v", *c.GalileoV2Time)
}
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, Archimedes: %v, Shanghai: %v, Bernoulli: %v, Curie: %v, Darwin: %v, DarwinV2: %v, Euclid: %v, EuclidV2: %v, Feynman: %v, Galileo: %v, GalileoV2: %v, Engine: %v, Scroll config: %v}",
c.ChainID,
c.HomesteadBlock,
c.DAOForkBlock,
Expand All @@ -904,6 +912,7 @@ func (c *ChainConfig) String() string {
euclidV2Time,
feynmanTime,
galileoTime,
galileoV2Time,
engine,
c.Scroll,
)
Expand Down Expand Up @@ -1021,13 +1030,24 @@ func (c *ChainConfig) IsFeynman(now uint64) bool {
return isForkedTime(now, c.FeynmanTime)
}

// IsFeynmanTransitionBlock returns whether the given block timestamp corresponds to the first Feynman block.
func (c *ChainConfig) IsFeynmanTransitionBlock(blockTimestamp uint64, parentTimestamp uint64) bool {
return isForkedTime(blockTimestamp, c.FeynmanTime) && !isForkedTime(parentTimestamp, c.FeynmanTime)
}

// IsGalileo returns whether time is either equal to the Galileo fork time or greater.
func (c *ChainConfig) IsGalileo(now uint64) bool {
return isForkedTime(now, c.GalileoTime)
}

// IsFeynmanTransitionBlock returns whether the given block timestamp corresponds to the first Feynman block.
func (c *ChainConfig) IsFeynmanTransitionBlock(blockTimestamp uint64, parentTimestamp uint64) bool {
return isForkedTime(blockTimestamp, c.FeynmanTime) && !isForkedTime(parentTimestamp, c.FeynmanTime)
// IsGalileoV2 returns whether time is either equal to the GalileoV2 fork time or greater.
func (c *ChainConfig) IsGalileoV2(now uint64) bool {
return isForkedTime(now, c.GalileoV2Time)
}

// IsGalileoV2TransitionBlock returns whether the given block timestamp corresponds to the first GalileoV2 block.
func (c *ChainConfig) IsGalileoV2TransitionBlock(blockTimestamp uint64, parentTimestamp uint64) bool {
return isForkedTime(blockTimestamp, c.GalileoV2Time) && !isForkedTime(parentTimestamp, c.GalileoV2Time)
}

// IsScroll returns whether the node is an scroll node or not.
Expand Down Expand Up @@ -1258,7 +1278,7 @@ type Rules struct {
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
IsBerlin, IsLondon, IsArchimedes, IsShanghai bool
IsBernoulli, IsCurie, IsDarwin, IsEuclid, IsEuclidV2 bool
IsFeynman, IsGalileo bool
IsFeynman, IsGalileo, IsGalileoV2 bool
}

// Rules ensures c's ChainID is not nil.
Expand Down Expand Up @@ -1288,5 +1308,6 @@ func (c *ChainConfig) Rules(num *big.Int, time uint64) Rules {
IsEuclidV2: c.IsEuclidV2(time),
IsFeynman: c.IsFeynman(time),
IsGalileo: c.IsGalileo(time),
IsGalileoV2: c.IsGalileoV2(time),
}
}
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const (
VersionMajor = 5 // Major version component of the current release
VersionMinor = 9 // Minor version component of the current release
VersionPatch = 15 // Patch version component of the current release
VersionPatch = 16 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string
)

Expand Down
14 changes: 14 additions & 0 deletions rollup/rcfg/config.go

Large diffs are not rendered by default.

Loading