Skip to content

Commit

Permalink
Merge pull request #116 from RetricSu/develop
Browse files Browse the repository at this point in the history
release ckb2021
  • Loading branch information
RetricSu authored Sep 29, 2021
2 parents 835ffaf + 04a6413 commit 5d82c82
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 25 deletions.
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ endif

### 1. utils
manual-image:
cd docker/manual-image && docker build -t ${DOCKER_MANUAL_BUILD_IMAGE_NAME} .
@read -p "Please Enter New Image Tag: " VERSION ; \
cd docker/manual-image && docker build . -t ${DOCKER_MANUAL_BUILD_IMAGE_NAME}:$$VERSION ;\

create-folder:
mkdir -p workspace/bin
Expand Down Expand Up @@ -64,13 +65,13 @@ install:
# if manual build web3
if [ "$(MANUAL_BUILD_WEB3)" = true ] ; then \
source ./gw_util.sh && prepare_package godwoken-web3 $$WEB3_GIT_URL $$WEB3_GIT_CHECKOUT > /dev/null; \
make copy-web3-node-modules-if-empty;\
"$(INSTALL_JS_NODE_MODULE_NOT_COPY)" && make install-web3-node-modules-if-empty || make copy-web3-node-modules-if-empty ;\
docker run --rm -v `pwd`/packages/godwoken-web3:/app -w=/app $$DOCKER_JS_PREBUILD_IMAGE_NAME:$$DOCKER_JS_PREBUILD_IMAGE_TAG /bin/bash -c "yarn workspace @godwoken-web3/godwoken tsc;" ; \
fi
# if manual build polyman
if [ "$(MANUAL_BUILD_POLYMAN)" = true ] ; then \
source ./gw_util.sh && prepare_package godwoken-polyman $$POLYMAN_GIT_URL $$POLYMAN_GIT_CHECKOUT > /dev/null; \
make copy-polyman-node-modules-if-empty;\
"$(INSTALL_JS_NODE_MODULE_NOT_COPY)" && make install-polyman-node-modules-if-empty || make copy-polyman-node-modules-if-empty ;\
fi
# if manual build godwoken
if [ "$(MANUAL_BUILD_GODWOKEN)" = true ] ; then \
Expand Down Expand Up @@ -305,6 +306,12 @@ copy-web3-node-modules-if-empty:
copy-polyman-node-modules-if-empty::
docker run --rm -v `pwd`/packages/godwoken-polyman:/app $$DOCKER_JS_PREBUILD_IMAGE_NAME:$$DOCKER_JS_PREBUILD_IMAGE_TAG /bin/bash -c "cd app && yarn check --verify-tree && cd .. || ( cd .. && echo 'start copying polyman node_modules from docker to local package..' && cp -r ./godwoken-polyman/node_modules ./app/) ;"

install-web3-node-modules-if-empty:
cd `pwd`/packages/godwoken-web3 && yarn check --verify-tree && cd .. || yarn install

install-polyman-node-modules-if-empty:
cd `pwd`/packages/godwoken-polyman && yarn check --verify-tree && cd .. || yarn install

### 7. godwoken gen schema helper command
gen-schema:
make clean-schema
Expand Down
1 change: 1 addition & 0 deletions ckb/ckb-miner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dsn = ""
# please leave a way to contact you when we have troubles to reproduce the errors.
# org_contact = ""

# # **Experimental** Monitor memory changes.
# [memory_tracker]
# # Seconds between checking the process, 0 is disable, default is 0.
# interval = 600
Expand Down
12 changes: 7 additions & 5 deletions ckb/ckb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dsn = ""
# please leave a way to contact you when we have troubles to reproduce the errors.
# org_contact = ""

# # **Experimental** Monitor memory changes.
# [memory_tracker]
# # Seconds between checking the process, 0 is disable, default is 0.
# interval = 600
Expand Down Expand Up @@ -50,6 +51,8 @@ bootnodes = []
# whitelist_only = false
### Whitelist peers connecting from the given IP addresses
# whitelist_peers = []
### Enable `SO_REUSEPORT` feature to reuse port on Linux, not supported on other OS yet
# reuse_port_on_linux = true

max_peers = 125
max_outbound_peers = 8
Expand Down Expand Up @@ -90,11 +93,8 @@ enable_deprecated_rpc = false
[tx_pool]
max_mem_size = 20_000_000 # 20mb
max_cycles = 200_000_000_000
max_verify_cache_size = 100_000
max_conflict_cache_size = 1_000
max_committed_txs_hash_cache_size = 100_000
min_fee_rate = 1_000 # shannons/KB
max_tx_verify_cycles = 700_000_000
max_tx_verify_cycles = 70_000_000
max_ancestors_count = 25

[store]
Expand All @@ -103,7 +103,6 @@ cell_data_cache_size = 128
block_proposals_cache_size = 30
block_tx_hashes_cache_size = 30
block_uncles_cache_size = 30
cellbase_cache_size = 30

# [notifier]
# # Execute command when the new tip block changes, first arg is block hash.
Expand Down Expand Up @@ -143,8 +142,11 @@ cellbase_cache_size = 30
#
# ckb init <lock_arg>
#
# secp256k1_blake160_sighash_all example:
[block_assembler]
code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
args = "0x43d509d97f26007a285f39241cffcd411157196c"
hash_type = "type"
message = "0x1234"
# # CKB will prepend the binary version to message, to identify the block miner client. (default true, false to disable it)
# use_binary_version_as_message_prefix = true
9 changes: 9 additions & 0 deletions ckb/specs/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,14 @@ genesis_epoch_length = 10
# Keep difficulty be permanent if the pow is Dummy. (default: false)
permanent_difficulty_in_dummy = true

[params.hardfork]
rfc_0028 = 10
rfc_0029 = 10
rfc_0030 = 10
rfc_0031 = 10
rfc_0032 = 10
rfc_0036 = 10
rfc_0038 = 10

[pow]
func = "Dummy"
25 changes: 16 additions & 9 deletions docker/.build.mode.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,37 @@ MANUAL_BUILD_POLYMAN=false

####[images]
DOCKER_PREBUILD_IMAGE_NAME=nervos/godwoken-prebuilds
DOCKER_PREBUILD_IMAGE_TAG=v0.6.2-rc6
DOCKER_PREBUILD_IMAGE_TAG=v0.6.5-rc3
DOCKER_MANUAL_BUILD_IMAGE_NAME=retricsu/godwoken-manual-build
DOCKER_MANUAL_BUILD_IMAGE_TAG=add-jq
DOCKER_MANUAL_BUILD_IMAGE_TAG=ckb2021
DOCKER_JS_PREBUILD_IMAGE_NAME=nervos/godwoken-js-prebuilds
DOCKER_JS_PREBUILD_IMAGE_TAG=v0.7.3-rc3
DOCKER_JS_PREBUILD_IMAGE_TAG=v0.8.0-rc2

####[packages]
GODWOKEN_GIT_URL=https://github.com/nervosnetwork/godwoken.git
GODWOKEN_GIT_CHECKOUT=v0.6.2-rc5
POLYMAN_GIT_URL=https://github.com/RetricSu/godwoken-polyman.git
POLYMAN_GIT_CHECKOUT=v0.6.1-rc1
GODWOKEN_GIT_CHECKOUT=v0.6.5-rc3
POLYMAN_GIT_URL=https://github.com/retricsu/godwoken-polyman.git
POLYMAN_GIT_CHECKOUT=v0.7.0-rc2
WEB3_GIT_URL=https://github.com/nervosnetwork/godwoken-web3.git
WEB3_GIT_CHECKOUT=v0.6.0-rc7
WEB3_GIT_CHECKOUT=v0.7.0-rc1
SCRIPTS_GIT_URL=https://github.com/nervosnetwork/godwoken-scripts.git
SCRIPTS_GIT_CHECKOUT=v0.8.0-rc2
SCRIPTS_GIT_CHECKOUT=v0.8.2-rc1
POLYJUICE_GIT_URL=https://github.com/nervosnetwork/godwoken-polyjuice.git
POLYJUICE_GIT_CHECKOUT=v0.8.4
POLYJUICE_GIT_CHECKOUT=v0.8.6
CLERKB_GIT_URL=https://github.com/nervosnetwork/clerkb.git
CLERKB_GIT_CHECKOUT=v0.4.0

####[system]
ALWAYS_FETCH_NEW_PACKAGE=false
#
# while in manual build mode,
# if you like to build godwoken on local machine(it might be faster than in docker),
# make sure you are on ubuntu 20.04 with 2.31 glibc installed
# if so, you can set below variable to true
BUILD_GODWOKEN_ON_LOCAL_OVER_DOCKER=false
#
# while in manual build mode, the js components will copy node_modules from DOCKER_JS_PREBUILD_IMAGE by default,
# this might have some problem when prebuild docker image is behind the newest version which you want to build right away.
# if you have nodejs version >= 14 and yarn install on you local environment,
# you can choose to yarn install the node_modules, just set the below var to true
INSTALL_JS_NODE_MODULE_NOT_COPY=false
10 changes: 10 additions & 0 deletions docker/layer2/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ export GODWOKEN_BIN=${PROJECT_DIR}/workspace/bin/godwoken
export GW_TOOLS_BIN=${PROJECT_DIR}/workspace/bin/gw-tools

function runGodwoken(){
# wait for ckb rpc server to start
while true; do
sleep 0.2;
if isCkbRpcRunning "${CKB_RPC}";
then
break;
else echo "keep waitting for ckb rpc..."
fi
done
# running godwoken
RUST_LOG=info,gw_block_producer=info,gw_generator=debug,gw_web3_indexer=debug $GODWOKEN_BIN
}

Expand Down
16 changes: 8 additions & 8 deletions docker/manual-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt update -y && \
DEBIAN_FRONTEND=noninteractive apt-get install cmake musl-tools clang libc++-dev autoconf libtool pkg-config unzip -y

# Install Rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.50.0 -y
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.54.0 -y
ENV PATH=/root/.cargo/bin:$PATH
RUN which cargo

Expand All @@ -17,25 +17,25 @@ RUN curl -sL https://deb.nodesource.com/setup_14.x | DEBIAN_FRONTEND=noninterac
RUN apt install -y nodejs
RUN npm install -g yarn

RUN cargo install moleculec --version 0.6.1
RUN cargo install moleculec --version 0.7.2
RUN echo $HOME
RUN moleculec --version
#RUN curl http://ftp.br.debian.org/debian/pool/main/g/glibc/libc6_2.31-11_amd64.deb --output libc6_2.31-11_amd64.deb && dpkg -i libc6_2.31-11_amd64.deb
RUN apt-get install libc6 -y

# install ckb tools
RUN mkdir /ckb
RUN cd /ckb && curl -LO https://github.com/nervosnetwork/ckb/releases/download/v0.41.0/ckb_v0.41.0_x86_64-unknown-linux-gnu.tar.gz
RUN cd /ckb && tar xzf ckb_v0.41.0_x86_64-unknown-linux-gnu.tar.gz
RUN cd /ckb && curl -LO https://github.com/nervosnetwork/ckb/releases/download/v0.100.0/ckb_v0.100.0_x86_64-unknown-linux-gnu.tar.gz
RUN cd /ckb && tar xzf ckb_v0.100.0_x86_64-unknown-linux-gnu.tar.gz

RUN mkdir /ckb-indexer
RUN cd /ckb-indexer && curl -LO https://github.com/nervosnetwork/ckb-indexer/releases/download/v0.2.0/ckb-indexer-0.2.0-linux.zip
RUN cd /ckb-indexer && unzip ckb-indexer-0.2.0-linux.zip && tar xzf ckb-indexer-linux-x86_64.tar.gz
RUN cd /ckb-indexer && curl -LO https://github.com/nervosnetwork/ckb-indexer/releases/download/v0.3.0/ckb-indexer-0.3.0-linux.zip
RUN cd /ckb-indexer && unzip ckb-indexer-0.3.0-linux.zip && tar xzf ckb-indexer-linux-x86_64.tar.gz

RUN ls

RUN cp /ckb/ckb_v0.41.0_x86_64-unknown-linux-gnu/ckb /usr/bin/ckb
RUN cp /ckb/ckb_v0.41.0_x86_64-unknown-linux-gnu/ckb-cli /usr/bin/ckb-cli
RUN cp /ckb/ckb_v0.100.0_x86_64-unknown-linux-gnu/ckb /usr/bin/ckb
RUN cp /ckb/ckb_v0.100.0_x86_64-unknown-linux-gnu/ckb-cli /usr/bin/ckb-cli
RUN cp /ckb-indexer/ckb-indexer /usr/bin/ckb-indexer

RUN apt-get install jq -y \
Expand Down
11 changes: 11 additions & 0 deletions docker/polyjuice/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -o errexit
#set -o xtrace
PROJECT_DIR=/code
GODWOKEN_RPC_URL="http://godwoken:8119"
WEB3_RPC_URL="http://web3:8024"
export INDEXER_DB=/usr/local/polyman

# import some helper function
Expand Down Expand Up @@ -37,5 +38,15 @@ cp /code/workspace/deploy/lumos-config.json packages/runner/configs/lumos-config

yarn gen-config

# wait for web3 rpc server to start
while true; do
sleep 2;
if isWeb3RpcRunning "${WEB3_RPC_URL}";
then
break;
else echo "keep waitting..."
fi
done

# start the main http server of polyman
yarn workspace @godwoken-polyman/runner start
33 changes: 33 additions & 0 deletions gw_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,39 @@ isPolymanUIRunning(){
fi
}

isWeb3RpcRunning(){
if [[ -n $1 ]];
then
local rpc_url="$1"
else
local rpc_url="http://localhost:8024"
fi

# curl retry on connrefused, considering ECONNREFUSED as a transient error(network issues)
# connections with ipv6 are not retried because it returns EADDRNOTAVAIL instead of ECONNREFUSED,
# hence we should use --ipv4
result=$( echo '{
"id": 2,
"jsonrpc": "2.0",
"method": "net_listening",
"params": []
}' \
| tr -d '\n' \
| curl -s --ipv4 --retry 3 --retry-connrefused \
-H 'content-type: application/json' -d @- \
$rpc_url)

if [[ $result =~ "true" ]]; then
echo "web3 rpc server is up and running!"
# 0 equals true
return 0
else
echo "web3 rpc server is down."
# 1 equals false
return 1
fi
}

# set key value in toml config file
# how to use: set_key_value_in_toml key value your_toml_config_file
set_key_value_in_toml() {
Expand Down

0 comments on commit 5d82c82

Please sign in to comment.