Skip to content

Commit

Permalink
fix(taiko-client): remove finalizedBlock info when P2P syncing (#18735
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mask-pp authored Jan 9, 2025
1 parent 60865c7 commit d81a630
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func (t *SyncProgressTracker) ClearMeta() {

log.Debug("Clear sync progress tracker meta")

t.triggered = false
t.lastSyncedBlockID = nil
t.lastSyncedBlockHash = common.Hash{}
t.outOfSync = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (s *BeaconSyncProgressTrackerTestSuite) TestSyncProgressed() {
func (s *BeaconSyncProgressTrackerTestSuite) TestClearMeta() {
s.t.triggered = true
s.t.ClearMeta()
s.False(s.t.triggered)
s.True(s.t.triggered)
}

func (s *BeaconSyncProgressTrackerTestSuite) TestHeadChanged() {
Expand Down
25 changes: 1 addition & 24 deletions packages/taiko-client/driver/chain_syncer/beaconsync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/eth/downloader"
Expand Down Expand Up @@ -72,30 +71,8 @@ func (s *Syncer) TriggerBeaconSync(blockID uint64) error {
return fmt.Errorf("unexpected NewPayload response status: %s", status.Status)
}

var lastVerifiedBlockHash common.Hash
if lastVerifiedBlockHash, err = s.rpc.GetLastVerifiedBlockHash(s.ctx); err != nil {
log.Debug("Failed to fetch the last verified block hash", "err", err)

stateVars, err := s.rpc.GetProtocolStateVariables(&bind.CallOpts{Context: s.ctx})
if err != nil {
return fmt.Errorf("failed to fetch protocol state variables: %w", err)
}

lastVerifiedBlockHeader, err := s.rpc.L2CheckPoint.HeaderByNumber(
s.ctx,
new(big.Int).SetUint64(stateVars.B.LastVerifiedBlockId),
)
if err != nil {
return fmt.Errorf("failed to fetch the last verified block hash: %w", err)
}

lastVerifiedBlockHash = lastVerifiedBlockHeader.Hash()
}

fcRes, err := s.rpc.L2Engine.ForkchoiceUpdate(s.ctx, &engine.ForkchoiceStateV1{
HeadBlockHash: headPayload.BlockHash,
SafeBlockHash: lastVerifiedBlockHash,
FinalizedBlockHash: lastVerifiedBlockHash,
HeadBlockHash: headPayload.BlockHash,
}, nil)
if err != nil {
return err
Expand Down

0 comments on commit d81a630

Please sign in to comment.