diff --git a/prover/proof_producer/dummy_producer.go b/prover/proof_producer/dummy_producer.go index 507c6ce3d..c5a4fd129 100644 --- a/prover/proof_producer/dummy_producer.go +++ b/prover/proof_producer/dummy_producer.go @@ -4,8 +4,6 @@ import ( "bytes" "context" "math/big" - "math/rand" - "time" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" @@ -13,10 +11,7 @@ import ( ) // DummyProofProducer always returns a dummy proof. -type DummyProofProducer struct { - RandomDummyProofDelayLowerBound *time.Duration - RandomDummyProofDelayUpperBound *time.Duration -} +type DummyProofProducer struct{} // RequestProof implements the ProofProducer interface. func (d *DummyProofProducer) RequestProof( @@ -30,42 +25,21 @@ func (d *DummyProofProducer) RequestProof( log.Info( "Request dummy proof", "blockID", blockID, - "proposer", meta.Proposer, + "coinbase", meta.Coinbase, "height", header.Number, "hash", header.Hash(), ) - time.AfterFunc(d.proofDelay(), func() { - resultCh <- &ProofWithHeader{ - BlockID: blockID, - Meta: meta, - Header: header, - ZkProof: bytes.Repeat([]byte{0xff}, 100), - Degree: CircuitsIdx, - Opts: opts, - } - }) - - return nil -} - -// proofDelay calculates a random proof delay between the bounds. -func (d *DummyProofProducer) proofDelay() time.Duration { - if d.RandomDummyProofDelayLowerBound == nil || - d.RandomDummyProofDelayUpperBound == nil || - *d.RandomDummyProofDelayUpperBound == time.Duration(0) { - return time.Duration(0) + resultCh <- &ProofWithHeader{ + BlockID: blockID, + Meta: meta, + Header: header, + ZkProof: bytes.Repeat([]byte{0xff}, 100), + Degree: CircuitsIdx, + Opts: opts, } - lowerSeconds := int(d.RandomDummyProofDelayLowerBound.Seconds()) - upperSeconds := int(d.RandomDummyProofDelayUpperBound.Seconds()) - - randomDurationSeconds := rand.Intn((upperSeconds - lowerSeconds)) + lowerSeconds - delay := time.Duration(randomDurationSeconds) * time.Second - - log.Info("Random dummy proof delay", "delay", delay) - - return delay + return nil } // Cancel cancels an existing proof generation. diff --git a/prover/proof_producer/dummy_producer_test.go b/prover/proof_producer/dummy_producer_test.go index 27dfb7bf0..e97756b56 100644 --- a/prover/proof_producer/dummy_producer_test.go +++ b/prover/proof_producer/dummy_producer_test.go @@ -50,41 +50,6 @@ func TestRequestProof(t *testing.T) { require.NotEmpty(t, res.ZkProof) } -func TestProofDelay(t *testing.T) { - dummyProofProducer := &DummyProofProducer{} - require.Equal(t, time.Duration(0), dummyProofProducer.proofDelay()) - - var ( - delays []time.Duration - oneSecond = 1 * time.Second - oneDay = 24 * time.Hour - ) - for i := 0; i < 1024; i++ { - dummyProofProducer := &DummyProofProducer{ - RandomDummyProofDelayLowerBound: &oneSecond, - RandomDummyProofDelayUpperBound: &oneDay, - } - - delay := dummyProofProducer.proofDelay() - - require.LessOrEqual(t, delay, oneDay) - require.Greater(t, delay, oneSecond) - - delays = append(delays, delay) - } - - allSame := func(d []time.Duration) bool { - for i := 1; i < len(d); i++ { - if d[i] != d[0] { - return false - } - } - return true - } - - require.False(t, allSame(delays)) -} - func TestProofCancel(t *testing.T) { dummyProofProducer := &DummyProofProducer{} diff --git a/prover/proof_producer/zkevm_cmd_producer.go b/prover/proof_producer/zkevm_cmd_producer.go index 12478e7c0..a664b0b35 100644 --- a/prover/proof_producer/zkevm_cmd_producer.go +++ b/prover/proof_producer/zkevm_cmd_producer.go @@ -45,7 +45,7 @@ func (p *ZkevmCmdProducer) RequestProof( log.Info( "Request proof from ZKEVM CMD", "blockID", blockID, - "proposer", meta.Proposer, + "coinbase", meta.Coinbase, "height", header.Number, "hash", header.Hash(), "cmd", p.CmdPath, diff --git a/prover/proof_producer/zkevm_rpcd_producer.go b/prover/proof_producer/zkevm_rpcd_producer.go index 23c074546..341ca042d 100644 --- a/prover/proof_producer/zkevm_rpcd_producer.go +++ b/prover/proof_producer/zkevm_rpcd_producer.go @@ -131,7 +131,7 @@ func (p *ZkevmRpcdProducer) RequestProof( log.Info( "Request proof from zkevm-chain proverd service", "blockID", blockID, - "proposer", meta.Proposer, + "coinbase", meta.Coinbase, "height", header.Number, "hash", header.Hash(), ) diff --git a/prover/prover.go b/prover/prover.go index 1ed725a6a..9f1ef5f67 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -63,13 +63,13 @@ type Prover struct { validProofSubmitter proofSubmitter.ProofSubmitter // Subscriptions - blockProposedCh chan *bindings.TaikoL1ClientBlockProposed - blockProposedSub event.Subscription - blockProvenCh chan *bindings.TaikoL1ClientBlockProven - blockProvenSub event.Subscription - blockVerifiedCh chan *bindings.TaikoL1ClientBlockVerified - blockVerifiedSub event.Subscription - proveNotify chan struct{} + blockProposedCh chan *bindings.TaikoL1ClientBlockProposed + blockProposedSub event.Subscription + transitionProvenCh chan *bindings.TaikoL1ClientTransitionProved + blockProvenSub event.Subscription + blockVerifiedCh chan *bindings.TaikoL1ClientBlockVerified + blockVerifiedSub event.Subscription + proveNotify chan struct{} // Proof related proofGenerationCh chan *proofProducer.ProofWithHeader @@ -143,7 +143,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) { chBufferSize := p.protocolConfigs.BlockMaxProposals p.blockProposedCh = make(chan *bindings.TaikoL1ClientBlockProposed, chBufferSize) p.blockVerifiedCh = make(chan *bindings.TaikoL1ClientBlockVerified, chBufferSize) - p.blockProvenCh = make(chan *bindings.TaikoL1ClientBlockProven, chBufferSize) + p.transitionProvenCh = make(chan *bindings.TaikoL1ClientTransitionProved, chBufferSize) p.proofGenerationCh = make(chan *proofProducer.ProofWithHeader, chBufferSize) p.proveNotify = make(chan struct{}, 1) if err := p.initL1Current(cfg.StartingBlockID); err != nil { @@ -170,10 +170,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) { var producer proofProducer.ProofProducer if cfg.Dummy { - producer = &proofProducer.DummyProofProducer{ - RandomDummyProofDelayLowerBound: p.cfg.RandomDummyProofDelayLowerBound, - RandomDummyProofDelayUpperBound: p.cfg.RandomDummyProofDelayUpperBound, - } + producer = &proofProducer.DummyProofProducer{} } else { if producer, err = proofProducer.NewZkevmRpcdProducer( cfg.ZKEvmRpcdEndpoint, @@ -215,7 +212,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) { CapacityManager: p.capacityManager, TaikoL1Address: p.cfg.TaikoL1Address, Rpc: p.rpc, - Bond: protocolConfigs.ProofBond, + Bond: protocolConfigs.LivenessBond, IsOracle: p.cfg.OracleProver, } if p.cfg.OracleProver { @@ -307,7 +304,7 @@ func (p *Prover) eventLoop() { if err := p.onBlockVerified(p.ctx, e); err != nil { log.Error("Handle BlockVerified event error", "error", err) } - case e := <-p.blockProvenCh: + case e := <-p.transitionProvenCh: if err := p.onBlockProven(p.ctx, e); err != nil { log.Error("Handle BlockProven event error", "error", err) } @@ -802,7 +799,7 @@ func (p *Prover) isBlockVerified(id *big.Int) (bool, error) { func (p *Prover) initSubscription() { p.blockProposedSub = rpc.SubscribeBlockProposed(p.rpc.TaikoL1, p.blockProposedCh) p.blockVerifiedSub = rpc.SubscribeBlockVerified(p.rpc.TaikoL1, p.blockVerifiedCh) - p.blockProvenSub = rpc.SubscribeBlockProven(p.rpc.TaikoL1, p.blockProvenCh) + p.blockProvenSub = rpc.SubscribeBlockProven(p.rpc.TaikoL1, p.transitionProvenCh) } // closeSubscription closes all subscriptions.