Skip to content

Commit

Permalink
chore(taiko-client): replace l1headch to ticker
Browse files Browse the repository at this point in the history
  • Loading branch information
luanxu-mxc committed Nov 14, 2024
1 parent 8ece528 commit bed98b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/taiko-client/driver/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/big"
"sync"
"sync/atomic"
"time"

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

Expand Down Expand Up @@ -135,7 +136,7 @@ func (s *State) eventLoop(ctx context.Context) {
l2BlockProposedV2Sub.Unsubscribe()
l2TransitionProvedV2Sub.Unsubscribe()
}()

l1HeadTicker := time.NewTicker(time.Millisecond * 1500)
for {
select {
case <-ctx.Done():
Expand Down Expand Up @@ -177,10 +178,17 @@ func (s *State) eventLoop(ctx context.Context) {
"hash", common.Hash(e.BlockHash),
"prover", e.Prover,
)
case newHead := <-l1HeadCh:
log.Info("L1 head ticker", "height", newHead.Number, "current", s.GetL1Current().Number)
case <-l1HeadTicker.C:
newHead, err := s.rpc.L1.HeaderByNumber(ctx, nil)
if err != nil {
log.Error("Get L1 head error", "error", err)
}
log.Debug("L1 head ticker", "height", newHead.Number, "current", s.GetL1Current().Number)
s.setL1Head(newHead)
s.l1HeadsFeed.Send(newHead)
// case newHead := <-l1HeadCh:
// s.setL1Head(newHead)
// s.l1HeadsFeed.Send(newHead)
case newHead := <-l2HeadCh:
s.setL2Head(newHead)
}
Expand Down
6 changes: 6 additions & 0 deletions packages/taiko-client/prover/event_handler/block_proposed.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/cenkalti/backoff/v4"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/encoding"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/metadata"
Expand Down Expand Up @@ -172,6 +173,11 @@ func (h *BlockProposedEventHandler) checkL1Reorg(
if meta.GetBlockID().Uint64() < encoding.GetProtocolConfig(h.rpc.L2.ChainID.Uint64()).OntakeForkHeight {
return nil
}
if h.rpc.L2.ChainID.Uint64() == params.MoonchainGenevaNetworkID.Uint64() {
if meta.GetBlockID().Uint64() < uint64(715157) {
return nil
}
}
// Check whether the L2 EE's anchored L1 info, to see if the L1 chain has been reorged.
reorgCheckResult, err := h.rpc.CheckL1Reorg(
ctx,
Expand Down

0 comments on commit bed98b1

Please sign in to comment.