Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/update consensus beta #1111

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libconsensus
Submodule libconsensus updated 44 files
+36 −29 .idea/workspace.xml
+1 −0 CMakeLists.txt
+15 −13 blockfinalize/client/BlockFinalizeDownloader.cpp
+3 −1 blockfinalize/client/BlockFinalizeDownloader.h
+8 −3 blockproposal/pusher/BlockProposalClientAgent.cpp
+307 −304 blockproposal/server/BlockProposalServerAgent.cpp
+14 −14 catchup/client/CatchupClientAgent.cpp
+3 −3 catchup/client/CatchupClientAgent.h
+76 −41 chains/Schain.cpp
+3 −1 chains/Schain.h
+2 −1 chains/SchainGettersSetters.cpp
+7 −3 crypto/ConsensusEdDSASigShare.cpp
+1 −1 crypto/ConsensusEdDSASigShare.h
+178 −102 crypto/CryptoManager.cpp
+17 −9 crypto/CryptoManager.h
+6 −9 crypto/OpenSSLECDSAKey.cpp
+2 −2 crypto/OpenSSLECDSAKey.h
+5 −10 crypto/OpenSSLEdDSAKey.cpp
+1 −1 crypto/OpenSSLEdDSAKey.h
+12 −3 datastructures/BlockProposal.cpp
+1 −1 datastructures/BlockProposal.h
+93 −93 datastructures/CommittedBlock.cpp
+2 −1 datastructures/CommittedBlock.h
+1 −1 datastructures/CommittedBlockList.cpp
+2 −2 datastructures/SerializationTests.cpp
+4 −0 datastructures/TimeStamp.cpp
+1 −0 datastructures/TimeStamp.h
+15 −13 db/BlockDB.cpp
+1 −3 db/BlockDB.h
+3 −1 db/BlockProposalDB.cpp
+3 −3 db/MsgDB.cpp
+1 −1 db/PriceDB.cpp
+1 −1 db/PriceDB.h
+3 −2 db/SigDB.cpp
+2 −3 db/SigDB.h
+11 −5 json/JSONFactory.cpp
+6 −2 json/JSONFactory.h
+6 −1 messages/NetworkMessage.cpp
+13 −6 monitoring/StuckDetectionAgent.cpp
+68 −15 node/ConsensusEngine.cpp
+8 −2 node/ConsensusEngine.h
+17 −0 node/Node.cpp
+10 −0 node/Node.h
+1 −1 unittests/sgx_tests.cpp
29 changes: 24 additions & 5 deletions libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ std::unique_ptr< ConsensusInterface > DefaultConsensusFactory::create(
this->fillSgxInfo( *consensus_engine_ptr );
}


this->fillPublicKeyInfo(*consensus_engine_ptr);


this->fillRotationHistory( *consensus_engine_ptr );

return consensus_engine_ptr;
Expand Down Expand Up @@ -125,6 +129,9 @@ void DefaultConsensusFactory::fillSgxInfo( ConsensusEngine& consensus ) const tr

consensus.setSGXKeyInfo( sgxServerUrl, sgxSSLKeyFilePath, sgxSSLCertFilePath, ecdsaKeyName,
blsKeyName);



} catch ( ... ) {
std::throw_with_nested( std::runtime_error( "Error filling SGX info (nodeGroups)" ) );
}
Expand Down Expand Up @@ -172,14 +179,26 @@ void DefaultConsensusFactory::fillPublicKeyInfo( ConsensusEngine& consensus ) co


void DefaultConsensusFactory::fillRotationHistory( ConsensusEngine& consensus ) const try {
std::map< uint64_t, std::vector< std::string > > rh;
std::map< uint64_t, std::vector< std::string > > previousBLSKeys;
std::map< uint64_t, std::string > historicECDSAKeys;
std::map< uint64_t, std::vector< uint64_t > > historicNodeGroups;
auto u256toUint64 = []( const dev::u256& u ) { return std::stoull( u.str() ); };
for ( const auto& nodeGroup : m_client.chainParams().sChain.nodeGroups ) {
std::vector< string > commonBLSPublicKey = {nodeGroup.blsPublicKey[0],
nodeGroup.blsPublicKey[1], nodeGroup.blsPublicKey[2], nodeGroup.blsPublicKey[3]};
rh[nodeGroup.finishTs] = commonBLSPublicKey;
std::vector< string > commonBLSPublicKey = { nodeGroup.blsPublicKey[0],
nodeGroup.blsPublicKey[1], nodeGroup.blsPublicKey[2], nodeGroup.blsPublicKey[3] };
previousBLSKeys[nodeGroup.finishTs] = commonBLSPublicKey;
std::vector< uint64_t > nodes;
// add ecdsa keys info and historic groups info
for ( const auto& node : nodeGroup.nodes ) {
historicECDSAKeys[u256toUint64( node.id )] = node.publicKey;
nodes.push_back( u256toUint64( node.id ) );
}
historicNodeGroups[nodeGroup.finishTs] = nodes;
}
consensus.setRotationHistory(
std::make_shared< std::map< uint64_t, std::vector< std::string > > >( rh ) );
std::make_shared< std::map< uint64_t, std::vector< std::string > > >( previousBLSKeys ),
std::make_shared< std::map< uint64_t, std::string > >( historicECDSAKeys ),
std::make_shared< std::map< uint64_t, std::vector< uint64_t > > >( historicNodeGroups ) );
} catch ( ... ) {
std::throw_with_nested( std::runtime_error( "Error reading rotation history (nodeGroups)" ) );
}
Expand Down
6 changes: 3 additions & 3 deletions libweb3jsonrpc/SkaleStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,14 @@ bool pending_ima_txns::broadcast_txn_verify_signature( const char* strActionName
strNextErrorType = "encode TX hash";
bytes v = dev::BMPBN::encode2vec< dev::u256 >( hashToSign, true );
strNextErrorType = "do ECDSA signature verification";
isSignatureOK = key->verifySGXSig( strBroadcastSignature, ( const char* ) v.data() );
key->verifySGXSig( strBroadcastSignature, ( const char* ) v.data() );
isSignatureOK = true;
clog( VerbosityTrace, "IMA" )
<< ( cc::debug( "IMA broadcast ECDSA signature " ) + cc::info( strBroadcastSignature ) +
cc::debug( " verification from node ID " ) + cc::num10( node_id ) +
cc::debug( " using ECDSA public key " ) + cc::info( strEcdsaPublicKey ) +
cc::debug( " and message/hash " ) + cc::info( strHashToSign ) +
cc::debug( " is " ) +
( isSignatureOK ? cc::success( "passed" ) : cc::fatal( "failed" ) ) );
cc::debug( " is " ) + cc::success( "passed" ) );
} catch ( const std::exception& ex ) {
isSignatureOK = false;
clog( VerbosityTrace, "IMA" )
Expand Down