add hive client files

This commit is contained in:
jangko 2021-03-23 18:52:25 +07:00
parent a7344b13d1
commit e237e21372
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
4 changed files with 186 additions and 0 deletions

View File

@ -0,0 +1,42 @@
# Docker container spec for building the master branch of nimbus.
FROM debian:buster-slim AS build
RUN apt-get update \
&& apt-get install -y --fix-missing build-essential make git libpcre3-dev librocksdb-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV NPROC=2
RUN git clone --depth 1 https://github.com/status-im/nimbus-eth1.git \
&& cd nimbus-eth1 \
&& git checkout master \
&& make -j${NPROC} NIMFLAGS="--parallelBuild:${NPROC}" V=1 update
RUN cd nimbus-eth1 && \
make -j${NPROC} NIMFLAGS="--parallelBuild:${NPROC}" nimbus && \
mv build/nimbus /usr/bin/
# --------------------------------- #
# Starting new image to reduce size #
# --------------------------------- #
FROM debian:buster-slim AS deploy
RUN apt-get update \
&& apt-get install -y librocksdb-dev bash curl jq\
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY --from=build /usr/bin/nimbus /usr/bin/nimbus
# Inject the startup script
ADD nimbus.sh /nimbus.sh
ADD mapper.jq /mapper.jq
RUN chmod +x /nimbus.sh
ADD genesis.json /genesis.json
# Export the usual networking ports to allow outside access to the node
EXPOSE 8545 8546 8547 30303 30303/udp
ENTRYPOINT ["/nimbus.sh"]

View File

@ -0,0 +1,15 @@
{
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "0x020000",
"extraData" : "0x42",
"gasLimit" : "0x2fefd8",
"mixHash" : "0x2c85bcbce56429100b2108254bb56906257582aeafcbd682bc9af67a9f5aee46",
"nonce" : "0x78cc16f7b4f65485",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x54c98c81",
"alloc" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance" : "0x09184e72a000"
}
}
}

View File

@ -0,0 +1,47 @@
# Removes all empty keys and values in input.
def remove_empty:
. | walk(
if type == "object" then
with_entries(
select(
.value != null and
.value != "" and
.value != [] and
.key != null and
.key != ""
)
)
else .
end
)
;
# Converts decimal string to number.
def to_int:
if . == null then . else .|tonumber end
;
# Converts "1" / "0" to boolean.
def to_bool:
if . == null then . else
if . == "1" then true else false end
end
;
# Replace config in input.
. + {
"config": {
"chainId": env.HIVE_CHAIN_ID|to_int,
"homesteadBlock": env.HIVE_FORK_HOMESTEAD|to_int,
"daoForkBlock": env.HIVE_FORK_DAO_BLOCK|to_int,
"daoForkSupport": env.HIVE_FORK_DAO_VOTE|to_bool,
"eip150Block": env.HIVE_FORK_TANGERINE|to_int,
"eip158Block": env.HIVE_FORK_SPURIOUS|to_int,
"byzantiumBlock": env.HIVE_FORK_BYZANTIUM|to_int,
"constantinopleBlock": env.HIVE_FORK_CONSTANTINOPLE|to_int,
"petersburgBlock": env.HIVE_FORK_PETERSBURG|to_int,
"istanbulBlock": env.HIVE_FORK_ISTANBUL|to_int,
"muirGlacierBlock": env.HIVE_FORK_MUIR_GLACIER|to_int,
"berlinBlock": env.HIVE_FORK_BERLIN|to_int
}|remove_empty
}

View File

@ -0,0 +1,82 @@
#!/bin/bash
# Startup script to initialize and boot a nimbus instance.
#
# This script assumes the following files:
# - `nimbus` binary is located in the filesystem root
# - `genesis.json` file is located in the filesystem root (mandatory)
# - `chain.rlp` file is located in the filesystem root (optional)
# - `blocks` folder is located in the filesystem root (optional)
# - `keys` folder is located in the filesystem root (optional)
#
# This script assumes the following environment variables:
#
# - [ ] HIVE_BOOTNODE enode URL of the remote bootstrap node
# - [ ] HIVE_NETWORK_ID network ID number to use for the eth protocol
# - [ ] HIVE_TESTNET whether testnet nonces (2^20) are needed
# - [ ] HIVE_NODETYPE sync and pruning selector (archive, full, light)
#
# Forks:
#
# - [x] HIVE_FORK_HOMESTEAD block number of the homestead hard-fork transition
# - [x] HIVE_FORK_DAO_BLOCK block number of the DAO hard-fork transition
# - [x] HIVE_FORK_DAO_VOTE whether the node support (or opposes) the DAO fork
# - [x] HIVE_FORK_TANGERINE block number of Tangerine Whistle transition
# - [x] HIVE_FORK_SPURIOUS block number of Spurious Dragon transition
# - [x] HIVE_FORK_BYZANTIUM block number for Byzantium transition
# - [x] HIVE_FORK_CONSTANTINOPLE block number for Constantinople transition
# - [x] HIVE_FORK_PETERSBURG block number for ConstantinopleFix/PetersBurg transition
# - [x] HIVE_FORK_ISTANBUL block number for Istanbul transition
# - [x] HIVE_FORK_MUIRGLACIER block number for Muir Glacier transition
# - [x] HIVE_FORK_BERLIN block number for Berlin transition
#
# Clique PoA:
#
# - [ ] HIVE_CLIQUE_PERIOD enables clique support. value is block time in seconds.
# - [ ] HIVE_CLIQUE_PRIVATEKEY private key for clique mining
#
# Other:
#
# - [ ] HIVE_MINER enable mining. value is coinbase address.
# - [ ] HIVE_MINER_EXTRA extra-data field to set for newly minted blocks
# - [ ] HIVE_SKIP_POW if set, skip PoW verification during block import
# - [ ] HIVE_LOGLEVEL client loglevel (0-5)
# - [ ] HIVE_GRAPHQL_ENABLED enables graphql on port 8545
# Immediately abort the script on any error encountered
set -e
nimbus=/usr/bin/nimbus
FLAGS="--prune:archive"
if [ "$HIVE_LOGLEVEL" != "" ]; then
FLAGS="$FLAGS --log-level:$HIVE_LOGLEVEL"
fi
# Configure the chain.
mv /genesis.json /genesis-input.json
jq -f /mapper.jq /genesis-input.json > /genesis.json
# Dump genesis
echo "Supplied genesis state:"
cat /genesis.json
F-LAGS="$FLAGS --customgenesis:genesis.json"
# Don't immediately abort, some imports are meant to fail
set +e
# Load the remainder of the test chain
echo "Loading remaining individual blocks..."
if [ -d /blocks ]; then
(cd /blocks && $nimbus $FLAGS --log-level:$HIVE_LOGLEVEL --import:`ls | sort -n`)
else
echo "Warning: blocks folder not found."
fi
set -e
# Configure RPC.
FLAGS="$FLAGS --rpc --rpcapi:eth,debug"
echo "Running nimbus with flags $FLAGS"
$nimbus $FLAGS