-
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
Consider appending data to a contract's bytecode which decribes which abi
s the contract implements.
#3234
Comments
We could also just expose an implicit ABI method (that can be toggled on with an annotation) a la fn supports_interface(interface_commitment: u32) -> bool |
I like that approach. |
I've been thinking more about this in the context of both: A few points to consider:
ImplementationOne way we could support interface detection/ discoverability is as follows:
Caching is optional, but maybe still beneficial; erc-165 backwards compatibility is not needed. |
This seems unnecessarily complicated compared to
ERC-1820 doesn't provide a cache, it provides a registry. It's also not clear how calling the registry then the contract is cheaper than calling the contract then the contract. The registry is itself a contract. The actual motivation for ERC-1820 is:
|
It may be slightly more complicated, but if we separate the core ideas into:
then for the purpose of this issue, we're only concerned with number 1. (Number 2 is related, but not necessary for 1 to be useful).
The ERC-1820 registry contract is indeed first and foremost a registry. It does however have some features meant to provide backward compatibility with ERC-165, and a couple of these functions are caching-related:
Given that I don't think? we need to provide backward compatibility with ERC-165, we can disregard any of my previous comments related to caching.
The beauty of the proposed change here (appending bytecode to a known location) is that we can discover which |
Oops, closed by mistake yesterday, so I reopened it. |
@adlerjohn Any more thoughts on this given my response to your critique above? |
A call shouldn't be much more expensive than loading code, if contracts are small. If contracts are larger, then an optimizoooor may well split it up into multiple contracts so that only what's necessary is loaded. The benefit of a standard code location is being able to get the supported ABI methods without calling (but you still have to load, which as above isn't in all cases meaningfully cheaper). The downside of a standard code location is that it doesn't work with proxies. |
My thinking here was that when loading code via cc @sezna |
In Solidity it’s faily common to register each interface that a contract implements and provide a getter for this, so that other contracts can query it to see if it can for example receive erc-721 tokens safely. This is done according to https://eips.ethereum.org/EIPS/eip-165 , where “interface detection” is achieved via registering interface signatures in storage manually.
I think we could do better than this. The compiler already knows whether a contract implements an abi or not when compiling; seems like it could append that data somewhere in a common format (like the hash, or the first 4 bytes or whatever).
It was suggested by @adlerjohn @sezna that it could be added to the bytecode:
We would still need to determine the best format to use to represent an abi in a standardized way.
From eip-165 :
The text was updated successfully, but these errors were encountered: