From 1bfeba4366fcf58b6d37b082d69e04e2223e28fa Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Wed, 24 Apr 2024 16:07:44 +0100 Subject: [PATCH 01/11] IS-864 bls sync config --- libconsensus | 2 +- libethereum/ChainParams.cpp | 45 ++++++++++++++++++++++------------- libethereum/SchainPatch.cpp | 4 ++++ libethereum/SchainPatch.h | 5 ++++ libethereum/SchainPatchEnum.h | 1 + libethereum/SkaleHost.cpp | 8 ++++--- 6 files changed, 44 insertions(+), 21 deletions(-) diff --git a/libconsensus b/libconsensus index 2f7c74374..dc3970a75 160000 --- a/libconsensus +++ b/libconsensus @@ -1 +1 @@ -Subproject commit 2f7c7437465ed3cbbfc914ce9fb0fefe3d096ecb +Subproject commit dc3970a751d5a9a80e01379239a6cdc04584197f diff --git a/libethereum/ChainParams.cpp b/libethereum/ChainParams.cpp index ca4f51b6b..40c0d35eb 100644 --- a/libethereum/ChainParams.cpp +++ b/libethereum/ChainParams.cpp @@ -224,27 +224,38 @@ void ChainParams::processSkaleConfigItems( ChainParams& cp, json_spirit::mObject array< string, 4 > BLSPublicKeys; array< string, 4 > commonBLSPublicKeys; - try { - js::mObject ima = infoObj.at( "wallets" ).get_obj().at( "ima" ).get_obj(); + if ( !syncNode ) + try { + js::mObject ima = infoObj.at( "wallets" ).get_obj().at( "ima" ).get_obj(); - keyShareName = ima.at( "keyShareName" ).get_str(); + keyShareName = ima.at( "keyShareName" ).get_str(); - t = ima.at( "t" ).get_int(); + t = ima.at( "t" ).get_int(); - BLSPublicKeys[0] = ima["BLSPublicKey0"].get_str(); - BLSPublicKeys[1] = ima["BLSPublicKey1"].get_str(); - BLSPublicKeys[2] = ima["BLSPublicKey2"].get_str(); - BLSPublicKeys[3] = ima["BLSPublicKey3"].get_str(); + BLSPublicKeys[0] = ima["BLSPublicKey0"].get_str(); + BLSPublicKeys[1] = ima["BLSPublicKey1"].get_str(); + BLSPublicKeys[2] = ima["BLSPublicKey2"].get_str(); + BLSPublicKeys[3] = ima["BLSPublicKey3"].get_str(); - commonBLSPublicKeys[0] = ima["commonBLSPublicKey0"].get_str(); - commonBLSPublicKeys[1] = ima["commonBLSPublicKey1"].get_str(); - commonBLSPublicKeys[2] = ima["commonBLSPublicKey2"].get_str(); - commonBLSPublicKeys[3] = ima["commonBLSPublicKey3"].get_str(); - } catch ( ... ) { - // all or nothing - if ( !keyShareName.empty() ) - throw; - } + commonBLSPublicKeys[0] = ima["commonBLSPublicKey0"].get_str(); + commonBLSPublicKeys[1] = ima["commonBLSPublicKey1"].get_str(); + commonBLSPublicKeys[2] = ima["commonBLSPublicKey2"].get_str(); + commonBLSPublicKeys[3] = ima["commonBLSPublicKey3"].get_str(); + } catch ( ... ) { + // all or nothing + if ( !keyShareName.empty() ) + throw; + } + else + try { + js::mObject ima = infoObj.at( "wallets" ).get_obj().at( "ima" ).get_obj(); + + commonBLSPublicKeys[0] = ima["commonBLSPublicKey0"].get_str(); + commonBLSPublicKeys[1] = ima["commonBLSPublicKey1"].get_str(); + commonBLSPublicKeys[2] = ima["commonBLSPublicKey2"].get_str(); + commonBLSPublicKeys[3] = ima["commonBLSPublicKey3"].get_str(); + } catch ( ... ) { + } cp.nodeInfo = { nodeName, nodeID, ip, static_cast< uint16_t >( port ), ip6, static_cast< uint16_t >( port6 ), sgxServerUrl, ecdsaKeyName, keyShareName, BLSPublicKeys, diff --git a/libethereum/SchainPatch.cpp b/libethereum/SchainPatch.cpp index 1ae076376..cca733240 100644 --- a/libethereum/SchainPatch.cpp +++ b/libethereum/SchainPatch.cpp @@ -28,6 +28,8 @@ SchainPatchEnum getEnumForPatchName( const std::string& _patchName ) { return SchainPatchEnum::StorageDestructionPatch; else if ( _patchName == "SkipInvalidTransactionsPatch" ) return SchainPatchEnum::SkipInvalidTransactionsPatch; + else if ( _patchName == "VerifyBlsSyncPatch" ) + return SchainPatchEnum::VerifyBlsSyncPatch; else throw std::out_of_range( _patchName ); } @@ -56,6 +58,8 @@ std::string getPatchNameForEnum( SchainPatchEnum _enumValue ) { return "SkipInvalidTransactionsPatch"; case SchainPatchEnum::SelfdestructStorageLimitPatch: return "SelfdestructStorageLimitPatch"; + case SchainPatchEnum::VerifyBlsSyncPatch: + return "VerifyBlsSyncPatch"; default: throw std::out_of_range( "UnknownPatch #" + std::to_string( static_cast< size_t >( _enumValue ) ) ); diff --git a/libethereum/SchainPatch.h b/libethereum/SchainPatch.h index d8fabce97..b5af00469 100644 --- a/libethereum/SchainPatch.h +++ b/libethereum/SchainPatch.h @@ -130,4 +130,9 @@ DEFINE_AMNESIC_PATCH( StorageDestructionPatch ); */ DEFINE_SIMPLE_PATCH( SelfdestructStorageLimitPatch ); +/* + * Enable bls signatures verification for sync node + */ +DEFINE_AMNESIC_PATCH( VerifyBlsSyncPatch ); + #endif // SCHAINPATCH_H diff --git a/libethereum/SchainPatchEnum.h b/libethereum/SchainPatchEnum.h index b1f439211..513ff45ad 100644 --- a/libethereum/SchainPatchEnum.h +++ b/libethereum/SchainPatchEnum.h @@ -16,6 +16,7 @@ enum class SchainPatchEnum { StorageDestructionPatch, SkipInvalidTransactionsPatch, SelfdestructStorageLimitPatch, + VerifyBlsSyncPatch, PatchesCount }; diff --git a/libethereum/SkaleHost.cpp b/libethereum/SkaleHost.cpp index 7988705e8..f6f59f841 100644 --- a/libethereum/SkaleHost.cpp +++ b/libethereum/SkaleHost.cpp @@ -81,6 +81,8 @@ std::unique_ptr< ConsensusInterface > DefaultConsensusFactory::create( patchTimeStamps["verifyDaSigsPatchTimestamp"] = m_client.chainParams().getPatchTimestamp( SchainPatchEnum::VerifyDaSigsPatch ); + patchTimeStamps["verifyBlsSyncPatchTimestamp"] = + m_client.chainParams().getPatchTimestamp( SchainPatchEnum::VerifyBlsSyncPatch ); auto consensus_engine_ptr = make_unique< ConsensusEngine >( _extFace, m_client.number(), ts, 0, patchTimeStamps, m_client.chainParams().sChain.consensusStorageLimit ); @@ -89,9 +91,9 @@ std::unique_ptr< ConsensusInterface > DefaultConsensusFactory::create( this->fillSgxInfo( *consensus_engine_ptr ); } - - this->fillPublicKeyInfo( *consensus_engine_ptr ); - + // does nothing for a sync node + if ( !m_client.chainParams().nodeInfo.syncNode ) + this->fillPublicKeyInfo( *consensus_engine_ptr ); this->fillRotationHistory( *consensus_engine_ptr ); From 804aef3fc010fef0aece944e3fd84f06eff990a9 Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Wed, 24 Apr 2024 19:41:22 +0100 Subject: [PATCH 02/11] IS-864 bls sync config --- libconsensus | 2 +- libethereum/SchainPatch.cpp | 4 ++-- libethereum/SkaleHost.cpp | 11 +++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libconsensus b/libconsensus index dc3970a75..5276c8e47 160000 --- a/libconsensus +++ b/libconsensus @@ -1 +1 @@ -Subproject commit dc3970a751d5a9a80e01379239a6cdc04584197f +Subproject commit 5276c8e479b2db0d06d377df7fada6f53a1486e3 diff --git a/libethereum/SchainPatch.cpp b/libethereum/SchainPatch.cpp index cca733240..193da59d4 100644 --- a/libethereum/SchainPatch.cpp +++ b/libethereum/SchainPatch.cpp @@ -29,7 +29,7 @@ SchainPatchEnum getEnumForPatchName( const std::string& _patchName ) { else if ( _patchName == "SkipInvalidTransactionsPatch" ) return SchainPatchEnum::SkipInvalidTransactionsPatch; else if ( _patchName == "VerifyBlsSyncPatch" ) - return SchainPatchEnum::VerifyBlsSyncPatch; + return SchainPatchEnum::VerifyBlsSyncPatch; else throw std::out_of_range( _patchName ); } @@ -59,7 +59,7 @@ std::string getPatchNameForEnum( SchainPatchEnum _enumValue ) { case SchainPatchEnum::SelfdestructStorageLimitPatch: return "SelfdestructStorageLimitPatch"; case SchainPatchEnum::VerifyBlsSyncPatch: - return "VerifyBlsSyncPatch"; + return "VerifyBlsSyncPatch"; default: throw std::out_of_range( "UnknownPatch #" + std::to_string( static_cast< size_t >( _enumValue ) ) ); diff --git a/libethereum/SkaleHost.cpp b/libethereum/SkaleHost.cpp index f6f59f841..aacbc4c1a 100644 --- a/libethereum/SkaleHost.cpp +++ b/libethereum/SkaleHost.cpp @@ -82,7 +82,7 @@ std::unique_ptr< ConsensusInterface > DefaultConsensusFactory::create( patchTimeStamps["verifyDaSigsPatchTimestamp"] = m_client.chainParams().getPatchTimestamp( SchainPatchEnum::VerifyDaSigsPatch ); patchTimeStamps["verifyBlsSyncPatchTimestamp"] = - m_client.chainParams().getPatchTimestamp( SchainPatchEnum::VerifyBlsSyncPatch ); + m_client.chainParams().getPatchTimestamp( SchainPatchEnum::VerifyBlsSyncPatch ); auto consensus_engine_ptr = make_unique< ConsensusEngine >( _extFace, m_client.number(), ts, 0, patchTimeStamps, m_client.chainParams().sChain.consensusStorageLimit ); @@ -91,9 +91,7 @@ std::unique_ptr< ConsensusInterface > DefaultConsensusFactory::create( this->fillSgxInfo( *consensus_engine_ptr ); } - // does nothing for a sync node - if ( !m_client.chainParams().nodeInfo.syncNode ) - this->fillPublicKeyInfo( *consensus_engine_ptr ); + this->fillPublicKeyInfo( *consensus_engine_ptr ); this->fillRotationHistory( *consensus_engine_ptr ); @@ -181,8 +179,9 @@ void DefaultConsensusFactory::fillPublicKeyInfo( ConsensusEngine& consensus ) co size_t n = m_client.chainParams().sChain.nodes.size(); size_t t = ( 2 * n + 1 ) / 3; - if ( ecdsaPublicKeys->size() && ecdsaPublicKeys->at( 0 ).size() && blsPublicKeys.size() && - blsPublicKeys[0]->at( 0 ).size() ) + if ( ecdsaPublicKeys->size() && ecdsaPublicKeys->at( 0 ).size() && + ( ( blsPublicKeys.size() && blsPublicKeys[0]->at( 0 ).size() ) || + m_client.chainParams().nodeInfo.syncNode ) ) consensus.setPublicKeyInfo( ecdsaPublicKeys, blsPublicKeysPtr, t, n ); } catch ( ... ) { std::throw_with_nested( std::runtime_error( "Error filling SGX info (nodeGroups)" ) ); From a1e8069d70903de72c181491976588fd23229307 Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Tue, 30 Apr 2024 16:00:23 +0100 Subject: [PATCH 03/11] IS 864 better exception description --- libethereum/SkaleHost.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethereum/SkaleHost.cpp b/libethereum/SkaleHost.cpp index aacbc4c1a..ef1638d81 100644 --- a/libethereum/SkaleHost.cpp +++ b/libethereum/SkaleHost.cpp @@ -184,7 +184,7 @@ void DefaultConsensusFactory::fillPublicKeyInfo( ConsensusEngine& consensus ) co m_client.chainParams().nodeInfo.syncNode ) ) consensus.setPublicKeyInfo( ecdsaPublicKeys, blsPublicKeysPtr, t, n ); } catch ( ... ) { - std::throw_with_nested( std::runtime_error( "Error filling SGX info (nodeGroups)" ) ); + std::throw_with_nested( std::runtime_error( "Error filling public keys info (nodeGroups)" ) ); } From 7d612eddeb483dac1786a0badf1884c397fb9c8a Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Fri, 3 May 2024 15:45:36 +0100 Subject: [PATCH 04/11] IS-864 bls sync config --- libconsensus | 2 +- libethereum/SkaleHost.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libconsensus b/libconsensus index 5276c8e47..d3432c51b 160000 --- a/libconsensus +++ b/libconsensus @@ -1 +1 @@ -Subproject commit 5276c8e479b2db0d06d377df7fada6f53a1486e3 +Subproject commit d3432c51b2041b892f5d9707e9feb89da35cfd12 diff --git a/libethereum/SkaleHost.cpp b/libethereum/SkaleHost.cpp index ef1638d81..53d03c8e0 100644 --- a/libethereum/SkaleHost.cpp +++ b/libethereum/SkaleHost.cpp @@ -182,7 +182,8 @@ void DefaultConsensusFactory::fillPublicKeyInfo( ConsensusEngine& consensus ) co if ( ecdsaPublicKeys->size() && ecdsaPublicKeys->at( 0 ).size() && ( ( blsPublicKeys.size() && blsPublicKeys[0]->at( 0 ).size() ) || m_client.chainParams().nodeInfo.syncNode ) ) - consensus.setPublicKeyInfo( ecdsaPublicKeys, blsPublicKeysPtr, t, n ); + consensus.setPublicKeyInfo( + ecdsaPublicKeys, blsPublicKeysPtr, t, n, m_client.chainParams().nodeInfo.syncNode ); } catch ( ... ) { std::throw_with_nested( std::runtime_error( "Error filling public keys info (nodeGroups)" ) ); } From 03b289f80d413d1708bbeeaedf9a6d2271babd59 Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Thu, 9 May 2024 11:23:36 +0100 Subject: [PATCH 05/11] IS-864 add debug logs --- libconsensus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libconsensus b/libconsensus index d3432c51b..1dfeafa6a 160000 --- a/libconsensus +++ b/libconsensus @@ -1 +1 @@ -Subproject commit d3432c51b2041b892f5d9707e9feb89da35cfd12 +Subproject commit 1dfeafa6a18da9bdc88709752d2a917ffd331eb1 From d072ea5a8b2a5a6f87fecd32ad682e4f2379cf20 Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Thu, 9 May 2024 17:41:42 +0100 Subject: [PATCH 06/11] IS-864 update consensus --- libconsensus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libconsensus b/libconsensus index 1dfeafa6a..adc20562c 160000 --- a/libconsensus +++ b/libconsensus @@ -1 +1 @@ -Subproject commit 1dfeafa6a18da9bdc88709752d2a917ffd331eb1 +Subproject commit adc20562c360ab1f6902d6162cfba4e472e7ffb2 From ec40d75b09a145689c80839f93acafc8ac2e8790 Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Fri, 10 May 2024 19:56:37 +0100 Subject: [PATCH 07/11] IS-864 Small code rearrangement --- libethereum/ChainParams.cpp | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/libethereum/ChainParams.cpp b/libethereum/ChainParams.cpp index 2d7b28436..ba72d351b 100644 --- a/libethereum/ChainParams.cpp +++ b/libethereum/ChainParams.cpp @@ -226,10 +226,15 @@ void ChainParams::processSkaleConfigItems( ChainParams& cp, json_spirit::mObject array< string, 4 > BLSPublicKeys; array< string, 4 > commonBLSPublicKeys; - if ( !syncNode ) - try { - js::mObject ima = infoObj.at( "wallets" ).get_obj().at( "ima" ).get_obj(); + try { + js::mObject ima = infoObj.at( "wallets" ).get_obj().at( "ima" ).get_obj(); + + commonBLSPublicKeys[0] = ima["commonBLSPublicKey0"].get_str(); + commonBLSPublicKeys[1] = ima["commonBLSPublicKey1"].get_str(); + commonBLSPublicKeys[2] = ima["commonBLSPublicKey2"].get_str(); + commonBLSPublicKeys[3] = ima["commonBLSPublicKey3"].get_str(); + if ( !syncNode ) { keyShareName = ima.at( "keyShareName" ).get_str(); t = ima.at( "t" ).get_int(); @@ -238,26 +243,13 @@ void ChainParams::processSkaleConfigItems( ChainParams& cp, json_spirit::mObject BLSPublicKeys[1] = ima["BLSPublicKey1"].get_str(); BLSPublicKeys[2] = ima["BLSPublicKey2"].get_str(); BLSPublicKeys[3] = ima["BLSPublicKey3"].get_str(); - - commonBLSPublicKeys[0] = ima["commonBLSPublicKey0"].get_str(); - commonBLSPublicKeys[1] = ima["commonBLSPublicKey1"].get_str(); - commonBLSPublicKeys[2] = ima["commonBLSPublicKey2"].get_str(); - commonBLSPublicKeys[3] = ima["commonBLSPublicKey3"].get_str(); - } catch ( ... ) { - // all or nothing - if ( !keyShareName.empty() ) - throw; } - else - try { - js::mObject ima = infoObj.at( "wallets" ).get_obj().at( "ima" ).get_obj(); - commonBLSPublicKeys[0] = ima["commonBLSPublicKey0"].get_str(); - commonBLSPublicKeys[1] = ima["commonBLSPublicKey1"].get_str(); - commonBLSPublicKeys[2] = ima["commonBLSPublicKey2"].get_str(); - commonBLSPublicKeys[3] = ima["commonBLSPublicKey3"].get_str(); - } catch ( ... ) { - } + } catch ( ... ) { + // all or nothing + if ( !syncNode && !keyShareName.empty() ) + throw; + } cp.nodeInfo = { nodeName, nodeID, ip, static_cast< uint16_t >( port ), ip6, static_cast< uint16_t >( port6 ), sgxServerUrl, ecdsaKeyName, keyShareName, BLSPublicKeys, From d678d09834ce4fbff02a32c230b0be3dd372227a Mon Sep 17 00:00:00 2001 From: Oleh Date: Mon, 13 May 2024 18:30:27 +0100 Subject: [PATCH 08/11] IS 864 fix typo after merge --- libethereum/SchainPatch.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libethereum/SchainPatch.h b/libethereum/SchainPatch.h index 9352138d8..e0ecc7639 100644 --- a/libethereum/SchainPatch.h +++ b/libethereum/SchainPatch.h @@ -139,6 +139,5 @@ DEFINE_SIMPLE_PATCH( EIP1559TransactionsPatch ); * Enable bls signatures verification for sync node */ DEFINE_AMNESIC_PATCH( VerifyBlsSyncPatch ); -======= #endif // SCHAINPATCH_H From 538f60bfccf14332fa9b500d33720a4256f3b0cd Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Wed, 15 May 2024 11:31:22 +0100 Subject: [PATCH 09/11] IS 864 add new config variable --- libethcore/ChainOperationParams.h | 5 ++- libethereum/ChainParams.cpp | 15 ++++---- libethereum/SkaleHost.cpp | 34 +++++++++---------- libethereum/ValidationSchemes.cpp | 4 +-- test/unittests/libethereum/ClientTest.cpp | 6 ++-- .../libethereum/PrecompiledConfig.json | 2 +- .../unittests/libethereum/PrecompiledTest.cpp | 2 +- test/unittests/libethereum/SkaleHost.cpp | 1 + test/unittests/libweb3jsonrpc/jsonrpc.cpp | 2 +- 9 files changed, 36 insertions(+), 35 deletions(-) diff --git a/libethcore/ChainOperationParams.h b/libethcore/ChainOperationParams.h index 9123ad3cf..1383b84b8 100644 --- a/libethcore/ChainOperationParams.h +++ b/libethcore/ChainOperationParams.h @@ -90,6 +90,7 @@ struct NodeInfo { bool syncNode; bool archiveMode; bool syncFromCatchup; + bool testSignatures; NodeInfo( std::string _name = "TestNode", u256 _id = 1, std::string _ip = "127.0.0.11", uint16_t _port = 11111, std::string _ip6 = "::1", uint16_t _port6 = 11111, @@ -107,7 +108,8 @@ struct NodeInfo { "11559732032986387107991004021392285783925812861821192530917403151452391805634", "8495653923123431417604973247489272438418190587263600148770280649306958101930", "4082367875863433681332203403145435568316851327593401208105741076214120093531" }, - bool _syncNode = false, bool _archiveMode = false, bool _syncFromCatchup = false ) { + bool _syncNode = false, bool _archiveMode = false, bool _syncFromCatchup = false, + bool _testSignatures = true ) { name = _name; id = _id; ip = _ip; @@ -122,6 +124,7 @@ struct NodeInfo { syncNode = _syncNode; archiveMode = _archiveMode; syncFromCatchup = _syncFromCatchup; + testSignatures = _testSignatures; } }; diff --git a/libethereum/ChainParams.cpp b/libethereum/ChainParams.cpp index ba72d351b..4b2be0789 100644 --- a/libethereum/ChainParams.cpp +++ b/libethereum/ChainParams.cpp @@ -217,16 +217,18 @@ void ChainParams::processSkaleConfigItems( ChainParams& cp, json_spirit::mObject if ( cp.rotateAfterBlock_ < 0 ) cp.rotateAfterBlock_ = 0; - string ecdsaKeyName; + bool testSignatures = false; try { - ecdsaKeyName = infoObj.at( "ecdsaKeyName" ).get_str(); + testSignatures = infoObj.at( "testSignatures" ).get_bool(); } catch ( ... ) { } + string ecdsaKeyName; array< string, 4 > BLSPublicKeys; array< string, 4 > commonBLSPublicKeys; + if ( !testSignatures ) { + ecdsaKeyName = infoObj.at( "ecdsaKeyName" ).get_str(); - try { js::mObject ima = infoObj.at( "wallets" ).get_obj().at( "ima" ).get_obj(); commonBLSPublicKeys[0] = ima["commonBLSPublicKey0"].get_str(); @@ -244,16 +246,11 @@ void ChainParams::processSkaleConfigItems( ChainParams& cp, json_spirit::mObject BLSPublicKeys[2] = ima["BLSPublicKey2"].get_str(); BLSPublicKeys[3] = ima["BLSPublicKey3"].get_str(); } - - } catch ( ... ) { - // all or nothing - if ( !syncNode && !keyShareName.empty() ) - throw; } cp.nodeInfo = { nodeName, nodeID, ip, static_cast< uint16_t >( port ), ip6, static_cast< uint16_t >( port6 ), sgxServerUrl, ecdsaKeyName, keyShareName, BLSPublicKeys, - commonBLSPublicKeys, syncNode, archiveMode, syncFromCatchup }; + commonBLSPublicKeys, syncNode, archiveMode, syncFromCatchup, testSignatures }; auto sChainObj = skaleObj.at( "sChain" ).get_obj(); SChain s{}; diff --git a/libethereum/SkaleHost.cpp b/libethereum/SkaleHost.cpp index 87b32856b..bb91505e1 100644 --- a/libethereum/SkaleHost.cpp +++ b/libethereum/SkaleHost.cpp @@ -143,13 +143,15 @@ void DefaultConsensusFactory::fillSgxInfo( ConsensusEngine& consensus ) const tr } void DefaultConsensusFactory::fillPublicKeyInfo( ConsensusEngine& consensus ) const try { + if ( m_client.chainParams().nodeInfo.testSignatures ) + // no keys in tests + return; + const std::string sgxServerUrl = m_client.chainParams().nodeInfo.sgxServerUrl; std::shared_ptr< std::vector< std::string > > ecdsaPublicKeys = std::make_shared< std::vector< std::string > >(); for ( const auto& node : m_client.chainParams().sChain.nodes ) { - if ( node.publicKey.size() == 0 ) - return; // just don't do anything ecdsaPublicKeys->push_back( node.publicKey.substr( 2 ) ); } @@ -157,15 +159,15 @@ void DefaultConsensusFactory::fillPublicKeyInfo( ConsensusEngine& consensus ) co for ( const auto& node : m_client.chainParams().sChain.nodes ) { std::vector< std::string > public_key_share( 4 ); if ( node.id != this->m_client.chainParams().nodeInfo.id ) { - public_key_share[0] = node.blsPublicKey[0]; - public_key_share[1] = node.blsPublicKey[1]; - public_key_share[2] = node.blsPublicKey[2]; - public_key_share[3] = node.blsPublicKey[3]; + public_key_share[0] = node.blsPublicKey.at( 0 ); + public_key_share[1] = node.blsPublicKey.at( 1 ); + public_key_share[2] = node.blsPublicKey.at( 2 ); + public_key_share[3] = node.blsPublicKey.at( 3 ); } else { - public_key_share[0] = m_client.chainParams().nodeInfo.BLSPublicKeys[0]; - public_key_share[1] = m_client.chainParams().nodeInfo.BLSPublicKeys[1]; - public_key_share[2] = m_client.chainParams().nodeInfo.BLSPublicKeys[2]; - public_key_share[3] = m_client.chainParams().nodeInfo.BLSPublicKeys[3]; + public_key_share[0] = m_client.chainParams().nodeInfo.BLSPublicKeys.at( 0 ); + public_key_share[1] = m_client.chainParams().nodeInfo.BLSPublicKeys.at( 1 ); + public_key_share[2] = m_client.chainParams().nodeInfo.BLSPublicKeys.at( 2 ); + public_key_share[3] = m_client.chainParams().nodeInfo.BLSPublicKeys.at( 3 ); } blsPublicKeys.push_back( @@ -179,11 +181,8 @@ void DefaultConsensusFactory::fillPublicKeyInfo( ConsensusEngine& consensus ) co size_t n = m_client.chainParams().sChain.nodes.size(); size_t t = ( 2 * n + 1 ) / 3; - if ( ecdsaPublicKeys->size() && ecdsaPublicKeys->at( 0 ).size() && - ( ( blsPublicKeys.size() && blsPublicKeys[0]->at( 0 ).size() ) || - m_client.chainParams().nodeInfo.syncNode ) ) - consensus.setPublicKeyInfo( - ecdsaPublicKeys, blsPublicKeysPtr, t, n, m_client.chainParams().nodeInfo.syncNode ); + consensus.setPublicKeyInfo( + ecdsaPublicKeys, blsPublicKeysPtr, t, n, m_client.chainParams().nodeInfo.syncNode ); } catch ( ... ) { std::throw_with_nested( std::runtime_error( "Error filling public keys info (nodeGroups)" ) ); } @@ -195,8 +194,9 @@ void DefaultConsensusFactory::fillRotationHistory( ConsensusEngine& consensus ) 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] }; + std::vector< string > commonBLSPublicKey = { nodeGroup.blsPublicKey.at( 0 ), + nodeGroup.blsPublicKey.at( 1 ), nodeGroup.blsPublicKey.at( 2 ), + nodeGroup.blsPublicKey.at( 3 ) }; previousBLSKeys[nodeGroup.finishTs] = commonBLSPublicKey; std::vector< uint64_t > nodes; // add ecdsa keys info and historic groups info diff --git a/libethereum/ValidationSchemes.cpp b/libethereum/ValidationSchemes.cpp index 4040e774a..e6b493e7e 100644 --- a/libethereum/ValidationSchemes.cpp +++ b/libethereum/ValidationSchemes.cpp @@ -164,7 +164,7 @@ void validateConfigJson( js::mObject const& _obj ) { { "snapshotIntervalSec", { { js::int_type }, JsonFieldPresence::Optional } }, { "rotateAfterBlock", { { js::int_type }, JsonFieldPresence::Optional } }, { "wallets", { { js::obj_type }, JsonFieldPresence::Optional } }, - { "ecdsaKeyName", { { js::str_type }, JsonFieldPresence::Required } }, + { "ecdsaKeyName", { { js::str_type }, JsonFieldPresence::Optional } }, { "verifyImaMessagesViaLogsSearch", { { js::bool_type }, JsonFieldPresence::Optional } }, { "verifyImaMessagesViaContractCall", @@ -222,6 +222,7 @@ void validateConfigJson( js::mObject const& _obj ) { { "syncNode", { { js::bool_type }, JsonFieldPresence::Optional } }, { "archiveMode", { { js::bool_type }, JsonFieldPresence::Optional } }, { "syncFromCatchup", { { js::bool_type }, JsonFieldPresence::Optional } }, + { "testSignatures", { { js::bool_type }, JsonFieldPresence::Optional } }, { "wallets", { { js::obj_type }, JsonFieldPresence::Optional } } } ); std::string keyShareName = ""; @@ -268,7 +269,6 @@ void validateConfigJson( js::mObject const& _obj ) { { "maxSkaledLeveldbStorageBytes", { { js::int_type }, JsonFieldPresence::Optional } }, { "freeContractDeployment", { { js::bool_type }, JsonFieldPresence::Optional } }, { "multiTransactionMode", { { js::bool_type }, JsonFieldPresence::Optional } }, - { "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } }, { "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } } }, []( const string& _key ) { // function fow allowing fields diff --git a/test/unittests/libethereum/ClientTest.cpp b/test/unittests/libethereum/ClientTest.cpp index a3f8850e0..ed9bdb878 100644 --- a/test/unittests/libethereum/ClientTest.cpp +++ b/test/unittests/libethereum/ClientTest.cpp @@ -411,7 +411,7 @@ static std::string const c_genesisInfoSkaleTest = std::string() + "basePort": )E"+std::to_string( rand_port ) + R"E(, "logLevel": "trace", "logLevelProposal": "trace", - "ecdsaKeyName": "NEK:fa112" + "testSignatures": true }, "sChain": { "schainName": "TestChain", @@ -887,7 +887,7 @@ static std::string const c_genesisInfoSkaleIMABLSPublicKeyTest = std::string() + "basePort": )E"+std::to_string( rand_port ) + R"E(, "logLevel": "trace", "logLevelProposal": "trace", - "ecdsaKeyName": "NEK:fa112" + "testSignatures": true }, "sChain": { "schainName": "TestChain", @@ -1002,7 +1002,7 @@ static std::string const c_skaleConfigString = R"E( "nodeID": 1112, "bindIP": "127.0.0.1", "basePort": )E"+std::to_string( rand_port ) + R"E(, - "ecdsaKeyName": "NEK:fa112" + "testSignatures": true }, "sChain": { "schainName": "TestChain", diff --git a/test/unittests/libethereum/PrecompiledConfig.json b/test/unittests/libethereum/PrecompiledConfig.json index b7b4901f0..ec4673de2 100644 --- a/test/unittests/libethereum/PrecompiledConfig.json +++ b/test/unittests/libethereum/PrecompiledConfig.json @@ -38,7 +38,7 @@ "basePort": 1234, "logLevel": "trace", "logLevelProposal": "trace", - "ecdsaKeyName": "NEK:fa112", + "testSignatures": true, "wallets": { "ima": { "n": 1 diff --git a/test/unittests/libethereum/PrecompiledTest.cpp b/test/unittests/libethereum/PrecompiledTest.cpp index bec328e70..7be67c511 100644 --- a/test/unittests/libethereum/PrecompiledTest.cpp +++ b/test/unittests/libethereum/PrecompiledTest.cpp @@ -1619,7 +1619,7 @@ static std::string const genesisInfoSkaleConfigTest = std::string() + "basePort": 1234, "logLevel": "trace", "logLevelProposal": "trace", - "ecdsaKeyName": "NEK:fa112", + "testSignatures": true, "wallets": { "ima": { "n": 1 diff --git a/test/unittests/libethereum/SkaleHost.cpp b/test/unittests/libethereum/SkaleHost.cpp index 7f2be5290..f4b93ce8d 100644 --- a/test/unittests/libethereum/SkaleHost.cpp +++ b/test/unittests/libethereum/SkaleHost.cpp @@ -130,6 +130,7 @@ struct SkaleHostFixture : public TestOutputHelperFixture { chainParams.extraData = h256::random().asBytes(); chainParams.sChain.nodeGroups = { { {}, uint64_t(-1), {"0", "0", "1", "0"} } }; chainParams.nodeInfo.port = chainParams.nodeInfo.port6 = rand_port; + chainParams.nodeInfo.testSignatures = true; chainParams.sChain.nodes[0].port = chainParams.sChain.nodes[0].port6 = rand_port; // not 0-timestamp genesis - to test patch diff --git a/test/unittests/libweb3jsonrpc/jsonrpc.cpp b/test/unittests/libweb3jsonrpc/jsonrpc.cpp index d7a33fd49..b89e62726 100644 --- a/test/unittests/libweb3jsonrpc/jsonrpc.cpp +++ b/test/unittests/libweb3jsonrpc/jsonrpc.cpp @@ -101,7 +101,7 @@ static std::string const c_genesisConfigString = "basePort": )"+std::to_string( rand_port ) + R"(, "logLevel": "trace", "logLevelProposal": "trace", - "ecdsaKeyName": "NEK:fa112" + "testSignatures": true }, "sChain": { "schainName": "TestChain", From a88f7dad54980b54ef28f324e124e3a2ea587023 Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Wed, 15 May 2024 16:01:23 +0100 Subject: [PATCH 10/11] IS 864 functional tests --- .github/workflows/functional-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index 02ad6deb7..df34f37da 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -24,7 +24,7 @@ with: token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} repository: skalenetwork/skale-ci-integration_tests - ref: v3.18.0 + ref: temp-branch-3.19.0 submodules: recursive - name: Set up Node uses: actions/setup-node@v3.4.0 From 360f8d8941ae3ac33f78d7ee2192babaf1406f59 Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Thu, 16 May 2024 14:57:22 +0100 Subject: [PATCH 11/11] IS 864 update skale-ci-integrations ref --- .github/workflows/functional-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index df34f37da..f7356fc36 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -24,7 +24,7 @@ with: token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} repository: skalenetwork/skale-ci-integration_tests - ref: temp-branch-3.19.0 + ref: master submodules: recursive - name: Set up Node uses: actions/setup-node@v3.4.0