Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

feat(prover): add oracle proof submission delay #199

Merged
merged 1 commit into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 12 additions & 7 deletions prover/proof_producer/oracle_proof_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/ecdsa"
"fmt"
"math/big"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand All @@ -22,20 +23,22 @@ type OracleProducer struct {
rpc *rpc.Client
proverPrivKey *ecdsa.PrivateKey
anchorTxValidator *anchorTxValidator.AnchorTxValidator
proofTimeTarget time.Duration
}

// NewOracleProducer creates a new NewOracleProducer instance.
func NewOracleProducer(
rpc *rpc.Client,
proverPrivKey *ecdsa.PrivateKey,
taikoL2Address common.Address,
proofTimeTarget time.Duration,
) (*OracleProducer, error) {
anchorValidator, err := anchorTxValidator.New(taikoL2Address, rpc.L2ChainID, rpc)
if err != nil {
return nil, err
}

return &OracleProducer{rpc, proverPrivKey, anchorValidator}, nil
return &OracleProducer{rpc, proverPrivKey, anchorValidator, proofTimeTarget}, nil
}

// RequestProof implements the ProofProducer interface.
Expand Down Expand Up @@ -100,12 +103,14 @@ func (d *OracleProducer) RequestProof(
return fmt.Errorf("failed to sign evidence: %w", err)
}

resultCh <- &ProofWithHeader{
BlockID: blockID,
Header: header,
Meta: meta,
ZkProof: proof,
}
time.AfterFunc(d.proofTimeTarget, func() {
resultCh <- &ProofWithHeader{
BlockID: blockID,
Header: header,
Meta: meta,
ZkProof: proof,
}
})

return nil
}
Expand Down
1 change: 1 addition & 0 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
p.rpc,
p.cfg.L1ProverPrivKey,
p.cfg.TaikoL2Address,
time.Duration(p.protocolConfigs.ProofTimeTarget)*time.Second,
); err != nil {
return err
}
Expand Down