Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible endless loop in resolving DID document #164

Open
S3bb1 opened this issue May 5, 2021 · 2 comments
Open

Possible endless loop in resolving DID document #164

S3bb1 opened this issue May 5, 2021 · 2 comments

Comments

@S3bb1
Copy link

S3bb1 commented May 5, 2021

Hi all,

i found a possible endless loop when resolving a DID document.

Test scenario:

  const testDid = 'did:elem:EiC6QAiru_uIUJf9FF18mxUFyLSqhsE-ZvCUj0N5--cmHg';
  const testData = [{
    type: 'create',
    suffix_data: 'eyJkZWx0YV9oYXNoIjoiRWlBOVNGU2hacVQzVWQ3eWtTdFZpTmxZZ2VpRjViblNuZUd6Vl9MdjVCbXdsUSIsInJlY292ZXJ5X2NvbW1pdG1lbnQiOiJFaUMzaDVoanJJdzRfRHBlUzB6RjRaanVRXzdzSFFjRXVPWVRHOXZOcDlMdUxRIn0',
    delta: 'eyJwYXRjaGVzIjpbeyJhY3Rpb24iOiJyZXBsYWNlIiwiZG9jdW1lbnQiOnsicHVibGljX2tleXMiOlt7ImlkIjoiejZNa20zQ3ZhUDdjRG9RRTRTd0V2ajNMMTJzZHBQYnl5WjE2ZlhvR1NvWUFzS0N4IiwiandrIjp7ImNydiI6IkVkMjU1MTkiLCJrdHkiOiJPS1AiLCJ4IjoiWWRoWEYyc1BNVW85OWdTNE1WSWNSeW0xQTVaMWhsRGg2REt0MFByWXRfMCJ9LCJwdXJwb3NlIjpbImdlbmVyYWwiLCJhdXRoIiwiYXNzZXJ0aW9uIiwiaW52b2NhdGlvbiIsImRlbGVnYXRpb24iXSwidHlwZSI6Ikpzb25XZWJLZXkyMDIwIn0seyJpZCI6Ino2TFNoYkZua0NmM0cyaDVHeXl1RHhLMmJCUHZzcjZEbml0UERCazNXQmhkQ0tTTiIsImp3ayI6eyJjcnYiOiJYMjU1MTkiLCJrdHki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Wx0YV9oYXNoIjoiRWlEWFhFdENUYWNHYjZvZFVoVDBzdl8tR1lsQ2lnaWtiV1NtTWpyQWtTNEJxZyIsInVwZGF0ZV9rZXkiOnsiY3J2IjoiRWQyNTUxOSIsImt0eSI6Ik9LUCIsIngiOiJZZGhYRjJzUE1Vbzk5Z1M0TVZJY1J5bTFBNVoxaGxEaDZES3QwUHJZdF8wIn19.pPi69Jbw8C6Pw8jfyu8hmNjt3XJgTzn6rjza1hrxBKaVbhlNS8V8ZyvXR-ZeGqT37kNJvw6sBOgBuCznPZtNDw',
    delta: 'eyJwYXRjaGVzIjpbeyJhY3Rpb24iOiJhZGQtc2VydmljZS1lbmRwb2ludHMiLCJzZXJ2aWNlX2VuZHBvaW50cyI6W3siZW5kcG9pbnQiOiJodHRwOi8vdGVzdDIuY29tIiwiaWQiOiJ0ZXN0MiIsInR5cGUiOiJTZWN1cmVEYXRhU3RvcmUifV19XSwidXBkYXRlX2NvbW1pdG1lbnQiOiJFaUMzaDVoanJJdzRfRHBlUzB6RjRaanVRXzdzSFFjRXVPWVRHOXZOcDlMdUxRIn0'
  }]

When executing these three operations in order with the following order

   await element.handleOperationRequest(
    Buffer.from(JSON.stringify(testData[0]))
  );
  await element.triggerBatchAndObserve();
   await element.handleOperationRequest(
    Buffer.from(JSON.stringify(testData[1]))
  );
  await element.triggerBatchAndObserve();
   await element.handleOperationRequest(
    Buffer.from(JSON.stringify(testData[2]))
  );
  await element.triggerBatchAndObserve();
  const resolveRequest = await element.handleResolveRequest(testDid);

sidetree.js runs into an endless loop during calculation of the didState. This is because i updated the DID document with 2 times the same "updateCommitment" hash.

In the resolver where the commitValueToOperationMap is processed i have for the same entry two values:

image

now the while loop in https://github.com/transmute-industries/sidetree.js/blob/main/packages/core/src/Resolver.ts#L151 checks if the map has the nextUpdateCommitmentHash and continues the loop. My nextUpdateCommitmentHash is always the same like in the picture above EiC3h5hjrIw4_DpeS0zF4ZjuQ_7sHQcEuOYTG9vNp9LuLQ and the while loop never finishes.

Solution would be that the already processed keys are deleted from the map.

I have also looked into the original Sidetree repo and it seems that the same issue exists there too.

@S3bb1 S3bb1 changed the title Possible endless Loop in resolving DID Document Possible endless loop in resolving DID document May 5, 2021
@OR13
Copy link
Sponsor Member

OR13 commented Jan 19, 2022

@BenjaminMoe I think I had you look at this issue on the upstream, please make sure to cross link so we get their fixes implemented.

@OR13
Copy link
Sponsor Member

OR13 commented Jan 20, 2022

I think this is related: decentralized-identity/sidetree#1172 (review)

@BenjaminMoe can you confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants