Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ratan/phala
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Oct 10, 2024
2 parents d929506 + 135d0b2 commit 8100a10
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions proposer/op/proposer/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ func (db *ProofDB) GetConsecutiveSpanProofs(start, end uint64) ([][]byte, error)
currentBlock = span.EndBlock
}

if currentBlock-1 != end {
return nil, fmt.Errorf("incomplete proof chain: ends at block %d, expected %d", currentBlock-1, end)
if currentBlock != end {
return nil, fmt.Errorf("incomplete proof chain: ends at block %d, expected %d", currentBlock, end)
}

return result, nil
Expand Down
6 changes: 3 additions & 3 deletions proposer/op/proposer/prove.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ func (l *L2OutputSubmitter) RequestSpanProof(l2Start, l2End uint64) (string, err
return l.RequestProofFromServer("request_span_proof", jsonBody)
}

// Request an aggregate proof for the range [start+1, end]. If there is not a consecutive set of span proofs,
// Request an aggregate proof for the range [start, end]. If there is not a consecutive set of span proofs,
// which cover the range, the request will error.
func (l *L2OutputSubmitter) RequestAggProof(start, end uint64, l1BlockHash string) (string, error) {
l.Log.Info("requesting agg proof", "start", start, "end", end)

// Query the DB for the consecutive span proofs that cover the range [start+1, end].
subproofs, err := l.db.GetConsecutiveSpanProofs(start+1, end)
// Query the DB for the consecutive span proofs that cover the range [start, end].
subproofs, err := l.db.GetConsecutiveSpanProofs(start, end)
if err != nil {
return "", fmt.Errorf("failed to get subproofs: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion proposer/op/proposer/span_batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Span struct {
func (l *L2OutputSubmitter) CreateSpans(start, end uint64) []Span {
spans := []Span{}
// Create spans of size MaxBlockRangePerSpanProof from start to end.
// Each span starts where the previous one ended + 1.
// Each span starts where the previous one ended.
// Continue until we can't fit another full span before reaching end.
for i := start; i+l.Cfg.MaxBlockRangePerSpanProof <= end; i += l.Cfg.MaxBlockRangePerSpanProof {
spans = append(spans, Span{Start: i, End: i + l.Cfg.MaxBlockRangePerSpanProof})
Expand Down
6 changes: 3 additions & 3 deletions proposer/op/proposer/span_batches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestCreateSpans(t *testing.T) {
maxBlockRange: 500,
expectedSpansCount: 3,
expectedFirstSpan: Span{Start: 1000, End: 1500},
expectedLastSpan: Span{Start: 2002, End: 2502},
expectedLastSpan: Span{Start: 2000, End: 2500},
},
{
name: "Partial last span excluded",
Expand All @@ -43,7 +43,7 @@ func TestCreateSpans(t *testing.T) {
maxBlockRange: 100,
expectedSpansCount: 2,
expectedFirstSpan: Span{Start: 100, End: 200},
expectedLastSpan: Span{Start: 201, End: 301},
expectedLastSpan: Span{Start: 200, End: 300},
},
{
name: "No spans possible",
Expand All @@ -69,7 +69,7 @@ func TestCreateSpans(t *testing.T) {
}

for i := 0; i < len(spans)-1; i++ {
assert.Equal(t, spans[i].End+1, spans[i+1].Start, "Spans should be contiguous")
assert.Equal(t, spans[i].End, spans[i+1].Start, "Spans should be contiguous")
assert.Equal(t, tt.maxBlockRange, spans[i].End-spans[i].Start, "Span range should match maxBlockRange")
}
})
Expand Down

0 comments on commit 8100a10

Please sign in to comment.