-
Notifications
You must be signed in to change notification settings - Fork 114
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
Vyper Interfaces Verification #334
Comments
Or, more basically, the contract on zksync era mainnet at address: # pragma version 0.4.0
"""
@license MIT
@title snek_token
@author You!
@notice This is my ERC20 token!
"""
# ------------------------------------------------------------------
# IMPORTS
# ------------------------------------------------------------------
from ethereum.ercs import IERC20
implements: IERC20
from ethereum.ercs import IERC20Detailed
implements: IERC20Detailed
from snekmate.auth import ownable as ow
# from pcaversaccio.snekmate.src.snekmate.auth import ownable as ow
initializes: ow
from snekmate.tokens import erc20
initializes: erc20[ownable := ow]
exports: erc20.__interface__
# ------------------------------------------------------------------
# STATE VARIABLES
# ------------------------------------------------------------------
# Constants & Immutables
NAME: constant(String[25]) = "snek_token"
SYMBOL: constant(String[5]) = "SNEK"
DECIMALS: constant(uint8) = 18
EIP712_VERSOIN: constant(String[20]) = "1"
# Storage - none!
# ------------------------------------------------------------------
# FUNCTIONS
# ------------------------------------------------------------------
@deploy
def __init__(initial_supply: uint256):
ow.__init__()
erc20.__init__(NAME, SYMBOL, DECIMALS, NAME, EIP712_VERSOIN)
erc20._mint(msg.sender, initial_supply) This needs the |
Hey @PatrickAlphaC It feels like not all the files are being included into the compilation request. Could you please check what network request is being sent to the explorer? Does it include all the dependencies? |
@popzxc I think the issue is that the Let me see if it makes sense to fix on the user's end... |
@PatrickAlphaC hey, did you manage to fix this on the user's side? |
@dimazhornyk no. Here is where we are. The (truncated) body of a request (for example, for this address live on ZKsync: {
"contractAddress": "0x36266F07E40aeaFD5FBeaB736f85d2f1F1B4Bb06",
"sourceCode": {
"lib/pypi/snekmate/tokens/interfaces/IERC721Metadata.vyi": "# pragma version ~=0.4.0\n\"\"\"...",
"lib/pypi/snekmate/tokens/interfaces/IERC721Enumerable.vyi": "# pragma version ~=0.4.0\n\"\"\"...",
"lib/pypi/snekmate/tokens/interfaces/IERC721Permit.vyi": "# pragma version ~=0.4.0\n\"\"\"...",
"lib/pypi/snekmate/tokens/interfaces/IERC4906.vyi": "# pragma version ~=0.4.0\n\"\"\"...",
"lib/pypi/snekmate/utils/interfaces/IERC5267.vyi": "# pragma version ~=0.4.0\n\"\"\"...",
"lib/pypi/snekmate/tokens/interfaces/IERC721Receiver.vyi": "# pragma version ~=0.4.0\n\"\"\"...",
"lib/pypi/snekmate/auth/ownable.vy": "# pragma version ~=0.4.0\n\"\"\"...",
"lib/pypi/snekmate/utils/ecdsa.vy": "# pragma version ~=0.4.0\n\"\"\"...",
"lib/pypi/snekmate/utils/message_hash_utils.vy": "# pragma version ~=0.4.0\n\"\"\"...",
"lib/pypi/snekmate/utils/eip712_domain_separator.vy": "# pragma version ~=0.4.0\n\"\"\"...",
"lib/pypi/snekmate/tokens/erc721.vy": "# pragma version ~=0.4.0\n\"\"\"...",
"birthday_coffee": "# pragma version 0.4.0\n\"\"\"...\""
},
"codeFormat": "vyper-multi-file",
"contractName": "birthday_coffee",
"compilerVyperVersion": "0.4.0",
"compilerZkvyperVersion": "v1.5.7",
"constructorArguments": "0x",
"optimizationUsed": true
} However, Vyper uses the Python Path to identify contracts. So instead of: from lib.pypi.snekmate.tokens.interfaces import IERC721Metadata We can just do: from snekmate.tokens.interfaces import IERC721Metadata Here are the options we can do to fix this:
I think 1 is probably (sadly) the correct answer... So we'll have to do some work to do this automatically for users... |
Because otherwise you'll get:
|
i think the issue here is that the search path (see |
@charles-cooper right now this setting is not passed, the list of files is just passed in the "sources" field (see the code). I see a few ways around it:
WDYT? |
i'm not sure how the verifier is calling vyper, but if it's passing standard json, then everything should "just work" so long as search_paths is correctly added to the standard json bundle |
Btw, the search paths do not need to be absolute. |
I will try to implement the first proposal next week and let's see if it works. |
I think it will work for a specific case, but the proper thing to do is to allow the settings to be properly set in the input bundle. |
OK, I investigated it further, and looks like unfortunately this issue is not actionable right now 😓 There are some experiments with standard JSON going on there, but it's hard to say when it will reach production support. |
search paths can be set on the command line for cc @hedgar2017 |
Thanks @charles-cooper. @popzxc, but full migration to standard JSON can only be done starting from the Hardhat plugin. Right now it relies on combined JSON output. The optimal path would be to test the plugin with vyper first. |
I guess if |
I will try now. @charles-cooper is it safe to use with all versions of vyper? |
it is, but it has different semantics for < 0.4.0 (for <0.4.0, it is not as important, because prior to 0.4.0 multi-file contracts are not supported). i would recommend guarding the feature to only apply for >=0.4.0, or more simply just propagate it to the compiler and let the compiler raise an error if the semantics are invalid, as the user would not really be setting search paths prior to 0.4.0. |
@charles-cooper thanks, understood! Could you also drop a quick comment on the status of combined JSON mode? I cannot find enough info on it in the docs. |
it is not being deprecated, it is just the "json output" mode for standard cli so that the output is more structured than just text. |
Hey @PatrickAlphaC @popzxc - could you try this build? |
@hedgar2017 so this will be passed to the explorer server? This fixes verification? I’m a bit confused |
@PatrickAlphaC sorry for the confusion! |
🐛 Bug Report
If a smart contract in vyper uses an interface, the ZKsync explorer will throw an error.
However,
zkvyper
compiles successfully. This is because the explorer verification process is not correctly understanding the python paths.🔄 Reproduction Steps
Easiest way is to download uv, then download mox
Make sure you have zkvyper and era_test_node also installed
First, install snekmate with:
Then create a file called
snek_token.vy
and add:Add the following to your
moccasin.toml
Where
ZKSYNC_RPC_URL
is your zksync mainnet RPC URL.verify.py
in yourscript
folder with this code:You'll get the error. This is an error on the explorer's side. This contract should be able to be installed.
The text was updated successfully, but these errors were encountered: