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

docs: Document safe use of Twox64Concat #601

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

weichweich
Copy link
Contributor

@weichweich weichweich commented Jan 12, 2024

fixes https://github.com/KILTprotocol/ticket/issues/2529

Metadata Diff to Develop Branch

Peregrine Diff
!!! THE SUBWASM REDUCED DIFFER IS EXPERIMENTAL, DOUBLE CHECK THE RESULTS !!!
No change detected
SUMMARY:
- Compatible.......................: true
- Require transaction_version bump.: false

!!! THE SUBWASM REDUCED DIFFER IS EXPERIMENTAL, DOUBLE CHECK THE RESULTS !!!
Spiritnet Diff
!!! THE SUBWASM REDUCED DIFFER IS EXPERIMENTAL, DOUBLE CHECK THE RESULTS !!!
No change detected
SUMMARY:
- Compatible.......................: true
- Require transaction_version bump.: false

!!! THE SUBWASM REDUCED DIFFER IS EXPERIMENTAL, DOUBLE CHECK THE RESULTS !!!

Checklist:

  • I have verified that the code works
    • No panics! (checked arithmetic ops, no indexing array[3] use get(3), ...)
  • I have verified that the code is easy to understand
    • If not, I have left a well-balanced amount of inline comments
  • I have left the code in a better state
  • I have documented the changes (where applicable)
    • Either PR or Ticket to update the Docs
    • Link the PR/Ticket here

_,
Twox64Concat,
<T as Config>::Namespace,
Blake2_128Concat,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note this change. I think the DepositKey might be chosable by the user

Copy link
Member

Choose a reason for hiding this comment

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

This follows the same reasoning as my other comments (not sure if above or below). The concrete type of a deposit key is defined by the runtime, but it could take user-specified values, so I am all in favor for this change.

@weichweich weichweich marked this pull request as ready for review January 12, 2024 11:49
Copy link
Member

@ntn-x2 ntn-x2 left a comment

Choose a reason for hiding this comment

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

The public credentials pallet also has a pub type Credentials<T> = StorageDoubleMap<_, Twox64Concat, SubjectIdOf<T>, Blake2_128Concat, CredentialIdOf<T>, CredentialEntryOf<T>>; which, more than anything else, allows for a user-chosen SubjectId, which is typically an asset DID which, although it has a specific syntax, can still be crafted by the user.

pallets/pallet-dip-provider/src/lib.rs Show resolved Hide resolved
pallets/pallet-dip-consumer/src/lib.rs Show resolved Hide resolved
pallets/pallet-dip-consumer/src/lib.rs Show resolved Hide resolved
_,
Twox64Concat,
<T as Config>::Namespace,
Blake2_128Concat,
Copy link
Member

Choose a reason for hiding this comment

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

This follows the same reasoning as my other comments (not sure if above or below). The concrete type of a deposit key is defined by the runtime, but it could take user-specified values, so I am all in favor for this change.

// SAFETY of Twox64Concat:
// The DID Identifier must be registered on chain first. To register a DID
// Identifier, you must provide a valid signature for the identifier or
// control the origin that corresponds to the identifier.
Copy link
Member

Choose a reason for hiding this comment

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

How does this play out with cross-chain origins? I know probably migration would be hard here, but it might still be worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The DID that creates the endpoint still needs to be a valid accountId. If you would be able to choose an arbitrary accountId you could impersonate other accounts. So I don't think that this will ever be possible.

Copy link
Member

Choose a reason for hiding this comment

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

No, but the resulting account ID is given by our location converter. There might be a way for a chain to craft origins which are then converted into something else on our chain. That would be the same as crafting origins on our chain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Creating specific AccountIds on our chain should never be possible? Even if the origin is coming from another chain.

Copy link
Member

Choose a reason for hiding this comment

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

Not saying that. But to have an account on our chain you must have a valid private key to generate the signature. On a different chain, "trying" with different accounts might be cheaper, e.g., if, by absurd, you simply create a chain to spam all possible account IDs. This is probably very theoretical, but still possible. All those origins would be converted into some sort of account ID on our chain, but we don't really know what's the "proof of ownership" for that account ID on the source chain. Maybe this is somehow prevented by having XCM fees in place, which is also a mitigation in our case.

@weichweich
Copy link
Contributor Author

  • check Metadata and SDK compatibility before merging

@ntn-x2
Copy link
Member

ntn-x2 commented Mar 6, 2024

This will break cross-chain DIP proofs since the storage keys (and the related proofs) have changed, hence we might want to change at least the DIP stuff to make it resistant.

ntn-x2 added a commit that referenced this pull request Mar 28, 2024
Changing the storage hasher before we deploy on production, otherwise we
would then need a migration strategy. I think
we can disregard any migrations on our testnets, as the effort is not
justified.

I also lowered the limits of the DIP provider template, which were
higher than Peregrine, so that it is faster to generate the benchmark
worst case.

Related to #601, based on
top of #612.
@ntn-x2
Copy link
Member

ntn-x2 commented May 20, 2024

DIP stuff was fixed in #613.

@ntn-x2
Copy link
Member

ntn-x2 commented May 22, 2024

I'm putting this on hold until we get to a polkadot-sdk version that supports multi-block-migrations, after which we can revise this PR and perform the necessary migrations.

@ntn-x2 ntn-x2 added the ✋on hold status: on hold label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✋on hold status: on hold
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants