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

Disable london hardfork if burn contract address is not provided #1454

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
33 changes: 21 additions & 12 deletions command/genesis/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ func (p *genesisParams) generateGenesis() error {
}

func (p *genesisParams) initGenesisConfig() error {
// Disable london hardfork if burn contract address is not provided
enabledForks := chain.AllForksEnabled
if len(p.burnContracts) == 0 {
enabledForks.London = nil
}

chainConfig := &chain.Chain{
Name: p.name,
Genesis: &chain.Genesis{
Expand All @@ -364,25 +370,28 @@ func (p *genesisParams) initGenesisConfig() error {
Alloc: map[types.Address]*chain.GenesisAccount{},
ExtraData: p.extraData,
GasUsed: command.DefaultGenesisGasUsed,
BaseFee: command.DefaultGenesisBaseFee,
BaseFeeEM: command.DefaultGenesisBaseFeeEM,
},
Params: &chain.Params{
ChainID: int64(p.chainID),
Forks: chain.AllForksEnabled,
Engine: p.consensusEngineConfig,
BurnContract: map[uint64]string{},
ChainID: int64(p.chainID),
Forks: enabledForks,
Engine: p.consensusEngineConfig,
},
Bootnodes: p.bootnodes,
}

for _, burnContract := range p.burnContracts {
block, address, err := parseBurnContractInfo(burnContract)
if err != nil {
return err
}
if len(p.burnContracts) > 0 {
chainConfig.Genesis.BaseFee = command.DefaultGenesisBaseFee
chainConfig.Genesis.BaseFeeEM = command.DefaultGenesisBaseFeeEM
chainConfig.Params.BurnContract = map[uint64]string{}
begmaroman marked this conversation as resolved.
Show resolved Hide resolved

for _, burnContract := range p.burnContracts {
block, address, err := parseBurnContractInfo(burnContract)
if err != nil {
return err
}

chainConfig.Params.BurnContract[block] = address.String()
chainConfig.Params.BurnContract[block] = address.String()
}
}

// Predeploy staking smart contract if needed
Expand Down
25 changes: 17 additions & 8 deletions command/genesis/polybft_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,20 @@ func (p *genesisParams) generatePolyBftChainConfig(o command.OutputFormatter) er
NativeTokenConfig: p.nativeTokenConfig,
}

// Disable london hardfork if burn contract address is not provided
enabledForks := chain.AllForksEnabled
if len(p.burnContracts) == 0 {
enabledForks.London = nil
}

chainConfig := &chain.Chain{
Name: p.name,
Params: &chain.Params{
ChainID: int64(p.chainID),
Forks: chain.AllForksEnabled,
Forks: enabledForks,
Engine: map[string]interface{}{
string(server.PolyBFTConsensus): polyBftConfig,
},
BurnContract: map[uint64]string{},
},
Bootnodes: p.bootnodes,
}
Expand Down Expand Up @@ -156,13 +161,17 @@ func (p *genesisParams) generatePolyBftChainConfig(o command.OutputFormatter) er
}
}

for _, burnContract := range p.burnContracts {
block, addr, err := parseBurnContractInfo(burnContract)
if err != nil {
return err
}
if len(p.burnContracts) > 0 {
begmaroman marked this conversation as resolved.
Show resolved Hide resolved
chainConfig.Params.BurnContract = map[uint64]string{}
begmaroman marked this conversation as resolved.
Show resolved Hide resolved

for _, burnContract := range p.burnContracts {
block, addr, err := parseBurnContractInfo(burnContract)
if err != nil {
return err
}

chainConfig.Params.BurnContract[block] = addr.String()
chainConfig.Params.BurnContract[block] = addr.String()
}
}

validatorMetadata := make([]*polybft.ValidatorMetadata, len(initialValidators))
Expand Down