Skip to content

Commit

Permalink
aug 14 fixes from zach/zk-proposer
Browse files Browse the repository at this point in the history
  • Loading branch information
zobront committed Aug 14, 2024
1 parent 582a035 commit e57d1f7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
45 changes: 23 additions & 22 deletions op-proposer/proposer/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,6 @@ func (l *L2OutputSubmitter) StartL2OutputSubmitting() error {
}
l.running = true

if l.Cfg.WaitNodeSync {
err := l.waitNodeSync()
if err != nil {
return fmt.Errorf("error waiting for node sync: %w", err)
}
}

l.wg.Add(1)
go l.loop()

Expand Down Expand Up @@ -265,7 +258,7 @@ func (l *L2OutputSubmitter) SubmitAggProofs(ctx context.Context) error {
return fmt.Errorf("failed to fetch output at block %d: %w", aggProof.EndBlock, err)
}

l.proposeOutput(ctx, output, aggProof.Proof)
l.proposeOutput(ctx, output, aggProof.Proof, aggProof.L1BlockNumber, common.HexToHash(aggProof.L1BlockHash))
l.Log.Info("AGG proof submitted on-chain", "start", aggProof.StartBlock, "end", aggProof.EndBlock)
}

Expand Down Expand Up @@ -376,18 +369,18 @@ func (l *L2OutputSubmitter) FetchOutput(ctx context.Context, block uint64) (*eth
}

// ProposeL2OutputTxData creates the transaction data for the ProposeL2Output function
func (l *L2OutputSubmitter) ProposeL2OutputTxData(output *eth.OutputResponse, proof []byte) ([]byte, error) {
return proposeL2OutputTxData(l.l2ooABI, output, proof)
func (l *L2OutputSubmitter) ProposeL2OutputTxData(output *eth.OutputResponse, proof []byte, l1BlockNum uint64, l1BlockHash common.Hash) ([]byte, error) {
return proposeL2OutputTxData(l.l2ooABI, output, proof, l1BlockNum, l1BlockHash)
}

// proposeL2OutputTxData creates the transaction data for the ProposeL2Output function
func proposeL2OutputTxData(abi *abi.ABI, output *eth.OutputResponse, proof []byte) ([]byte, error) {
func proposeL2OutputTxData(abi *abi.ABI, output *eth.OutputResponse, proof []byte, l1BlockNum uint64, l1BlockHash common.Hash) ([]byte, error) {
return abi.Pack(
"proposeL2Output",
output.OutputRoot,
new(big.Int).SetUint64(output.BlockRef.Number),
output.Status.CurrentL1.Hash,
new(big.Int).SetUint64(output.Status.CurrentL1.Number),
l1BlockHash,
l1BlockNum,
proof)
}

Expand Down Expand Up @@ -441,7 +434,7 @@ func (l *L2OutputSubmitter) waitForL1Head(ctx context.Context, blockNum uint64)
}

// sendTransaction creates & sends transactions through the underlying transaction manager.
func (l *L2OutputSubmitter) sendTransaction(ctx context.Context, output *eth.OutputResponse, proof []byte) error {
func (l *L2OutputSubmitter) sendTransaction(ctx context.Context, output *eth.OutputResponse, proof []byte, l1BlockNum uint64, l1BlockHash common.Hash) error {
err := l.waitForL1Head(ctx, output.Status.HeadL1.Number+1)
if err != nil {
return err
Expand All @@ -464,7 +457,7 @@ func (l *L2OutputSubmitter) sendTransaction(ctx context.Context, output *eth.Out
return err
}
} else {
data, err := l.ProposeL2OutputTxData(output, proof)
data, err := l.ProposeL2OutputTxData(output, proof, l1BlockNum, l1BlockHash)
if err != nil {
return err
}
Expand All @@ -483,8 +476,8 @@ func (l *L2OutputSubmitter) sendTransaction(ctx context.Context, output *eth.Out
} else {
l.Log.Info("Proposer tx successfully published",
"tx_hash", receipt.TxHash,
"l1blocknum", output.Status.CurrentL1.Number,
"l1blockhash", output.Status.CurrentL1.Hash)
"l1blocknum", l1BlockNum,
"l1blockhash", l1BlockHash)
}
return nil
}
Expand Down Expand Up @@ -520,6 +513,14 @@ func (l *L2OutputSubmitter) loop() {
defer l.wg.Done()
ctx := l.ctx

if l.Cfg.WaitNodeSync {
err := l.waitNodeSync()
if err != nil {
l.Log.Error("Error waiting for node sync", "err", err)
return
}
}

if l.dgfContract == nil {
l.loopL2OO(ctx)
} else {
Expand Down Expand Up @@ -640,22 +641,22 @@ func (l *L2OutputSubmitter) loopDGF(ctx context.Context) {
}
}

l.proposeOutput(ctx, output, nil)
l.proposeOutput(ctx, output, nil, 0, common.Hash{})
case <-l.done:
return
}
}
}

func (l *L2OutputSubmitter) proposeOutput(ctx context.Context, output *eth.OutputResponse, proof []byte) {
func (l *L2OutputSubmitter) proposeOutput(ctx context.Context, output *eth.OutputResponse, proof []byte, l1BlockNum uint64, l1BlockHash common.Hash) {
cCtx, cancel := context.WithTimeout(ctx, 10*time.Minute)
defer cancel()

if err := l.sendTransaction(cCtx, output, proof); err != nil {
if err := l.sendTransaction(cCtx, output, proof, l1BlockNum, l1BlockHash); err != nil {
l.Log.Error("Failed to send proposal transaction",
"err", err,
"l1blocknum", output.Status.CurrentL1.Number,
"l1blockhash", output.Status.CurrentL1.Hash,
"l1blocknum", l1BlockNum,
"l1blockhash", l1BlockHash,
"l1head", output.Status.HeadL1.Number,
"proof", proof)
return
Expand Down
2 changes: 1 addition & 1 deletion op-proposer/proposer/prove.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (l *L2OutputSubmitter) RequestQueuedProofs(ctx context.Context) error {
// wait for the next loop so that we have the version with the block info added
return nil
} else {
l.Log.Info("previous block data was there")
l.Log.Info("found agg proof with already checkpointed l1 block info")
}
} else {
currentRequestedProofs, err := l.db.CountRequestedProofs()
Expand Down

0 comments on commit e57d1f7

Please sign in to comment.