Skip to content

Commit

Permalink
Fix broadcasted message
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mashonskiy committed Sep 25, 2024
1 parent 7a9851b commit 492970e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/main/scala/units/ELUpdater.scala
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,17 @@ class ELUpdater(
latestValidHashOpt <- engineApiClient.applyNewPayload(payloadJson)
latestValidHash <- Either.fromOption(latestValidHashOpt, ClientError("Latest valid hash not defined"))
_ = logger.info(s"Applied payload $payloadId, block hash is $latestValidHash, timestamp = $timestamp")
newBlock <- NetworkBlock.signed(payloadJson, m.keyPair.privateKey)
_ = logger.debug(s"Broadcasting block ${newBlock.hash}")
_ <- Try(allChannels.broadcast(newBlock)).toEither.leftMap(err =>
ClientError(s"Failed to broadcast block ${newBlock.hash}: ${err.toString}")
newPm <- PayloadMessage.signed(payloadJson, m.keyPair.privateKey).leftMap(ClientError.apply)
_ = logger.debug(s"Broadcasting block ${newPm.hash} payload")
_ <- Try(allChannels.broadcast(newPm)).toEither.leftMap(err =>
ClientError(s"Failed to broadcast block ${newPm.hash} payload: ${err.toString}")
)
executionPayload = newBlock.toPayload
transfersRootHash <- getE2CTransfersRootHash(executionPayload.hash, chainContractOptions.elBridgeAddress)
funcCall <- contractFunction.toFunctionCall(executionPayload.hash, transfersRootHash, m.lastC2ETransferIndex)
_ <- callContract(funcCall, executionPayload, m.keyPair)
} yield executionPayload).fold(
payloadInfo <- newPm.payloadInfo.leftMap(ClientError.apply)
payload = payloadInfo.payload
transfersRootHash <- getE2CTransfersRootHash(payload.hash, chainContractOptions.elBridgeAddress)
funcCall <- contractFunction.toFunctionCall(payload.hash, transfersRootHash, m.lastC2ETransferIndex)
_ <- callContract(funcCall, payload, m.keyPair)
} yield payload).fold(
err => logger.error(s"Failed to forge block for payloadId $payloadId at epoch ${epochInfo.number}: ${err.message}"),
newPayload => scheduler.execute { () => tryToForgeNextBlock(epochInfo.number, newPayload, chainContractOptions) }
)
Expand Down

0 comments on commit 492970e

Please sign in to comment.