Skip to content

Commit

Permalink
rhp4: add proof validation comment
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Sep 28, 2024
1 parent c1dddb9 commit 3543c96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion rhp/v4/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func RPCSettings(ctx context.Context, t TransportClient) (rhp4.HostSettings, err
}

// RPCReadSector reads a sector from the host.
func RPCReadSector(ctx context.Context, t TransportClient, prices rhp4.HostPrices, token rhp4.AccountToken, root types.Hash256, offset, length uint64, w io.Writer) (RPCReadSectorResult, error) {
func RPCReadSector(ctx context.Context, t TransportClient, prices rhp4.HostPrices, token rhp4.AccountToken, w io.Writer, root types.Hash256, offset, length uint64) (RPCReadSectorResult, error) {
req := &rhp4.RPCReadSectorRequest{
Prices: prices,
Token: token,
Expand Down Expand Up @@ -304,6 +304,8 @@ func RPCModifySectors(ctx context.Context, t TransportClient, cs consensus.State
return RPCModifySectorsResult{}, fmt.Errorf("failed to read response: %w", err)
}

// TODO: verify proof

revision, err := rhp4.ReviseForModifySectors(contract.Revision, req, resp)
if err != nil {
return RPCModifySectorsResult{}, fmt.Errorf("failed to revise contract: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions rhp/v4/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ func TestReadWriteSector(t *testing.T) {

// read the sector back
buf := bytes.NewBuffer(nil)
_, err = rhp4.RPCReadSector(context.Background(), transport, settings.Prices, token, writeResult.Root, 0, 64, buf)
_, err = rhp4.RPCReadSector(context.Background(), transport, settings.Prices, token, buf, writeResult.Root, 0, 64)
if err != nil {
t.Fatal(err)
} else if !bytes.Equal(buf.Bytes(), data[:64]) {
Expand Down Expand Up @@ -1364,7 +1364,7 @@ func BenchmarkRead(b *testing.B) {
for i := 0; i < b.N; i++ {
buf.Reset()
// store the sector
_, err = rhp4.RPCReadSector(context.Background(), transport, settings.Prices, token, roots[i], 0, proto4.SectorSize, buf)
_, err = rhp4.RPCReadSector(context.Background(), transport, settings.Prices, token, buf, roots[i], 0, proto4.SectorSize)
if err != nil {
b.Fatal(err)
} else if !bytes.Equal(buf.Bytes(), sectors[i][:]) {
Expand Down

0 comments on commit 3543c96

Please sign in to comment.