Skip to content

Commit 7cdf975

Browse files
committed
only submitted agg proof with greatest distance
1 parent d2ff362 commit 7cdf975

File tree

2 files changed

+73
-10
lines changed

2 files changed

+73
-10
lines changed

docker-compose.yml

+54-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,55 @@
11
services:
2-
w
2+
# OP Succinct Server
3+
op-succinct-server-bob-testnet:
4+
build:
5+
context: .
6+
dockerfile: ./proposer/succinct/Dockerfile
7+
env_file:
8+
- ${ENV_FILE:-.env.bobtestnet}
9+
restart: unless-stopped
10+
ports:
11+
- "3001:3001"
12+
13+
# OP Succinct Proposer
14+
op-succinct-proposer-bob-testnet:
15+
build:
16+
context: .
17+
dockerfile: ./proposer/op/Dockerfile.op_proposer
18+
env_file:
19+
# Running with Conduit.
20+
- ${ENV_FILE:-.env.bobtestnet}
21+
restart: unless-stopped
22+
depends_on:
23+
- op-succinct-server-bob-testnet
24+
volumes:
25+
- ./db:/usr/local/bin/dbdata
26+
# The metrics port is the default port for the OP Proposer.
27+
ports:
28+
- "7301:7301"
29+
# OP Succinct Server
30+
op-succinct-server-conduit-10s:
31+
build:
32+
context: .
33+
dockerfile: ./proposer/succinct/Dockerfile
34+
env_file:
35+
- ${ENV_FILE:-.env.conduit}
36+
restart: unless-stopped
37+
ports:
38+
- "3005:3005"
39+
40+
# OP Succinct Proposer
41+
op-succinct-proposer-conduit-10s:
42+
build:
43+
context: .
44+
dockerfile: ./proposer/op/Dockerfile.op_proposer
45+
env_file:
46+
# Running with Conduit.
47+
- ${ENV_FILE:-.env.conduit}
48+
restart: unless-stopped
49+
depends_on:
50+
- op-succinct-server-conduit-10s
51+
volumes:
52+
- ./db:/usr/local/bin/dbdata
53+
# The metrics port is the default port for the OP Proposer.
54+
ports:
55+
- "7305:7305"

proposer/op/proposer/driver.go

+19-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"math/big"
88
_ "net/http/pprof"
9+
"sort"
910
"sync"
1011
"time"
1112

@@ -362,12 +363,20 @@ func (l *L2OutputSubmitter) SubmitAggProofs(ctx context.Context) error {
362363
return nil
363364
}
364365

365-
for _, aggProof := range completedAggProofs {
366-
output, err := l.FetchOutput(ctx, aggProof.EndBlock)
367-
if err != nil {
368-
return fmt.Errorf("failed to fetch output at block %d: %w", aggProof.EndBlock, err)
369-
}
370-
l.proposeOutput(ctx, output, aggProof.Proof, aggProof.L1BlockNumber)
366+
// Select the agg proof with the highest L2 block number.
367+
sort.Slice(completedAggProofs, func(i, j int) bool {
368+
return completedAggProofs[i].EndBlock > completedAggProofs[j].EndBlock
369+
})
370+
371+
// Submit the agg proof with the highest L2 block number.
372+
aggProof := completedAggProofs[0]
373+
output, err := l.FetchOutput(ctx, aggProof.EndBlock)
374+
if err != nil {
375+
return fmt.Errorf("failed to fetch output at block %d: %w", aggProof.EndBlock, err)
376+
}
377+
err = l.proposeOutput(ctx, output, aggProof.Proof, aggProof.L1BlockNumber)
378+
if err != nil {
379+
return fmt.Errorf("failed to propose output: %w", err)
371380
}
372381

373382
return nil
@@ -683,15 +692,15 @@ func (l *L2OutputSubmitter) loopL2OO(ctx context.Context) {
683692
}
684693
}
685694

686-
func (l *L2OutputSubmitter) proposeOutput(ctx context.Context, output *eth.OutputResponse, proof []byte, l1BlockNum uint64) {
695+
func (l *L2OutputSubmitter) proposeOutput(ctx context.Context, output *eth.OutputResponse, proof []byte, l1BlockNum uint64) error {
687696
cCtx, cancel := context.WithTimeout(ctx, 10*time.Minute)
688697
defer cancel()
689698

690699
// Get the current nextBlockNumber from the L2OO contract.
691700
nextBlockNumber, err := l.l2ooContract.NextBlockNumber(&bind.CallOpts{Context: cCtx})
692701
if err != nil {
693702
l.Log.Error("Failed to get nextBlockNumber", "err", err)
694-
return
703+
return err
695704
}
696705

697706
if err := l.sendTransaction(cCtx, output, proof, l1BlockNum); err != nil {
@@ -702,10 +711,11 @@ func (l *L2OutputSubmitter) proposeOutput(ctx context.Context, output *eth.Outpu
702711
"l1blocknum", l1BlockNum,
703712
"l1head", output.Status.HeadL1.Number,
704713
"proof", proof)
705-
return
714+
return err
706715
}
707716
l.Log.Info("AGG proof submitted on-chain", "end", output.BlockRef.Number)
708717
l.Metr.RecordL2BlocksProposed(output.BlockRef)
718+
return nil
709719
}
710720

711721
// checkpointBlockHash gets the current L1 head, and then sends a transaction to checkpoint the blockhash on

0 commit comments

Comments
 (0)