6#ifndef ALT_INTEGRATION_VERIBLOCK_STATELESS_VALIDATION_H
7#define ALT_INTEGRATION_VERIBLOCK_STATELESS_VALIDATION_H
9#include "blockchain/alt_chain_params.hpp"
10#include "blockchain/btc_chain_params.hpp"
11#include "blockchain/vbk_chain_params.hpp"
12#include "crypto/secp256k1.hpp"
13#include "entities/atv.hpp"
14#include "entities/btcblock.hpp"
15#include "entities/popdata.hpp"
16#include "entities/vbkblock.hpp"
17#include "entities/vtb.hpp"
18#include "pop_stateless_validator.hpp"
20#include "validation_state.hpp"
25bool containsSplit(
const std::vector<uint8_t>& pop_data,
26 const std::vector<uint8_t>& btcTx_data,
27 ValidationState& state);
30template <
typename MerklePathType,
typename HashType1,
typename HashType2>
32 const HashType1& transactionHash,
33 const HashType2& merkleRoot,
35 if (merklePath.subject != transactionHash) {
36 return state.Invalid(
"invalid-merklepath",
37 "Transaction hash cannot be proven by merkle path");
40 auto root = merklePath.calculateMerkleRoot();
41 if (root != merkleRoot) {
42 return state.Invalid(
"invalid-merklepath",
43 "Wrong merkle root. Expected: " + merkleRoot.toHex() +
44 ", got: " + root.toHex());
122bool hasDuplicateIdsOf(
const std::vector<typename P::id_t>& payloadIds) {
123 std::unordered_set<typename P::id_t> ids;
124 for (
const auto&
id : payloadIds) {
125 bool inserted = ids.insert(
id).second;
135bool hasDuplicateIdsOf(
const std::vector<typename P::id_t>& payloadIds,
136 ValidationState& state) {
137 if (hasDuplicateIdsOf<P>(payloadIds)) {
138 return !state.Invalid(P::name() +
"-duplicate",
139 format(
"duplicate {} ids", P::name()));
145bool checkPopDataForDuplicates(
const PopData& popData, ValidationState& state);
Class that is used for storing validation state.
bool checkVbkPopTx(const VbkPopTx &tx, ValidationState &state, const BtcChainParams ¶m, const VbkChainParams &vbk)
Stateless validation for VbkPopTx.
bool checkVTB(const VTB &vtb, ValidationState &state, const BtcChainParams &btc, const VbkChainParams &vbk)
Stateless validation for VTB.
bool checkProofOfWork(const BtcBlock &block, const BtcChainParams ¶m)
Stateless validation for a Block.
bool checkPopData(PopValidator &validator, const PopData &popData, ValidationState &state)
Stateless validation for PopData and all internal PoP payloads.
bool checkVbkBlocks(const std::vector< VbkBlock > &vbkBlocks, ValidationState &state, const VbkChainParams ¶m)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool checkMerklePath(const MerklePathType &merklePath, const HashType1 &transactionHash, const HashType2 &merkleRoot, ValidationState &state)
Verify merkle path.
bool checkVbkTx(const VbkTx &tx, const AltChainParams ¶ms, const VbkChainParams &vbkparams, ValidationState &state)
Stateless validation for VbkTx.
bool checkBlock(const BtcBlock &block, ValidationState &state, const BtcChainParams ¶ms)
Stateless validation for a single block.
bool checkVbkBlockPlausibility(const VbkBlock &block, ValidationState &state, const VbkChainParams ¶ms)
Optimization: VBK block is not plausible if its combination of height+time do not correspond to poten...
bool checkATV(const ATV &atv, ValidationState &state, const AltChainParams &alt, const VbkChainParams &vbkp)
Stateless validation for ATV.
bool checkPublicationData(const PublicationData &pub, const AltChainParams ¶ms, ValidationState &state)
Stateless validation for PublicationData.
bool checkBtcBlocks(const std::vector< BtcBlock > &btcBlocks, ValidationState &state, const BtcChainParams ¶m)
Stateless validation for a chain of Blocks.
bool checkSignature(const VbkTx &tx, ValidationState &state)
Verify signature of a transaction.
bool checkBitcoinTransactionForPoPData(const VbkPopTx &tx, ValidationState &state)
Search BtcTx for POP data.
Base class for all Altchain-related configs.
base class for BTC params
Represents ALT block body of POP-related info.
Publication data about ALT block inside VBK blockchain.
Veriblock to Bitcoin publication, committed to Veriblock blockchain in containingBlock.
VeriBlock chain parameters.
Veriblock POP transaction, which endorses VBK block in BTC blockchain.
Veriblock transaction, which endorses ALT block in VBK blockchain.