wavesplatform / matcher

Matcher for Waves Node.
MIT License
18 stars 32 forks source link

Could not run dex extension #27

Closed duongvansang closed 5 years ago

duongvansang commented 5 years ago

When I try to run dex on my laptop to connect to testnet, got this issue: Unrecognized option: --add-modules=java.xml.bind Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.

When I remove --add-modules=java.xml.bind option, it runs but only REST API on port REST API was bound on 0.0.0.0:6869 is open.

How to check and make dex extension works?

My command: java -cp "/{absolute_path}/dex-testnet-1.0.1-5-ge721ad9/lib/*" -jar /{absolute_path}/waves/node/target/waves-all-1.0.2.jar

Note: I follow command from this issue https://github.com/wavesplatform/dex/issues/23

vsuharnikov commented 5 years ago

Hello!

--add-modules=java.xml.bind is an option to run the NODE with DEX on JRE/JDK 9+. If you have JRE/JDK of version 8, you doesn't need this option.

Another solution is to add an additional flag: -XX:+IgnoreUnrecognizedVMOptions. So, if you have both flags: --add-modules=java.xml.bind -XX:+IgnoreUnrecognizedVMOptions, your NODE with DEX will run on JRE/JDK 8+ (including 9).

To run DEX, you need:

  1. Installed NODE
  2. Copied DEX artifacts to the NODE JARs' path
  3. Added a line in the config:
waves.extensions = [ "com.wavesplatform.dex.Matcher" ]

That's all :)

Also we have a some kind of documentation (we are keep improving :D ), see 6 and 7.

Feel free to ask questions here, I'm leaving the ticket open until you've done.

duongvansang commented 5 years ago

Hello!

--add-modules=java.xml.bind is an option to run the NODE with DEX on JRE/JDK 9+. If you have JRE/JDK of version 8, you doesn't need this option.

Another solution is to add an additional flag: -XX:+IgnoreUnrecognizedVMOptions. So, if you have both flags: --add-modules=java.xml.bind -XX:+IgnoreUnrecognizedVMOptions, your NODE with DEX will run on JRE/JDK 8+ (including 9).

To run DEX, you need:

  1. Installed NODE
  2. Copied DEX artifacts to the NODE JARs' path
  3. Added a line in the config:
waves.extensions = [ "com.wavesplatform.dex.Matcher" ]

That's all :)

Also we have a some kind of documentation (we are keep improving :D ), see 6 and 7.

Feel free to ask questions here, I'm leaving the ticket open until you've done.

Thank you very much when I add config to wall node

I got this issue:

java -cp "~/wave-dex/target/release/dex-testnet-1.0.1-5-ge721ad9/lib/*" -jar target/waves-all-1.0.2.jar ./waves-devnet.conf 2019-08-06 19:19:43,391 INFO [main] k.metrics.SystemMetrics - Starting the Kamon(SystemMetrics) module Aug 06, 2019 7:19:43 PM kamon.sigar.SigarProvisioner provision INFO: Sigar library provisioned: ~/.sbt/1.0/staging/b02d83a062fa303d833d/waves/node/native/libsigar-universal64-macosx.dylib 2019-08-06 19:19:43,531 INFO [main] c.w.Application$ - Starting... 2019-08-06 19:19:43,958 INFO [ctor.default-dispatcher-3] a.event.slf4j.Slf4jLogger - Slf4jLogger started 2019-08-06 19:19:44,057 INFO [main] c.w.Application$ - Waves v1.0.2 Blockchain Id: D 2019-08-06 19:19:44,803 INFO [main] c.w.n.PeerDatabaseImpl - Loaded 3 known peer(s) from peers.dat 2019-08-06 19:19:45,913 INFO [main] com.wavesplatform.package$ - Genesis block Block(5ASUNefZs2dLRroid7LPS24PL85K5Y6WZqA1bfQGCHxkfhLK39jHDUpmFzELKQ66AHCm7ZhQVwpF6G95tat3xfpr -> 67rpwLC..., txs=6, features=Set()) has been added to the state 2019-08-06 19:19:45,922 INFO [main] c.w.w.Wallet$WalletImpl - Added account #1 2019-08-06 19:19:46,275 ERROR [main] c.w.actor.RootActorSystem$ - Error while initializing actor system wavesplatform java.lang.ClassNotFoundException: com.wavesplatform.dex.Matcher at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at com.wavesplatform.Application.$anonfun$run$11(Application.scala:220) at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:237) at scala.collection.Iterator.foreach(Iterator.scala:941) at scala.collection.Iterator.foreach$(Iterator.scala:941) at scala.collection.AbstractIterator.foreach(Iterator.scala:1429) at scala.collection.IterableLike.foreach(IterableLike.scala:74) at scala.collection.IterableLike.foreach$(IterableLike.scala:73) at scala.collection.AbstractIterable.foreach(Iterable.scala:56) at scala.collection.TraversableLike.map(TraversableLike.scala:237) at scala.collection.TraversableLike.map$(TraversableLike.scala:230) at scala.collection.AbstractTraversable.map(Traversable.scala:108)

My configure for devnet:

# Waves node settins
waves {
  max-cache-size = 10

  # Blockchain settings
  blockchain {
    type = CUSTOM
    custom {
      address-scheme-character = "D"
      functionality {
        feature-check-blocks-period = 5
        blocks-for-feature-activation = 4
        allow-temporary-negative-until = 1477958400000
        allow-invalid-payment-transactions-by-timestamp = 1477958400000
        require-sorted-transactions-after = 1477958400000
        generation-balance-depth-from-50-to-1000-after-height = 0
        minimal-generating-balance-after = 0
        allow-transactions-from-future-until = 0
        allow-unissued-assets-until = 1479416400000
        require-payment-unique-id-after = 0
        allow-invalid-reissue-in-same-block-until-timestamp = 0
        allow-multiple-lease-cancel-transaction-until-timestamp = 1492128000000
        reset-effective-balances-at-height = 4650
        block-version-3-after-height = 0
        pre-activated-features {
          1  = 0
          2  = 0
          3  = 0
          4  = 0
          5  = 0
          6  = 0
          7  = 0
          8  = 0
          9  = 0
          10 = 0
        }
        double-features-periods-after-height = 1000000000
        max-transaction-time-back-offset = 120m
        max-transaction-time-forward-offset = 90m
      }
      genesis {
        average-block-delay = 60000ms
        initial-base-target = 100
        timestamp = 1489352400000
        block-timestamp = 1489352400000
        signature = "5ASUNefZs2dLRroid7LPS24PL85K5Y6WZqA1bfQGCHxkfhLK39jHDUpmFzELKQ66AHCm7ZhQVwpF6G95tat3xfpr"
        initial-balance = 7700000000000000
        transactions = [
          {recipient = "3FR3MyuXumwBj1bLC8xnW38iHtwm9Ugdm8K", amount = 2500000000000000},
          {recipient = "3FgScYB6MNdnN8m4xXddQe1Bjkwmd3U7YtM", amount = 200000000000000},
          {recipient = "3FWXhvWq2r8m54MmCEZ3YZkLg2qUdGWbU3V", amount = 1000000000000000},
          {recipient = "3FkBWsgT9T3snZ4ZpzzQCJWQngJBLdDEPfU", amount = 500000000000000},
          {recipient = "3FeeqPbaEUQ8h3eQ4ZX9WcqzqskGbfTqM2a", amount = 1500000000000000},
          {recipient = "3FcSgww3tKZ7feQVmcnPFmRxsjqBodYz63x", amount = 2000000000000000}
        ]
      }
    }
  }

  # P2P Network settings
  network {
    # Network address
    bind-address = "0.0.0.0"

    # Port number
    port = 6864

    known-peers = ["34.251.200.245:6864", "35.157.212.173:6864", "13.229.61.140:6864"]

    # Node name to send during handshake. Comment this string out to set random node name.
    node-name = "My DEVNET node"

    # String with IP address and port to send as external address during handshake. Could be set automatically if uPnP is enabled.
    declared-address = "127.0.0.1:6864"

  }

  # Wallet settings
  wallet {

    file = null

    # Wallet seed as BASE58 string
     seed = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  }

  # Node's REST API settings
  rest-api {
    # Enable/disable node's REST API
    enable = yes

    # Network address to bind to
    bind-address = "0.0.0.0"

    # Port to listen to REST API requests
    port = 6869

    # Hash of API key string
    api-key-hash = "7B74gZMpdzQSB45A7KRwKW6mDUYaWhFY8kWh5qiLRRoA"

    api-key-different-host = yes
  }

  # Nodes synchronization settings
  synchronization {

    # Timeout to receive all requested blocks
    synchronization-timeout = 120s
  }
  miner {
    interval-after-last-block-then-generation-is-allowed = 15d
  }
}

# See application.conf for more information
kamon {
  enable = yes
  metric.tick-interval = 5s
  util.filters {
    "akka.tracked-dispatcher" {
      includes = [
        "wavesplatform/**"
      ]
    }
    "tx-processing" {
      includes = [
        "tx.**"
      ]
    }
  }
}

waves.extensions = [
  "com.wavesplatform.dex.Matcher"
]

waves.dex {
  account = "3Q5GKPLkxXcEwGv6d57v8aksTjh1igHNNDd" # This account must be known at the Node, e.g. created through POST /addresses
  bind-address = "0.0.0.0" # uncomment this line to accept connections from any host
}

include "local.conf"
duongvansang commented 5 years ago

I could able to run it now, but if I use devnet-conf I got issue java.lang.Exception: MissingSenderPrivateKey at com.wavesplatform.common.utils.package$EitherExt2.explicitGet(package.scala:8) at com.wavesplatform.dex.Matcher.(Matcher.scala:49) ... 22 common frames omitted

If I use testnet, it's run fine. I got something issue with wallet config, do you have any suggest for local dev node?

vsuharnikov commented 5 years ago

Yeah, just from the config:

waves.dex {
  account = "3Q5GKPLkxXcEwGv6d57v8aksTjh1igHNNDd" # This account must be known at the Node, e.g. created through POST /addresses

:) This account must be in the wallet. If you changed the network, the address should be changed too, because it depends on network. I recommend to:

  1. Delete wallet.dat
  2. Run the NODE without DEX (comment the extension in config)
  3. Generate a new address from the REST API
  4. Copy and paste this address to the config's waves.dex.account
duongvansang commented 5 years ago

Yeah, just from the config:

waves.dex {
  account = "3Q5GKPLkxXcEwGv6d57v8aksTjh1igHNNDd" # This account must be known at the Node, e.g. created through POST /addresses

:) This account must be in the wallet. If you changed the network, the address should be changed too, because it depends on network. I recommend to:

  1. Delete wallet.dat
  2. Run the NODE without DEX (comment the extension in config)
  3. Generate a new address from the REST API
  4. Copy and paste this address to the config's waves.dex.account

Yes, I could run testnet with ablow step, but for private net, I am still facing with issue

  1. If I let genesis block in configuration, It will reset block every time I run it, so I could not able to run Node firstly and then create address, because when I create addresses, and then stop to edit config and then start again, all addresses is gone, and I get back to start point.

  2. If I remove genesis block in configuration file, I could not able to start as custom private net.

Do you have any suggestion to overcome it? Many thanks,

vsuharnikov commented 5 years ago

The genesis configuration should be done once for a private network. After this change, you need to delete the waves directory, where the state and blocks are stored - see thewaves.directory in the config (or your /home_directory/waves if it isn't specified). So, full steps are:

  1. Specify in the config: 1.1. The genesis configuration (once for your private network) 1.2. The seed in wallet section
  2. Delete waves.directory from your filesystem
  3. Start the Node without DEX
  4. Generate an address for DEX
  5. Stop the Node
  6. Enable DEX on configuration
  7. Start the Node

If you need to switch between networks from time to time, you should create a separate configuration file (with a different waves.directory) and do these steps again with a new genesis configuration. After this you will be able to run the node with different configurations and thus networks.

In next versions the Cli for generating address will be available, so steps will be simpler :)

duongvansang commented 5 years ago

Here is step I did:

  1. Start private chain with genesis config 2019-08-08 09:44:08,173 INFO [main] c.w.n.PeerDatabaseImpl - Loaded 4 known peer(s) from peers.dat 2019-08-08 09:44:09,329 INFO [main] com.wavesplatform.package$ - Genesis block Block(5ASUNefZs2dLRroid7LPS24PL85K5Y6WZqA1bfQGCHxkfhLK39jHDUpmFzELKQ66AHCm7ZhQVwpF6G95tat3xfpr -> 67rpwLC..., txs=6, features=Set()) has been added to the state 2019-08-08 09:44:11,149 INFO [main] c.w.Application - REST API was bound on 0.0.0.0:6869

  2. Stop node and remove genesis block setting, but I could not start node, I got this error. For waves.directory, I don't have this config in config file. There is only one folder ~/Library/Application Support/waves-custom-44 in system to save blockchain data, If I delete it, could not start also.

Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'custom.genesis' at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:156) at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:149) at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:176) at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:180) at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:188) at com.typesafe.config.impl.SimpleConf

vsuharnikov commented 5 years ago

Stop node and remove genesis block setting, but I could not start node, I got this error.

The genesis setting should not be removed after start. Also you can't run your private network, and then use same waves.directory and run the node on another network.

Also see the documentation about private networks.

duongvansang commented 5 years ago

@vsuharnikov When I try to connect from WavesGUI to my node and matcher, I always got CORS issue, but I do set cors=no, or remove it. I still got it. Do you know how to disable cors checking at node and matcher?

vsuharnikov commented 5 years ago

CORS is Cross-Origin Resource Sharing. The requests are blocked by browser, not by server. So you should enable CORS support on the server by setting waves.rest-api.cors = yes

vsuharnikov commented 5 years ago

@duongvansang any progress here? )