Skip to content

Commit

Permalink
Add all other GingerbreadP2 flags
Browse files Browse the repository at this point in the history
  • Loading branch information
gastonponti committed Aug 11, 2023
1 parent 85261d7 commit f8071f4
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 17 deletions.
3 changes: 3 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
if ctx.GlobalIsSet(utils.OverrideGingerbreadFlag.Name) {
cfg.Eth.OverrideGingerbread = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideGingerbreadFlag.Name))
}
if ctx.GlobalIsSet(utils.OverrideGingerbreadP2Flag.Name) {
cfg.Eth.OverrideGingerbreadP2 = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideGingerbreadP2Flag.Name))
}
backend, _ := utils.RegisterEthService(stack, &cfg.Eth)

// Configure GraphQL if requested
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var (
utils.USBFlag,
// utils.SmartCardDaemonPathFlag,
utils.OverrideGingerbreadFlag,
utils.OverrideGingerbreadP2Flag,
utils.TxPoolLocalsFlag,
utils.TxPoolNoLocalsFlag,
utils.TxPoolJournalFlag,
Expand Down
13 changes: 13 additions & 0 deletions cmd/mycelo/genesis_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ var templateFlags = []cli.Flag{
Name: "forks.gingerbread",
Usage: "Optional flag to allow gingerbread fork overwritting (default: 0, disable: -1)",
},
cli.Int64Flag{
Name: "forks.gingerbreadp2",
Usage: "Optional flag to allow gingerbread p2 fork overwritting (default: 0, disable: -1)",
},
}

var buildpathFlag = cli.StringFlag{
Expand Down Expand Up @@ -183,6 +187,15 @@ func envFromTemplate(ctx *cli.Context, workdir string) (*env.Environment, *genes

genesisConfig.Hardforks.GingerbreadBlock = gingerbreadBlock

if ctx.IsSet("forks.gingerbreadp2") {
gingerbreadP2BlockNumber := ctx.Int64("forks.gingerbreadp2")
if gingerbreadP2BlockNumber < 0 {
genesisConfig.Hardforks.GingerbreadP2Block = nil
} else {
genesisConfig.Hardforks.GingerbreadP2Block = big.NewInt(gingerbreadP2BlockNumber)
}
}

return env, genesisConfig, nil
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ var (
Usage: "Manually specify the gingerbread fork block, overriding the bundled setting",
}

OverrideGingerbreadP2Flag = cli.Uint64Flag{
Name: "override.gingerbreadp2",
Usage: "Manually specify the gingerbread p2 fork block, overriding the bundled setting",
}

BloomFilterSizeFlag = cli.Uint64Flag{
Name: "bloomfilter.size",
Usage: "Megabytes of memory allocated to bloom-filter for pruning",
Expand Down
7 changes: 5 additions & 2 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ func (e *GenesisMismatchError) Error() string {
//
// The returned chain configuration is never nil.
func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig, common.Hash, error) {
return SetupGenesisBlockWithOverride(db, genesis, nil)
return SetupGenesisBlockWithOverride(db, genesis, nil, nil)
}

func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, overrideGingerbread *big.Int) (*params.ChainConfig, common.Hash, error) {
func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, overrideGingerbread, overrideGingerbreadP2 *big.Int) (*params.ChainConfig, common.Hash, error) {
if genesis != nil && (genesis.Config == nil || genesis.Config.Istanbul == nil) {
return params.MainnetChainConfig, common.Hash{}, errGenesisNoConfig
}
Expand Down Expand Up @@ -207,6 +207,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override
if overrideGingerbread != nil {
newcfg.GingerbreadBlock = overrideGingerbread
}
if overrideGingerbreadP2 != nil {
newcfg.GingerbreadP2Block = overrideGingerbreadP2
}

if err := newcfg.CheckConfigForkOrder(); err != nil {
return newcfg, common.Hash{}, err
Expand Down
1 change: 1 addition & 0 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestStateProcessorErrors(t *testing.T) {
DonutBlock: big.NewInt(0),
EspressoBlock: big.NewInt(0),
GingerbreadBlock: big.NewInt(0),
GingerbreadP2Block: big.NewInt(0),
Faker: true,
FakeBaseFee: common.Big3,
}
Expand Down
2 changes: 1 addition & 1 deletion core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter {
if cfg.JumpTable[STOP] == nil {
var jt JumpTable
switch {
case evm.chainRules.IsGingerbread:
case evm.chainRules.IsGingerbread, evm.chainRules.IsGingerbreadP2:
jt = gingerbreadInstructionSet
case evm.chainRules.IsEspresso:
jt = espressoInstructionSet
Expand Down
1 change: 1 addition & 0 deletions core/vm/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func setDefaults(cfg *Config) {
DonutBlock: new(big.Int),
EspressoBlock: new(big.Int),
GingerbreadBlock: new(big.Int),
GingerbreadP2Block: new(big.Int),
}
}
if cfg.Time == nil {
Expand Down
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if err != nil {
return nil, err
}
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis, config.OverrideGingerbread)
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis, config.OverrideGingerbread, config.OverrideGingerbreadP2)
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
return nil, genesisErr
}
Expand Down
3 changes: 3 additions & 0 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ type Config struct {
// Gingerbread block override (TODO: remove after the fork)
OverrideGingerbread *big.Int `toml:",omitempty"`

// Gingerbread block override (TODO: remove after the fork)
OverrideGingerbreadP2 *big.Int `toml:",omitempty"`

// The minimum required peers in order for syncing to be initiated, if left
// at 0 then the default will be used.
MinSyncPeers int `toml:",omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions eth/ethconfig/gen_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion les/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) {
return nil, err
}
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis,
config.OverrideGingerbread)
config.OverrideGingerbread, config.OverrideGingerbreadP2)
if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat {
return nil, genesisErr
}
Expand Down
1 change: 1 addition & 0 deletions miner/stress/1559/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func makeGenesis(faucets []*ecdsa.PrivateKey) *core.Genesis {

genesis.Config = params.BaklavaChainConfig
genesis.Config.GingerbreadBlock = gingerbreadBlock
genesis.Config.GingerbreadP2Block = gingerbreadBlock

genesis.Config.ChainID = big.NewInt(18)
genesis.Config.EIP150Hash = common.Hash{}
Expand Down
18 changes: 10 additions & 8 deletions mycelo/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ func (cfg *Config) ChainConfig() *params.ChainConfig {
PetersburgBlock: common.Big0,
IstanbulBlock: common.Big0,

ChurritoBlock: cfg.Hardforks.ChurritoBlock,
DonutBlock: cfg.Hardforks.DonutBlock,
EspressoBlock: cfg.Hardforks.EspressoBlock,
GingerbreadBlock: cfg.Hardforks.GingerbreadBlock,
ChurritoBlock: cfg.Hardforks.ChurritoBlock,
DonutBlock: cfg.Hardforks.DonutBlock,
EspressoBlock: cfg.Hardforks.EspressoBlock,
GingerbreadBlock: cfg.Hardforks.GingerbreadBlock,
GingerbreadP2Block: cfg.Hardforks.GingerbreadP2Block,

Istanbul: &params.IstanbulConfig{
Epoch: cfg.Istanbul.Epoch,
Expand All @@ -99,10 +100,11 @@ func (cfg *Config) ChainConfig() *params.ChainConfig {

// HardforkConfig contains celo hardforks activation blocks
type HardforkConfig struct {
ChurritoBlock *big.Int `json:"churritoBlock"`
DonutBlock *big.Int `json:"donutBlock"`
EspressoBlock *big.Int `json:"espressoBlock"`
GingerbreadBlock *big.Int `json:"gingerbreadBlock"`
ChurritoBlock *big.Int `json:"churritoBlock"`
DonutBlock *big.Int `json:"donutBlock"`
EspressoBlock *big.Int `json:"espressoBlock"`
GingerbreadBlock *big.Int `json:"gingerbreadBlock"`
GingerbreadP2Block *big.Int `json:"gingerbreadP2Block"`
}

// MultiSigParameters are the initial configuration parameters for a MultiSig contract
Expand Down
9 changes: 5 additions & 4 deletions mycelo/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ func CreateCommonGenesisConfig(chainID *big.Int, adminAccountAddress common.Addr
genesisConfig.GenesisTimestamp = uint64(time.Now().Unix())
genesisConfig.Istanbul = istanbulConfig
genesisConfig.Hardforks = HardforkConfig{
ChurritoBlock: common.Big0,
DonutBlock: common.Big0,
EspressoBlock: common.Big0,
GingerbreadBlock: gingerbreadBlock,
ChurritoBlock: common.Big0,
DonutBlock: common.Big0,
EspressoBlock: common.Big0,
GingerbreadBlock: gingerbreadBlock,
GingerbreadP2Block: gingerbreadBlock,
}

// Make admin account manager of Governance & Reserve
Expand Down
1 change: 1 addition & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ func (c *ChainConfig) OverrideChainIdConfig(chainId *big.Int) *ChainConfig {

func (c *ChainConfig) DisableGingerbread() *ChainConfig {
c.GingerbreadBlock = nil
c.GingerbreadP2Block = nil
return c
}

Expand Down
16 changes: 16 additions & 0 deletions tests/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@ var Forks = map[string]*params.ChainConfig{
EspressoBlock: big.NewInt(0),
GingerbreadBlock: big.NewInt(0),
},
"GingerbreadP2": {
ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
ChurritoBlock: big.NewInt(0),
DonutBlock: big.NewInt(0),
EspressoBlock: big.NewInt(0),
GingerbreadBlock: big.NewInt(0),
GingerbreadP2Block: big.NewInt(0),
},
}

// Returns the set of defined fork names
Expand Down

0 comments on commit f8071f4

Please sign in to comment.