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

network from fork version #102

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
Prev Previous commit
Next Next commit
add support for returning network based on fork version
y0sher authored Oct 31, 2023
commit 1f6fd74b51b56ddf6c4838e06a80b5b885f890de
17 changes: 17 additions & 0 deletions core/networks.go
Original file line number Diff line number Diff line change
@@ -44,6 +44,23 @@ func (n Network) GenesisForkVersion() phase0.Version {
}
}

// NetworkFromGenesisForkVersion returns the network base on the 4 bytes of the genesis fork version
func NetworkFromGenesisForkVersion(fork phase0.Version) Network {
switch fork {
case phase0.Version{0, 0, 32, 9}:
return PyrmontNetwork
case phase0.Version{0x00, 0x00, 0x10, 0x20}:
return PraterNetwork
case phase0.Version{0x01, 0x01, 0x70, 0x00}:
return HoleskyNetwork
case phase0.Version{0, 0, 0, 0}:
return MainNetwork
default:
logrus.WithField("network", n).Fatal("undefined network")
return ""
}
}

// GenesisValidatorsRoot returns the genesis validators root of the network.
func (n Network) GenesisValidatorsRoot() phase0.Root {
var genValidatorsRoot phase0.Root