@@ -128,8 +128,33 @@ bool StReconfigurationHandler::handle(const concord::messages::AddRemoveWithWedg
128128 uint64_t bft_seq_num,
129129 uint64_t current_cp_num,
130130 uint64_t bid) {
131- return handleWedgeCommands (
132- command, bid, current_cp_num, bft_seq_num, command.bft_support , true , command.restart , command.restart );
131+ // This callback should work together with the asyncCRE scaling handler. If the scale command has broken state
132+ // transfer itself, we won't even get to that point, and the CRE is expected to handle this case. However, if we did
133+ // manage to complete state transfer, CRE is halted and we need to execute the command based on the state we gained
134+ // during state transfer. In order not to execute the command twice, we do check that this configuration was not
135+ // already executed by reading the local configuration list.
136+ std::ofstream configurations_file;
137+ configurations_file.open (bftEngine::ReplicaConfig::instance ().configurationViewFilePath + " /" +
138+ concord::reconfiguration::configurationsFileName + " ." +
139+ std::to_string (bftEngine::ReplicaConfig::instance ().replicaId ),
140+ std::ios_base::app);
141+ if (configurations_file.good ()) {
142+ std::stringstream stream;
143+ stream << configurations_file.rdbuf ();
144+ std::string configs = stream.str ();
145+ if (configs.find (command.config_descriptor ) != std::string::npos) {
146+ LOG_INFO (GL, " the scale command was already executed by async CRE, we won't execute it again" );
147+ return false ;
148+ }
149+ }
150+ bool succ = true ;
151+ concord::messages::ReconfigurationResponse response;
152+ for (auto &h : orig_reconf_handlers_) {
153+ // If it was written to the blockchain, it means that this is a valid request.
154+ // We do need to execute every relevant reconfiguration handler to complete the scale command.
155+ succ &= h->handle (command, bft_seq_num, UINT32_MAX, std::nullopt , response);
156+ }
157+ return succ;
133158}
134159
135160bool StReconfigurationHandler::handle (const concord::messages::RestartCommand &command,
0 commit comments