Skip to content

Commit 008e63b

Browse files
authored
Feature/verify-post (#84)
* Added PoSt functions Signed-off-by: artyom-yurin <[email protected]>
1 parent a5d3479 commit 008e63b

23 files changed

+1527
-7
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
include:
3131
- os: macOS-latest
3232
env:
33-
CFLAGS: "-I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
33+
CFLAGS: "-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
34+
CXXFLAGS: "-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
3435
steps:
3536
- uses: actions/checkout@v2
3637
name: checkout repo
@@ -45,9 +46,10 @@ jobs:
4546
set -e
4647
if [ "$RUNNER_OS" = "macOS" ]; then
4748
brew install ninja
49+
brew install pkg-config
4850
else
4951
sudo apt-get update || true
50-
sudo apt-get install -y ninja-build python-setuptools
52+
sudo apt-get install -y ninja-build python-setuptools pkg-config ocl-icd-* opencl-headers
5153
fi
5254
5355
pip3 -V || sudo python3 -m pip install --upgrade pip
@@ -58,6 +60,8 @@ jobs:
5860
env:
5961
CC: ${{ matrix.compiler.cc }}
6062
CXX: ${{ matrix.compiler.cxx }}
63+
CFLAGS: ${{ matrix.env.CFLAGS }}
64+
CXXFLAGS: ${{ matrix.env.CXXFLAGS }}
6165
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # has to be included to access other secrets
6266
GITHUB_HUNTER_USERNAME: ${{ secrets.GITHUB_HUNTER_USERNAME }}
6367
GITHUB_HUNTER_TOKEN: ${{ secrets.GITHUB_HUNTER_TOKEN }}

.github/workflows/clang-tidy.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ jobs:
2222
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
2323
- name: install
2424
run: |
25-
brew install ninja llvm
25+
brew install ninja llvm pkg-config
2626
sudo python3 -m pip install --upgrade pip
2727
sudo python3 -m pip install scikit-build cmake requests gitpython gcovr pyyaml
2828
- name: run checks
29+
env:
30+
CFLAGS: "-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
31+
CXXFLAGS: "-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
2932
run: |
3033
#!/bin/bash
3134
LLVM_DIR=/usr/local/Cellar/llvm

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "deps/tinycbor"]
55
path = deps/tinycbor
66
url = https://github.com/intel/tinycbor.git
7+
[submodule "deps/filecoin-ffi"]
8+
path = deps/filecoin-ffi
9+
url = https://github.com/filecoin-project/filecoin-ffi.git

cmake/dependencies.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ find_package(GTest CONFIG REQUIRED)
77
find_package(GMock CONFIG REQUIRED)
88

99
# https://docs.hunter.sh/en/latest/packages/pkg/Boost.html
10-
hunter_add_package(Boost COMPONENTS date_time filesystem random)
11-
find_package(Boost CONFIG REQUIRED date_time filesystem random)
10+
hunter_add_package(Boost COMPONENTS date_time filesystem random system)
11+
find_package(Boost CONFIG REQUIRED date_time filesystem random system)
1212

1313
# https://docs.hunter.sh/en/latest/packages/pkg/Microsoft.GSL.html
1414
hunter_add_package(Microsoft.GSL)

core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ add_subdirectory(storage)
1414
add_subdirectory(fslock)
1515
add_subdirectory(power)
1616
add_subdirectory(vm)
17+
add_subdirectory(proofs)

core/crypto/blake2/blake2b160.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "crypto/blake2/blake2b160.hpp"
77

8+
#include <iostream>
89
#include "crypto/blake2/blake2b.h"
910

1011
namespace fc::crypto::blake2b {
@@ -20,8 +21,7 @@ namespace fc::crypto::blake2b {
2021
return res;
2122
}
2223

23-
Blake2b256Hash blake2b_256(
24-
gsl::span<const uint8_t> to_hash) {
24+
Blake2b256Hash blake2b_256(gsl::span<const uint8_t> to_hash) {
2525
Blake2b256Hash res{};
2626
::blake2b(res.data(),
2727
BLAKE2B256_HASH_LENGTH,
@@ -32,4 +32,28 @@ namespace fc::crypto::blake2b {
3232
return res;
3333
}
3434

35+
Blake2b512Hash blake2b_512_from_file(std::ifstream &file_stream) {
36+
if (!file_stream.is_open()) return {};
37+
38+
blake2b_ctx ctx;
39+
40+
if (blake2b_init(&ctx, BLAKE2B512_HASH_LENGTH, nullptr, 0)) {
41+
return {};
42+
}
43+
44+
const int one_kb = 1024;
45+
std::string bytes(one_kb, ' ');
46+
file_stream.read(bytes.data(), one_kb);
47+
int currently_read = file_stream.gcount();
48+
while (currently_read != 0) {
49+
blake2b_update(&ctx, bytes.data(), currently_read);
50+
file_stream.read(bytes.data(), one_kb);
51+
currently_read = file_stream.gcount();
52+
}
53+
54+
Blake2b512Hash hash;
55+
blake2b_final(&ctx, hash.data());
56+
return hash;
57+
}
58+
3559
} // namespace fc::crypto::blake2b

core/crypto/blake2/blake2b160.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010

1111
#include "common/blob.hpp"
1212
#include "common/outcome.hpp"
13+
#include <fstream>
1314

1415
namespace fc::crypto::blake2b {
1516

1617
const size_t BLAKE2B160_HASH_LENGTH = 20; // 160 BIT
1718
const size_t BLAKE2B256_HASH_LENGTH = 32; // 256 BIT
19+
const size_t BLAKE2B512_HASH_LENGTH = 64; // 512 BIT
1820

1921
using Blake2b160Hash = common::Blob<BLAKE2B160_HASH_LENGTH>;
2022
using Blake2b256Hash = common::Blob<BLAKE2B256_HASH_LENGTH>;
23+
using Blake2b512Hash = common::Blob<BLAKE2B512_HASH_LENGTH>;
2124

2225
/**
2326
* @brief Get blake2b-160 hash
@@ -33,6 +36,8 @@ namespace fc::crypto::blake2b {
3336
*/
3437
Blake2b256Hash blake2b_256(gsl::span<const uint8_t> to_hash);
3538

39+
Blake2b512Hash blake2b_512_from_file(std::ifstream &file_stream);
40+
3641
} // namespace fc::crypto::blake2b
3742

3843
#endif // CPP_FILECOIN_BLAKE2B160_HPP

core/proofs/CMakeLists.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Copyright Soramitsu Co., Ltd. All Rights Reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
6+
add_library(proof_param_provider
7+
proof_param_provider.cpp
8+
proof_param_provider_error.cpp
9+
)
10+
11+
target_link_libraries(proof_param_provider
12+
Boost::system
13+
outcome
14+
blake2
15+
logger
16+
)
17+
18+
add_custom_command(
19+
TARGET proof_param_provider PRE_BUILD
20+
COMMAND ${CMAKE_COMMAND} -E make_directory
21+
/var/tmp/filecoin-proof-parameters)
22+
23+
add_custom_command(
24+
TARGET proof_param_provider PRE_LINK
25+
COMMAND ${CMAKE_COMMAND} -E copy
26+
${CMAKE_CURRENT_SOURCE_DIR}/parameters.json
27+
/var/tmp/filecoin-proof-parameters/parameters.json)
28+
29+
add_library(proofs
30+
proofs.cpp
31+
proofs_error.cpp
32+
)
33+
34+
target_link_libraries(proofs
35+
filecoin_ffi
36+
outcome
37+
blob
38+
proof_param_provider
39+
logger
40+
)

core/proofs/parameters.json

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"v20-proof-of-spacetime-election-5f585aca354eb68e411c8582ed0efd800792430e4e76d73468c4fc03f1a8d6d2.params": {
3+
"cid": "QmX7tYeNPWae2fjZ3Am6GB9dmHvLqvoz8dKo3PR98VYxH9",
4+
"digest": "39a9edec3355516674f0d12b926be493",
5+
"sector_size": 34359738368
6+
},
7+
"v20-proof-of-spacetime-election-5f585aca354eb68e411c8582ed0efd800792430e4e76d73468c4fc03f1a8d6d2.vk": {
8+
"cid": "QmbNGx7pNbGiEr8ykoHxVXHW2LNSmGdsxKtj1onZCyguCX",
9+
"digest": "0227ae7df4f2affe529ebafbbc7540ee",
10+
"sector_size": 34359738368
11+
},
12+
"v20-proof-of-spacetime-election-a4e18190d4b4657ba1b4d08a341871b2a6f398e327cb9951b28ab141fbdbf49d.params": {
13+
"cid": "QmRGZsNp4mp1cZshcXqt3VMuWscAEsiMa2iepF4CsWWoiv",
14+
"digest": "991041a354b12c280542741f58c7f2ca",
15+
"sector_size": 1024
16+
},
17+
"v20-proof-of-spacetime-election-a4e18190d4b4657ba1b4d08a341871b2a6f398e327cb9951b28ab141fbdbf49d.vk": {
18+
"cid": "QmWpmrhCGVcfqLyqp5oGAnhPmCE5hGTPaauHi25mpQwRSU",
19+
"digest": "91fac550e1f9bccab213830bb0c85bd6",
20+
"sector_size": 1024
21+
},
22+
"v20-proof-of-spacetime-election-a9eb6d90b896a282ec2d3a875c6143e3fcff778f0da1460709e051833651559b.params": {
23+
"cid": "QmenSZXh1EsSyHiSRvA6wb8yaPhYBTjrKehJw96Px5HnN4",
24+
"digest": "6322eacd2773163ddd51f9ca7d645fc4",
25+
"sector_size": 1073741824
26+
},
27+
"v20-proof-of-spacetime-election-a9eb6d90b896a282ec2d3a875c6143e3fcff778f0da1460709e051833651559b.vk": {
28+
"cid": "QmPvZoMKofw6eDhDg5ESJA2QAZP8HvM6qMQk7fw4pq9bQf",
29+
"digest": "0df62745fceac922e3e70847cfc70b52",
30+
"sector_size": 1073741824
31+
},
32+
"v20-proof-of-spacetime-election-bf872523641b1de33553db2a177df13e412d7b3b0103e6696ae0a1cf5d525259.params": {
33+
"cid": "QmVibFqzkZoL8cwQmzj8njPokCQGCCx4pBcUH77bzgJgV9",
34+
"digest": "de9d71e672f286706a1673bd57abdaac",
35+
"sector_size": 16777216
36+
},
37+
"v20-proof-of-spacetime-election-bf872523641b1de33553db2a177df13e412d7b3b0103e6696ae0a1cf5d525259.vk": {
38+
"cid": "QmZa5FX27XyiEXQQLQpHqtMJKLzrcY8wMuj3pxzmSimSyu",
39+
"digest": "7f796d3a0f13499181e44b5eee0cc744",
40+
"sector_size": 16777216
41+
},
42+
"v20-proof-of-spacetime-election-ffc3fb192364238b60977839d14e3154d4a98313e30d46694a12af54b6874975.params": {
43+
"cid": "Qmbt2SWWAmMcYoY3DAiRDXA8fAuqdqRLWucJMSxYmzBCmN",
44+
"digest": "151ae0ae183fc141e8c2bebc28e5cc10",
45+
"sector_size": 268435456
46+
},
47+
"v20-proof-of-spacetime-election-ffc3fb192364238b60977839d14e3154d4a98313e30d46694a12af54b6874975.vk": {
48+
"cid": "QmUxvPu4xdVmjMFihUKoYyEdXBqxsXkvmxRweU7KouWHji",
49+
"digest": "95eb89588e9d1832aca044c3a13178af",
50+
"sector_size": 268435456
51+
},
52+
"v20-stacked-proof-of-replication-117839dacd1ef31e5968a6fd13bcd6fa86638d85c40c9241a1d07c2a954eb89b.params": {
53+
"cid": "QmQZe8eLo2xXbhSDxtyYZNqEjqjdcWGdADywECRvNEZQdX",
54+
"digest": "fcd50e2e08a8560a6bb3418e883567ed",
55+
"sector_size": 268435456
56+
},
57+
"v20-stacked-proof-of-replication-117839dacd1ef31e5968a6fd13bcd6fa86638d85c40c9241a1d07c2a954eb89b.vk": {
58+
"cid": "Qme1hn6QT1covfoUFGDZkqoE1pMTax9FNW3nWWmTNqFe7y",
59+
"digest": "872e244d86499fd659082e3bcf3f13e7",
60+
"sector_size": 268435456
61+
},
62+
"v20-stacked-proof-of-replication-b46f3a1051afbb67f70aae7082da95def62eee943662f3e1bf69837fb08aaae4.params": {
63+
"cid": "QmSfrPDC9jwY4MKrjzhCqDBBAG44wSDM8oE5NuDwWSh2xN",
64+
"digest": "0a338b941c5f17946340de5fc95cab30",
65+
"sector_size": 34359738368
66+
},
67+
"v20-stacked-proof-of-replication-b46f3a1051afbb67f70aae7082da95def62eee943662f3e1bf69837fb08aaae4.vk": {
68+
"cid": "QmTDGynCmnbaZNBP3Bv3F3duC3ecKRubCKeMUiQQZYbGpF",
69+
"digest": "c752e070a6b7aa8b79aa661a6b600b55",
70+
"sector_size": 34359738368
71+
},
72+
"v20-stacked-proof-of-replication-e71093863cadc71de61f38311ee45816633973bbf34849316b147f8d2e66f199.params": {
73+
"cid": "QmXjSSnMUnc7EjQBYtTHhvLU3kXJTbUyhVhJRSTRehh186",
74+
"digest": "efa407fd09202dffd15799a8518e73d3",
75+
"sector_size": 1024
76+
},
77+
"v20-stacked-proof-of-replication-e71093863cadc71de61f38311ee45816633973bbf34849316b147f8d2e66f199.vk": {
78+
"cid": "QmYHW3zhQouDP4okFbXSsRMcZ8bokKGvzxqbv7ZrunPMiG",
79+
"digest": "b2f09a0ccb62da28c890d5b881c8dcd2",
80+
"sector_size": 1024
81+
},
82+
"v20-stacked-proof-of-replication-e99a585174b6a45b254ba4780d72c89ad808c305c6d11711009ade4f39dba8e9.params": {
83+
"cid": "QmUhyfNeLb32LfSkjsUwTFYLXQGMj6JQ8daff4DdVMt79q",
84+
"digest": "b53c1916a63839ec345aa2224e9198b7",
85+
"sector_size": 1073741824
86+
},
87+
"v20-stacked-proof-of-replication-e99a585174b6a45b254ba4780d72c89ad808c305c6d11711009ade4f39dba8e9.vk": {
88+
"cid": "QmWReGfbuoozNErbskmFvqV4q36BY6F2WWb4cVFc3zoYkA",
89+
"digest": "20d58a3fae7343481f8298a2dd493dd7",
90+
"sector_size": 1073741824
91+
},
92+
"v20-stacked-proof-of-replication-f571ee2386f4c65a68e802747f2d78691006fc81a67971c4d9641403fffece16.params": {
93+
"cid": "QmSAHu14Pe8iav6BYCt9XkpHJ73XM7tcpY4d9JK9BST9HU",
94+
"digest": "7698426202c7e07b26ef056d31485b3a",
95+
"sector_size": 16777216
96+
},
97+
"v20-stacked-proof-of-replication-f571ee2386f4c65a68e802747f2d78691006fc81a67971c4d9641403fffece16.vk": {
98+
"cid": "QmaKtFLShnhMGVn7P9UsHjkgqtqRFSwCStqqykBN7u8dax",
99+
"digest": "834408e5c3fce6ec5d1bf64e64cee94e",
100+
"sector_size": 16777216
101+
}
102+
}

0 commit comments

Comments
 (0)