Skip to content

Commit

Permalink
fix: clear "side-effect fields" after switch a child record from SUCC…
Browse files Browse the repository at this point in the history
…ESS to REVERTED_SUCCESS

Signed-off-by: Nikita Lebedev <nikita.lebedev@limechain.tech>
  • Loading branch information
thenswan committed Dec 12, 2023
1 parent 6f00b68 commit cc51672
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.hedera.node.app.workflows.handle.HandleContextImpl;
import com.hedera.node.app.workflows.handle.record.SingleTransactionRecordBuilderImpl.ReversingBehavior;
import com.hedera.node.config.data.ConsensusConfig;
import com.hedera.pbj.runtime.io.buffer.Bytes;
import com.swirlds.config.api.Configuration;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.time.Instant;
Expand Down Expand Up @@ -376,7 +377,31 @@ public void revertChildrenOf(@NonNull final SingleTransactionRecordBuilderImpl r
followingChildRemoved = true;
} else {
if (child.reversingBehavior() == ReversingBehavior.REVERSIBLE && SUCCESSES.contains(child.status())) {
// clear "side effect" fields
child.accountID(null);
child.contractID(null);
child.fileID(null);
child.tokenID(null);
child.scheduleID(null);
child.scheduledTransactionID(null);
child.serialNumbers().clear();
child.topicRunningHash(Bytes.EMPTY);
child.newTotalSupply(-1L);
child.topicRunningHashVersion(0L);
child.topicSequenceNumber(0L);
child.tokenTransferLists().clear();
child.automaticTokenAssociations().clear();
if (child.transferList().hasAccountAmounts()) {
child.transferList().accountAmounts().clear();
}
child.paidStakingRewards().clear();
child.contractCreateResult(null);
child.scheduleRef(null);
child.assessedCustomFees().clear();
child.alias(Bytes.EMPTY);
child.ethereumHash(Bytes.EMPTY);
child.evmAddress(Bytes.EMPTY);

child.status(ResponseCodeEnum.REVERTED_SUCCESS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,17 @@ public SingleTransactionRecordBuilderImpl contractCreateResult(
return this;
}

/**
* Gets the transferList.
*
* @return transferList
*/
@Override
@NonNull
public TransferList transferList() {
return transferList;
}

/**
* Sets the transferList.
*
Expand All @@ -496,12 +507,6 @@ public SingleTransactionRecordBuilderImpl transferList(@NonNull final TransferLi
return this;
}

@Override
@NonNull
public TransferList transferList() {
return transferList;
}

/**
* Sets the tokenTransferLists.
*
Expand Down Expand Up @@ -549,6 +554,16 @@ public SingleTransactionRecordBuilderImpl scheduleRef(@NonNull final ScheduleID
return this;
}

/**
* Gets the assessedCustomFees.
*
* @return assessedCustomFees
*/
@NonNull
public List<AssessedCustomFee> assessedCustomFees() {
return this.assessedCustomFees;
}

/**
* Sets the assessedCustomFees.
*
Expand Down Expand Up @@ -577,6 +592,16 @@ public SingleTransactionRecordBuilderImpl addAssessedCustomFee(@NonNull final As
return this;
}

/**
* Gets the automaticTokenAssociations.
*
* @return automaticTokenAssociations
*/
@NonNull
public List<TokenAssociation> automaticTokenAssociations() {
return this.automaticTokenAssociations;
}

/**
* Sets the automaticTokenAssociations.
*
Expand Down Expand Up @@ -631,6 +656,16 @@ public SingleTransactionRecordBuilderImpl ethereumHash(@NonNull final Bytes ethe
return this;
}

/**
* Gets the paidStakingRewards.
*
* @return paidStakingRewards
*/
@NonNull
public final List<AccountAmount> paidStakingRewards() {
return this.paidStakingRewards;
}

/**
* Sets the paidStakingRewards.
*
Expand Down

0 comments on commit cc51672

Please sign in to comment.