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

fix(taiko-client): fix path parsing in /eth/v1/config/spec #18295

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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
18 changes: 17 additions & 1 deletion packages/taiko-client/pkg/rpc/beaconclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/ethereum/go-ethereum/log"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v5/api/client"
"github.com/prysmaticlabs/prysm/v5/api/client/beacon"
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
Expand All @@ -18,6 +19,7 @@ var (
// Request urls.
sidecarsRequestURL = "/eth/v1/beacon/blob_sidecars/%d"
genesisRequestURL = "/eth/v1/beacon/genesis"
getConfigSpecPath = "/eth/v1/config/spec"
)

type ConfigSpec struct {
Expand Down Expand Up @@ -67,7 +69,7 @@ func NewBeaconClient(endpoint string, timeout time.Duration) (*BeaconClient, err
log.Info("L1 genesis time", "time", genesisTime)

// Get the seconds per slot.
spec, err := cli.GetConfigSpec(ctx)
spec, err := getConfigSpec(ctx, cli)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -111,3 +113,17 @@ func (c *BeaconClient) timeToSlot(timestamp uint64) (uint64, error) {
}
return (timestamp - c.genesisTime) / c.secondsPerSlot, nil
}

// getConfigSpec retrieve the current configs of the network used by the beacon node.
func getConfigSpec(ctx context.Context, c *beacon.Client) (*structs.GetSpecResponse, error) {
body, err := c.Get(ctx, c.BaseURL().Path+getConfigSpecPath)
if err != nil {
return nil, errors.Wrap(err, "error requesting configSpecPath")
}
fsr := &structs.GetSpecResponse{}
err = json.Unmarshal(body, fsr)
if err != nil {
return nil, err
}
return fsr, nil
}
Loading