Code Monkey home page Code Monkey logo

Comments (5)

danijelTxFusion avatar danijelTxFusion commented on July 28, 2024 3

@mixbe

You are write when it comes to gas_limit it should be named l2_gas_limit (your PR that makes those changes is already merged). Also when gas_limit is not provided, the fixed default value of 10_000_000 is used. This is not correct anymore and the gas limit should be estimated using zks_estimateGasL1toL2. The provider does not have this RPC method implemented yet, but it will be implemented in the upcoming release.

from zksync2-python.

danijelTxFusion avatar danijelTxFusion commented on July 28, 2024

Gas estimation on mainnet does not work. Temporary solution is to estimate gas on testnet and set gasLimit value for transactions that needs to be broadcasted to mainnet.

from zksync2-python.

mixbe avatar mixbe commented on July 28, 2024

Use web bridge zksync, transfer 0.001 ETH,The ETH cost is 0.00155528 ETH

But using the Python SDK, I found that the same amount of transfer The ETH cost is 0.006 ETH

It can be said that there is a big difference, so to solve this problem, you need to pass the gas_limit parameter

eth_provider.deposit(token=Token.create_eth(),
                                         to=to,
                                         amount=Web3.to_wei(amount, 'ether'),
                                         l2_gas_limit=1123680,
                                         gas_limit=200000,
                                         gas_price=int(eth_web3.eth.gas_price * 1.2))

At the same time, I found another problem, it may be a bug, the gas_limit should be l2_gas_limit, Why? it can be found through the contract, the base cost is : l2GasPrice * _l2GasLimit

    /// @notice Estimates the cost in Ether of requesting execution of an L2 transaction from L1
    /// @return The estimated L2 gas for the transaction to be paid
    function l2TransactionBaseCost(
        uint256 _gasPrice,
        uint256 _l2GasLimit,
        uint256 _l2GasPerPubdataByteLimit
    ) public pure returns (uint256) {
        uint256 l2GasPrice = _deriveL2GasPrice(_gasPrice, _l2GasPerPubdataByteLimit);
        return l2GasPrice * _l2GasLimit;
    }

/zksync2/provider/eth_provider.py

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

from zksync2-python.

BoboTiG avatar BoboTiG commented on July 28, 2024

Any news, or plan to share with us? :)

from zksync2-python.

danijelTxFusion avatar danijelTxFusion commented on July 28, 2024

The issues are resolved in version 1.0.0. To use the SDK, please refer to the documentation and examples.

from zksync2-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.