Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: 0xPolygon/polygon-edge
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf83dd53f7ce6fdd4549926910b6b0bc46318bea
Choose a base ref
..
head repository: 0xPolygon/polygon-edge
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 592dbf8fd0a945427514737a1829915931de5b6a
Choose a head ref
Showing with 16 additions and 4 deletions.
  1. +5 −0 command/genesis/polybft_params.go
  2. +1 −0 forkmanager/fork.go
  3. +10 −4 forkmanager/fork_manager.go
5 changes: 5 additions & 0 deletions command/genesis/polybft_params.go
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ import (
"github.com/0xPolygon/polygon-edge/consensus/polybft/contractsapi/artifact"
"github.com/0xPolygon/polygon-edge/consensus/polybft/validator"
"github.com/0xPolygon/polygon-edge/contracts"
"github.com/0xPolygon/polygon-edge/forkmanager"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/server"
"github.com/0xPolygon/polygon-edge/types"
@@ -71,6 +72,10 @@ var (

// generatePolyBftChainConfig creates and persists polybft chain configuration to the provided file path
func (p *genesisParams) generatePolyBftChainConfig(o command.OutputFormatter) error {
if err := forkmanager.ForkManagerInit(polybft.ForkManagerFactory, chain.AllForksEnabled); err != nil {
return err
}

// populate premine balance map
premineBalances := make(map[types.Address]*premineInfo, len(p.premine))

1 change: 1 addition & 0 deletions forkmanager/fork.go
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ func ForkManagerInit(factory func(*chain.Forks) error, forks *chain.Forks) error
}

fm := GetInstance()
fm.Clear()

// register initial fork
fm.RegisterFork(InitialFork)
14 changes: 10 additions & 4 deletions forkmanager/fork_manager.go
Original file line number Diff line number Diff line change
@@ -35,15 +35,21 @@ func GetInstance() *forkManager {
defer forkManagerInstanceLock.Unlock()

if forkManagerInstance == nil {
forkManagerInstance = &forkManager{
forkMap: map[string]*Fork{},
handlersMap: map[HandlerDesc][]Handler{},
}
forkManagerInstance = &forkManager{}
forkManagerInstance.Clear()
}

return forkManagerInstance
}

func (fm *forkManager) Clear() {
fm.lock.Lock()
defer fm.lock.Unlock()

fm.forkMap = map[string]*Fork{}
fm.handlersMap = map[HandlerDesc][]Handler{}
}

// RegisterFork registers fork by its name
func (fm *forkManager) RegisterFork(name string) {
fm.lock.Lock()