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

*: capella fork to networks #3138

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func bindRunFlags(cmd *cobra.Command, config *app.Config) {
cmd.Flags().StringVar(&config.TestnetConfig.GenesisForkVersionHex, "testnet-fork-version", "", "Genesis fork version in hex of the custom test network.")
cmd.Flags().Uint64Var(&config.TestnetConfig.ChainID, "testnet-chain-id", 0, "Chain ID of the custom test network.")
cmd.Flags().Int64Var(&config.TestnetConfig.GenesisTimestamp, "testnet-genesis-timestamp", 0, "Genesis timestamp of the custom test network.")
cmd.Flags().StringVar(&config.TestnetConfig.CapellaHardFork, "testnet-capella-hard-fork", "", "Capella hard fork version of the custom test network.")

wrapPreRunE(cmd, func(cmd *cobra.Command, args []string) error {
if len(config.BeaconNodeAddrs) == 0 && !config.SimnetBMock {
Expand Down
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Flags:
--simnet-validator-keys-dir string The directory containing the simnet validator key shares. (default ".charon/validator_keys")
--simnet-validator-mock Enables an internal mock validator client when running a simnet. Requires simnet-beacon-mock.
--synthetic-block-proposals Enables additional synthetic block proposal duties. Used for testing of rare duties.
--testnet-capella-hard-fork string Capella hard fork version of the custom test network.
--testnet-chain-id uint Chain ID of the custom test network.
--testnet-fork-version string Genesis fork version in hex of the custom test network.
--testnet-genesis-timestamp int Genesis timestamp of the custom test network.
Expand Down
20 changes: 8 additions & 12 deletions eth2util/helper_capella.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,19 @@ import (
"github.com/obolnetwork/charon/app/errors"
)

var capellaForkMap = map[string]string{
"0x00000000": "0x03000000",
"0x00001020": "0x03001020",
"0x00000064": "0x03000064",
"0x90000069": "0x90000072",
"0x01017000": "0x04017000",
}

// CapellaFork maps generic fork hashes to their specific Capella hardfork
// values.
func CapellaFork(forkHash string) (string, error) {
d, ok := capellaForkMap[forkHash]
if !ok {
return "", errors.New("no capella fork for specified fork")
networksMu.Lock()
defer networksMu.Unlock()

for _, n := range supportedNetworks {
if n.GenesisForkVersionHex == forkHash {
return n.CapellaHardFork, nil
}
}

return d, nil
return "", errors.New("no capella fork for specified fork")
}

type forkDataType struct {
Expand Down
7 changes: 7 additions & 0 deletions eth2util/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type Network struct {
GenesisForkVersionHex string
// GenesisTimestamp represents genesis timestamp of the network in unix format
GenesisTimestamp int64
// CapellaHardFork represents capella fork version, used for computing domains for signatures
CapellaHardFork string
}

// IsNonZero checks if each field in this struct is not equal to its zero value.
Expand All @@ -39,31 +41,36 @@ var (
Name: "mainnet",
GenesisForkVersionHex: "0x00000000",
GenesisTimestamp: 1606824023,
CapellaHardFork: "0x03000000",
}
Goerli = Network{
ChainID: 5,
Name: "goerli",
GenesisForkVersionHex: "0x00001020",
GenesisTimestamp: 1616508000,
CapellaHardFork: "0x03001020",
}
Gnosis = Network{
ChainID: 100,
Name: "gnosis",
GenesisForkVersionHex: "0x00000064",
GenesisTimestamp: 1638993340,
CapellaHardFork: "0x03000064",
}
Sepolia = Network{
ChainID: 11155111,
Name: "sepolia",
GenesisForkVersionHex: "0x90000069",
GenesisTimestamp: 1655733600,
CapellaHardFork: "0x90000072",
}
// Holesky metadata taken from https://github.com/eth-clients/holesky#metadata.
Holesky = Network{
ChainID: 17000,
Name: "holesky",
GenesisForkVersionHex: "0x01017000",
GenesisTimestamp: 1696000704,
CapellaHardFork: "0x04017000",
}
)

Expand Down
Loading