Skip to content

Commit

Permalink
Restart scilla process at vacuous epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
chetan-zilliqa committed Aug 22, 2023
1 parent 301eb08 commit 1ef8b00
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libDirectoryService/FinalBlockPostProcessing.cpp
Expand Up @@ -34,6 +34,7 @@
#include "libUtils/DataConversion.h"
#include "libUtils/DetachedFunction.h"
#include "libUtils/Logger.h"
#include "libScilla/ScillaClient.h"

using namespace std;
using namespace boost::multiprecision;
Expand Down Expand Up @@ -220,6 +221,9 @@ void DirectoryService::ProcessFinalBlockConsensusWhenDone() {
}

if (isVacuousEpoch) {
// Restart scilla client after every vacuous epoch
ScillaClient::GetInstance().RestartScillaClient();

auto writeStateToDisk = [this]() -> void {
if (!AccountStore::GetInstance().MoveUpdatesToDisk(
m_mediator.m_dsBlockChain.GetLastBlock()
Expand Down
15 changes: 15 additions & 0 deletions src/libScilla/ScillaClient.cpp
Expand Up @@ -126,7 +126,22 @@ bool ScillaClient::OpenServer(uint32_t version) {
return true;
}

void ScillaClient::RestartScillaClient() {
LOG_MARKER();
if (ENABLE_SCILLA_MULTI_VERSION == true) {
LOG_GENERAL(INFO, "ENABLE_SCILLA_MULTI_VERSION is true");
for (const auto& entry : m_clients) {
LOG_GENERAL(INFO, "entry.first = " << entry.first);
CheckClient(entry.first, true);
}
} else {
LOG_GENERAL(INFO, "ENABLE_SCILLA_MULTI_VERSION is false");
CheckClient(0, true);
}
}

bool ScillaClient::CheckClient(uint32_t version, bool enforce) {
LOG_GENERAL(INFO, "CheckClient = " << version << " enforce = " << enforce);
std::lock_guard<std::mutex> g(m_mutexMain);

if (m_clients.find(version) != m_clients.end() && !enforce) {
Expand Down
2 changes: 2 additions & 0 deletions src/libScilla/ScillaClient.h
Expand Up @@ -44,6 +44,8 @@ class ScillaClient {

bool CheckClient(uint32_t version, bool enforce = false);

void RestartScillaClient();

void Init();

bool CallChecker(uint32_t version, const Json::Value& _json,
Expand Down

0 comments on commit 1ef8b00

Please sign in to comment.