Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(taiko-client): enable proof aggregation (batch proofs) #18163

Open
wants to merge 118 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 113 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
453d730
feat(protocol): introduce `getTransitions` in TaikoL1
YoGhurt111 Sep 20, 2024
5b802d3
Merge branch 'main' into feature/get-transitions
YoGhurt111 Sep 20, 2024
5dd741d
fix
YoGhurt111 Sep 20, 2024
937eeb6
Merge branch 'feature/get-transitions' into feature/batch-proof
YoGhurt111 Sep 20, 2024
1b4e58c
Merge branch 'main' into feature/batch-proof
YoGhurt111 Sep 23, 2024
92b8e7b
feat(taiko-client): submit batch proofs
YoGhurt111 Sep 23, 2024
45fa2a1
Update packages/protocol/contracts/layer1/based/LibUtils.sol
YoGhurt111 Sep 23, 2024
1f46ea9
Update packages/taiko-client/cmd/flags/prover.go
YoGhurt111 Sep 24, 2024
64b9de1
Update packages/taiko-client/cmd/flags/prover.go
YoGhurt111 Sep 24, 2024
66a3efb
Update packages/taiko-client/prover/proof_producer/sgx_producer.go
YoGhurt111 Sep 24, 2024
d1d2d55
Update packages/taiko-client/prover/proof_submitter/proof_submitter.go
YoGhurt111 Sep 24, 2024
88d7a43
Update packages/taiko-client/cmd/flags/prover.go
YoGhurt111 Sep 24, 2024
b5c5968
Update packages/taiko-client/prover/proof_producer/sgx_producer.go
YoGhurt111 Sep 25, 2024
236e660
Update packages/taiko-client/prover/proof_producer/sgx_producer.go
YoGhurt111 Sep 25, 2024
24add9c
Update packages/taiko-client/prover/proof_producer/sgx_producer.go
YoGhurt111 Sep 25, 2024
dd4e626
Merge branch 'main' into feature/batch-proof
YoGhurt111 Sep 25, 2024
e20e064
changes based on comments
YoGhurt111 Sep 25, 2024
948c55d
Merge branches 'feature/batch-proof' and 'feature/batch-proof' of git…
YoGhurt111 Sep 25, 2024
73fc040
add optional flag for zk batch
YoGhurt111 Sep 26, 2024
54124c8
Merge branch 'main' into feature/batch-proof
YoGhurt111 Sep 26, 2024
f4a9ac8
temp
YoGhurt111 Sep 26, 2024
62ac02b
temp
YoGhurt111 Sep 26, 2024
a1818e4
temp
YoGhurt111 Sep 26, 2024
e29ba96
feat(taiko-client): update contract bingdings
YoGhurt111 Sep 27, 2024
0834514
Merge branch 'main' into feature/batch-proof
YoGhurt111 Sep 27, 2024
d505ebe
changes based on pr-18181
YoGhurt111 Sep 27, 2024
008ac1d
fix
YoGhurt111 Sep 27, 2024
804428e
fix
YoGhurt111 Sep 27, 2024
b25ed1c
fix
YoGhurt111 Sep 28, 2024
1a5014b
add log
YoGhurt111 Sep 28, 2024
a385f99
build image
YoGhurt111 Sep 28, 2024
0f86de8
Revert "build image"
YoGhurt111 Sep 29, 2024
603bc1a
fix
YoGhurt111 Sep 29, 2024
023ff02
fix
YoGhurt111 Sep 29, 2024
9e82059
fix
YoGhurt111 Sep 29, 2024
b0b17c4
fix
YoGhurt111 Sep 29, 2024
1afd4fe
fix
YoGhurt111 Sep 29, 2024
9222d1c
fix
YoGhurt111 Sep 29, 2024
f776a63
fix
YoGhurt111 Sep 29, 2024
e35e7a6
upgrade
YoGhurt111 Sep 29, 2024
f6d0ee2
fix
YoGhurt111 Sep 29, 2024
56db4ce
fix
YoGhurt111 Sep 30, 2024
04250f9
refactor
YoGhurt111 Sep 30, 2024
49c2972
add zk support
YoGhurt111 Sep 30, 2024
fc667be
temp
YoGhurt111 Sep 30, 2024
9c2271c
fix
YoGhurt111 Sep 30, 2024
fd5c6ee
fix
YoGhurt111 Sep 30, 2024
82cff3c
fix
YoGhurt111 Oct 8, 2024
e52775c
fix
YoGhurt111 Oct 8, 2024
51b885c
fix
YoGhurt111 Oct 9, 2024
a2fe08d
fix
YoGhurt111 Oct 9, 2024
2328487
fix
YoGhurt111 Oct 9, 2024
4360b2a
fix
YoGhurt111 Oct 9, 2024
af76a29
fix
YoGhurt111 Oct 9, 2024
2ffe93a
fix
YoGhurt111 Oct 9, 2024
209574e
Merge branch 'main' into feature/batch-proof
YoGhurt111 Oct 10, 2024
b742583
fix
YoGhurt111 Oct 11, 2024
d53c504
debug
YoGhurt111 Oct 11, 2024
87be364
fix
YoGhurt111 Oct 11, 2024
2cc63f0
log optimisation
YoGhurt111 Oct 11, 2024
11190cc
fix
YoGhurt111 Oct 11, 2024
928363e
fix
YoGhurt111 Oct 11, 2024
eb4ea5c
Merge branch 'main' into feature/batch-proof
davidtaikocha Oct 13, 2024
b60ce73
Revert "debug"
YoGhurt111 Oct 16, 2024
6f7736b
Merge branch 'main' into feature/batch-proof
YoGhurt111 Oct 16, 2024
5409ad4
Revert "temp"
YoGhurt111 Oct 16, 2024
7cd5ee2
Merge branch 'feature/batch-proof' of github.com:taikoxyz/taiko-mono …
YoGhurt111 Oct 16, 2024
94d3787
Update DevnetTierProvider.sol
YoGhurt111 Oct 16, 2024
83e9dce
Update DevnetTierProvider.sol
YoGhurt111 Oct 16, 2024
6753450
Update Risc0Verifier.sol
YoGhurt111 Oct 16, 2024
9c0f5a5
Update SgxVerifier.sol
YoGhurt111 Oct 16, 2024
1b3b961
Update SgxVerifier.sol
YoGhurt111 Oct 16, 2024
98e5b6f
Update packages/protocol/contracts/layer2/based/TaikoL2.sol
YoGhurt111 Oct 16, 2024
19cd84c
fix
YoGhurt111 Oct 16, 2024
6e658d7
Update packages/taiko-client/bindings/encoding/input.go
YoGhurt111 Oct 16, 2024
8c9bdca
changes based on comments
YoGhurt111 Oct 16, 2024
6138b8b
feat(taiko-client): improve `BlobTransactionBuilder` to support `Blob…
davidtaikocha Oct 14, 2024
1b7240f
temp
YoGhurt111 Oct 16, 2024
ac19d34
debug
YoGhurt111 Oct 17, 2024
3844048
debug
YoGhurt111 Oct 17, 2024
1e68832
debug
YoGhurt111 Oct 17, 2024
bd6482d
zk
YoGhurt111 Oct 17, 2024
9d3ad02
temp
YoGhurt111 Oct 17, 2024
c9f32fe
Revert "temp"
YoGhurt111 Oct 17, 2024
78cf58d
Revert "debug"
YoGhurt111 Oct 17, 2024
3681c38
Revert "debug"
YoGhurt111 Oct 17, 2024
26b2619
Revert "debug"
YoGhurt111 Oct 17, 2024
1b3123b
Revert "temp"
YoGhurt111 Oct 17, 2024
7e31f03
Revert "feat(taiko-client): improve `BlobTransactionBuilder` to suppo…
YoGhurt111 Oct 17, 2024
348a96d
Merge branch 'main' into feature/batch-proof
davidtaikocha Oct 25, 2024
99000b2
Update packages/taiko-client/prover/init.go
YoGhurt111 Oct 25, 2024
6441d62
Update packages/taiko-client/cmd/flags/prover.go
YoGhurt111 Oct 25, 2024
095392b
Update packages/taiko-client/cmd/flags/prover.go
YoGhurt111 Oct 25, 2024
25ecc2c
fix based on comments
YoGhurt111 Oct 25, 2024
237b501
Merge branch 'main' into feature/batch-proof
davidtaikocha Nov 4, 2024
de53a2a
Merge branch 'main' into feature/batch-proof
YoGhurt111 Nov 4, 2024
45890cd
Merge branch 'main' into feature/batch-proof
YoGhurt111 Nov 5, 2024
80260a3
Merge branch 'main' into feature/batch-proof
YoGhurt111 Nov 6, 2024
dd1bb5d
temp
YoGhurt111 Nov 6, 2024
1e9d376
fix
YoGhurt111 Nov 6, 2024
0eacfdf
Merge branch 'main' into feature/batch-proof
davidtaikocha Nov 8, 2024
8046b9f
Update packages/taiko-client/pkg/rpc/utils.go
YoGhurt111 Nov 8, 2024
f0f0a46
Update packages/taiko-client/prover/proof_submitter/proof_submitter.go
YoGhurt111 Nov 8, 2024
bcd1542
Update packages/taiko-client/prover/proof_submitter/transaction/build…
YoGhurt111 Nov 8, 2024
7c2b509
Update packages/taiko-client/prover/proof_submitter/proof_submitter.go
YoGhurt111 Nov 8, 2024
cf5dfe8
add log
YoGhurt111 Nov 8, 2024
4f47f42
fix based on comments
YoGhurt111 Nov 18, 2024
54ce66c
fix lint
YoGhurt111 Nov 18, 2024
d704e13
Merge branch 'main' into feature/batch-proof
YoGhurt111 Nov 18, 2024
50a71d4
chore: cleanup some code
davidtaikocha Nov 20, 2024
0876fc1
fix metrics
YoGhurt111 Nov 20, 2024
8fe2889
Update packages/taiko-client/prover/proof_submitter/transaction/sende…
YoGhurt111 Nov 20, 2024
d3cb491
Update packages/taiko-client/prover/proof_submitter/transaction/sende…
YoGhurt111 Nov 20, 2024
4ce2d56
Update packages/taiko-client/prover/proof_submitter/transaction/sende…
davidtaikocha Nov 20, 2024
bd68a89
Update packages/taiko-client/prover/proof_submitter/proof_submitter.go
YoGhurt111 Nov 20, 2024
00bda1e
Update packages/taiko-client/prover/proof_submitter/proof_submitter.go
YoGhurt111 Nov 20, 2024
ff2228b
Update proof_submitter.go
YoGhurt111 Nov 20, 2024
b9a719d
Revert "Update proof_submitter.go"
YoGhurt111 Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/taiko-client--docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Build and Push Multi-Arch Docker Image"

on:
push:
branches: [main]
branches: [feature/batch-proof]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change it back?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to build a new image to test in devnet first and then I will change it back.

tags:
- "taiko-client-v*"
paths:
Expand Down
44 changes: 44 additions & 0 deletions packages/taiko-client/bindings/encoding/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@ var (
{Name: "TaikoData.Transition", Type: transitionComponentsType},
{Name: "TaikoData.TierProof", Type: tierProofComponentsType},
}
proveBlocksInputArgs = abi.Arguments{
{Name: "TaikoData.BlockMetadata", Type: blockMetadataV2ComponentsType},
{Name: "TaikoData.Transition", Type: transitionComponentsType},
}
proveBlocksBatchProofArgs = abi.Arguments{
{Name: "TaikoData.TierProof", Type: tierProofComponentsType},
}
)

// Contract ABIs.
Expand Down Expand Up @@ -423,6 +430,43 @@ func EncodeProveBlockInput(
return b, nil
}

// EncodeProveBlocksInput performs the solidity `abi.encode` for the given TaikoL1.proveBlocks input.
func EncodeProveBlocksInput(
metas []metadata.TaikoBlockMetaData,
transitions []bindings.TaikoDataTransition,
) ([][]byte, error) {
if len(metas) != len(transitions) {
YoGhurt111 marked this conversation as resolved.
Show resolved Hide resolved
return nil, fmt.Errorf("both arrays of TaikoBlockMetaData and TaikoDataTransition must be equal in length")
}
b := make([][]byte, 0, len(metas))
for i := range metas {
input, err := proveBlocksInputArgs.Pack(
metas[i].(*metadata.TaikoDataBlockMetadataOntake).InnerMetadata(),
transitions[i],
)
if err != nil {
return nil, fmt.Errorf("failed to abi.encode TaikoL1.proveBlocks input item after ontake fork, %w", err)
}

b = append(b, input)
}

return b, nil
}

// EncodeProveBlocksBatchProof performs the solidity `abi.encode` for the given TaikoL1.proveBlocks batchProof.
func EncodeProveBlocksBatchProof(
tierProof *bindings.TaikoDataTierProof,
) ([]byte, error) {
input, err := proveBlocksBatchProofArgs.Pack(
tierProof,
)
if err != nil {
return nil, fmt.Errorf("failed to abi.encode TaikoL1.proveBlocks input item after ontake fork, %w", err)
}
return input, nil
}

// UnpackTxListBytes unpacks the input data of a TaikoL1.proposeBlock transaction, and returns the txList bytes.
func UnpackTxListBytes(txData []byte) ([]byte, error) {
method, err := TaikoL1ABI.MethodById(txData)
Expand Down
28 changes: 28 additions & 0 deletions packages/taiko-client/cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,31 @@ var (
Category: proverCategory,
EnvVars: []string{"PROVER_BLOCK_CONFIRMATIONS"},
}
// Batch proof related flag
SGXBatchSize = &cli.Uint64Flag{
Name: "prover.sgx.batchSize",
Usage: "The default size of batch sgx proofs, when it arrives, submit a batch of proof immediately, " +
"this flag only works post Ontake fork",
Value: 1,
Category: proverCategory,
EnvVars: []string{"PROVER_SGX_BATCH_SIZE"},
}
ZKVMBatchSize = &cli.Uint64Flag{
Name: "prover.zkvm.batchSize",
Usage: "The size of batch ZKVM proof, when it arrives, submit a batch of proof immediately, " +
"this flag only works post Ontake fork",
Value: 1,
Category: proverCategory,
EnvVars: []string{"PROVER_ZKVM_BATCH_SIZE"},
}
ForceProveInterval = &cli.DurationFlag{
Name: "prover.forceBatchProvingInterval",
Usage: "Time interval to prove blocks even the number of pending proof do not exceed prover.batchSize, " +
"this flag only works post Ontake fork",
Category: proverCategory,
Value: 30 * time.Minute,
EnvVars: []string{"PROVER_FORCE_BATCH_PROVING_INTERVAL"},
}
)

// ProverFlags All prover flags.
Expand Down Expand Up @@ -227,4 +252,7 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
BlockConfirmations,
RaikoRequestTimeout,
RaikoZKVMHostEndpoint,
SGXBatchSize,
ZKVMBatchSize,
ForceProveInterval,
}, TxmgrFlags)
12 changes: 12 additions & 0 deletions packages/taiko-client/internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,27 @@ var (
ProverSubmissionErrorCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_submission_error",
})
ProverAggregationSubmissionErrorCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_aggregation_submission_error",
})
ProverSgxProofGeneratedCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_sgx_generated",
})
ProverSgxProofAggregationGeneratedCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_sgx_aggregation_generated",
})
ProverR0ProofGeneratedCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_r0_generated",
})
ProverR0ProofAggregationGeneratedCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_r0_aggregation_generated",
})
ProverSp1ProofGeneratedCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_sp1_generated",
})
ProverSp1ProofAggregationGeneratedCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_sp1_aggregation_generated",
})
ProverSubmissionRevertedCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_submission_reverted",
})
Expand Down
122 changes: 121 additions & 1 deletion packages/taiko-client/pkg/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"golang.org/x/sync/errgroup"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/encoding"
Expand Down Expand Up @@ -62,7 +63,6 @@ func GetProtocolStateVariables(
}
opts.Context, cancel = CtxWithTimeoutOrDefault(opts.Context, defaultTimeout)
defer cancel()

// Notice: sloB.LastProposedIn and slotB.LastUnpausedAt are always 0
// before upgrading contract, but we can ignore it since we won't use it.
slotA, slotB, err := taikoL1Client.GetStateVariables(opts)
Expand Down Expand Up @@ -248,6 +248,126 @@ func GetBlockProofStatus(
}, nil
}

// BatchGetBlocksProofStatus checks whether the batch of L2 blocks still need new proofs or new contests.
// Here are the possible status:
// 1. No proof on chain at all.
// 2. A valid proof has been submitted.
// 3. An invalid proof has been submitted, and there is no valid contest.
// 4. An invalid proof has been submitted, and there is a valid contest.
func BatchGetBlocksProofStatus(
ctx context.Context,
cli *Client,
ids []*big.Int,
proverAddress common.Address,
proverSetAddress common.Address,
) ([]*BlockProofStatus, error) {
ctxWithTimeout, cancel := CtxWithTimeoutOrDefault(ctx, defaultTimeout)
defer cancel()
var (
parentHashes = make([][32]byte, len(ids))
parents = make([]*types.Header, len(ids))
blockIDs = make([]uint64, len(ids))
result = make([]*BlockProofStatus, len(ids))
)
// Get the local L2 parent header.
g, gCtx := errgroup.WithContext(ctxWithTimeout)
Copy link
Member

@davidtaikocha davidtaikocha Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And after thinking twice, let's do batch requests https://geth.ethereum.org/docs/interacting-with-geth/rpc/batch here and some other places, to make the network requests always O1.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, pretty good!

for i, id := range ids {
davidtaikocha marked this conversation as resolved.
Show resolved Hide resolved
g.Go(func() error {
parent, err := cli.L2.HeaderByNumber(gCtx, new(big.Int).Sub(id, common.Big1))
if err != nil {
return err
}
parentHashes[i] = parent.Hash()
parents[i] = parent
blockIDs[i] = id.Uint64()
return nil
})
}
if gErr := g.Wait(); gErr != nil {
return nil, gErr
}

// Get the transition state from TaikoL1 contract.
transitions, err := cli.TaikoL1.GetTransitions(
&bind.CallOpts{Context: ctxWithTimeout},
blockIDs,
parentHashes,
)
if err != nil {
return nil, err
}
g, gCtx = errgroup.WithContext(ctxWithTimeout)
for i, transition := range transitions {
YoGhurt111 marked this conversation as resolved.
Show resolved Hide resolved
davidtaikocha marked this conversation as resolved.
Show resolved Hide resolved
// No proof on chain
if transition.BlockHash == (common.Hash{}) {
result[i] = &BlockProofStatus{IsSubmitted: false, ParentHeader: parents[i]}
continue
}
g.Go(func() error {
header, err := cli.WaitL2Header(gCtx, ids[i])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just wait for the highest header here right? no need to send requests to check and wait every block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

if err != nil {
return err
}
if header.Hash() != transition.BlockHash ||
(transition.StateRoot != (common.Hash{}) && transition.StateRoot != header.Root) {
log.Info(
"Different block hash or state root detected, try submitting a contest",
"localBlockHash", header.Hash(),
"protocolTransitionBlockHash", common.BytesToHash(transition.BlockHash[:]),
"localStateRoot", header.Root,
"protocolTransitionStateRoot", common.BytesToHash(transition.StateRoot[:]),
)
result[i] = &BlockProofStatus{
IsSubmitted: true,
Invalid: true,
CurrentTransitionState: &transitions[i],
ParentHeader: parents[i],
}
return nil
}

if proverAddress == transition.Prover ||
(proverSetAddress != ZeroAddress && transition.Prover == proverSetAddress) {
log.Info(
"📬 Block's proof has already been submitted by current prover",
"blockID", ids[i],
"parent", parents[i].Hash().Hex(),
"hash", common.Bytes2Hex(transition.BlockHash[:]),
"stateRoot", common.Bytes2Hex(transition.StateRoot[:]),
"timestamp", transition.Timestamp,
"contester", transition.Contester,
)
result[i] = &BlockProofStatus{
IsSubmitted: true,
Invalid: transition.Contester != ZeroAddress,
ParentHeader: parents[i],
CurrentTransitionState: &transitions[i],
}
return nil
}
log.Info(
"📬 Block's proof has already been submitted by another prover",
"blockID", ids[i],
"prover", transition.Prover,
"parent", parents[i].Hash().Hex(),
"hash", common.Bytes2Hex(transition.BlockHash[:]),
"stateRoot", common.Bytes2Hex(transition.StateRoot[:]),
"timestamp", transition.Timestamp,
"contester", transition.Contester,
)

result[i] = &BlockProofStatus{
IsSubmitted: true,
Invalid: transition.Contester != ZeroAddress,
ParentHeader: parents[i],
CurrentTransitionState: &transitions[i],
}
return nil
})
}
return result, g.Wait()
}

// SetHead makes a `debug_setHead` RPC call to set the chain's head, should only be used
// for testing purpose.
func SetHead(ctx context.Context, client *EthClient, headNum *big.Int) error {
Expand Down
6 changes: 6 additions & 0 deletions packages/taiko-client/prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type Config struct {
BlockConfirmations uint64
TxmgrConfigs *txmgr.CLIConfig
PrivateTxmgrConfigs *txmgr.CLIConfig
SGXProofBufferSize uint64
ZKVMProofBufferSize uint64
ForceProveInterval time.Duration
}

// NewConfigFromCliContext creates a new config instance from command line flags.
Expand Down Expand Up @@ -183,5 +186,8 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
l1ProverPrivKey,
c,
),
SGXProofBufferSize: c.Uint64(flags.SGXBatchSize.Name),
ZKVMProofBufferSize: c.Uint64(flags.ZKVMBatchSize.Name),
ForceProveInterval: c.Duration(flags.ForceProveInterval.Name),
}, nil
}
14 changes: 11 additions & 3 deletions packages/taiko-client/prover/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ func (p *Prover) initProofSubmitters(
) error {
for _, tier := range p.sharedState.GetTiers() {
var (
producer proofProducer.ProofProducer
submitter proofSubmitter.Submitter
err error
bufferSize = p.cfg.SGXProofBufferSize
davidtaikocha marked this conversation as resolved.
Show resolved Hide resolved
producer proofProducer.ProofProducer
submitter proofSubmitter.Submitter
err error
)
switch tier.ID {
case encoding.TierOptimisticID:
Expand All @@ -121,6 +122,7 @@ func (p *Prover) initProofSubmitters(
Dummy: p.cfg.Dummy,
RaikoRequestTimeout: p.cfg.RaikoRequestTimeout,
}
bufferSize = p.cfg.ZKVMProofBufferSize
case encoding.TierZkVMSp1ID:
producer = &proofProducer.ZKvmProofProducer{
ZKProofType: proofProducer.ZKProofTypeSP1,
Expand All @@ -129,10 +131,13 @@ func (p *Prover) initProofSubmitters(
Dummy: p.cfg.Dummy,
RaikoRequestTimeout: p.cfg.RaikoRequestTimeout,
}
bufferSize = p.cfg.ZKVMProofBufferSize
case encoding.TierGuardianMinorityID:
producer = proofProducer.NewGuardianProofProducer(encoding.TierGuardianMinorityID, p.cfg.EnableLivenessBondProof)
bufferSize = 0
case encoding.TierGuardianMajorityID:
producer = proofProducer.NewGuardianProofProducer(encoding.TierGuardianMajorityID, p.cfg.EnableLivenessBondProof)
bufferSize = 0
default:
return fmt.Errorf("unsupported tier: %d", tier.ID)
}
Expand All @@ -141,6 +146,8 @@ func (p *Prover) initProofSubmitters(
p.rpc,
producer,
p.proofGenerationCh,
p.batchProofGenerationCh,
p.aggregationNotify,
p.cfg.ProverSetAddress,
p.cfg.TaikoL2Address,
p.cfg.Graffiti,
Expand All @@ -151,6 +158,7 @@ func (p *Prover) initProofSubmitters(
tiers,
p.IsGuardianProver(),
p.cfg.GuardianProofSubmissionDelay,
bufferSize,
); err != nil {
return err
}
Expand Down
12 changes: 12 additions & 0 deletions packages/taiko-client/prover/proof_producer/dummy_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@ func (o *DummyProofProducer) RequestProof(
Tier: tier,
}, nil
}

// RequestBatchProofs returns a dummy proof aggregation to the result channel.
func (o *DummyProofProducer) RequestBatchProofs(
YoGhurt111 marked this conversation as resolved.
Show resolved Hide resolved
proofs []*ProofWithHeader,
tier uint16,
) (*BatchProofs, error) {
return &BatchProofs{
Proofs: proofs,
BatchProof: bytes.Repeat([]byte{0xbb}, 100),
davidtaikocha marked this conversation as resolved.
Show resolved Hide resolved
Tier: tier,
}, nil
}
10 changes: 10 additions & 0 deletions packages/taiko-client/prover/proof_producer/guardian_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,23 @@ func (g *GuardianProofProducer) RequestProof(
return g.DummyProofProducer.RequestProof(opts, blockID, meta, header, g.Tier(), requestAt)
}

// RequestCancel implements the ProofProducer interface to cancel the proof generating progress.
func (g *GuardianProofProducer) RequestCancel(
_ context.Context,
_ *ProofRequestOptions,
) error {
return nil
}

// Aggregate implements the ProofProducer interface to aggregate a batch of proofs.
func (g *GuardianProofProducer) Aggregate(
_ context.Context,
_ []*ProofWithHeader,
_ time.Time,
) (*BatchProofs, error) {
return nil, nil
}

// Tier implements the ProofProducer interface.
func (g *GuardianProofProducer) Tier() uint16 {
return g.tier
Expand Down
Loading
Loading