From fef6884bc318e4f09d9c59930a0565cc15e25996 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 31 Dec 2024 14:53:26 +0800 Subject: [PATCH] chore(taiko-client): cleanup pre-ontake prover code (#18677) --- .../prover/proof_submitter/proof_submitter.go | 9 +-- .../proof_submitter/transaction/builder.go | 73 ++++++------------- .../transaction/builder_test.go | 9 ++- packages/taiko-client/prover/prover.go | 35 --------- 4 files changed, 34 insertions(+), 92 deletions(-) diff --git a/packages/taiko-client/prover/proof_submitter/proof_submitter.go b/packages/taiko-client/prover/proof_submitter/proof_submitter.go index cf9d76227f8..e1f5bdc8ee3 100644 --- a/packages/taiko-client/prover/proof_submitter/proof_submitter.go +++ b/packages/taiko-client/prover/proof_submitter/proof_submitter.go @@ -123,12 +123,7 @@ func (s *ProofSubmitter) RequestProof(ctx context.Context, meta metadata.TaikoBl return fmt.Errorf("failed to get the L2 parent block by hash (%s): %w", header.ParentHash, err) } - if meta.IsOntakeBlock() { - blockInfo, err = s.rpc.GetL2BlockInfoV2(ctx, meta.GetBlockID()) - } else { - blockInfo, err = s.rpc.GetL2BlockInfo(ctx, meta.GetBlockID()) - } - if err != nil { + if blockInfo, err = s.rpc.GetL2BlockInfoV2(ctx, meta.GetBlockID()); err != nil { return err } @@ -206,7 +201,7 @@ func (s *ProofSubmitter) RequestProof(ctx context.Context, meta metadata.TaikoBl } return fmt.Errorf("failed to request proof (id: %d): %w", meta.GetBlockID(), err) } - if meta.IsOntakeBlock() && s.proofBuffer.Enabled() { + if s.proofBuffer.Enabled() { bufferSize, err := s.proofBuffer.Write(result) if err != nil { return fmt.Errorf( diff --git a/packages/taiko-client/prover/proof_submitter/transaction/builder.go b/packages/taiko-client/prover/proof_submitter/transaction/builder.go index 4ec13d85b2d..795edd55588 100644 --- a/packages/taiko-client/prover/proof_submitter/transaction/builder.go +++ b/packages/taiko-client/prover/proof_submitter/transaction/builder.go @@ -80,40 +80,26 @@ func (a *ProveBlockTxBuilder) Build( return nil, err } - if meta.IsOntakeBlock() { - if a.proverSetAddress != ZeroAddress { - if data, err = encoding.ProverSetABI.Pack( - "proveBlocks", - []uint64{blockID.Uint64()}, - [][]byte{input}, - []byte{}, - ); err != nil { - return nil, err - } - to = a.proverSetAddress - } else { - if data, err = encoding.TaikoL1ABI.Pack( - "proveBlocks", - []uint64{blockID.Uint64()}, - [][]byte{input}, - []byte{}, - ); err != nil { - return nil, err - } - to = a.taikoL1Address + if a.proverSetAddress != ZeroAddress { + if data, err = encoding.ProverSetABI.Pack( + "proveBlocks", + []uint64{blockID.Uint64()}, + [][]byte{input}, + []byte{}, + ); err != nil { + return nil, err } + to = a.proverSetAddress } else { - if a.proverSetAddress != ZeroAddress { - if data, err = encoding.ProverSetABI.Pack("proveBlock", blockID.Uint64(), input); err != nil { - return nil, err - } - to = a.proverSetAddress - } else { - if data, err = encoding.TaikoL1ABI.Pack("proveBlock", blockID.Uint64(), input); err != nil { - return nil, err - } - to = a.taikoL1Address + if data, err = encoding.TaikoL1ABI.Pack( + "proveBlocks", + []uint64{blockID.Uint64()}, + [][]byte{input}, + []byte{}, + ); err != nil { + return nil, err } + to = a.taikoL1Address } } else { if tier > encoding.TierGuardianMinorityID { @@ -124,24 +110,13 @@ func (a *ProveBlockTxBuilder) Build( return nil, fmt.Errorf("tier %d need set guardianProverMinorityAddress", tier) } - if meta.IsOntakeBlock() { - if data, err = encoding.GuardianProverABI.Pack( - "approveV2", - meta.(*metadata.TaikoDataBlockMetadataOntake).InnerMetadata(), - *transition, - *tierProof, - ); err != nil { - return nil, err - } - } else { - if data, err = encoding.GuardianProverABI.Pack( - "approve", - meta.(*metadata.TaikoDataBlockMetadataLegacy).InnerMetadata(), - *transition, - *tierProof, - ); err != nil { - return nil, err - } + if data, err = encoding.GuardianProverABI.Pack( + "approveV2", + meta.(*metadata.TaikoDataBlockMetadataOntake).InnerMetadata(), + *transition, + *tierProof, + ); err != nil { + return nil, err } } diff --git a/packages/taiko-client/prover/proof_submitter/transaction/builder_test.go b/packages/taiko-client/prover/proof_submitter/transaction/builder_test.go index c2fb3d5e55f..bc508cde5eb 100644 --- a/packages/taiko-client/prover/proof_submitter/transaction/builder_test.go +++ b/packages/taiko-client/prover/proof_submitter/transaction/builder_test.go @@ -11,7 +11,14 @@ import ( func (s *TransactionTestSuite) TestBuildTxs() { _, err := s.builder.Build( common.Big256, - &metadata.TaikoDataBlockMetadataLegacy{}, + &metadata.TaikoDataBlockMetadataOntake{TaikoDataBlockMetadataV2: bindings.TaikoDataBlockMetadataV2{ + AnchorBlockHash: [32]byte{}, + Difficulty: [32]byte{}, + BlobHash: [32]byte{}, + ExtraData: [32]byte{}, + ParentMetaHash: [32]byte{}, + LivenessBond: common.Big0, + }}, &bindings.TaikoDataTransition{}, &bindings.TaikoDataTierProof{}, 1, diff --git a/packages/taiko-client/prover/prover.go b/packages/taiko-client/prover/prover.go index a157a59bc6e..80c20da4612 100644 --- a/packages/taiko-client/prover/prover.go +++ b/packages/taiko-client/prover/prover.go @@ -291,28 +291,16 @@ func (p *Prover) eventLoop() { // Channels chBufferSize := p.protocolConfigs.BlockMaxProposals - blockProposedCh := make(chan *bindings.TaikoL1ClientBlockProposed, chBufferSize) - blockVerifiedCh := make(chan *bindings.TaikoL1ClientBlockVerified, chBufferSize) - transitionProvedCh := make(chan *bindings.TaikoL1ClientTransitionProved, chBufferSize) - transitionContestedCh := make(chan *bindings.TaikoL1ClientTransitionContested, chBufferSize) blockProposedV2Ch := make(chan *bindings.TaikoL1ClientBlockProposedV2, chBufferSize) blockVerifiedV2Ch := make(chan *bindings.TaikoL1ClientBlockVerifiedV2, chBufferSize) transitionProvedV2Ch := make(chan *bindings.TaikoL1ClientTransitionProvedV2, chBufferSize) transitionContestedV2Ch := make(chan *bindings.TaikoL1ClientTransitionContestedV2, chBufferSize) // Subscriptions - blockProposedSub := rpc.SubscribeBlockProposed(p.rpc.TaikoL1, blockProposedCh) - blockVerifiedSub := rpc.SubscribeBlockVerified(p.rpc.TaikoL1, blockVerifiedCh) - transitionProvedSub := rpc.SubscribeTransitionProved(p.rpc.TaikoL1, transitionProvedCh) - transitionContestedSub := rpc.SubscribeTransitionContested(p.rpc.TaikoL1, transitionContestedCh) blockProposedV2Sub := rpc.SubscribeBlockProposedV2(p.rpc.TaikoL1, blockProposedV2Ch) blockVerifiedV2Sub := rpc.SubscribeBlockVerifiedV2(p.rpc.TaikoL1, blockVerifiedV2Ch) transitionProvedV2Sub := rpc.SubscribeTransitionProvedV2(p.rpc.TaikoL1, transitionProvedV2Ch) transitionContestedV2Sub := rpc.SubscribeTransitionContestedV2(p.rpc.TaikoL1, transitionContestedV2Ch) defer func() { - blockProposedSub.Unsubscribe() - blockVerifiedSub.Unsubscribe() - transitionProvedSub.Unsubscribe() - transitionContestedSub.Unsubscribe() blockProposedV2Sub.Unsubscribe() blockVerifiedV2Sub.Unsubscribe() transitionProvedV2Sub.Unsubscribe() @@ -337,27 +325,6 @@ func (p *Prover) eventLoop() { } case tier := <-p.aggregationNotify: p.withRetry(func() error { return p.aggregateOp(tier) }) - case e := <-blockVerifiedCh: - p.blockVerifiedHandler.Handle(encoding.BlockVerifiedEventToV2(e)) - case e := <-transitionProvedCh: - p.withRetry(func() error { - blockInfo, err := p.rpc.GetL2BlockInfo(p.ctx, e.BlockId) - if err != nil { - return err - } - return p.transitionProvedHandler.Handle(p.ctx, encoding.TransitionProvedEventToV2(e, blockInfo.ProposedIn)) - }) - case e := <-transitionContestedCh: - p.withRetry(func() error { - blockInfo, err := p.rpc.GetL2BlockInfo(p.ctx, e.BlockId) - if err != nil { - return err - } - return p.transitionContestedHandler.Handle( - p.ctx, - encoding.TransitionContestedEventToV2(e, blockInfo.ProposedIn), - ) - }) case e := <-blockVerifiedV2Ch: p.blockVerifiedHandler.Handle(e) case e := <-transitionProvedV2Ch: @@ -370,8 +337,6 @@ func (p *Prover) eventLoop() { }) case m := <-p.assignmentExpiredCh: p.withRetry(func() error { return p.assignmentExpiredHandler.Handle(p.ctx, m) }) - case <-blockProposedCh: - reqProving() case <-blockProposedV2Ch: reqProving() case <-forceProvingTicker.C: