diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 7d9b009db..78e7f271d 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.10.0" + ".": "0.11.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 6945739ea..26de5665e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## [0.11.0](https://github.com/taikoxyz/taiko-client/compare/v0.10.0...v0.11.0) (2023-06-26) + + +### Features + +* **all:** disable no beacon client seen warning ([#279](https://github.com/taikoxyz/taiko-client/issues/279)) ([cdabcac](https://github.com/taikoxyz/taiko-client/commit/cdabcacb36303667560300775573a4db55fbd5d4)) +* **driver:** check the mismatch of last verified block ([#296](https://github.com/taikoxyz/taiko-client/issues/296)) ([79fda87](https://github.com/taikoxyz/taiko-client/commit/79fda8792b29d506b5fa653ed78304d34e892003)) +* **driver:** improve error messages ([#289](https://github.com/taikoxyz/taiko-client/issues/289)) ([90e365a](https://github.com/taikoxyz/taiko-client/commit/90e365a79759e0ea701619594b0bf71db4dd3b44)) +* **driver:** improve sync progress information ([#288](https://github.com/taikoxyz/taiko-client/issues/288)) ([45d73b9](https://github.com/taikoxyz/taiko-client/commit/45d73b9da34232cf6a3c8636e97aef5854bb86bb)) +* **flags:** add retry related flags ([#281](https://github.com/taikoxyz/taiko-client/issues/281)) ([2df4105](https://github.com/taikoxyz/taiko-client/commit/2df4105ab344fb118435b7ef53bcf13ac10f5dc7)) +* **metrics:** add `ProverNormalProofRewardGauge` metrics ([#275](https://github.com/taikoxyz/taiko-client/issues/275)) ([cd4e40d](https://github.com/taikoxyz/taiko-client/commit/cd4e40dd477895746843021732a1beba14fa248a)) +* **proposer:** add `waitReceiptTimeout` when proposing ([#282](https://github.com/taikoxyz/taiko-client/issues/282)) ([ebf3162](https://github.com/taikoxyz/taiko-client/commit/ebf31623dc491887a25a76da0078559d0b86865c)) +* **prover:** improve retry policy for prover ([#280](https://github.com/taikoxyz/taiko-client/issues/280)) ([344bac1](https://github.com/taikoxyz/taiko-client/commit/344bac1435812770c5a1e39efad1545b98d4b106)) + + +### Bug Fixes + +* **driver:** fix an issue in `checkLastVerifiedBlockMismatch` ([#297](https://github.com/taikoxyz/taiko-client/issues/297)) ([a68730c](https://github.com/taikoxyz/taiko-client/commit/a68730c0d9cc1b15cdd314ad7939f8971104b362)) +* **driver:** fix geth lag to verified block when syncing ([#294](https://github.com/taikoxyz/taiko-client/issues/294)) ([c57f6e8](https://github.com/taikoxyz/taiko-client/commit/c57f6e8ac84ad55c0d51bfae278c88f7694c2265)) +* **pkg:** minor fixes for `WaitReceipt` ([#284](https://github.com/taikoxyz/taiko-client/issues/284)) ([feaa2b6](https://github.com/taikoxyz/taiko-client/commit/feaa2b6487e1578c4082ba0b4be087a627512c4b)) +* **prover:** ensure L2 reorg finished before generating proofs && add `verificationCheckTicker` ([#277](https://github.com/taikoxyz/taiko-client/issues/277)) ([6fa24ea](https://github.com/taikoxyz/taiko-client/commit/6fa24ea2b4674865dc381098e57a2171c9fce95b)) + ## [0.10.0](https://github.com/taikoxyz/taiko-client/compare/v0.9.0...v0.10.0) (2023-06-08) diff --git a/driver/chain_syncer/beaconsync/syncer.go b/driver/chain_syncer/beaconsync/syncer.go index c9f85893a..cba804857 100644 --- a/driver/chain_syncer/beaconsync/syncer.go +++ b/driver/chain_syncer/beaconsync/syncer.go @@ -51,8 +51,6 @@ func (s *Syncer) TriggerBeaconSync() error { "newBlockID", blockID, ) } - - return nil } status, err := s.rpc.L2Engine.NewPayload( diff --git a/driver/chain_syncer/calldata/syncer.go b/driver/chain_syncer/calldata/syncer.go index ffb8a0ddd..adf7e4e57 100644 --- a/driver/chain_syncer/calldata/syncer.go +++ b/driver/chain_syncer/calldata/syncer.go @@ -116,12 +116,35 @@ func (s *Syncer) onBlockProposed( if !s.progressTracker.Triggered() { // Check whteher we need to reorg the L2 chain at first. - reorged, l1CurrentToReset, lastInsertedBlockIDToReset, err := s.rpc.CheckL1Reorg( - ctx, - new(big.Int).Sub(event.Id, common.Big1), + // 1. Last verified block + var ( + reorged bool + l1CurrentToReset *types.Header + lastInsertedBlockIDToReset *big.Int + err error ) + reorged, err = s.checkLastVerifiedBlockMismatch(ctx) if err != nil { - return fmt.Errorf("failed to check whether L1 chain has been reorged: %w", err) + return fmt.Errorf("failed to check if last verified block in L2 EE has been reorged: %w", err) + } + + // 2. Parent block + if reorged { + genesisL1Header, err := s.rpc.GetGenesisL1Header(ctx) + if err != nil { + return fmt.Errorf("failed to fetch genesis L1 header: %w", err) + } + + l1CurrentToReset = genesisL1Header + lastInsertedBlockIDToReset = common.Big0 + } else { + reorged, l1CurrentToReset, lastInsertedBlockIDToReset, err = s.rpc.CheckL1Reorg( + ctx, + new(big.Int).Sub(event.Id, common.Big1), + ) + if err != nil { + return fmt.Errorf("failed to check whether L1 chain has been reorged: %w", err) + } } if reorged { @@ -239,7 +262,7 @@ func (s *Syncer) onBlockProposed( "blockID", event.Id, "height", payloadData.Number, "hash", payloadData.BlockHash, - "latestVerifiedBlockHeight", s.state.GetLatestVerifiedBlock().Height, + "latestVerifiedBlockID", s.state.GetLatestVerifiedBlock().ID, "latestVerifiedBlockHash", s.state.GetLatestVerifiedBlock().Hash, "transactions", len(payloadData.Transactions), "baseFee", payloadData.BaseFeePerGas, @@ -427,3 +450,19 @@ func (s *Syncer) createExecutionPayloads( return payload, nil } + +// checkLastVerifiedBlockMismatch checks if there is a mismatch between protocol's last verified block hash and +// the corresponding L2 EE block hash. +func (s *Syncer) checkLastVerifiedBlockMismatch(ctx context.Context) (bool, error) { + lastVerifiedBlockInfo := s.state.GetLatestVerifiedBlock() + if s.state.GetL2Head().Number.Cmp(lastVerifiedBlockInfo.ID) < 0 { + return false, nil + } + + l2Header, err := s.rpc.L2.HeaderByNumber(ctx, lastVerifiedBlockInfo.ID) + if err != nil { + return false, err + } + + return l2Header.Hash() != lastVerifiedBlockInfo.Hash, nil +} diff --git a/driver/chain_syncer/chain_syncer.go b/driver/chain_syncer/chain_syncer.go index 92764acab..6b0cded7f 100644 --- a/driver/chain_syncer/chain_syncer.go +++ b/driver/chain_syncer/chain_syncer.go @@ -121,7 +121,7 @@ func (s *L2ChainSyncer) Sync(l1End *types.Header) error { // AheadOfProtocolVerifiedHead checks whether the L2 chain is ahead of verified head in protocol. func (s *L2ChainSyncer) AheadOfProtocolVerifiedHead() bool { - verifiedHeightToCompare := s.state.GetLatestVerifiedBlock().Height.Uint64() + verifiedHeightToCompare := s.state.GetLatestVerifiedBlock().ID.Uint64() log.Debug( "Checking whether the execution engine is ahead of protocol's verified head", "latestVerifiedBlock", verifiedHeightToCompare, @@ -150,7 +150,7 @@ func (s *L2ChainSyncer) AheadOfProtocolVerifiedHead() bool { // another new beacon sync. func (s *L2ChainSyncer) needNewBeaconSyncTriggered() bool { return s.p2pSyncVerifiedBlocks && - s.state.GetLatestVerifiedBlock().Height.Uint64() > 0 && + s.state.GetLatestVerifiedBlock().ID.Uint64() > 0 && !s.AheadOfProtocolVerifiedHead() && !s.progressTracker.OutOfSync() } diff --git a/driver/state/state.go b/driver/state/state.go index 81fd67f75..ce6654483 100644 --- a/driver/state/state.go +++ b/driver/state/state.go @@ -236,16 +236,15 @@ func (s *State) GetL2Head() *types.Header { // VerifiedHeaderInfo contains information about a verified L2 block header. type VerifiedHeaderInfo struct { - ID *big.Int - Hash common.Hash - Height *big.Int + ID *big.Int + Hash common.Hash } // setLatestVerifiedBlockHash sets the latest verified L2 block hash concurrent safely. func (s *State) setLatestVerifiedBlockHash(id *big.Int, height *big.Int, hash common.Hash) { log.Debug("New verified block", "height", height, "hash", hash) metrics.DriverL2VerifiedHeightGauge.Update(height.Int64()) - s.l2VerifiedHead.Store(&VerifiedHeaderInfo{ID: id, Height: height, Hash: hash}) + s.l2VerifiedHead.Store(&VerifiedHeaderInfo{ID: id, Hash: hash}) } // GetLatestVerifiedBlock reads the latest verified L2 block concurrent safely.