Separate contract and ledger file system mounts. (#235)

- Creating two separate hpfs folders for contract and ledger file systems (contract_fs and ledger_fs).
- Added separate mounts for contract and ledger file systems.
- Added separate instances for contract serving and ledger serving.
- Added separate instances for contract syncing and ledger syncing.
- Modified cluster creating script to accompany folder name changes in contract folder.
This commit is contained in:
Savinda Senevirathne
2021-02-05 11:48:52 +05:30
committed by GitHub
parent ae55a6ea5a
commit a4399544b9
39 changed files with 622 additions and 359 deletions

View File

@@ -10,10 +10,7 @@
#include "p2p/peer_session_handler.hpp"
#include "hplog.hpp"
#include "crypto.hpp"
#include "sc.hpp"
#include "util/h32.hpp"
#include "hpfs/hpfs.hpp"
#include "hpfs/hpfs_sync.hpp"
#include "unl.hpp"
#include "ledger.hpp"
#include "consensus.hpp"
@@ -113,9 +110,8 @@ namespace consensus
// Get current lcl and state.
std::string lcl = ledger::ctx.get_lcl();
const uint64_t lcl_seq_no = ledger::ctx.get_seq_no();
hpfs::hpfs_mount &contract_fs = hpfs::contract_fs; // Ref of the contract_fs object.
util::h32 state_hash = contract_fs.get_parent_hash(hpfs::STATE_DIR_PATH);
util::h32 patch_hash = contract_fs.get_parent_hash(hpfs::PATCH_FILE_PATH);
util::h32 state_hash = sc::contract_fs.get_parent_hash(hpfs::STATE_DIR_PATH);
util::h32 patch_hash = sc::contract_fs.get_parent_hash(hpfs::PATCH_FILE_PATH);
if (ctx.stage == 0)
{
@@ -214,7 +210,7 @@ namespace consensus
sync_target_list.push(hpfs::sync_target{"state", majority_state_hash, hpfs::STATE_DIR_PATH, hpfs::BACKLOG_ITEM_TYPE::DIR});
// Set sync targets for contract fs.
hpfs::contract_sync.set_target(std::move(sync_target_list));
sc::contract_sync_worker.set_target(std::move(sync_target_list));
}
// Proceed further only if both lcl and state are in sync with majority.
@@ -238,7 +234,7 @@ namespace consensus
*/
void check_sync_completion()
{
if (conf::cfg.node.role == conf::ROLE::OBSERVER && !hpfs::contract_sync.ctx.is_syncing && !ledger::sync_ctx.is_syncing)
if (conf::cfg.node.role == conf::ROLE::OBSERVER && !sc::contract_sync_worker.is_syncing && !ledger::sync_ctx.is_syncing)
conf::change_role(conf::ROLE::VALIDATOR);
}
@@ -770,7 +766,7 @@ namespace consensus
}
}
is_state_desync = (hpfs::contract_fs.get_parent_hash(hpfs::STATE_DIR_PATH) != majority_state_hash);
is_state_desync = (sc::contract_fs.get_parent_hash(hpfs::STATE_DIR_PATH) != majority_state_hash);
}
/**
@@ -796,7 +792,7 @@ namespace consensus
}
}
is_patch_desync = (hpfs::contract_fs.get_parent_hash(hpfs::PATCH_FILE_PATH) != majority_patch_hash);
is_patch_desync = (sc::contract_fs.get_parent_hash(hpfs::PATCH_FILE_PATH) != majority_patch_hash);
}
/**
@@ -883,7 +879,7 @@ namespace consensus
}
// Update state hash in contract fs global hash tracker.
hpfs::contract_fs.set_parent_hash(hpfs::STATE_DIR_PATH, args.post_execution_state_hash);
sc::contract_fs.set_parent_hash(hpfs::STATE_DIR_PATH, args.post_execution_state_hash);
new_state_hash = args.post_execution_state_hash;
extract_user_outputs_from_contract_bufmap(args.userbufs);
@@ -1052,18 +1048,16 @@ namespace consensus
*/
int apply_consensed_patch_file_changes(const util::h32 &prop_patch_hash, const util::h32 &current_patch_hash)
{
hpfs::hpfs_mount &contract_fs = hpfs::contract_fs;
// Check whether is there any patch changes to be applied which reached consensus.
if (is_patch_update_pending && current_patch_hash == prop_patch_hash)
{
if (contract_fs.start_ro_session(HPFS_SESSION_NAME, false) != -1)
if (sc::contract_fs.start_ro_session(HPFS_SESSION_NAME, false) != -1)
{
// Appling new patch file changes to hpcore runtime.
if (conf::apply_patch_config(HPFS_SESSION_NAME) == -1)
{
LOG_ERROR << "Appling patch file changes after consensus failed.";
contract_fs.stop_ro_session(HPFS_SESSION_NAME);
sc::contract_fs.stop_ro_session(HPFS_SESSION_NAME);
return -1;
}
else
@@ -1073,7 +1067,7 @@ namespace consensus
}
}
if (contract_fs.stop_ro_session(HPFS_SESSION_NAME) == -1)
if (sc::contract_fs.stop_ro_session(HPFS_SESSION_NAME) == -1)
return -1;
}
return 0;