-
Notifications
You must be signed in to change notification settings - Fork 329
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
CIP-0030 | Encourage namespaced extension endpoints #577
CIP-0030 | Encourage namespaced extension endpoints #577
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On general principles (I'm not a dApp developer) I can see how the namespacing would be helpful. According to my understanding of these methods we wouldn't have a backward compatibility problem.
@refi93 @stevenj to fill out the reviews here, could you please summarise why you thought this was important & link to the relevant CIP-30 comments in any other GitHub PR threads where this was discussed? 🙏
@rphair This was discussed in a meeting, so there are no notes. The cleanest way forward seemed to be to namespace the extension so that there could never be a collision, and the wallet could easily just provide the namespace APIs which are enabled, and not provide them if they are not. And if they are 90% identical internally, that's up to the wallet to sort out, which it can easily do. For a dApp author, it also makes it clear that they are trying to get the enabled functionality, and it's no harder to call The CIP-62 draft defines a kind of namespacing as well, but it will be bought into line with this proposal if accepted. |
CIP-0030/README.md
Outdated
@@ -368,6 +374,10 @@ Extensions can be seen as a smart versioning scheme. Except that, instead of bei | |||
2. Not everyone agrees and has desired to support every existing standard; | |||
3. There's a need from an API consumer standpoint to clearly identify what features are supported by providers. | |||
|
|||
#### Namespacing Extension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, it is unclear how a DApp will use these namespaced methods.
Let's take signTx usage as an example:
- DApp enables cip-95 and cip-1234.
- Builds a transaction with Conway fields (e.g. registers a DRep certificate) + cip-1234-specific-stuff
Which signTx will the DApp use?
- cip95.signTx(tx, partialSign=true) + cip1234.signTx(tx, partialSign=true)
- Split it into 2 transactions and sign them separately?
- Will all namespaced signTx extend the cip30 base sign?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good question! and I think the answer would depend on how CIP-1234 defines it's signTx
.
For me, I think it is best that extensions completely replace other extensions capabilities rather than dApps needing two extensions to do the same thing; such as signing transactions. So my preferred approach would be for CIP-1234 to be supporting all of the CIP-95 capabilities and it's own at once. This would prevent the need for dApps to support two extensions for the same purpose.
I also don't see this as a massive issue, as I don't see there being a massive emergence of conflicting extensions.
With that said, CIP-30 as it stands today would does allow for such awkward overlaps of capabilities between extensions and it is up to wallets to reconcile their capabilities, at enable time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
I like the idea of name-spacing generally speaking; in that particular case, however, I think the possible clash is a desired feature of the whole extension scheme as it allows to issue new extensions to fix / patch / upgrade a previously published extension. In a way, there's nothing preventing extensions to already use a namespace and perhaps we should encourage it: "new extensions MAY be under a specific namespace" but that "MUSTN'T", so we leave the door open to upgradable extensions. However, if namespaced then they should abide by a specific format (i.e. as proposed here cipXXXX) |
I agree generally. However, I see four possibilities:
An example of 1: An example of 2: An example of 3: In the case of 4, I think there should be a well-documented chain in the CIPs. Like a note added to the original CIP that says, this behavior of I would rather the default posture be "Namespace" unless it can be shown that the change proposed is backward and forwards compatible with existing behavior. And this should be on the proposer to justify. The new CIP should also be clear about it and discuss forward/backward compatibility reasoning. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would there ever be a case where the a CIP-tagged namespace extension needed to be distinct by version number? Or would that just tack on as a different endpointX()
undefined in the previous version?
If this specification implies that only the .cipNNN
namespace is defined, and implementors are free to add other name subspaces after it, what would be the naming convention (e.g. endpoints like cipNNN.v?.endpointX()
)?
Whatever the preferred approach to the impact of CIP updates on the API, could this part of the document describe some recommendations about how to handle methods that are introduced or changed in newer versions?
If this was already covered in the meeting discussion, it went right over my head. As @Ryun1 you know I don't work with this material directly & just following on a question that came up in Discord here.
I would be against this as it mixes two types of versioning at once, which I believe would be introduce unneeded complexity. Id much prefer to keep using the CIP extensions as a novel versioning scheme as outlined in CIP-30. |
Replaces previous PR cardano-foundation#443 by adopting CIP-30 extension framework as well as to-be-merged CIP-30 namespace PR cardano-foundation#577.
A [CIP-30 extension](https://cips.cardano.org/cips/cip30/#cardanowalletnameenableextensionsextensionpromiseapi) that allows for a DApp (if allowed) to fetch the connected account public key. Utilizes yet to-be-merged CIP-30 namespace PR cardano-foundation#577.
One thing I noticed while adding the two new PRs for tx bulk signing and account pub is that you want to do reference implementations before CIP becomes active a gets a CIP number assigned. How are you supposed to namespace extensions before a number is assigned? If you use a temporary namespace all reference implementations would then once a number is assigned have to update endpoints for this. I guess this is not unique to this namespace change but affect also already merged Extension feature. Haven't actually checked if there is a method described there for how to handle this. |
As discussed in CIP Editors' Call 72, I have removed the overly prescriptive draft extension procedure. My motivation for this;
Does this match what was discussed in the meeting? @Crypto2099 @rphair cc: @Scitz0 |
@Ryun1 👍 I do think the retraction gives us a lower common denominator that will improve use of the API without being too restrictive in the pathological cases we talked about this week. |
Agree with change, no need to overcomplicate draft implementations. Experimental namespace is enough 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an actual use case for namespacing right now, or is this about future-proofing?
I do not understand the motivation:
This prevents extensions from creating conflicting endpoints with the same naming.
It does not seem to prevent it, as namespacing is optional. Also, why would we allow conflicting endpoints in the first place? If an endpoint does a different thing, then it can have a different name. We do not want to end up with 5 slightly different signTx
methods and have to read through all the CIPs to figure out which one to use, also having to do fallbacks when some of them are unavailable - that's awful developer experience.
This should help simplify wallet implementations, by allowing easier routing of requests.
Might save a dozen lines of code for a wallet (probably only if namespacing was mandatory too) - don't see this as an issue.
This should simplify extension management for dApps.
Why/how? 🤔
Regarding the scenarios listed by @stevenj:
- The change does not change the Method signature, AND the functionality causes no harm if always enabled.
As @stevenj wrote, there's no harm for wallet to support more than is being used. The dApp can also check whether new tx type is supported just by checking supportedExtensions
. I don't think namespacing solves anything in this scenario.
- The change does not change the Method signature, BUT the functionality is incompatible with the previous behavior.
signData is changed to add a rule that payload must be "BSON"
We can avoid the conflict simply via extension adding a new endpoint named signBSON
rather than making a breaking change in the existing one. Or add an optional argument signData(addr, payload, { encoding: 'bson' })
, keeping original behavior intact.
- The method is NEW or changes the signature for an existing method.
signData is changed to add a third optional parameter schema which is a JSON schema of the data being passed in payload so it can be better displayed to the User. This should be namespaced because it's not backward compatible
I do not consider this a breaking change, because it's JavaScript. Yes, technically it can be breaking in some cases, but most of the time it wouldn't be and imho the risk here is tolerable to allow such changes to the API.
"I want the schema to also be CDDL" and makes another CIP to enable that, and you end up in # 2 where what the wallet needs to do with all the possible permutations is ambiguous, and not easy to define in a backward or forwards compatible way.
Well, the schema
argument should've been added as { schema }
, so # 2 can simply add { cddl }
. It's up to the community and CIP editors to refine the designs before they are finalized. If we mess up and it's not possible to make a non-breaking change, then # 2 would add a new signCBOR
endpoint.
- it is a literal patch extension to a previous CIP.
Don't quite understand the problem here, but I suspect a similar append/extend-only solution would work too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that this namespacing solution offers good future-proofing against a scenario where we have many extensions to this web wallet bridge. From both an implementer and developer perspective I would prefer namespace scoping to prevent global scope bloat leading to chaotic documentation and type hinting.
As written I see no hard barriers to following this standard as written and instead view the objections as more of a personal coding style preference versus any breaking objections. IMO it is easier to introduce namespace scoping now rather than attempting to retcon namespacing in the future when the namespace becomes intolerable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirming #577 (review) as representing editor consensus in today's CIP meeting in the course of reviewing all discussion so far.
…on#577) * stipulate namespaced extensions * chose better number example * Added removing leading zeros * made namspacing partially optional * added that authors have to justify * address draft extensions * remove over perscriptive draft extension protocol * small stipulation added
* CIP-???? | CIP-30 ext: Account public key A [CIP-30 extension](https://cips.cardano.org/cips/cip30/#cardanowalletnameenableextensionsextensionpromiseapi) that allows for a DApp (if allowed) to fetch the connected account public key. Utilizes yet to-be-merged CIP-30 namespace PR #577. * Update CIP-XXXX/README.md Co-authored-by: Ryan Williams <[email protected]> * standard form for copyright footer Co-authored-by: Ryan Williams <[email protected]> * Update according to #590 * Update CIP-XXXX/README.md Co-authored-by: Ryan Williams <[email protected]> * change delimiter character as per #594 * title delimiter changed to - as per #594 update * assign CIP number 104 * Updates according to assigned CIP number * updates according #601 * Move access line to spec section --------- Co-authored-by: Robert Phair <[email protected]> Co-authored-by: Ryan Williams <[email protected]>
* CIP-???? | CIP-30 ext: Bulk transaction signing Replaces previous PR #443 by adopting CIP-30 extension framework as well as to-be-merged CIP-30 namespace PR #577. * update api call to use cip namespace * add checkboxes for items we're not sure are done yet * word accuracy + grammar * Mark criteria as completed * include *all* prior GitHub discussion (2 PRs) Co-authored-by: Ryan Williams <[email protected]> * Update according to #590 * Update CIP-XXXX/README.md Co-authored-by: Ryan Williams <[email protected]> * Update CIP-XXXX/README.md Co-authored-by: Ryan Williams <[email protected]> * Update CIP-XXXX/README.md Co-authored-by: Ryan Williams <[email protected]> * Update CIP-XXXX/README.md Co-authored-by: Ryan Williams <[email protected]> * Update CIP-XXXX/README.md Co-authored-by: Ryan Williams <[email protected]> * Update CIP-XXXX/README.md Co-authored-by: Ryan Williams <[email protected]> * Update CIP-XXXX/README.md Co-authored-by: Ryan Williams <[email protected]> * Update CIP-XXXX/README.md Co-authored-by: Ryan Williams <[email protected]> * Addresses mentioned comments * change delimiter character as per #594 * title delimiter changed to - as per #594 update * assign CIP number 103 * Updates according to assigned CIP number * Updates according to #601 * Update CIP-0103/README.md Co-authored-by: Ryan <[email protected]> * Update CIP-0103/README.md Co-authored-by: Ryan <[email protected]> * Update CIP-0103/README.md Co-authored-by: Ryan <[email protected]> --------- Co-authored-by: Robert Phair <[email protected]> Co-authored-by: Ryan Williams <[email protected]>
Change
example:
api.cip95.getPubDRepKey()
Motivation
I believe this is a sensible change to make ahead of the emergence of CIP-30 extensions, such as #509.
Thanks @stevenj and @refi93 for the suggestion.