zeta-chain / node

ZetaChain’s blockchain node and an observer validator client
https://zetachain.com
MIT License
167 stars 109 forks source link

Can't call a contract on ZetaChain from a contract on a connected chain #2348

Closed fadeev closed 3 months ago

fadeev commented 5 months ago

Describe the Bug

When an EOA calls a contract on ZetaChain by sending tokens to a TSS address, everything works.

When a contract on a connected chain calls a contract on ZetaChain, doesn't seem to work.

Example caller contract:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

contract Caller {
    address constant tssAddress = 0x8531a5aB847ff5B22D855633C25ED1DA3255247e;
    event DepositSuccess(address, address);
    error DepositFailed();

    function deposit(address universalAppAddress) public payable {
        bytes memory data = abi.encodePacked(universalAppAddress);

        (bool success, ) = payable(tssAddress).call{
            value: msg.value,
            gas: 100000
        }(data);

        if (success) {
            emit DepositSuccess(msg.sender, universalAppAddress);
        } else {
            revert DepositFailed();
        }
    }
}

To Reproduce use the following branch: https://github.com/zeta-chain/example-contracts/pull/184

git clone https://github.com/zeta-chain/example-contracts
cd example-contracts
gh pr checkout 184
cd omnichain/example
yarn
npx hardhat deploy --network zeta_testnet --name UniversalApp
npx hardhat deploy-caller --network sepolia_testnet

npx hardhat deposit-caller --network sepolia_testnet --amount 0.0 --caller 0x9189570EE6Cfdb940107028334e454C040E3188f --contract 0x29C7E1222023C88f0B04Ca8B555030e1B4C2a7CC

Contract on Sepolia: https://sepolia.etherscan.io/address/0x9189570ee6cfdb940107028334e454c040e3188f Tx: https://sepolia.etherscan.io/tx/0x3bb7de25248378e5500d45bc2e31ff49062573e756714f96189f47f1463f0d7f Contract on ZetaChain: https://zetachain-athens-3.blockscout.com/address/0x0814c1b3BC752574D66E4BAD7a057e618916A61E?tab=txs

Expected Behavior

Expected to see a transaction to a TSS address: https://sepolia.etherscan.io/address/0x8531a5aB847ff5B22D855633C25ED1DA3255247e

And an event emitted from a contract on ZetaChain.

lumtis commented 3 months ago

V2 smart contracts will address the issue once on live network