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

Bug/is 864 bls sync config #1891

Merged
merged 15 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
23 changes: 13 additions & 10 deletions libethereum/ChainParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,22 +229,25 @@ void ChainParams::processSkaleConfigItems( ChainParams& cp, json_spirit::mObject
try {
js::mObject ima = infoObj.at( "wallets" ).get_obj().at( "ima" ).get_obj();

keyShareName = ima.at( "keyShareName" ).get_str();

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();

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();

BLSPublicKeys[0] = ima["BLSPublicKey0"].get_str();
BLSPublicKeys[1] = ima["BLSPublicKey1"].get_str();
BLSPublicKeys[2] = ima["BLSPublicKey2"].get_str();
BLSPublicKeys[3] = ima["BLSPublicKey3"].get_str();
}

} catch ( ... ) {
// all or nothing
if ( !keyShareName.empty() )
if ( !syncNode && !keyShareName.empty() )
throw;
}

Expand Down
4 changes: 4 additions & 0 deletions libethereum/SchainPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ SchainPatchEnum getEnumForPatchName( const std::string& _patchName ) {
return SchainPatchEnum::SkipInvalidTransactionsPatch;
else if ( _patchName == "EIP1559TransactionsPatch" )
return SchainPatchEnum::EIP1559TransactionsPatch;
else if ( _patchName == "VerifyBlsSyncPatch" )
return SchainPatchEnum::VerifyBlsSyncPatch;
else
throw std::out_of_range( _patchName );
}
Expand Down Expand Up @@ -60,6 +62,8 @@ std::string getPatchNameForEnum( SchainPatchEnum _enumValue ) {
return "SelfdestructStorageLimitPatch";
case SchainPatchEnum::EIP1559TransactionsPatch:
return "EIP1559TransactionsPatch";
case SchainPatchEnum::VerifyBlsSyncPatch:
return "VerifyBlsSyncPatch";
default:
throw std::out_of_range(
"UnknownPatch #" + std::to_string( static_cast< size_t >( _enumValue ) ) );
Expand Down
6 changes: 6 additions & 0 deletions libethereum/SchainPatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,10 @@ DEFINE_SIMPLE_PATCH( SelfdestructStorageLimitPatch );
*/
DEFINE_SIMPLE_PATCH( EIP1559TransactionsPatch );

/*
* Enable bls signatures verification for sync node
*/
DEFINE_AMNESIC_PATCH( VerifyBlsSyncPatch );
=======

#endif // SCHAINPATCH_H
1 change: 1 addition & 0 deletions libethereum/SchainPatchEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum class SchainPatchEnum {
SkipInvalidTransactionsPatch,
SelfdestructStorageLimitPatch,
EIP1559TransactionsPatch,
VerifyBlsSyncPatch,
PatchesCount
};

Expand Down
14 changes: 8 additions & 6 deletions libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -89,10 +91,8 @@ 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 @@ -179,11 +179,13 @@ 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() )
consensus.setPublicKeyInfo( ecdsaPublicKeys, blsPublicKeysPtr, t, n );
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 );
} 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)" ) );
}


Expand Down
Loading