2023-06-08 07:43:27 +00:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/ledgerwatch/erigon-lib/common"
|
2023-09-05 20:37:18 +00:00
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
2023-12-04 23:13:52 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cl/beacon/beaconhttp"
|
2023-06-08 07:43:27 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cl/fork"
|
|
|
|
)
|
|
|
|
|
2023-12-11 03:08:00 +00:00
|
|
|
type genesisResponse struct {
|
2023-09-05 20:37:18 +00:00
|
|
|
GenesisTime uint64 `json:"genesis_time,omitempty"`
|
|
|
|
GenesisValidatorRoot common.Hash `json:"genesis_validator_root,omitempty"`
|
|
|
|
GenesisForkVersion libcommon.Bytes4 `json:"genesis_fork_version,omitempty"`
|
2023-06-08 07:43:27 +00:00
|
|
|
}
|
|
|
|
|
2023-12-04 23:13:52 +00:00
|
|
|
func (a *ApiHandler) getGenesis(r *http.Request) (*beaconResponse, error) {
|
2023-06-08 07:43:27 +00:00
|
|
|
if a.genesisCfg == nil {
|
2023-12-04 23:13:52 +00:00
|
|
|
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, "Genesis Config is missing")
|
2023-06-08 07:43:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
digest, err := fork.ComputeForkDigest(a.beaconChainCfg, a.genesisCfg)
|
|
|
|
if err != nil {
|
2023-12-04 23:13:52 +00:00
|
|
|
return nil, err
|
2023-06-08 07:43:27 +00:00
|
|
|
}
|
|
|
|
|
2023-12-11 03:08:00 +00:00
|
|
|
return newBeaconResponse(&genesisResponse{
|
2023-06-08 07:43:27 +00:00
|
|
|
GenesisTime: a.genesisCfg.GenesisTime,
|
|
|
|
GenesisValidatorRoot: a.genesisCfg.GenesisValidatorRoot,
|
2023-09-01 13:29:17 +00:00
|
|
|
GenesisForkVersion: digest,
|
2023-12-04 23:13:52 +00:00
|
|
|
}), nil
|
2023-06-08 07:43:27 +00:00
|
|
|
}
|