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

Commit

Permalink
feat(prover): add oracle proof submission delay (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Apr 30, 2023
1 parent f64e0e3 commit 7b5ed94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
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

0 comments on commit 7b5ed94

Please sign in to comment.