Skip to content

Commit 5f8d4b6

Browse files
committed
feat: upgrade L1GasOracle predeploy in GalileoV2 upgrade
1 parent d53c0e1 commit 5f8d4b6

File tree

9 files changed

+77
-7
lines changed

9 files changed

+77
-7
lines changed

cmd/evm/internal/t8ntool/execution.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
156156
if chainConfig.IsFeynmanTransitionBlock(pre.Env.Timestamp, pre.Env.ParentTimestamp) {
157157
misc.ApplyFeynmanHardFork(statedb)
158158
}
159+
// Apply GalileoV2 hard fork
160+
if chainConfig.IsGalileoV2TransitionBlock(pre.Env.Timestamp, pre.Env.ParentTimestamp) {
161+
misc.ApplyGalileoV2HardFork(statedb)
162+
}
159163
// Apply EIP-2935
160164
if pre.Env.BlockHashes != nil && chainConfig.IsFeynman(pre.Env.Timestamp) {
161165
var (

consensus/misc/galileoV2.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package misc
2+
3+
import (
4+
"github.com/scroll-tech/go-ethereum/common"
5+
"github.com/scroll-tech/go-ethereum/core/state"
6+
"github.com/scroll-tech/go-ethereum/log"
7+
"github.com/scroll-tech/go-ethereum/rollup/rcfg"
8+
)
9+
10+
// ApplyGalileoV2HardFork modifies the state database according to the GalileoV2 hard-fork rules,
11+
// updating the bytecode and storage of the L1GasPriceOracle contract.
12+
func ApplyGalileoV2HardFork(statedb *state.StateDB) {
13+
log.Info("Applying GalileoV2 hard fork")
14+
15+
// update contract byte code
16+
statedb.SetCode(rcfg.L1GasPriceOracleAddress, rcfg.GalileoV2L1GasPriceOracleBytecode)
17+
18+
// initialize new storage slots
19+
statedb.SetState(rcfg.L1GasPriceOracleAddress, rcfg.IsGalileoSlot, common.BytesToHash([]byte{1}))
20+
}

core/chain_makers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
252252
if config.IsFeynmanTransitionBlock(b.Time(), parent.Time()) {
253253
misc.ApplyFeynmanHardFork(statedb)
254254
}
255+
if config.IsGalileoV2TransitionBlock(b.Time(), parent.Time()) {
256+
misc.ApplyGalileoV2HardFork(statedb)
257+
}
255258
// Execute any user modifications to the block
256259
if gen != nil {
257260
gen(i, b)

core/state_processor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
9797
if p.config.IsFeynmanTransitionBlock(block.Time(), parent.Time) {
9898
misc.ApplyFeynmanHardFork(statedb)
9999
}
100+
// Apply GalileoV2 hard fork
101+
if p.config.IsGalileoV2TransitionBlock(block.Time(), parent.Time) {
102+
misc.ApplyGalileoV2HardFork(statedb)
103+
}
100104
blockContext := NewEVMBlockContext(header, p.bc, p.config, nil)
101105
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg)
102106
processorBlockTransactionGauge.Update(int64(block.Transactions().Len()))

eth/api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,11 @@ func generateWitness(blockchain *core.BlockChain, block *types.Block) (*stateles
362362
// Collect storage locations that prover needs but sequencer might not touch necessarily
363363
statedb.GetState(rcfg.L2MessageQueueAddress, rcfg.WithdrawTrieRootSlot)
364364

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

370371
// Ensure that all access list entries are included in the witness,
371372
// as these are always loaded by revm.

miner/scroll_worker.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,11 @@ func (w *worker) handleForks(parent *types.Block) (bool, error) {
641641
misc.ApplyFeynmanHardFork(w.current.state)
642642
}
643643

644+
// Apply GalileoV2 hard fork
645+
if w.chainConfig.IsGalileoV2TransitionBlock(w.current.header.Time, parent.Time()) {
646+
misc.ApplyGalileoV2HardFork(w.current.state)
647+
}
648+
644649
// Apply EIP-2935
645650
if w.chainConfig.IsFeynman(w.current.header.Time) {
646651
context := core.NewEVMBlockContext(w.current.header, w.chain, w.chainConfig, nil)

params/config.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ var (
334334
EuclidV2Time: newUint64(1741852800),
335335
FeynmanTime: newUint64(1753167600),
336336
GalileoTime: newUint64(1764054000),
337+
GalileoV2Time: nil,
337338
Clique: &CliqueConfig{
338339
Period: 3,
339340
Epoch: 30000,
@@ -387,6 +388,8 @@ var (
387388
EuclidTime: newUint64(1744815600),
388389
EuclidV2Time: newUint64(1745305200),
389390
FeynmanTime: newUint64(1755576000),
391+
GalileoTime: nil,
392+
GalileoV2Time: nil,
390393
Clique: &CliqueConfig{
391394
Period: 3,
392395
Epoch: 30000,
@@ -672,6 +675,7 @@ type ChainConfig struct {
672675
EuclidV2Time *uint64 `json:"euclidv2Time,omitempty"` // EuclidV2 switch time (nil = no fork, 0 = already on euclidv2)
673676
FeynmanTime *uint64 `json:"feynmanTime,omitempty"` // Feynman switch time (nil = no fork, 0 = already on feynman)
674677
GalileoTime *uint64 `json:"galileoTime,omitempty"` // Galileo switch time (nil = no fork, 0 = already on galileo)
678+
GalileoV2Time *uint64 `json:"galileoV2Time,omitempty"` // GalileoV2 switch time (nil = no fork, 0 = already on galileoV2)
675679

676680
// TerminalTotalDifficulty is the amount of total difficulty reached by
677681
// the network that triggers the consensus upgrade.
@@ -878,7 +882,11 @@ func (c *ChainConfig) String() string {
878882
if c.GalileoTime != nil {
879883
galileoTime = fmt.Sprintf("@%v", *c.GalileoTime)
880884
}
881-
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}",
885+
galileoV2Time := "<nil>"
886+
if c.GalileoV2Time != nil {
887+
galileoV2Time = fmt.Sprintf("@%v", *c.GalileoV2Time)
888+
}
889+
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}",
882890
c.ChainID,
883891
c.HomesteadBlock,
884892
c.DAOForkBlock,
@@ -904,6 +912,7 @@ func (c *ChainConfig) String() string {
904912
euclidV2Time,
905913
feynmanTime,
906914
galileoTime,
915+
galileoV2Time,
907916
engine,
908917
c.Scroll,
909918
)
@@ -1021,13 +1030,22 @@ func (c *ChainConfig) IsFeynman(now uint64) bool {
10211030
return isForkedTime(now, c.FeynmanTime)
10221031
}
10231032

1033+
// IsFeynmanTransitionBlock returns whether the given block timestamp corresponds to the first Feynman block.
1034+
func (c *ChainConfig) IsFeynmanTransitionBlock(blockTimestamp uint64, parentTimestamp uint64) bool {
1035+
return isForkedTime(blockTimestamp, c.FeynmanTime) && !isForkedTime(parentTimestamp, c.FeynmanTime)
1036+
}
1037+
10241038
func (c *ChainConfig) IsGalileo(now uint64) bool {
10251039
return isForkedTime(now, c.GalileoTime)
10261040
}
10271041

1028-
// IsFeynmanTransitionBlock returns whether the given block timestamp corresponds to the first Feynman block.
1029-
func (c *ChainConfig) IsFeynmanTransitionBlock(blockTimestamp uint64, parentTimestamp uint64) bool {
1030-
return isForkedTime(blockTimestamp, c.FeynmanTime) && !isForkedTime(parentTimestamp, c.FeynmanTime)
1042+
func (c *ChainConfig) IsGalileoV2(now uint64) bool {
1043+
return isForkedTime(now, c.GalileoV2Time)
1044+
}
1045+
1046+
// IsGalileoV2TransitionBlock returns whether the given block timestamp corresponds to the first GalileoV2 block.
1047+
func (c *ChainConfig) IsGalileoV2TransitionBlock(blockTimestamp uint64, parentTimestamp uint64) bool {
1048+
return isForkedTime(blockTimestamp, c.GalileoV2Time) && !isForkedTime(parentTimestamp, c.GalileoV2Time)
10311049
}
10321050

10331051
// IsScroll returns whether the node is an scroll node or not.
@@ -1258,7 +1276,7 @@ type Rules struct {
12581276
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
12591277
IsBerlin, IsLondon, IsArchimedes, IsShanghai bool
12601278
IsBernoulli, IsCurie, IsDarwin, IsEuclid, IsEuclidV2 bool
1261-
IsFeynman, IsGalileo bool
1279+
IsFeynman, IsGalileo, IsGalileoV2 bool
12621280
}
12631281

12641282
// Rules ensures c's ChainID is not nil.
@@ -1288,5 +1306,6 @@ func (c *ChainConfig) Rules(num *big.Int, time uint64) Rules {
12881306
IsEuclidV2: c.IsEuclidV2(time),
12891307
IsFeynman: c.IsFeynman(time),
12901308
IsGalileo: c.IsGalileo(time),
1309+
IsGalileoV2: c.IsGalileoV2(time),
12911310
}
12921311
}

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 9 // Minor version component of the current release
27-
VersionPatch = 15 // Patch version component of the current release
27+
VersionPatch = 16 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

rollup/rcfg/config.go

Lines changed: 14 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)