Skip to content

Commit

Permalink
chore(taiko-client): cleanup pre-ontake prover code (#18677)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Dec 31, 2024
1 parent 60bda60 commit fef6884
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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(
Expand Down
73 changes: 24 additions & 49 deletions packages/taiko-client/prover/proof_submitter/transaction/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
35 changes: 0 additions & 35 deletions packages/taiko-client/prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit fef6884

Please sign in to comment.