This repository has been archived by the owner on Aug 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 370
Feature: Add solidification stage to pipeline and only broadcast solid transactions #1646
Open
DyrellC
wants to merge
79
commits into
iotaledger:dev
Choose a base branch
from
DyrellC:add-Broadcast-queue
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 48 commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
53ea166
Add ubiquitous Broadcast Queue
DyrellC be7c132
Update unit tests with broadcasting queue
DyrellC 6593388
Remove unneeded log
DyrellC 33f193f
Merge branch 'dev' into add-Broadcast-queue
ff58495
Fix broadcast queue injection
DyrellC 1a0ea43
remove unused function
DyrellC ad3a203
Merge branch 'add-Broadcast-queue' of https://github.com/DyrellC/iri …
DyrellC 2283fb0
Merge branch 'dev' of https://github.com/iotaledger/iri into add-Broa…
DyrellC 24e31a5
Clean up imports
DyrellC 03590dd
Remove BroadcastQueue, add TransactionSolidifier class
DyrellC 06242eb
Add docs
DyrellC 1ec3794
Add to solidification queue if update status fails
DyrellC bc5897f
Fix network injection test
DyrellC 62a2330
Remove unused import, lower checkSolidity complexity
DyrellC 9fc4cba
Reduce complexity further
DyrellC ccca691
Comments
DyrellC f0c1955
Change queue type, log error messages differentely
DyrellC fa72acc
Condense code slightly
DyrellC c3b1417
Synchronize solidifier queue access, add received transactions to sol…
DyrellC 1538b36
Move solidification queue entry point, reduce interval for scans
DyrellC a34c5e8
Broadcast from reply stage to increase transactions to request speed
DyrellC 14e784d
Merge branch 'dev' into add-Broadcast-queue
89ec550
Clean up PR, add interface
DyrellC 8801ef2
Add unit tests
DyrellC 26b9521
Wrap in try/catch, fix styling
DyrellC 16170cf
Merge branch 'add-Broadcast-queue' of https://github.com/DyrellC/iri …
DyrellC 7e34c91
Update src/main/java/com/iota/iri/network/pipeline/TransactionProcess…
DyrellC 778c833
Remove solidification from broadcast queue next stage
DyrellC 0b61c89
Add quick solid transactions to broadcast queue, comments and tests u…
DyrellC 1a2d950
Merge branch 'add-Broadcast-queue' of https://github.com/DyrellC/iri …
DyrellC 864c2db
codacy conflict
DyrellC 4bfb138
Add messages to solidifier test
DyrellC d623d1d
Pop eldest on queue fill
DyrellC 48258b1
Remove unused function
DyrellC 1cde4bf
Iterator -> poll()
DyrellC 6543981
Add transaction solidification stage
DyrellC 7b4d3c5
Comments/clean-up
DyrellC 5e0a974
update tests
DyrellC f86fe55
Remove unused payload Mock
DyrellC de08907
Remove log
DyrellC 4086fce
Remove circular solidified queue
DyrellC b16c752
Make addToBroadcastQueue private again
DyrellC f5de8fe
Ensure solidTip is solid before broadcasting
DyrellC 30f226e
Update tests, only broadcast solid transactions from solidify stage
DyrellC 303648b
Move validator test to appropriate package
DyrellC 7e36e1c
Downgrade log error to log info
DyrellC eb53b2f
Remove unnecessary solidity propogation thread in validator
DyrellC 0409d3e
only import used parts of junit
DyrellC 1b5294a
Add propagation queue back, remove addToSolidificationQueue from soli…
DyrellC ab6e628
Codacy corrections
DyrellC 839d9cb
Move update status from validation to solidification
DyrellC 031180b
Merge branch 'dev' of https://github.com/iotaledger/iri into add-Broa…
DyrellC f61e6ff
Codacy conflicts
DyrellC 6e0a383
reremove old transaction validator
DyrellC 4126903
Merge branch 'dev' into add-Broadcast-queue
ff4a13c
Fix codacy import error, break up runValidation
DyrellC 5bd3066
Merge branch 'add-Broadcast-queue' of https://github.com/DyrellC/iri …
DyrellC 10baada
Merge branch 'dev' into add-Broadcast-queue
DyrellC 4327b10
Merge branch 'dev' into add-Broadcast-queue
DyrellC 092cfa5
Merge branch 'dev' of https://github.com/iotaledger/iri into add-Broa…
DyrellC cc220b0
Merge branch 'add-Broadcast-queue' of https://github.com/DyrellC/iri …
DyrellC 82359a7
Update regression logging
DyrellC 7adfdc5
Merge branch 'dev' of https://github.com/iotaledger/iri into add-Broa…
DyrellC d3baeee
Remove double import from merge
DyrellC ffea048
Verbose logging for debugging
DyrellC 0f29416
Merge branch 'dev' of https://github.com/iotaledger/iri into add-Broa…
DyrellC 0084b48
Merge branch 'dev' of https://github.com/iotaledger/iri into add-Broa…
DyrellC 4664000
Revert "Fix: sort milestone candidates before analyzing for faster so…
DyrellC cc5e8b8
Broadcast latest tip even if not solid (will be latest milestone)
DyrellC d488a1d
Correct cpu load issues
DyrellC 9ad4886
Remove max to propagation cascade
DyrellC 9ab2a7d
Reintroduce limiter to adding duplicates for solidification
DyrellC 5663d30
Merge branch 'dev' of https://github.com/iotaledger/iri into dev
DyrellC b2cb269
Update DagHelper
DyrellC 31223b3
Update regression logging
DyrellC ea3bbf8
Move validation to validation service package
DyrellC e4feaf6
Merge branch 'update-regression-logging' into merge-transaction-solid…
DyrellC 059e7e4
Merge branch 'dev' of https://github.com/iotaledger/iri into add-Broa…
DyrellC 7528b22
Merge branch 'merge-transaction-solidifier' into add-Broadcast-queue
DyrellC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/com/iota/iri/network/pipeline/SolidifyPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.iota.iri.network.pipeline; | ||
|
||
import com.iota.iri.controllers.TransactionViewModel; | ||
import com.iota.iri.network.neighbor.Neighbor; | ||
|
||
/** | ||
* Defines a payload which gets submitted to the {@link SolidifyStage}. | ||
*/ | ||
public class SolidifyPayload extends Payload { | ||
private Neighbor originNeighbor; | ||
private TransactionViewModel tvm; | ||
|
||
/** | ||
* Constructor for solidification payload. | ||
* | ||
* @param originNeighbor The originating point of a received transaction | ||
* @param tvm The transaction that needs to be solidified | ||
*/ | ||
public SolidifyPayload(Neighbor originNeighbor, TransactionViewModel tvm){ | ||
this.originNeighbor = originNeighbor; | ||
this.tvm = tvm; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Neighbor getOriginNeighbor(){ | ||
return originNeighbor; | ||
} | ||
|
||
/** | ||
* Fetches the transaction from the payload. | ||
* @return The transaction stored in the payload. | ||
*/ | ||
public TransactionViewModel getTransaction(){ | ||
return tvm; | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
src/main/java/com/iota/iri/network/pipeline/SolidifyStage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package com.iota.iri.network.pipeline; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
import com.iota.iri.controllers.TipsViewModel; | ||
import com.iota.iri.controllers.TransactionViewModel; | ||
import com.iota.iri.model.Hash; | ||
import com.iota.iri.service.validation.TransactionSolidifier; | ||
import com.iota.iri.service.validation.TransactionValidator; | ||
import com.iota.iri.storage.Tangle; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static com.iota.iri.controllers.TransactionViewModel.fromHash; | ||
|
||
/** | ||
* The {@link SolidifyStage} is used to process newly received transaction for solidity. Once a transaction has been | ||
* passed from the {@link ReceivedStage} it will be placed into this stage to have the {@link TransactionSolidifier} | ||
* check the solidity of the transaction. If the transaction is found to be solid, it will be passed forward to the | ||
* {@link BroadcastStage}. If it is found to be unsolid, it is put through the solidity check so that missing reference | ||
* transactions get requested. If the transaction is unsolid, a random solid tip is broadcast instead to keep the | ||
* requests transmitting to neighbors. | ||
*/ | ||
public class SolidifyStage implements Stage { | ||
private static final Logger log = LoggerFactory.getLogger(SolidifyStage.class); | ||
|
||
private TransactionSolidifier txSolidifier; | ||
private TransactionValidator txValidator; | ||
private TipsViewModel tipsViewModel; | ||
private Tangle tangle; | ||
private TransactionViewModel tip; | ||
|
||
/** | ||
* Constructor for the {@link SolidifyStage}. | ||
* | ||
* @param txSolidifier Transaction solidifier implementation for updating transaction's solidity status | ||
* @param txValidator Transaction validator implementation for determining the validity of a transaction | ||
* @param tipsViewModel Used for broadcasting random solid tips if the subject transaction is unsolid | ||
* @param tangle A reference to the nodes DB | ||
*/ | ||
public SolidifyStage(TransactionSolidifier txSolidifier, TransactionValidator txValidator, | ||
TipsViewModel tipsViewModel, Tangle tangle){ | ||
this.txSolidifier = txSolidifier; | ||
this.txValidator = txValidator; | ||
this.tipsViewModel = tipsViewModel; | ||
this.tangle = tangle; | ||
} | ||
|
||
/** | ||
* Processes the payload of the {@link ProcessingContext} as a {@link SolidifyPayload}. First the transaction will | ||
* be checked for solidity and validity. If the transaction is already solid or can be set solid quickly by the | ||
* transaction validator, the transaction is passed to the {@link BroadcastStage}. If not, the transaction is | ||
* added to the solidification queue, and a random solid tip is pulled form the {@link TipsViewModel} to be | ||
* broadcast instead. | ||
* | ||
* @param ctx The context to process | ||
* @return The output context, in most cases a {@link BroadcastPayload}. | ||
*/ | ||
@Override | ||
public ProcessingContext process(ProcessingContext ctx){ | ||
try { | ||
SolidifyPayload payload = (SolidifyPayload) ctx.getPayload(); | ||
TransactionViewModel tvm = payload.getTransaction(); | ||
|
||
if (tvm.isSolid() || txValidator.quickSetSolid(tvm)) { | ||
ctx.setNextStage(TransactionProcessingPipeline.Stage.BROADCAST); | ||
ctx.setPayload(new BroadcastPayload(payload.getOriginNeighbor(), payload.getTransaction())); | ||
return ctx; | ||
} | ||
|
||
txSolidifier.addToSolidificationQueue(tvm.getHash()); | ||
|
||
return broadcastTip(ctx, payload); | ||
}catch (Exception e){ | ||
log.error("Failed to process transaction for solidification", e); | ||
ctx.setNextStage(TransactionProcessingPipeline.Stage.ABORT); | ||
return ctx; | ||
} | ||
|
||
} | ||
|
||
private ProcessingContext broadcastTip(ProcessingContext ctx, SolidifyPayload payload) throws Exception{ | ||
if(tip == null) { | ||
Hash tipHash = tipsViewModel.getRandomSolidTipHash(); | ||
|
||
if (tipHash == null) { | ||
ctx.setNextStage(TransactionProcessingPipeline.Stage.FINISH); | ||
return ctx; | ||
} | ||
|
||
tip = fromHash(tangle, tipHash); | ||
} | ||
|
||
if(tip.isSolid()) { | ||
ctx.setNextStage(TransactionProcessingPipeline.Stage.BROADCAST); | ||
ctx.setPayload(new BroadcastPayload(payload.getOriginNeighbor(), tip)); | ||
return ctx; | ||
} | ||
|
||
ctx.setNextStage(TransactionProcessingPipeline.Stage.FINISH); | ||
return ctx; | ||
} | ||
|
||
@VisibleForTesting | ||
void injectTip(TransactionViewModel tvm) throws Exception { | ||
tip = tvm; | ||
tip.updateSolid(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally missed...
Delete this line :-P
Explanation:
What you are basically doing here is reviving the old tip solidifier...
We decided that we don't need to actively request transactions that are not needed to solidify milestones.
This is because:
a. It is most likely that most txs will get quickly solid
b. If not due to receiving txs out of order then they should get solid by
propagateSolidTransactions
(this is optional and could be left out, maybe)c. Else they may either become solid by milestone or never become solid
Basically, we assume that a&b will be enough most of the time, and if not a milestone will fix the situation.
If a milestone never comes then it doesn't matter because they are not in a consensus state.
The problems with actively requesting transactions for solidifying are: