Skip to content
This repository was archived by the owner on Aug 23, 2020. It is now read-only.

Check validity rules on tip-sel and check-consistency only #1802

Merged
merged 5 commits into from
Mar 19, 2020

Conversation

GalRogozinski
Copy link
Contributor

Description

We want the rules added in #1786 to only be used when we are doing tip-selection and check consistency calls. This is so that IRI won't give an error when calculating the ledger state on old milestones that didn't adhere to the rule.

We have a boolean flag in the validate method that takes care of the 2 modes, that forces the extra checks.

Fixes #1746

Type of change

  • Enhancement (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

Unit test have been added

  • One unit test fails validation when the extra checks flag is set to true, on a bundle that will otherwise be valid.
  • When the flag is set to false we verify that the extra checks are not being called

Checklist:

  • My code follows the style guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Contributor

@acha-bill acha-bill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
Just I'm not so clear about when you decide to enforce the extra rules and when you don't.

Travis is not so happy btw.

@@ -133,7 +133,7 @@ public boolean isBalanceDiffConsistent(Set<Hash> approvedHashes, Map<Hash, Long>
}
Set<Hash> visitedHashes = new HashSet<>(approvedHashes);
Map<Hash, Long> currentState = generateBalanceDiff(visitedHashes, tip,
snapshotProvider.getLatestSnapshot().getIndex());
snapshotProvider.getLatestSnapshot().getIndex(), true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forcing extra rules here cannot break backward compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify that when we apply milestone we don't hit this code
Only in tip-selection we do

@GalRogozinski
Copy link
Contributor Author

@acha-bill
Taking a discussion from slack here about the behavior of GetBalances.

I think this doesn't hurt previously confirmed txs because the snapshot is being inspected directly here:

 for (final Hash address : addressList) {
                Long value = snapshotProvider.getLatestSnapshot().getBalance(address);
                if (value == null) {
                    value = 0L;
                }
                balances.put(address, value);
            }

Copy link
Contributor

@acha-bill acha-bill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

@GalRogozinski GalRogozinski merged commit a51ae09 into iotaledger:release-v1.8.5 Mar 19, 2020
@GalRogozinski GalRogozinski deleted the validity-rules branch March 19, 2020 09:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants