Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
sgxwallet
Commits
c064a774
Unverified
Commit
c064a774
authored
Jan 15, 2021
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug/SKALE-3662 Adding libzmq
parent
d09a4f4c
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
39 deletions
+87
-39
Makefile.am
Makefile.am
+2
-2
SGXException.cpp
SGXException.cpp
+30
-0
SGXException.h
SGXException.h
+6
-6
ServerWorker.cpp
ServerWorker.cpp
+31
-15
VERSION
VERSION
+1
-1
ZMQMessage.cpp
ZMQMessage.cpp
+13
-11
common.h
common.h
+4
-4
No files found.
Makefile.am
View file @
c064a774
...
@@ -70,7 +70,7 @@ bin_PROGRAMS = sgxwallet testw sgx_util
...
@@ -70,7 +70,7 @@ bin_PROGRAMS = sgxwallet testw sgx_util
## have to be explicitly listed
## have to be explicitly listed
COMMON_SRC
=
ZMQClient.cpp BLSSignRspMessage.cpp ECDSASignRspMessage.cpp ECDSASignReqMessage.cpp BLSSignReqMessage.cpp ZMQMessage.cpp ZMQServer.cpp ServerWorker.cpp InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp
\
COMMON_SRC
=
SGXException.cpp
ZMQClient.cpp BLSSignRspMessage.cpp ECDSASignRspMessage.cpp ECDSASignReqMessage.cpp BLSSignReqMessage.cpp ZMQMessage.cpp ZMQServer.cpp ServerWorker.cpp InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp
\
SGXWalletServer.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp BLSCrypto.cpp
\
SGXWalletServer.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp BLSCrypto.cpp
\
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp ServerDataChecker.cpp SEKManager.cpp
\
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp ServerDataChecker.cpp SEKManager.cpp
\
third_party/intel/sgx_stub.c third_party/intel/sgx_detect_linux.c third_party/intel/create_enclave.c third_party/intel/oc_alloc.c
\
third_party/intel/sgx_stub.c third_party/intel/sgx_detect_linux.c third_party/intel/create_enclave.c third_party/intel/oc_alloc.c
\
...
@@ -116,7 +116,7 @@ nodist_testw_SOURCES=${nodist_sgxwallet_SOURCES}
...
@@ -116,7 +116,7 @@ nodist_testw_SOURCES=${nodist_sgxwallet_SOURCES}
EXTRA_testw_DEPENDENCIES
=
${
EXTRA_sgxwallet_DEPENDENCIES
}
EXTRA_testw_DEPENDENCIES
=
${
EXTRA_sgxwallet_DEPENDENCIES
}
testw_LDADD
=
${
sgxwallet_LDADD
}
testw_LDADD
=
${
sgxwallet_LDADD
}
sgx_util_SOURCES
=
InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp sgx_util.cpp stubclient.cpp LevelDB.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp
sgx_util_SOURCES
=
SGXException.cpp
InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp sgx_util.cpp stubclient.cpp LevelDB.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp
sgx_util_LDADD
=
-LlibBLS
/deps/deps_inst/x86_or_x64/lib
-Lleveldb
/build
-LlibBLS
/build
\
sgx_util_LDADD
=
-LlibBLS
/deps/deps_inst/x86_or_x64/lib
-Lleveldb
/build
-LlibBLS
/build
\
-LlibBLS
/build/libff/libff
\
-LlibBLS
/build/libff/libff
\
...
...
SGXException.cpp
0 → 100644
View file @
c064a774
/*
Copyright (C) 2021-Present SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file SGXException.cpp
@author Stan Kladko
@date 2021
*/
#include "SGXException.h"
const
char
*
SGXException
::
what
()
const
noexcept
{
return
errString
.
c_str
();
}
SGXException.h
View file @
c064a774
...
@@ -16,13 +16,13 @@
...
@@ -16,13 +16,13 @@
You should have received a copy of the GNU Affero General Public License
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file
RPC
Exception.h
@file
SGX
Exception.h
@author Stan Kladko
@author Stan Kladko
@date 2019
@date 2019
*/
*/
#ifndef SGXD_
RPC
EXCEPTION_H
#ifndef SGXD_
SGX
EXCEPTION_H
#define SGXD_
RPC
EXCEPTION_H
#define SGXD_
SGX
EXCEPTION_H
#include <string>
#include <string>
#include <exception>
#include <exception>
...
@@ -46,11 +46,11 @@ public:
...
@@ -46,11 +46,11 @@ public:
return
errString
;
return
errString
;
}
}
const
char
*
what
()
const
noexcept
override
;
const
int32_t
getStatus
()
const
{
const
int32_t
getStatus
()
const
{
return
status
;
return
status
;
}
}
};
};
#endif //SGXD_
RPC
EXCEPTION_H
#endif //SGXD_
SGX
EXCEPTION_H
ServerWorker.cpp
View file @
c064a774
...
@@ -18,16 +18,18 @@ ServerWorker::ServerWorker(zmq::context_t &ctx, int sock_type) : ctx_(ctx),
...
@@ -18,16 +18,18 @@ ServerWorker::ServerWorker(zmq::context_t &ctx, int sock_type) : ctx_(ctx),
void
ServerWorker
::
work
()
{
void
ServerWorker
::
work
()
{
worker_
.
connect
(
"inproc://backend"
);
worker_
.
connect
(
"inproc://backend"
);
try
{
std
::
string
replyStr
;
while
(
true
)
{
while
(
true
)
{
try
{
zmq
::
message_t
msg
;
zmq
::
message_t
msg
;
zmq
::
message_t
copied_msg
;
worker_
.
recv
(
&
msg
);
worker_
.
recv
(
&
msg
);
vector
<
uint8_t
>
msgData
(
msg
.
size
()
+
1
,
0
);
vector
<
uint8_t
>
msgData
(
msg
.
size
()
+
1
,
0
);
memcpy
(
msgData
.
data
(),
msg
.
data
(),
msg
.
size
());
memcpy
(
msgData
.
data
(),
msg
.
data
(),
msg
.
size
());
auto
parsedMsg
=
ZMQMessage
::
parse
(
msgData
,
true
);
auto
parsedMsg
=
ZMQMessage
::
parse
(
msgData
,
true
);
CHECK_STATE
(
parsedMsg
);
CHECK_STATE
(
parsedMsg
);
...
@@ -36,21 +38,35 @@ void ServerWorker::work() {
...
@@ -36,21 +38,35 @@ void ServerWorker::work() {
Json
::
FastWriter
fastWriter
;
Json
::
FastWriter
fastWriter
;
std
::
string
replyStr
=
fastWriter
.
write
(
reply
);
replyStr
=
fastWriter
.
write
(
reply
);
zmq
::
message_t
replyMsg
(
replyStr
.
c_str
(),
replyStr
.
size
()
+
1
);
worker_
.
send
(
replyMsg
);
}
}
}
catch
(
std
::
exception
&
e
)
{
catch
(
std
::
exception
&
e
)
{
spdlog
::
info
(
"Exiting
zmq server worker:{}"
,
e
.
what
());
spdlog
::
error
(
"Exception in
zmq server worker:{}"
,
e
.
what
());
return
;
replyStr
=
""
;
}
catch
(...)
{
}
catch
(...)
{
spdlog
::
error
(
"Error in zmq server worker"
);
spdlog
::
error
(
"Error in zmq server worker"
);
return
;
replyStr
=
""
;
}
}
try
{
zmq
::
message_t
replyMsg
(
replyStr
.
c_str
(),
replyStr
.
size
()
+
1
);
worker_
.
send
(
replyMsg
);
}
catch
(
std
::
exception
&
e
)
{
spdlog
::
error
(
"Exception in zmq server send :{}"
,
e
.
what
());
}
catch
(...)
{
spdlog
::
error
(
"Unklnown exception in zmq server send"
);
}
}
}
}
VERSION
View file @
c064a774
1.6
6
.1
1.6
7
.1
ZMQMessage.cpp
View file @
c064a774
...
@@ -47,37 +47,39 @@ string ZMQMessage::getStringRapid(const char *_name) {
...
@@ -47,37 +47,39 @@ string ZMQMessage::getStringRapid(const char *_name) {
shared_ptr
<
ZMQMessage
>
ZMQMessage
::
parse
(
vector
<
uint8_t
>
&
_msg
,
bool
_isRequest
)
{
shared_ptr
<
ZMQMessage
>
ZMQMessage
::
parse
(
vector
<
uint8_t
>
&
_msg
,
bool
_isRequest
)
{
CHECK_STATE
(
_msg
.
size
()
>
2
);
CHECK_STATE
(
_msg
.
back
()
==
0
);
return
parse
((
const
char
*
)
_msg
.
data
(),
_msg
.
size
(),
_isRequest
);
return
parse
((
const
char
*
)
_msg
.
data
(),
_msg
.
size
()
-
1
,
_isRequest
);
}
}
shared_ptr
<
ZMQMessage
>
ZMQMessage
::
parse
(
const
char
*
_msg
,
shared_ptr
<
ZMQMessage
>
ZMQMessage
::
parse
(
const
char
*
_msg
,
size_t
_size
,
bool
_isRequest
)
{
size_t
_size
,
bool
_isRequest
)
{
CHECK_STATE
(
_size
>
0
);
CHECK_STATE
(
_size
>
2
);
CHECK_STATE
(
_msg
);
CHECK_STATE
(
_msg
);
// CHECK NULL TERMINATED
// CHECK NULL TERMINATED
CHECK_STATE
(
_msg
[
_size
-
1
]
==
0
);
CHECK_STATE
(
_msg
[
_size
]
==
0
);
CHECK_STATE
(
_msg
[
_size
-
1
]
==
'}'
);
auto
d
=
make_shared
<
rapidjson
::
Document
>
(
);
CHECK_STATE
(
_msg
[
0
]
==
'{'
);
cerr
<<
"parsing"
<<
endl
;
cerr
<<
_msg
<<
endl
;
d
->
Parse
(
_msg
)
;
cerr
<<
"parsing"
<<
endl
;
auto
d
=
make_shared
<
rapidjson
::
Document
>
();
d
->
Parse
(
_msg
);
CHECK_STATE
(
!
d
->
HasParseError
());
CHECK_STATE
(
!
d
->
HasParseError
());
CHECK_STATE
(
d
->
IsObject
())
CHECK_STATE
(
d
->
IsObject
())
CHECK_STATE
(
d
->
HasMember
(
"type"
));
CHECK_STATE
(
d
->
HasMember
(
"type"
));
CHECK_STATE
((
*
d
)[
"type"
].
IsString
());
CHECK_STATE
((
*
d
)[
"type"
].
IsString
());
string
type
=
(
*
d
)[
"type"
].
GetString
();
string
type
=
(
*
d
)[
"type"
].
GetString
();
shared_ptr
<
ZMQMessage
>
result
;
shared_ptr
<
ZMQMessage
>
result
;
if
(
_isRequest
)
{
if
(
_isRequest
)
{
...
...
common.h
View file @
c064a774
...
@@ -56,7 +56,7 @@ inline std::string className(const std::string &prettyFunction) {
...
@@ -56,7 +56,7 @@ inline std::string className(const std::string &prettyFunction) {
#include <execinfo.h>
#include <execinfo.h>
inline
void
print_stack
()
{
inline
void
print_stack
(
int
_line
)
{
void
*
array
[
10
];
void
*
array
[
10
];
size_t
size
;
size_t
size
;
...
@@ -64,16 +64,16 @@ inline void print_stack() {
...
@@ -64,16 +64,16 @@ inline void print_stack() {
size
=
backtrace
(
array
,
10
);
size
=
backtrace
(
array
,
10
);
// print out all the frames to stderr
// print out all the frames to stderr
fprintf
(
stderr
,
"
Error: signal
\n
"
);
fprintf
(
stderr
,
"
Backtrace on line %d:
\n
"
,
_line
);
backtrace_symbols_fd
(
array
,
size
,
STDERR_FILENO
);
backtrace_symbols_fd
(
array
,
size
,
STDERR_FILENO
);
exit
(
-
1
);
}
}
#define CHECK_STATE(_EXPRESSION_) \
#define CHECK_STATE(_EXPRESSION_) \
if (!(_EXPRESSION_)) { \
if (!(_EXPRESSION_)) { \
auto __msg__ = std::string("State check failed::") + #_EXPRESSION_ + " " + std::string(__FILE__) + ":" + std::to_string(__LINE__); \
auto __msg__ = std::string("State check failed::") + #_EXPRESSION_ + " " + std::string(__FILE__) + ":" + std::to_string(__LINE__); \
print_stack(); \
print_stack(__LINE__); \
\
BOOST_THROW_EXCEPTION(SGXException(-100, string(__CLASS_NAME__) + ":" + __msg__));}
BOOST_THROW_EXCEPTION(SGXException(-100, string(__CLASS_NAME__) + ":" + __msg__));}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment