From 7df3554d054f7f345b24d82ea3b5f63257bd7934 Mon Sep 17 00:00:00 2001 From: wenxing wang Date: Fri, 20 Dec 2024 17:12:49 +0000 Subject: [PATCH] fix: update for polygon testnet from mumbai to amoy --- README.md | 12 ++---------- bin/start | 2 +- src/boilerplate/common/bin/setup | 8 ++++---- src/boilerplate/common/config/default.js | 22 ++++++++++++++++++---- src/boilerplate/common/truffle-config.js | 6 ++++-- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 89b6d1e5e..d5cd9ed7e 100644 --- a/README.md +++ b/README.md @@ -344,17 +344,9 @@ Starlight handles secret initiation in the constructor by creating a proof at th Since this inevitably creates a commitment to be sent your local db, simply restarting the zapp will **not** work. The blockchain will be aware of the constructor commitment, but your zapp will not. -If you would like to restart the zapp and redeploy the contract, always (with no running docker containers) run: - -`./bin/redeploy` <-- creates a new constructor proof and saves the commitment, then deploys the shield contract - -`npm run restart` <-- if you'd like to use the APIs, always **restart** rather than **start** since the latter clears your local dbs - -Then, if you previously had nullifiers, reinstate them in your local sparse merkle tree by sending a POST to `http://localhost:3000/reinstateNullifiers`. - #### Deploy on public testnets -Apart from local ganache instance, Starlight output zapps can now be deployed in Sepolia, Goerli and Polygon Mumbai as cli options. Connection to Sepolia and Goerli are made through [infura](https://infura.io/) endpoints and that of Polygon Mumbai is provided via [maticvigil](https://rpc.maticvigil.com/). +Apart from local ganache instance, Starlight output zapps can now be deployed in Sepolia, Goerli and Polygon Amoy as cli options. Connection to Sepolia and Goerli are made through [infura](https://infura.io/) endpoints and that of Polygon Amoy is provided via [Alchemy](https://www.alchemy.com/). The configuration can be done during `./bin/setup` phase in the following way. @@ -364,7 +356,7 @@ The configuration can be done during `./bin/setup` phase in the following way. | option | description | |:--|:--| -| `-n` | Network : Specify testnet you want to connect to. possible options: `mumbai/ sepolia/ goerli` | +| `-n` | Network : Specify testnet you want to connect to. possible options: `amoy/ sepolia/ goerli` | | `-a` | Ethereum address | | `-k` | Private key of above ethereum address | | `-m` - | 12 letter mnemonic passphrase | diff --git a/bin/start b/bin/start index dce49e21e..3b99cddb8 100755 --- a/bin/start +++ b/bin/start @@ -3,4 +3,4 @@ set -e npm install -g ./ -tsc +./node_modules/typescript/bin/tsc diff --git a/src/boilerplate/common/bin/setup b/src/boilerplate/common/bin/setup index 78fde5e90..fe58838cb 100644 --- a/src/boilerplate/common/bin/setup +++ b/src/boilerplate/common/bin/setup @@ -44,7 +44,7 @@ rm -rf proving-files perl -i -pe "s,docker-compose.zapp.yml -f docker-compose.zapp.override.yml,docker-compose.zapp.yml,g" package.json -if [[ $network == 'mumbai' ]] || [[ $network == 'sepolia' ]] || [[ $network == 'goerli' ]] +if [[ $network == 'amoy' ]] || [[ $network == 'sepolia' ]] || [[ $network == 'goerli' ]] then perl -i -pe "s,DEFAULT_ACCOUNT: '',DEFAULT_ACCOUNT: \'$account\',g" docker-compose.zapp.override.yml perl -i -pe "s,DEFAULT_ACCOUNT_MNEMONIC: '',DEFAULT_ACCOUNT_MNEMONIC: \'$mnemonic\',g" docker-compose.zapp.override.yml @@ -54,10 +54,10 @@ perl -i -pe "s,docker-compose.zapp.yml,docker-compose.zapp.yml -f docker-compose perl -i -pe "s,docker-compose -f docker-compose.zapp.yml up -d ganache, ## up ganache service for ganache,g" bin/startup fi -if [[ $network == 'mumbai' ]] +if [[ $network == 'amoy' ]] then -perl -i -pe "s,RPC_URL: '',RPC_URL: \'wss:\/\/rpc-mumbai.maticvigil.com\/ws\/v1\/$rpc\',g" docker-compose.zapp.override.yml -perl -i -pe "s,development_ganache,mumbai,g" entrypoint.sh +perl -i -pe "s,RPC_URL: '',RPC_URL: \'wss:\/\/polygon-amoy.g.alchemy.com\/v2\/$rpc\',g" docker-compose.zapp.override.yml +perl -i -pe "s,development_ganache,amoy,g" entrypoint.sh perl -i -pe "s,while,##while,g" entrypoint.sh perl -i -pe "s,10,60,g" bin/startup fi diff --git a/src/boilerplate/common/config/default.js b/src/boilerplate/common/config/default.js index 69cd2eb22..a483d2fde 100644 --- a/src/boilerplate/common/config/default.js +++ b/src/boilerplate/common/config/default.js @@ -88,7 +88,7 @@ module.exports = { port: process.env.BLOCKCHAIN_PORT, }, // web3: - web3: { + web3: { host: process.env.BLOCKCHAIN_HOST, port: process.env.BLOCKCHAIN_PORT, // url: `${process.env.BLOCKCHAIN_HOST}:${process.env.BLOCKCHAIN_PORT}`, @@ -96,19 +96,33 @@ module.exports = { rpcUrl: process.env.RPC_URL, defaultAccountMnemonic: process.env.DEFAULT_ACCOUNT_MNEMONIC, key: process.env.KEY, + autoReconnectInterval: process.env.BLOCKCHAIN_RECONNECT_INTERVAL || 1000, options: { // defaultAccount: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1', defaultAccount: process.env.DEFAULT_ACCOUNT, - defaultGas: 5221975, - defaultGasPrice: 20000000000, + defaultGas: 11511304, + defaultGasPrice: 30000000000, // defaultBlock: '0', // e.g. the genesis block our blockchain // defaultGas: 90000000, // defaultGasPrice: 20000000000, - // transactionBlockTimeout: 50, + transactionBlockTimeout: 150, // transactionConfirmationBlocks: 15, // transactionPollingTimeout: 480, // transactionSigner: new CustomTransactionSigner() + clientConfig: { + // Useful to keep a connection alive + keepalive: true, + // Keep keepalive interval small so that socket doesn't die + keepaliveInterval: -1, + }, + timeout: 0, + reconnect: { + auto: true, + delay: 5000, // ms + maxAttempts: 120, + onTimeout: false, + }, }, }, }; diff --git a/src/boilerplate/common/truffle-config.js b/src/boilerplate/common/truffle-config.js index e90b631ef..209b1ddfc 100644 --- a/src/boilerplate/common/truffle-config.js +++ b/src/boilerplate/common/truffle-config.js @@ -50,10 +50,12 @@ module.exports = { network_id: 1337, // Any network (default: none) gas: 10000000, }, - mumbai: { + amoy: { networkCheckTimeout: 10000, provider: () => new HDWalletProvider(mnemonic, rpcUrl), - network_id: 80001, + network_id: 80002, + gas:8500000, + gasPrice:30000000000, confirmations: 2, timeoutBlocks: 200, port: 8545,