From b8f30398a425be75113056830ff6f4fb787c996b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Uhl=C3=AD=C5=99?= Date: Mon, 7 Nov 2022 06:03:07 -0800 Subject: [PATCH] fix: invalid mode and gas block limit (#217) --- generator/package-lock.json | 102 +++++++++++++++++++------- generator/package.json | 2 +- generator/scripts/bee-docker-build.sh | 2 + generator/scripts/bee.sh | 2 + generator/scripts/blockchain.sh | 2 +- generator/scripts/gen-traffic.js | 27 ++----- 6 files changed, 87 insertions(+), 50 deletions(-) diff --git a/generator/package-lock.json b/generator/package-lock.json index 8ac95fd..35dc43c 100644 --- a/generator/package-lock.json +++ b/generator/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "license": "BSD-3-Clause", "dependencies": { - "@ethersphere/bee-js": "^3.3.4", + "@ethersphere/bee-js": "^5.0.0", "@openzeppelin/contracts": "^3.1.0", "truffle": "^5.6.3" } @@ -206,10 +206,11 @@ } }, "node_modules/@ethersphere/bee-js": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-3.3.4.tgz", - "integrity": "sha512-uxH0kR31tE8IKVON7jyQHANZ/5edlU8OUCz/qyRft1YeS+L4HzEHAD3bN58iE842nt6Iz/fekrJ7yk1ONIcDBg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-5.0.0.tgz", + "integrity": "sha512-Dr5Xon0UZvi37fvbyGj46kw3/0D8fydwfDtVtFHKi2p7mNEizG0uok2mXvwLZrMvUMOS8uXkFhbQjTFBjB+pWA==", "dependencies": { + "@ethersphere/swarm-cid": "^0.1.0", "@types/readable-stream": "^2.3.13", "bufferutil": "^4.0.6", "elliptic": "^6.5.4", @@ -222,13 +223,13 @@ "tar-js": "^0.3.0", "utf-8-validate": "^5.0.9", "web-streams-polyfill": "^4.0.0-beta.1", - "ws": "^8.5.0" + "ws": "^8.7.0" }, "engines": { - "bee": "1.5.1-d0a77598", - "beeApiVersion": "3.0.0", - "beeDebugApiVersion": "2.0.0", - "node": ">=12.0.0", + "bee": "1.7.0-bbf13011", + "beeApiVersion": "3.0.2", + "beeDebugApiVersion": "3.0.2", + "node": ">=14.0.0", "npm": ">=6.0.0" } }, @@ -246,9 +247,9 @@ } }, "node_modules/@ethersphere/bee-js/node_modules/ws": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", - "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", "engines": { "node": ">=10.0.0" }, @@ -265,6 +266,18 @@ } } }, + "node_modules/@ethersphere/swarm-cid": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@ethersphere/swarm-cid/-/swarm-cid-0.1.0.tgz", + "integrity": "sha512-n+n+w5RJBPm7CiPf8TIgNFIRMo4bLh5bYpZxHObgCaxFW8WNZ4UGfqg+qjS/jEr+A3Mmp0lugKDvd8GnfFy7JQ==", + "dependencies": { + "multiformats": "^9.5.4" + }, + "engines": { + "node": ">=12.0.0", + "npm": ">=6.0.0" + } + }, "node_modules/@ethersproject/abi": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz", @@ -2885,6 +2898,7 @@ "version": "0.4.1", "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.4.1.tgz", "integrity": "sha512-r4eRSeStEGf6M5SKdrQhhLK5bOwOBxQhIE3YSTnZE3GpKiLfnnhE+tPtrJE79+eDJgm39BM6LSoI8SCx4HbwlQ==", + "optional": true, "engines": { "node": ">=6" } @@ -4579,7 +4593,8 @@ "node_modules/immediate": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.3.0.tgz", - "integrity": "sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==" + "integrity": "sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==", + "optional": true }, "node_modules/inflight": { "version": "1.0.6", @@ -5370,6 +5385,7 @@ "resolved": "https://registry.npmjs.org/leveldown/-/leveldown-5.6.0.tgz", "integrity": "sha512-iB8O/7Db9lPaITU1aA2txU/cBEXAt4vWwKQRrrWuS6XDgbP4QZGj9BL2aNbwb002atoQ/lIotJkfyzz+ygQnUQ==", "hasInstallScript": true, + "optional": true, "dependencies": { "abstract-leveldown": "~6.2.1", "napi-macros": "~2.0.0", @@ -5383,6 +5399,7 @@ "version": "6.2.3", "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-6.2.3.tgz", "integrity": "sha512-BsLm5vFMRUrrLeCcRc+G0t2qOaTzpoJQLOubq2XM72eNpjF5UdU5o/5NvlNhx95XHcAvcl8OMXr4mlg/fRgUXQ==", + "optional": true, "dependencies": { "buffer": "^5.5.0", "immediate": "^3.2.3", @@ -5412,6 +5429,7 @@ "url": "https://feross.org/support" } ], + "optional": true, "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.1.13" @@ -5421,6 +5439,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/level-concat-iterator/-/level-concat-iterator-2.0.1.tgz", "integrity": "sha512-OTKKOqeav2QWcERMJR7IS9CUo1sHnke2C0gkSmcR7QuEtFNLLzHQAvnMw8ykvEcv0Qtkg0p7FOwP1v9e5Smdcw==", + "optional": true, "engines": { "node": ">=6" } @@ -5429,6 +5448,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/level-supports/-/level-supports-1.0.1.tgz", "integrity": "sha512-rXM7GYnW8gsl1vedTJIbzOrRv85c/2uCMpiiCzO2fndd06U/kUXEEU9evYn4zFggBOg36IsBW8LzqIpETwwQzg==", + "optional": true, "dependencies": { "xtend": "^4.0.2" }, @@ -5440,6 +5460,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.1.1.tgz", "integrity": "sha512-dSq1xmcPDKPZ2EED2S6zw/b9NKsqzXRE6dVr8TVQnI3FJOTteUMuqF3Qqs6LZg+mLGYJWqQzMbIjMtJqTv87nQ==", + "optional": true, "bin": { "node-gyp-build": "bin.js", "node-gyp-build-optional": "optional.js", @@ -6013,6 +6034,11 @@ "varint": "^5.0.0" } }, + "node_modules/multiformats": { + "version": "9.9.0", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-9.9.0.tgz", + "integrity": "sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==" + }, "node_modules/multihashes": { "version": "0.4.21", "resolved": "https://registry.npmjs.org/multihashes/-/multihashes-0.4.21.tgz", @@ -6064,7 +6090,8 @@ "node_modules/napi-macros": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.0.0.tgz", - "integrity": "sha512-A0xLykHtARfueITVDernsAWdtIMbOJgKgcluwENp3AlsKN/PloyO10HtmoqnFAQAcxPkgZN7wdfPfEd0zNGxbg==" + "integrity": "sha512-A0xLykHtARfueITVDernsAWdtIMbOJgKgcluwENp3AlsKN/PloyO10HtmoqnFAQAcxPkgZN7wdfPfEd0zNGxbg==", + "optional": true }, "node_modules/negotiator": { "version": "0.6.3", @@ -9102,10 +9129,11 @@ } }, "@ethersphere/bee-js": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-3.3.4.tgz", - "integrity": "sha512-uxH0kR31tE8IKVON7jyQHANZ/5edlU8OUCz/qyRft1YeS+L4HzEHAD3bN58iE842nt6Iz/fekrJ7yk1ONIcDBg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-5.0.0.tgz", + "integrity": "sha512-Dr5Xon0UZvi37fvbyGj46kw3/0D8fydwfDtVtFHKi2p7mNEizG0uok2mXvwLZrMvUMOS8uXkFhbQjTFBjB+pWA==", "requires": { + "@ethersphere/swarm-cid": "^0.1.0", "@types/readable-stream": "^2.3.13", "bufferutil": "^4.0.6", "elliptic": "^6.5.4", @@ -9118,7 +9146,7 @@ "tar-js": "^0.3.0", "utf-8-validate": "^5.0.9", "web-streams-polyfill": "^4.0.0-beta.1", - "ws": "^8.5.0" + "ws": "^8.7.0" }, "dependencies": { "js-sha3": { @@ -9132,13 +9160,21 @@ "integrity": "sha512-UHhhnoe2M40uh2r0KVdJTN7qjFytm6o0Yp3VcjwV3bfo6rz8uqvxNoE5yNmGF0y3eFfXaFeb6M09MDSwwLmq4w==" }, "ws": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", - "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", "requires": {} } } }, + "@ethersphere/swarm-cid": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@ethersphere/swarm-cid/-/swarm-cid-0.1.0.tgz", + "integrity": "sha512-n+n+w5RJBPm7CiPf8TIgNFIRMo4bLh5bYpZxHObgCaxFW8WNZ4UGfqg+qjS/jEr+A3Mmp0lugKDvd8GnfFy7JQ==", + "requires": { + "multiformats": "^9.5.4" + } + }, "@ethersproject/abi": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz", @@ -11210,7 +11246,8 @@ "emittery": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.4.1.tgz", - "integrity": "sha512-r4eRSeStEGf6M5SKdrQhhLK5bOwOBxQhIE3YSTnZE3GpKiLfnnhE+tPtrJE79+eDJgm39BM6LSoI8SCx4HbwlQ==" + "integrity": "sha512-r4eRSeStEGf6M5SKdrQhhLK5bOwOBxQhIE3YSTnZE3GpKiLfnnhE+tPtrJE79+eDJgm39BM6LSoI8SCx4HbwlQ==", + "optional": true }, "emoji-regex": { "version": "8.0.0", @@ -12477,7 +12514,8 @@ "immediate": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.3.0.tgz", - "integrity": "sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==" + "integrity": "sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==", + "optional": true }, "inflight": { "version": "1.0.6", @@ -13040,6 +13078,7 @@ "version": "5.6.0", "resolved": "https://registry.npmjs.org/leveldown/-/leveldown-5.6.0.tgz", "integrity": "sha512-iB8O/7Db9lPaITU1aA2txU/cBEXAt4vWwKQRrrWuS6XDgbP4QZGj9BL2aNbwb002atoQ/lIotJkfyzz+ygQnUQ==", + "optional": true, "requires": { "abstract-leveldown": "~6.2.1", "napi-macros": "~2.0.0", @@ -13050,6 +13089,7 @@ "version": "6.2.3", "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-6.2.3.tgz", "integrity": "sha512-BsLm5vFMRUrrLeCcRc+G0t2qOaTzpoJQLOubq2XM72eNpjF5UdU5o/5NvlNhx95XHcAvcl8OMXr4mlg/fRgUXQ==", + "optional": true, "requires": { "buffer": "^5.5.0", "immediate": "^3.2.3", @@ -13062,6 +13102,7 @@ "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "optional": true, "requires": { "base64-js": "^1.3.1", "ieee754": "^1.1.13" @@ -13070,12 +13111,14 @@ "level-concat-iterator": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/level-concat-iterator/-/level-concat-iterator-2.0.1.tgz", - "integrity": "sha512-OTKKOqeav2QWcERMJR7IS9CUo1sHnke2C0gkSmcR7QuEtFNLLzHQAvnMw8ykvEcv0Qtkg0p7FOwP1v9e5Smdcw==" + "integrity": "sha512-OTKKOqeav2QWcERMJR7IS9CUo1sHnke2C0gkSmcR7QuEtFNLLzHQAvnMw8ykvEcv0Qtkg0p7FOwP1v9e5Smdcw==", + "optional": true }, "level-supports": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/level-supports/-/level-supports-1.0.1.tgz", "integrity": "sha512-rXM7GYnW8gsl1vedTJIbzOrRv85c/2uCMpiiCzO2fndd06U/kUXEEU9evYn4zFggBOg36IsBW8LzqIpETwwQzg==", + "optional": true, "requires": { "xtend": "^4.0.2" } @@ -13083,7 +13126,8 @@ "node-gyp-build": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.1.1.tgz", - "integrity": "sha512-dSq1xmcPDKPZ2EED2S6zw/b9NKsqzXRE6dVr8TVQnI3FJOTteUMuqF3Qqs6LZg+mLGYJWqQzMbIjMtJqTv87nQ==" + "integrity": "sha512-dSq1xmcPDKPZ2EED2S6zw/b9NKsqzXRE6dVr8TVQnI3FJOTteUMuqF3Qqs6LZg+mLGYJWqQzMbIjMtJqTv87nQ==", + "optional": true } } }, @@ -13517,6 +13561,11 @@ "varint": "^5.0.0" } }, + "multiformats": { + "version": "9.9.0", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-9.9.0.tgz", + "integrity": "sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==" + }, "multihashes": { "version": "0.4.21", "resolved": "https://registry.npmjs.org/multihashes/-/multihashes-0.4.21.tgz", @@ -13555,7 +13604,8 @@ "napi-macros": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.0.0.tgz", - "integrity": "sha512-A0xLykHtARfueITVDernsAWdtIMbOJgKgcluwENp3AlsKN/PloyO10HtmoqnFAQAcxPkgZN7wdfPfEd0zNGxbg==" + "integrity": "sha512-A0xLykHtARfueITVDernsAWdtIMbOJgKgcluwENp3AlsKN/PloyO10HtmoqnFAQAcxPkgZN7wdfPfEd0zNGxbg==", + "optional": true }, "negotiator": { "version": "0.6.3", diff --git a/generator/package.json b/generator/package.json index dba23b5..2579725 100644 --- a/generator/package.json +++ b/generator/package.json @@ -13,7 +13,7 @@ "gen:traffic": "node ./scripts/gen-traffic.js" }, "dependencies": { - "@ethersphere/bee-js": "^3.3.4", + "@ethersphere/bee-js": "^5.0.0", "@openzeppelin/contracts": "^3.1.0", "truffle": "^5.6.3" }, diff --git a/generator/scripts/bee-docker-build.sh b/generator/scripts/bee-docker-build.sh index c88640b..a0438b8 100755 --- a/generator/scripts/bee-docker-build.sh +++ b/generator/scripts/bee-docker-build.sh @@ -69,11 +69,13 @@ fi ### BEE_VERSION ALERNATIONS END CONTRACT_ADDRESSES_LABELS="" +OLD_IFS=$IFS IFS=';' array=($CONTRACT_ADDRESSES) for element in "${array[@]}"; do CONTRACT_ADDRESSES_LABELS+=" --label org.ethswarm.beefactory.contracts.${element}" done +IFS=$OLD_IFS echo "Build Dockerfiles" for BEE_DIR in $BEE_DIRS diff --git a/generator/scripts/bee.sh b/generator/scripts/bee.sh index 0d3687c..5a45b09 100755 --- a/generator/scripts/bee.sh +++ b/generator/scripts/bee.sh @@ -204,11 +204,13 @@ if $EPHEMERAL ; then fi CONTRACT_ADDRESSES_ARGS="" +OLD_IFS=$IFS IFS=';' array=($CONTRACT_ADDRESSES) for element in "${array[@]}"; do CONTRACT_ADDRESSES_ARGS+=" --${element}" done +IFS=$OLD_IFS # Start Bee Queen if [ -z "$QUEEN_CONTAINER_IN_DOCKER" ] || $EPHEMERAL ; then diff --git a/generator/scripts/blockchain.sh b/generator/scripts/blockchain.sh index f4d3d73..e7a9a76 100755 --- a/generator/scripts/blockchain.sh +++ b/generator/scripts/blockchain.sh @@ -21,7 +21,7 @@ if [ -z "$CONTAINER_IN_DOCKER" ]; then --wallet.deterministic --chain.networkId 4020 -h 0.0.0.0 -p 9545 \ --miner.blockTime 2 \ --chain.chainId 4020 \ - --database.dbPath swarm-testchain --miner.blockGasLimit 6721975 + --database.dbPath swarm-testchain --miner.blockGasLimit 16721975 else docker start $NAME fi diff --git a/generator/scripts/gen-traffic.js b/generator/scripts/gen-traffic.js index d809927..9d39c63 100644 --- a/generator/scripts/gen-traffic.js +++ b/generator/scripts/gen-traffic.js @@ -17,7 +17,7 @@ class BeePair { const SLEEP_BETWEEN_UPLOADS_MS = 1000 const POSTAGE_STAMPS_AMOUNT = '10000' -const POSTAGE_STAMPS_DEPTH = 32 +const POSTAGE_STAMPS_DEPTH = 22 /** * Lehmer random number generator with seed (minstd_rand in C++11) @@ -57,22 +57,6 @@ async function uploadRandomBytes(beePair, seed = 500, bytes = 1024 * 4 * 400) { console.log(`${beePair.uploaderBee.url} uploaded ${bytes} bytes to ${reference}`) } -const DEFAULT_POLLING_FREQUENCY = 1_000 -const DEFAULT_STAMP_USABLE_TIMEOUT = 120_000 -async function waitUntilStampUsable(batchId, beeDebug, options = {}) { - const timeout = options?.timeout || DEFAULT_STAMP_USABLE_TIMEOUT - const pollingFrequency = options?.pollingFrequency || DEFAULT_POLLING_FREQUENCY - - for (let i = 0; i < timeout; i += pollingFrequency) { - const stamp = await beeDebug.getPostageBatch(batchId) - - if (stamp.usable) return stamp - await sleep(pollingFrequency) - } - - throw new Error('Wait until stamp usable timeout has been reached') -} - /** * Generate traffic on Bee node(s) * @@ -107,11 +91,10 @@ async function genTrafficLoop(hosts, minCheques) { const uploaderBeeDebug = new BeeDebug(uploaderBeeDebugUrl) console.log(`Creating postage stamp on ${uploaderBeeDebugUrl}...`) - const postageBatchId = await uploaderBeeDebug.createPostageBatch(POSTAGE_STAMPS_AMOUNT, POSTAGE_STAMPS_DEPTH) - console.log(`Generated ${postageBatchId} postage stamp on ${uploaderBeeDebugUrl}. Waiting until it is usable.`) - - await waitUntilStampUsable(postageBatchId, uploaderBeeDebug) - console.log('Postage stamp usable.') + const postageBatchId = await uploaderBeeDebug.createPostageBatch(POSTAGE_STAMPS_AMOUNT, POSTAGE_STAMPS_DEPTH, { + waitForUsable: true, + }) + console.log(`Generated ${postageBatchId} postage stamp on ${uploaderBeeDebugUrl}.`) return new BeePair(chequeReceiverBeeDebug, uploaderBee, uploaderBeeDebug, postageBatchId) })