Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Add eth_getLogs API (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
canepat authored Mar 5, 2021
1 parent 68abda1 commit a60d6c9
Show file tree
Hide file tree
Showing 105 changed files with 6,208 additions and 76 deletions.
37 changes: 30 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,25 @@
version: 2.1

commands:
build:
checkout_with_submodules:
steps:
- checkout
- run:
name: "Update submodules"
command: |
git submodule sync
git submodule update --init --recursive
build:
steps:
- run:
name: "Install GMP"
command: |
sudo apt-get update
sudo apt-get install -y libgmp3-dev
- restore_cache:
name: "Restore Hunter cache"
key: &hunter-cache-key hunter-{{ .Environment.CIRCLE_JOB }}-{{checksum "cmake/toolchain.cmake"}}-{{checksum "cmake/Hunter/packages.cmake"}}
key: &hunter-cache-key hunter-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-{{checksum "cmake/toolchain.cmake"}}-{{checksum "cmake/Hunter/packages.cmake"}}
- run:
name: "Cmake"
working_directory: ~/build
Expand All @@ -52,21 +55,41 @@ commands:
command: cmd/unit_test

jobs:
linux-gcc-9:
linux-gcc-10:
environment:
BUILD_TYPE: Debug
docker:
- image: ethereum/cpp-build-env:15-gcc-9
CLANG_COVERAGE: OFF
machine:
image: ubuntu-2004:202101-01
steps:
- run:
name: "Install GCC 10"
command: |
sudo apt update
sudo apt -y install gcc-10 g++-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 50
gcc --version
g++ --version
- checkout_with_submodules
- build
- test

linux-clang-coverage:
environment:
BUILD_TYPE: Debug
CLANG_COVERAGE: ON
docker:
- image: ethereum/cpp-build-env:14-clang-10
steps:
- run:
name: "Install LLVM C++ Standard Library" # for C++ standard headers clang does not have
command: |
sudo apt update
sudo apt -y install apt-utils
sudo apt -y install libc++abi-dev
sudo apt -y install libc++-dev
- checkout_with_submodules
- build
- run:
name: "Unit Tests"
Expand Down Expand Up @@ -96,5 +119,5 @@ workflows:
version: 2
silkworm:
jobs:
#- linux-gcc-9
- linux-clang-coverage
- linux-gcc-10
#- linux-clang-coverage
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
build
build_gcc_debug
build_gcc_release
build_clang_debug
build_clang_release
.vscode
.vs
*.code-workspace
*.code-workspace
*.hrd
*.stdout
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "silkworm"]
path = silkworm
url = [email protected]:torquem-ch/silkworm.git
[submodule "silkrpc/croaring"]
path = silkrpc/croaring
url = [email protected]:lemire/CRoaringUnityBuild.git
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/silkworm/.git)
message(FATAL_ERROR "Git submodules not initialized, execute:\n git submodule update --init --recursive")
endif()

#
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/silkworm/cmake/toolchain.cmake CACHE FILEPATH "" FORCE)
# Use default toolchain file if not specified on the command line
if(NOT CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/silkworm/cmake/toolchain.cmake CACHE FILEPATH "" FORCE)
endif()

include(silkworm/evmone/cmake/cable/HunterGate.cmake)
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.23.267.tar.gz"
SHA1 "9c5c7fa6e17c2ae15dd922184bc7c51235aaae70"
FILEPATH "${CMAKE_SOURCE_DIR}/silkworm/cmake/Hunter/config.cmake"
URL "https://github.com/cpp-pm/hunter/archive/v0.23.293.tar.gz"
SHA1 "e8e5470652db77149d9b38656db2a6c0b7642693"
FILEPATH "${CMAKE_SOURCE_DIR}/cmake/Hunter/config.cmake"
)

project(silkrpc)
Expand All @@ -42,6 +44,6 @@ find_package(intx CONFIG REQUIRED)
add_subdirectory(silkworm)

# SilkRpc itself
add_subdirectory(silkrpc/kv/remote)
add_subdirectory(silkrpc/ethdb/kv/remote)
add_subdirectory(silkrpc)
add_subdirectory(cmd)
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ git submodule update --init --recursive
```

## Linux & MacOS
Building SilkRPC Daemon requires:
* C++17 compiler (GCC or Clang)
* [CMake](http://cmake.org)
Building SilkRPC daemon requires
* C++20 compiler: [GCC](https://www.gnu.org/software/gcc/) >= 10.2.0 or [Clang](https://clang.llvm.org/) >= 10.0.0
* [CMake](http://cmake.org) >= 3.18.4
* [GMP](http://gmplib.org) (`sudo apt-get install libgmp3-dev` or `brew install gmp`)

Once the prerequisites are installed, bootstrap cmake by running
Expand All @@ -35,18 +35,35 @@ mkdir build
cd build
cmake ..
```
(You have to run `cmake ..` just the first time.)
(BTW, you have to run `cmake ..` just the first time).

Generate the [gRPC](https://grpc.io/) Key-Value (KV) interface protocol bindings
```
cmake --build . --target generate_kv_grpc
```

Then run the build itself
```
make -j
cmake --build .
```

Now you can run the unit tests
```
cmd/unit_test
```

There are also convenience [bash](https://www.gnu.org/software/bash/) scripts for a complete rebuild both in debug and release configurations using [GCC](https://www.gnu.org/software/gcc/) compiler:
```
./build_gcc_debug.sh
./build_gcc_release.sh
```
and [Clang](https://clang.llvm.org/) compiler:
```
./build_clang_debug.sh
./build_clang_release.sh
```
The resulting build folders are `build_[gcc, clang]_[debug, release]` according to your choice.

## Windows
* Install [Visual Studio](https://www.visualstudio.com/downloads) 2019. Community edition is fine.
* Make sure your setup includes CMake support and Windows 10 SDK.
Expand All @@ -63,7 +80,7 @@ cmd/unit_test

# Code style

We use the standard C++17 programming language. We follow the [Google's C++ Style Guide](https://google.github.io/styleguide/cppguide.html) with the following differences:
We use the standard C++20 programming language. We follow the [Google's C++ Style Guide](https://google.github.io/styleguide/cppguide.html) with the following differences:

* `snake_case` for function names.
* .cpp & .hpp file extensions are used for C++; .cc are used just for [gRPC](https://grpc.io/) generated C++; .c & .h are reserved for C.
Expand Down
9 changes: 9 additions & 0 deletions build_clang_debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

PROJECT_DIR=$PWD
rm -fr build_clang_debug
mkdir build_clang_debug
cd build_clang_debug
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=$PROJECT_DIR/cmake/clang-libcxx20-fpic.cmake ..
cmake --build .
cmd/unit_test
9 changes: 9 additions & 0 deletions build_clang_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

PROJECT_DIR=$PWD
rm -fr build_clang_release
mkdir build_clang_release
cd build_clang_release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PROJECT_DIR/cmake/clang-libcxx20-fpic.cmake ..
cmake --build .
cmd/unit_test
8 changes: 8 additions & 0 deletions build_gcc_debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

rm -fr build_gcc_debug
mkdir build_gcc_debug
cd build_gcc_debug
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 ..
cmake --build .
cmd/unit_test
8 changes: 8 additions & 0 deletions build_gcc_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

rm -fr build_gcc_release
mkdir build_gcc_release
cd build_gcc_release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 ..
cmake --build .
cmd/unit_test
22 changes: 22 additions & 0 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#[[
Copyright 2020 The Silkworm Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]

# silkworm configuration
include(${CMAKE_SOURCE_DIR}/silkworm/cmake/Hunter/config.cmake)

# silkrpc configuration
hunter_config(Protobuf VERSION 3.12.4-p1) # <-- Last working version (greater seems to have networking issues)
hunter_config(gRPC VERSION 1.31.0-p0) # <-- Last working version (greater seems to have networking issues)
51 changes: 51 additions & 0 deletions cmake/clang-libcxx20-fpic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#[[
Copyright 2020 The Silkworm Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]

if(XCODE_VERSION)
set(_err "This toolchain is not available for Xcode")
set(_err "${_err} because Xcode ignores CMAKE_C(XX)_COMPILER variable.")
set(_err "${_err} Use xcode.cmake toolchain instead.")
fatal_error(${_err})
endif()

find_program(CMAKE_C_COMPILER clang-10)
find_program(CMAKE_CXX_COMPILER clang++-10)

if(NOT CMAKE_C_COMPILER)
message(FATAL_ERROR "clang not found")
endif()

if(NOT CMAKE_CXX_COMPILER)
message(FATAL_ERROR "clang++ not found")
endif()

set(CMAKE_C_COMPILER "${CMAKE_C_COMPILER}" CACHE STRING "C compiler" FORCE)
set(CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER}" CACHE STRING "C++ compiler" FORCE)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines-ts" CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD 20 CACHE STRING "C++ Standard (toolchain)" FORCE)
set(CMAKE_CXX_STANDARD_REQUIRED YES CACHE BOOL "C++ Standard required" FORCE)
set(CMAKE_CXX_EXTENSIONS NO CACHE BOOL "C++ Standard extensions" FORCE)

set(CMAKE_POSITION_INDEPENDENT_CODE TRUE CACHE BOOL "Position independent code" FORCE)

set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)

cmake_policy(SET CMP0063 NEW)
2 changes: 1 addition & 1 deletion cmake/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
]]

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)

Expand Down
36 changes: 22 additions & 14 deletions cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,32 @@ endif()
find_package(gRPC CONFIG REQUIRED)
find_package(protobuf CONFIG REQUIRED)

file(GLOB_RECURSE SILKRPC_SRC CONFIGURE_DEPENDS
"${CMAKE_SOURCE_DIR}/silkrpc/common/*.cpp"
"${CMAKE_SOURCE_DIR}/silkrpc/common/*.hpp"
"${CMAKE_SOURCE_DIR}/silkrpc/kv/remote/*.cc"
"${CMAKE_SOURCE_DIR}/silkrpc/kv/remote/*.h"
)

add_executable(kv_seek_async_asio kv_seek_async_asio.cpp ${SILKRPC_SRC})
add_compile_options(-std=c++2a)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-fcoroutines)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-stdlib=libc++)
endif()

add_executable(kv_seek_async_asio kv_seek_async_asio.cpp)
target_include_directories(kv_seek_async_asio PRIVATE ${CMAKE_SOURCE_DIR})
target_link_libraries(kv_seek_async_asio absl::flags_parse gRPC::grpc++_unsecure protobuf::libprotobuf silkworm)
target_link_libraries(kv_seek_async_asio absl::flags_parse gRPC::grpc++_unsecure protobuf::libprotobuf silkworm_core silkworm_db silkrpc)

add_executable(kv_seek_async_callback kv_seek_async_callback.cpp)
target_include_directories(kv_seek_async_callback PRIVATE ${CMAKE_SOURCE_DIR})
target_link_libraries(kv_seek_async_callback absl::flags_parse gRPC::grpc++_unsecure protobuf::libprotobuf silkworm_core silkworm_db silkrpc)

add_executable(kv_seek_async_coroutines kv_seek_async_coroutines.cpp)
target_include_directories(kv_seek_async_coroutines PRIVATE ${CMAKE_SOURCE_DIR})
target_link_libraries(kv_seek_async_coroutines absl::flags_parse gRPC::grpc++_unsecure protobuf::libprotobuf silkworm_core silkworm_db silkrpc)

add_executable(kv_seek_async kv_seek_async.cpp ${SILKRPC_SRC})
add_executable(kv_seek_async kv_seek_async.cpp)
target_include_directories(kv_seek_async PRIVATE ${CMAKE_SOURCE_DIR})
target_link_libraries(kv_seek_async absl::flags_parse gRPC::grpc++_unsecure protobuf::libprotobuf silkworm)
target_link_libraries(kv_seek_async absl::flags_parse gRPC::grpc++_unsecure protobuf::libprotobuf silkworm_core silkworm_db silkrpc)

add_executable(kv_seek kv_seek.cpp ${SILKRPC_SRC})
add_executable(kv_seek kv_seek.cpp)
target_include_directories(kv_seek PRIVATE ${CMAKE_SOURCE_DIR})
target_link_libraries(kv_seek absl::flags_parse gRPC::grpc++_unsecure protobuf::libprotobuf silkworm)
target_link_libraries(kv_seek absl::flags_parse gRPC::grpc++_unsecure protobuf::libprotobuf silkworm_core silkworm_db silkrpc)

# Unit tests
enable_testing()
Expand All @@ -49,7 +57,7 @@ find_package(Catch2 CONFIG REQUIRED)

file(GLOB_RECURSE SILKRPC_TESTS CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/silkrpc/*_test.cpp")
add_executable(unit_test unit_test.cpp ${SILKRPC_TESTS})
target_link_libraries(unit_test Catch2::Catch2)
target_link_libraries(unit_test silkrpc Catch2::Catch2)

include(CTest)
include(Catch)
Expand Down
Loading

0 comments on commit a60d6c9

Please sign in to comment.