@@ -88,13 +88,18 @@ export class DecryptDdoHandler extends CommandHandler {
8888 }
8989
9090 async handle ( task : DecryptDDOCommand ) : Promise < P2PCommandResponse > {
91+ CORE_LOGGER . info (
92+ `Decrypt DDO handle start for chain ${ task . chainId } and asset ${ task . dataNftAddress } `
93+ )
9194 const validationResponse = await this . verifyParamsAndRateLimits ( task )
9295 if ( this . shouldDenyTaskHandling ( validationResponse ) ) {
96+ CORE_LOGGER . info ( 'Decrypt DDO denied during validation or rate limiting' )
9397 return validationResponse
9498 }
9599 const chainId = String ( task . chainId )
96100 const config = await getConfiguration ( )
97101 const supportedNetwork = config . supportedNetworks [ chainId ]
102+ CORE_LOGGER . info ( `Decrypt DDO loaded configuration for chain ${ chainId } ` )
98103
99104 // check if supported chainId
100105 if ( ! supportedNetwork ) {
@@ -114,6 +119,9 @@ export class DecryptDdoHandler extends CommandHandler {
114119 task . signature ,
115120 task . command
116121 )
122+ CORE_LOGGER . info (
123+ `Decrypt DDO authorization validation returned ${ isAuthRequestValid . status . httpStatus } `
124+ )
117125 if ( isAuthRequestValid . status . httpStatus !== 200 ) {
118126 return isAuthRequestValid
119127 }
@@ -132,16 +140,23 @@ export class DecryptDdoHandler extends CommandHandler {
132140 }
133141 }
134142 }
143+ CORE_LOGGER . info ( `Decrypt DDO normalized decrypter ${ decrypterAddress } ` )
135144
136145 const ourEthAddress = this . getOceanNode ( ) . getKeyManager ( ) . getEthAddress ( )
137146 if ( config . authorizedDecrypters . length > 0 ) {
147+ CORE_LOGGER . info (
148+ `Decrypt DDO checking static authorized decrypters for ${ decrypterAddress } `
149+ )
138150 // allow if on authorized list or it is own node
139151 if (
140152 ! config . authorizedDecrypters
141153 . map ( ( address ) => address ?. toLowerCase ( ) )
142154 . includes ( decrypterAddress ?. toLowerCase ( ) ) &&
143155 decrypterAddress ?. toLowerCase ( ) !== ourEthAddress . toLowerCase ( )
144156 ) {
157+ CORE_LOGGER . info (
158+ `Decrypt DDO rejected unauthorized decrypter ${ decrypterAddress } `
159+ )
145160 return {
146161 stream : null ,
147162 status : {
@@ -153,6 +168,9 @@ export class DecryptDdoHandler extends CommandHandler {
153168 }
154169 const oceanNode = this . getOceanNode ( )
155170 const blockchain = oceanNode . getBlockchain ( supportedNetwork . chainId )
171+ CORE_LOGGER . info (
172+ `Decrypt DDO resolved blockchain instance for chain ${ supportedNetwork . chainId } : ${ Boolean ( blockchain ) } `
173+ )
156174 if ( ! blockchain ) {
157175 return {
158176 stream : null ,
@@ -163,6 +181,7 @@ export class DecryptDdoHandler extends CommandHandler {
163181 }
164182 }
165183 const { ready, error } = await blockchain . isNetworkReady ( )
184+ CORE_LOGGER . info ( `Decrypt DDO network readiness for chain ${ chainId } : ${ ready } ` )
166185 if ( ! ready ) {
167186 return {
168187 stream : null ,
@@ -175,6 +194,7 @@ export class DecryptDdoHandler extends CommandHandler {
175194
176195 const provider = await blockchain . getProvider ( )
177196 const signer = await blockchain . getSigner ( )
197+ CORE_LOGGER . info ( `Decrypt DDO acquired provider and signer for chain ${ chainId } ` )
178198 // note: "getOceanArtifactsAdresses()"" is broken for at least optimism sepolia
179199 // if we do: artifactsAddresses[supportedNetwork.network]
180200 // because on the contracts we have "optimism_sepolia" instead of "optimism-sepolia"
@@ -186,6 +206,9 @@ export class DecryptDdoHandler extends CommandHandler {
186206 signer ,
187207 dataNftAddress
188208 )
209+ CORE_LOGGER . info (
210+ `Decrypt DDO factory validation for ${ dataNftAddress } : ${ wasDeployedByUs } `
211+ )
189212 if ( ! wasDeployedByUs ) {
190213 return {
191214 stream : null ,
@@ -205,6 +228,9 @@ export class DecryptDdoHandler extends CommandHandler {
205228 decrypterAddress ,
206229 signer
207230 )
231+ CORE_LOGGER . info (
232+ `Decrypt DDO access list authorization for ${ decrypterAddress } : ${ isAllowed } `
233+ )
208234 if ( ! isAllowed ) {
209235 return {
210236 stream : null ,
@@ -220,6 +246,9 @@ export class DecryptDdoHandler extends CommandHandler {
220246 let flags : number
221247 let documentHash : string
222248 if ( transactionId ) {
249+ CORE_LOGGER . info (
250+ `Decrypt DDO loading encrypted document from tx ${ transactionId } `
251+ )
223252 try {
224253 const receipt = await provider . getTransactionReceipt ( transactionId )
225254 if ( ! receipt . logs . length ) {
@@ -240,7 +269,13 @@ export class DecryptDdoHandler extends CommandHandler {
240269 flags = parseInt ( eventData . args [ 3 ] , 16 )
241270 encryptedDocument = ethers . getBytes ( eventData . args [ 4 ] )
242271 documentHash = eventData . args [ 5 ]
272+ CORE_LOGGER . info (
273+ `Decrypt DDO extracted metadata event ${ eventData . name } from tx ${ transactionId } `
274+ )
243275 } catch ( error ) {
276+ CORE_LOGGER . info (
277+ `Decrypt DDO failed to process transaction id ${ transactionId } `
278+ )
244279 return {
245280 stream : null ,
246281 status : {
@@ -250,12 +285,17 @@ export class DecryptDdoHandler extends CommandHandler {
250285 }
251286 }
252287 } else {
288+ CORE_LOGGER . info (
289+ 'Decrypt DDO loading encrypted document from direct request payload'
290+ )
253291 try {
254292 encryptedDocument = ethers . getBytes ( task . encryptedDocument )
255293 flags = Number ( task . flags )
256294 // eslint-disable-next-line prefer-destructuring
257295 documentHash = task . documentHash
296+ CORE_LOGGER . info ( 'Decrypt DDO converted direct request payload to bytes' )
258297 } catch ( error ) {
298+ CORE_LOGGER . info ( 'Decrypt DDO failed to convert direct request payload' )
259299 return {
260300 stream : null ,
261301 status : {
@@ -272,6 +312,9 @@ export class DecryptDdoHandler extends CommandHandler {
272312 )
273313 const metaData = await templateContract . getMetaData ( )
274314 const metaDataState = Number ( metaData [ 2 ] )
315+ CORE_LOGGER . info (
316+ `Decrypt DDO fetched metadata state ${ metaDataState } for ${ dataNftAddress } `
317+ )
275318 if ( [ MetadataStates . DEPRECATED , MetadataStates . REVOKED ] . includes ( metaDataState ) ) {
276319 CORE_LOGGER . logMessage ( `Decrypt DDO: error metadata state ${ metaDataState } ` , true )
277320 return {
@@ -303,11 +346,14 @@ export class DecryptDdoHandler extends CommandHandler {
303346 let decryptedDocument : Buffer
304347 // check if DDO is ECIES encrypted
305348 if ( ( flags & 2 ) !== 0 ) {
349+ CORE_LOGGER . info ( 'Decrypt DDO using ECIES decryption path' )
306350 try {
307351 decryptedDocument = await oceanNode
308352 . getKeyManager ( )
309353 . decrypt ( encryptedDocument , EncryptMethod . ECIES )
354+ CORE_LOGGER . info ( 'Decrypt DDO ECIES decryption succeeded' )
310355 } catch ( error ) {
356+ CORE_LOGGER . info ( 'Decrypt DDO ECIES decryption failed' )
311357 return {
312358 stream : null ,
313359 status : {
@@ -317,8 +363,10 @@ export class DecryptDdoHandler extends CommandHandler {
317363 }
318364 }
319365 } else {
366+ CORE_LOGGER . info ( 'Decrypt DDO using LZMA decompression path' )
320367 try {
321368 decryptedDocument = lzmajs . decompressFile ( decryptedDocument )
369+ CORE_LOGGER . info ( 'Decrypt DDO LZMA decompression succeeded' )
322370 /*
323371 lzma.decompress(
324372 decryptedDocument,
@@ -329,6 +377,7 @@ export class DecryptDdoHandler extends CommandHandler {
329377 )
330378 */
331379 } catch ( error ) {
380+ CORE_LOGGER . info ( 'Decrypt DDO LZMA decompression failed' )
332381 return {
333382 stream : null ,
334383 status : {
@@ -342,6 +391,7 @@ export class DecryptDdoHandler extends CommandHandler {
342391 // did matches
343392 const ddo = JSON . parse ( decryptedDocument . toString ( ) )
344393 if ( ddo . id && ! this . checkId ( ddo . id , dataNftAddress , chainId ) ) {
394+ CORE_LOGGER . info ( `Decrypt DDO DID validation failed for ${ ddo . id } ` )
345395 return {
346396 stream : null ,
347397 status : {
@@ -352,16 +402,20 @@ export class DecryptDdoHandler extends CommandHandler {
352402 }
353403 const decryptedDocumentString = decryptedDocument . toString ( )
354404 const ddoObject = JSON . parse ( decryptedDocumentString )
405+ CORE_LOGGER . info ( 'Decrypt DDO parsed decrypted document successfully' )
355406
356407 let stream = Readable . from ( decryptedDocumentString )
357408 if ( isRemoteDDO ( ddoObject ) ) {
409+ CORE_LOGGER . info ( 'Decrypt DDO detected remote DDO payload' )
358410 const storage = Storage . getStorageClass ( ddoObject . remote , config )
359411 const result = await storage . getReadableStream ( )
360412 stream = result . stream as Readable
413+ CORE_LOGGER . info ( 'Decrypt DDO loaded remote DDO stream' )
361414 } else {
362415 // checksum matches
363416 const decryptedDocumentHash = create256Hash ( decryptedDocument . toString ( ) )
364417 if ( decryptedDocumentHash !== documentHash ) {
418+ CORE_LOGGER . info ( 'Decrypt DDO checksum validation failed' )
365419 return {
366420 stream : null ,
367421 status : {
@@ -370,8 +424,10 @@ export class DecryptDdoHandler extends CommandHandler {
370424 }
371425 }
372426 }
427+ CORE_LOGGER . info ( 'Decrypt DDO checksum validation succeeded' )
373428 }
374429
430+ CORE_LOGGER . info ( `Decrypt DDO completed successfully for ${ dataNftAddress } ` )
375431 return {
376432 stream,
377433 status : { httpStatus : 200 }
0 commit comments