Skip to content

Commit

Permalink
Merge branch 'WE-8462-contract-update-fix' into 'release-1.12'
Browse files Browse the repository at this point in the history
WE-8462 – Fixed specific case with contract updating

See merge request waves-enterprise/open-source-node!30
  • Loading branch information
Ruslan Gamzaliev committed Nov 25, 2022
2 parents 47b6f0b + e847035 commit acc40d8
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,24 @@ class ValidatorTransactionsExecutor(
atomically: Boolean): Either[ValidationError, TransactionWithDiff] = {
(for {
executedTx <- ExecutedContractTransactionV1.selfSigned(nodeOwnerAccount, tx, List.empty, time.getTimestamp())
_ = log.debug(s"Built executed transaction '${executedTx.id()}' for '${tx.id()}'")
_ = log.debug(s"Built executed transaction '${executedTx.id()}' for '${tx.id()}'")
contractId = ContractId(tx.contractId)
// We need to check the validation policy before tx appending, because if the policy changes to any, we will not
// send validation result and miner will not be able to process the tx.
validationPolicyIsNotAnyBeforeAppend = validationPolicyIsNotAny(contractId)
diff <- {
if (atomically)
transactionsAccumulator.processAtomically(executedTx, maybeCertChainWithCrl)
else
transactionsAccumulator.process(executedTx, maybeCertChainWithCrl)
}
} yield {
if (validationPolicyIsNotAny(tx)) {
def validationPolicyIsNotAnyAfterAppend: Boolean = validationPolicyIsNotAny(contractId)

if (validationPolicyIsNotAnyBeforeAppend || validationPolicyIsNotAnyAfterAppend) {
broadcastResultsMessage(tx, List.empty, List.empty)
}

log.debug(s"Success update contract execution for tx '${tx.id()}'")
TransactionWithDiff(executedTx, diff)
}).leftMap { error =>
Expand Down Expand Up @@ -110,7 +117,7 @@ class ValidatorTransactionsExecutor(
}
} yield {

if (validationPolicyIsNotAny(tx)) {
if (validationPolicyIsNotAny(ContractId(tx.contractId))) {
broadcastResultsMessage(tx, results, assetOperations)
}
log.debug(s"Success contract execution for tx '${tx.id()}'")
Expand Down Expand Up @@ -168,9 +175,9 @@ class ValidatorTransactionsExecutor(
}

@inline
private def validationPolicyIsNotAny(tx: ExecutableTransaction): Boolean = {
private def validationPolicyIsNotAny(contractId: ContractId): Boolean = {
transactionsAccumulator
.contract(ContractId(tx.contractId))
.contract(contractId)
.exists(_.validationPolicy != ValidationPolicy.Any)
}
}
Expand Down

0 comments on commit acc40d8

Please sign in to comment.