Skip to content

Commit 8a2d09c

Browse files
authored
Merge pull request #5 from bobanetwork/upstream-v1.0.1
Upstream v1.0.1 Merge
2 parents 2e13f2c + cb2e00f commit 8a2d09c

File tree

7 files changed

+67
-35
lines changed

7 files changed

+67
-35
lines changed

book.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
[book]
2-
authors = ["Uma Roy"]
2+
authors = ["Uma Roy", "ratankaliani"]
33
language = "en"
44
multilingual = false
55
src = "book"
6-
title = "OP Succinct"
6+
title = "OP Succinct book"
77
description = "A book on all things SP1"
88

99
[build]
1010
build-dir = "target/book"
1111

12+
[output.html]
13+
git-repository-url = "https://github.com/succinctlabs/op-succinct"
14+
1215
[preprocessor.template]
1316
before = ["links"]
1417

1518
[preprocessor.index]
1619

17-
[preprocessor.links]
20+
[preprocessor.links]

book/advanced/node-setup.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,12 @@
33
This guide will show you how to set up an L2 execution node (`op-geth`) and a rollup node (`op-node`) for your OP Stack chain.
44

55
## Instructions
6-
1. Clone [ops-anton](https://github.com/anton-rs/ops-anton) and follow the instructions in the README to set up your rollup.
7-
2. Go to [op-node.sh](https://github.com/anton-rs/ops-anton/blob/main/L2/op-mainnet/op-node/op-node.sh#L4-L6) and set the `L2_RPC` to your rollup RPC. Modify the `l1` and `l1.beacon` to your L1 and L1 Beacon RPCs. Note: Your L1 node should be an archive node.
8-
3. If you are starting a node for a different chain, you will need to modify `op-network` in `op-geth.sh` [here](https://github.com/anton-rs/ops-anton/blob/main/L2/op-mainnet/op-geth/op-geth.sh#L18) and `network` in `op-node.sh` [here](https://github.com/anton-rs/ops-anton/blob/main/L2/op-mainnet/op-node/op-node.sh#L10).
9-
4. In `/L2/op-mainnet` (or the directory you chose):
10-
1. Generate a JWT secret `./generate_jwt.sh`
11-
2. `docker network create anton-net` (Creates a Docker network for the nodes to communicate on).
12-
3. `just up` (Starts all the services).
6+
1. Clone [simple-optimism-node](https://github.com/smartcontracts/simple-optimism-node) and follow the instructions in the README to set up your rollup.
7+
2. Ensure you configure the rollup with `NODE_TYPE`=`archive` and `OP_GETH__SYNCMODE`=snap. With this, you will be able to prove blocks in OP Succcinct using blocks after the snap sync.
138

14-
Your `op-geth` endpoint will be available at the RPC port chosen [here](https://github.com/anton-rs/ops-anton/blob/main/L2/op-mainnet/op-geth/op-geth.sh#L7), which in this case is `8547` (e.g. `http://localhost:8547`).
9+
Your `op-geth` endpoint will be available at the RPC port chosen [here](https://github.com/smartcontracts/simple-optimism-node/blob/main/scripts/start-op-geth.sh#L39), which in this case is `8545` (e.g. `http://localhost:8545`).
1510

16-
Your `op-node` endpoint (rollup node) will be available at the RPC port chosen [here](https://github.com/anton-rs/ops-anton/blob/main/L2/op-mainnet/op-node/op-node.sh#L13), which in this case is `5058` (e.g. `http://localhost:5058`).
11+
Your `op-node` endpoint (rollup node) will be available at the RPC port chosen [here](https://github.com/smartcontracts/simple-optimism-node/blob/main/scripts/start-op-node.sh#L21), which in this case is `9545` (e.g. `http://localhost:9545`).
1712

1813
## Check Sync Status
1914

@@ -24,11 +19,11 @@ To check your node's sync status, you can run the following commands:
2419
**op-geth:**
2520

2621
```bash
27-
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://localhost:8547
22+
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://localhost:8545
2823
```
2924

3025
**op-node:**
3126

3227
```bash
33-
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"optimism_syncStatus","params":[],"id":1}' http://localhost:5058
34-
```
28+
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"optimism_syncStatus","params":[],"id":1}' http://localhost:9545
29+
```

book/architecture.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ OP Succinct enables OP Stack blocks to be proven with SP1 through a lightweight
3434

3535
### Core Components
3636

37-
1. <!-- mdbook-link-ignore --> **[Range Program](/programs/range/src/main.rs)**
37+
1. **[Range Program](https://github.com/succinctlabs/op-succinct/tree/main/programs/range/src/main.rs)**
3838
- Derives and executes batches of blocks
3939
- Generates proofs of correct execution
4040

41-
2. <!-- mdbook-link-ignore -->**[Aggregation Program](/programs/aggregation/src/main.rs)**
41+
2. **[Aggregation Program](https://github.com/succinctlabs/op-succinct/tree/main/programs/aggregation/src/main.rs)**
4242
- Aggregates multiple range program proofs
4343
- Reduces on-chain verification costs
4444

book/book.toml

Lines changed: 0 additions & 10 deletions
This file was deleted.

proposer/op/proposer/db/db.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,19 @@ func (db *ProofDB) GetConsecutiveSpanProofs(start, end uint64) ([][]byte, error)
443443

444444
return result, nil
445445
}
446+
447+
// Get the proofs with start block and end block of a specific status.
448+
func (db *ProofDB) GetProofRequestsWithBlockRangeAndStatus(proofType proofrequest.Type, startBlock, endBlock uint64, status proofrequest.Status) ([]*ent.ProofRequest, error) {
449+
proofs, err := db.readClient.ProofRequest.Query().
450+
Where(
451+
proofrequest.TypeEQ(proofType),
452+
proofrequest.StartBlockEQ(startBlock),
453+
proofrequest.EndBlockEQ(endBlock),
454+
proofrequest.StatusEQ(status),
455+
).
456+
All(context.Background())
457+
if err != nil {
458+
return nil, fmt.Errorf("failed to query proofs with block range and status: %w", err)
459+
}
460+
return proofs, nil
461+
}

proposer/op/proposer/prove.go

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (l *L2OutputSubmitter) ProcessWitnessgenRequests() error {
8181

8282
// Retry a proof request. Sets the status of a proof to FAILED and retries the proof based on the optional proof status response.
8383
// If an error response is received:
84-
// - Range Proof: Split in two if the block range is > 1. Retry the same request if range is 1 block.
84+
// - Range Proof: Split in two if the block range is > 1 AND the proof is unexecutable OR has failed before. Retry the same request if range is 1 block.
8585
// - Agg Proof: Retry the same request.
8686
func (l *L2OutputSubmitter) RetryRequest(req *ent.ProofRequest, status ProofStatusResponse) error {
8787
err := l.db.UpdateProofStatus(req.ID, proofrequest.StatusFAILED)
@@ -90,11 +90,30 @@ func (l *L2OutputSubmitter) RetryRequest(req *ent.ProofRequest, status ProofStat
9090
return err
9191
}
9292

93-
// If there's an execution error AND the request is a SPAN proof AND the block range is > 1, split the request into two requests.
94-
// This is likely caused by an SP1 OOM due to a large block range with many transactions.
95-
// TODO: This solution can be removed once the embedded allocator is used, because then the programs
96-
// will never OOM.
97-
if req.Type == proofrequest.TypeSPAN && status.ExecutionStatus == SP1ExecutionStatusUnexecutable && req.EndBlock-req.StartBlock > 1 {
93+
unexecutable := status.ExecutionStatus == SP1ExecutionStatusUnexecutable
94+
spanProof := req.Type == proofrequest.TypeSPAN
95+
multiBlockRange := req.EndBlock-req.StartBlock > 1
96+
97+
// Get the number of failed requests with the same block range and status.
98+
prevFailedReq, err := l.db.GetProofRequestsWithBlockRangeAndStatus(req.Type, req.StartBlock, req.EndBlock, proofrequest.StatusFAILED)
99+
if err != nil {
100+
l.Log.Error("failed to check for previous failures", "err", err)
101+
return err
102+
}
103+
104+
// Check if there is another proof (besides the one marked as failed above) with the same block range that also failed.
105+
severalFailedRequests := len(prevFailedReq) > 1
106+
107+
// If there's an execution error OR several failed requests AND the request is a SPAN proof AND the block range is > 1,
108+
// split the request into two requests.
109+
//
110+
// If the embedded allocator is enabled, the proof will never be unexecutable. Instead, the issue is because there's a limit on the number
111+
// of shards in V4. This will be fixed in V5 when the cycle limit is removed.
112+
//
113+
// If the embedded allocator is not enabled, the trigger for unexecutable is the SP1 OOM.
114+
//
115+
// The reason why we only split with multiple failed requests is to avoid transient errors causing unnecessary splits.
116+
if spanProof && (unexecutable || severalFailedRequests) && multiBlockRange {
98117
// Split the request into two requests.
99118
midBlock := (req.StartBlock + req.EndBlock) / 2
100119
err = l.db.NewEntry(req.Type, req.StartBlock, midBlock)

proposer/succinct/bin/server.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ use sp1_sdk::{
3131
utils, HashableKey, Prover, ProverClient, SP1Proof, SP1ProofMode, SP1ProofWithPublicValues,
3232
SP1_CIRCUIT_VERSION,
3333
};
34-
use std::{env, fs, str::FromStr, time::Instant};
34+
use std::{
35+
env, fs,
36+
str::FromStr,
37+
time::{Instant, SystemTime, UNIX_EPOCH},
38+
};
3539
use tower_http::limit::RequestBodyLimitLayer;
3640

3741
pub const RANGE_ELF: &[u8] = include_bytes!("../../../elf/range-elf");
@@ -546,7 +550,12 @@ async fn get_proof_status(
546550
};
547551

548552
// Check the deadline.
549-
if status.deadline < Instant::now().elapsed().as_secs() {
553+
if status.deadline
554+
< SystemTime::now()
555+
.duration_since(UNIX_EPOCH)
556+
.unwrap()
557+
.as_secs()
558+
{
550559
error!(
551560
"Proof request timed out on the server. Default timeout is set to 4 hours. Returning status as Unfulfillable."
552561
);

0 commit comments

Comments
 (0)