Skip to content

Commit

Permalink
Get rid of exact math for sector roots response size (#1339)
Browse files Browse the repository at this point in the history
`areq` has an alert for unexpected response size (very old host),
figured getting rid of the exact math is probably ok, reused
`maxMerkleProofResponseSize` to avoid duplicating the const
  • Loading branch information
peterjan authored Jun 25, 2024
1 parent 8ad5541 commit c03d012
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions worker/rhpv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,11 @@ func (w *worker) fetchContractRoots(t *rhpv2.Transport, rev *rhpv2.ContractRevis
// calculate the cost
cost, _ := settings.RPCSectorRootsCost(offset, n).Total()

// calculate the response size
proofSize := rhpv2.RangeProofSize(numsectors, offset, offset+n)
responseSize := (proofSize + n) * crypto.HashSize

// TODO: remove once host network is updated
if build.VersionCmp(settings.Version, "1.6.0") < 0 {
// calculate the response size
proofSize := rhpv2.RangeProofSize(numsectors, offset, offset+n)
responseSize := (proofSize + n) * crypto.HashSize
if responseSize < minMessageSize {
responseSize = minMessageSize
}
Expand Down Expand Up @@ -609,7 +608,7 @@ func (w *worker) fetchContractRoots(t *rhpv2.Transport, rev *rhpv2.ContractRevis
var rootsResp rhpv2.RPCSectorRootsResponse
if err := t.WriteRequest(rhpv2.RPCSectorRootsID, req); err != nil {
return nil, err
} else if err := t.ReadResponse(&rootsResp, minMessageSize+responseSize); err != nil {
} else if err := t.ReadResponse(&rootsResp, maxMerkleProofResponseSize); err != nil {
return nil, fmt.Errorf("couldn't read sector roots response: %w", err)
}

Expand Down

0 comments on commit c03d012

Please sign in to comment.