Skip to content

Commit 9609ec7

Browse files
authored
register spdz connected endpoint info 2 gateway (#112)
* register spdz connected endpoint info 2 gateway * fix agency id not load bug
1 parent 187ecc1 commit 9609ec7

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

cpp/ppc-framework/protocol/Constant.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ namespace ppc::protocol
2626
{
2727
const static std::string PSI_SERVICE_TYPE = "PSI";
2828
const static std::string MPC_SERVICE_TYPE = "MPC";
29+
const static std::string SPDZ_SERVICE_TYPE = "SPDZ";
2930
const static size_t LARGE_MSG_THRESHOLD = 30 * 1024 * 1024;
3031
} // namespace ppc::protocol

cpp/wedpr-helper/ppc-tools/src/config/MPCConfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ struct MPCConfig
3030
std::string mpcRootPathNoGateway;
3131
uint64_t readPerBatchLines;
3232
int threadPoolSize;
33+
34+
std::string spdzConnectedIP;
35+
int spdzConnectedPort;
3336
};
3437
} // namespace ppc::tools

cpp/wedpr-helper/ppc-tools/src/config/PPCConfig.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,24 @@ void PPCConfig::loadCEMConfig(boost::property_tree::ptree const& _pt)
653653

654654
void PPCConfig::loadMPCConfig(boost::property_tree::ptree const& _pt)
655655
{
656+
// the agencyID
657+
m_agencyID = _pt.get<std::string>("agency.id", "");
658+
if (m_agencyID.empty())
659+
{
660+
BOOST_THROW_EXCEPTION(InvalidConfig() << errinfo_comment("Must set agency.id"));
661+
}
662+
663+
PPCConfig_LOG(INFO) << LOG_DESC("load agency id") << LOG_KV("agencyID", m_agencyID);
664+
656665
m_mpcConfig.jobPath = _pt.get<std::string>("mpc.job_path", "./");
657666
m_mpcConfig.mpcRootPath = _pt.get<std::string>("mpc.mpc_root_path", "./");
658667
m_mpcConfig.mpcRootPathNoGateway = _pt.get<std::string>("mpc.mpc_root_path_no_gateway", "./");
659668
m_mpcConfig.readPerBatchLines = _pt.get<std::uint64_t>("mpc.read_per_batch_lines", 100000);
669+
m_mpcConfig.spdzConnectedPort = _pt.get<int>("spdz.connected_port", 5894);
670+
m_mpcConfig.spdzConnectedIP = _pt.get<std::string>("transport.host_ip", "");
671+
672+
PPCConfig_LOG(INFO) << LOG_DESC("spdzConnectedPort") << LOG_KV("spdzConnectedIP", m_mpcConfig.spdzConnectedIP) << LOG_KV("spdzConnectedPort", m_mpcConfig.spdzConnectedPort);
673+
660674
m_mpcConfig.threadPoolSize = _pt.get<int>("mpc.async_thread_pool_size", -1);
661675
if (m_mpcConfig.threadPoolSize < 0)
662676
{

cpp/wedpr-helper/ppc-tools/src/config/PPCConfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ class PPCConfig
249249
return m_frontConfig->selfEndPoint().host() + ":" + std::to_string(m_rpcConfig.listenPort);
250250
}
251251

252+
std::string spdzConnectedEndPoint() const // for mpc
253+
{
254+
return m_mpcConfig.spdzConnectedIP + ":" + std::to_string(m_mpcConfig.spdzConnectedPort);
255+
}
256+
252257
// load the front config
253258
virtual void loadFrontConfig(bool requireTransport,
254259
ppc::front::FrontConfigBuilder::Ptr const& frontConfigBuilder,

cpp/wedpr-main/mpc-node/MPCInitializer.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,16 @@ void MPCInitializer::initTransport(boost::property_tree::ptree const& property)
9090

9191
// add the service meta
9292
ServiceConfigBuilder serviceConfigBuilder;
93-
auto entryPoint = serviceConfigBuilder.buildEntryPoint(
94-
getServiceName(m_config->agencyID(), MPC_SERVICE_TYPE), m_config->accessEntrypoint());
9593
auto serviceConfig = serviceConfigBuilder.buildServiceConfig();
96-
serviceConfig.addEntryPoint(entryPoint);
94+
95+
auto mpcEntryPoint =
96+
serviceConfigBuilder.buildEntryPoint(getServiceName(m_config->agencyID(), MPC_SERVICE_TYPE), m_config->accessEntrypoint());
97+
serviceConfig.addEntryPoint(mpcEntryPoint);
98+
99+
auto spdzEntryPoint =
100+
serviceConfigBuilder.buildEntryPoint(getServiceName(m_config->agencyID(), SPDZ_SERVICE_TYPE), m_config->spdzConnectedEndPoint());
101+
serviceConfig.addEntryPoint(spdzEntryPoint);
102+
97103
auto serviceMeta = serviceConfig.encode();
98104
m_config->frontConfig()->setMeta(serviceMeta);
99105
INIT_LOG(INFO) << LOG_DESC("initTransport: register serviceMeta")

0 commit comments

Comments
 (0)