@@ -16,10 +16,9 @@ import (
1616 "github.com/stretchr/testify/require"
1717)
1818
19- // /blob/accept is performed by the upload service: the handler requires the
20- // invocation issuer to be the upload service DID and reads the space from the
21- // invocation subject (authorized by a space->upload-service delegation). The
22- // handler:
19+ // /blob/accept is performed by the upload service: The invocation subject is
20+ // the storage provider (authorized by a provider->upload-service delegation)
21+ // and the space travels in AcceptArguments.Space. The handler:
2322// - looks up the blob bytes in the piece store (Has check)
2423// - writes an acceptance record carrying a /pdp/accept promise
2524// - issues a /assert/location claim and persists it in the invocation store
@@ -42,20 +41,22 @@ func (s *RPCSuite) TestBlobAccept_Basic() {
4241 // hand it a freshly-minted CID — the handler doesn't resolve the
4342 // promise, it just persists it alongside the acceptance record.
4443 putAwait := promise.AwaitOK {Task : testutil .RandomCID (t )}
44+ space := testutil .RandomDID (t )
4545
46- // /blob/accept is performed by the upload service: the space delegates
47- // /blob/accept to the upload service (the guppy chain), which then
48- // issues the invocation with the space as its subject and the
49- // delegation as proof .
46+ // /blob/accept is performed by the upload service: the provider delegates
47+ // /blob/accept to the upload service, which issues the invocation with the
48+ // provider as its subject and the delegation as proof. The space travels in
49+ // the arguments .
5050 proof := testutil .Must (delegation .Delegate (
5151 s .ServiceID , s .UploadServiceIdentity .DID (), s .ServiceID .DID (), blob .Accept .Command ,
5252 ))(t )
5353 inv := testutil .Must (blob .Accept .Invoke (
5454 s .UploadServiceIdentity ,
5555 s .ServiceID .DID (),
5656 & blob.AcceptArguments {
57- Blob : blob.Blob {Digest : digest , Size : size },
58- Put : putAwait ,
57+ Space : space ,
58+ Blob : blob.Blob {Digest : digest , Size : size },
59+ Put : putAwait ,
5960 },
6061 invocation .WithAudience (s .ServiceID .DID ()),
6162 invocation .WithProofs (proof .Link ()),
@@ -66,11 +67,11 @@ func (s *RPCSuite) TestBlobAccept_Basic() {
6667 require .NotEqual (t , cid .Undef , ok .Site , "AcceptOK.Site is the location claim CID" )
6768
6869 // Acceptance store carries the accepted blob + space + cause.
69- acc , err := s .Acceptances .Get (t .Context (), digest , s . ServiceID . DID () )
70+ acc , err := s .Acceptances .Get (t .Context (), digest , space )
7071 require .NoError (t , err , "acceptance persisted" )
7172 require .Equal (t , digest , acc .Blob .Digest )
7273 require .Equal (t , size , acc .Blob .Size )
73- require .Equal (t , s . ServiceID . DID () , acc .Space )
74+ require .Equal (t , space , acc .Space )
7475 require .Equal (t , inv .Task ().Link (), acc .Cause , "cause records the accept task link" )
7576 require .NotNil (t , acc .PDPAccept , "PDP accept promise is recorded for aggregation completion" )
7677
@@ -79,7 +80,7 @@ func (s *RPCSuite) TestBlobAccept_Basic() {
7980 require .NoError (t , err , "location claim persisted under Site CID" )
8081 require .Equal (t , s .ServiceID .DID (), claim .Issuer (), "claim is signed by the service" )
8182 require .Equal (t , s .ServiceID .DID (), claim .Subject (),
82- "location claim is scoped to the service in the current single-space handler " )
83+ "location claim is issued by the provider node " )
8384 require .Equal (t , assert .Location .Command , claim .Command (),
8485 "claim is an /assert/location invocation" )
8586
@@ -89,6 +90,7 @@ func (s *RPCSuite) TestBlobAccept_Basic() {
8990 require .NoError (t , locArgs .UnmarshalCBOR (bytes .NewReader (claim .ArgumentsBytes ())),
9091 "location claim args decode" )
9192 require .Equal (t , digest , locArgs .Content , "claim references the accepted blob digest" )
93+ require .Equal (t , space , locArgs .Space , "location claim is scoped to the space from the args" )
9294 expectedURL , err := s .Pieces .ReadPieceURL (cid .NewCidV1 (cid .Raw , digest ))
9395 require .NoError (t , err )
9496 require .Len (t , locArgs .Location , 1 )
@@ -117,18 +119,25 @@ func (s *RPCSuite) TestBlobAccept_ExistingDataInDifferentSpace() {
117119 digest := testutil .Must (multihash .Sum (data , multihash .SHA2_256 , - 1 ))(t )
118120 size := uint64 (len (data ))
119121
120- // Two spaces, each its own did:key signer. Each self-issues its
121- // /blob/allocate (issuer == subject, no proof chain) but delegates
122- // /blob/accept to the upload service, which issues that invocation.
123- spaceA := testutil .RandomSigner (t )
124- spaceB := testutil .RandomSigner (t )
122+ // Two spaces, each just a DID carried in the invocation arguments. Every
123+ // invocation's subject is the provider. /blob/allocate is self-issued by the
124+ // provider (issuer == subject, no proof chain); /blob/accept is issued by the
125+ // upload service and authorized by a single provider->upload-service
126+ // delegation, reused across spaces since it is not space-scoped.
127+ spaceA := testutil .RandomDID (t )
128+ spaceB := testutil .RandomDID (t )
129+
130+ acceptProof := testutil .Must (delegation .Delegate (
131+ s .ServiceID , s .UploadServiceIdentity .DID (), service , blob .Accept .Command ,
132+ ))(t )
125133
126134 // --- spaceA: first allocation, then upload, then accept ---
127135
128136 allocA := testutil .Must (blob .Allocate .Invoke (
129- spaceA ,
130- spaceA . DID () ,
137+ s . ServiceID ,
138+ service ,
131139 & blob.AllocateArguments {
140+ Space : spaceA ,
132141 Blob : blob.Blob {Digest : digest , Size : size },
133142 Cause : testutil .RandomCID (t ),
134143 },
@@ -141,30 +150,26 @@ func (s *RPCSuite) TestBlobAccept_ExistingDataInDifferentSpace() {
141150 // Simulate the upload completing.
142151 s .Pieces .Put (digest , data )
143152
144- // /blob/accept is issued by the upload service; each space delegates
145- // the capability to it (the guppy chain) and the delegation rides
146- // along as proof.
147- acceptProofA := testutil .Must (delegation .Delegate (
148- spaceA , s .UploadServiceIdentity .DID (), spaceA .DID (), blob .Accept .Command ,
149- ))(t )
150153 acceptA := testutil .Must (blob .Accept .Invoke (
151154 s .UploadServiceIdentity ,
152- spaceA . DID () ,
155+ service ,
153156 & blob.AcceptArguments {
154- Blob : blob.Blob {Digest : digest , Size : size },
155- Put : promise.AwaitOK {Task : testutil .RandomCID (t )},
157+ Space : spaceA ,
158+ Blob : blob.Blob {Digest : digest , Size : size },
159+ Put : promise.AwaitOK {Task : testutil .RandomCID (t )},
156160 },
157161 invocation .WithAudience (service ),
158- invocation .WithProofs (acceptProofA .Link ()),
162+ invocation .WithProofs (acceptProof .Link ()),
159163 ))(t )
160- acceptOKA := decodeAcceptOK (t , s .sendInvocationWithProofs (t , acceptA , acceptProofA ))
164+ acceptOKA := decodeAcceptOK (t , s .sendInvocationWithProofs (t , acceptA , acceptProof ))
161165
162166 // --- spaceB: bytes are already present from spaceA's upload ---
163167
164168 allocB := testutil .Must (blob .Allocate .Invoke (
165- spaceB ,
166- spaceB . DID () ,
169+ s . ServiceID ,
170+ service ,
167171 & blob.AllocateArguments {
172+ Space : spaceB ,
168173 Blob : blob.Blob {Digest : digest , Size : size },
169174 Cause : testutil .RandomCID (t ),
170175 },
@@ -176,20 +181,18 @@ func (s *RPCSuite) TestBlobAccept_ExistingDataInDifferentSpace() {
176181 require .Nil (t , okB .Address ,
177182 "bytes already in store from spaceA — no upload URL for spaceB" )
178183
179- acceptProofB := testutil .Must (delegation .Delegate (
180- spaceB , s .UploadServiceIdentity .DID (), spaceB .DID (), blob .Accept .Command ,
181- ))(t )
182184 acceptB := testutil .Must (blob .Accept .Invoke (
183185 s .UploadServiceIdentity ,
184- spaceB . DID () ,
186+ service ,
185187 & blob.AcceptArguments {
186- Blob : blob.Blob {Digest : digest , Size : size },
187- Put : promise.AwaitOK {Task : testutil .RandomCID (t )},
188+ Space : spaceB ,
189+ Blob : blob.Blob {Digest : digest , Size : size },
190+ Put : promise.AwaitOK {Task : testutil .RandomCID (t )},
188191 },
189192 invocation .WithAudience (service ),
190- invocation .WithProofs (acceptProofB .Link ()),
193+ invocation .WithProofs (acceptProof .Link ()),
191194 ))(t )
192- acceptOKB := decodeAcceptOK (t , s .sendInvocationWithProofs (t , acceptB , acceptProofB ))
195+ acceptOKB := decodeAcceptOK (t , s .sendInvocationWithProofs (t , acceptB , acceptProof ))
193196
194197 // --- both spaces have independent records keyed on (digest, space) ---
195198
@@ -198,8 +201,8 @@ func (s *RPCSuite) TestBlobAccept_ExistingDataInDifferentSpace() {
198201 site cid.Cid
199202 cause cid.Cid
200203 }{
201- {spaceA . DID () , acceptOKA .Site , acceptA .Task ().Link ()},
202- {spaceB . DID () , acceptOKB .Site , acceptB .Task ().Link ()},
204+ {spaceA , acceptOKA .Site , acceptA .Task ().Link ()},
205+ {spaceB , acceptOKB .Site , acceptB .Task ().Link ()},
203206 } {
204207 alloc , err := s .Allocations .Get (t .Context (), digest , sp .space )
205208 require .NoError (t , err , "allocation persisted under space=%s" , sp .space )
0 commit comments