Giter Site home page Giter Site logo

scorex's Introduction

Scorex 2 - The modular blockchain framework Build Status Coverage Status

Scorex and Scorex 2

Scorex 2 is modular blockchain framework is Scala language which allows for free and limitless experimentation with a wide variety of designs.

It is a complete rewrite of Scorex framework, which can be found at https://github.com/input-output-hk/Scorex.

Motivation

If you have a new design for a blockchain system, there are few options available in regards with an implementation:

  • you can fork codebase of a Bitcoin or Ethereum client. However, such clients are optimized towards concrete protocol, thus implementing something different would be a cumbersome task.
  • there are some modular frameworks, such as Scorex, where you can change consensus layer, or transactional layer, or both. Still, these modules have concrete interfaces, so for many designs more low-level and abstract approach was needed.

We have read a lot of research papers to make Scorex 2 supporting their implementations. Its abstract core allows for implementing a broad range of systems, including ones with multiple types of blocks and non-linear history.

Features

  • Compact, functional code
  • Modular design with fine granularity
  • Scala language
  • Asynchronous networking layer on top of TCP
  • JSON API
  • Cryptographic primitives externalized into separate scrypto framework
  • Some examples provided, including one working in production

Documentation and Communication.

Please join maillist at https://groups.io/g/scorex-dev. There is tutorial in progress, available at https://github.com/ScorexFoundation/ScorexTutorial.

Examples

There are two examples of blockchain systems built with Scorex:

Development Plans

Final 1.0 release of Scorex 2 is not done but near. Currently we're polishing and auditing the codebase towards the release. Then we will consider further plans, possibly including:

  • Improved networking layer
  • Support for Scala 3
  • More examples, possibly including non-linear systems (such as DAGs)

Contributions

Contributions are welcome! Please take a look into issues. Testing codebase is still not perfect at the moment, so writing a test is not just good for start, but useful for the product as well.

New examples would be very helpful as well!

Release

To publish release version to Sonatype:

  • make a tag with version number vX.Y.Z (used by sbt-dynver to set version in build.sbt);
  • use the new tag to make a Github release, which triggers release.yml workflow and publishes release version to Sonatype;

scorex's People

Contributors

alanverbner avatar anatoly-shamov avatar aslesarenko avatar catena2w avatar ceilican avatar dkaidalov avatar ezequielpostan avatar greenhat avatar knizhnik avatar kushti avatar mayank0403 avatar mike-aksarin avatar oskin1 avatar piterden avatar pragmaxim avatar ryjones avatar scasplte2 avatar semyonoskin avatar tdroxler avatar terjokhin avatar tharindudg avatar tolsi avatar victormikheev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scorex's Issues

Make Access Control Allowed Origin tunable

Currently, all the settings.json files have a field called rpcAllowed, but it is not used anywhere. I would assume that this was designed to take in some origins for which CORS would be allowed.

At the same time, when you set cors to be true. Access-Control-Allow-Origin will be set to * in ApiRoute.scala.

Wouldn't it make more sense to control the Access-Control-Allow-Origin with the origins specified in rpcAllowed?

Hello World sample

It will really help a newcomer to get started if there is a "Hello World" level app with Scorex (something similar to slide 20 from https://www.slideshare.net/AlexChepurnoy/scorex-the-modular-blockchain-framework or https://github.com/input-output-hk/Scorex/wiki/Getting-started#running-scorex).

I tried to port https://github.com/input-output-hk/Scorex/wiki/Getting-started#running-scorex, but there are quite a few changes between the input-output-hk version and the ScorexFoundation version, so I got lost). I am looking at examples in https://github.com/ScorexFoundation/Scorex/tree/master/examples, but there is a lot going on there, so for someone that is just starting out, it can be a bit intimidating.

Warning and error messages in Twinscoin logs to fix

Found some strange behaviour between two running nodes.
It looks like for each sync request we get 2 answers from 1 node.
That is the reason for warnings like
[2-Hop-akka.actor.default-dispatcher-2] >> [WARN ] examples.hybrid.HybridNodeViewHolder >> 16:21:48.003 Received modifier 99aQPCZfUYc68nrvQtEH7PJ5RVv28abBWECaMce2bttL that is already in history

Full log

[2-Hop-akka.actor.default-dispatcher-10] >> [INFO ] s.core.network.PeerConnectionHandler >> 16:21:47.985 Send message MessageSpec(22: RequestModifier) to localhost/127.0.0.1:54378
[2-Hop-akka.actor.default-dispatcher-12] >> [INFO ] s.core.network.PeerConnectionHandler >> 16:21:47.986 Send message MessageSpec(22: RequestModifier) to localhost/127.0.0.1:9084
[2-Hop-akka.actor.default-dispatcher-4] >> [INFO ] s.core.network.PeerConnectionHandler >> 16:21:47.987 Received message MessageSpec(33: Modifier) from localhost/127.0.0.1:9084
[2-Hop-akka.actor.default-dispatcher-4] >> [INFO ] s.core.network.NodeViewSynchronizer >> 16:21:47.988 Got modifiers of type 3 with ids Pojoe34B1cxMSXR2GZNAURNv3csphAQ2DY6ddnHQ3zm
[2-Hop-akka.actor.default-dispatcher-4] >> [INFO ] s.core.network.NodeViewSynchronizer >> 16:21:47.988 From remote connected peer: ConnectedPeer(localhost/127.0.0.1:9084)
[2-Hop-akka.actor.default-dispatcher-12] >> [INFO ] s.core.network.PeerConnectionHandler >> 16:21:47.987 Received message MessageSpec(33: Modifier) from localhost/127.0.0.1:54378
[2-Hop-akka.actor.default-dispatcher-6] >> [INFO ] s.core.network.NodeViewSynchronizer >> 16:21:47.992 Got modifiers of type 3 with ids Pojoe34B1cxMSXR2GZNAURNv3csphAQ2DY6ddnHQ3zm
[2-Hop-akka.actor.default-dispatcher-6] >> [INFO ] s.core.network.NodeViewSynchronizer >> 16:21:47.992 From remote connected peer: ConnectedPeer(localhost/127.0.0.1:54378)
[2-Hop-akka.actor.default-dispatcher-13] >> [WARN ] examples.hybrid.HybridNodeViewHolder >> 16:21:47.992 Received modifier Pojoe34B1cxMSXR2GZNAURNv3csphAQ2DY6ddnHQ3zm that is already in history
[2-Hop-akka.actor.default-dispatcher-13] >> [INFO ] s.core.network.PeerConnectionHandler >> 16:21:47.996 Received message MessageSpec(55: Inv) from localhost/127.0.0.1:54378
[2-Hop-akka.actor.default-dispatcher-6] >> [INFO ] s.core.network.PeerConnectionHandler >> 16:21:47.996 Received message MessageSpec(55: Inv) from localhost/127.0.0.1:9084
[2-Hop-akka.actor.default-dispatcher-12] >> [INFO ] s.core.network.PeerConnectionHandler >> 16:21:47.996 Send message MessageSpec(22: RequestModifier) to localhost/127.0.0.1:54378
[2-Hop-akka.actor.default-dispatcher-2] >> [INFO ] s.core.network.PeerConnectionHandler >> 16:21:47.997 Send message MessageSpec(22: RequestModifier) to localhost/127.0.0.1:9084
[2-Hop-akka.actor.default-dispatcher-12] >> [INFO ] s.core.network.PeerConnectionHandler >> 16:21:47.999 Received message MessageSpec(33: Modifier) from localhost/127.0.0.1:54378
[2-Hop-akka.actor.default-dispatcher-8] >> [INFO ] s.core.network.PeerConnectionHandler >> 16:21:47.999 Received message MessageSpec(33: Modifier) from localhost/127.0.0.1:9084
[2-Hop-akka.actor.default-dispatcher-2] >> [INFO ] s.core.network.NodeViewSynchronizer >> 16:21:47.999 Got modifiers of type 4 with ids 99aQPCZfUYc68nrvQtEH7PJ5RVv28abBWECaMce2bttL
[2-Hop-akka.actor.default-dispatcher-2] >> [INFO ] s.core.network.NodeViewSynchronizer >> 16:21:47.999 From remote connected peer: ConnectedPeer(localhost/127.0.0.1:54378)
[2-Hop-akka.actor.default-dispatcher-2] >> [INFO ] s.core.network.NodeViewSynchronizer >> 16:21:48.000 Got modifiers of type 4 with ids 99aQPCZfUYc68nrvQtEH7PJ5RVv28abBWECaMce2bttL
[2-Hop-akka.actor.default-dispatcher-2] >> [INFO ] s.core.network.NodeViewSynchronizer >> 16:21:48.000 From remote connected peer: ConnectedPeer(localhost/127.0.0.1:9084)
[2-Hop-akka.actor.default-dispatcher-2] >> [WARN ] examples.hybrid.HybridNodeViewHolder >> 16:21:48.003 Received modifier 99aQPCZfUYc68nrvQtEH7PJ5RVv28abBWECaMce2bttL that is already in history

Opened connections

Looks like 2 nodes opens a lot of connections to each other, should be only 1.

versionID is already used during restart of a HybridApp node

Hello there,

I am encountering an issue of nodes not being able to restore its state after restart. I was able to replicate this issue by doing the following:

  1. Clear the /tmp/scorex/ directory
  2. Start a node with HybridApp and wait for generation of several blocks
  3. Ctrl+C in the terminal
  4. Restart the node
    and the error I am getting is following:
[ERROR] [03/16/2017 16:50:03.284] [2-Hop-akka.actor.default-dispatcher-4] [akka://2-Hop/user/$b] versionID is already used
akka.actor.ActorInitializationException: akka://2-Hop/user/$b: exception during creation
	at akka.actor.ActorInitializationException$.apply(Actor.scala:175)
	at akka.actor.ActorCell.create(ActorCell.scala:607)
	at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:461)
	at akka.actor.ActorCell.systemInvoke(ActorCell.scala:483)
	at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282)
	at akka.dispatch.Mailbox.run(Mailbox.scala:223)
	at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at akka.util.Reflect$.instantiate(Reflect.scala:65)
	at akka.actor.ArgsReflectConstructor.produce(IndirectActorProducer.scala:96)
	at akka.actor.Props.newActor(Props.scala:213)
	at akka.actor.ActorCell.newActor(ActorCell.scala:562)
	at akka.actor.ActorCell.create(ActorCell.scala:588)
	... 9 more
Caused by: java.lang.IllegalArgumentException: versionID is already used
	at io.iohk.iodb.LSMStore.update(LSMStore.scala:370)
	at examples.hybrid.history.HistoryStorage.update(HistoryStorage.scala:91)
	at examples.hybrid.history.HybridHistory.$anonfun$append$1(HybridHistory.scala:110)
	at scala.util.Try$.apply(Try.scala:209)
	at examples.hybrid.history.HybridHistory.append(HybridHistory.scala:99)
	at examples.hybrid.HybridNodeViewHolder.genesisState(HybridNodeViewHolder.scala:69)
	at scorex.core.NodeViewHolder.$anonfun$nodeView$1(NodeViewHolder.scala:55)
	at scala.Option.getOrElse(Option.scala:121)
	at scorex.core.NodeViewHolder.$init$(NodeViewHolder.scala:55)
	at examples.hybrid.HybridNodeViewHolder.<init>(HybridNodeViewHolder.scala:18)
	... 18 more
  1. Further requests to Swagger UI respond with There was an internal server error. and no blocks will be generated

Add rollback to History

At the moment History basic trait doesn't have a rollback functionality, but it is probably needed if block is failed to be applied to a current state. Reconsider interface & application logic.

NodeViewHolder modifiersCache

If some invalid modifiers appear in modifiersCache, they'll live there forever.

  • Clear old modifier by some condition
  • Limit modifiersCache size
  • Do not show all ids list in logs (which is huge if cache size ~40000)

Fix findbugs warnings

Findbugs tool (running via "sbt findbugs") is finding a couple of high-priority warnings and a lot of medium-priority warnings. We need to fix them (most of claims are definitely reasonable). Good task for an external contributor!

Connection to Peer in TwinsCoin Testnet Fails

I followed the instructions in the README for the examples, and then I keep getting the following message:

> [INFO ] s.core.network.NetworkController >> 18:27:53.805 Failed to connect to : /34.210.250.171:9084

And then:

$ ping 34.210.250.171
PING 34.210.250.171 (34.210.250.171): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5

Is there any active TwinsCode node besides 34.210.250.171?

Node view synchronizer refactoring

NodeViewSynchronizer is caching ids of modifiers (blocks/transactions etc) asked from network (so only objects requested are expected to be delivered):
private val asked = mutable.MapModifierTypeId, mutable.Set[ModifierId]

However, this structure is not storing a peer being asked.

Also, we need to have another structure which contains objects delivered, in order to extract a peer when, during processing, a node is realizing that object sent is e.g. invalid (so the peer is to be banned or de-prioritized)

private val delivered = mutable.MapModifierId, ConnectedPeer

HybridApp example error while finding commong block

Description

On HybridAppHistory, finding suffixes after a common block between branches it's not working.

Cause

@tailrec
  private def suffixesAfterCommonBlock(winnerChain: Seq[BlockId], loserChain: Seq[BlockId]): (Seq[BlockId], Seq[BlockId]) = {
    val c1h = winnerChain.head
    val c2h = loserChain.head

    if (loserChain.contains(c1h)) {
      (winnerChain, loserChain.dropWhile(id => !(id sameElements c2h)))
    } else if (winnerChain.contains(c2h)) {
      (winnerChain.dropWhile(id => !(id sameElements c2h)), loserChain)
    } else suffixesAfterCommonBlock(blockById(c1h).get.parentId +: winnerChain, blockById(c2h).get.parentId +: loserChain)
  }

On the first if branch (when loserChain.contains(c1h) == true) it should be comparing by c1h while dropping. If not, the condition is matched at the first dropWhile iteration (because c2h is the head of loserChain sequence)

How to fix

Change the first dropWhile condition. The function may look like:

@tailrec
  private def suffixesAfterCommonBlock(winnerChain: Seq[BlockId], loserChain: Seq[BlockId]): (Seq[BlockId], Seq[BlockId]) = {
    val c1h = winnerChain.head
    val c2h = loserChain.head

    if (loserChain.contains(c1h)) {
      (winnerChain, loserChain.dropWhile(id => !(id sameElements c1h)))
    } else if (winnerChain.contains(c2h)) {
      (winnerChain.dropWhile(id => !(id sameElements c2h)), loserChain)
    } else suffixesAfterCommonBlock(blockById(c1h).get.parentId +: winnerChain, blockById(c2h).get.parentId +: loserChain)
  }

Json serializers

Extract Json serializers and remove json field from JsonSerializable

Generic Boxes

Currently, boxes are parameterized only by proposition, with a value type of Long. It seems that a lot of the code is intertwined with this assumption, but there's no particular reason why box values should be limited to Long.

One example is using String as the value type for a box in order to define access restrictions to a blockchain resource.

Curvepos example throws an ActorInitializationException

I'm trying to run the Curvepos example with

sbt runMain examples.curvepos.SimpleApp

but I keep getting the exception thrown some time after the application starts. Here's the stack trace for it:

[info] Running (fork) examples.curvepos.SimpleApp [info] [main] >> [WARN ] scorex.core.settings.ScorexSettings$ >> 00:49:28.880 NO CONFIGURATION FILE WAS PROVIDED. STARTING WITH DEFAULT SETTINGS FOR TESTNET! [info] [scorex-akka.actor.default-dispatcher-2] >> [INFO ] scorex.core.network.UPnP >> 00:49:29.589 Looking for UPnP gateway device... [info] [ERROR] [11/17/2017 00:49:30.023] [scorex-akka.actor.default-dispatcher-3] [akka://scorex/user/$e] assertion failed [info] akka.actor.ActorInitializationException: akka://scorex/user/$e: exception during creation [info] at akka.actor.ActorInitializationException$.apply(Actor.scala:180) [info] at akka.actor.ActorCell.create(ActorCell.scala:607) [info] at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:461) [info] at akka.actor.ActorCell.systemInvoke(ActorCell.scala:483) [info] at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282) [info] at akka.dispatch.Mailbox.run(Mailbox.scala:223) [info] at akka.dispatch.Mailbox.exec(Mailbox.scala:234) [info] at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [info] at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [info] at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) [info] at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) [info] Caused by: java.lang.AssertionError: assertion failed [info] at scala.Predef$.assert(Predef.scala:204) [info] at scala.Predef$Ensuring$.ensuring$extension2(Predef.scala:316) [info] at examples.curvepos.transaction.SimpleState.$anonfun$validate$3(SimpleState.scala:115) [info] at scala.collection.immutable.List.foreach(List.scala:389) [info] at examples.curvepos.transaction.SimpleState.$anonfun$validate$2(SimpleState.scala:115) [info] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12) [info] at scala.util.Try$.apply(Try.scala:209) [info] at examples.curvepos.transaction.SimpleState.validate(SimpleState.scala:115) [info] at examples.curvepos.transaction.SimpleState.validate(SimpleState.scala:19) [info] at scorex.mid.state.BoxMinimalState.applyModifier(BoxMinimalState.scala:29) [info] at scorex.mid.state.BoxMinimalState.applyModifier$(BoxMinimalState.scala:28) [info] at examples.curvepos.transaction.SimpleState.applyModifier(SimpleState.scala:19) [info] at examples.curvepos.SimpleNodeViewHolder.genesisState(SimpleNodeViewHolder.scala:55) [info] at scorex.core.NodeViewHolder.$anonfun$nodeView$1(NodeViewHolder.scala:52) [info] at scala.Option.getOrElse(Option.scala:121) [info] at scorex.core.NodeViewHolder.$init$(NodeViewHolder.scala:52) [info] at examples.curvepos.SimpleNodeViewHolder.<init>(SimpleNodeViewHolder.scala:15) [info] at examples.curvepos.SimpleApp.$anonfun$nodeViewHolderRef$1(SimpleApp.scala:32) [info] at akka.actor.TypedCreatorFunctionConsumer.produce(IndirectActorProducer.scala:87) [info] at akka.actor.Props.newActor(Props.scala:213) [info] at akka.actor.ActorCell.newActor(ActorCell.scala:562) [info] at akka.actor.ActorCell.create(ActorCell.scala:588) [info] ... 9 more

After the exception is thrown, the app continues to run, but the only thing it does is repeatedly write this message to the console:

[info] [INFO] [11/17/2017 00:49:30.029] [scorex-akka.actor.default-dispatcher-8] [akka://scorex/user/$e] Message [scorex.core.NodeViewHolder$Subscribe] from Actor[akka://scorex/user/$c#-1848096250] to Actor[akka://scorex/user/$e#-362370127] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.

Integrate Scoverage to measure test coverage

I have added the Scoverage plugin to Scorex in #76. It can be used manually within the SBT shell for now. But a better integration could still be done:

  • Make Scoverage work within the Examples module.
  • Add Scoverage to Scorex's CI pipeline, so that a coverage report is generated automatically.
  • Add a coverage percentage badge on Scorex's README.md .

Warning in PeerDatabaseImpl

[warn] Scorex/src/main/scala/scorex/core/network/peer/PeerDatabaseImpl.scala:39:70: AnyVal and Option[Long] are unrelated: they will most likely always compare unequal
[warn]       case true => knownPeers(false).filter(_._2.nonce.getOrElse(-1) != ownNonce)
[warn]                                                                      ^
[warn] there was one unchecked warning; re-run with -unchecked for details
[warn] three warnings found

Make a test suite for properties tests

Fow now only following tests are to be launched by "sbt test"

[info] SigningFunctionsSpecification:
[info] - PrivateKey25519Companion generates valid keypair (379 milliseconds)
[info] - PrivateKey25519Companion serialization (187 milliseconds)
[info] HandshakeSpecification:
[info] - handshake should remain the same after serialization/deserialization (147 milliseconds)

Intermittent NullPointerException

Travis CI initially failed in PR 110, because a NullPointerException was thrown during the execution of the test "NodeViewHolder: forking - switching" in NodeViewHolderTests.

[info] - NodeViewHolder: forking - switching *** FAILED ***
[info]   java.lang.NullPointerException:
[info]   at scorex.testkit.properties.NodeViewHolderTests.$anonfun$$init$$39(NodeViewHolderTests.scala:239)
[info]   at scorex.testkit.properties.NodeViewHolderTests.$anonfun$$init$$39$adapted(NodeViewHolderTests.scala:211)
[info]   at scorex.testkit.properties.NodeViewHolderTests.withFixture(NodeViewHolderTests.scala:47)
[info]   at scorex.testkit.properties.NodeViewHolderTests.$anonfun$$init$$38(NodeViewHolderTests.scala:211)
[info]   at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[info]   at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
[info]   at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
[info]   at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info]   at org.scalatest.Transformer.apply(Transformer.scala:22)
[info]   at org.scalatest.Transformer.apply(Transformer.scala:20)
[info]   ...

However, when I asked Travis to re-run this build, the test passed. So, whatever is causing this problem doesn't happen all the time.

Connection authentication using Noise

Noise Protocol Framework https://noiseprotocol.org/

"Noise is a framework for building crypto protocols. Noise protocols support mutual and optional authentication, identity hiding, forward secrecy, zero round-trip encryption, and other advanced features. "

Let's use Noise for optional auth. handshake.

Fix "last seen date" for connected peers api route.

Currently api route /peers/connected returns list of objects with lastSeen field. This field is being filled with now() timestamp instead of correct last seen date. However class Handshake has its own time field. Maybe we should consider use this field instead of now()?

Forks comparison

Currently, a node in the TwinsCoin example is getting Nonsense status initially (other peer if getting Younger status). Naturally, a peer should obtain correct status (Older). We also should ban for Nonsense status probably.

Double notification from NVHT

In case if semantically valid modifier is being applied to NVH we gonna get 2 notification about semantic validity of this modifier.

ApiClient Json parsing error

Description

After downloading and running one of the example projects when trying to query REST api using the provided ApiClient we are receiving an error while parsing Json response.

Error Output

[info] Welcome to the Scorex command-line client...
GET utils/seed
[info] [GET utils/seed RESULT] Problem occurred java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input: expected close marker for OBJECT (from [Source: {; line: 1, column: 0])
[info]  at [Source: {; line: 1, column: 3]! 

How to reproduce

  1. Startup any of the examplel projects included in this repo, for example, SimpleApp.scala
  2. Run ApiClient
  3. Execute the command GET utils/seed

Cause

It seems that scorex.core.api.http.ApiRoute#jsonRoute calls Json.toString which uses by default spaces2 formatting and returns a multi line string but ApiClient is expecting a single one

scala> foo.asJson.noSpaces
res0: String = {"Qux":{"i":13,"d":14.0}}

scala> foo.asJson.spaces2
res1: String =
{
  "Qux" : {
    "i" : 13,
    "d" : 14.0
  }
}

scala> foo.asJson.toString
res3: String =
{
  "Qux" : {
    "i" : 13,
    "d" : 14.0
  }
}

How to Fix

There are two options:

  1. Change ApiRoute in order to return Json encoded with noSpaces (this might be the best alternative because formatting is not needed before sending to the wire)
  2. Change ApiClient to receive multiline Strings, val result = Source.fromInputStream(stream) mkString ""

We can create a PR if you want to.

Remove non-public peer from database

For now, we're adding peer to the peer database if its public (declared address is the same as the socket address). It is also needed to remove peer from database the peer is not public.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.