Skip to content

Commit 2cdccd4

Browse files
gastonpontipalango
authored andcommittedMar 2, 2023
G Fork base and flags
1 parent bac7831 commit 2cdccd4

File tree

6 files changed

+51
-8
lines changed

6 files changed

+51
-8
lines changed
 

‎cmd/mycelo/genesis_commands.go

+9
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ func envFromTemplate(ctx *cli.Context, workdir string) (*env.Environment, *genes
167167
}
168168
}
169169

170+
if ctx.IsSet("forks.gFork") {
171+
gForkBlockNumber := ctx.Int64("forks.gFork")
172+
if gForkBlockNumber < 0 {
173+
genesisConfig.Hardforks.GForkBlock = nil
174+
} else {
175+
genesisConfig.Hardforks.GForkBlock = big.NewInt(gForkBlockNumber)
176+
}
177+
}
178+
170179
return env, genesisConfig, nil
171180
}
172181

‎core/state_processor_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func TestStateProcessorErrors(t *testing.T) {
5151
ChurritoBlock: big.NewInt(0),
5252
DonutBlock: big.NewInt(0),
5353
EspressoBlock: big.NewInt(0),
54+
GForkBlock: new(big.Int),
5455
Faker: true,
5556
}
5657
signer = types.LatestSigner(config)

‎core/vm/runtime/runtime.go

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func setDefaults(cfg *Config) {
6767
ChurritoBlock: new(big.Int),
6868
DonutBlock: new(big.Int),
6969
EspressoBlock: new(big.Int),
70+
GForkBlock: new(big.Int),
7071
}
7172
}
7273
if cfg.Time == nil {

‎mycelo/genesis/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func (cfg *Config) ChainConfig() *params.ChainConfig {
8585
ChurritoBlock: cfg.Hardforks.ChurritoBlock,
8686
DonutBlock: cfg.Hardforks.DonutBlock,
8787
EspressoBlock: cfg.Hardforks.EspressoBlock,
88+
GForkBlock: cfg.Hardforks.GForkBlock,
8889

8990
Istanbul: &params.IstanbulConfig{
9091
Epoch: cfg.Istanbul.Epoch,
@@ -101,6 +102,7 @@ type HardforkConfig struct {
101102
ChurritoBlock *big.Int `json:"churritoBlock"`
102103
DonutBlock *big.Int `json:"donutBlock"`
103104
EspressoBlock *big.Int `json:"espressoBlock"`
105+
GForkBlock *big.Int `json:"gForkBlock"`
104106
}
105107

106108
// MultiSigParameters are the initial configuration parameters for a MultiSig contract

‎params/config.go

+23-8
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ var (
6565
ChurritoBlock: big.NewInt(6774000),
6666
DonutBlock: big.NewInt(6774000),
6767
EspressoBlock: big.NewInt(11838440),
68+
GForkBlock: nil,
6869
Istanbul: &IstanbulConfig{
6970
Epoch: 17280,
7071
ProposerPolicy: 2,
@@ -90,6 +91,7 @@ var (
9091
ChurritoBlock: big.NewInt(2719099),
9192
DonutBlock: big.NewInt(5002000),
9293
EspressoBlock: big.NewInt(9195000),
94+
GForkBlock: nil,
9395
Istanbul: &IstanbulConfig{
9496
Epoch: 17280,
9597
ProposerPolicy: 2,
@@ -115,6 +117,7 @@ var (
115117
ChurritoBlock: big.NewInt(4960000),
116118
DonutBlock: big.NewInt(4960000),
117119
EspressoBlock: big.NewInt(9472000),
120+
GForkBlock: nil,
118121
Istanbul: &IstanbulConfig{
119122
Epoch: 17280,
120123
ProposerPolicy: 2,
@@ -124,28 +127,28 @@ var (
124127
},
125128
}
126129

127-
DeveloperChainConfig = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, big.NewInt(0), big.NewInt(0), nil, &IstanbulConfig{
130+
DeveloperChainConfig = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, big.NewInt(0), big.NewInt(0), nil, nil, &IstanbulConfig{
128131
Epoch: 300,
129132
ProposerPolicy: 0,
130133
RequestTimeout: 1000,
131134
BlockPeriod: 1,
132135
}, true, false}
133136

134-
IstanbulTestChainConfig = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, big.NewInt(0), nil, nil, &IstanbulConfig{
137+
IstanbulTestChainConfig = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, big.NewInt(0), nil, nil, nil, &IstanbulConfig{
135138
Epoch: 300,
136139
ProposerPolicy: 0,
137140
RequestTimeout: 1000,
138141
BlockPeriod: 1,
139142
}, true, false}
140143

141-
IstanbulEHFTestChainConfig = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), &IstanbulConfig{
144+
IstanbulEHFTestChainConfig = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), &IstanbulConfig{
142145
Epoch: 300,
143146
ProposerPolicy: 0,
144147
RequestTimeout: 1000,
145148
BlockPeriod: 1,
146149
}, true, false}
147150

148-
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, big.NewInt(0), nil, nil, &IstanbulConfig{
151+
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, big.NewInt(0), nil, nil, nil, &IstanbulConfig{
149152
Epoch: 30000,
150153
ProposerPolicy: 0,
151154
}, true, true}
@@ -230,6 +233,7 @@ type ChainConfig struct {
230233
ChurritoBlock *big.Int `json:"churritoBlock,omitempty"` // Churrito switch block (nil = no fork, 0 = already activated)
231234
DonutBlock *big.Int `json:"donutBlock,omitempty"` // Donut switch block (nil = no fork, 0 = already activated)
232235
EspressoBlock *big.Int `json:"espressoBlock,omitempty"` // Espresso switch block (nil = no fork, 0 = already activated)
236+
GForkBlock *big.Int `json:"gForkBlock,omitempty"` // G Fork switch block (nil = no fork, 0 = already activated)
233237

234238
Istanbul *IstanbulConfig `json:"istanbul,omitempty"`
235239
// This does not belong here but passing it to every function is not possible since that breaks
@@ -271,7 +275,7 @@ func (c *ChainConfig) String() string {
271275
} else {
272276
engine = "MockEngine"
273277
}
274-
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 Churrito: %v, Donut: %v, Espresso: %v, Engine: %v}",
278+
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 Churrito: %v, Donut: %v, Espresso: %v, GFork: %v, Engine: %v}",
275279
c.ChainID,
276280
c.HomesteadBlock,
277281
c.DAOForkBlock,
@@ -286,6 +290,7 @@ func (c *ChainConfig) String() string {
286290
c.ChurritoBlock,
287291
c.DonutBlock,
288292
c.EspressoBlock,
293+
c.GForkBlock,
289294
engine,
290295
)
291296
}
@@ -352,11 +357,16 @@ func (c *ChainConfig) IsDonut(num *big.Int) bool {
352357
return isForked(c.DonutBlock, num)
353358
}
354359

355-
// IsEspresso returns whether num represents a block number after the E fork
360+
// IsEspresso returns whether num represents a block number after the Espresso fork
356361
func (c *ChainConfig) IsEspresso(num *big.Int) bool {
357362
return isForked(c.EspressoBlock, num)
358363
}
359364

365+
// IsGFork returns whether num represents a block number after the G fork
366+
func (c *ChainConfig) IsGFork(num *big.Int) bool {
367+
return isForked(c.GForkBlock, num)
368+
}
369+
360370
// CheckCompatible checks whether scheduled fork transitions have been imported
361371
// with a mismatching chain configuration.
362372
func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64) *ConfigCompatError {
@@ -396,6 +406,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
396406
{name: "churritoBlock", block: c.ChurritoBlock},
397407
{name: "donutBlock", block: c.DonutBlock},
398408
{name: "espressoBlock", block: c.EspressoBlock},
409+
{name: "gForkBlock", block: c.GForkBlock},
399410
} {
400411
if lastFork.name != "" {
401412
// Next one must be higher number
@@ -466,7 +477,10 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
466477
return newCompatError("Donut fork block", c.DonutBlock, newcfg.DonutBlock)
467478
}
468479
if isForkIncompatible(c.EspressoBlock, newcfg.EspressoBlock, head) {
469-
return newCompatError("E fork block", c.EspressoBlock, newcfg.EspressoBlock)
480+
return newCompatError("Espresso fork block", c.EspressoBlock, newcfg.EspressoBlock)
481+
}
482+
if isForkIncompatible(c.GForkBlock, newcfg.GForkBlock, head) {
483+
return newCompatError("G fork block", c.GForkBlock, newcfg.GForkBlock)
470484
}
471485
return nil
472486
}
@@ -535,7 +549,7 @@ type Rules struct {
535549
ChainID *big.Int
536550
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
537551
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
538-
IsChurrito, IsDonut, IsEspresso bool
552+
IsChurrito, IsDonut, IsEspresso, IsGFork bool
539553
}
540554

541555
// Rules ensures c's ChainID is not nil.
@@ -557,5 +571,6 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
557571
IsChurrito: c.IsChurrito(num),
558572
IsDonut: c.IsDonut(num),
559573
IsEspresso: c.IsEspresso(num),
574+
IsGFork: c.IsGFork(num),
560575
}
561576
}

‎tests/init.go

+15
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,21 @@ var Forks = map[string]*params.ChainConfig{
170170
DonutBlock: big.NewInt(0),
171171
EspressoBlock: big.NewInt(5),
172172
},
173+
"GFork": {
174+
ChainID: big.NewInt(1),
175+
HomesteadBlock: big.NewInt(0),
176+
EIP150Block: big.NewInt(0),
177+
EIP155Block: big.NewInt(0),
178+
EIP158Block: big.NewInt(0),
179+
ByzantiumBlock: big.NewInt(0),
180+
ConstantinopleBlock: big.NewInt(0),
181+
PetersburgBlock: big.NewInt(0),
182+
IstanbulBlock: big.NewInt(0),
183+
ChurritoBlock: big.NewInt(0),
184+
DonutBlock: big.NewInt(0),
185+
EspressoBlock: big.NewInt(0),
186+
GForkBlock: big.NewInt(0),
187+
},
173188
}
174189

175190
// Returns the set of defined fork names

0 commit comments

Comments
 (0)
Please sign in to comment.