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

hardhat-example project isn't fully functional #488

Closed
mshakeg opened this issue Aug 31, 2022 · 7 comments
Closed

hardhat-example project isn't fully functional #488

mshakeg opened this issue Aug 31, 2022 · 7 comments
Labels
bug Something isn't working limechain P2 process Build, test and deployment-process related tasks
Milestone

Comments

@mshakeg
Copy link
Contributor

mshakeg commented Aug 31, 2022

Description

The hardhat-example project appears to have missing/incorrect dependencies/config. Only 1/5 tests pass.

  RPC
The address 0x67D8d32E9Bf1a9968a5ff53B87d777Aa8EBBEe69 has 9999605811370000000000 tinybars
    ✔ should be able to get the account balance (299ms)
Balance before tx: 9999605811370000000000
    1) should be able to transfer hbars between two accounts
    2) should be able to deploy a contract
    3) should be able to make a contract view call
    4) should be able to make a contract call

Steps to reproduce

  1. Install the project: npm i
  2. Install @hashgraph/hedera-local@1.2.0 in the project: npm i @hashgraph/hedera-local@1.2.0
  3. Start hedera-local node in project root: npx @hashgraph/hedera-local start
  4. Run test cmd in project root: npx hardhat test

Device:

OS: macOS 12.2.1
Chip: Apple M1

Additional context

json-rpc-relay container log for 1 of the failed calls which seems to indicate a network config issue particularly with the chainId, I did attempt to set the chainId to 298, 200 and 1 in the hardhat config for the relay network, but none worked.

[2022-08-31 14:47:21.921 +0000] ERROR (relay-eth/49 on e63350e0cd8c): Failed to successfully submit sendRawTransaction for transaction 0x02f87382012a808459682f0086014fa0186f008252089405fba803be258049a27b820088bab1cad205887185174876e80080c080a07e95626e5f8795e15a555bd0f3acc86d47d765822dff57453a1589895ca5e375a0408a1ba43a091c0c5ac727d35100cd7fbd833f7fe528a2643210fd0fb3d6e7c5
    err: {
      "type": "Error",
      "message": "transaction 0.0.2@1661957231.900676825 failed precheck with status WRONG_CHAIN_ID",
      "stack":
          Error: transaction 0.0.2@1661957231.900676825 failed precheck with status WRONG_CHAIN_ID
              at SDKClient.<anonymous> (/home/node/app/packages/relay/dist/lib/clients/sdkClient.js:83:27)
              at Generator.throw (<anonymous>)
              at rejected (/home/node/app/packages/relay/dist/lib/clients/sdkClient.js:25:65)
              at processTicksAndRejections (node:internal/process/task_queues:96:5)
    }

Stack traces for failed tests:

  1) RPC
       should be able to transfer hbars between two accounts:
     Error: processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":55,\"error\":{\"code\":-32603,\"name\":\"Internal error\",\"message\":\"Unknown error invoking RPC\"}}", error={"code":-32603}, requestBody="{\"method\":\"eth_sendRawTransaction\",\"params\":[\"0x02f87382012a808459682f0086014fa0186f008252089405fba803be258049a27b820088bab1cad205887185174876e80080c080a07e95626e5f8795e15a555bd0f3acc86d47d765822dff57453a1589895ca5e375a0408a1ba43a091c0c5ac727d35100cd7fbd833f7fe528a2643210fd0fb3d6e7c5\"],\"id\":55,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="http://localhost:7546", code=SERVER_ERROR, version=web/5.6.1)
      at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:261:28)
      at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:273:20)
      at /Users/user/dev/hedera/hedera-json-rpc-relay/tools/hardhat-example/node_modules/@ethersproject/web/src.ts/index.ts:329:28
      at step (node_modules/@ethersproject/web/lib/index.js:33:23)
      at Object.next (node_modules/@ethersproject/web/lib/index.js:14:53)
      at fulfilled (node_modules/@ethersproject/web/lib/index.js:5:58)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)

  2) RPC
       should be able to deploy a contract:
     Error: processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":53,\"error\":{\"code\":-32603,\"name\":\"Internal error\",\"message\":\"Unknown error invoking RPC\"}}", error={"code":-32603}, requestBody="{\"method\":\"eth_sendRawTransaction\",\"params\":[\"0x02f9084682012a808459682f0086014fa0186f0083061a808080b907e9608060405234801561001057600080fd5b506040516107893803806107898339818101604052810190610032919061015a565b806000908051906020019061004892919061004f565b50506102f6565b82805461005b90610224565b90600052602060002090601f01602090048101928261007d57600085556100c4565b82601f1061009657805160ff19168380011785556100c4565b828001600101855582156100c4579182015b828111156100c35782518255916020019190600101906100a8565b5b5090506100d191906100d5565b5090565b5b808211156100ee5760008160009055506001016100d6565b5090565b6000610105610100846101c0565b61019b565b90508281526020810184848401111561011d57600080fd5b6101288482856101f1565b509392505050565b600082601f83011261014157600080fd5b81516101518482602086016100f2565b91505092915050565b60006020828403121561016c57600080fd5b600082015167ffffffffffffffff81111561018657600080fd5b61019284828501610130565b91505092915050565b60006101a56101b6565b90506101b18282610256565b919050565b6000604051905090565b600067ffffffffffffffff8211156101db576101da6102b6565b5b6101e4826102e5565b9050602081019050919050565b60005b8381101561020f5780820151818401526020810190506101f4565b8381111561021e576000848401525b50505050565b6000600282049050600182168061023c57607f821691505b602082108114156102505761024f610287565b5b50919050565b61025f826102e5565b810181811067ffffffffffffffff8211171561027e5761027d6102b6565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b610484806103056000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063a41368621461003b578063cfae321714610057575b600080fd5b6100556004803603810190610050919061022c565b610075565b005b61005f61008f565b60405161006c91906102a6565b60405180910390f35b806000908051906020019061008b929190610121565b5050565b60606000805461009e9061037c565b80601f01602080910402602001604051908101604052809291908181526020018280546100ca9061037c565b80156101175780601f106100ec57610100808354040283529160200191610117565b820191906000526020600020905b8154815290600101906020018083116100fa57829003601f168201915b5050505050905090565b82805461012d9061037c565b90600052602060002090601f01602090048101928261014f5760008555610196565b82601f1061016857805160ff1916838001178555610196565b82800160010185558215610196579182015b8281111561019557825182559160200191906001019061017a565b5b5090506101a391906101a7565b5090565b5b808211156101c05760008160009055506001016101a8565b5090565b60006101d76101d2846102ed565b6102c8565b9050828152602081018484840111156101ef57600080fd5b6101fa84828561033a565b509392505050565b600082601f83011261021357600080fd5b81356102238482602086016101c4565b91505092915050565b60006020828403121561023e57600080fd5b600082013567ffffffffffffffff81111561025857600080fd5b61026484828501610202565b91505092915050565b60006102788261031e565b6102828185610329565b9350610292818560208601610349565b61029b8161043d565b840191505092915050565b600060208201905081810360008301526102c0818461026d565b905092915050565b60006102d26102e3565b90506102de82826103ae565b919050565b6000604051905090565b600067ffffffffffffffff8211156103085761030761040e565b5b6103118261043d565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b82818337600083830152505050565b60005b8381101561036757808201518184015260208101905061034c565b83811115610376576000848401525b50505050565b6000600282049050600182168061039457607f821691505b602082108114156103a8576103a76103df565b5b50919050565b6103b78261043d565b810181811067ffffffffffffffff821117156103d6576103d561040e565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f830116905091905056fea264697066735822122070d157c4efbb3fba4a1bde43cbba5b92b69f2fc455a650c0dfb61e9ed3d4bd6364736f6c634300080400330000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b696e697469616c5f6d7367000000000000000000000000000000000000000000c080a0433934dae6055440112a7b106d6d822f9eff1d941efe2a1e0e5078a67ae32840a075b1e00f6c77e02924a7bf1e1a8880a489e2d11fb5813cb0b3888c89c5eb0339\"],\"id\":53,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="http://localhost:7546", code=SERVER_ERROR, version=web/5.6.1)
      at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:261:28)
      at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:273:20)
      at /Users/user/dev/hedera/hedera-json-rpc-relay/tools/hardhat-example/node_modules/@ethersproject/web/src.ts/index.ts:329:28
      at step (node_modules/@ethersproject/web/lib/index.js:33:23)
      at Object.next (node_modules/@ethersproject/web/lib/index.js:14:53)
      at fulfilled (node_modules/@ethersproject/web/lib/index.js:5:58)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)

  3) RPC
       should be able to make a contract view call:
     Error: invalid contract address or ENS name (argument="addressOrName", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.6.2)
      at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:261:28)
      at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:273:20)
      at Logger.throwArgumentError (node_modules/@ethersproject/logger/src.ts/index.ts:277:21)
      at Contract.BaseContract (node_modules/@ethersproject/contracts/src.ts/index.ts:712:20)
      at new Contract (node_modules/@ethersproject/contracts/lib/index.js:1053:42)
      at Function.ContractFactory.getContract (node_modules/@ethersproject/contracts/src.ts/index.ts:1297:16)
      at ContractFactory.attach (node_modules/@ethersproject/contracts/src.ts/index.ts:1260:42)
      at getContractAtFromArtifact (node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:352:26)

  4) RPC
       should be able to make a contract call:
     Error: invalid contract address or ENS name (argument="addressOrName", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.6.2)
      at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:261:28)
      at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:273:20)
      at Logger.throwArgumentError (node_modules/@ethersproject/logger/src.ts/index.ts:277:21)
      at Contract.BaseContract (node_modules/@ethersproject/contracts/src.ts/index.ts:712:20)
      at new Contract (node_modules/@ethersproject/contracts/lib/index.js:1053:42)
      at Function.ContractFactory.getContract (node_modules/@ethersproject/contracts/src.ts/index.ts:1297:16)
      at ContractFactory.attach (node_modules/@ethersproject/contracts/src.ts/index.ts:1260:42)
      at getContractAtFromArtifact (node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:352:26)

Hedera network

other

Version

@hashgraph/hedera-local@1.2.0

Operating system

macOS

@mshakeg mshakeg added the bug Something isn't working label Aug 31, 2022
@mshakeg
Copy link
Contributor Author

mshakeg commented Aug 31, 2022

@natanasow seems to be the only contributor to any of the 3 examples, none of which seem to run the tests 100%.

The truffle-example doesn't even begin to run the tests and fails with the following trace:

Compiling your contracts...
===========================
> Compiling ./contracts/Greeter.sol
> Artifacts written to /var/folders/nw/7k5l56jn0ngd77ll2zykymhr0000gn/T/test--35109-PSqrzFCnNK4l
> Compiled successfully using:
   - solc: 0.8.15+commit.e14f2714.Emscripten.clang
Error: 
    at /Users/user/dev/hedera/hedera-json-rpc-relay/tools/truffle-example/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:331:1
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Migration._deploy (/Users/user/dev/hedera/hedera-json-rpc-relay/tools/truffle-example/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:68:1)
    at Migration._load (/Users/user/dev/hedera/hedera-json-rpc-relay/tools/truffle-example/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:54:1)
    at Migration.run (/Users/user/dev/hedera/hedera-json-rpc-relay/tools/truffle-example/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:202:1)
    at Object.runMigrations (/Users/user/dev/hedera/hedera-json-rpc-relay/tools/truffle-example/node_modules/truffle/build/webpack:/packages/migrate/index.js:142:1)
    at Object.runFrom (/Users/user/dev/hedera/hedera-json-rpc-relay/tools/truffle-example/node_modules/truffle/build/webpack:/packages/migrate/index.js:107:1)
    at Object.runAll (/Users/user/dev/hedera/hedera-json-rpc-relay/tools/truffle-example/node_modules/truffle/build/webpack:/packages/migrate/index.js:111:1)
    at Object.run (/Users/user/dev/hedera/hedera-json-rpc-relay/tools/truffle-example/node_modules/truffle/build/webpack:/packages/migrate/index.js:84:1)
    at Object.run (/Users/user/dev/hedera/hedera-json-rpc-relay/tools/truffle-example/node_modules/truffle/build/webpack:/packages/core/lib/testing/Test.js:114:1)
    at Object.module.exports [as run] (/Users/user/dev/hedera/hedera-json-rpc-relay/tools/truffle-example/node_modules/truffle/build/webpack:/packages/core/lib/commands/test/run.js:115:1)
    at runCommand (/Users/user/dev/hedera/hedera-json-rpc-relay/tools/truffle-example/node_modules/truffle/build/webpack:/packages/core/lib/command-utils.js:184:1)
Truffle v5.5.23 (core: 5.5.23)
Node v16.17.0

The web3js-example tests fail similarly to the hardhat-example with the following tests error trace:

  RPC
The address 0x67D8d32E9Bf1a9968a5ff53B87d777Aa8EBBEe69 has 9999605811370000000000 tinybars
    ✔ should be able to get the account balance (372ms)
Balance before tx: 9999605811370000000000
    1) should be able to transfer hbars between two accounts
    2) should be able to deploy a contract
    3) should be able to make a contract view call
    4) should be able to make a contract call


  1 passing (2s)
  4 failing

  1) RPC
       should be able to transfer hbars between two accounts:
     Error: Returned error: Unknown error invoking RPC
      at Object.ErrorResponse (node_modules/web3-core-helpers/lib/errors.js:28:19)
      at /Users/user/dev/hedera/hedera-json-rpc-relay/tools/web3js-example/node_modules/web3-core-requestmanager/lib/index.js:300:36
      at XMLHttpRequest.request.onreadystatechange (node_modules/web3-providers-http/lib/index.js:98:13)
      at XMLHttpRequestEventTarget.dispatchEvent (node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
      at XMLHttpRequest._setReadyState (node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
      at XMLHttpRequest._onHttpResponseEnd (node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
      at IncomingMessage.<anonymous> (node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
      at IncomingMessage.emit (node:events:525:35)
      at endReadableNT (node:internal/streams/readable:1358:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)

  2) RPC
       should be able to deploy a contract:
     Error: Returned error: Unknown error invoking RPC
      at Object.ErrorResponse (node_modules/web3-core-helpers/lib/errors.js:28:19)
      at /Users/user/dev/hedera/hedera-json-rpc-relay/tools/web3js-example/node_modules/web3-core-requestmanager/lib/index.js:300:36
      at XMLHttpRequest.request.onreadystatechange (node_modules/web3-providers-http/lib/index.js:98:13)
      at XMLHttpRequestEventTarget.dispatchEvent (node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
      at XMLHttpRequest._setReadyState (node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
      at XMLHttpRequest._onHttpResponseEnd (node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
      at IncomingMessage.<anonymous> (node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
      at IncomingMessage.emit (node:events:525:35)
      at endReadableNT (node:internal/streams/readable:1358:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)

  3) RPC
       should be able to make a contract view call:
     Error: This contract object doesn't have address set yet, please set an address first.
      at Object.ContractNoAddressDefinedError (node_modules/web3-core-helpers/lib/errors.js:122:16)
      at Object._processExecuteArguments (node_modules/web3-eth-contract/lib/index.js:728:22)
      at Object._executeMethod (node_modules/web3-eth-contract/lib/index.js:744:68)
      at module.exports (scripts/contractViewCall.js:32:49)
      at async Context.<anonymous> (test/rpc.js:59:17)

  4) RPC
       should be able to make a contract call:
     Error: This contract object doesn't have address set yet, please set an address first.
      at Object.ContractNoAddressDefinedError (node_modules/web3-core-helpers/lib/errors.js:122:16)
      at Object._processExecuteArguments (node_modules/web3-eth-contract/lib/index.js:728:22)
      at Object._executeMethod (node_modules/web3-eth-contract/lib/index.js:744:68)
      at module.exports (scripts/contractCall.js:32:59)
      at async Context.<anonymous> (test/rpc.js:66:5)

@mshakeg
Copy link
Contributor Author

mshakeg commented Sep 1, 2022

@georgi-l95 believes this issue might be related to this one.

@Nana-EC
Copy link
Collaborator

Nana-EC commented Sep 1, 2022

HI @mshakeg given the issue is around the WRONG_CHAIN_ID then yes that is the issue.
This should be addressed with the next local-node release.
In the mean time you should be able to configure the relay properties in your docker-compose to use the CHAIN_ID that matches what services expects

@mshakeg
Copy link
Contributor Author

mshakeg commented Sep 1, 2022

Thanks for the reply @Nana-EC , starting up the relay and hedera-local-node services separately using the default .env for both(which both set RELAY_CHAIN_ID and CHAIN_ID to 0x12a) doesn't seem to create the initial sets of accounts hence the balance 0 on the first hardhat example test:

  RPC
The address 0x67D8d32E9Bf1a9968a5ff53B87d777Aa8EBBEe69 has 0 tinybars
    1) should be able to get the account balance

@mshakeg
Copy link
Contributor Author

mshakeg commented Sep 2, 2022

I managed to get a temp workaround, start the hedera-local-node(npx @hashgraph/hedera-local start), then in docker shut down the relay container, then in the relay project repo, set the CHAIN_ID in .env to testnet i.e. 0x128, then setup, build and start the relay.

@Nana-EC Nana-EC added limechain P2 process Build, test and deployment-process related tasks labels Sep 7, 2022
@Nana-EC Nana-EC added this to the 0.8.0 milestone Sep 7, 2022
@Nana-EC
Copy link
Collaborator

Nana-EC commented Sep 7, 2022

@mshakeg glad you got a work around.
We'll also take a look in conjunction with the local-node updates to see what can be done.
Thanks

@mshakeg
Copy link
Contributor Author

mshakeg commented Sep 8, 2022

Great to hear @Nana-EC , I'll close this issue, given there's already visibility on the earlier issue

@mshakeg mshakeg closed this as completed Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working limechain P2 process Build, test and deployment-process related tasks
Projects
None yet
Development

No branches or pull requests

2 participants