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

added bundle validity rules #1786

Merged
merged 3 commits into from
Mar 16, 2020

Conversation

acha-bill
Copy link
Contributor

Description

Adds 2 new rules for bundle validity. A bundle is valid if:

  • It only approves tail transactions
  • All transactions within the bundle approve via their branch the trunk transaction of the head transaction.

Fixes #1746

Type of change

  • Enhancement (a non-breaking change which adds functionality)

How Has This Been Tested?

  • Existing unit tests pass that cover newly added rules
  • Added new tests for the specific rules

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

public static Validity validateBundleTransactionsApproval(List<TransactionViewModel> bundleTxs){
Hash headTrunkTransactionHash = bundleTxs.get(bundleTxs.size() - 1).getTrunkTransactionHash();
for(int i = 0; i < bundleTxs.size() - 1; i++){
if(!bundleTxs.get(i).getBranchTransactionHash().equals(headTrunkTransactionHash)){
Copy link
Contributor

Choose a reason for hiding this comment

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

usually I don't like all those concatenated gets becuase they mask nulls
but I think here no nulls would appear anyhows

@acha-bill acha-bill changed the base branch from dev to release-v1.8.5 March 13, 2020 15:09
Copy link
Contributor

@GalRogozinski GalRogozinski 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

src/test/java/com/iota/iri/BundleValidatorTest.java Outdated Show resolved Hide resolved
@acha-bill acha-bill requested a review from GalRogozinski March 16, 2020 09:52
@GalRogozinski GalRogozinski merged commit 450b728 into iotaledger:release-v1.8.5 Mar 16, 2020
GalRogozinski pushed a commit to GalRogozinski/iri that referenced this pull request Mar 17, 2020
* added bundle validity rules

* commented on test and added invalid bundle tests

* Fix: lower error severity for faulty neighbor to warning (iotaledger#1710)

Co-authored-by: Dyrell Chapman <dyrell.chapman@iota.org>
GalRogozinski pushed a commit to GalRogozinski/iri that referenced this pull request Mar 17, 2020
* added bundle validity rules

* commented on test and added invalid bundle tests

* Fix: lower error severity for faulty neighbor to warning (iotaledger#1710)

Co-authored-by: Dyrell Chapman <dyrell.chapman@iota.org>
@acha-bill
Copy link
Contributor Author

Manual tests:

rule 1: It only approves tail transactions

trunk = tail, branch = tail : true
branch = trunk = non tail: invalid bundle
trunk = non tail, branch = non tail: invalid bundle
trunk = tail, branch = non tail:  invalid bundle

rule 2: All transactions within the bundle approve via their branch the trunk transaction of the head transaction
Created a good bundle with 3 transactions, edited it and set it's tx[1].branch = some old tx.
Then validity for this new bundle.

Db and source here: https://github.com/acha-bill/iri_bundle_validity

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change bundle validity rules for enabling more robust node architecture
4 participants