diff --git a/packages/core/examples/simple-asset-transfer/quorum/api/scripts/deploy-contracts.js b/packages/core/examples/simple-asset-transfer/quorum/api/scripts/deploy-contracts.js index a12bc6a0c19..b7531427b07 100755 --- a/packages/core/examples/simple-asset-transfer/quorum/api/scripts/deploy-contracts.js +++ b/packages/core/examples/simple-asset-transfer/quorum/api/scripts/deploy-contracts.js @@ -38,6 +38,9 @@ module.exports = (async () => { } tryCount += 1; } + if (notSuccessful) { + throw new Error(`Failed to deploy contracts after ${maxTries} attempts. See logs above for details.`); + } if (config.env !== 'test') { /* Forcibly exit the process as we suspect that web3.js may leave dangling open network connections that prevent normal exit. */ diff --git a/packages/core/examples/simple-asset-transfer/quorum/api/utils/contracts.js b/packages/core/examples/simple-asset-transfer/quorum/api/utils/contracts.js index c14a97a2c19..ed2a9ea32fd 100644 --- a/packages/core/examples/simple-asset-transfer/quorum/api/utils/contracts.js +++ b/packages/core/examples/simple-asset-transfer/quorum/api/utils/contracts.js @@ -51,16 +51,20 @@ const Contracts = { }, async newPublicContract(contractObject, ...contractArguments) { - const newContract = await contractObject - .deploy({ - arguments: contractArguments, - }) - .send({ - from: web3Ws.eth.defaultAccount, - gas: 10000000, - }) - .on('transactionHash', txHash => logger.log('info', `newPublicContract: txHash:${txHash}`)); - logger.log('debug', `newPublicContract: ${newContract.options.address}`); + const deployTask = contractObject.deploy({ arguments: contractArguments }); + const gasEstimate = await deployTask.estimateGas({ + from: web3Ws.eth.defaultAccount, + gas: 10000000, + }); + const gas = gasEstimate * 3; // offer triple the gas estimate to be sure + const taskPayload = { + from: web3Ws.eth.defaultAccount, + gas, + }; + logger.info(`newPublicContract: gasEstimate=%s taskPayload=%s`, gasEstimate, JSON.stringify(taskPayload)); + const newContract = await deployTask.send(taskPayload); + + logger.log('debug', `newPublicContract: deployment DONE. address=${newContract.options.address}`); return newContract; }, diff --git a/packages/core/examples/simple-asset-transfer/quorum/api/wrappers/actor.wrapper.js b/packages/core/examples/simple-asset-transfer/quorum/api/wrappers/actor.wrapper.js index 9ae8604b76d..f484f4d89ef 100644 --- a/packages/core/examples/simple-asset-transfer/quorum/api/wrappers/actor.wrapper.js +++ b/packages/core/examples/simple-asset-transfer/quorum/api/wrappers/actor.wrapper.js @@ -22,12 +22,17 @@ async function registerActor({ name, type, constKey, ethAddress, host, port }) { host, port ); - const receipt = await rootContract.methods - .registerActor(name, constKey, ethAddress, ActorTypes[type], host, port) - .send({ - from: web3.eth.defaultAccount, - gas: 3000000, - }); + const actorRegistrationTask = rootContract.methods + .registerActor(name, constKey, ethAddress, ActorTypes[type], host, port); + + const gasEstimate = await actorRegistrationTask.estimateGas(); + const gas = gasEstimate * 3; // offer triple the gas estimate to be sure + const taskPayload = { + from: web3.eth.defaultAccount, + gas, + }; + logger.info(`registerActor gasEstimate=%s taskPayload=%s`, gasEstimate, JSON.stringify(taskPayload)); + const receipt = await actorRegistrationTask.send(taskPayload); logger.log('debug', 'registerActor receipt %j', receipt); return receipt; } diff --git a/packages/core/examples/simple-asset-transfer/quorum/platform/docker-compose.yml b/packages/core/examples/simple-asset-transfer/quorum/platform/docker-compose.yml index 9708e29f841..5b923299897 100644 --- a/packages/core/examples/simple-asset-transfer/quorum/platform/docker-compose.yml +++ b/packages/core/examples/simple-asset-transfer/quorum/platform/docker-compose.yml @@ -10,7 +10,7 @@ version: "3.6" x-quorum-def: &quorum-def restart: "on-failure" - image: "${QUORUM_DOCKER_IMAGE:-quorumengineering/quorum:2.3.0}" + image: "${QUORUM_DOCKER_IMAGE:-quorumengineering/quorum:2.2.5}" expose: - "21000" - "50400" @@ -71,6 +71,10 @@ x-quorum-def: --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,${QUORUM_CONSENSUS:-istanbul} \ --port 21000 \ --unlock 0 \ + --mine \ + --miner.threads 1 \ + --miner.gaslimit 60000000 \ + --miner.gastarget 10 \ --password /examples/passwords.txt \ ${QUORUM_GETH_ARGS:-} $${GETH_ARGS_${QUORUM_CONSENSUS:-istanbul}} x-tx-manager-def: