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 Native data in ERC20 Assets is not updated. #1281

Closed
FrederLu opened this issue Jan 16, 2023 · 3 comments
Closed

The Native data in ERC20 Assets is not updated. #1281

FrederLu opened this issue Jan 16, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@FrederLu
Copy link

FrederLu commented Jan 16, 2023

The Native data in ERC20 Assets is not synchronized with CKB Balance of Overview after the withdraw operation.
(Whether the withdraw operation after including deposit and pCKB transfer will be updated.)
https://godwoken-explorer-ui-development.vercel.app/zh-CN/account/0x9d5f761080663e5a336fc5923cc510bf8bf2363e?tab=assets
image

The hardhat environment is required to deploy the contract, and you can refer to the information to create the project environment.

Before operating withdraw on the contract, you need to deploy the contract locally through the command line hardhat:

// SPDX-License-Identifier UNLICENSED
pragma solidity ^0.8.9;

import "hardhat/console.sol";

// Author: @keith-cy
contract LockTest {
    uint public unlockTime;
    address payable public owner;

    event Withdrawal(uint amount, uint when);

    constructor(uint _unlockTime) payable {
      unlockTime = _unlockTime;
      owner = payable(msg.sender);
    }

    function withdraw() public {
      console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);
      emit Withdrawal(address(this).balance, block.timestamp);
      owner.transfer(address(this).balance);
    }

    function deposit(uint _unlockTime) public payable {
      unlockTime = _unlockTime;
      owner = payable(msg.sender);
    }
}

After the contract is deployed, call such a method through hardhat console--npx hardhat --network godwoken console

const LockTest = await ethers.getContractFactory('LockTest')
const Lock = await LockTest.attach('0x9D5f761080663e5A336Fc5923cc510bF8BF2363E')
await Lock.deposit(16735791609250, {value:9000999999999990})
await Lock.withdraw({gasLimit: 100000})

Seeing the following information on the command line indicates that the deposit and withdraw method calls are successful.

> await Lock.deposit(16735791609250, {value:9000999999999990})
{
  hash: '0x38f5d288b456fabe7a1e122ee71393a4773a1e3b1f858efdbb79239136daf646',
  type: 0,
  accessList: null,
  blockHash: '0xb69f8be24240f1b91e9c4020ff045b32e701be5c58dcd70d54ce0fe102ba8216',
  blockNumber: 1494402,
  transactionIndex: 0,
  confirmations: 1,
  from: '0x46a23E25df9A0F6c18729ddA9Ad1aF3b6A131160',
  gasPrice: BigNumber { value: "45871559633" },
  gasLimit: BigNumber { value: "90570" },
  to: '0x9D5f761080663e5A336Fc5923cc510bF8BF2363E',
  value: BigNumber { value: "9000999999999990" },
  nonce: 214,
  data: '0xb6b55f2500000000000000000000000000000000000000000000000000000f389ae9f5a2',
  r: '0x4aa02afebeee965e40ce34fe748264cfdd7b5627c36b7e3eea6705f6e381c9bc',
  s: '0x67c6be5a07828aab98e223f2ea45fa8860cfe4385090cb99bc3e4dacdb132137',
  v: 142838,
  creates: null,
  chainId: 71401,
  wait: [Function (anonymous)]
}
> await Lock.withdraw({gasLimit: 100000})
{
  hash: '0xb3c69d3f554da3eebfb19a3cb1e635e8f31049b5d5c1fbfec202b458e7b605bb',
  type: 0,
  accessList: null,
  blockHash: '0xfed442a70cfa503540bc035012313dfffe5462b94691e49cd97da76600d6cc8a',
  blockNumber: 1494407,
  transactionIndex: 0,
  confirmations: 1,
  from: '0x46a23E25df9A0F6c18729ddA9Ad1aF3b6A131160',
  gasPrice: BigNumber { value: "45871559633" },
  gasLimit: BigNumber { value: "100000" },
  to: '0x9D5f761080663e5A336Fc5923cc510bF8BF2363E',
  value: BigNumber { value: "0" },
  nonce: 215,
  data: '0x3ccfd60b',
  r: '0xa13f3dfc9939d36cefc292b86d464dfc4e63d2f0241954ae001fea513a3f26c4',
  s: '0x6fdd622c4d0a9508ea0ecdfbe31953c51b96ff7b2e3f801b20681287c9f76fb5',
  v: 142838,
  creates: null,
  chainId: 71401,
  wait: [Function (anonymous)]
}
@FrederLu FrederLu added the bug Something isn't working label Jan 16, 2023
@zmcNotafraid zmcNotafraid self-assigned this Feb 1, 2023
@FrederLu
Copy link
Author

FrederLu commented Feb 2, 2023

https://godwoken-explorer-ui-development.vercel.app/account/0xb795a25fef9948050b47d46d30c2117e872106dd?tab=assets
image
https://godwoken-explorer-ui-development.vercel.app/account/0x714e35b687c86db95d788aeb363ab22037b6a655?tab=assets
Review questions.
step:

  1. Deploy the contract through hardhat, so that the hardhat console can perform Deposit and Withdraw operations on the network godwoken;
  2. Use MetaMask to transfer funds to the contract (pCKB);
  3. Perform a Withdraw operation on the transferred contract through the hardhat console;

Finally, it was found that the page CKB Balance and Native data were out of sync.

@zmcNotafraid
Copy link
Member

zmcNotafraid commented Feb 7, 2023

After test, deposit to this contract is correct and the ckb balance will update.I think the bug is caused by withdrawal.So I need more withdrawal detail to check.


https://gw-explorer.nervosdao.community/address/0xb795A25FeF9948050B47d46D30c2117e872106dD/coin-balances#address-tabs
After compare with blockscout,the value should be update.


The blockscout logic is when this block have logs or internal transactions or beneficiary, they will parse address hash and block_hash and insert into tables, then async to fetch the address's eth balance(ckb balance)

@FrederLu
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

3 participants