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

Solidify transactions we walk across while doing GTTA #1826

Merged

Conversation

GalRogozinski
Copy link
Contributor

@GalRogozinski GalRogozinski commented Apr 5, 2020

Description

While doing GTTA we will attempt to solidify transactions we walk across.
This will make sure that transactions that we missed out on for whatever reason will solidify

Fixes #1818

Type of change

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

How Has This Been Tested?

I ran both 1.8.5 and a canary with this change.
I called GTTA in a loop on both with JMETER

GTTA with this change was still faster compared to 1.8.5.
Throughput: 176.662 ops/minute compared to 71.603 ops/minute

However, profiling showed that solidifying takes 30 % of cpu time...

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

ThreadFactory threadFactory = new ThreadFactoryBuilder()
.setNameFormat(this.getClass().getSimpleName() + " %d")
.build();
solidExecutor = Executors.newCachedThreadPool(threadFactory);
Copy link
Contributor Author

@GalRogozinski GalRogozinski Apr 6, 2020

Choose a reason for hiding this comment

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

Perhaps it needs to be changed to another executor?
Currently we have a limit on the amount of GTTA calls we can make, so this also limits how much solidification we can do

Copy link
Contributor

@kwek20 kwek20 left a comment

Choose a reason for hiding this comment

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

What made you chose this dummy solidifier instead of a null check? Probably same speed after optimizing, but just wondering. I would generally not chose the empty class approach.

Theres no issue linked, but besides that it looks good. CPU load increase makes sense due to more tx requested, but i didn´t check locally. Was the network traffic increasing as well?

About the other executor, lets leave it as is until we notice a problem. We shouldn´t solve problems that don´t exist yet.

Maybe we should consider setting the checkSolidity second parameter to something more sensible instead of defaulting to maximum integer, like 10.000 (called in AsyncTipSelSolidifier.java:43)

You may consider this an approval code wise, but as theres some questions im marking it as comment

Copy link
Contributor

@DyrellC DyrellC left a comment

Choose a reason for hiding this comment

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

Overall looks like a good stand in. The solidifier will be easily replaced post 1.9.0, and the implementation of said solidifier will be very simple with this setup (basically just replacing a couple lines). Just a couple comments regarding the checkSolidity call as well as the potential memory leak on an unchecked set size.

public void solidify(Hash transactionHash) {
// Don't try to solidify transactions that are in the process of being solidified
//Problem: we are not checking transactions in the past cone here
if (transactionToSolidify.add(transactionHash)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

As you pointed out this has the potential to get DOS attacked if there is enough power behind the spammers being thrown at the node. Does it make sense maybe to have a limit to the maximum number of objects within the set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I tested this I counted the number of AsyncSolidifier threads created when I bombed the node with Jmeter spam

I think there are more chances of bombing the CPU out before getting an oom from this

solidExecutor.submit(() -> {
try {
log.debug("attempting to solidify transaction {}", transactionHash);
transactionValidator.checkSolidity(transactionHash);
Copy link
Contributor

Choose a reason for hiding this comment

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

As Brord pointed out, we probably shouldn't allow this to run up to MAX_INTEGER and limit it to something like 10k analysed transactions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will use the same solidification limit as the milestone solidifier
If it is too much here, it is too much for milestones

import com.iota.iri.service.tipselection.TipSelector;
import com.iota.iri.service.tipselection.WalkValidator;
import com.iota.iri.service.tipselection.Walker;
import com.iota.iri.service.tipselection.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really a review on this PR specifically, but can we do something about Codacy freaking out about these kinds of imports?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I know...
I need to find time to take care of this, so much to do...

@GalRogozinski
Copy link
Contributor Author

GalRogozinski commented Apr 7, 2020

@kwek20

What made you chose this dummy solidifier instead of a null check? Probably same speed after optimizing, but just wondering. I would generally not chose the empty class approach.

I am just wired to use polymorphism instead of if-else. In some cases it makes way shorter readable code. In this case, it matters less and maybe the null check is better. The "advantage" here is that now you are ready to inject other imps in other places the WalkValidator is called from. But we probably won't use it. Anyhow, this change will be changed by Dyrell and he can choose another approach

Theres no issue linked

Fixed :-)

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.

LGTM

@GalRogozinski GalRogozinski merged commit f975033 into iotaledger:release-v1.9.0 Apr 7, 2020
@GalRogozinski GalRogozinski deleted the solidify-gtta branch April 7, 2020 10:24
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.

4 participants