Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Dec 23, 2024
1 parent 88e157e commit b2b05aa
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions proposer/op/proposer/prove.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import (
)

const PROOF_STATUS_TIMEOUT = 30 * time.Second
const WITNESSGEN_TIMEOUT = 60 * 60 * time.Second
const WITNESSGEN_TIMEOUT = 60 * 60 * 4 * time.Second

// This limit is set to prevent overloading the witness generation server. Until Kona improves their native I/O API (https://github.com/anton-rs/kona/issues/553)
// the maximum number of concurrent witness generation requests is roughly num_cpu / 2. Set it to 5 for now to be safe.
const MAX_CONCURRENT_WITNESS_GEN = 3
const MAX_CONCURRENT_WITNESS_GEN = 10

// Process all of requests in PROVING state.
func (l *L2OutputSubmitter) ProcessProvingRequests() error {
Expand Down Expand Up @@ -257,13 +257,8 @@ func (l *L2OutputSubmitter) prepareProofRequest(p ent.ProofRequest) ([]byte, err

// RequestProof handles both mock and real proof requests
func (l *L2OutputSubmitter) RequestProof(p ent.ProofRequest, isMock bool) error {
jsonBody, err := l.prepareProofRequest(p)
if err != nil {
return err
}

if isMock {
proofData, err := l.requestMockProof(p.Type, jsonBody)
proofData, err := l.requestMockProof(p.Type, p)
if err != nil {
return fmt.Errorf("mock proof request failed: %w", err)
}
Expand All @@ -277,7 +272,7 @@ func (l *L2OutputSubmitter) RequestProof(p ent.ProofRequest, isMock bool) error
}

// Request a real proof from the witness generation server. Returns the proof ID from the network.
proofID, err := l.requestRealProof(p.Type, jsonBody)
proofID, err := l.requestRealProof(p.Type, p)
if err != nil {
return fmt.Errorf("real proof request failed: %w", err)
}
Expand All @@ -291,8 +286,8 @@ func (l *L2OutputSubmitter) RequestProof(p ent.ProofRequest, isMock bool) error
return l.db.SetProverRequestID(p.ID, proofID)
}

func (l *L2OutputSubmitter) requestRealProof(proofType proofrequest.Type, jsonBody []byte) ([]byte, error) {
resp, err := l.makeProofRequest(proofType, jsonBody)
func (l *L2OutputSubmitter) requestRealProof(proofType proofrequest.Type, p ent.ProofRequest) ([]byte, error) {
resp, err := l.makeProofRequest(proofType, p)
if err != nil {
return nil, err
}
Expand All @@ -308,8 +303,8 @@ func (l *L2OutputSubmitter) requestRealProof(proofType proofrequest.Type, jsonBo
}

// Request a mock proof from the witness generation server.
func (l *L2OutputSubmitter) requestMockProof(proofType proofrequest.Type, jsonBody []byte) ([]byte, error) {
resp, err := l.makeProofRequest(proofType, jsonBody)
func (l *L2OutputSubmitter) requestMockProof(proofType proofrequest.Type, p ent.ProofRequest) ([]byte, error) {
resp, err := l.makeProofRequest(proofType, p)
if err != nil {
return nil, err
}
Expand All @@ -323,7 +318,12 @@ func (l *L2OutputSubmitter) requestMockProof(proofType proofrequest.Type, jsonBo
}

// Make a proof request to the witness generation server for the correct proof type.
func (l *L2OutputSubmitter) makeProofRequest(proofType proofrequest.Type, jsonBody []byte) ([]byte, error) {
func (l *L2OutputSubmitter) makeProofRequest(proofType proofrequest.Type, p ent.ProofRequest) ([]byte, error) {
jsonBody, err := l.prepareProofRequest(p)
if err != nil {
return nil, err
}

urlPath := l.getProofEndpoint(proofType)
req, err := http.NewRequest("POST", l.Cfg.OPSuccinctServerUrl+"/"+urlPath, bytes.NewBuffer(jsonBody))
if err != nil {
Expand All @@ -344,7 +344,7 @@ func (l *L2OutputSubmitter) makeProofRequest(proofType proofrequest.Type, jsonBo
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
l.Log.Error("Witness generation request failed", "status", resp.StatusCode, "body", resp.Body)
l.Log.Error("Witness generation request failed. ", "proofType", proofType, "start", p.StartBlock, "end", p.EndBlock, "status", resp.StatusCode, "body", resp.Body)
l.Metr.RecordWitnessGenFailure("Failed")
return nil, fmt.Errorf("received non-200 status code: %d", resp.StatusCode)
}
Expand Down

0 comments on commit b2b05aa

Please sign in to comment.