Skip to content

Commit

Permalink
only submitted agg proof with greatest distance
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Dec 10, 2024
1 parent d2ff362 commit 7cdf975
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 10 deletions.
55 changes: 54 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,55 @@
services:
w
# OP Succinct Server
op-succinct-server-bob-testnet:
build:
context: .
dockerfile: ./proposer/succinct/Dockerfile
env_file:
- ${ENV_FILE:-.env.bobtestnet}
restart: unless-stopped
ports:
- "3001:3001"

# OP Succinct Proposer
op-succinct-proposer-bob-testnet:
build:
context: .
dockerfile: ./proposer/op/Dockerfile.op_proposer
env_file:
# Running with Conduit.
- ${ENV_FILE:-.env.bobtestnet}
restart: unless-stopped
depends_on:
- op-succinct-server-bob-testnet
volumes:
- ./db:/usr/local/bin/dbdata
# The metrics port is the default port for the OP Proposer.
ports:
- "7301:7301"
# OP Succinct Server
op-succinct-server-conduit-10s:
build:
context: .
dockerfile: ./proposer/succinct/Dockerfile
env_file:
- ${ENV_FILE:-.env.conduit}
restart: unless-stopped
ports:
- "3005:3005"

# OP Succinct Proposer
op-succinct-proposer-conduit-10s:
build:
context: .
dockerfile: ./proposer/op/Dockerfile.op_proposer
env_file:
# Running with Conduit.
- ${ENV_FILE:-.env.conduit}
restart: unless-stopped
depends_on:
- op-succinct-server-conduit-10s
volumes:
- ./db:/usr/local/bin/dbdata
# The metrics port is the default port for the OP Proposer.
ports:
- "7305:7305"
28 changes: 19 additions & 9 deletions proposer/op/proposer/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"math/big"
_ "net/http/pprof"
"sort"
"sync"
"time"

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

for _, aggProof := range completedAggProofs {
output, err := l.FetchOutput(ctx, aggProof.EndBlock)
if err != nil {
return fmt.Errorf("failed to fetch output at block %d: %w", aggProof.EndBlock, err)
}
l.proposeOutput(ctx, output, aggProof.Proof, aggProof.L1BlockNumber)
// Select the agg proof with the highest L2 block number.
sort.Slice(completedAggProofs, func(i, j int) bool {
return completedAggProofs[i].EndBlock > completedAggProofs[j].EndBlock
})

// Submit the agg proof with the highest L2 block number.
aggProof := completedAggProofs[0]
output, err := l.FetchOutput(ctx, aggProof.EndBlock)
if err != nil {
return fmt.Errorf("failed to fetch output at block %d: %w", aggProof.EndBlock, err)
}
err = l.proposeOutput(ctx, output, aggProof.Proof, aggProof.L1BlockNumber)
if err != nil {
return fmt.Errorf("failed to propose output: %w", err)
}

return nil
Expand Down Expand Up @@ -683,15 +692,15 @@ func (l *L2OutputSubmitter) loopL2OO(ctx context.Context) {
}
}

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

// Get the current nextBlockNumber from the L2OO contract.
nextBlockNumber, err := l.l2ooContract.NextBlockNumber(&bind.CallOpts{Context: cCtx})
if err != nil {
l.Log.Error("Failed to get nextBlockNumber", "err", err)
return
return err
}

if err := l.sendTransaction(cCtx, output, proof, l1BlockNum); err != nil {
Expand All @@ -702,10 +711,11 @@ func (l *L2OutputSubmitter) proposeOutput(ctx context.Context, output *eth.Outpu
"l1blocknum", l1BlockNum,
"l1head", output.Status.HeadL1.Number,
"proof", proof)
return
return err
}
l.Log.Info("AGG proof submitted on-chain", "end", output.BlockRef.Number)
l.Metr.RecordL2BlocksProposed(output.BlockRef)
return nil
}

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

0 comments on commit 7cdf975

Please sign in to comment.