Skip to content

Commit

Permalink
Merge pull request #296 from skalenetwork/bug/SKALE-2810-pass-sgx-par…
Browse files Browse the repository at this point in the history
…ameters

SKALE-2810 read blsPublicKey from config
  • Loading branch information
olehnikolaiev authored Jun 26, 2020
2 parents b7d7688 + d2987d7 commit 380fa2b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions libethcore/ChainOperationParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct sChainNode {
u256 port6;
u256 sChainIndex;
std::string publicKey;
std::array< std::string, 4 > blsPublicKey;
};

/// skale
Expand All @@ -135,8 +136,8 @@ struct SChain {

// HACK This creates one node and allows to run tests - BUT when loading config we need to
// delete this explicitly!!
sChainNode me = {
u256( 1 ), "127.0.0.11", u256( 11111 ), "::1", u256( 11111 ), u256( 1 ), "0xfa"};
sChainNode me = {u256( 1 ), "127.0.0.11", u256( 11111 ), "::1", u256( 11111 ), u256( 1 ),
"0xfa", {"0", "1", "0", "1"}};
nodes.push_back( me );
}
};
Expand Down
6 changes: 6 additions & 0 deletions libethereum/ChainParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ ChainParams ChainParams::loadConfig(
}
node.sChainIndex = nodeConfObj.at( "schainIndex" ).get_uint64();
node.publicKey = nodeConfObj.at( "publicKey" ).get_str();
if ( !keyShareName.empty() ) {
node.blsPublicKey[0] = nodeConfObj.at( "blsPublicKey0" ).get_str();
node.blsPublicKey[1] = nodeConfObj.at( "blsPublicKey1" ).get_str();
node.blsPublicKey[2] = nodeConfObj.at( "blsPublicKey2" ).get_str();
node.blsPublicKey[3] = nodeConfObj.at( "blsPublicKey3" ).get_str();
}
s.nodes.push_back( node );
}
cp.sChain = s;
Expand Down
14 changes: 4 additions & 10 deletions libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,10 @@ void DefaultConsensusFactory::fillSgxInfo( ConsensusEngine& consensus ) const {
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 ) {
jsonrpc::HttpClient* jsonRpcClient = new jsonrpc::HttpClient(
"http://" + node.ip + ':' + ( node.port + 3 ).convert_to< std::string >() );
SkaleClient skaleClient( *jsonRpcClient );

Json::Value joPublicKeyResponse = skaleClient.skale_imaInfo();

public_key_share[0] = joPublicKeyResponse["insecureBLSPublicKey0"].asString();
public_key_share[1] = joPublicKeyResponse["insecureBLSPublicKey1"].asString();
public_key_share[2] = joPublicKeyResponse["insecureBLSPublicKey2"].asString();
public_key_share[3] = joPublicKeyResponse["insecureBLSPublicKey3"].asString();
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];
} else {
public_key_share[0] = this->m_client.chainParams().nodeInfo.insecureBLSPublicKeys[0];
public_key_share[1] = this->m_client.chainParams().nodeInfo.insecureBLSPublicKeys[1];
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/mapreduce_consensus/ConsensusEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class ConsensusExtFaceFixture : public ConsensusExtFace {
chainParams.gasLimit = chainParams.maxGasLimit;
chainParams.extraData = h256::random().asBytes();

sChainNode node2{u256( 2 ), "127.0.0.12", u256( 11111 ), "::1", u256( 11111 ), u256( 1 ), "0xfa"};
sChainNode node2{u256( 2 ), "127.0.0.12", u256( 11111 ), "::1", u256( 11111 ), u256( 1 ), "0xfa", {"0", "1", "0", "1"}};
chainParams.sChain.nodes.push_back( node2 );
//////////////////////////////////////////////

Expand Down

0 comments on commit 380fa2b

Please sign in to comment.