Skip to content

Commit 55b9ca4

Browse files
authored
Apply pre-commit (#997)
1 parent 4d3884f commit 55b9ca4

File tree

291 files changed

+640
-656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+640
-656
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
BasedOnStyle: Google
22
BinPackArguments: false
3-
BinPackParameters: false
3+
BinPackParameters: false

.clang-tidy

-1
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,3 @@ CheckOptions:
159159
- key: cert-msc32-c.DisallowedSeedTypes
160160
value: 'time_t,std::time_t'
161161
...
162-

.github/workflows/doxygen.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
uses: JamesIves/[email protected]
3131
with:
3232
branch: docs
33-
folder: build/docs/html
33+
folder: build/docs/html

.github/workflows/fuzz.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ jobs:
6262
with:
6363
commit_changes: Update corpus ${{ github.sha }}
6464
branch: master
65-
repository: ${{ github.workspace }}/fuzz-corpus
65+
repository: ${{ github.workspace }}/fuzz-corpus

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
### Requirements for Pull-Requests
1212

13-
A Pull-Request can be merged into `master` only if:
13+
A Pull-Request can be merged into `master` only if:
1414

1515
1. Code is formatted with `clang-format`.
1616
2. Continuous Integration system is green (all checks passed).

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,4 @@ This License, the documents related to it and any agreement that incorporates an
160160

161161
**"Source Code"** means, as it pertains to a Covered Work or a Program, those statements in a computer language which, when processed by a compiler, assembler or interpreter, become executable by a computer and includes, without limitation, all comments, notes, flow charts, decision tables, argument lists and other human readable references relating to the operation, purpose, compilation, assembly or interpretation thereof.
162162

163-
**"Special Conditions"** means Chapter II (Special Conditions) of this License.
163+
**"Special Conditions"** means Chapter II (Special Conditions) of this License.

benchmark/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ addbenchmark(progpow progpow.cpp)
1818
addbenchmark(keccakf800 keccakf800.cpp)
1919
addbenchmark(stateless_validation stateless_validation.cpp)
2020
addbenchmark(cache cache.cpp)
21-
addbenchmark(mempool mempool.cpp)
21+
addbenchmark(mempool mempool.cpp)

benchmark/cache.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ static void ThirdPartyLRUCacheWithMutex(benchmark::State& state) {
3939
}
4040
}
4141

42-
4342
static void ThirdPartyLRUCacheWithoutMutex(benchmark::State& state) {
4443
srand(0);
4544
lru11::Cache<int, std::shared_ptr<int>, lru11::NullLock> cache(SIZE);

benchmark/mempool.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
#include <benchmark/benchmark.h>
77

88
#include <veriblock/pop/mempool.hpp>
9+
#include <veriblock/pop/mock_miner.hpp>
910
#include <veriblock/pop/storage/adaptors/block_provider_impl.hpp>
1011
#include <veriblock/pop/storage/adaptors/inmem_storage_impl.hpp>
1112
#include <veriblock/pop/storage/adaptors/payloads_provider_impl.hpp>
12-
#include <veriblock/pop/mock_miner.hpp>
1313

1414
using namespace altintegration;
1515

16-
struct MempoolFixture: public benchmark::Fixture {
16+
struct MempoolFixture : public benchmark::Fixture {
1717
MempoolFixture() {
1818
auto BTCgenesis = GetRegTestBtcBlock();
1919
auto VBKgenesis = GetRegTestVbkBlock();
@@ -31,14 +31,13 @@ struct MempoolFixture: public benchmark::Fixture {
3131

3232
void SetUp(const ::benchmark::State&) {
3333
// generate 100 vbk blocks
34-
for(int i = 0; i < 100; i++) {
34+
for (int i = 0; i < 100; i++) {
3535
auto block = popminer.mineVbkBlocks(1);
3636
assert(mempool.submit(block->getHeader(), false, val_state));
3737
}
3838
}
3939

40-
void TearDown(const ::benchmark::State&) {
41-
}
40+
void TearDown(const ::benchmark::State&) {}
4241

4342
AltChainParamsRegTest altparam{};
4443
VbkChainParamsRegTest vbkparam{};
@@ -58,13 +57,14 @@ struct MempoolFixture: public benchmark::Fixture {
5857
ValidationState val_state;
5958
};
6059

61-
BENCHMARK_DEFINE_F(MempoolFixture, Mempool_generatePopData)(benchmark::State& state) {
62-
for (auto _ : state) {
63-
auto pop_data = mempool.generatePopData();
64-
(void)pop_data;
65-
}
60+
BENCHMARK_DEFINE_F(MempoolFixture, Mempool_generatePopData)
61+
(benchmark::State& state) {
62+
for (auto _ : state) {
63+
auto pop_data = mempool.generatePopData();
64+
(void)pop_data;
65+
}
6666
}
6767

6868
BENCHMARK_REGISTER_F(MempoolFixture, Mempool_generatePopData);
6969
// Run the benchmark
70-
BENCHMARK_MAIN();
70+
BENCHMARK_MAIN();

benchmark/progpow.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ static void ProgpowEpochUnCached(benchmark::State& state) {
2929
}
3030
}
3131

32-
BENCHMARK(ProgpowEpochCached)->Unit(benchmark::kMillisecond);;
33-
BENCHMARK(ProgpowEpochUnCached)->Unit(benchmark::kMillisecond);;
32+
BENCHMARK(ProgpowEpochCached)->Unit(benchmark::kMillisecond);
33+
;
34+
BENCHMARK(ProgpowEpochUnCached)->Unit(benchmark::kMillisecond);
35+
;
3436
// Run the benchmark
3537
BENCHMARK_MAIN();

benchmark/vbk_sig.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ static auto defaultSignatureVbk =
2222
"3044022008d07afee77324d0bced6f3bce19892d0413981e83e68401cd83d1e1ed3bc37c022005273429062dcf623ccd04c8d9c9e601e7fc45b5db32900c9b0ffda2dbc8f452"_unhex;
2323

2424
static void VerifySecp256k1Sig(benchmark::State& state) {
25-
auto privateKey = altintegration::secp256k1::privateKeyFromVbk(defaultPrivateKeyVbk);
25+
auto privateKey =
26+
altintegration::secp256k1::privateKeyFromVbk(defaultPrivateKeyVbk);
2627
auto publicKey = altintegration::secp256k1::derivePublicKey(privateKey);
2728

2829
for (auto _ : state) {
29-
altintegration::secp256k1::verify(defaultMsg, defaultSignatureVbk, publicKey);
30+
altintegration::secp256k1::verify(
31+
defaultMsg, defaultSignatureVbk, publicKey);
3032
}
3133
}
3234
// Register the function as a benchmark

bindings/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
add_subdirectory(go)
1+
add_subdirectory(go)

cmake/asan.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ function(enable_asan_on_target target)
1414
set(ENV{ASAN_OPTIONS} detect_container_overflow=0:verbosity=1:debug=1:detect_leaks=1:check_initialization_order=1:alloc_dealloc_mismatch=true:use_odr_indicator=true)
1515
endif()
1616
endfunction()
17-

cmake/backward.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ endif()
2828
FetchContent_Declare(
2929
backward
3030
GIT_REPOSITORY https://github.com/bombela/backward-cpp.git
31-
GIT_TAG 74184aad55777f0c04227edd56c3dea84b6a272f
31+
GIT_TAG f30744bcf726ea3735df7ecf9e9de9ddac540283
3232
GIT_PROGRESS TRUE
3333
GIT_SHALLOW TRUE
3434
USES_TERMINAL_DOWNLOAD TRUE

cmake/leveldb.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
2828
endif()
2929

3030

31-
add_compile_definitions(WITH_LEVELDB)
31+
add_compile_definitions(WITH_LEVELDB)

cmake/lib.pc.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Description: Libraries for leveraging VeriBlock Proof-Of-Proof blockchain techno
66
Version: @PROJECT_VERSION@
77
URL: https://github.com/VeriBlock/alt-integration-cpp
88
Libs: -L${libdir} -l@LIB_NAME@ @VBK_DEPENDENCIES_LIBS@ -lstdc++ -lm @SANITIZERS_LIBS@
9-
Cflags: -I${includedir} @SANITIZERS_CFLAGS@ @ADDITIONAL_CFLAGS@
9+
Cflags: -I${includedir} @SANITIZERS_CFLAGS@ @ADDITIONAL_CFLAGS@

cmake/rocksdb.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
5555
target_add_flag(rocksdb /wd4242)
5656
endif()
5757

58-
add_compile_definitions(WITH_ROCKSDB)
58+
add_compile_definitions(WITH_ROCKSDB)

cmake/ubsan.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ function(enable_ubsan_on_target target)
1111
set(ENV{UBSAN_OPTIONS} print_stacktrace=1)
1212
endif()
1313
endfunction()
14-

docs/build.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $ mkdir build
1515
$ cd build
1616

1717
# build static library in release mode
18-
$ cmake .. -DCMAKE_BUILD_TYPE=Release -DSHARED=OFF
18+
$ cmake .. -DCMAKE_BUILD_TYPE=Release -DSHARED=OFF
1919
$ make -j
2020

2121
# install it in your OS globally

docs/description.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- altintegration::VTB - Cryptographic proof of VeriBlock block header publication in Bitcoin.
1111
- altintegration::VbkBlock - VeriBlock block header.
1212
- Payloads - ATV, VTB, VbkBlock sometimes can be referred to as "payloads".
13-
- altintegration::PopData - contains a list of VTBs, a list of ATVs, and a list of VBK blocks, called "Context".
13+
- altintegration::PopData - contains a list of VTBs, a list of ATVs, and a list of VBK blocks, called "Context".
1414
- APM - Altchain PoP Miner.
1515
- VPM - VeriBlock PoP Miner.
1616
- Security Providing Chain (SP Chain) - blockchain, which stores endorsements and is used for providing security for SI chain.
@@ -31,14 +31,14 @@
3131

3232
![Network Topology](./img/topology.png)
3333

34-
PoP security is built around "endorsing" blocks.
34+
PoP security is built around "endorsing" blocks.
3535
When miners want to increase likelyhood of finalizing a block, they "endorse" it and blocks after it by creating "endorsing transaction" in SP chain.
3636

3737
In example above, we see 3 chains (top-down): Bitcoin, VeriBlock, Altchain.
3838

3939
In Altchain, we want to finalize block A100, then:
4040
1. APM creates altintegration::VbkTx, which contains altintegration::PublicationData - an entity, which contains Endorsed Block header, and Payout Information - for rewarding APM for this endorsement.
41-
2. This VBK TX is sent to VeriBlock.
41+
2. This VBK TX is sent to VeriBlock.
4242
3. VBK POW miners create block V54 - this block will include this VBK TX from step above.
4343
4. APM builds cryptographic proof that endorsement of Altchain block is added to main chain. This proof is named ATV (Altchain to VeriBlock publication) and includes: VBK TX, Context (VBK blocks connecting V54 to V51 - V52..V53), Block Of Proof (V54), Merkle Path which proves that VBK TX is really inside V54.
4444
5. Then all this data is sent to Altchain, and added to PoP MemPool.
@@ -51,12 +51,12 @@ Continuing this example, VPM does exactly the same algorithm but with VBK blocks
5151

5252
@note Endorsement Settlement Interval for VeriBlock is 400 blocks, PoP Payout Delay is also 400 blocks.
5353

54-
Block V54 contains proof for A100, and B16 contains proof for block V56.
54+
Block V54 contains proof for A100, and B16 contains proof for block V56.
5555
Since V56 is after V54, and V56 is finalized, we finalize all previous blocks, including V54, thus
5656
Altchain transitively inherits security of Bitcoin.
5757

5858
@note We count endorsements, whose according blocks of proof **are on main chains** of according blockchains. An endorsement whose block of proof is not on the main chain of SP chain is not eligible for PoP Payout.
5959

60-
You can also notice that VTBs and VBK blocks are sent to Altchain.
60+
You can also notice that VTBs and VBK blocks are sent to Altchain.
6161
This is needed to communicate Bitcoin and VeriBlock consensus information to Altchain.
6262
APM implementation continuously submits VBK blocks and VTBs found on VeriBlock network to Altchain, so it is important to have at least 1 APM running continuously for the whole network.

docs/families/btc/integration_10_fr.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Add additional failure codes.
134134
+{
135135
+ AssertLockHeld(cs_main);
136136
+ CBlockIndex* bestCandidate = m_chain.Tip();
137-
137+
138138
- // Find the best candidate header.
139139
- {
140140
- std::set<CBlockIndex*, CBlockIndexWorkComparator>::reverse_iterator it = setBlockIndexCandidates.rbegin();
@@ -277,7 +277,7 @@ Add additional failure codes.
277277
[method CChainState::ActivateBestChain](https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/validation.cpp#L2856)
278278
```cpp
279279
ConnectTrace connectTrace(mempool); // Destructed before cs_main is unlocked
280-
280+
281281
- if (pindexMostWork == nullptr) {
282282
- pindexMostWork = FindMostWorkChain();
283283
+ if (pblock && pindexBestChain == nullptr) {
@@ -297,13 +297,13 @@ Add additional failure codes.
297297
+ if (pindexBestChain == nullptr) {
298298
+ pindexBestChain = FindBestChain();
299299
}
300-
300+
301301
// Whether we have anything to do at all.
302302
- if (pindexMostWork == nullptr || pindexMostWork == m_chain.Tip()) {
303303
+ if (pindexBestChain == nullptr || pindexBestChain == m_chain.Tip()) {
304304
break;
305305
}
306-
306+
307307
+ assert(pindexBestChain);
308308
+ // if pindexBestHeader is a direct successor of pindexBestChain, pindexBestHeader is still best.
309309
+ // otherwise pindexBestChain is new best pindexBestHeader
@@ -352,7 +352,7 @@ Add additional failure codes.
352352
```cpp
353353
InvalidChainFound(to_mark_failed);
354354
}
355-
355+
356356
+ PruneBlockIndexCandidates();
357357
+
358358
// Only notify about a new block tip if the active chain was modified.
@@ -377,7 +377,7 @@ Add additional failure codes.
377377
[method CChainState::ResetBlockFailureFlags](https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/validation.cpp#L3162)
378378
```cpp
379379
}
380-
380+
381381
+ PruneBlockIndexCandidates();
382382
+
383383
// Remove the invalidity flag from all ancestors too.
@@ -475,4 +475,4 @@ Pop fork resolution test: [https://github.com/VeriBlock/vbk-ri-btc/blob/master/s
475475
- vbk/test/unit/pop_reward_tests.cpp
476476
+ vbk/test/unit/pop_reward_tests.cpp \
477477
+ vbk/test/unit/forkresolution_tests.cpp
478-
```
478+
```

docs/families/btc/integration_11_p2p.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,20 @@ P2P source: [https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/vbk/p2p_syn
9595
{
9696
if (count == 0)
9797
return;
98-
98+
9999
vBlocks.reserve(vBlocks.size() + count);
100100
- CNodeState *state = State(nodeid);
101101
- assert(state != nullptr);
102102
-
103103
- // Make sure pindexBestKnownBlock is up to date, we'll need it.
104104
- ProcessBlockAvailability(nodeid);
105-
105+
106106
- if (state->pindexBestKnownBlock == nullptr || state->pindexBestKnownBlock->nChainWork < ::ChainActive().Tip()->nChainWork || state->pindexBestKnownBlock->nChainWork < nMinimumChainWork) {
107107
+ if (bestBlock == nullptr || bestBlock->nChainWork < nMinimumChainWork) {
108108
// This peer has nothing interesting.
109109
return;
110110
}
111-
111+
112112
- if (state->pindexLastCommonBlock == nullptr) {
113113
+ assert(lastCommonBlockOut);
114114
+
@@ -118,15 +118,15 @@ P2P source: [https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/vbk/p2p_syn
118118
- state->pindexLastCommonBlock = ::ChainActive()[std::min(state->pindexBestKnownBlock->nHeight, ::ChainActive().Height())];
119119
+ *lastCommonBlockOut = ::ChainActive()[std::min(bestBlock->nHeight, ::ChainActive().Height())];
120120
}
121-
121+
122122
// If the peer reorganized, our previous pindexLastCommonBlock may not be an ancestor
123123
// of its current tip anymore. Go back enough to fix that.
124124
- state->pindexLastCommonBlock = LastCommonAncestor(state->pindexLastCommonBlock, state->pindexBestKnownBlock);
125125
- if (state->pindexLastCommonBlock == state->pindexBestKnownBlock)
126126
+ *lastCommonBlockOut = LastCommonAncestor(*lastCommonBlockOut, bestBlock);
127127
+ if (*lastCommonBlockOut == bestBlock)
128128
return;
129-
129+
130130
std::vector<const CBlockIndex*> vToFetch;
131131
- const CBlockIndex *pindexWalk = state->pindexLastCommonBlock;
132132
+ const CBlockIndex *pindexWalk = *lastCommonBlockOut;
@@ -248,15 +248,15 @@ P2P source: [https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/vbk/p2p_syn
248248
[method PeerLogicValidation::FinalizeNode](https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/net_processing.cpp#L799)
249249
```cpp
250250
assert(g_outbound_peers_with_protect_from_disconnect >= 0);
251-
251+
252252
mapNodeState.erase(nodeid);
253253
+ // VeriBlock
254254
+ VeriBlock::p2p::erasePopDataNodeState(nodeid);
255255
```
256256
[method ProcessMessage](https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/net_processing.cpp#L1919)
257257
```cpp
258258
}
259-
259+
260260
+ // VeriBlock: if POP is not enabled, ignore POP-related P2P calls
261261
+ int tipHeight = ChainActive().Height();
262262
+ if (Params().isPopActive(tipHeight)) {
@@ -265,15 +265,15 @@ P2P source: [https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/vbk/p2p_syn
265265
+ return pop_res;
266266
+ }
267267
+ }
268-
268+
269269
if (!(pfrom->GetLocalServices() & NODE_BLOOM) &&
270270
(strCommand == NetMsgType::FILTERLOAD ||
271271
```
272272
[method PeerLogicValidation::SendMessages](https://github.com/VeriBlock/vbk-ri-btc/blob/master/src/net_processing.cpp#L3596)
273273
```cpp
274274
if (!vInv.empty())
275275
connman->PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
276-
276+
277277
+ // VeriBlock offer Pop Data
278278
+ {
279279
+ VeriBlock::p2p::offerPopData<altintegration::ATV>(pto, connman, msgMaker);
@@ -313,4 +313,4 @@ libbitcoin_server_a_SOURCES = \
313313
+ vbk/p2p_sync.hpp \
314314
+ vbk/p2p_sync.cpp \
315315
rpc/blockchain.cpp \
316-
```
316+
```

0 commit comments

Comments
 (0)