diff --git a/go.mod b/go.mod index daa9e730..ffc06b39 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/ethpandaops/xatu go 1.22.0 -replace github.com/probe-lab/hermes => github.com/ethpandaops/hermes v0.0.0-20240508034827-0c42cafd65a5 +replace github.com/probe-lab/hermes => github.com/ethpandaops/hermes v0.0.0-20240513080348-eafb396a7027 require ( github.com/IBM/sarama v1.43.0 @@ -31,7 +31,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/probe-lab/hermes v0.0.0-20240327153144-a2528356b4f7 github.com/prometheus/client_golang v1.19.0 - github.com/prysmaticlabs/prysm/v5 v5.0.4-0.20240507051732-39060d20cdd9 + github.com/prysmaticlabs/prysm/v5 v5.0.4-0.20240510074809-a76de4f79a99 github.com/r3labs/sse/v2 v2.10.0 github.com/redis/go-redis/v9 v9.5.1 github.com/sirupsen/logrus v1.9.3 @@ -94,7 +94,7 @@ require ( github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect github.com/eapache/queue v1.1.0 // indirect github.com/elastic/gosigar v0.14.2 // indirect - github.com/ethereum/c-kzg-4844 v1.0.1-0.20240422190800-13be436f5927 // indirect + github.com/ethereum/c-kzg-4844 v1.0.2-0.20240507203752-26d3b4156f7a // indirect github.com/fatih/color v1.16.0 // indirect github.com/ferranbt/fastssz v0.1.3 // indirect github.com/flynn/noise v1.1.0 // indirect diff --git a/go.sum b/go.sum index 81ec8f36..d98b546f 100644 --- a/go.sum +++ b/go.sum @@ -256,8 +256,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/c-kzg-4844 v1.0.1-0.20240422190800-13be436f5927 h1:ffWmm0RUR2+VqJsCkf94HqgEwZi2fgbm2iq+O/GdJNI= -github.com/ethereum/c-kzg-4844 v1.0.1-0.20240422190800-13be436f5927/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/c-kzg-4844 v1.0.2-0.20240507203752-26d3b4156f7a h1:EV64oiDZGl97cptCieq1X7KrumSbP4MhmKg0/ll65wo= +github.com/ethereum/c-kzg-4844 v1.0.2-0.20240507203752-26d3b4156f7a/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-ethereum v1.13.14 h1:EwiY3FZP94derMCIam1iW4HFVrSgIcpsu0HwTQtm6CQ= github.com/ethereum/go-ethereum v1.13.14/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= github.com/ethpandaops/beacon v0.36.0 h1:BIsb0ftrrOSwsORCNPvq7df3O5f6sVcFm7guGLpFztc= @@ -266,8 +266,8 @@ github.com/ethpandaops/ethcore v0.0.0-20240422023000-2a5727b18756 h1:8JWjrRfP14m github.com/ethpandaops/ethcore v0.0.0-20240422023000-2a5727b18756/go.mod h1:ZvKqL6CKxiraefdXPHeJurV2pDD/f2HF2uklDVdrry8= github.com/ethpandaops/ethwallclock v0.3.0 h1:xF5fwtBf+bHFHZKBnwiPFEuelW3sMM7SD3ZNFq1lJY4= github.com/ethpandaops/ethwallclock v0.3.0/go.mod h1:y0Cu+mhGLlem19vnAV2x0hpFS5KZ7oOi2SWYayv9l24= -github.com/ethpandaops/hermes v0.0.0-20240508034827-0c42cafd65a5 h1:kbXv4MfY+3xJ5ldL5bxf6AVU0CqmmYFfYSSHssoOUYE= -github.com/ethpandaops/hermes v0.0.0-20240508034827-0c42cafd65a5/go.mod h1:Z65YW+OhX67VHToofu2+wZDdMUgQ1AnvaEPgB9GzTC0= +github.com/ethpandaops/hermes v0.0.0-20240513080348-eafb396a7027 h1:Q9QXjCXYsvFmrlZ+F+w1plLufilUVTLS9trGONbV6IE= +github.com/ethpandaops/hermes v0.0.0-20240513080348-eafb396a7027/go.mod h1:Z65YW+OhX67VHToofu2+wZDdMUgQ1AnvaEPgB9GzTC0= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= @@ -878,8 +878,8 @@ github.com/prysmaticlabs/prombbolt v0.0.0-20210126082820-9b7adba6db7c h1:9PHRCuO github.com/prysmaticlabs/prombbolt v0.0.0-20210126082820-9b7adba6db7c/go.mod h1:ZRws458tYHS/Zs936OQ6oCrL+Ict5O4Xpwve1UQ6C9M= github.com/prysmaticlabs/protoc-gen-go-cast v0.0.0-20230228205207-28762a7b9294 h1:q9wE0ZZRdTUAAeyFP/w0SwBEnCqlVy2+on6X2/e+eAU= github.com/prysmaticlabs/protoc-gen-go-cast v0.0.0-20230228205207-28762a7b9294/go.mod h1:ZVEbRdnMkGhp/pu35zq4SXxtvUwWK0J1MATtekZpH2Y= -github.com/prysmaticlabs/prysm/v5 v5.0.4-0.20240507051732-39060d20cdd9 h1:z6b+3uqU4t2lJAAYIB75Yp8sBaCeo4p1/+uHxZxXkmw= -github.com/prysmaticlabs/prysm/v5 v5.0.4-0.20240507051732-39060d20cdd9/go.mod h1:5Pt2wu6NOUTSzLWcoEco/SraJ4kEEx5HubrHBTsmGmE= +github.com/prysmaticlabs/prysm/v5 v5.0.4-0.20240510074809-a76de4f79a99 h1:RGPhzM/qJR8QqXK8ep2qs3ZABM4tPl0bnGFhDADr+NM= +github.com/prysmaticlabs/prysm/v5 v5.0.4-0.20240510074809-a76de4f79a99/go.mod h1:I3fzhjqrdv/17V3ckLKHLIU2K00kuFzFLw3P24EuKlo= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= diff --git a/pkg/clmimicry/fetch.go b/pkg/clmimicry/fetch.go index 52b8c194..ecd1f35d 100644 --- a/pkg/clmimicry/fetch.go +++ b/pkg/clmimicry/fetch.go @@ -9,22 +9,26 @@ import ( "gopkg.in/yaml.v2" ) -func (m *Mimicry) FetchConfigFromUpstream(ctx context.Context) (*params.BeaconChainConfig, error) { +func (m *Mimicry) FetchConfigFromURL(ctx context.Context, url string) (*params.BeaconChainConfig, error) { + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, err + } - spec, err := m.ethereum.Node().FetchRawSpec(ctx) + response, err := http.DefaultClient.Do(req) if err != nil { return nil, err } + defer response.Body.Close() - // Marshal the spec to a yaml string - yamlSpec, err := yaml.Marshal(spec) + data, err := io.ReadAll(response.Body) if err != nil { return nil, err } - config := ¶ms.BeaconChainConfig{} + config := params.MainnetConfig().Copy() - out, err := params.UnmarshalConfig(yamlSpec, config) + out, err := params.UnmarshalConfig(data, config) if err != nil { return nil, err } diff --git a/pkg/clmimicry/mimicry.go b/pkg/clmimicry/mimicry.go index a966a8c6..b8e6406d 100644 --- a/pkg/clmimicry/mimicry.go +++ b/pkg/clmimicry/mimicry.go @@ -113,11 +113,17 @@ func (m *Mimicry) deriveNetworkConfig(ctx context.Context) (*eth.GenesisConfig, GenesisTime: genesis.GenesisTime, } - beaconChainConfig, err := m.FetchConfigFromUpstream(ctx) + beaconChainConfig, err := m.FetchConfigFromURL(ctx, m.Config.Ethereum.CustomNetwork.ConfigURL) if err != nil { return nil, nil, nil, fmt.Errorf("failed to fetch custom Ethereum network config.yaml: %w", err) } + if err := params.SetActive(beaconChainConfig); err != nil { + return nil, nil, nil, fmt.Errorf("failed to set active network config: %w", err) + } + + params.OverrideBeaconConfig(beaconChainConfig) + networkConfig := params.BeaconNetworkConfig() // TODO: Support others bootnodes, err := FetchBootnodeENRsFromURL(ctx, m.Config.Ethereum.CustomNetwork.BootnodeENRURL) @@ -133,6 +139,8 @@ func (m *Mimicry) deriveNetworkConfig(ctx context.Context) (*eth.GenesisConfig, networkConfig.BootstrapNodes = bootnodes networkConfig.ContractDeploymentBlock = depositContractBlock + params.OverrideBeaconNetworkConfig(networkConfig) + return genesisConfig, networkConfig, beaconChainConfig, nil } @@ -247,7 +255,7 @@ func (m *Mimicry) Start(ctx context.Context) error { m.log.Info("Ethereum client is ready. Starting Hermes..") if err := m.startHermes(ctx); err != nil { - m.log.Fatalf("failed to start hermes: %w", err) + m.log.Fatalf("failed to start hermes: %s", err.Error()) } return nil