This repository has been archived by the owner on May 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prover): introduce
SGXAndZkevmRpcdProducer
(#476)
- Loading branch information
1 parent
a27d353
commit 1750a4b
Showing
7 changed files
with
244 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package producer | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/log" | ||
"github.com/taikoxyz/taiko-client/bindings" | ||
"github.com/taikoxyz/taiko-client/bindings/encoding" | ||
"golang.org/x/sync/errgroup" | ||
) | ||
|
||
// SGXAndZkevmRpcdProducer generates a SGX + PSE ZKEVM proof for the given block. | ||
type SGXAndZkevmRpcdProducer struct { | ||
*SGXProofProducer | ||
*ZkevmRpcdProducer | ||
} | ||
|
||
// RequestProof implements the ProofProducer interface. | ||
func (o *SGXAndZkevmRpcdProducer) RequestProof( | ||
ctx context.Context, | ||
opts *ProofRequestOptions, | ||
blockID *big.Int, | ||
meta *bindings.TaikoDataBlockMetadata, | ||
header *types.Header, | ||
resultCh chan *ProofWithHeader, | ||
) error { | ||
log.Info( | ||
"Request SGX+PSE proof", | ||
"blockID", blockID, | ||
"coinbase", meta.Coinbase, | ||
"height", header.Number, | ||
"hash", header.Hash(), | ||
) | ||
|
||
sgxProofCh := make(chan *ProofWithHeader, 1) | ||
pseZkEvmProofCh := make(chan *ProofWithHeader, 1) | ||
|
||
g, ctx := errgroup.WithContext(ctx) | ||
g.Go(func() error { | ||
return o.SGXProofProducer.RequestProof(ctx, opts, blockID, meta, header, sgxProofCh) | ||
}) | ||
g.Go(func() error { | ||
return o.ZkevmRpcdProducer.RequestProof(ctx, opts, blockID, meta, header, pseZkEvmProofCh) | ||
}) | ||
if err := g.Wait(); err != nil { | ||
return err | ||
} | ||
|
||
resultCh <- &ProofWithHeader{ | ||
BlockID: blockID, | ||
Meta: meta, | ||
Header: header, | ||
Proof: append((<-sgxProofCh).Proof, (<-pseZkEvmProofCh).Proof...), | ||
Opts: opts, | ||
Tier: o.Tier(), | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// Tier implements the ProofProducer interface. | ||
func (o *SGXAndZkevmRpcdProducer) Tier() uint16 { | ||
return encoding.TierSgxAndPseZkevmID | ||
} | ||
|
||
// Cancellable implements the ProofProducer interface. | ||
func (o *SGXAndZkevmRpcdProducer) Cancellable() bool { | ||
return false | ||
} | ||
|
||
// Cancel cancels an existing proof generation. | ||
func (o *SGXAndZkevmRpcdProducer) Cancel(ctx context.Context, blockID *big.Int) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.