Skip to content

Commit

Permalink
Update fixes for apollo framework
Browse files Browse the repository at this point in the history
Signed-off-by: Kush <kusha@vmware.com>
  • Loading branch information
agrkushvm committed May 5, 2023
1 parent 64a4762 commit 15bf161
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
26 changes: 17 additions & 9 deletions tests/apollo/test_skvbc_reconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ async def test_single_signature_scheme_to_no_single_signature_scheme(self, bft_n
key_file_prefix=KEY_FILE_PREFIX,
start_replica_cmd=lambda builddir, replica_id: start_replica_cmd(builddir, replica_id) +
["--key-exchange-on-start", "True"],
stop_replica_cmd=None, num_ro_replicas=0)
stop_replica_cmd=None, num_ro_replicas=0, num_fn=0)
await bft_network.change_configuration(conf, generate_tls=False)

bft_network.restart_clients(restart_replicas=True)
Expand Down Expand Up @@ -1550,7 +1550,8 @@ async def test_remove_nodes(self, bft_network):
key_file_prefix=KEY_FILE_PREFIX,
start_replica_cmd=start_replica_cmd_with_key_exchange,
stop_replica_cmd=None,
num_ro_replicas=0)
num_ro_replicas=0,
num_fn=0)
await bft_network.change_configuration(conf)
await op.add_remove_with_wedge(test_config, bft=False)
await self.validate_epoch_number(bft_network, 1, bft_network.all_replicas())
Expand Down Expand Up @@ -1598,7 +1599,8 @@ async def test_remove_nodes_with_f_failures(self, bft_network):
key_file_prefix=KEY_FILE_PREFIX,
start_replica_cmd=start_replica_cmd_with_key_exchange,
stop_replica_cmd=None,
num_ro_replicas=0)
num_ro_replicas=0,
num_fn=0)
await bft_network.change_configuration(conf)
await op.add_remove_with_wedge(test_config, bft=True, restart=True)
await self.validate_epoch_number(bft_network, 1, bft_network.all_replicas())
Expand Down Expand Up @@ -1641,7 +1643,8 @@ async def test_remove_nodes_with_unwedge(self, bft_network):
key_file_prefix=KEY_FILE_PREFIX,
start_replica_cmd=start_replica_cmd_with_key_exchange,
stop_replica_cmd=None,
num_ro_replicas=0)
num_ro_replicas=0,
num_fn=0)
await bft_network.change_configuration(conf)
await op.add_remove_with_wedge(test_config, bft=False, restart=False)
await self.validate_stop_on_wedge_point(bft_network, skvbc, fullWedge=True)
Expand Down Expand Up @@ -1691,7 +1694,8 @@ async def test_add_nodes(self, bft_network):
key_file_prefix=KEY_FILE_PREFIX,
start_replica_cmd=start_replica_cmd,
stop_replica_cmd=None,
num_ro_replicas=0)
num_ro_replicas=0,
num_fn=0)
await bft_network.change_configuration(conf, generate_tls=True)
bft_network.restart_clients()
await self.validate_epoch_number(bft_network, 1, bft_network.all_replicas())
Expand Down Expand Up @@ -1730,7 +1734,8 @@ async def test_key_exchange_after_add_nodes_with_failure(self, bft_network):
key_file_prefix=KEY_FILE_PREFIX,
start_replica_cmd=start_replica_cmd_with_key_exchange,
stop_replica_cmd=None,
num_ro_replicas=0)
num_ro_replicas=0,
num_fn=0)
await bft_network.change_configuration(conf, generate_tls=True)
bft_network.restart_clients(restart_replicas=False)
bft_network.start_replicas(replicas=bft_network.all_replicas(without=late_replica_set))
Expand Down Expand Up @@ -1816,7 +1821,8 @@ async def test_add_nodes_with_failures(self, bft_network):
key_file_prefix=KEY_FILE_PREFIX,
start_replica_cmd=start_replica_cmd_with_key_exchange,
stop_replica_cmd=None,
num_ro_replicas=0)
num_ro_replicas=0,
num_fn=0)
await bft_network.change_configuration(conf, generate_tls=True)
bft_network.restart_clients(generate_tx_signing_keys=True, restart_replicas=False)

Expand Down Expand Up @@ -1928,7 +1934,8 @@ async def test_reconfiguration_with_ror(self, bft_network):
key_file_prefix=KEY_FILE_PREFIX,
start_replica_cmd=start_replica_cmd_with_object_store_and_ke,
stop_replica_cmd=None,
num_ro_replicas=1)
num_ro_replicas=1,
num_fn=0)
await bft_network.change_configuration(conf)
ro_replica_id = bft_network.config.n
await bft_network.check_initial_key_exchange(stop_replicas=False)
Expand Down Expand Up @@ -1965,7 +1972,8 @@ async def test_reconfiguration_with_ror(self, bft_network):
key_file_prefix=KEY_FILE_PREFIX,
start_replica_cmd=start_replica_cmd_with_object_store_and_ke,
stop_replica_cmd=None,
num_ro_replicas=1)
num_ro_replicas=1,
num_fn=0)
await bft_network.change_configuration(conf)
ro_replica_id = bft_network.config.n
await bft_network.check_initial_key_exchange(stop_replicas=False)
Expand Down
6 changes: 4 additions & 2 deletions tests/apollo/util/bft.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,11 @@ def restart_clients(self, generate_tx_signing_keys=True, restart_replicas=True):

def _generate_crypto_keys(self):
keygen = os.path.join(self.toolsdir, "GenerateConcordKeys")
args = [keygen, "-n", str(self.config.n + self.config.num_fn), "-f", str(2)]
args = [keygen, "-n", str(self.config.n), "-f", str(self.config.f)]
if self.config.num_ro_replicas > 0:
args.extend(["-r", str(self.config.num_ro_replicas)])
args.extend(["-r", str(self.config.num_ro_replicas)])
if self.config.num_fn > 0:
args.extend(["-fn", str(self.config.num_fn)])
args.extend(["-o", self.config.key_file_prefix])
with log.start_action(action_type="Key Generation", cmdline=' '.join(args)):
subprocess.run(args, check=True)
Expand Down
2 changes: 2 additions & 0 deletions tests/simpleKVBC/TesterReplica/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ std::unique_ptr<TestSetup> TestSetup::ParseArgs(int argc, char** argv) {
}
}

LOG_INFO(logger, "\nRead all the arguments \n");

replicaConfig.singleSignatureScheme = singleSignatureScheme;
if (keysFilePrefix.empty()) throw std::runtime_error("missing --key-file-prefix");

Expand Down
16 changes: 13 additions & 3 deletions tools/GenerateConcordKeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ int main(int argc, char** argv) {
ReplicaConfig& config = ReplicaConfig::instance();
uint16_t n = 0;
uint16_t ro = 0;
uint16_t fn = 0;
std::string outputPrefix;

std::string defaultSysType = "UninitializedCryptoSystem";
Expand Down Expand Up @@ -128,6 +129,9 @@ int main(int argc, char** argv) {
} else if (option == "-r") {
if (i >= argc - 1) throw std::runtime_error("Expected an argument to -r");
ro = parse<std::uint16_t>(argv[i++ + 1], "-r");
} else if (option == "-fn") {
if (i >= argc - 1) throw std::runtime_error("Expected an argument to -fn");
fn = parse<std::uint16_t>(argv[i++ + 1], "-fn");
} else if (option == "-o") {
if (i >= argc - 1) throw std::runtime_error("Expected an argument to -o");
outputPrefix = argv[i++ + 1];
Expand Down Expand Up @@ -176,7 +180,7 @@ int main(int argc, char** argv) {

std::vector<std::pair<std::string, std::string>> replicaKeyPairs;

for (uint16_t i = 0; i < n + ro; ++i) {
for (uint16_t i = 0; i < n + ro + fn; ++i) {
if (ReplicaConfig::instance().replicaMsgSigningAlgo == SignatureAlgorithm::EdDSA) {
replicaKeyPairs.push_back(generateEdDSAKeyPair());
}
Expand All @@ -193,14 +197,20 @@ int main(int argc, char** argv) {
for (uint16_t i = 0; i < n; ++i) {
config.replicaId = i;
config.replicaPrivateKey = replicaKeyPairs[i].first;
outputReplicaKeyfile(n, ro, config, outputPrefix + std::to_string(i), &cryptoSys);
outputReplicaKeyfile(n, ro, fn, config, outputPrefix + std::to_string(i), &cryptoSys);
}

for (uint16_t i = n; i < n + ro; ++i) {
config.isReadOnly = true;
config.replicaId = i;
config.replicaPrivateKey = replicaKeyPairs[i].first;
outputReplicaKeyfile(n, ro, config, outputPrefix + std::to_string(i));
outputReplicaKeyfile(n, ro, fn, config, outputPrefix + std::to_string(i));
}

for (uint16_t i = n + ro; i < n + ro + fn; ++i) {
config.replicaId = i;
config.replicaPrivateKey = replicaKeyPairs[i].first;
outputReplicaKeyfile(n, ro, fn, config, outputPrefix + std::to_string(i));
}
} catch (std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
Expand Down
1 change: 1 addition & 0 deletions tools/KeyfileIOUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ using concord::crypto::Ed25519PublicKeyByteSize;

void outputReplicaKeyfile(uint16_t numReplicas,
uint16_t numRoReplicas,
uint16_t numFn,
ReplicaConfig& config,
const std::string& outputFilename,
Cryptosystem* commonSys) {
Expand Down
1 change: 1 addition & 0 deletions tools/KeyfileIOUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*/
void outputReplicaKeyfile(uint16_t numReplicas,
uint16_t numRoReplicas,
uint16_t numFn,
bftEngine::ReplicaConfig& config,
const std::string& outputFilename,
Cryptosystem* commonSys = nullptr);
Expand Down

0 comments on commit 15bf161

Please sign in to comment.