feat: bee 1.0.0 (#41)

* feat: new Price Oracle bytecode

* refactor: remove file smth.txt

* feat: new PostageStamp contract

* feat: change contract deploy workflow

* feat: bee-1.0.0-rc2 compatible runner

* feat: build from source (#47)

* feat: extend build-envrionment.sh with building bee image from source

* ci: new workflow option parameter - beeVersionAsCommitHash

* fix(ci): try to overwrite BEE_VERSION sys variable

* fix: do not export BEE_VERSION after env build

* fix(ci): run build-environment without source command

* fix(ci): try to retrieve built BEE_VERSION value

* fix: save build BEE_VERSION value

* fix(ci): retrieve built image tag in the last step

* refactor: echoerr

* refactor(ci): export sys variables

* feat: disable warmup time (#46)

* feat: disable warmup time

* fix: place warmup-time to the correct place

* fix: put quote back where it truly belongs

* feat: state commit (#45)

* refactor: remove payment treshold option because it causes performance issues

* docs: design planned parameters for the new build workflow

* feat: build environment with traffic gen option

* fix(log): rephrase traffic gen log

* feat: special bee version tagging when state commit happens

* build: new env variable STATE_COMMIT

* ci: STATE_COMMIT

* feat: state commit scripts

* refactor: destroy containers after state producing

* refactor: remove unnecessary echo

* fix: blockchain version at state commit

* build: bumo bee-js version

* build: update package-lock

* fix: fixes

* ci: build environment workflow with state commit

* refactor: buy larger stamp

* fix: publish workflow

* refactor: increase stamp depth

* fix: bee version fetch at commit

* refactor: start containers normally instead of ephemeral for debugging

* fix(ci): add chown for bee user on bee-data-dirs in order to write bee state

* fix: try out the permission on bee data dir with 777 chmod

* fix(ci): give folder permission in the build environment phrase

* refactor(ci): raise sleep between uploads in order to generate cheques

* refactor: wait 11 secs after batch purchase

* fix: commit version tag string true instead of boolean

* fix: add state commit check for set COMMIT_VERSION_TAG

* chore: bump bee version

Co-authored-by: Cafe137 <77121044+Cafe137@users.noreply.github.com>
This commit is contained in:
nugaon 2021-06-21 16:10:55 +02:00 committed by GitHub
parent e163745839
commit b8e451e57e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 241 additions and 60 deletions

View File

@ -2,14 +2,20 @@ on:
workflow_dispatch:
inputs:
buildImage:
description: 'Build Docker Image according to the environment'
description: 'Build and push Docker Image according to the environment'
default: 'false'
commitVersionTag:
description: 'The image tag will be retrieved from the bee version command'
default: 'false'
beeVersion:
description: 'The official bee image tag that the image will be built on. Default: last supported version'
default: '0.5.3'
default: 'latest'
beeVersionAsCommitHash:
description: 'The beeVersion parameter will be interpreted as a source code commit hash that the bee base image will be built on'
default: 'false'
stateCommit:
description: 'The images will have cheques by the traffic generation'
default: 'false'
push:
branches:
- 'master'
@ -21,6 +27,8 @@ env:
BEE_IMAGE_PREFIX: 'docker.pkg.github.com/ethersphere/bee-factory'
COMMIT_VERSION_TAG: ${{ github.event.inputs.commitVersionTag }}
BEE_VERSION: ${{ github.event.inputs.beeVersion }}
BUILD_IMAGE: ${{ github.event.inputs.beeVersionAsCommitHash }}
STATE_COMMIT: ${{ github.event.inputs.stateCommit }}
jobs:
bee-images:
@ -44,7 +52,14 @@ jobs:
run: npm ci
- name: Build images
run: |
npm run build:env
BUILD_PARAMS=""
if [ $BUILD_IMAGE == 'true' ] ; then
BUILD_PARAMS+=" --build-base-bee --base-bee-commit-hash=$BEE_VERSION"
fi
if [ $STATE_COMMIT == 'true' ] ; then
BUILD_PARAMS+=" --gen-traffic"
fi
npm run build:env -- $BUILD_PARAMS
- name: Publish if it was clicked manually
if: ${{ github.event.inputs.buildImage == 'true' && success() }}
run: |

4
.gitignore vendored
View File

@ -1,2 +1,4 @@
node_modules/
build/
build/
# In case of building bee image, the bee source code will be cloned to this folder
bee/

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
0x608060405234801561001057600080fd5b506040516104b83803806104b883398101604081905261002f9161007e565b600080546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001919091556002556100a1565b60008060408385031215610090578182fd5b505080516020909101519092909150565b610408806100b06000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806398d5fdca1161005b57806398d5fdca146100dd578063a035b1fe146100f8578063dd4899321461010f578063f2fde38b1461011857600080fd5b8063710f2dd11461008d578063715018a6146100a25780638d6cc56d146100aa5780638da5cb5b146100bd575b600080fd5b6100a061009b366004610385565b61012b565b005b6100a061019a565b6100a06100b8366004610385565b61020e565b6000546040516001600160a01b0390911681526020015b60405180910390f35b600154600254604080519283526020830191909152016100d4565b61010160015481565b6040519081526020016100d4565b61010160025481565b6100a0610126366004610357565b61026d565b6000546001600160a01b0316331461015e5760405162461bcd60e51b81526004016101559061039d565b60405180910390fd5b60028190556040518181527f0f45948e42a1e34f851df8452200e744563dae2029a99b8178ff6530458bd3df906020015b60405180910390a150565b6000546001600160a01b031633146101c45760405162461bcd60e51b81526004016101559061039d565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146102385760405162461bcd60e51b81526004016101559061039d565b60018190556040518181527fae46785019700e30375a5d7b4f91e32f8060ef085111f896ebf889450aa2ab5a9060200161018f565b6000546001600160a01b031633146102975760405162461bcd60e51b81526004016101559061039d565b6001600160a01b0381166102fc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610155565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600060208284031215610368578081fd5b81356001600160a01b038116811461037e578182fd5b9392505050565b600060208284031215610396578081fd5b5035919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260408201526060019056fea264697066735822122069737c178b79be7973d71a433150ff2571d211a983a7f5a5ba0f7dba3d57fd7664736f6c63430008040033

View File

@ -7,6 +7,10 @@ function prefixedAddressParamToByteCode(address) {
return address.substring(2).toLowerCase().padStart(64, '0')
}
function intToByteCode(intParam) {
return Number(intParam).toString(16).padStart(64, '0')
}
function getSimpleSwapFactoryBin(tokenAddress) {
const binPath = Path.join(__dirname, '..', 'contracts', 'SimpleSwapFactory.bytecode')
const bin = FS.readFileSync(binPath, 'utf8').toString()
@ -23,6 +27,15 @@ function getPostageStampBin(tokenAddress) {
return bin + tokenAddress
}
function getPriceOracleBin(price, chequeValueDeduction) {
const binPath = Path.join(__dirname, '..', 'contracts', 'PriceOracle.bytecode')
const bin = FS.readFileSync(binPath, 'utf8').toString()
const priceAbi = intToByteCode(price)
const chequeValueAbi = intToByteCode(chequeValueDeduction)
//add tokenaddress for param to the end of the bytecode
return bin + priceAbi + chequeValueAbi
}
/** Returns back contract hash */
async function createContract(contractName, data, creatorAccount) {
const transaction = await web3.eth.sendTransaction({
@ -51,9 +64,20 @@ async function createPostageStampContract(erc20ContractAddress, creatorAccount)
return createContract('PostageStamp', getPostageStampBin(erc20ContractAddress), creatorAccount)
}
/**
*
* @param {number} price current price in PLUR per accounting unit
* @param {number} chequeValueDeduction value deducted from first received cheque from a peer in PLUR
* @param {string} creatorAccount
*/
async function createPriceOracleContract(price, chequeValueDeduction, creatorAccount) {
return createContract('PriceOracle', getPriceOracleBin(price, chequeValueDeduction), creatorAccount)
}
module.exports = function (deployer, network, accounts) {
deployer.deploy(ERC20PresetMinterPauser, "Swarm Token", "BZZ").then(async () => {
await createSimpleSwapFactoryContract(ERC20PresetMinterPauser.address, accounts[0])
await createPostageStampContract(ERC20PresetMinterPauser.address, accounts[0])
await createPriceOracleContract(100000, 1, accounts[0])
});
};

52
package-lock.json generated
View File

@ -8,7 +8,7 @@
"version": "0.0.1",
"license": "BSD-3-Clause",
"dependencies": {
"@ethersphere/bee-js": "github:ethersphere/bee-js#bee-0.6.0",
"@ethersphere/bee-js": "0.12.0",
"@openzeppelin/contracts": "^3.1.0",
"axios": "^0.20.0",
"truffle": "^5.3.5"
@ -1038,20 +1038,19 @@
}
},
"node_modules/@ethersphere/bee-js": {
"version": "0.8.1",
"resolved": "git+ssh://git@github.com/ethersphere/bee-js.git#94836afaebae98728a8136365a7e2fe7e9bc9526",
"license": "BSD-3-Clause",
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-0.12.0.tgz",
"integrity": "sha512-fpZjbjIU5pxuGGo6nvVyAkEvCNSYIuoUb5fyaaIyZ+czswEkVm5oPeEfNvF703EWnar6kcAjCpAOs+dLWwLKAg==",
"dependencies": {
"axios": "^0.21.1",
"elliptic": "^6.5.4",
"isomorphic-ws": "^4.0.1",
"js-sha3": "^0.8.0",
"json-bigint": "^1.0.0",
"tar-js": "^0.3.0",
"ws": "^7.4.4"
},
"engines": {
"bee": "0.6.0-17f7837-dirty",
"bee": "1.0.0-3a92ef5-dirty",
"node": ">=12.0.0",
"npm": ">=6.0.0"
}
@ -5862,6 +5861,7 @@
"dependencies": {
"anymatch": "~3.1.1",
"braces": "~3.0.2",
"fsevents": "~2.1.2",
"glob-parent": "~5.1.0",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
@ -7281,7 +7281,8 @@
"esprima": "^4.0.1",
"estraverse": "^4.2.0",
"esutils": "^2.0.2",
"optionator": "^0.8.1"
"optionator": "^0.8.1",
"source-map": "~0.6.1"
},
"bin": {
"escodegen": "bin/escodegen.js",
@ -7341,6 +7342,9 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"dependencies": {
"graceful-fs": "^4.1.6"
},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
@ -9015,6 +9019,7 @@
"dom-serializer": "~0.1.0",
"entities": "~1.1.1",
"htmlparser2": "~3.8.1",
"jsdom": "^7.0.2",
"lodash": "^4.1.0"
},
"engines": {
@ -10176,14 +10181,6 @@
"node": ">=4"
}
},
"node_modules/json-bigint": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz",
"integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
"dependencies": {
"bignumber.js": "^9.0.0"
}
},
"node_modules/json-buffer": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz",
@ -10275,6 +10272,7 @@
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"optional": true,
"dependencies": {
"graceful-fs": "^4.1.6",
"universalify": "^2.0.0"
},
"optionalDependencies": {
@ -15747,6 +15745,9 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"dependencies": {
"graceful-fs": "^4.1.6"
},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
@ -16086,7 +16087,12 @@
"integrity": "sha512-qdvaZzKc5WxnWS6qW7hpAo4aAphAtQfJYnr2hv7FftbycgOv7lemtIPxcd91+/3eZAIGM6hmCjbFYXgEyyaIkQ==",
"hasInstallScript": true,
"dependencies": {
"@truffle/db": "^0.5.11",
"@truffle/debugger": "^8.0.25",
"@truffle/preserve-fs": "^0.2.2",
"@truffle/preserve-to-buckets": "^0.2.2",
"@truffle/preserve-to-filecoin": "^0.2.2",
"@truffle/preserve-to-ipfs": "^0.2.2",
"app-module-path": "^2.2.0",
"mocha": "8.1.2",
"original-require": "^1.0.1"
@ -16679,6 +16685,7 @@
"integrity": "sha512-HYLeVCdJ0+lBYV2FvNZmv3HJ2Nt0QYXqZojk3d9FJOLkwnuhzM9tmamh8d7HPM8QqjKH8DeHkFTx+CFlWpZZDA==",
"optional": true,
"dependencies": {
"@zxing/text-encoding": "0.9.0",
"util": "^0.12.3"
},
"optionalDependencies": {
@ -18571,14 +18578,14 @@
}
},
"@ethersphere/bee-js": {
"version": "git+ssh://git@github.com/ethersphere/bee-js.git#94836afaebae98728a8136365a7e2fe7e9bc9526",
"from": "@ethersphere/bee-js@github:ethersphere/bee-js#bee-0.6.0",
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-0.12.0.tgz",
"integrity": "sha512-fpZjbjIU5pxuGGo6nvVyAkEvCNSYIuoUb5fyaaIyZ+czswEkVm5oPeEfNvF703EWnar6kcAjCpAOs+dLWwLKAg==",
"requires": {
"axios": "^0.21.1",
"elliptic": "^6.5.4",
"isomorphic-ws": "^4.0.1",
"js-sha3": "^0.8.0",
"json-bigint": "^1.0.0",
"tar-js": "^0.3.0",
"ws": "^7.4.4"
},
@ -22376,6 +22383,7 @@
"integrity": "sha512-FeXxO37BLV5JRvxPmVFB91zRHalavV8H4TdQGt1/hz0AkoPymIV68OkuB+TptpjeYgatcgKPoPvPhglJkTzFQQ==",
"optional": true,
"requires": {
"bitcore-lib": "^8.25.10",
"unorm": "^1.4.1"
}
},
@ -26496,14 +26504,6 @@
"integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==",
"optional": true
},
"json-bigint": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz",
"integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
"requires": {
"bignumber.js": "^9.0.0"
}
},
"json-buffer": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz",

View File

@ -12,7 +12,7 @@
"gen:traffic": "node ./scripts/gen-traffic.js"
},
"dependencies": {
"@ethersphere/bee-js": "0.10.0",
"@ethersphere/bee-js": "0.12.0",
"@openzeppelin/contracts": "^3.1.0",
"axios": "^0.20.0",
"truffle": "^5.3.5"

View File

@ -1,5 +1,6 @@
BEE_VERSION="0.6.0"
BLOCKCHAIN_VERSION="1.1.1"
BEE_VERSION="1.0.0"
BLOCKCHAIN_VERSION="1.2.0"
BEE_ENV_PREFIX="swarm-test"
BEE_IMAGE_PREFIX="docker.pkg.github.com/ethersphere/bee-factory"
COMMIT_VERSION_TAG="false"
STATE_COMMIT="false"

View File

@ -20,6 +20,7 @@ MY_PATH=$( cd "$MY_PATH" && pwd )
BEE_DIRS=$(ls -d "$MY_PATH"/bee-data-dirs/*/)
BEE_VERSION=$("$MY_PATH/utils/env-variable-value.sh" BEE_VERSION)
BEE_IMAGE_PREFIX=$("$MY_PATH/utils/env-variable-value.sh" BEE_IMAGE_PREFIX)
STATE_COMMIT=$("$MY_PATH/utils/env-variable-value.sh" STATE_COMMIT)
OFFICIAL_BEE_IMAGE="ethersphere/bee:$BEE_VERSION"
# Make sure we the user has permission all the files
@ -30,20 +31,33 @@ sudo chmod 777 -R "$MY_PATH/bee-data-dirs"
echo "Update common dockerfile"
dockerfile "$MY_PATH/bee-data-dirs/Dockerfile" "$BEE_VERSION"
### BEE_VERSION ALTERNATIONS START
# If the user has been set the COMMIT_VERSION_TAG env variable
# The image will be built with the tag that is the bee version string
COMMIT_VERSION_TAG="$("$MY_PATH/utils/env-variable-value.sh" COMMIT_VERSION_TAG)"
if [ "$COMMIT_VERSION_TAG" == "true" ] ; then
echo "Image version tag will be extracted from the bee version command..."
docker pull $OFFICIAL_BEE_IMAGE
# somehow the version command's output goes to the stderr
BEE_VERSION=$(docker run --rm $OFFICIAL_BEE_IMAGE version 2>&1)
echo "Extracted Bee version: $BEE_VERSION"
"$MY_PATH/utils/build-image-tag.sh" set "$BEE_VERSION"
fi
if [ "$STATE_COMMIT" == 'true' ] ; then
echo "The bee image will be built with their state"
BEE_VERSION+="-stateful"
"$MY_PATH/utils/build-image-tag.sh" set "$BEE_VERSION"
echo "Stateful Bee version: $BEE_VERSION"
fi
### BEE_VERSION ALERNATIONS END
echo "Build Dockerfiles"
for BEE_DIR in $BEE_DIRS
do
echo "$BEE_DIR"
echo "Build Bee version $BEE_VERSION on $BEE_DIR"
dockerbuild "$BEE_DIR" "$MY_PATH/bee-data-dirs/Dockerfile" "$BEE_VERSION" "$BEE_IMAGE_PREFIX"
done

View File

@ -21,7 +21,6 @@ PARAMETERS:
--own-image If passed, the used Docker image names will be identical as the name of the workers.
--version=x.y.z used version of Bee client.
--detach It will not log the output of Queen node at the end of the process.
--payment-threshold The threshold in BZZ where you expect to get paid from your peers. (without decimals, default: 310000000000)
USAGE
exit 1
}
@ -107,8 +106,8 @@ PORT_MAPS=2
SWAP=true
SWAP_FACTORY_ADDRESS="0x5b1869D9A4C187F2EAa108f3062412ecf0526b24"
POSTAGE_STAMP_ADDRESS="0xCfEB869F69431e42cdB54A4F4f105C19C080A601"
PRICE_ORACLE_ADDRESS="0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B"
INIT_ROOT_DATA_DIR="$MY_PATH/bee-data-dirs"
PAYMENT_THRESHOLD="310000000000"
# Decide script action
case "$1" in
@ -148,10 +147,6 @@ do
PORT_MAPS="${1#*=}"
shift 1
;;
--payment-treshold=*)
PAYMENT_THRESHOLD="${1#*=}"
shift 1
;;
--own-image)
OWN_IMAGE=true
shift 1
@ -197,6 +192,7 @@ if [ -z "$QUEEN_CONTAINER_IN_DOCKER" ] || $EPHEMERAL ; then
$EXTRA_QUEEN_PARAMS \
$DOCKER_IMAGE \
start \
--warmup-time=0 \
--password "$BEE_PASSWORD" \
--bootnode="$QUEEN_BOOTNODE" \
--debug-api-enable \
@ -204,8 +200,8 @@ if [ -z "$QUEEN_CONTAINER_IN_DOCKER" ] || $EPHEMERAL ; then
--swap-enable=$SWAP \
--swap-endpoint="http://$SWARM_BLOCKCHAIN_NAME:9545" \
--swap-factory-address=$SWAP_FACTORY_ADDRESS \
--payment-threshold="$PAYMENT_THRESHOLD" \
--postage-stamp-address=$POSTAGE_STAMP_ADDRESS \
--price-oracle-address=$PRICE_ORACLE_ADDRESS \
--network-id 4020 \
--full-node=true \
--welcome-message="You have found the queen of the beehive..." \
@ -246,14 +242,15 @@ for i in $(seq 1 1 "$WORKERS"); do
$EXTRA_WORKER_PARAMS \
$DOCKER_IMAGE \
start \
--warmup-time=0 \
--password "$BEE_PASSWORD" \
--bootnode="$QUEEN_UNDERLAY_ADDRESS" \
--debug-api-enable \
--swap-enable=$SWAP \
--swap-endpoint="http://$SWARM_BLOCKCHAIN_NAME:9545" \
--swap-factory-address=$SWAP_FACTORY_ADDRESS \
--payment-threshold="$PAYMENT_THRESHOLD" \
--postage-stamp-address=$POSTAGE_STAMP_ADDRESS \
--price-oracle-address=$PRICE_ORACLE_ADDRESS \
--network-id 4020 \
--full-node=true \
--welcome-message="I'm just Bee worker ${i} in the beehive." \

View File

@ -5,6 +5,14 @@ MY_PATH=$( cd "$MY_PATH" && pwd )
BEE_ENV_PREFIX=$("$MY_PATH/utils/env-variable-value.sh" BEE_ENV_PREFIX)
BEE_IMAGE_PREFIX=$("$MY_PATH/utils/env-variable-value.sh" BEE_IMAGE_PREFIX)
BLOCKCHAIN_VERSION=$("$MY_PATH/utils/env-variable-value.sh" BLOCKCHAIN_VERSION)
STATE_COMMIT=$("$MY_PATH/utils/env-variable-value.sh" STATE_COMMIT)
if [ "$STATE_COMMIT" == 'true' ] ; then
export COMMIT_VERSION_TAG='true'
BEE_VERSION=$("$MY_PATH/utils/build-image-tag.sh" get)
BLOCKCHAIN_VERSION+="-for-$BEE_VERSION"
echo "Blockchain will have image version: $BLOCKCHAIN_VERSION"
fi
NAME="$BEE_ENV_PREFIX-blockchain"

View File

@ -1,10 +1,120 @@
#!/bin/bash
usage() {
cat << USAGE >&2
USAGE:
$ build-environment.sh [PARAMETERS]
PARAMETERS:
--build-base-bee The base bee image will be built from source code
--base-bee-commit-hash=string the source code commit hash of the base bee; Default: HEAD; Dependency: --build-base-bee
--gen-traffic Generate traffic before bee image commit.
--gen-traffic-upload-node=string The traffic will be generated on the node under the given API URL. Default: http://locahost:1633; Dependency: --gen-traffic
--gen-traffic-checker-node=string The incoming cheques will be checked on the node under the given Debug API URL. Default: http://localhost:11635; Dependency: --gen-traffic
--cheques-count=number this amount of cheques is intended to be generated by the traffic gen. Default: 1; Dependency: --gen-traffic
USAGE
exit 1
}
echoerr() {
>&2 echo "$@"
}
build_bee() {
# Clone source code
BEE_SOURCE_PATH=$MY_PATH/../bee
if [ -d "$BEE_SOURCE_PATH" ] ; then
rm -rf "$BEE_SOURCE_PATH"
fi
mkdir "$BEE_SOURCE_PATH" && cd "$BEE_SOURCE_PATH" || exit 1
git init
git remote add origin https://github.com/ethersphere/bee.git
git fetch origin --depth=1 "$COMMIT_HASH"
git reset --hard FETCH_HEAD
# Build bee and make docker image
export BEE_VERSION=${COMMIT_HASH::7}-commit
make binary
echo "Bee image will be built with version: $BEE_VERSION"
docker build . -t ethersphere/bee:$BEE_VERSION
cd "$MY_PATH" || exit 1
# Set build image tag so that other terminal session can retrieve
"$MY_PATH/utils/build-image-tag.sh" set "$BEE_VERSION"
}
# the image label for the produced bee images in case of state commitment
stateful_image_label() {
echo "$BEE_VERSION-stateful"
}
MY_PATH=$(dirname "$0")
MY_PATH=$( cd "$MY_PATH" && pwd )
COMMIT_HASH=HEAD
BUILD_BASE_BEE=false
GEN_TRAFFIC=false
GEN_TRAFFIC_UPLOAD_NODE="http://localhost:1633"
GEN_TRAFFIC_CHECKER_NODE="http://localhost:11635"
CHEQUES_COUNT=1
# Bee version here means the base bee version on which the images will be built
BEE_VERSION=$("$MY_PATH/utils/env-variable-value.sh" BEE_VERSION)
SUPPORTED_WORKER_N=4
# handle passed options
while [ $# -gt 0 ]
do
case "$1" in
--build-base-bee)
BUILD_BASE_BEE=true
shift 1
;;
--base-bee-commit-hash=*)
COMMIT_HASH="${1#*=}"
shift 1
;;
--gen-traffic)
GEN_TRAFFIC=true
shift 1
;;
--cheques-count=*)
CHEQUES_COUNT=${1#*=}
shift 1
;;
--gen-traffic-upload-node=*)
GEN_TRAFFIC_UPLOAD_NODE="${1#*=}"
shift 1
;;
--gen-traffic-checker-node=*)
GEN_TRAFFIC_CHECKER_NODE="${1#*=}"
shift 1
;;
*)
echoerr "Unknown argument: $1"
usage
;;
esac
done
# cleanup for start from an empty state
"$MY_PATH/bee-cleanup.sh"
if $BUILD_BASE_BEE ; then
build_bee
fi
"$MY_PATH/network.sh"
"$MY_PATH/blockchain.sh"
npm run migrate:contracts
npm run supply
"$MY_PATH/blockchain-docker-build.sh"
if $GEN_TRAFFIC ; then
export STATE_COMMIT='true'
echo "Bee image with special state will be commited... traffic generation is on."
# give the permission to the bee user
BEE_DIR_PATH="$MY_PATH/bee-data-dirs/"
sudo chown 999:999 -R "$BEE_DIR_PATH"
echo "Start Bee nodes so that traffic can be generated and commited to the images"
"$MY_PATH/bee.sh" start --workers=$SUPPORTED_WORKER_N --detach
echo "Generating traffic on Bee node $GEN_TRAFFIC_UPLOAD_NODE"
echo "Run traffic generation until $CHEQUES_COUNT incoming cheques will arrive to node under Debug API $GEN_TRAFFIC_CHECKER_NODE"
npm run gen:traffic -- "$CHEQUES_COUNT" "$GEN_TRAFFIC_UPLOAD_NODE;$GEN_TRAFFIC_CHECKER_NODE"
echo "traffic has been generated, stop nodes before commit..."
"$MY_PATH/bee.sh" stop
docker container prune -f
fi
"$MY_PATH/bee-docker-build.sh"
"$MY_PATH/blockchain-docker-build.sh"

View File

@ -10,7 +10,6 @@ PARAMETERS:
--ephemeral create ephemeral container for bee-client. Data won't be persisted.
--workers=number all Bee nodes in the test environment. Default is 4.
--detach It will not log the output of Queen node at the end of the process.
--payment-treshold excess debt above payment threshold in BZZ where you disconnect from your peer (without decimals, default: 310000000000)
--port-maps=number map ports of the cluster nodes to the hosting machine in the following manner:
1. 1633:1635
2. 11633:11635
@ -44,7 +43,6 @@ WORKERS=4
LOG=true
SWARM_BLOCKCHAIN_NAME="$BEE_ENV_PREFIX-blockchain"
SWARM_NETWORK="$BEE_ENV_PREFIX-network"
PAYMENT_THRESHOLD="310000000000"
PORT_MAPS=2
# Decide script action
@ -74,10 +72,6 @@ do
WORKERS=${1#*=}
shift 1
;;
--payment-treshold=*)
PAYMENT_THRESHOLD=${1#*=}
shift 1
;;
--port-maps=*)
PORT_MAPS="${1#*=}"
shift 1
@ -116,7 +110,7 @@ fi
sleep 5
# Build up bee.sh parameters
BEE_SH_ARGUMENTS="--workers=$WORKERS --own-image --payment-treshold=$PAYMENT_THRESHOLD --port-maps=$PORT_MAPS"
BEE_SH_ARGUMENTS="--workers=$WORKERS --own-image --port-maps=$PORT_MAPS"
if $EPHEMERAL ; then
BEE_SH_ARGUMENTS="$BEE_SH_ARGUMENTS --ephemeral"
fi

View File

@ -1,9 +1,9 @@
const axios = require('axios').default;
const { Bee, BeeDebug } = require('@ethersphere/bee-js');
const SLEEP_BETWEEN_UPLOADS_MS = 500
const POSTAGE_STAMPS_AMOUNT = BigInt(10000)
const POSTAGE_STAMPS_DEPTH = 20
const SLEEP_BETWEEN_UPLOADS_MS = 1000
const POSTAGE_STAMPS_AMOUNT = '10000'
const POSTAGE_STAMPS_DEPTH = 32
/**
* Lehmer random number generator with seed (minstd_rand in C++11)
@ -73,15 +73,18 @@ async function genTrafficLoop(hosts, minCheques) {
const bee = new Bee(beeApiUrl)
const beeDebug = new BeeDebug(beeDebugApiUrl)
console.log(`Generating postage stamps on ${host}...`)
console.log(`Create postage stamp on ${beeApiUrl}...`)
const postageBatchId = await bee.createPostageBatch(POSTAGE_STAMPS_AMOUNT, POSTAGE_STAMPS_DEPTH)
console.log(`Generated ${postageBatchId} postage stamp on ${host}...`)
console.log(`Generated ${postageBatchId} postage stamp on ${beeApiUrl}...`)
return {bee, beeDebug, postageBatchId}
})
const bees = await Promise.all(promises)
console.log(`wait 11 secs (>10 block time) before postage stamp usages`)
await sleep(11*1000)
while(true) {
await genTrafficOnOpenPorts(bees)
@ -96,14 +99,13 @@ async function genTrafficLoop(hosts, minCheques) {
const lastCashOutPromises = incomingCheques.map(({ peer }) => beeDebug.getLastCashoutAction(peer))
const lastCashOuts = await Promise.all(lastCashOutPromises)
for(const [index, lastCashOut] of lastCashOuts.entries()) {
if(lastCashOut.uncashedAmount > 0) {
if(BigInt(lastCashOut.uncashedAmount) > 0) {
uncashedCheques.push(incomingCheques[index])
}
}
beesUncashedCheques.push(uncashedCheques)
}
if(beesUncashedCheques.every(uncashedCheques => uncashedCheques.length >= minCheques)) {
console.log(`Generated at least ${minCheques} for every node on the given Debug API endpoints`,)
break

View File

@ -2,9 +2,22 @@
MY_PATH=$(dirname "$0")
MY_PATH=$( cd "$MY_PATH" && pwd )
BEE_VERSION=$("$MY_PATH/utils/build-image-tag.sh" get)
BEE_ENV_PREFIX=$("$MY_PATH/utils/env-variable-value.sh" BEE_ENV_PREFIX)
STATE_COMMIT=$("$MY_PATH/utils/env-variable-value.sh" STATE_COMMIT)
BUILD_IMAGE=$("$MY_PATH/utils/env-variable-value.sh" BUILD_IMAGE)
BLOCKCHAIN_VERSION=$("$MY_PATH/utils/env-variable-value.sh" BLOCKCHAIN_VERSION)
if [ $BUILD_IMAGE == 'true' ] || [ $STATE_COMMIT == 'true' ] ; then
# Necessary for fetch BEE_VERSION from .commit-version-tag
export COMMIT_VERSION_TAG='true'
fi
BEE_VERSION=$("$MY_PATH/utils/build-image-tag.sh" get)
if [ $STATE_COMMIT == 'true' ] ; then
BLOCKCHAIN_VERSION+="-for-$BEE_VERSION"
fi
BEE_ENV_PREFIX=$("$MY_PATH/utils/env-variable-value.sh" BEE_ENV_PREFIX)
BEE_IMAGE_PREFIX=$("$MY_PATH/utils/env-variable-value.sh" BEE_IMAGE_PREFIX)
BLOCKCHAIN_NAME="$BEE_ENV_PREFIX-blockchain"
BLOCKCHAIN_IMAGE_NAME="$BEE_IMAGE_PREFIX/$BLOCKCHAIN_NAME:$BLOCKCHAIN_VERSION"

BIN
smth.txt

Binary file not shown.