-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
EIP-3085 Discussion: wallet_addEthereumChain #3086
Comments
Great to see some EIP materializing to help apps make it easy for user to use other chains that what wallet provider offer by default. I got few comments: A general one: in my opinion we should avoid as much as possible the use of Regarding Regarding Regarding
As mentioned as general comment, we should not use MAY or SHOULD Also regarding what happen in the following scenario
what about chain 1 (that is expected to be supported by most wallet)? Some more consideration: Could the standard not add a way for the app to check if the wallet already support a chain ? Regarding security, I don't think this standard by being just a "request to add" is avoiding the security consideration mentioned in EIP-2015 (see https://ethereum-magicians.org/t/eip-2015-wallet-update-chain-json-rpc-method-wallet-updatechain/3274/13) There are dangerous scenario waiting to happen for wallet that accept the addition of chain. Letting the app decide the currency and name, etc... is not a good idea. As such I think the proposal should focus solely on the ability for an app to ask the wallet to use a specific rpc url for a specific chain Id. All other data should be handled by the wallet itself. If the wallet do not know a chainId, it MUST reject. Else it might display false information to the user without knowing This brings me to EIP-2015, as the latter seems a better solution in general, as if the only purpose of 2016 is to associate a rpc url to a chainId. EIP-2015 could do that while switching the user to that new chain in the same action. EIP-2016 also brings a potential concern for application that might not wish to make it easy for other apps to user their endpoint. |
Thanks for your feedback @wighawag, I always appreciate it! I'm going to try to respond to each point in turn. Note that the EIP will be numbered 3085 instead of 2016, after feedback from editors. First, regarding MAY and SHOULD, they have a purpose wherever I use them, although I try to minimize the use of MAY especially. Nevertheless, whether we should use them at all is a topic that I don't want to get into here, unless there's more widespread feedback concerning my style of specification writing. Second, regarding the ambiguity about how the wallet should process the request, that is a deliberate choice. Wallets (and dapps) need standardized formats for different requests. Dapps need to know whether a request succeeded or failed, and if the latter, why. The specification establishes these things (we'll get to errors shortly). As stated in the security considerations, and as you yourself point out, Third, regarding errors and error codes, the specification states that the wallet must return an error if the request fails. Since the wallet can reject requests for arbitrary reasons, the specification can't make any definitive statement about what the errors are. Error standards are specified elsewhere, most prominently EIP-1474 and 1193/2696. Implementers can find suitable error codes there. Fourth, regarding the following:
I know how MetaMask is likely to handle those cases (we won't allow chain ID Fifth, regarding:
I believe that method should exist, but as part of a different standard. There is a clear and long-standing need for a standardized way of asking a provider "what can you do?", but that EIP has yet to be written. Sixth, regarding the security of accepting externally added metadata, I absolutely agree. That's why the security considerations recommend against letting dapps specify any chain metadata other than the That said, adding an unknown chain with externally submitted metadata can be acceptable if the user is informed of the risks. In any event, we can't prevent wallets from allowing it if they want to. Seventh, and finally, regarding this:
Perhaps, but that's a concern for the proprietors of those endpoints. |
Thanks @rekmarks for your reply. here are further comments : Regarding point 2, 4 and 7, there is an issue in that the current EIP allows an app to request adding a broken endpoint, that user might require manual operation to remove Indeed, what if an app request to add endpoint for a specific chain The issue could be alleviated if the addition of a chain was sandboxed to the origin requesting it. This seems to be a good solution. What do you think? Note though that even if the rpc url was sandboxed, the app might want to update it to a new url (they might have changed their domain name for example) I see several options a) reuse b) separate the addition of a chain from the updating of its rpc url. Both options would make the EIP more explicit and avoid potential differences between wallets, making the life of applications much easier This is in my opinion an important point and as currently defined, the EIP ambiguity will likely cause trouble to app developers Regarding point 5, I was not asking for a rpc method to check if the wallet can switch chain, but an rpc that check whether a chain is already added. I think having it as part of the standard is better than having to wait for yet another. If we really want them separate, then I would argue that they should come together with EIP-3085 being dependent on the other one. Such method will be a necessary rpc method for apps to offer a proper user experience. Regarding point 6, I strongly believe that having a standard allowing unsafe metadata to be displayed is a really bad idea. Especially when such data is shared across apps. A user might visit an app, accept the request thinking lightly of the consequence because the user did not intend to interact with it. then forgot about it and visit another app not realising it is being displayed wrong information. From a security standpoint, no wallet should allow an app to make the user believe false information when it can technically prevent it. Allowing it as part of a standard run the risk of creating a race to the bottom where unsafe wallet will be used because they offer a convenience to app/users. Also note that as you said, nothing prevent such wallet to have their own api to allow for that if they really want to. But as for standard goes we should not make it easy. Since Metamask already believe that they won't be allowing such ability, I do not see the argument for why metadata should be allowed to be specified by the app. Not allowing it will also simplify the EIP which is an extra benefit. This could be as follow : interface AddEthereumChainParameter {
chainId: string;
rpcUrl: string;
} Note that now the rpcUrl is mandatory as adding a chainId without any info would be pointless. This is also mean that we can now remove some of the MAY and SHOULD We could also define the different errors:
Regarding CHAIN_ALREADY_EXISTS, as mentioned this only make sense for option b) mentioned above for option a) there would be no such error for Regarding error (point 3) it is I think beneficial to define the potential type of error in the EIP as it helps define the protocol more acurately. |
As per recommendation (thank you @MicahZoltu) Ive copied my request from the PR: Any chance you could add an OpenRPC definition of the method? I need json schemas for this to add it. for example,
This will allow me to easily add this method to http://ethereum-json-rpc-specification.org/ and downstream tooling. Thanks. |
Hi @rekmarks, @pedrouid I stumbled over this EIP and would like to suggest some additions to this RPC method proposal. It is becoming more and more common that wallets can subscribe via websocket to events in order to reduce the polling towards RPC nodes. Therefore, it would be good to see something like Another typical problem is the network specific icon and considering that this method is used for wallets needing to display also an icon for the network, it would make sense to add an option like During the Minerva mobile wallet development, we encountered problems with RPC nodes and therefore I wanted to ask if that specification allows to add more than one Thanks and happy new year. |
Maybe there is some synergy with #3012 that I proposed. If there where RPC methods for chainName, nativeCurrency, blockExplorerUrl, etc. and not only chainId then one would only need to pass the RPC url here. Consider this a sidenote. |
@BelfordZ, have you guys ever created a meta EIP for specifying RPC methods using OpenRPC? I'm not opposed to it by any means, but I don't want to add OpenRPC definitions to EIPs willy-nilly. Meanwhile, I created this, where I'm about to ping you on an issue with some questions: https://github.com/rekmarks/ts-to-open-rpc @tze42, I like your suggestion of supporting WebSockets, and multiple RPC URLs. We could kill two birds with stone by replacing the There's then a question of what we do with the other URL fields, and cc: @pedrouid @PeterTheOne, I think what you're suggesting in #3012 makes a lot of sense, and the suggested methods could definitely be beneficial to implementers of 3085. There are some security concerns with getting chain data from endpoints, as elaborated on in 3085. |
Previously I've leaned more towards JSON schemas and OpenRPC but currently I think that we could save more time by writing proto files instead. Mostly motivated by how lacking typing is for JSON schema and how verbose it is. That being said @rekmarks's library looks great I like the suggestion for making all url fields to have string arrays. We can even simplify keys to |
@rekmarks, I'm not a dev, but the suggestion of
For the |
Here's the updated params interface, merged via #3190: interface AddEthereumChainParameter {
chainId: string;
blockExplorerUrls?: string[];
chainName?: string;
iconUrl?: string;
nativeCurrency?: {
name: string;
symbol: string;
decimals: number;
};
rpcUrls?: string[];
} |
I decided to keep |
I agree regarding |
Actually I would disagree with the |
That is a very good point and we would definitely prefer to get a SVG over PNG or JPG, if it is available. |
Yeah, I agree that we should do For any dapp developers reading this, MetaMask won't do anything with this property in our first iteration of this feature, and once we do use it, we will pick the first SVG that we find and ignore anything else. |
Hey all, @rekmarks, any feedback on my comments? I would love to finally have applications be able to use different chains without requiring user to manually enter information, but this should not come at the cost of decreased security. |
Hey @wighawag, I see it from a wallet perspective and the Minerva wallet we work on, uses all supported chains simultaneously. Adding a new chain via the proposed interface is a big improvement, as it avoids us to integrate it natively and allows a higher convenience for the user. So UX is actually very much improved. Also we could use that interface to get updated information, avoiding manual code intervention. |
@tze42 thanks for your feedback, some comments:
I understand, I am not against the benefits. I have been asking for this feature for a while myself as an app developer. I am against its current form. In my comment above, I mention security but I also mention the following issues:
The security issue I mention are about the metadata. With the current design, that allows application to provide the metadata, it allows application to mislead users into thinking they are on a testnet for example, not realizing they are operating on an actual mainnet they interacted before and where their tokens are at risk. I strongly believe that wallets' main role is to protect users and this include ensuring the validity of the information displayed to them. This proposal fails in this regard. In one earlier reply, @rekmarks mentioned that Metamask will actually ensure the metadata provided is valid but as I mentioned, some wallet (like your it seems) might not do the check for "user convenience". An EIP should prevent such wallet to do that to ensure user safety. The EIP actually mention the following :
To me it should be a MUST and removing the ability to specify metadata make it so while at the same time simplifying the proposal. If adding extra network to your wallet code is a difficult operation, you can always implement that through an external service, like metamask is planning to do. This would already be better than letting malicious app doing it for you. |
@wighawag, I apologize for my tardy response. I think you make some excellent points, some that I believe disagree with for technical / UX reasons, and others that I disagree with on principle. The disagreements are not insubstantial, and I've been putting off my response, but here goes. I will try to summarize your points and respond to them in turn. I will preface this by noting that:
Whether EIP-3085 Switches the Currently Selected Network
This is not true. Rather, EIP-3085 is agnostic on the matter. The specification mentions this:
In MetaMask's implementation, the network is switched when the user adds the network. I'm open to recommending (i.e., using SHOULD) that the wallet switches to a network when it is added. I don't think that it ought to be required, since a wallet implementer may not want to for various reasons. Edit: More than anything, I feel like the spec can remain agnostic on the matter, and people will do what makes the most sense, which is probably switching the network. Regarding Necessary Parameters
I believe that, regardless of any proposed implementations, the Regarding the Addition of a "
|
To summarize action items from my above post synthesized from @wighawag's feedback, I think we should:
I'm happy to take on those two. In addition, if someone feels so inclined, they should create a new EIP (or just discussion for now) for As an aside I want to note that, in an ideal world, wallets get rid of the notion of a "currently selected chain", parameterize the chain ID for incoming requests, and thereby solve all issues related to "switching the network". |
I added a PR for the previously discussed error: #3237 While adding this to the specification, I also changed the specification such that the method must return this error if a wallet receives a request to add a chain that was already added. This way, the method call is only regarded as a success if the call itself caused the chain to be added to the wallet. That means there's less room for ambiguity, which should be good for dapp developers. Since it is a change in behavior, comments are appreciated. |
Thanks @rekmarks for your reply. It gave me a better understanding of the current proposal's perspective that I did not fully consider. I still have some remark to make: Whether EIP-3085 Switches the Currently Selected Network
I indeed read that the spec mention that switching is possible, but as an app developer if this is not a guarantee, this is not the same as EIP-2015, hence my comment. I am still happy with EIP-3085 approach though, and as you mentioned in your last comment, if we can move to a non-switching chain system where the chainId is specified as part of other rpc call, then EIP-3085 will be indeed all we need. I hope we get there soon :) Regarding the Addition of a "wallet_hasEthereumChain" RPC Method
I strongly disagree on this. I see an EIP as a set of rules for a single purpose with consideration for everything that this purpose entails, including UX consideration. Let's not constrain ourselves to an adhoc rule of "1 rpc method = 1 EIP". While in some case it might be a good rule, I see it as a heuristic not as a hard rule. I worry that separating these 2 rpc call will result in wallet implementing one and not the other. It will actually de-facto allow them to do that and this would be bad for application's user experience. If you too agree that this will lead to a better UX, why not make "wallet_hasEthereumChain" EIP a dependency to "wallet_addEthereumChain" or simply add it to the proposal. I think it is important to consider the UX consequences when writing EIP like this one and saying we can have improvements later, while we could already foresee the issues, is to me a bad idea. So unless there is strong reason to not bake-in this improvement, it should in my opinion, be part of the proposal. Regarding Associating RPC URLs with Origins + Regarding Failing Endpoints
If you agree with the issue of "failing endpoints" and the idea of associating rpc url to origins to solve it, why not make it part of the EIP ? As alluded above, saying it is an Regarding Malicious BehaviorI understand better the perspective but still consider it a potential security issue. The analogy to web browser is I think not accurate. The analogy to ERC20 sounds accurate but the security risk is present there too and I would have made the same comment if I had the opportunity :) It might be true though that letting wallet decide how to handle the addition of metadata might well be the best we can do to ensure we do not segregate valid chain / ERC20 tokens . Your experience seems to indicate it and I do not have any evidence of a better mechanism working. Further commentsIt is not clear to me what should / must happen when adding a chain whose chainId already exist. You now mention the idea of using "CHAIN_ALREADY_EXISTS " which was suggested as part of mechanism b) ( see comment: #3086 (comment)) where a new rpc method was proposed to allow the updating of rpc url. Is that something considered too ? something like |
I just realised from this comment that you might not fully grasp the issue about the lack of "wallet_hasEthereumChain" and its consequences for the applications and their users. The error "CHAIN_ALREADY_EXISTS " you mentioned would not solve it as this error happen only if you call And like it is today best practise to not request access to the wallet without having the user make an interaction first, you would not want to trigger a popup for chain addition without first notifying the user of the need for it. To show the issue here are the step that would happen for an application that cannot rely on the existence of the "wallet_hasEthereumChain" method:
The alternative as mentioned above would be to always call "wallet_addEthereumChain" but this would result in throwing a wallet popup in the user face when the chain was never added, a bad user experience if "wallet_addEthereumChain" implementation was a requirement to EIP-3085, then step 3, would not need to be considered and we could directly continue with the application flow after checking the chain was already added. This would enable a more natural flow for the user. hence why I strongly believe "wallet_hasEthereumChain" should be part of EIP-3085 or a dependency of it |
@wighawag thanks for continuing to contribute to this discussion! I am thanks to your arguments convinced that we need My inclination is still to put Regarding sandboxing a chainId / RPC URL combo to a specific origin, the EIP is explicitly agnostic about what it means to "add" a chain to a wallet in order to avoid making assumptions about wallet implementation details, which are likely to change in fundamental ways over the course of time. I think recommending it in the security considerations section is good enough, and also all that this specification can feasibly do. |
Hey @rekmarks glad to be contributing to this must needed EIP :) Regarding the separation of the 2 RPC in 2 different EIPs. I do not really mind, except that the relation should be a MUST and not a SHOULD for the reason I mentioned. Otherwise applications will have to consider the case where wallets do not implement As such if there are 2 EIPs, then EIP-2085 will need to depend on the This is a separate topic but the issue about failing rpc, might require the need for yet another rpc call: In some ways, this EIP (EIP-3085) is about a resource and not about a specific rpc call. as such having the usual CRUD methods form a logical whole (I don't think we need the DELETE operation though). That is why I personally prefers all of these method to be part of the same EIP. |
I agree with @wighawag that |
Thanks @MicahZoltu for sharing your opinion.
What are the reasons exactly? Is that solely the following or are there other reasons ?
If so, this does not sounds strong arguments by themselves to me. And while I do not really mind how EIP are structured, I want to make sure that a To me having the (potentially 3) rpc method in one EIP is the most logical. It is also the most simple. As soon as there are cyclic dependency between them, which is definitely the case if we add The argument that having them in the same EIP would make it longer to have them finalized is probably only true for rpc calls that are truly independent. This is not the case here. |
If it ends up being the case that there is no use in implementing any of the 3 EIPs standalone, then having a single EIP starts to make sense. However, I believe we can falsify this statement with To me, this is enough to extract out that EIP, which leaves I believe that it would not be unreasonable for a wallet to implement TL;DR: I think separate EIPs are a good idea here because there are imaginable situations where a wallet will implement a subset of all of the endpoints. |
thanks @MicahZoltu As for Wallets that want to keep the association for only a session lifetime, they can simply reject the call to Now we could argue that we could have
(arrow meaning "depends on") |
If we just define this rejection to be a JSON-RPC error for |
That's what I want to avoid (I want to make sure both are implemented), as this otherwise lead to issue for applications when dealing with wallet that chose to not implement It is easier to enforce implementation even for wallet that keep chain info only for a session, than letting any wallet to not implement it. Now it is true we cannot avoid implementation to reject a call for whatever reason, so the issue mentioned is not entirely avoidable, but at least the wallet would have an error for the application to display. And rejecting for a "not found" reason would simply be a the detriment of the wallet. Hence why the EIP should not mention it as a possibility. The EIP should make It is also worth noting that at the point an application will call |
I 💯 agree with this. The JSON-RPC is in dire need of a capabilities discovery/negotiation mechanism. e.g., a way to ask |
At the request of the Catherders, I'm moving discussion for this EIP here: https://ethereum-magicians.org/t/eip-3085-wallet-addethereumchain/5469 |
Discussion for EIP-3085:
wallet_addEthereumChain
The EIP was briefly known as EIP-2016.
Initial PR: #3085
The text was updated successfully, but these errors were encountered: