Skip to content

Commit

Permalink
Merge branch 'develop' into master2dev
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusKysel committed Feb 26, 2024
2 parents 357ede0 + a86bf59 commit 4b7c892
Show file tree
Hide file tree
Showing 76 changed files with 1,054 additions and 779 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ include(ExternalProject)
set(JSONCPP_INCLUDE_DIR ${CONAN_INCLUDE_DIRS_JSONCPP})
include(ProjectJSONRPCCPP)

# rocksdb build
include(${PROJECT_SOURCE_DIR}/CMakeModules/rocksdb.cmake)

# Add sub-directories cmakes
add_subdirectory(submodules)
add_subdirectory(libraries)
Expand Down
1 change: 1 addition & 0 deletions CMakeModules/cpp_graphql_gen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ FetchContent_Declare(
cppgraphqlgen
GIT_REPOSITORY https://github.com/microsoft/cppgraphqlgen.git
GIT_TAG 1d659227bfc51fb7d9bb5dc9862234e7cfd1b1e3 # v4.5.4
GIT_SHALLOW TRUE
)
set(GRAPHQL_BUILD_TESTS OFF)
set(GRAPHQL_UPDATE_VERSION OFF)
Expand Down
1 change: 1 addition & 0 deletions CMakeModules/cppcheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ else ()
--suppress=unusedFunction:${PROJECT_SOURCE_DIR}/*/vrf_wrapper.cpp
--suppress=unusedFunction:${PROJECT_SOURCE_DIR}/*/UPnP.cpp
--suppress=unusedFunction:${PROJECT_SOURCE_DIR}/*/logger.cpp
--suppress=unusedFunction:${PROJECT_SOURCE_DIR}/*/state_api.cpp
# TODO remove this when we solve correct exit of programs
--suppress=localMutex:${PROJECT_SOURCE_DIR}/*/main.cpp
# Just style warning
Expand Down
32 changes: 32 additions & 0 deletions CMakeModules/rocksdb.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ========================================================================== #
# RocksDB key-value store #
# ========================================================================== #
include(FetchContent)

set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

FetchContent_Declare(
rocksdb
GIT_REPOSITORY https://github.com/facebook/rocksdb
GIT_TAG v8.5.3
GIT_SHALLOW TRUE
)

FetchContent_GetProperties(rocksdb)

message(STATUS "Populating rocksdb")
set(USE_RTTI 1)
set(WITH_LZ4 ON)
set(WITH_GFLAGS OFF)
set(FAIL_ON_WARNINGS OFF)
set(PORTABLE 1 CACHE STRING "Override: Minimum CPU arch to support") # Disable -march=native
set(WITH_TESTS OFF CACHE INTERNAL "")
set(WITH_JNI OFF CACHE INTERNAL "")
set(WITH_TOOLS OFF CACHE INTERNAL "")
set(WITH_BENCHMARK_TOOLS OFF CACHE INTERNAL "")
set(WITH_CORE_TOOLS OFF CACHE INTERNAL "")
set(WITH_TRACE_TOOLS OFF CACHE INTERNAL "")
set(ROCKSDB_BUILD_SHARED ${BUILD_SHARED_LIBS} CACHE INTERNAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -Wno-error=unused-const-variable -Wno-error=pedantic -Wno-error=format-pedantic -Wno-error=gnu-zero-variadic-macro-arguments -Wno-error=extra-semi -Wc++98-compat-extra-semi -Wno-error=deprecated-copy -Wno-deprecated-copy -Wno-error=pessimizing-move -Wno-pessimizing-move -Wno-pessimizing-move")

FetchContent_MakeAvailable(rocksdb)
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ RUN mkdir $BUILD_OUTPUT_DIR && cd $BUILD_OUTPUT_DIR \

RUN cd $BUILD_OUTPUT_DIR && make -j$(nproc) all \
# Copy CMake generated Testfile to be able to trigger ctest from bin directory
&& cp tests/CTestTestfile.cmake bin/ \
&& cp tests/CTestTestfile.cmake bin/;
# \
# keep only required shared libraries and final binaries
&& find . -maxdepth 1 ! -name "lib" ! -name "bin" -exec rm -rfv {} \;
# && find . -maxdepth 1 ! -name "lib" ! -name "bin" -exec rm -rfv {} \;

# Set LD_LIBRARY_PATH so taraxad binary finds shared libs
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

###############################################################################
##### Taraxa image containing taraxad binary + dynamic libraries + config #####
Expand All @@ -123,7 +127,7 @@ WORKDIR /root/.taraxa
# Copy required binaries
COPY --from=build /opt/taraxa/$BUILD_OUTPUT_DIR/bin/taraxad /usr/local/bin/taraxad
COPY --from=build /opt/taraxa/$BUILD_OUTPUT_DIR/bin/taraxa-bootnode /usr/local/bin/taraxa-bootnode
COPY --from=build /opt/taraxa/$BUILD_OUTPUT_DIR/lib/*.so /usr/local/lib/
COPY --from=build /opt/taraxa/$BUILD_OUTPUT_DIR/lib/*.so* /usr/local/lib/

# Copy scripts
COPY scripts/taraxa-sign.py /usr/local/bin/taraxa-sign
Expand Down
3 changes: 0 additions & 3 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def requirements(self):
self.requires("cryptopp/8.7.0")
self.requires("gtest/1.14.0")
self.requires("lz4/1.9.4")
self.requires("rocksdb/6.29.5")
self.requires("prometheus-cpp/1.1.0")
self.requires("jsoncpp/1.9.5")

Expand Down Expand Up @@ -61,8 +60,6 @@ def configure(self):
self.options["gtest"].build_gmock = False
# this links cppcheck to prce library
self.options["cppcheck"].have_rules = False
self.options["rocksdb"].use_rtti = True
self.options["rocksdb"].with_lz4 = True
# mpir is required by cppcheck and it causing gmp confict
self.options["mpir"].enable_gmpcompat = False

Expand Down
55 changes: 55 additions & 0 deletions doc/RPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,61 @@ curl -X POST --data '{"jsonrpc":"2.0","method":"taraxa_getChainStats","params":[
}
```

### taraxa_yield

Returns yield for specified period

#### Parameters

`QUANTITY` - period

#### Returns

`String` - yield

To transform returned yield to percents -> ```decimal(yield) / 1e4```\
To transform returned yield to fraction -> ```decimal(yield) / 1e6```

#### Example

```json
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"taraxa_yield","params":["0x1D533B"],"id":1}'

// Result
{
"id": 1,
"jsonrpc": "2.0",
"result": "0x30D40"
}
```

### taraxa_totalSupply

Returns total supply for specified period

#### Parameters

`QUANTITY` - period

#### Returns

`String` - total supply

#### Example

```json
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"taraxa_totalSupply","params":["0x1D533B"],"id":1}'

// Result
{
"id": 1,
"jsonrpc": "2.0",
"result": "0x204FCE5E3E25026110000000"
}
```

## Test API

### get_sortition_change
Expand Down
3 changes: 3 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ else
if [[ -z "${ADVERTISED_IP}" ]]; then
echo "ADVERTISED_IP is not set."
else
if [ "$ADVERTISED_IP" = "auto" ]; then
ADVERTISED_IP=$(curl icanhazip.com 2>/dev/null)
fi
FLAGS="--public-ip ${ADVERTISED_IP}"
fi

Expand Down
20 changes: 10 additions & 10 deletions for_devs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Usage: local-net start [OPTIONS] BINARY
Start a local testnet
Options:
--boot-nodes INTEGER Number of boot nodes
--consensus-nodes INTEGER Number of consensus nodes
--rpc-nodes INTEGER Number of RPC nodes
--tps INTEGER Number of transactions per second (if zero the faucet
will not start)
Expand All @@ -27,25 +27,25 @@ Options:

The script can be run from anywhere but keep in mind that it will create a new directory called `local-net-data` that contains the data and config files for the nodes in the current path.

For example if you want to test the new binary on a network with 3 boot nodes and 1 RPC node you can run the following command in the root of the current repo:
For example if you want to test the new binary on a network with 3 consensus nodes and 1 RPC node you can run the following command in the root of the current repo:

```bash
./for_devs/local-net start --boot-nodes 3 --rpc-nodes 1 --tps 1 ./cmake-build/bin/taraxad
./for_devs/local-net start --consensus-nodes 3 --rpc-nodes 1 --tps 1 ./cmake-build/bin/taraxad
```

Network can be stopped, config files for nodes adjusted and redeployed... It can be used for debugging, for example:

- Deploy new network with 3 boot nodes and 1 rpc node:
- Deploy new network with 3 consensus nodes and 1 rpc node:
```bash
./for_devs/local-net start --boot-nodes 3 --rpc-nodes 1 --tps 1 ./cmake-build/bin/taraxad
./for_devs/local-net start --consensus-nodes 3 --rpc-nodes 1 --tps 1 ./cmake-build/bin/taraxad
```

- Let it run for 1 minute so boot nodes create a few pbft blocks. Then stop the network, increase number of rpc nodes(let's say to 5) and redeploy the networK:
- Let it run for 1 minute so consensus nodes create a few pbft blocks. Then stop the network, increase number of rpc nodes(let's say to 5) and redeploy the networK:
```bash
./for_devs/local-net start --boot-nodes 3 --rpc-nodes 5 --tps 1 ./cmake-build/bin/taraxad
./for_devs/local-net start --consensus-nodes 3 --rpc-nodes 5 --tps 1 ./cmake-build/bin/taraxad
```

New rpc nodes start syncing with original nodes as they are behind with pbft and we can debug this process. Network can be stopped at any time,
config files adjusted and redeployed with the same command.
New rpc nodes start syncing with original nodes as they are behind with pbft and we can debug this process. Network can be stopped at any time,
config files adjusted and redeployed with the same command.

!!! Note: For existing network only rpc nodes number can be increased, in case you want to increase boot nodes number, network must deployed from scratch.
!!! Note: For existing network only rpc nodes number can be increased, in case you want to increase consensus nodes number, network must deployed from scratch.
Loading

0 comments on commit 4b7c892

Please sign in to comment.