Skip to content

Commit

Permalink
806 fix deps build
Browse files Browse the repository at this point in the history
  • Loading branch information
kladkogex committed Feb 26, 2025
1 parent 0824b3f commit 37fc3d2
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 2 deletions.
64 changes: 63 additions & 1 deletion bite/server/BiteBlockFinalizeAndDecryptServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,18 @@
*/


#include "Log.h"

// remove conflict with Google LOG macro definition
#pragma push_macro("LOG")
#undef LOG
#include <proxygen/httpserver/HTTPServer.h>
#include <proxygen/httpserver/RequestHandler.h>
#include <proxygen/httpserver/RequestHandlerFactory.h>
#include <proxygen/httpserver/ResponseBuilder.h>
#include <folly/io/IOBuf.h>
#pragma pop_macro("LOG")


#include "SkaleCommon.h"
#include "chains/Schain.h"
#include "exceptions/FatalError.h"
Expand All @@ -35,6 +46,33 @@

#include "BiteBlockFinalizeAndDecryptServer.h"


class FlatBufferHandlerFactory : public RequestHandlerFactory {
public:
void onServerStart(folly::EventBase* /*evb*/) noexcept override {}
void onServerStop() noexcept override {}

RequestHandler* onRequest(RequestHandler*, HTTPMessage*) noexcept override {
return nullptr;
}
};


/*
int main1(int argc, char* ) {
std::vector<HTTPServer::IPConfig> ipConfigs = {
{SocketAddress("0.0.0.0", 8080, true), HTTPServer::Protocol::HTTP}}
;
HTTPServer server(std::make_unique<FlatBufferHandlerFactory>());
server.bind(ipConfigs);
server.start();
return 0;
}
*/


BiteBlockFinalizeAndDecryptServer::BiteBlockFinalizeAndDecryptServer( Schain& _sChain )
: Agent( _sChain, true ) {

Expand All @@ -44,3 +82,27 @@ BiteBlockFinalizeAndDecryptServer::BiteBlockFinalizeAndDecryptServer( Schain& _s

BiteBlockFinalizeAndDecryptServer::~BiteBlockFinalizeAndDecryptServer() {
}


void BiteBlockFinalizeAndDecryptServer::onBody(std::unique_ptr<IOBuf> _body) noexcept {
// Parse incoming FlatBuffers message
const uint8_t* data = _body->data();
// auto requestMsg = GetRequestMessage(data);

// Extract data from FlatBuffer (replace with your schema fields)
//std::string message = requestMsg->message()->str();

// Create response FlatBuffer
//flatbuffers::FlatBufferBuilder builder;
//auto responseMessage = builder.CreateString("Response to: " + message);
//auto response = CreateResponseMessage(builder, responseMessage);
//builder.Finish(response);

//auto responseBuffer = IOBuf::copyBuffer(builder.GetBufferPointer(), builder.GetSize());
auto responseBuffer = "";
ResponseBuilder(downstream_)
.status(200, "OK")
.header("Content-Type", "application/octet-stream")
.body(std::move(responseBuffer))
.sendWithEOM();
}
34 changes: 33 additions & 1 deletion bite/server/BiteBlockFinalizeAndDecryptServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,50 @@

#pragma once


// remove conflict with Google LOG macro definition
#pragma push_macro("LOG")
#undef LOG
#include <proxygen/httpserver/RequestHandler.h>
#pragma pop_macro("LOG")


#include "Agent.h"

class Schain;
class Node;

using namespace proxygen;
using namespace folly;

class BiteBlockFinalizeAndDecryptServer : public Agent {

class BiteBlockFinalizeAndDecryptServer : public Agent, RequestHandler {

public:

explicit BiteBlockFinalizeAndDecryptServer( Schain& _sChain );

~BiteBlockFinalizeAndDecryptServer() override;


void onRequest(std::unique_ptr<HTTPMessage> ) noexcept override {
// Handle initial request headers
}

void onBody(std::unique_ptr<IOBuf> _body) noexcept override;

void onEOM() noexcept override {
// Handle end of message
}

void onUpgrade(UpgradeProtocol ) noexcept override {}

void requestComplete() noexcept override {
delete this;
}

void onError(ProxygenError ) noexcept override {
delete this;
}
};

37 changes: 37 additions & 0 deletions deps/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ setup_variable WITH_LEVELDB "yes"

setup_variable WITH_FMT "yes"
setup_variable WITH_DOUBLE_CONVERSION "yes"
setup_variable WITH_GFLAGS "yes"
setup_variable WITH_FOLLY "yes"
setup_variable WITH_PROXYGEN "yes"
setup_variable WITH_GOOGLE_LOG "yes"
Expand Down Expand Up @@ -622,6 +623,7 @@ echo -e "${COLOR_VAR_NAME}WITH_CRC32${COLOR_DOTS}.............${COLOR_VAR_DESC}L
echo -e "${COLOR_VAR_NAME}WITH_SNAPPY${COLOR_DOTS}............${COLOR_VAR_DESC}LibSnappy${COLOR_DOTS}..............................${COLOR_VAR_VAL}$WITH_SNAPPY${COLOR_RESET}"
echo -e "${COLOR_VAR_NAME}WITH_LEVELDB${COLOR_DOTS}...........${COLOR_VAR_DESC}LibLevelDB${COLOR_DOTS}.............................${COLOR_VAR_VAL}$WITH_LEVELDB${COLOR_RESET}"
echo -e "${COLOR_VAR_NAME}WITH_FMT${COLOR_DOTS}...............${COLOR_VAR_DESC}LibFMT${COLOR_DOTS}.................................${COLOR_VAR_VAL}$WITH_FMT${COLOR_RESET}"
echo -e "${COLOR_VAR_NAME}WITH_GFLAGS${COLOR_DOTS}............${COLOR_VAR_DESC}LibGFLAGS${COLOR_DOTS}..............................${COLOR_VAR_VAL}$WITH_GFLAGS${COLOR_RESET}"
echo -e "${COLOR_VAR_NAME}WITH_FOLLY${COLOR_DOTS}.............${COLOR_VAR_DESC}LibFolly${COLOR_DOTS}...............................${COLOR_VAR_VAL}$WITH_FOLLY${COLOR_RESET}"
echo -e "${COLOR_VAR_NAME}WITH_PROXYGEN${COLOR_DOTS}..........${COLOR_VAR_DESC}LibProxygen${COLOR_DOTS}............................${COLOR_VAR_VAL}$WITH_PROXYGEN${COLOR_RESET}"
echo -e "${COLOR_VAR_NAME}WITH_DOUBLE_CONVERSION${COLOR_DOTS}.${COLOR_VAR_DESC}LibDoubleConversion${COLOR_DOTS}....................${COLOR_VAR_VAL}$WITH_DOUBLE_CONVERSION${COLOR_RESET}"
Expand Down Expand Up @@ -2656,6 +2658,41 @@ then
fi
fi

#https://github.com/gflags/gflags
#[email protected]:gflags/gflags.git
#https://github.com/gflags/gflags.git
if [ "$WITH_GFLAGS" = "yes" ];
then
echo -e "${COLOR_SEPARATOR}==================== ${COLOR_PROJECT_NAME}libGFLAGS${COLOR_SEPARATOR} ====================================${COLOR_RESET}"
if [ ! -f "$INSTALL_ROOT/lib/libgflags${DEBUG__DEBUG}.a" ];
then
env_restore
cd "$SOURCES_ROOT"
if [ ! -d "gflags" ];
then
echo -e "${COLOR_INFO}unpacking it${COLOR_DOTS}...${COLOR_RESET}"
eval unzip -o "$PREDOWNLOADED_ROOT/gflags-master.zip"
echo -e "${COLOR_INFO}configuring it${COLOR_DOTS}...${COLOR_RESET}"
cd gflags-master
eval mkdir -p build
cd build
eval "$CMAKE" "${CMAKE_CROSSCOMPILING_OPTS}" -DCMAKE_INSTALL_PREFIX="$INSTALL_ROOT" -DCMAKE_BUILD_TYPE="$TOP_CMAKE_BUILD_TYPE" \
-DBUILD_SHARED_LIBS=OFF \
..
cd ..
else
cd gflags-master
fi
echo -e "${COLOR_INFO}building it${COLOR_DOTS}...${COLOR_RESET}"
cd build
eval "$MAKE" "${PARALLEL_MAKE_OPTIONS}"
eval "$MAKE" "${PARALLEL_MAKE_OPTIONS}" install
cd "$SOURCES_ROOT"
else
echo -e "${COLOR_SUCCESS}SKIPPED${COLOR_RESET}"
fi
fi

#https://github.com/facebook/folly
#[email protected]:facebook/folly.git
#https://github.com/facebook/folly.git
Expand Down
14 changes: 14 additions & 0 deletions node/ConsensusEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

#include "zmq.h"

#include <folly/init/Init.h>


#include "Agent.h"
#include "Log.h"
#include "SkaleCommon.h"
Expand Down Expand Up @@ -643,6 +646,15 @@ void ConsensusEngine::systemHealthCheck() {
void ConsensusEngine::init() {
cout << "Consensus engine init(): version:" + ConsensusEngine::getEngineVersion() << endl;

// init folly if it has not been inited


#ifdef CONSENSUS_STANDALONE
// init folly in standalone mode. Otherwise, init is performed by skaled
folly::init(nullptr, nullptr);
#endif


libff::inhibit_profiling_counters = true;

libBLS::ThresholdUtils::initCurve();
Expand Down Expand Up @@ -672,6 +684,8 @@ ConsensusEngine::ConsensusEngine( block_id _lastId, uint64_t _totalStorageLimitB
curl_global_init( CURL_GLOBAL_ALL );




storageLimits = make_shared< StorageLimits >( _totalStorageLimitBytes );

lastCommittedBlockTimeStamp = make_shared< TimeStamp >( 0, 0 );
Expand Down

0 comments on commit 37fc3d2

Please sign in to comment.