From b2e178a2d2e387b147f0d87e64fc773d5ec799d0 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 1 Jun 2016 01:39:56 -0700 Subject: Add deserialize + CheckBlock benchmarks, and a full block hex --- src/bench/checkblock.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/bench/checkblock.cpp (limited to 'src/bench/checkblock.cpp') diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp new file mode 100644 index 000000000..bb596ce7f --- /dev/null +++ b/src/bench/checkblock.cpp @@ -0,0 +1,55 @@ +// Copyright (c) 2016 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "bench.h" + +#include "chainparams.h" +#include "main.h" +#include "consensus/validation.h" + +namespace block_bench { +#include "bench/data/block413567.raw.h" +} + +// These are the two major time-sinks which happen after we have fully received +// a block off the wire, but before we can relay the block on to peers using +// compact block relay. + +static void DeserializeBlockTest(benchmark::State& state) +{ + CDataStream stream((const char*)block_bench::block413567, + (const char*)&block_bench::block413567[sizeof(block_bench::block413567)], + SER_NETWORK, PROTOCOL_VERSION); + char a; + stream.write(&a, 1); // Prevent compaction + + while (state.KeepRunning()) { + CBlock block; + stream >> block; + assert(stream.Rewind(sizeof(block_bench::block413567))); + } +} + +static void DeserializeAndCheckBlockTest(benchmark::State& state) +{ + CDataStream stream((const char*)block_bench::block413567, + (const char*)&block_bench::block413567[sizeof(block_bench::block413567)], + SER_NETWORK, PROTOCOL_VERSION); + char a; + stream.write(&a, 1); // Prevent compaction + + Consensus::Params params = Params(CBaseChainParams::MAIN).GetConsensus(); + + while (state.KeepRunning()) { + CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here + stream >> block; + assert(stream.Rewind(sizeof(block_bench::block413567))); + + CValidationState state; + assert(CheckBlock(block, state, params)); + } +} + +BENCHMARK(DeserializeBlockTest); +BENCHMARK(DeserializeAndCheckBlockTest); -- cgit v1.2.3 From bf49f107ef4fa32c3271010ccd394e2ab3c44b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Jan=C3=ADk?= Date: Thu, 10 Nov 2016 21:38:07 +0100 Subject: Use better name for local variable to prevent -Wshadow compiler warning --- src/bench/checkblock.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/bench/checkblock.cpp') diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp index bb596ce7f..4a564d3fc 100644 --- a/src/bench/checkblock.cpp +++ b/src/bench/checkblock.cpp @@ -46,8 +46,8 @@ static void DeserializeAndCheckBlockTest(benchmark::State& state) stream >> block; assert(stream.Rewind(sizeof(block_bench::block413567))); - CValidationState state; - assert(CheckBlock(block, state, params)); + CValidationState validationState; + assert(CheckBlock(block, validationState, params)); } } -- cgit v1.2.3 From e736772c56a883e2649cc8534dd7857a0718ec56 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 1 Dec 2016 15:45:50 -0800 Subject: Move network-msg-processing code out of main to its own file --- src/bench/checkblock.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/bench/checkblock.cpp') diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp index 4a564d3fc..5243682f8 100644 --- a/src/bench/checkblock.cpp +++ b/src/bench/checkblock.cpp @@ -6,6 +6,7 @@ #include "chainparams.h" #include "main.h" +#include "streams.h" #include "consensus/validation.h" namespace block_bench { -- cgit v1.2.3 From 76faa3cdfedbd3fc91be4ecfff77fc6dc18134fb Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 1 Dec 2016 16:06:41 -0800 Subject: Rename the remaining main.{h,cpp} to validation.{h,cpp} --- src/bench/checkblock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bench/checkblock.cpp') diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp index 5243682f8..230e4ca77 100644 --- a/src/bench/checkblock.cpp +++ b/src/bench/checkblock.cpp @@ -5,7 +5,7 @@ #include "bench.h" #include "chainparams.h" -#include "main.h" +#include "validation.h" #include "streams.h" #include "consensus/validation.h" -- cgit v1.2.3 From 1be681a1b97b686f838af90682a57f2030d26015 Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Thu, 28 Dec 2017 15:04:08 +0000 Subject: Modify chain consensus parameters to be height aware (#1396) * Modify chain consensus parameters to be height aware * Correct implementation of simplified rewards in parameters * Correct max money * Use base block version in IsSuperMajority() instead of full version * Correct mining of blocks in AuxPoW tests * Add in missing pre-AuxPoW consensus checks --- src/bench/checkblock.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/bench/checkblock.cpp') diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp index 230e4ca77..77181b296 100644 --- a/src/bench/checkblock.cpp +++ b/src/bench/checkblock.cpp @@ -40,15 +40,13 @@ static void DeserializeAndCheckBlockTest(benchmark::State& state) char a; stream.write(&a, 1); // Prevent compaction - Consensus::Params params = Params(CBaseChainParams::MAIN).GetConsensus(); - while (state.KeepRunning()) { CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here stream >> block; assert(stream.Rewind(sizeof(block_bench::block413567))); CValidationState validationState; - assert(CheckBlock(block, validationState, params)); + assert(CheckBlock(block, validationState)); } } -- cgit v1.2.3