Skip to content

Fallback to eigentrust for SAW. Re-enable SAW & local test#1600

Open
ryle-goehausen wants to merge 2 commits intodevfrom
rg-rep-stack-error
Open

Fallback to eigentrust for SAW. Re-enable SAW & local test#1600
ryle-goehausen wants to merge 2 commits intodevfrom
rg-rep-stack-error

Conversation

@ryle-goehausen
Copy link
Contributor

@ryle-goehausen ryle-goehausen commented Sep 28, 2021

Tested this on cluster.

selfScores.foreach{case (k, v) => selfM(k) = v}
val addressToId = selfScores.keys.map{k => k.address -> k }.toMap
if (this.eigenTrust != null) {
val addressMap = this.eigenTrust.getTrustForAddresses.unsafeRunSync()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please avoid unsafeRunSync. An effectful code should be wrapped into a monad that will delay the execution of side effects. Running unsafeRunSync manually is both unsafe and performance degrading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, this code is hopefully only temporary until larger fix implemented -- and should be fast since it's only accessing a map, but I rewrote it as monadic anyways.

idMappedScores: Map[Id, Double] = sawAttempt match {
case Success(x) => x
case Failure(e) =>
logger.error(s"SAW Failure: $e")
Copy link
Contributor

Choose a reason for hiding this comment

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

this logger will not work because it's wrapped in a monad

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 59 to 61
sawAttempt = Try {
SelfAvoidingWalk
.runWalkFeedbackUpdateSingleNode(
Copy link
Contributor

Choose a reason for hiding this comment

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

sawAttempt <- F.delay { SelfAvoidingWalk.run... }.attempt // Either[Throwable, Map[Id, Double]
idMappedScores <- sawAttempt match {
 case Right(x) => F.pure(x)
 case Left(e) => logger.error(s"SAW Failure: $e") >>
   ...
   this.eigenTrust.getTrustForAddresses.flatMap { addressMap =>
     ...
   }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@ryle-goehausen
Copy link
Contributor Author

@marcinwadon re-ran scalafmt as well. Should I rebase? It seems like squash commits are required by default, I am happy to just use the commit message from original on a squash commit to avoid having to rebase every time.

@marcinwadon
Copy link
Contributor

@marcinwadon re-ran scalafmt as well. Should I rebase? It seems like squash commits are required by default, I am happy to just use the commit message from original on a squash commit to avoid having to rebase every time.

Yeah, linear history is required. You can either squash and keep the original message, or once updating the pull request, just ammend changes instead of creating a new commit.

@ryle-goehausen
Copy link
Contributor Author

@marcinwadon ready for review again, just to clarify I usually use the 'Squash and Merge' option in PR page (this webpage) -- that is sufficient right? I think it's required anyways. I'll squash with original commit message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants