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

The block explorer always says "Fail with error 'mv'" error #10

Closed
lusharenck opened this issue Apr 4, 2023 · 8 comments
Closed

The block explorer always says "Fail with error 'mv'" error #10

lusharenck opened this issue Apr 4, 2023 · 8 comments

Comments

@lusharenck
Copy link

lusharenck commented Apr 4, 2023

use python
0x8a0f0ef395d4633369d74a374fc81e60ead6a06af30a51e3c6b02593e1555946
UZ@{QDE`HQ$U_QA1O6WN K

from web3 import Web3
from eth_account import Account
from web3.middleware import geth_poa_middleware
from eth_account.signers.local import LocalAccount
from source_interaction.zksync2_python_develop.zksync2.module.module_builder import ZkSyncBuilder
from source_interaction.zksync2_python_develop.zksync2.core.types import Token
from source_interaction.zksync2_python_develop.zksync2.provider.eth_provider import EthereumProvider
from source_interaction.zksync2_python_develop.zksync2.core.types import Token, EthBlockParams


URL_TO_ETH_NETWORK = "https://endpoints.omniatech.io/v1/eth/goerli/public"
URL_TO_ETH_NETWORK = "https://goerli.infura.io/v3/"
ZKSYNC_NETWORK_URL = "https://zksync2-testnet.zksync.dev"

PRIVATE_KEY2 = bytes.fromhex("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")


def deposit(amount: float):
    zksync = ZkSyncBuilder.build(ZKSYNC_NETWORK_URL)
    eth_web3 = Web3(Web3.HTTPProvider(URL_TO_ETH_NETWORK))
    eth_web3.middleware_onion.inject(geth_poa_middleware, layer=0)
    account: LocalAccount = Account.from_key(PRIVATE_KEY2)
    eth_provider = EthereumProvider(zksync, eth_web3, account)
    wei_amount = Web3.to_wei(amount, "ether")
    eth_token = Token.create_eth()
    gas_price = int(eth_web3.eth.gas_price * 1.1)
    before_deposit = eth_provider.get_l1_balance(eth_token, EthBlockParams.LATEST)
    eth_provider._zksync_web3.zksync
    print(f"Before: {before_deposit}")
    addres = Web3.to_checksum_address("0x79a5b5916665735fdde66eeacb4e62628416d56c")
    l2_gas_limit = eth_provider._zksync_web3.zksync.eth_estimate_gas({
        "value":"0x38d7ea4c68000", 
        "from": addres,
        "to": addres,
        "data":"0x",
        # "eip712Meta":{"gasPerPubdata":"0x0"}
    }) # int(733664 * 2) # int(eth_provider._zksync_web3.eth.gas_price * 1.1)
    gas_per_pubdata_byte = None # 800
    gas_limit = None # 118722

    l1_tx_receipt = eth_provider.deposit(token=eth_token,
                                         amount=wei_amount,
                                         l2_gas_limit=l2_gas_limit,
                                         gas_limit=gas_limit,
                                         gas_per_pubdata_byte=gas_per_pubdata_byte,
                                         gas_price=gas_price)
    # TODO: when L2 tx

    after = eth_provider.get_l1_balance(eth_token, EthBlockParams.LATEST)
    print(f"After : {after}")

    print(f"Tx status: {l1_tx_receipt['status']}")


if __name__ == '__main__':
    deposit(0.001)

`

use javascript
0x51ee30a9b0936c76051acf07fc0b10099a002bd22105e9f279d2f60c66c55fcf
21H%N}{2J4B~GRWFWX_FTO7

The hashes they generate don't look any different, but using the python module always produces an error

@vyastrebovvareger
Copy link
Collaborator

Please. use this URL "https://rpc.ankr.com/eth_goerli" as the URL_TO_ETH_NETWORK
And please have a try with the following example:
https://github.com/zksync-sdk/zksync2-python/blob/master/examples/01_deposit.py

@vyastrebovvareger
Copy link
Collaborator

I will investigate your issue as soon as possible

@lusharenck
Copy link
Author

请。使用此 URL"https://rpc.ankr.com/eth_goerli"作为 URL_TO_ETH_NETWORK 请尝试以下示例: https: //github.com/zksync-sdk/zksync2-python/blob/master/examples/01_deposit.py

I got the same error after replacing the rpc
0x8a5d3c948e182e8921b8c43fba2d9d1523a5d557b443be7257466f90d74125fd
image

@vyastrebovvareger
Copy link
Collaborator

One thing that come to mi mind that you directly setup l2_gas_limit
and this one

   gas_per_pubdata_byte = None # 800
    gas_limit = None # 118722

I would go step by step. Run test from example. Then if you need to calculate precise l2_gas_limit I investigate it and provide an example

@chuwt
Copy link

chuwt commented Apr 4, 2023

I think the key of this issue is that the value sent on the deposit doesn't add the fee will be used in L2.

here the l1_value should be replaced with value.

value = base_cost + operator_tip + l2_value
check_base_cost(base_cost, value)
call_data = to_bytes(call_data)
tx_receipt = self.main_contract.request_l2_transaction(contract_l2=contract_address,
l2_value=l2_value,
call_data=call_data,
l2_gas_limit=l2_gas_limit,
l2_gas_per_pubdata_byte_limit=gas_per_pubdata_byte,
factory_deps=factory_deps,
refund_recipient=refund_recipient,
gas_price=gas_price,
gas_limit=gas_limit,
l1_value=l1_value)

Also, I think here the gas_limit should be l2_gas_limit

base_cost = self.get_base_cost(gas_price=gas_price,
gas_per_pubdata_byte=gas_per_pubdata_byte,
gas_limit=gas_limit)

Let me know if I'm wrong😄.

@0xth0mas
Copy link
Contributor

0xth0mas commented Apr 4, 2023

Ran into the same issue today with deposits. Started out with error "qp" for the gas per pubdata value not being right (eth provider has this set at 50000). After I overrode that I got the "mv" error and it looks like the SDK is setting the base_cost to 0. Got around that by calculating the base cost with get_base_cost and passing it as the operator tip.

            gas_price = web3.eth.gas_price
            operator_tip = eth_provider.get_base_cost(gas_limit=eth_provider.RECOMMENDED_DEPOSIT_L2_GAS_LIMIT, gas_per_pubdata_byte=800,gas_price=gas_price)
            l1_tx_receipt = eth_provider.deposit(token=Token.create_eth(),
                                    amount=web3.to_wei(str(depositAmount), "ether"),
                                    gas_per_pubdata_byte=800,
                                    operator_tip=operator_tip)

image
image

@lusharenck
Copy link
Author

Ran into the same issue today with deposits. Started out with error "qp" for the gas per pubdata value not being right (eth provider has this set at 50000). After I overrode that I got the "mv" error and it looks like the SDK is setting the base_cost to 0. Got around that by calculating the base cost with get_base_cost and passing it as the operator tip.

            gas_price = web3.eth.gas_price
            operator_tip = eth_provider.get_base_cost(gas_limit=eth_provider.RECOMMENDED_DEPOSIT_L2_GAS_LIMIT, gas_per_pubdata_byte=800,gas_price=gas_price)
            l1_tx_receipt = eth_provider.deposit(token=Token.create_eth(),
                                    amount=web3.to_wei(str(depositAmount), "ether"),
                                    gas_per_pubdata_byte=800,
                                    operator_tip=operator_tip)

image image

this is the right solution

@lusharenck lusharenck reopened this Apr 7, 2023
@lovehhf
Copy link

lovehhf commented Apr 7, 2023

Ran into the same issue today with deposits. Started out with error "qp" for the gas per pubdata value not being right (eth provider has this set at 50000). After I overrode that I got the "mv" error and it looks like the SDK is setting the base_cost to 0. Got around that by calculating the base cost with get_base_cost and passing it as the operator tip.

            gas_price = web3.eth.gas_price
            operator_tip = eth_provider.get_base_cost(gas_limit=eth_provider.RECOMMENDED_DEPOSIT_L2_GAS_LIMIT, gas_per_pubdata_byte=800,gas_price=gas_price)
            l1_tx_receipt = eth_provider.deposit(token=Token.create_eth(),
                                    amount=web3.to_wei(str(depositAmount), "ether"),
                                    gas_per_pubdata_byte=800,
                                    operator_tip=operator_tip)

image image

I encountered the same issue today, this code can help solve it, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants