Skip to content

Conversation

reinkrul
Copy link
Member

This lower the amount of (now unnecessary) casting and JSON unmarshalling we do.

TODO:

  • Release go-did if PR is OK

Copy link
Member

@gerardsn gerardsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and pending performance test of course

Comment on lines -504 to +503
credentialSubject := make([]credential.BaseCredentialSubject, 0)
err := organization.UnmarshalCredentialSubject(&credentialSubject)
if err != nil {
return nil, did.DID{}, fmt.Errorf("unable to get DID from organization credential: %w", err)
}
organizationDIDStr := credentialSubject[0].ID
organizationDID, err := did.ParseDID(organizationDIDStr)
organizationDID, err := organization.SubjectDID()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is now a stricter check since VerifiableCredential.SubjectDID() checks if all credentialSubject.IDs are the same compared to just parsing the first value.

go.mod Outdated
github.com/nats-io/nats.go v1.39.1
github.com/nuts-foundation/crypto-ecies v0.0.0-20211207143025-5b84f9efce2b
github.com/nuts-foundation/go-did v0.15.0
github.com/nuts-foundation/go-did v0.15.1-0.20250319081900-aa2a47f72926
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update after go-did is tagged (and probably run go mod tidy for cleanup of go.sum)


import "encoding/json"

func remarshal(src interface{}, dst interface{}) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dst in the signature should probably be a pointer to match unmarshal behavior. the least line should then be return json.Unmarshal(asJSON, dst)

Comment on lines -168 to -178
for _, b := range bl {
if b.ID != "" {
// check credentialSubject
subjectDID, err := did.ParseDID(b.ID)
if err == nil {
if !slices.Contains(didMethods, subjectDID.Method) {
continue outer
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this used to require only one subjectDID to be valid, but credential.SubjectDID() now requires all to be valid and have the same value.

@reinkrul
Copy link
Member Author

reinkrul commented Mar 26, 2025

Test e2e-tests/nuts-network/private-transactions is performed using #3753 on my local system. This test performs 40 iterations, and it sleeps 1 second in each iteration. So 40 seconds needs to be retracted for wait time.

  • Baseline (20bdc8f4725ff1073b93fec20aa2f1ea5345a0e4) completes in 56~57 seconds
  • This PR (bd2ee943a35d59fe1f393aceb2276b4c12c62f86) completes in 56~57 seconds

So currently, no measurable benefit.

@gerardsn
Copy link
Member

its hard to give a meaningful interpretation to this without the profiler results

Copy link
Member

@woutslakhorst woutslakhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly better code, but unfortunately no real gain.

@gerardsn
Copy link
Member

gerardsn commented Apr 2, 2025

I still cannot make any conclusions based on these results. Subtracting the wait time and looking at the difference based on the information I have the gain could ~6% (=1-16/17).
This excludes several important factors:

  • Time lost in communicating to external DBs
  • Tests do not run in parallel, the condition that triggers issues in practice.
  • Tests are performed on hardware that does not have the same resource constraints that typical production node runs in.

@woutslakhorst
Copy link
Member

and pending performance test of course

even without performance gains, it cleans up the code (a bit)?

@gerardsn
Copy link
Member

gerardsn commented Apr 8, 2025

and pending performance test of course

even without performance gains, it cleans up the code (a bit)?

Agreed, but other comments above still stand.

@reinkrul
Copy link
Member Author

reinkrul commented Jul 2, 2025

Superseded by #3811

@reinkrul reinkrul closed this Jul 2, 2025
@reinkrul reinkrul deleted the iss3663-unmarshalcredentialsubject branch July 2, 2025 04:57
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

Successfully merging this pull request may close these issues.

3 participants