Skip to content

Commit

Permalink
chore(taiko-client): bump dependencies (#18202)
Browse files Browse the repository at this point in the history
Co-authored-by: maskpp <[email protected]>
Co-authored-by: Gavin Yu <[email protected]>
  • Loading branch information
3 people authored Oct 6, 2024
1 parent 8077dfb commit 219a7e8
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 1,266 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/eventindexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.21.0
go-version: 1.23.0
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ">=1.21.0"
go-version: ">=1.23.0"

- name: eventindexer - Unit Tests
working-directory: ./packages/eventindexer
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/guardian-prover-health-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.21.0
go-version: 1.23.0
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
Expand All @@ -44,7 +44,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21.0"
go-version: "1.23.0"

- name: guardian-prover-health-check - Unit Tests
working-directory: ./packages/guardian-prover-health-check
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/relayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.21.0
go-version: 1.23.0
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21.0"
go-version: "1.23.0"

- name: relayer - Unit Tests
working-directory: ./packages/relayer
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/taiko-client--hive_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: 1.23
cache: true

- name: Clone taikoxyz/hive
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/taiko-client--test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: 1.23
cache: true

- name: Install golangci-lint
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: 1.23
cache: true

- name: Install pnpm dependencies
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG PACKAGE=eventindexer

FROM golang:1.21.0 as builder
FROM golang:1.23.0 as builder

ARG PACKAGE

Expand All @@ -27,4 +27,4 @@ RUN apk add --no-cache ca-certificates

COPY --from=builder /taiko-mono/packages/${PACKAGE}/bin/${PACKAGE} /usr/local/bin/

ENTRYPOINT /usr/local/bin/${PACKAGE}
ENTRYPOINT /usr/local/bin/${PACKAGE}
186 changes: 47 additions & 139 deletions go.mod

Large diffs are not rendered by default.

1,167 changes: 90 additions & 1,077 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/taiko-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine as builder
FROM golang:1.23-alpine as builder

RUN apk update && apk add --no-cache --update gcc musl-dev linux-headers git make build-base

Expand Down
12 changes: 8 additions & 4 deletions packages/taiko-client/driver/chain_syncer/beaconsync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import (
"fmt"
"math/big"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"

"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/log"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/encoding"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/driver/state"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/rpc"
Expand Down Expand Up @@ -72,10 +71,15 @@ func (s *Syncer) TriggerBeaconSync(blockID uint64) error {
return fmt.Errorf("unexpected NewPayload response status: %s", status.Status)
}

lastVerifiedBlockHash, err := s.rpc.GetLastVerifiedBlockHash(s.ctx)
if err != nil {
return fmt.Errorf("failed to fetch the last verified block hash: %w", err)
}

fcRes, err := s.rpc.L2Engine.ForkchoiceUpdate(s.ctx, &engine.ForkchoiceStateV1{
HeadBlockHash: headPayload.BlockHash,
SafeBlockHash: headPayload.BlockHash,
FinalizedBlockHash: headPayload.BlockHash,
SafeBlockHash: lastVerifiedBlockHash,
FinalizedBlockHash: lastVerifiedBlockHash,
}, nil)
if err != nil {
return err
Expand Down
9 changes: 7 additions & 2 deletions packages/taiko-client/driver/chain_syncer/blob/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,15 @@ func (s *Syncer) insertNewHead(
return nil, fmt.Errorf("failed to create execution payloads: %w", err)
}

lastVerifiedBlockHash, err := s.rpc.GetLastVerifiedBlockHash(ctx)
if err != nil {
return nil, fmt.Errorf("failed to fetch the last verified block hash: %w", err)
}

fc := &engine.ForkchoiceStateV1{
HeadBlockHash: payload.BlockHash,
SafeBlockHash: payload.BlockHash,
FinalizedBlockHash: payload.BlockHash,
SafeBlockHash: lastVerifiedBlockHash,
FinalizedBlockHash: lastVerifiedBlockHash,
}

// Update the fork choice
Expand Down
4 changes: 2 additions & 2 deletions packages/taiko-client/internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"context"

opMetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/ethereum-optimism/optimism/op-service/opio"
txmgrMetrics "github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
"github.com/ethereum/go-ethereum/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/urfave/cli/v2"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/cmd/flags"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/rpc"
)

// Metrics
Expand Down Expand Up @@ -92,7 +92,7 @@ func Serve(ctx context.Context, c *cli.Context) error {
}
}()

opio.BlockOnInterruptsContext(ctx)
rpc.BlockOnInterruptsContext(ctx)

return nil
}
2 changes: 1 addition & 1 deletion packages/taiko-client/pkg/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"strings"

"github.com/prysmaticlabs/prysm/v4/io/file"
"github.com/prysmaticlabs/prysm/v5/io/file"
)

// Taken from: https://github.com/prysmaticlabs/prysm/blob/v2.1.4/cmd/beacon-chain/execution/options.go#L43
Expand Down
30 changes: 6 additions & 24 deletions packages/taiko-client/pkg/rpc/beaconclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ import (
"time"

"github.com/ethereum/go-ethereum/log"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/api/client"
"github.com/prysmaticlabs/prysm/v4/api/client/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/blob"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/config"
"github.com/prysmaticlabs/prysm/v5/api/client"
"github.com/prysmaticlabs/prysm/v5/api/client/beacon"
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
)

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 @@ -70,7 +67,7 @@ func NewBeaconClient(endpoint string, timeout time.Duration) (*BeaconClient, err
log.Info("L1 genesis time", "time", genesisTime)

// Get the seconds per slot.
spec, err := getConfigSpec(ctx, cli)
spec, err := cli.GetConfigSpec(ctx)
if err != nil {
return nil, err
}
Expand All @@ -86,21 +83,20 @@ func NewBeaconClient(endpoint string, timeout time.Duration) (*BeaconClient, err
}

// GetBlobs returns the sidecars for a given slot.
func (c *BeaconClient) GetBlobs(ctx context.Context, time uint64) ([]*blob.Sidecar, error) {
func (c *BeaconClient) GetBlobs(ctx context.Context, time uint64) ([]*structs.Sidecar, error) {
ctxWithTimeout, cancel := CtxWithTimeoutOrDefault(ctx, c.timeout)
defer cancel()

slot, err := c.timeToSlot(time)
if err != nil {
return nil, err
}

resBytes, err := c.Get(ctxWithTimeout, c.BaseURL().Path+fmt.Sprintf(sidecarsRequestURL, slot))
if err != nil {
return nil, err
}

var sidecars *blob.SidecarsResponse
var sidecars *structs.SidecarsResponse
if err = json.Unmarshal(resBytes, &sidecars); err != nil {
return nil, err
}
Expand All @@ -115,17 +111,3 @@ 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) (*config.GetSpecResponse, error) {
body, err := c.Get(ctx, c.BaseURL().Path+getConfigSpecPath)
if err != nil {
return nil, errors.Wrap(err, "error requesting configSpecPath")
}
fsr := &config.GetSpecResponse{}
err = json.Unmarshal(body, fsr)
if err != nil {
return nil, err
}
return fsr, nil
}
10 changes: 5 additions & 5 deletions packages/taiko-client/pkg/rpc/blob_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/go-resty/resty/v2"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/blob"
"github.com/prysmaticlabs/prysm/v5/api/server/structs"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg"
)
Expand Down Expand Up @@ -77,9 +77,9 @@ func (ds *BlobDataSource) GetBlobs(
ctx context.Context,
timestamp uint64,
blobHash common.Hash,
) ([]*blob.Sidecar, error) {
) ([]*structs.Sidecar, error) {
var (
sidecars []*blob.Sidecar
sidecars []*structs.Sidecar
err error
)
if ds.client.L1Beacon == nil {
Expand All @@ -99,9 +99,9 @@ func (ds *BlobDataSource) GetBlobs(
if err != nil {
return nil, err
}
sidecars = make([]*blob.Sidecar, len(blobs.Data))
sidecars = make([]*structs.Sidecar, len(blobs.Data))
for index, value := range blobs.Data {
sidecars[index] = &blob.Sidecar{
sidecars[index] = &structs.Sidecar{
KzgCommitment: value.KzgCommitment,
Blob: value.Blob,
}
Expand Down
13 changes: 13 additions & 0 deletions packages/taiko-client/pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,19 @@ func (c *Client) GetProtocolStateVariables(opts *bind.CallOpts) (*struct {
return GetProtocolStateVariables(c.TaikoL1, opts)
}

// GetLastVerifiedBlockHash gets the last verified block hash from TaikoL1 contract.
func (c *Client) GetLastVerifiedBlockHash(ctx context.Context) (common.Hash, error) {
ctxWithTimeout, cancel := context.WithTimeout(ctx, defaultTimeout)
defer cancel()

b, err := c.TaikoL1.GetLastVerifiedBlock(&bind.CallOpts{Context: ctxWithTimeout})
if err != nil {
return common.Hash{}, err
}

return b.BlockHash, nil
}

// GetL2BlockInfo fetches the L2 block information from the protocol.
func (c *Client) GetL2BlockInfo(ctx context.Context, blockID *big.Int) (bindings.TaikoDataBlockV2, error) {
ctxWithTimeout, cancel := CtxWithTimeoutOrDefault(ctx, defaultTimeout)
Expand Down
26 changes: 26 additions & 0 deletions packages/taiko-client/pkg/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package rpc
import (
"context"
"math/big"
"os"
"os/signal"
"strings"
"syscall"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand All @@ -21,6 +24,13 @@ var (
ZeroAddress common.Address
BlobBytes = params.BlobTxBytesPerFieldElement * params.BlobTxFieldElementsPerBlob
BlockMaxTxListBytes uint64 = (params.BlobTxBytesPerFieldElement - 1) * params.BlobTxFieldElementsPerBlob
// DefaultInterruptSignals is a set of default interrupt signals.
DefaultInterruptSignals = []os.Signal{
os.Interrupt,
os.Kill,
syscall.SIGTERM,
syscall.SIGQUIT,
}
)

// GetProtocolStateVariables gets the protocol states from TaikoL1 contract.
Expand Down Expand Up @@ -251,3 +261,19 @@ func CtxWithTimeoutOrDefault(ctx context.Context, defaultTimeout time.Duration)

return ctx, func() {}
}

// BlockOnInterruptsContext blocks until a SIGTERM is received.
// Passing in signals will override the default signals.
// The function will stop blocking if the context is closed.
func BlockOnInterruptsContext(ctx context.Context, signals ...os.Signal) {
if len(signals) == 0 {
signals = DefaultInterruptSignals
}
interruptChannel := make(chan os.Signal, 1)
signal.Notify(interruptChannel, signals...)
select {
case <-interruptChannel:
case <-ctx.Done():
signal.Stop(interruptChannel)
}
}

0 comments on commit 219a7e8

Please sign in to comment.