From db17d019719cff7aa40b14d880e2b6b69f1b0c54 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Fri, 20 Sep 2024 12:46:51 +0100 Subject: [PATCH 1/7] Fix auth and pathed URLs for events. --- http/events.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/http/events.go b/http/events.go index cb3f189d..b0418c97 100644 --- a/http/events.go +++ b/http/events.go @@ -21,7 +21,6 @@ import ( "math/rand" "net" "net/http" - "net/url" "strings" "time" @@ -54,14 +53,12 @@ func (s *Service) Events(ctx context.Context, topics []string, handler consensus } } - reference, err := url.Parse(fmt.Sprintf("eth/v1/events?topics=%s", strings.Join(topics, "&topics="))) - if err != nil { - return errors.Join(errors.New("invalid endpoint"), err) - } - callURL := s.base.ResolveReference(reference).String() - log.Trace().Str("url", callURL).Msg("GET request to events stream") + endpoint := "/eth/v1/events" + query := "topics=" + strings.Join(topics, "&topics=") + callURL := urlForCall(s.base, endpoint, query) + log.Trace().Str("url", callURL.String()).Msg("GET request to events stream") - client := sse.NewClient(callURL) + client := sse.NewClient(callURL.String()) for k, v := range s.extraHeaders { client.Headers[k] = v } From 791091e5a75bd6695814a586fde20019bfe50c72 Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Thu, 10 Oct 2024 17:22:40 +0100 Subject: [PATCH 2/7] Add goheader check --- .gitignore | 6 ++++++ .golangci.yml | 18 ++++++++++++++++++ api/v1/blobsidecarevent.go | 13 +++++++++++++ api/v1/payloadattributesevent.go | 13 +++++++++++++ api/v1/peers.go | 13 +++++++++++++ http/json.go | 13 +++++++++++++ util/bellatrix/transactions.go | 13 +++++++++++++ util/capella/withdrawals.go | 13 +++++++++++++ 8 files changed, 102 insertions(+) diff --git a/.gitignore b/.gitignore index 8d09c99e..4b4eb8f4 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,11 @@ coverage.html # Vim *.sw? +# IntelliJ and friends +.idea/ + +# Makefile +Makefile + # Local TODO TODO.md diff --git a/.golangci.yml b/.golangci.yml index b94397e5..233a4f27 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -153,6 +153,24 @@ linters-settings: json: snake yaml: snake + goheader: + values: + regexp: + YEARS: '(20\d\d - 20\d\d|20\d\d, 20\d\d|20\d\d)' + template: |- + Copyright © {{ YEARS }} Attestant Limited. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + linters: # Enable all available linters. # Default: false diff --git a/api/v1/blobsidecarevent.go b/api/v1/blobsidecarevent.go index 8c1ad1bb..10208406 100644 --- a/api/v1/blobsidecarevent.go +++ b/api/v1/blobsidecarevent.go @@ -1,3 +1,16 @@ +// Copyright © 2023 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v1 import ( diff --git a/api/v1/payloadattributesevent.go b/api/v1/payloadattributesevent.go index ef8175b6..f321da72 100644 --- a/api/v1/payloadattributesevent.go +++ b/api/v1/payloadattributesevent.go @@ -1,3 +1,16 @@ +// Copyright © 2023 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v1 import ( diff --git a/api/v1/peers.go b/api/v1/peers.go index 004f5a95..8af96907 100644 --- a/api/v1/peers.go +++ b/api/v1/peers.go @@ -1,3 +1,16 @@ +// Copyright © 2023 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v1 import ( diff --git a/http/json.go b/http/json.go index 08997fab..06318c75 100644 --- a/http/json.go +++ b/http/json.go @@ -1,3 +1,16 @@ +// Copyright © 2023 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package http import ( diff --git a/util/bellatrix/transactions.go b/util/bellatrix/transactions.go index eb992222..c6d701d9 100644 --- a/util/bellatrix/transactions.go +++ b/util/bellatrix/transactions.go @@ -1,3 +1,16 @@ +// Copyright © 2023 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package bellatrix import "github.com/attestantio/go-eth2-client/spec/bellatrix" diff --git a/util/capella/withdrawals.go b/util/capella/withdrawals.go index 80098291..8fa671fc 100644 --- a/util/capella/withdrawals.go +++ b/util/capella/withdrawals.go @@ -1,3 +1,16 @@ +// Copyright © 2023 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package capella import "github.com/attestantio/go-eth2-client/spec/capella" From 951cf2c15b346dfa1f9bf1ecf3635e6c8ddf089a Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Fri, 25 Oct 2024 22:02:18 +0100 Subject: [PATCH 3/7] Allow custom HTTP client. --- http/parameters.go | 10 ++++++++++ http/service.go | 27 +++++++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/http/parameters.go b/http/parameters.go index 2f91e076..ab679a5b 100644 --- a/http/parameters.go +++ b/http/parameters.go @@ -15,6 +15,7 @@ package http import ( "errors" + "net/http" "time" "github.com/attestantio/go-eth2-client/metrics" @@ -34,6 +35,7 @@ type parameters struct { hooks *Hooks reducedMemoryUsage bool customSpecSupport bool + client *http.Client } // Parameter is the interface for service parameters. @@ -134,6 +136,14 @@ func WithCustomSpecSupport(customSpecSupport bool) Parameter { }) } +// WithHTTPClient provides a custom HTTP client for communication with the HTTP server. +// If not supplied then a standard HTTP client is used. +func WithHTTPClient(client *http.Client) Parameter { + return parameterFunc(func(p *parameters) { + p.client = client + }) +} + // parseAndCheckParameters parses and checks parameters to ensure that mandatory parameters are present and correct. func parseAndCheckParameters(params ...Parameter) (*parameters, error) { parameters := parameters{ diff --git a/http/service.go b/http/service.go index 8077064c..ddf98843 100644 --- a/http/service.go +++ b/http/service.go @@ -95,18 +95,21 @@ func New(ctx context.Context, params ...Parameter) (client.Service, error) { } } - httpClient := &http.Client{ - Transport: &http.Transport{ - DialContext: (&net.Dialer{ - Timeout: parameters.timeout, - KeepAlive: 30 * time.Second, - DualStack: true, - }).DialContext, - MaxIdleConns: 64, - MaxConnsPerHost: 64, - MaxIdleConnsPerHost: 64, - IdleConnTimeout: 600 * time.Second, - }, + httpClient := parameters.client + if httpClient == nil { + httpClient = &http.Client{ + Transport: &http.Transport{ + DialContext: (&net.Dialer{ + Timeout: parameters.timeout, + KeepAlive: 30 * time.Second, + DualStack: true, + }).DialContext, + MaxIdleConns: 64, + MaxConnsPerHost: 64, + MaxIdleConnsPerHost: 64, + IdleConnTimeout: 600 * time.Second, + }, + } } base, address, err := parseAddress(parameters.address) From dc6247ba49060f45234333f5e410126675545536 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Wed, 11 Dec 2024 13:43:02 +0000 Subject: [PATCH 4/7] Add gaslimit function. --- api/versionedproposal.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/api/versionedproposal.go b/api/versionedproposal.go index 35b8aa3e..f10543d7 100644 --- a/api/versionedproposal.go +++ b/api/versionedproposal.go @@ -451,6 +451,36 @@ func (v *VersionedProposal) Timestamp() (uint64, error) { } } +// GasLimit returns the gas limit of the proposal. +func (v *VersionedProposal) GasLimit() (uint64, error) { + if v.Version >= spec.DataVersionBellatrix && !v.payloadPresent() { + return 0, ErrDataMissing + } + + switch v.Version { + case spec.DataVersionBellatrix: + if v.Blinded { + return v.BellatrixBlinded.Body.ExecutionPayloadHeader.GasLimit, nil + } + + return v.Bellatrix.Body.ExecutionPayload.GasLimit, nil + case spec.DataVersionCapella: + if v.Blinded { + return v.CapellaBlinded.Body.ExecutionPayloadHeader.GasLimit, nil + } + + return v.Capella.Body.ExecutionPayload.GasLimit, nil + case spec.DataVersionDeneb: + if v.Blinded { + return v.DenebBlinded.Body.ExecutionPayloadHeader.GasLimit, nil + } + + return v.Deneb.Block.Body.ExecutionPayload.GasLimit, nil + default: + return 0, ErrUnsupportedVersion + } +} + // Blobs returns the blobs of the proposal. func (v *VersionedProposal) Blobs() ([]deneb.Blob, error) { if v.Version >= spec.DataVersionDeneb && !v.payloadPresent() { From 727775a3b51a59f6bdecf5e3ab83fee053360e6d Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Wed, 11 Dec 2024 13:46:12 +0000 Subject: [PATCH 5/7] Use single internal method for POST requests. --- .golangci.yml | 3 +- http/attesterduties.go | 15 ++- http/http.go | 125 +++++---------------- http/submitaggregateattestations.go | 14 ++- http/submitattestations.go | 14 ++- http/submitattesterslashing.go | 14 ++- http/submitbeaconblock.go | 14 ++- http/submitbeaconcommitteesubscriptions.go | 24 +++- http/submitblindedbeaconblock.go | 13 ++- http/submitblindedproposal.go | 2 +- http/submitblstoexecutionchanges.go | 14 ++- http/submitproposal.go | 2 +- http/submitproposalpreparation.go | 18 ++- http/submitproposalslashing.go | 14 ++- http/submitsynccommitteecontributions.go | 14 ++- http/submitsynccommitteemessages.go | 14 ++- http/submitsynccommitteesubscriptions.go | 22 +++- http/submitvalidatorregistrations.go | 14 ++- http/submitvoluntaryexit.go | 14 ++- http/synccommitteeduties.go | 15 ++- http/validatorbalances.go | 2 +- http/validators.go | 2 +- 22 files changed, 237 insertions(+), 146 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 233a4f27..35a2680a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -181,7 +181,6 @@ linters: - cyclop - depguard - dupl - - execinquery - exhaustive - exhaustruct - exportloopref @@ -193,13 +192,13 @@ linters: - gocognit - goconst - err113 - - gomnd - ireturn - lll - maintidx - mnd - musttag - perfsprint + - recvcheck - varnamelen - wrapcheck - wsl diff --git a/http/attesterduties.go b/http/attesterduties.go index 678c3256..f8d384a3 100644 --- a/http/attesterduties.go +++ b/http/attesterduties.go @@ -60,13 +60,22 @@ func (s *Service) AttesterDuties(ctx context.Context, return nil, errors.Join(errors.New("failed to write end of validator index array"), err) } - url := fmt.Sprintf("/eth/v1/validator/duties/attester/%d", opts.Epoch) - respBodyReader, err := s.post(ctx, url, &reqBodyReader) + endpoint := fmt.Sprintf("/eth/v1/validator/duties/attester/%d", opts.Epoch) + query := "" + + httpResponse, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + &reqBodyReader, + ContentTypeJSON, + map[string]string{}, + ) if err != nil { return nil, errors.Join(errors.New("failed to request attester duties"), err) } - data, metadata, err := decodeJSONResponse(respBodyReader, []*apiv1.AttesterDuty{}) + data, metadata, err := decodeJSONResponse(bytes.NewReader(httpResponse.body), []*apiv1.AttesterDuty{}) if err != nil { return nil, err } diff --git a/http/http.go b/http/http.go index 9a899e2a..18f90c04 100644 --- a/http/http.go +++ b/http/http.go @@ -27,6 +27,7 @@ import ( "github.com/attestantio/go-eth2-client/api" "github.com/attestantio/go-eth2-client/spec" + "github.com/rs/zerolog" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" @@ -34,89 +35,10 @@ import ( ) // defaultUserAgent is sent with requests if no other user agent has been supplied. -const defaultUserAgent = "go-eth2-client/0.21.11" +const defaultUserAgent = "go-eth2-client/0.22.0" // post sends an HTTP post request and returns the body. -func (s *Service) post(ctx context.Context, endpoint string, body io.Reader) (io.Reader, error) { - ctx, span := otel.Tracer("attestantio.go-eth2-client.http").Start(ctx, "post") - defer span.End() - - // #nosec G404 - log := s.log.With().Str("id", fmt.Sprintf("%02x", rand.Int31())).Str("address", s.address).Str("endpoint", endpoint).Logger() - if e := log.Trace(); e.Enabled() { - bodyBytes, err := io.ReadAll(body) - if err != nil { - return nil, errors.New("failed to read request body") - } - body = bytes.NewReader(bodyBytes) - - e.RawJSON("body", bodyBytes).Msg("POST request") - } - - callURL := urlForCall(s.base, endpoint, "") - log.Trace().Str("url", callURL.String()).Msg("URL to POST") - span.SetAttributes(attribute.String("url", callURL.String())) - - opCtx, cancel := context.WithTimeout(ctx, s.timeout) - defer cancel() - req, err := http.NewRequestWithContext(opCtx, http.MethodPost, callURL.String(), body) - if err != nil { - span.SetStatus(codes.Error, "Failed to create request") - - return nil, errors.Join(errors.New("failed to create POST request"), err) - } - - s.addExtraHeaders(req) - req.Header.Set("Content-Type", "application/json") - req.Header.Set("Accept", "application/json") - if req.Header.Get("User-Agent") == "" { - req.Header.Set("User-Agent", defaultUserAgent) - } - - resp, err := s.client.Do(req) - if err != nil { - go s.CheckConnectionState(ctx) - - span.SetStatus(codes.Error, err.Error()) - s.monitorPostComplete(ctx, callURL.Path, "failed") - - return nil, errors.Join(errors.New("failed to call POST endpoint"), err) - } - defer resp.Body.Close() - log = log.With().Int("status_code", resp.StatusCode).Logger() - - data, err := io.ReadAll(resp.Body) - if err != nil { - span.SetStatus(codes.Error, err.Error()) - s.monitorPostComplete(ctx, callURL.Path, "failed") - - return nil, errors.Join(errors.New("failed to read POST response"), err) - } - - statusFamily := statusCodeFamily(resp.StatusCode) - if statusFamily != 2 { - trimmedResponse := bytes.ReplaceAll(bytes.ReplaceAll(data, []byte{0x0a}, []byte{}), []byte{0x0d}, []byte{}) - log.Debug().Int("status_code", resp.StatusCode).RawJSON("response", trimmedResponse).Msg("POST failed") - - span.SetStatus(codes.Error, fmt.Sprintf("Status code %d", resp.StatusCode)) - s.monitorPostComplete(ctx, callURL.Path, "failed") - - return nil, &api.Error{ - Method: http.MethodPost, - StatusCode: resp.StatusCode, - Endpoint: endpoint, - Data: data, - } - } - - log.Trace().Str("response", string(data)).Msg("POST response") - s.monitorPostComplete(ctx, callURL.Path, "succeeded") - - return bytes.NewReader(data), nil -} - -// post2 sends an HTTP post request and returns the body. -func (s *Service) post2(ctx context.Context, +func (s *Service) post(ctx context.Context, endpoint string, query string, opts *api.CommonOpts, @@ -244,12 +166,7 @@ func (s *Service) post2(ctx context.Context, statusFamily := statusCodeFamily(resp.StatusCode) if statusFamily != 2 { - if res.contentType == ContentTypeJSON { - trimmedResponse := bytes.ReplaceAll(bytes.ReplaceAll(res.body, []byte{0x0a}, []byte{}), []byte{0x0d}, []byte{}) - log.Debug().Int("status_code", resp.StatusCode).RawJSON("response", trimmedResponse).Msg("POST failed") - } else { - log.Debug().Int("status_code", resp.StatusCode).Msg("POST failed") - } + s.logBadStatus(ctx, "POST", res, log) span.SetStatus(codes.Error, fmt.Sprintf("Status code %d", resp.StatusCode)) s.monitorPostComplete(ctx, callURL.Path, "failed") @@ -267,6 +184,23 @@ func (s *Service) post2(ctx context.Context, return res, nil } +func (*Service) logBadStatus(_ context.Context, + method string, + res *httpResponse, + log zerolog.Logger, +) { + if res.contentType == ContentTypeJSON { + trimmedResponse := bytes.ReplaceAll(bytes.ReplaceAll(res.body, []byte{0x0a}, []byte{}), []byte{0x0d}, []byte{}) + if bytes.HasPrefix(res.body, []byte("{")) { + log.Debug().Int("status_code", res.statusCode).RawJSON("response", trimmedResponse).Msg(method + " failed") + } else { + log.Debug().Int("status_code", res.statusCode).Str("response", string(trimmedResponse)).Msg(method + " failed") + } + } else { + log.Debug().Int("status_code", res.statusCode).Msg(method + " failed") + } +} + func (s *Service) addExtraHeaders(req *http.Request) { for k, v := range s.extraHeaders { req.Header.Add(k, v) @@ -400,17 +334,9 @@ func (s *Service) get(ctx context.Context, attribute.String("content-type", res.contentType.String()), )) - if res.contentType == ContentTypeJSON { - if e := log.Trace(); e.Enabled() { - trimmedResponse := bytes.ReplaceAll(bytes.ReplaceAll(res.body, []byte{0x0a}, []byte{}), []byte{0x0d}, []byte{}) - e.RawJSON("body", trimmedResponse).Msg("GET response") - } - } - statusFamily := statusCodeFamily(resp.StatusCode) if statusFamily != 2 { - trimmedResponse := bytes.ReplaceAll(bytes.ReplaceAll(res.body, []byte{0x0a}, []byte{}), []byte{0x0d}, []byte{}) - log.Debug().Int("status_code", resp.StatusCode).RawJSON("response", trimmedResponse).Msg("GET failed") + s.logBadStatus(ctx, "GET", res, log) span.SetStatus(codes.Error, fmt.Sprintf("Status code %d", resp.StatusCode)) s.monitorGetComplete(ctx, callURL.Path, "failed") @@ -423,6 +349,13 @@ func (s *Service) get(ctx context.Context, } } + if res.contentType == ContentTypeJSON { + if e := log.Trace(); e.Enabled() { + trimmedResponse := bytes.ReplaceAll(bytes.ReplaceAll(res.body, []byte{0x0a}, []byte{}), []byte{0x0d}, []byte{}) + e.RawJSON("body", trimmedResponse).Msg("GET response") + } + } + if err := populateConsensusVersion(res, resp); err != nil { return nil, errors.Join(errors.New("failed to parse consensus version"), err) } diff --git a/http/submitaggregateattestations.go b/http/submitaggregateattestations.go index 2f204f68..36419288 100644 --- a/http/submitaggregateattestations.go +++ b/http/submitaggregateattestations.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" + "github.com/attestantio/go-eth2-client/api" "github.com/attestantio/go-eth2-client/spec/phase0" ) @@ -33,8 +34,17 @@ func (s *Service) SubmitAggregateAttestations(ctx context.Context, aggregateAndP return errors.Join(errors.New("failed to marshal JSON"), err) } - _, err = s.post(ctx, "/eth/v1/validator/aggregate_and_proofs", bytes.NewBuffer(specJSON)) - if err != nil { + endpoint := "/eth/v1/validator/aggregate_and_proofs" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to submit aggregate and proofs"), err) } diff --git a/http/submitattestations.go b/http/submitattestations.go index 7fcd9ce3..9950be6b 100644 --- a/http/submitattestations.go +++ b/http/submitattestations.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" + "github.com/attestantio/go-eth2-client/api" "github.com/attestantio/go-eth2-client/spec/phase0" ) @@ -33,8 +34,17 @@ func (s *Service) SubmitAttestations(ctx context.Context, attestations []*phase0 return errors.Join(errors.New("failed to marshal JSON"), err) } - _, err = s.post(ctx, "/eth/v1/beacon/pool/attestations", bytes.NewBuffer(specJSON)) - if err != nil { + endpoint := "/eth/v1/beacon/pool/attestations" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to submit beacon attestations"), err) } diff --git a/http/submitattesterslashing.go b/http/submitattesterslashing.go index 9dc970cb..6b3cd2f1 100644 --- a/http/submitattesterslashing.go +++ b/http/submitattesterslashing.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" + "github.com/attestantio/go-eth2-client/api" "github.com/attestantio/go-eth2-client/spec/phase0" ) @@ -33,8 +34,17 @@ func (s *Service) SubmitAttesterSlashing(ctx context.Context, slashing *phase0.A return errors.Join(errors.New("failed to marshal JSON"), err) } - _, err = s.post(ctx, "/eth/v1/beacon/pool/attester_slashings", bytes.NewBuffer(specJSON)) - if err != nil { + endpoint := "/eth/v1/beacon/pool/attester_slashings" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to submit proposal slashing"), err) } diff --git a/http/submitbeaconblock.go b/http/submitbeaconblock.go index c168cfd2..5e1bf4fd 100644 --- a/http/submitbeaconblock.go +++ b/http/submitbeaconblock.go @@ -20,6 +20,7 @@ import ( "errors" client "github.com/attestantio/go-eth2-client" + "github.com/attestantio/go-eth2-client/api" "github.com/attestantio/go-eth2-client/spec" ) @@ -56,8 +57,17 @@ func (s *Service) SubmitBeaconBlock(ctx context.Context, block *spec.VersionedSi return errors.Join(errors.New("failed to marshal JSON"), err) } - _, err = s.post(ctx, "/eth/v1/beacon/blocks", bytes.NewBuffer(specJSON)) - if err != nil { + endpoint := "/eth/v1/beacon/blocks" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to submit beacon block"), err) } diff --git a/http/submitbeaconcommitteesubscriptions.go b/http/submitbeaconcommitteesubscriptions.go index 7ea2d885..66a3ab9d 100644 --- a/http/submitbeaconcommitteesubscriptions.go +++ b/http/submitbeaconcommitteesubscriptions.go @@ -19,22 +19,34 @@ import ( "encoding/json" "errors" - api "github.com/attestantio/go-eth2-client/api/v1" + "github.com/attestantio/go-eth2-client/api" + apiv1 "github.com/attestantio/go-eth2-client/api/v1" ) // SubmitBeaconCommitteeSubscriptions subscribes to beacon committees. -func (s *Service) SubmitBeaconCommitteeSubscriptions(ctx context.Context, subscriptions []*api.BeaconCommitteeSubscription) error { +func (s *Service) SubmitBeaconCommitteeSubscriptions(ctx context.Context, + subscriptions []*apiv1.BeaconCommitteeSubscription, +) error { if err := s.assertIsSynced(ctx); err != nil { return err } - var reqBodyReader bytes.Buffer - if err := json.NewEncoder(&reqBodyReader).Encode(subscriptions); err != nil { + specJSON, err := json.Marshal(subscriptions) + if err != nil { return errors.Join(errors.New("failed to encode beacon committee subscriptions"), err) } - _, err := s.post(ctx, "/eth/v1/validator/beacon_committee_subscriptions", &reqBodyReader) - if err != nil { + endpoint := "/eth/v1/validator/beacon_committee_subscriptions" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to request beacon committee subscriptions"), err) } diff --git a/http/submitblindedbeaconblock.go b/http/submitblindedbeaconblock.go index cc893d09..1fd62a47 100644 --- a/http/submitblindedbeaconblock.go +++ b/http/submitblindedbeaconblock.go @@ -57,8 +57,17 @@ func (s *Service) SubmitBlindedBeaconBlock(ctx context.Context, block *api.Versi return errors.Join(errors.New("failed to marshal JSON"), err) } - _, err = s.post(ctx, "/eth/v1/beacon/blinded_blocks", bytes.NewBuffer(specJSON)) - if err != nil { + endpoint := "/eth/v1/beacon/blinded_blocks" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to submit blinded beacon block"), err) } diff --git a/http/submitblindedproposal.go b/http/submitblindedproposal.go index ee1f2354..80277543 100644 --- a/http/submitblindedproposal.go +++ b/http/submitblindedproposal.go @@ -68,7 +68,7 @@ func (s *Service) SubmitBlindedProposal(ctx context.Context, headers := make(map[string]string) headers["Eth-Consensus-Version"] = strings.ToLower(opts.Proposal.Version.String()) - _, err = s.post2(ctx, endpoint, query, &opts.Common, bytes.NewBuffer(specJSON), ContentTypeJSON, headers) + _, err = s.post(ctx, endpoint, query, &opts.Common, bytes.NewBuffer(specJSON), ContentTypeJSON, headers) if err != nil { return errors.Join(errors.New("failed to submit blinded proposal"), err) } diff --git a/http/submitblstoexecutionchanges.go b/http/submitblstoexecutionchanges.go index 32eef78d..9d598767 100644 --- a/http/submitblstoexecutionchanges.go +++ b/http/submitblstoexecutionchanges.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" + "github.com/attestantio/go-eth2-client/api" "github.com/attestantio/go-eth2-client/spec/capella" ) @@ -35,8 +36,17 @@ func (s *Service) SubmitBLSToExecutionChanges(ctx context.Context, return errors.Join(errors.New("failed to marshal JSON"), err) } - _, err = s.post(ctx, "/eth/v1/beacon/pool/bls_to_execution_changes", bytes.NewBuffer(specJSON)) - if err != nil { + endpoint := "/eth/v1/beacon/pool/bls_to_execution_changes" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to submit BLS to execution change"), err) } diff --git a/http/submitproposal.go b/http/submitproposal.go index 52279ce7..ae8a34ef 100644 --- a/http/submitproposal.go +++ b/http/submitproposal.go @@ -52,7 +52,7 @@ func (s *Service) SubmitProposal(ctx context.Context, headers := make(map[string]string) headers["Eth-Consensus-Version"] = strings.ToLower(opts.Proposal.Version.String()) - _, err = s.post2(ctx, endpoint, query, &opts.Common, bytes.NewBuffer(body), contentType, headers) + _, err = s.post(ctx, endpoint, query, &opts.Common, bytes.NewBuffer(body), contentType, headers) if err != nil { return errors.Join(errors.New("failed to submit proposal"), err) } diff --git a/http/submitproposalpreparation.go b/http/submitproposalpreparation.go index af299fa9..5ec56036 100644 --- a/http/submitproposalpreparation.go +++ b/http/submitproposalpreparation.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" + "github.com/attestantio/go-eth2-client/api" apiv1 "github.com/attestantio/go-eth2-client/api/v1" ) @@ -29,13 +30,22 @@ func (s *Service) SubmitProposalPreparations(ctx context.Context, preparations [ return err } - var reqBodyReader bytes.Buffer - if err := json.NewEncoder(&reqBodyReader).Encode(preparations); err != nil { + specJSON, err := json.Marshal(preparations) + if err != nil { return errors.Join(errors.New("failed to encode proposal preparations"), err) } - _, err := s.post(ctx, "/eth/v1/validator/prepare_beacon_proposer", &reqBodyReader) - if err != nil { + endpoint := "/eth/v1/validator/prepare_beacon_proposer" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to send proposal preparations"), err) } diff --git a/http/submitproposalslashing.go b/http/submitproposalslashing.go index 8006c069..1831c8dd 100644 --- a/http/submitproposalslashing.go +++ b/http/submitproposalslashing.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" + "github.com/attestantio/go-eth2-client/api" "github.com/attestantio/go-eth2-client/spec/phase0" ) @@ -33,8 +34,17 @@ func (s *Service) SubmitProposalSlashing(ctx context.Context, slashing *phase0.P return errors.Join(errors.New("failed to marshal JSON"), err) } - _, err = s.post(ctx, "/eth/v1/beacon/pool/proposer_slashings", bytes.NewBuffer(specJSON)) - if err != nil { + endpoint := "/eth/v1/beacon/pool/proposer_slashings" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to submit proposal slashing"), err) } diff --git a/http/submitsynccommitteecontributions.go b/http/submitsynccommitteecontributions.go index 8a359e68..1f28e966 100644 --- a/http/submitsynccommitteecontributions.go +++ b/http/submitsynccommitteecontributions.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" + "github.com/attestantio/go-eth2-client/api" "github.com/attestantio/go-eth2-client/spec/altair" ) @@ -35,8 +36,17 @@ func (s *Service) SubmitSyncCommitteeContributions(ctx context.Context, return errors.Join(errors.New("failed to marshal JSON"), err) } - _, err = s.post(ctx, "/eth/v1/validator/contribution_and_proofs", bytes.NewBuffer(specJSON)) - if err != nil { + endpoint := "/eth/v1/validator/contribution_and_proofs" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to submit contribution and proofs"), err) } diff --git a/http/submitsynccommitteemessages.go b/http/submitsynccommitteemessages.go index d9514f52..7d7e9a0c 100644 --- a/http/submitsynccommitteemessages.go +++ b/http/submitsynccommitteemessages.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" + "github.com/attestantio/go-eth2-client/api" "github.com/attestantio/go-eth2-client/spec/altair" ) @@ -33,8 +34,17 @@ func (s *Service) SubmitSyncCommitteeMessages(ctx context.Context, messages []*a return errors.Join(errors.New("failed to marshal JSON"), err) } - _, err = s.post(ctx, "/eth/v1/beacon/pool/sync_committees", bytes.NewBuffer(specJSON)) - if err != nil { + endpoint := "/eth/v1/beacon/pool/sync_committees" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to submit sync committee messages"), err) } diff --git a/http/submitsynccommitteesubscriptions.go b/http/submitsynccommitteesubscriptions.go index b8c9a0ab..7821d392 100644 --- a/http/submitsynccommitteesubscriptions.go +++ b/http/submitsynccommitteesubscriptions.go @@ -19,22 +19,32 @@ import ( "encoding/json" "errors" - api "github.com/attestantio/go-eth2-client/api/v1" + "github.com/attestantio/go-eth2-client/api" + apiv1 "github.com/attestantio/go-eth2-client/api/v1" ) // SubmitSyncCommitteeSubscriptions subscribes to sync committees. -func (s *Service) SubmitSyncCommitteeSubscriptions(ctx context.Context, subscriptions []*api.SyncCommitteeSubscription) error { +func (s *Service) SubmitSyncCommitteeSubscriptions(ctx context.Context, subscriptions []*apiv1.SyncCommitteeSubscription) error { if err := s.assertIsSynced(ctx); err != nil { return err } - var reqBodyReader bytes.Buffer - if err := json.NewEncoder(&reqBodyReader).Encode(subscriptions); err != nil { + specJSON, err := json.Marshal(subscriptions) + if err != nil { return errors.Join(errors.New("failed to encode sync committee subscriptions"), err) } - _, err := s.post(ctx, "/eth/v1/validator/sync_committee_subscriptions", &reqBodyReader) - if err != nil { + endpoint := "/eth/v1/validator/sync_committee_subscriptions" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to request sync committee subscriptions"), err) } diff --git a/http/submitvalidatorregistrations.go b/http/submitvalidatorregistrations.go index 5d935fb4..1551e27a 100644 --- a/http/submitvalidatorregistrations.go +++ b/http/submitvalidatorregistrations.go @@ -64,8 +64,18 @@ func (s *Service) SubmitValidatorRegistrations(ctx context.Context, if err != nil { return errors.Join(errors.New("failed to marshal JSON"), err) } - _, err = s.post(ctx, "/eth/v1/validator/register_validator", bytes.NewBuffer(specJSON)) - if err != nil { + + endpoint := "/eth/v1/validator/register_validator" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to submit validator registration"), err) } diff --git a/http/submitvoluntaryexit.go b/http/submitvoluntaryexit.go index 4c5d0676..5c2b8f56 100644 --- a/http/submitvoluntaryexit.go +++ b/http/submitvoluntaryexit.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" + "github.com/attestantio/go-eth2-client/api" "github.com/attestantio/go-eth2-client/spec/phase0" ) @@ -33,8 +34,17 @@ func (s *Service) SubmitVoluntaryExit(ctx context.Context, voluntaryExit *phase0 return errors.Join(errors.New("failed to marshal JSON"), err) } - _, err = s.post(ctx, "/eth/v1/beacon/pool/voluntary_exits", bytes.NewBuffer(specJSON)) - if err != nil { + endpoint := "/eth/v1/beacon/pool/voluntary_exits" + query := "" + + if _, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + bytes.NewReader(specJSON), + ContentTypeJSON, + map[string]string{}, + ); err != nil { return errors.Join(errors.New("failed to submit voluntary exit"), err) } diff --git a/http/synccommitteeduties.go b/http/synccommitteeduties.go index 8350f102..8fe8020b 100644 --- a/http/synccommitteeduties.go +++ b/http/synccommitteeduties.go @@ -59,13 +59,22 @@ func (s *Service) SyncCommitteeDuties(ctx context.Context, return nil, errors.Join(errors.New("failed to write end of validator index array"), err) } - url := fmt.Sprintf("/eth/v1/validator/duties/sync/%d", opts.Epoch) - respBodyReader, err := s.post(ctx, url, &reqBodyReader) + endpoint := fmt.Sprintf("/eth/v1/validator/duties/sync/%d", opts.Epoch) + query := "" + + httpResponse, err := s.post(ctx, + endpoint, + query, + &api.CommonOpts{}, + &reqBodyReader, + ContentTypeJSON, + map[string]string{}, + ) if err != nil { return nil, errors.Join(errors.New("failed to request sync committee duties"), err) } - data, metadata, err := decodeJSONResponse(respBodyReader, []*apiv1.SyncCommitteeDuty{}) + data, metadata, err := decodeJSONResponse(bytes.NewReader(httpResponse.body), []*apiv1.SyncCommitteeDuty{}) if err != nil { return nil, err } diff --git a/http/validatorbalances.go b/http/validatorbalances.go index ef6c6a73..82985d85 100644 --- a/http/validatorbalances.go +++ b/http/validatorbalances.go @@ -59,7 +59,7 @@ func (s *Service) ValidatorBalances(ctx context.Context, return nil, errors.Join(errors.New("failed to marshal request data"), err) } - httpResponse, err := s.post2(ctx, endpoint, query, &opts.Common, bytes.NewReader(data), ContentTypeJSON, map[string]string{}) + httpResponse, err := s.post(ctx, endpoint, query, &opts.Common, bytes.NewReader(data), ContentTypeJSON, map[string]string{}) if err != nil { return nil, err } diff --git a/http/validators.go b/http/validators.go index 04bd01fe..2ba33902 100644 --- a/http/validators.go +++ b/http/validators.go @@ -78,7 +78,7 @@ func (s *Service) Validators(ctx context.Context, return nil, errors.Join(errors.New("failed to marshal request data"), err) } - httpResponse, err := s.post2(ctx, endpoint, query, &opts.Common, bytes.NewReader(reqData), ContentTypeJSON, map[string]string{}) + httpResponse, err := s.post(ctx, endpoint, query, &opts.Common, bytes.NewReader(reqData), ContentTypeJSON, map[string]string{}) if err != nil { return nil, errors.Join(errors.New("failed to request validators"), err) } From 636b3336265948e16e6c70e40210fb19513e5d4e Mon Sep 17 00:00:00 2001 From: pk910 Date: Thu, 12 Dec 2024 17:01:18 +0100 Subject: [PATCH 6/7] rename index field in PendingPartialWithdrawal --- spec/electra/pendingpartialwithdrawal.go | 2 +- spec/electra/pendingpartialwithdrawal_json.go | 8 ++++---- spec/electra/pendingpartialwithdrawal_ssz.go | 6 +++--- spec/electra/pendingpartialwithdrawal_yaml.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/electra/pendingpartialwithdrawal.go b/spec/electra/pendingpartialwithdrawal.go index 5e15b149..d8b53a9e 100644 --- a/spec/electra/pendingpartialwithdrawal.go +++ b/spec/electra/pendingpartialwithdrawal.go @@ -22,7 +22,7 @@ import ( // PendingPartialWithdrawal represents a pending partial withdrawal. type PendingPartialWithdrawal struct { - Index phase0.ValidatorIndex + ValidatorIndex phase0.ValidatorIndex Amount phase0.Gwei WithdrawableEpoch phase0.Epoch } diff --git a/spec/electra/pendingpartialwithdrawal_json.go b/spec/electra/pendingpartialwithdrawal_json.go index ad307a99..08425fc7 100644 --- a/spec/electra/pendingpartialwithdrawal_json.go +++ b/spec/electra/pendingpartialwithdrawal_json.go @@ -23,7 +23,7 @@ import ( // pendingPartialWithdrawalJSON is the spec representation of the struct. type pendingPartialWithdrawalJSON struct { - Index phase0.ValidatorIndex `json:"index"` + ValidatorIndex phase0.ValidatorIndex `json:"validator_index"` Amount phase0.Gwei `json:"amount"` WithdrawableEpoch phase0.Epoch `json:"withdrawable_epoch"` } @@ -31,7 +31,7 @@ type pendingPartialWithdrawalJSON struct { // MarshalJSON implements json.Marshaler. func (p *PendingPartialWithdrawal) MarshalJSON() ([]byte, error) { return json.Marshal(&pendingPartialWithdrawalJSON{ - Index: p.Index, + ValidatorIndex: p.ValidatorIndex, Amount: p.Amount, WithdrawableEpoch: p.WithdrawableEpoch, }) @@ -44,8 +44,8 @@ func (p *PendingPartialWithdrawal) UnmarshalJSON(input []byte) error { return err } - if err := p.Index.UnmarshalJSON(raw["index"]); err != nil { - return errors.Wrap(err, "index") + if err := p.ValidatorIndex.UnmarshalJSON(raw["validator_index"]); err != nil { + return errors.Wrap(err, "validator_index") } if err := p.Amount.UnmarshalJSON(raw["amount"]); err != nil { return errors.Wrap(err, "amount") diff --git a/spec/electra/pendingpartialwithdrawal_ssz.go b/spec/electra/pendingpartialwithdrawal_ssz.go index 00fb1334..74c1a0a6 100644 --- a/spec/electra/pendingpartialwithdrawal_ssz.go +++ b/spec/electra/pendingpartialwithdrawal_ssz.go @@ -18,7 +18,7 @@ func (p *PendingPartialWithdrawal) MarshalSSZTo(buf []byte) (dst []byte, err err dst = buf // Field (0) 'Index' - dst = ssz.MarshalUint64(dst, uint64(p.Index)) + dst = ssz.MarshalUint64(dst, uint64(p.ValidatorIndex)) // Field (1) 'Amount' dst = ssz.MarshalUint64(dst, uint64(p.Amount)) @@ -38,7 +38,7 @@ func (p *PendingPartialWithdrawal) UnmarshalSSZ(buf []byte) error { } // Field (0) 'Index' - p.Index = phase0.ValidatorIndex(ssz.UnmarshallUint64(buf[0:8])) + p.ValidatorIndex = phase0.ValidatorIndex(ssz.UnmarshallUint64(buf[0:8])) // Field (1) 'Amount' p.Amount = phase0.Gwei(ssz.UnmarshallUint64(buf[8:16])) @@ -65,7 +65,7 @@ func (p *PendingPartialWithdrawal) HashTreeRootWith(hh ssz.HashWalker) (err erro indx := hh.Index() // Field (0) 'Index' - hh.PutUint64(uint64(p.Index)) + hh.PutUint64(uint64(p.ValidatorIndex)) // Field (1) 'Amount' hh.PutUint64(uint64(p.Amount)) diff --git a/spec/electra/pendingpartialwithdrawal_yaml.go b/spec/electra/pendingpartialwithdrawal_yaml.go index d9a6fc9c..231893de 100644 --- a/spec/electra/pendingpartialwithdrawal_yaml.go +++ b/spec/electra/pendingpartialwithdrawal_yaml.go @@ -24,7 +24,7 @@ import ( // pendingPartialWithdrawalYAML is the spec representation of the struct. type pendingPartialWithdrawalYAML struct { - Index phase0.ValidatorIndex `yaml:"index"` + ValidatorIndex phase0.ValidatorIndex `yaml:"validator_index"` Amount phase0.Gwei `yaml:"amount"` WithdrawableEpoch phase0.Epoch `yaml:"withdrawable_epoch"` } @@ -32,7 +32,7 @@ type pendingPartialWithdrawalYAML struct { // MarshalYAML implements yaml.Marshaler. func (p *PendingPartialWithdrawal) MarshalYAML() ([]byte, error) { yamlBytes, err := yaml.MarshalWithOptions(&pendingPartialWithdrawalYAML{ - Index: p.Index, + ValidatorIndex: p.ValidatorIndex, Amount: p.Amount, WithdrawableEpoch: p.WithdrawableEpoch, }, yaml.Flow(true)) From 4d3d51c266773a7e0a6959cb296e0a6c6db8946f Mon Sep 17 00:00:00 2001 From: pk910 Date: Thu, 12 Dec 2024 17:04:02 +0100 Subject: [PATCH 7/7] fix comments --- spec/electra/pendingpartialwithdrawal_ssz.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/electra/pendingpartialwithdrawal_ssz.go b/spec/electra/pendingpartialwithdrawal_ssz.go index 74c1a0a6..874d3c66 100644 --- a/spec/electra/pendingpartialwithdrawal_ssz.go +++ b/spec/electra/pendingpartialwithdrawal_ssz.go @@ -17,7 +17,7 @@ func (p *PendingPartialWithdrawal) MarshalSSZ() ([]byte, error) { func (p *PendingPartialWithdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - // Field (0) 'Index' + // Field (0) 'ValidatorIndex' dst = ssz.MarshalUint64(dst, uint64(p.ValidatorIndex)) // Field (1) 'Amount' @@ -37,7 +37,7 @@ func (p *PendingPartialWithdrawal) UnmarshalSSZ(buf []byte) error { return ssz.ErrSize } - // Field (0) 'Index' + // Field (0) 'ValidatorIndex' p.ValidatorIndex = phase0.ValidatorIndex(ssz.UnmarshallUint64(buf[0:8])) // Field (1) 'Amount' @@ -64,7 +64,7 @@ func (p *PendingPartialWithdrawal) HashTreeRoot() ([32]byte, error) { func (p *PendingPartialWithdrawal) HashTreeRootWith(hh ssz.HashWalker) (err error) { indx := hh.Index() - // Field (0) 'Index' + // Field (0) 'ValidatorIndex' hh.PutUint64(uint64(p.ValidatorIndex)) // Field (1) 'Amount'