Skip to content

Commit c48afb3

Browse files
feat: network-v2 compatibility (#244)
* Compiles without network-v2 feature * Compiles and swapped out everything * add * add * feat: update network v2 * add * add * add * add * add * fix * configure port * add * use hosted * fix: reserved * fix * add * feat: deployed * added * add * push fixes * feat: re-starting proposer * wip * fix * only submitted agg proof with greatest distance * fix * fix * fix" * add * add * add * add * fix * add --------- Co-authored-by: ratankaliani <[email protected]>
1 parent a98ce28 commit c48afb3

File tree

15 files changed

+1058
-627
lines changed

15 files changed

+1058
-627
lines changed

Cargo.lock

+733-460
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ op-alloy-network = { version = "0.6.8", default-features = false }
9090
# sp1
9191
sp1-lib = { version = "3.0.0", features = ["verify"] }
9292
sp1-zkvm = { version = "3.0.0", features = ["verify"] }
93-
# Note: This rev is on a branch which includes skipping deferred verification + SP1 mock groth16 bytes fix + executor opts. Once 4.0.0 is released, update this.
94-
# ratan/op-succinct-sp1
95-
sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", rev = "884948a30c9b125950b9ddf7a344fb69548cd9df" }
93+
# Note: This rev includes the SP1 mock groth16 bytes fix, skipping deferred verification, executor opts and network-v2 changes.
94+
# ratan/v3.0.0-w-network-v2 branch includes the network-v2 changes from `19ae3e1`.
95+
sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", rev = "447fda5f759908bbc3091979bd933ee9d126873b", features = [
96+
"network-v2",
97+
] }
9698
sp1-build = { version = "3.0.0" }
9799

98100
[profile.release-client-lto]

configs/808813/rollup.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"ecotone_time": 0,
4242
"fjord_time": 0,
4343
"granite_time": 1725984001,
44+
"holocene_time": 1732633200,
4445
"batch_inbox_address": "0x734dde12fd466c14a85de838788efe6f1993c84c",
4546
"deposit_contract_address": "0xbaaf3bafdbd660380938b27d21c31bb7d072a799",
4647
"l1_system_config_address": "0x3974436fa4bb4deb5a04ace51a704b10ff5a1f25",

contracts/opsuccinctl2ooconfig.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"challenger": "0x0000000000000000000000000000000000000000",
3+
"finalizationPeriod": 0,
4+
"l2BlockTime": 2,
5+
"owner": "0xDEd0000E32f8F40414d3ab3a830f735a3553E18e",
6+
"proposer": "0xDEd0000E32f8F40414d3ab3a830f735a3553E18e",
7+
"rollupConfigHash": "0x0d7101e2acc7eae1fb42cfce5c604d14da561726e4e01b509315e5a9f97a9816",
8+
"startingBlockNumber": 5591859,
9+
"startingOutputRoot": "0xd2c903c40513a87898b2830196d53e0bedabe5dfba09c002b9cc39cb0ba5fe46",
10+
"startingTimestamp": 1733536206,
11+
"submissionInterval": 1200,
12+
"verifier": "0x397A5f7f3dBd538f23DE225B51f532c34448dA9B",
13+
"aggregationVkey": "0x00ea4171dbd0027768055bee7f6d64e17e9cec99b29aad5d18e5d804b967775b",
14+
"rangeVkeyCommitment": "0x51decb4a49105f2a1403423f560bc55d6d02e5eb57f21d0c5bd6a661555a8e53"
15+
}

justfile

+9
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ deploy-oracle env_file=".env":
149149

150150
# cd into contracts directory
151151
cd contracts
152+
153+
# forge install
154+
forge install
152155

153156
# Run the forge deployment script
154157
forge script script/OPSuccinctDeployer.s.sol:OPSuccinctDeployer \
@@ -173,6 +176,9 @@ upgrade-oracle env_file=".env":
173176

174177
# cd into contracts directory
175178
cd contracts
179+
180+
# forge install
181+
forge install
176182

177183
# Run the forge upgrade script
178184
if [ "${EXECUTE_UPGRADE_CALL:-true}" = "false" ]; then
@@ -203,6 +209,9 @@ update-parameters env_file=".env":
203209

204210
# cd into contracts directory
205211
cd contracts
212+
213+
# forge install
214+
forge install
206215

207216
# Run the forge upgrade script
208217
if [ "${EXECUTE_UPGRADE_CALL:-true}" = "false" ]; then

proposer/op/bindings/opsuccinctl2outputoracle.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proposer/op/proposer/db/db.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package db
22

33
import (
44
"context"
5+
"encoding/hex"
56
"fmt"
67
"os"
78
"path/filepath"
@@ -117,10 +118,13 @@ func (db *ProofDB) UpdateProofStatus(id int, proofStatus proofrequest.Status) er
117118
}
118119

119120
// SetProverRequestID sets the prover request ID for a proof request in the database.
120-
func (db *ProofDB) SetProverRequestID(id int, proverRequestID string) error {
121+
func (db *ProofDB) SetProverRequestID(id int, proverRequestID []byte) error {
122+
// Convert the []byte to a hex string.
123+
proverRequestIDHex := hex.EncodeToString(proverRequestID)
124+
121125
_, err := db.writeClient.ProofRequest.Update().
122126
Where(proofrequest.ID(id)).
123-
SetProverRequestID(proverRequestID).
127+
SetProverRequestID(proverRequestIDHex).
124128
SetProofRequestTime(uint64(time.Now().Unix())).
125129
SetLastUpdatedTime(uint64(time.Now().Unix())).
126130
Save(context.Background())
@@ -437,7 +441,8 @@ func (db *ProofDB) GetMaxContiguousSpanProofRange(start uint64) (uint64, error)
437441
currentBlock = span.EndBlock
438442
}
439443

440-
return max(start, currentBlock), nil
444+
// The current block is at minimum the start block, and at maximum the end block of the last span proof.
445+
return currentBlock, nil
441446
}
442447

443448
// GetConsecutiveSpanProofs returns the span proofs that cover the range [start, end].

proposer/op/proposer/driver.go

+37-10
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

@@ -251,6 +252,12 @@ func (l *L2OutputSubmitter) GetProposerMetrics(ctx context.Context) (opsuccinctm
251252
return opsuccinctmetrics.ProposerMetrics{}, fmt.Errorf("failed to get max contiguous span proof range: %w", err)
252253
}
253254

255+
// This fetches the next block number, which is the currentBlock + submissionInterval.
256+
minBlockToProveToAgg, err := l.l2ooContract.NextBlockNumber(&bind.CallOpts{Context: ctx})
257+
if err != nil {
258+
return opsuccinctmetrics.ProposerMetrics{}, fmt.Errorf("failed to get next L2OO output: %w", err)
259+
}
260+
254261
numProving, err := l.db.GetNumberOfRequestsWithStatuses(proofrequest.StatusPROVING)
255262
if err != nil {
256263
return opsuccinctmetrics.ProposerMetrics{}, fmt.Errorf("failed to get number of proofs proving: %w", err)
@@ -271,6 +278,7 @@ func (l *L2OutputSubmitter) GetProposerMetrics(ctx context.Context) (opsuccinctm
271278
L2FinalizedBlock: l2FinalizedBlock,
272279
LatestContractL2Block: latestContractL2Block.Uint64(),
273280
HighestProvenContiguousL2Block: highestProvenContiguousL2Block,
281+
MinBlockToProveToAgg: minBlockToProveToAgg.Uint64(),
274282
NumProving: uint64(numProving),
275283
NumWitnessgen: uint64(numWitnessgen),
276284
NumUnrequested: uint64(numUnrequested),
@@ -312,8 +320,8 @@ func (l *L2OutputSubmitter) SendSlackNotification(proposerMetrics opsuccinctmetr
312320

313321
message := fmt.Sprintf("*Chain %d Proposer Metrics*:\n"+
314322
"Contract is %d minutes behind L2 Finalized\n"+
315-
"| L2 Unsafe | L2 Finalized | Contract L2 | Proven L2 |\n"+
316-
"| %-9d | %-12d | %-11d | %-9d |\n"+
323+
"| L2 Unsafe | L2 Finalized | Contract L2 | Proven L2 | Min to Agg |\n"+
324+
"| %-9d | %-12d | %-11d | %-9d | %-9d |\n"+
317325
"| Proving | Witness Gen | Unrequested |\n"+
318326
"| %-9d | %-11d | %-11d |",
319327
l.Cfg.L2ChainID,
@@ -322,6 +330,7 @@ func (l *L2OutputSubmitter) SendSlackNotification(proposerMetrics opsuccinctmetr
322330
proposerMetrics.L2FinalizedBlock,
323331
proposerMetrics.LatestContractL2Block,
324332
proposerMetrics.HighestProvenContiguousL2Block,
333+
proposerMetrics.MinBlockToProveToAgg,
325334
proposerMetrics.NumProving,
326335
proposerMetrics.NumWitnessgen,
327336
proposerMetrics.NumUnrequested)
@@ -354,12 +363,20 @@ func (l *L2OutputSubmitter) SubmitAggProofs(ctx context.Context) error {
354363
return nil
355364
}
356365

357-
for _, aggProof := range completedAggProofs {
358-
output, err := l.FetchOutput(ctx, aggProof.EndBlock)
359-
if err != nil {
360-
return fmt.Errorf("failed to fetch output at block %d: %w", aggProof.EndBlock, err)
361-
}
362-
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)
363380
}
364381

365382
return nil
@@ -675,20 +692,30 @@ func (l *L2OutputSubmitter) loopL2OO(ctx context.Context) {
675692
}
676693
}
677694

678-
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 {
679696
cCtx, cancel := context.WithTimeout(ctx, 10*time.Minute)
680697
defer cancel()
681698

699+
// Get the current nextBlockNumber from the L2OO contract.
700+
nextBlockNumber, err := l.l2ooContract.NextBlockNumber(&bind.CallOpts{Context: cCtx})
701+
if err != nil {
702+
l.Log.Error("Failed to get nextBlockNumber", "err", err)
703+
return err
704+
}
705+
682706
if err := l.sendTransaction(cCtx, output, proof, l1BlockNum); err != nil {
683707
l.Log.Error("Failed to send proposal transaction",
684708
"err", err,
709+
"expected_next_blocknum", nextBlockNumber.Uint64(),
710+
"l2blocknum", output.BlockRef.Number,
685711
"l1blocknum", l1BlockNum,
686712
"l1head", output.Status.HeadL1.Number,
687713
"proof", proof)
688-
return
714+
return err
689715
}
690716
l.Log.Info("AGG proof submitted on-chain", "end", output.BlockRef.Number)
691717
l.Metr.RecordL2BlocksProposed(output.BlockRef)
718+
return nil
692719
}
693720

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

proposer/op/proposer/metrics/metrics.go

+74-66
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ type OPSuccinctMetrics struct {
4747
L2FinalizedBlock prometheus.Gauge
4848
LatestContractL2Block prometheus.Gauge
4949
HighestProvenContiguousL2Block prometheus.Gauge
50+
MinBlockToProveToAgg prometheus.Gauge
5051

51-
ErrorCount *prometheus.CounterVec
52-
ProveFailures *prometheus.CounterVec
52+
ErrorCount *prometheus.CounterVec
53+
ProveFailures *prometheus.CounterVec
5354
WitnessGenFailures *prometheus.CounterVec
5455
}
5556

@@ -66,70 +67,75 @@ func NewMetrics(procName string) *OPSuccinctMetrics {
6667

6768
return &OPSuccinctMetrics{
6869
ns: ns,
69-
registry: registry,
70-
factory: factory,
71-
72-
RefMetrics: opmetrics.MakeRefMetrics(ns, factory),
73-
TxMetrics: txmetrics.MakeTxMetrics(ns, factory),
74-
RPCMetrics: opmetrics.MakeRPCMetrics(ns, factory),
75-
76-
info: *factory.NewGaugeVec(prometheus.GaugeOpts{
77-
Namespace: ns,
78-
Name: "info",
79-
Help: "Pseudo-metric tracking version and config info",
80-
}, []string{
81-
"version",
82-
}),
83-
up: factory.NewGauge(prometheus.GaugeOpts{
84-
Namespace: ns,
85-
Name: "up",
86-
Help: "1 if the op-proposer has finished starting up",
87-
}),
88-
NumProving: factory.NewGauge(prometheus.GaugeOpts{
89-
Namespace: ns,
90-
Name: "num_proving",
91-
Help: "Number of proofs currently being proven",
92-
}),
93-
NumWitnessGen: factory.NewGauge(prometheus.GaugeOpts{
94-
Namespace: ns,
95-
Name: "num_witness_gen",
96-
Help: "Number of witnesses currently being generated",
97-
}),
98-
NumUnrequested: factory.NewGauge(prometheus.GaugeOpts{
99-
Namespace: ns,
100-
Name: "num_unrequested",
101-
Help: "Number of unrequested proofs",
102-
}),
103-
L2FinalizedBlock: factory.NewGauge(prometheus.GaugeOpts{
104-
Namespace: ns,
105-
Name: "l2_finalized_block",
106-
Help: "Latest finalized L2 block number",
107-
}),
108-
LatestContractL2Block: factory.NewGauge(prometheus.GaugeOpts{
109-
Namespace: ns,
110-
Name: "latest_contract_l2_block",
111-
Help: "Latest L2 block number on the L2OO contract",
112-
}),
113-
HighestProvenContiguousL2Block: factory.NewGauge(prometheus.GaugeOpts{
114-
Namespace: ns,
115-
Name: "highest_proven_contiguous_l2_block",
116-
Help: "Highest proven L2 block contiguous with contract's latest block",
117-
}),
118-
ErrorCount: factory.NewCounterVec(prometheus.CounterOpts{
119-
Namespace: ns,
120-
Name: "error_count",
121-
Help: "Number of errors encountered",
122-
}, []string{"type"}),
123-
ProveFailures: factory.NewCounterVec(prometheus.CounterOpts{
124-
Namespace: ns,
125-
Name: "prove_failures",
126-
Help: "Number of prove failures by type",
127-
}, []string{"reason"}),
128-
WitnessGenFailures: factory.NewCounterVec(prometheus.CounterOpts{
129-
Namespace: ns,
130-
Name: "witness_gen_failures",
131-
Help: "Number of witness generation failures by type",
132-
}, []string{"reason"}),
70+
registry: registry,
71+
factory: factory,
72+
73+
RefMetrics: opmetrics.MakeRefMetrics(ns, factory),
74+
TxMetrics: txmetrics.MakeTxMetrics(ns, factory),
75+
RPCMetrics: opmetrics.MakeRPCMetrics(ns, factory),
76+
77+
info: *factory.NewGaugeVec(prometheus.GaugeOpts{
78+
Namespace: ns,
79+
Name: "info",
80+
Help: "Pseudo-metric tracking version and config info",
81+
}, []string{
82+
"version",
83+
}),
84+
up: factory.NewGauge(prometheus.GaugeOpts{
85+
Namespace: ns,
86+
Name: "up",
87+
Help: "1 if the op-proposer has finished starting up",
88+
}),
89+
NumProving: factory.NewGauge(prometheus.GaugeOpts{
90+
Namespace: ns,
91+
Name: "num_proving",
92+
Help: "Number of proofs currently being proven",
93+
}),
94+
NumWitnessGen: factory.NewGauge(prometheus.GaugeOpts{
95+
Namespace: ns,
96+
Name: "num_witness_gen",
97+
Help: "Number of witnesses currently being generated",
98+
}),
99+
NumUnrequested: factory.NewGauge(prometheus.GaugeOpts{
100+
Namespace: ns,
101+
Name: "num_unrequested",
102+
Help: "Number of unrequested proofs",
103+
}),
104+
L2FinalizedBlock: factory.NewGauge(prometheus.GaugeOpts{
105+
Namespace: ns,
106+
Name: "l2_finalized_block",
107+
Help: "Latest finalized L2 block number",
108+
}),
109+
LatestContractL2Block: factory.NewGauge(prometheus.GaugeOpts{
110+
Namespace: ns,
111+
Name: "latest_contract_l2_block",
112+
Help: "Latest L2 block number on the L2OO contract",
113+
}),
114+
HighestProvenContiguousL2Block: factory.NewGauge(prometheus.GaugeOpts{
115+
Namespace: ns,
116+
Name: "highest_proven_contiguous_l2_block",
117+
Help: "Highest proven L2 block contiguous with contract's latest block",
118+
}),
119+
MinBlockToProveToAgg: factory.NewGauge(prometheus.GaugeOpts{
120+
Namespace: ns,
121+
Name: "min_block_to_prove_to_agg",
122+
Help: "Minimum L2 block number to prove to generate an AGG proof",
123+
}),
124+
ErrorCount: factory.NewCounterVec(prometheus.CounterOpts{
125+
Namespace: ns,
126+
Name: "error_count",
127+
Help: "Number of errors encountered",
128+
}, []string{"type"}),
129+
ProveFailures: factory.NewCounterVec(prometheus.CounterOpts{
130+
Namespace: ns,
131+
Name: "prove_failures",
132+
Help: "Number of prove failures by type",
133+
}, []string{"reason"}),
134+
WitnessGenFailures: factory.NewCounterVec(prometheus.CounterOpts{
135+
Namespace: ns,
136+
Name: "witness_gen_failures",
137+
Help: "Number of witness generation failures by type",
138+
}, []string{"reason"}),
133139
}
134140
}
135141

@@ -189,13 +195,15 @@ func (m *OPSuccinctMetrics) RecordProposerStatus(metrics ProposerMetrics) {
189195
m.L2FinalizedBlock.Set(float64(metrics.L2FinalizedBlock))
190196
m.LatestContractL2Block.Set(float64(metrics.LatestContractL2Block))
191197
m.HighestProvenContiguousL2Block.Set(float64(metrics.HighestProvenContiguousL2Block))
198+
m.MinBlockToProveToAgg.Set(float64(metrics.MinBlockToProveToAgg))
192199
}
193200

194201
type ProposerMetrics struct {
195202
L2UnsafeHeadBlock uint64
196203
L2FinalizedBlock uint64
197204
LatestContractL2Block uint64
198205
HighestProvenContiguousL2Block uint64
206+
MinBlockToProveToAgg uint64
199207
NumProving uint64
200208
NumWitnessgen uint64
201209
NumUnrequested uint64

0 commit comments

Comments
 (0)