filecoin-project / filecoin-solidity

Filecoin Solidity API Library
Other
17 stars 11 forks source link

Hardhat + Localnet #54

Closed wertikalk closed 4 months ago

wertikalk commented 6 months ago

Update: no longer WIP - it is done

Context

Contains hardhat dev. env. setup and initial tests (market.t.ts and verifreg.t.ts).

When complete, it will include all ports of all rust integration tests (from ./testing/) on localnet setup with some tests being able to run on calibnet testnet.

Approach

Affected issues:

snissn commented 4 months ago

there's also a failing forge test on this PR:

Failing tests:
Encountered 1 failing test in contracts/v0.8/tests/serialize.test.sol:FilAddressSerialize
[FAIL. Reason: assertion failed] test_1() (gas: 22037)
wertikalk commented 4 months ago

there's also a failing forge test on this PR:

Failing tests:
Encountered 1 failing test in contracts/v0.8/tests/serialize.test.sol:FilAddressSerialize
[FAIL. Reason: assertion failed] test_1() (gas: 22037)

This was a mistake commit. Was experimenting with deserialization.


contract FilAddressSerialize is Test {
    using FilecoinCBOR for *;

    function test_1() external {
        CommonTypes.FilAddress memory addr1 = CommonTypes.FilAddress({data: abi.encodePacked([uint8(0), 0x04, 0x22])});
        //0x5860000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000022
        CommonTypes.FilAddress memory addr2 = CommonTypes.FilAddress({data: abi.encode([0x66])});
        //0x584000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066
        assertEq(addr2.serializeAddress(), abi.encodePacked([uint8(0), 0x04, 0x22]));
    }
}

Assert condition is wrong. Removed the test.

snissn commented 4 months ago

thanks for these changes!

With the latest code I am trying to run and validate the tests so that we can merge the PR. I think that I need to rebuild my docker environment and will try that.

If you have other suggestions in the meantime, here is my output in the docker container:

# export HH_NETWORK=localnet && npx hardhat test --bail

  Account Test
    1) Test 1: Integration test port
DBG: (Test 1: Integration test port) :::: 
    Deploying contracts... (account)

  0 passing (22s)
  1 failing

  1) Account Test
       Test 1: Integration test port:
     Error: could not coalesce error (error={ "code": 1, "message": "failed to look up actor state nonce: resolution lookup failed (t410fsr4izgpov6wvycodvz53rorota5f4iwwtker3zq): resolve address t410fsr4izgpov6wvycodvz53rorota5f4iwwtker3zq: actor not found: validation failure" }, payload={ "id": 9, "jsonrpc": "2.0", "method": "eth_sendRawTransaction", "params": [ "0x02f
snissn commented 4 months ago

Below is the latest result that I get running the calibnet tests. There are still some failures but i see more passing tests than failing tests!


  Account Test
    1) Test 1: Integration test port
DBG: (Test 1: Integration test port) :::: 
    Deploying contracts... (account)

    Authenticating message...

  Address Test
    ✔ Test 1: Integration test port (128912ms)

  BigInt Test
    ✔ Test 1: Integration test port (111494ms)

  CborDecode Test
    ✔ Test 1: Integration test port (221771ms)

  Datacap Test
    ✔ Test 1: Integration test port (110909ms)

  Deserialize Params Test
    ✔ Test 1: Integration test port (155954ms)

  Leb128 Test
    ✔ Test 1: Integration test port

  Market Test
    2) Test 1: State changes on Calibnet
DBG: (Test 1: State changes on Calibnet) :::: 
    Adding funds to balance...

    ✔ Test 2: Reading from Calibnet (6527ms)

  Market Cbot Test
    ✔ Test 1: Integration test port (142970ms)

  Precompiles Test
    ✔ Test 1: Integration test port (112920ms)

  Send Test
    ✔ Test 1: Integration test port (273521ms)

  Verifreg Test
    ✔ Test 1: Integration test port (166314ms)

  Market Tests (Beacon)
    3) "before all" hook for "Test 1: State changes on Calibnet (Before Upgrade)"

  Market Tests (Transparent)
    4) Test 1: State changes on Calibnet (Before Upgrade)
DBG::No logs for: 'Test 1: State changes on Calibnet (Before Upgrade)'
    5) Test 2: Reading from Calibnet (Before Upgrade)
DBG::No logs for: 'Test 2: Reading from Calibnet (Before Upgrade)'
    6) Test 1: State changes on Calibnet (After Upgrade)
DBG::No logs for: 'Test 1: State changes on Calibnet (After Upgrade)'
    7) Test 2: Reading from Calibnet (After Upgrade)
DBG::No logs for: 'Test 2: Reading from Calibnet (After Upgrade)'

  Market Tests (UUPS)
    8) "before all" hook for "Test 1: State changes on Calibnet (Before Upgrade)"

  11 passing (33m)
  8 failing

  1) Account Test
       Test 1: Integration test port:
     Error: missing revert data (action="call", data=null, reason=null, transaction={ "data": "0xf5c62e87000000000000000000000000000000000000000000000000000000000001b3370000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000060b179ef5bdedaffffdd5a8c245c7e3a9629329b7870ee56eff12dbbc5479cebaae70233d708b37d1ff57ccab813c22aa80a9ea5d8fd8df5364d3dc71e024e1ffd872d87c2c60cab54966aac4f6b1fee4b0b3c663dde7d6d525a26f57e569452c500000000000000000000000000000000000000000000000000000000000000608eabea2a4001061ac4c9fe3c517725b8829b159149a863b2a2320cc628d026a871d3cb34947371f384a9eb49ff9bd56a019fa70e10c06ac5ca93df3c1d6f54d540c57cbe2f5209cafdc12146d5d59172dd4d8359015e10584fa6327de0ce5a6a", "from": "0xf7931ff7FC55d19EF4A8139fa7E4b3F06e03F2e2", "to": "0xF5d6a1907c9eED68D9b497449A334387Aa1EabC1" }, invocation=null, revert=null, code=CALL_EXCEPTION, version=6.12.1)
      at makeError (node_modules/ethers/src.ts/utils/errors.ts:694:21)
      at getBuiltinCallException (node_modules/ethers/src.ts/abi/abi-coder.ts:118:21)
      at Function.getBuiltinCallException (node_modules/ethers/src.ts/abi/abi-coder.ts:235:16)
      at JsonRpcProvider.getRpcError (node_modules/ethers/src.ts/providers/provider-jsonrpc.ts:979:32)
      at /var/lib/fil-sol/node_modules/ethers/src.ts/providers/provider-jsonrpc.ts:563:45
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

  2) Market Test
       Test 1: State changes on Calibnet:

      AssertionError: expected '0x00' to equal '0x0de0b6b3a7640000'
      + expected - actual

      -0x00
      +0x0de0b6b3a7640000

      at /var/lib/fil-sol/hh-test/calibnet/e2e/market.t.ts:62:48
      at step (hh-test/calibnet/e2e/market.t.ts:33:23)
      at Object.next (hh-test/calibnet/e2e/market.t.ts:14:53)
      at fulfilled (hh-test/calibnet/e2e/market.t.ts:5:58)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

  3) Market Tests (Beacon)
       "before all" hook for "Test 1: State changes on Calibnet (Before Upgrade)":
     Error: Contract at 0x4644Aed07481028F0AA298432F2c58cf51228642 doesn't look like a beacon

Deploy a beacon using deployBeacon().
      at Proxy.deployBeaconProxy (node_modules/@openzeppelin/hardhat-upgrades/src/deploy-beacon-proxy.ts:71:13)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

  4) Market Tests (Transparent)
       Test 1: State changes on Calibnet (Before Upgrade):
     Error: could not decode result data (value="0x", info={ "method": "get_balance", "signature": "get_balance((bytes))" }, code=BAD_DATA, version=6.12.1)
      at makeError (node_modules/ethers/src.ts/utils/errors.ts:694:21)
      at assert (node_modules/ethers/src.ts/utils/errors.ts:715:25)
      at Interface.decodeFunctionResult (node_modules/ethers/src.ts/abi/interface.ts:916:15)
      at staticCallResult (node_modules/ethers/src.ts/contract/contract.ts:346:35)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async staticCall (node_modules/ethers/src.ts/contract/contract.ts:303:24)
      at async Proxy.get_balance (node_modules/ethers/src.ts/contract/contract.ts:351:41)

  5) Market Tests (Transparent)
       Test 2: Reading from Calibnet (Before Upgrade):
     Error: could not decode result data (value="0x", info={ "method": "get_deal_data_commitment", "signature": "get_deal_data_commitment(uint64)" }, code=BAD_DATA, version=6.12.1)
      at makeError (node_modules/ethers/src.ts/utils/errors.ts:694:21)
      at assert (node_modules/ethers/src.ts/utils/errors.ts:715:25)
      at Interface.decodeFunctionResult (node_modules/ethers/src.ts/abi/interface.ts:916:15)
      at staticCallResult (node_modules/ethers/src.ts/contract/contract.ts:346:35)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async staticCall (node_modules/ethers/src.ts/contract/contract.ts:303:24)
      at async Proxy.get_deal_data_commitment (node_modules/ethers/src.ts/contract/contract.ts:351:41)

  6) Market Tests (Transparent)
       Test 1: State changes on Calibnet (After Upgrade):
     Error: Contract at 0x8E131be7aA417F3E04aD10E7d044646c896aC39b doesn't look like an ERC 1967 proxy with a logic contract address

      at getImplementationAddress (node_modules/@openzeppelin/upgrades-core/src/eip-1967.ts:29:11)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async processProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/validate-impl.ts:23:26)
      at async validateProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/validate-impl.ts:62:30)
      at async deployProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:72:3)
      at async Proxy.upgradeProxy (node_modules/@openzeppelin/hardhat-upgrades/src/upgrade-proxy.ts:38:32)

  7) Market Tests (Transparent)
       Test 2: Reading from Calibnet (After Upgrade):
     Error: Contract at 0x8E131be7aA417F3E04aD10E7d044646c896aC39b doesn't look like an ERC 1967 proxy with a logic contract address

      at getImplementationAddress (node_modules/@openzeppelin/upgrades-core/src/eip-1967.ts:29:11)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async processProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/validate-impl.ts:23:26)
      at async validateProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/validate-impl.ts:62:30)
      at async deployProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:72:3)
      at async Proxy.upgradeProxy (node_modules/@openzeppelin/hardhat-upgrades/src/upgrade-proxy.ts:38:32)

  8) Market Tests (UUPS)
       "before all" hook for "Test 1: State changes on Calibnet (Before Upgrade)":
     Error: Timed out waiting for implementation contract deployment to address 0x197dd6B8952aED4F7Cd63Ea1e0502e0b506138aa with transaction 0xf8ad7674e9cde5fc1c30fff71c5dc0fbd3b2e1df888e3c608bfb13580b40cb0b

Run the function again to continue waiting for the transaction confirmation. If the problem persists, adjust the polling parameters with the timeout and pollingInterval options.
      at waitAndValidateDeployment (node_modules/@openzeppelin/upgrades-core/src/deployment.ts:239:17)
      at async fetchOrDeployGeneric (node_modules/@openzeppelin/upgrades-core/src/impl-store.ts:86:5)
      at async deployImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:109:22)
      at async deployProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:77:9)
      at async Proxy.deployProxy (node_modules/@openzeppelin/hardhat-upgrades/src/deploy-proxy.ts:48:28)

make: *** [Makefile:154: test_hh_calibnet] Error 8
wertikalk commented 4 months ago

closing in favor of: https://github.com/filecoin-project/filecoin-solidity/pull/63