Skip to content

Commit

Permalink
chore: merge v4 and v5 network version to same version
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrankovi committed Dec 18, 2024
1 parent 4fef314 commit 92005e1
Show file tree
Hide file tree
Showing 39 changed files with 150 additions and 215 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(TARAXA_PATCH_VERSION 1)
set(TARAXA_VERSION ${TARAXA_MAJOR_VERSION}.${TARAXA_MINOR_VERSION}.${TARAXA_PATCH_VERSION})

# Any time a change in the network protocol is introduced this version should be increased
set(TARAXA_NET_VERSION 5)
set(TARAXA_NET_VERSION 4)
# Major version is modified when DAG blocks, pbft blocks and any basic building blocks of our blockchain is modified
# in the db
set(TARAXA_DB_MAJOR_VERSION 1)
Expand Down
2 changes: 1 addition & 1 deletion libraries/common/include/common/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ constexpr uint32_t kDefaultTransactionPoolSize{200000};
constexpr uint32_t kMaxNonFinalizedTransactions{1000000};
constexpr uint32_t kMaxNonFinalizedDagBlocks{100};

const size_t kV4NetworkVersion = 4;
const size_t kV3NetworkVersion = 3;

const uint32_t kRecentlyFinalizedTransactionsFactor = 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FinalChain;

} // namespace taraxa

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class ExtPillarVotePacketHandler : public PacketHandler {
public:
Expand All @@ -32,4 +32,4 @@ class ExtPillarVotePacketHandler : public PacketHandler {
std::shared_ptr<pillar_chain::PillarChainManager> pillar_chain_manager_;
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace taraxa::network::tarcap {
class PbftSyncingState;
}

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

/**
* @brief ExtSyncingPacketHandler is extended abstract PacketHandler with added functions that are used in packet
Expand Down Expand Up @@ -63,4 +63,4 @@ class ExtSyncingPacketHandler : public PacketHandler {
std::shared_ptr<DbStorage> db_{nullptr};
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class VoteManager;
class SlashingManager;
} // namespace taraxa

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

/**
* @brief ExtVotesPacketHandler is extended abstract PacketHandler with added functions that are used in packet
Expand Down Expand Up @@ -88,4 +88,4 @@ class ExtVotesPacketHandler : public PacketHandler {
std::shared_ptr<SlashingManager> slashing_manager_;
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "network/tarcap/taraxa_peer.hpp"
#include "network/threadpool/packet_data.hpp"

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

// class TimePeriodPacketsStats;

Expand Down Expand Up @@ -83,4 +83,4 @@ class PacketHandler : public BasePacketHandler {
LOG_OBJECTS_DEFINE
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace taraxa {
class TransactionManager;
} // namespace taraxa

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class DagBlockPacketHandler : public ExtSyncingPacketHandler {
public:
Expand Down Expand Up @@ -34,4 +34,4 @@ class DagBlockPacketHandler : public ExtSyncingPacketHandler {
std::shared_ptr<TransactionManager> trx_mgr_{nullptr};
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace taraxa {
class TransactionManager;
} // namespace taraxa

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class DagSyncPacketHandler : public ExtSyncingPacketHandler {
public:
Expand All @@ -28,4 +28,4 @@ class DagSyncPacketHandler : public ExtSyncingPacketHandler {
std::shared_ptr<TransactionManager> trx_mgr_{nullptr};
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DbStorage;
class TransactionManager;
} // namespace taraxa

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class GetDagSyncPacketHandler : public PacketHandler {
public:
Expand All @@ -35,4 +35,4 @@ class GetDagSyncPacketHandler : public PacketHandler {
std::shared_ptr<DbStorage> db_;
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PbftManager;
class VoteManager;
} // namespace taraxa

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class GetNextVotesBundlePacketHandler : public ExtVotesPacketHandler {
public:
Expand All @@ -26,4 +26,4 @@ class GetNextVotesBundlePacketHandler : public ExtVotesPacketHandler {
virtual void process(const threadpool::PacketData& packet_data, const std::shared_ptr<TaraxaPeer>& peer) override;
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
#pragma once

#include "common/packet_handler.hpp"

#include "../v3/common/packet_handler.hpp"
namespace taraxa {
class PbftChain;
class DbStorage;
class VoteManager;
} // namespace taraxa

namespace taraxa::network::tarcap {
class PbftSyncingState;
}

namespace taraxa::network::tarcap::v4 {

namespace taraxa::network::tarcap::v3 {
class GetPbftSyncPacketHandler : public PacketHandler {
public:
GetPbftSyncPacketHandler(const FullNodeConfig& conf, std::shared_ptr<PeersState> peers_state,
std::shared_ptr<TimePeriodPacketsStats> packets_stats,
GetPbftSyncPacketHandler(const FullNodeConfig& conf, std::shared_ptr<taraxa::network::tarcap::PeersState> peers_state,
std::shared_ptr<taraxa::network::tarcap::TimePeriodPacketsStats> packets_stats,
std::shared_ptr<PbftSyncingState> pbft_syncing_state, std::shared_ptr<PbftChain> pbft_chain,
std::shared_ptr<VoteManager> vote_mgr, std::shared_ptr<DbStorage> db,
const addr_t& node_addr, const std::string& logs_prefix = "GET_PBFT_SYNC_PH");

// Packet type that is processed by this handler
static constexpr SubprotocolPacketType kPacketType_ = SubprotocolPacketType::kGetPbftSyncPacket;

private:
virtual void validatePacketRlpFormat(const threadpool::PacketData& packet_data) const override;
virtual void process(const threadpool::PacketData& packet_data, const std::shared_ptr<TaraxaPeer>& peer) override;

virtual void sendPbftBlocks(const std::shared_ptr<TaraxaPeer>& peer, PbftPeriod from_period,
size_t blocks_to_transfer, bool pbft_chain_synced);

Expand All @@ -38,5 +31,4 @@ class GetPbftSyncPacketHandler : public PacketHandler {
std::shared_ptr<VoteManager> vote_mgr_;
std::shared_ptr<DbStorage> db_;
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "common/packet_handler.hpp"
#include "pillar_chain/pillar_chain_manager.hpp"

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class GetPillarVotesBundlePacketHandler : public PacketHandler {
public:
Expand All @@ -28,4 +28,4 @@ class GetPillarVotesBundlePacketHandler : public PacketHandler {
std::shared_ptr<pillar_chain::PillarChainManager> pillar_chain_manager_;
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#pragma once

#include "common/ext_syncing_packet_handler.hpp"
#include "../v3/common/ext_syncing_packet_handler.hpp"
#include "common/thread_pool.hpp"
#include "vote_manager/vote_manager.hpp"

namespace taraxa::network::tarcap::v4 {

namespace taraxa::network::tarcap::v3 {
class PbftSyncPacketHandler : public ExtSyncingPacketHandler {
public:
PbftSyncPacketHandler(const FullNodeConfig& conf, std::shared_ptr<PeersState> peers_state,
Expand All @@ -14,9 +11,7 @@ class PbftSyncPacketHandler : public ExtSyncingPacketHandler {
std::shared_ptr<PbftManager> pbft_mgr, std::shared_ptr<DagManager> dag_mgr,
std::shared_ptr<VoteManager> vote_mgr, std::shared_ptr<DbStorage> db, const addr_t& node_addr,
const std::string& logs_prefix = "PBFT_SYNC_PH");

void handleMaliciousSyncPeer(const dev::p2p::NodeID& id);

// Packet type that is processed by this handler
static constexpr SubprotocolPacketType kPacketType_ = SubprotocolPacketType::kPbftSyncPacket;

Expand All @@ -27,17 +22,12 @@ class PbftSyncPacketHandler : public ExtSyncingPacketHandler {
protected:
virtual PeriodData decodePeriodData(const dev::RLP& period_data_rlp) const;
virtual std::vector<std::shared_ptr<PbftVote>> decodeVotesBundle(const dev::RLP& votes_bundle_rlp) const;

void pbftSyncComplete();
void delayedPbftSync(uint32_t counter);

static constexpr uint32_t kDelayedPbftSyncDelayMs = 10;

std::shared_ptr<VoteManager> vote_mgr_;
util::ThreadPool periodic_events_tp_;

static constexpr size_t kStandardPacketSize = 2;
static constexpr size_t kChainSyncedPacketSize = 3;
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include "network/tarcap/packets_handlers/v4/common/ext_pillar_vote_packet_handler.hpp"
#include "network/tarcap/packets_handlers/v3/common/ext_pillar_vote_packet_handler.hpp"

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class PillarVotePacketHandler : public ExtPillarVotePacketHandler {
public:
Expand All @@ -22,4 +22,4 @@ class PillarVotePacketHandler : public ExtPillarVotePacketHandler {
virtual void process(const threadpool::PacketData& packet_data, const std::shared_ptr<TaraxaPeer>& peer) override;
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include "network/tarcap/packets_handlers/v4/common/ext_pillar_vote_packet_handler.hpp"
#include "network/tarcap/packets_handlers/v3/common/ext_pillar_vote_packet_handler.hpp"

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class PillarVotesBundlePacketHandler : public ExtPillarVotePacketHandler {
public:
Expand All @@ -22,4 +22,4 @@ class PillarVotesBundlePacketHandler : public ExtPillarVotePacketHandler {
constexpr static size_t kMaxPillarVotesInBundleRlp{250};
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "common/ext_syncing_packet_handler.hpp"

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class StatusPacketHandler : public ExtSyncingPacketHandler {
public:
Expand Down Expand Up @@ -30,4 +30,4 @@ class StatusPacketHandler : public ExtSyncingPacketHandler {
const h256 kGenesisHash;
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TransactionManager;
enum class TransactionStatus;
} // namespace taraxa

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class TestState;

Expand Down Expand Up @@ -75,4 +75,4 @@ class TransactionPacketHandler : public PacketHandler {
std::atomic<uint64_t> unique_received_trx_count_{0};
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "common/ext_votes_packet_handler.hpp"

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class VotePacketHandler : public ExtVotesPacketHandler {
public:
Expand Down Expand Up @@ -36,4 +36,4 @@ class VotePacketHandler : public ExtVotesPacketHandler {
const size_t kExtendedVotePacketSize{3};
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "common/ext_votes_packet_handler.hpp"

namespace taraxa::network::tarcap::v4 {
namespace taraxa::network::tarcap::v3 {

class VotesBundlePacketHandler : public ExtVotesPacketHandler {
public:
Expand Down Expand Up @@ -30,4 +30,4 @@ class VotesBundlePacketHandler : public ExtVotesPacketHandler {
virtual void process(const threadpool::PacketData& packet_data, const std::shared_ptr<TaraxaPeer>& peer) override;
};

} // namespace taraxa::network::tarcap::v4
} // namespace taraxa::network::tarcap::v3
Loading

0 comments on commit 92005e1

Please sign in to comment.