From 7e00ba845211c5c75898f7de997e50fc106fb571 Mon Sep 17 00:00:00 2001 From: ratankaliani Date: Tue, 10 Dec 2024 02:22:12 +0000 Subject: [PATCH] only submitted agg proof with greatest distance --- docker-compose.yml | 55 +++++++++++++++++++++++++++++++++- proposer/op/proposer/driver.go | 28 +++++++++++------ 2 files changed, 73 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 04ad2807..5a4466eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,2 +1,55 @@ services: -w \ No newline at end of file + # 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" diff --git a/proposer/op/proposer/driver.go b/proposer/op/proposer/driver.go index 10de7a5e..6d5c05cf 100644 --- a/proposer/op/proposer/driver.go +++ b/proposer/op/proposer/driver.go @@ -6,6 +6,7 @@ import ( "fmt" "math/big" _ "net/http/pprof" + "sort" "sync" "time" @@ -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 @@ -683,7 +692,7 @@ 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() @@ -691,7 +700,7 @@ func (l *L2OutputSubmitter) proposeOutput(ctx context.Context, output *eth.Outpu 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 { @@ -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