sdk
sdk copied to clipboard
web3_clientVersion not supported in the TruffleProvider
I've been working on a team project over harmony. For setting up the contract to be upgradeable, we used OpenZeppelin CLI along with @openzeppelin-upgrades library... It works fine when deployed in Ganache. However, an error is thrown when trying to deploy in the testnet for Harmony blockchain… Below is the error i get when deploying on stable net using oz create:
oz create Nothing to compile, all contracts are up to date. ? Pick a contract to instantiate Ball ? Pick a network stable ✓ Added contract Ball Returned error: The method web3_clientVersion does not exist/is not available
The dependencies are as follows: Truffle v5.0.38 (core: 5.0.38) Solidity - 0.5.7 (solc-js) Node v8.10.0 Web3.js v1.2.1 @openzeppelin-cli and @openzeppelin-upgrades version 2.5.1
I contacted with the Openzeppelin team and they said that: "It sounds like Harmony SDK doesn’t currently support web3_clientVersion in their TruffleProvider. (https://github.com/harmony-one/sdk/blob/master/packages/harmony-core/src/truffleProvider.ts)
This appears similar to an issue connecting to Loom network: https://github.com/OpenZeppelin/openzeppelin-sdk/issues/405#issuecomment-525175943"
Please do solve this, without this, we'll have to forbid using truffle altogether for our development and do it manually! Thank you!
web3_clientVersion is actually an RPC method of the blockchain. We need support from rpc side or we need to understand when and where it will be called and wrap the method with custom result
I didn't quite understand... can you elaborate it a little? What do you mean by the second sentence?
I didn't quite understand... can you elaborate it a little? What do you mean by the second sentence?
Just like Loom did it for their truffleProvider. We need to do the same. There is no such method in RPCs of Harmony‘s blockchain. We have to manually add the expected return to the TruffleProvider. @denniswon Would you like to dive in to find solution?
I went through this... https://forum.openzeppelin.com/t/loom-support/1239 but still, I'm running around in circles trying to figure out what I need to do... how to actually solve this, does this mean I can't use OpenZeppelin SDK altogether for this? How can I solve this? Please can you give a detailed example? or a way-around...?
I went through this... https://forum.openzeppelin.com/t/loom-support/1239 but still, I'm running around in circles trying to figure out what I need to do... how to actually solve this, does this mean I can't use OpenZeppelin SDK altogether for this? How can I solve this? Please can you give a detailed example? or a way-around...?
Let me do some modification on my side to the sdk, and i'll make a branch later these days, and you can clone and try to see if it works on your side.
maybe there are more rpc methods needed like getStorageAt, I'll try to understand what loom did to workaround.
@asmitadhungana would you try this branch and see if it works for you
https://github.com/harmony-one/sdk/tree/truffle_provider
but you have to build the sdk manually, please follow this manual:
https://github.com/harmony-one/sdk#bootstrap-and-build
and do reply if it works or not, then we can discuss how to work around it.
Sure! Thanks!
Hey @neeboo, it is not actually working... idk why! My project's versions are set-up as per this package.json file in the documentation https://docs.harmony.one/home/developers/smart-contracts/sample-files#package-json ... but in the github documentation that you share, it says we need to use Node 10.0.0+... can you clarify it to me? What are the standard versions for dependencies for developing a truffle project for Harmony? I think i'm going wrong in there...
The build was checked by one of my seniors and it seems to be working individually... it is not however, working with the project
Hey @neeboo, it is not actually working... idk why! My project's versions are set-up as per this package.json file in the documentation https://docs.harmony.one/home/developers/smart-contracts/sample-files#package-json ... but in the github documentation that you share, it says we need to use Node 10.0.0+... can you clarify it to me? What are the standard versions for dependencies for developing a truffle project for Harmony? I think i'm going wrong in there...
10.0+ is by default, personally i use v12.16.1
I think you would like to test on your local machine first follow this steps.
-
git clone my branch, to some folder say: "/dev/harmony-js"
-
go to "/dev/harmony-js", run
yarn bootstrap && yarn dist
- just go straight to your project javascript file, use relative path to point to the package
const {
Harmony,
TruffleProvider,
} = require('../dev/harmony-js/packages/harmony-core')
// do the truffle thing
Please do tell me whether it works or not, then we can pr to the team, and make a release
Can you post up your truffle-config.js here and the error log? @asmitadhungana
And I'm not quite familiar with OZ cli, would you like to make an example or guide me to some working example ,maybe for ethereum network, which i can debug for harmony?
for OpenZeppelin Cli, it's an interactive cli tool that I've used to make our smart-contract upgradeable... by using commands: oz compile: compiles the contract ~truffle compile oz create: deploys the contract so that it can be upgraded later to a network specified when given the choice in this interactive command like: oz create ?pick a network: development || stable || other_networks_in_truffle-config.js
since I'd initialzed openeppelin in a truffle folder, and configured the migrations accordingly, using truffle-migrate, it can deploy an upgradeable contract w/o having to use oz create too... likewise, it uses truffle-config.js instead of its network.js which would've been created with "openzeppelin init" and used if it was used independently...
you can use this reference for a quick understanding: https://github.com/OpenZeppelin/docs.openzeppelin.com/pull/67/files/46c54a3f21136dddc055dbcb9a2854e36f607e5f
you can use the example in this guide to get to know it easily and deploy it in harmony testnets: https://docs.openzeppelin.com/learn/upgrading-smart-contracts#:~:text=Upgrading%20Smart%20Contracts,may%20find%20in%20in%20production.
i realized that the inability to find "stable-fork" was due to dry-run simulation while migrating... now, the error's the same as for oz deploy:
$npx truffle migrate --network testnet --skip-dry-run --reset
Compiling your contracts...
Everything is up to date, there is nothing to compile.
Starting migrations...
Network name: 'testnet' Network id: 2 Block gas limit: 3321900 (0x32b02c)
1_initial_migration.js
Replacing 'Migrations'
transaction hash: 0xa773c7aa0ce1bb42826fb6ed123e8c8dd884d1c4ea7c0e2fdf2b8e3d9bc2608e Blocks: 2 Seconds: 20 contract address: 0x6a05F7Ee807e7b4302555209D6A95E5f7b98d72e block number: 129151 block timestamp: 1591779051 account: 0x3aea49553Ce2E478f1c0c5ACC304a84F5F4d1f98 balance: 6699997.390565589689332405 gas used: 188751 (0x2e14f) gas price: 1 gwei value sent: 0 ETH total cost: 0.000188751 ETH
Saving migration to chain. Saving artifacts
Total cost: 0.000188751 ETH
2_deploy_contracts.js
Error: Dice deployment failed with error: Returned error: The method web3_clientVersion does not exist/is not available at Object.ErrorResponse (/media/asmee/H/hello_zepplin/node_modules/web3-eth/node_modules/web3-core-helpers/src/errors.js:29:16) at /media/asmee/H/hello_zepplin/node_modules/web3-eth/node_modules/web3-core-requestmanager/src/index.js:140:36 at /media/asmee/H/hello_zepplin/node_modules/truffle-provider/wrapper.js:112:9 at TruffleProvider._this.resolveCallback (/media/asmee/H/hello_zepplin/dev/harmony-js/packages/harmony-core/src/truffleProvider.ts:225:7) at /media/asmee/H/hello_zepplin/dev/harmony-js/packages/harmony-core/src/truffleProvider.ts:176:61 at HttpProvider.callbackHandler (/media/asmee/H/hello_zepplin/dev/harmony-js/packages/harmony-network/src/providers/http.ts:141:7) at /media/asmee/H/hello_zepplin/dev/harmony-js/packages/harmony-network/src/providers/http.ts:82:30 at process._tickCallback (internal/process/next_tick.js:68:7) Truffle v5.1.29 (core: 5.1.29) Node v10.19.0
This is my truffle-config now only with two networks:
require('dotenv').config()
//const {TruffleProvider} = require('@harmony-js/core'); const { TruffleProvider } = require('./dev/harmony-js/packages/harmony-core');
const testnet_mnemonic = process.env.TESTNET_MNEMONIC const testnet_private_key = process.env.TESTNET_PRIVATE_KEY const testnet_url = process.env.TESTNET_0_URL
//GAS - Currently using same GAS accross all environments gasLimit = process.env.GAS_LIMIT gasPrice = process.env.GAS_PRICE
const HDWalletProvider = require("@truffle/hdwallet-provider");
module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
},
testnet: {
network_id: '2',
provider: () => {
const truffleProvider = new TruffleProvider(
testnet_url,
{ memonic: testnet_mnemonic },
{ shardID: 0, chainId: 2 },
{ gasLimit: gasLimit, gasPrice: gasPrice },
);
const newAcc = truffleProvider.addByPrivateKey(testnet_private_key);
truffleProvider.setSigner(newAcc);
return truffleProvider;
}
}
}, compilers: { solc: { version: "0.6.4" // ex: "0.4.20". (Default: Truffle's installed solc) } } }
@asmitadhungana would you git pull my branch and try again?
@asmitadhungana would you git pull my branch and try again?
sure, thanks!
Hey @neebo, I'm getting the following error while building your updated branch.... And one thing, as per my team member said just a while ago, the previous fix had worked for him... dk why it was throwing that error for me though!
asmee@asmee:/media/asmee/H/fix-test/harmony-js$ yarn dist
yarn run v1.22.4
warning package.json: "dependencies" has dependency "tslib" with range "^1.10.0" that collides with a dependency in "devDependencies" of the same name with version "^1.11.1"
$ yarn packages:bundler && yarn bundle:webpack
warning package.json: "dependencies" has dependency "tslib" with range "^1.10.0" that collides with a dependency in "devDependencies" of the same name with version "^1.11.1"
$ yarn packages:clean && yarn build:ts && ts-node -P scripts/tsconfig.json scripts/bundle.ts
warning package.json: "dependencies" has dependency "tslib" with range "^1.10.0" that collides with a dependency in "devDependencies" of the same name with version "^1.11.1"
$ gulp cleanServer && yarn packages:cleanUnexpected
[12:04:06] Using gulpfile /media/asmee/H/fix-test/harmony-js/gulpfile.js
[12:04:06] Starting 'cleanServer'...
[12:04:08] Finished 'cleanServer' after 1.5 s
warning package.json: "dependencies" has dependency "tslib" with range "^1.10.0" that collides with a dependency in "devDependencies" of the same name with version "^1.11.1"
$ gulp cleanUnexpected
[12:04:09] Using gulpfile /media/asmee/H/fix-test/harmony-js/gulpfile.js
[12:04:09] Starting 'cleanUnexpected'...
[12:04:09] Finished 'cleanUnexpected' after 15 ms
warning package.json: "dependencies" has dependency "tslib" with range "^1.10.0" that collides with a dependency in "devDependencies" of the same name with version "^1.11.1"
$ tsc -b tsconfig.json
warning package.json: "dependencies" has dependency "tslib" with range "^1.10.0" that collides with a dependency in "devDependencies" of the same name with version "^1.11.1"
$ rm -rf dist && cross-env NODE_ENV=production ts-node -P scripts/tsconfig.json scripts/webpack.ts
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
asmee@asmee:/media/asmee/H/fix-test/harmony-js$ Error: write EPIPE
at process.target._send (internal/child_process.js:762:20)
at process.target.send (internal/child_process.js:634:19)
at callback (/media/asmee/H/fix-test/harmony-js/node_modules/worker-farm/lib/child/index.js:32:17)
at module.exports (/media/asmee/H/fix-test/harmony-js/node_modules/webpack/node_modules/terser-webpack-plugin/dist/worker.js:13:5)
at handle (/media/asmee/H/fix-test/harmony-js/node_modules/worker-farm/lib/child/index.js:44:8)
at process.
I searched for this error and here's the link I got: https://github.com/codesandbox/codesandbox-client/issues/4281
It however, got built in my partner's system... Idk why none of the builds are working for mine.... And now, we're getting error in execution of a function after it's gotten deployed...
I searched for this error and here's the link I got: codesandbox/codesandbox-client#4281
Better cleanup your local project and try again.
It however, got built in my partner's system... Idk why none of the builds are working for mine.... And now, we're getting error in execution of a function after it's gotten deployed...
Now what is the error you got?
✖ Upgrading instance at 0xB9CE4120F4e2683E2025723C6fa40EE53d90b086 and calling 'initialize' with no arguments ✖ Upgrading instance at 0xB9CE4120F4e2683E2025723C6fa40EE53d90b086 Proxy dice-contract/Dice at 0xB9CE4120F4e2683E2025723C6fa40EE53d90b086 failed to upgrade with error: Error: gas required exceeds allowance (10000000) or always failing transaction
✖ Upgrading instance at 0xB9CE4120F4e2683E2025723C6fa40EE53d90b086 and calling 'initialize' with no arguments ✖ Upgrading instance at 0xB9CE4120F4e2683E2025723C6fa40EE53d90b086 Proxy dice-contract/Dice at 0xB9CE4120F4e2683E2025723C6fa40EE53d90b086 failed to upgrade with error: Error: gas required exceeds allowance (10000000) or always failing transaction
That i dont know how to solve. Maybe its the gas problem.
You may dig something useful here. https://forum.openzeppelin.com/t/error-gas-required-exceeds-allowance-8000000-or-always-failing-transaction/1856/12
I've already contacted the forum... Might be, I'm the active commentator in there at the moment...
They asked me to know the EVM version that Harmony is using... Can you let me know?
And I'll close this issue since the main problem's been solved. Thank you for all he help @neebo! Much appreciated!
I've already contacted the forum... Might be, I'm the active commentator in there at the moment...
They asked me to know the EVM version that Harmony is using... Can you let me know?
And I'll close this issue since the main problem's been solved. Thank you for all he help @neebo! Much appreciated!
It seems that it is related to ‘EVM‘ gas Limit. Since Harmony use EVM as its smart contract runtime however I am not sure it has the same gas setting to Ethereum. I will dig a bit and let you know
Sure @neeboo , thanks a lot! It's that the same contract works just fine for Rinkeby (Ethereum's testnet) but when it comes to harmony's testnet, it doesn't...
@neeboo any asnwer yet?