Skip to content

Commit

Permalink
introduce new command line startup parameters: [ton-http-api], [explo…
Browse files Browse the repository at this point in the history
…rer]. If specified MyLocalTon will be started with ton-http-api and blockchain explorer.

new [test-binaries] parameter is used to test binaries' integrity and used in solely in github workflows.
  • Loading branch information
neodiX committed Aug 5, 2024
1 parent 0703cae commit c47826a
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/commit-macos-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:
mkdir artifacts
mvn clean compile package -DskipTests
cp target/MyLocalTon.jar artifacts/MyLocalTon-arm64.jar
java -jar artifacts/MyLocalTon-arm64.jar nogui debug
java -jar artifacts/MyLocalTon-arm64.jar nogui debug test-binaries
- name: Build & Test arm64-aarch64 testnet
timeout-minutes: 10
run: |
mvn clean compile package -DskipTests -Dton_branch=testnet
cp target/MyLocalTon.jar artifacts/MyLocalTon-arm64-testnet.jar
java -jar artifacts/MyLocalTon-arm64-testnet.jar nogui debug
java -jar artifacts/MyLocalTon-arm64-testnet.jar nogui debug test-binaries
- name: Upload artifacts
uses: actions/upload-artifact@master
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/commit-macos-x86-64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:
mkdir artifacts
mvn clean compile package -DskipTests
cp target/MyLocalTon.jar artifacts/MyLocalTon-x86-64.jar
java -jar artifacts/MyLocalTon-x86-64.jar nogui debug
java -jar artifacts/MyLocalTon-x86-64.jar nogui debug test-binaries
- name: Build & Test x86-64 testnet
timeout-minutes: 10
run: |
mvn clean compile package -DskipTests -Dton_branch=testnet
cp target/MyLocalTon.jar artifacts/MyLocalTon-x86-64-testnet.jar
java -jar artifacts/MyLocalTon-x86-64-testnet.jar nogui debug
java -jar artifacts/MyLocalTon-x86-64-testnet.jar nogui debug test-binaries
- name: Upload artifacts
uses: actions/upload-artifact@master
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/commit-ubuntu-x86-64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:
mkdir artifacts
mvn clean compile package -DskipTests
cp target/MyLocalTon.jar artifacts/MyLocalTon-x86-64.jar
java -jar artifacts/MyLocalTon-x86-64.jar nogui debug
java -jar artifacts/MyLocalTon-x86-64.jar nogui debug test-binaries
- name: Build & Test x86-64 testnet
timeout-minutes: 10
run: |
mvn clean compile package -DskipTests -Dton_branch=testnet
cp target/MyLocalTon.jar artifacts/MyLocalTon-x86-64-testnet.jar
java -jar artifacts/MyLocalTon-x86-64-testnet.jar nogui debug
java -jar artifacts/MyLocalTon-x86-64-testnet.jar nogui debug test-binaries
- name: Upload artifacts
uses: actions/upload-artifact@master
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/commit-windows-x86-64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:
mkdir artifacts
mvn clean compile package -DskipTests
cp target/MyLocalTon.jar artifacts/MyLocalTon-x86-64.jar
java -jar artifacts/MyLocalTon-x86-64.jar nogui debug
java -jar artifacts/MyLocalTon-x86-64.jar nogui debug test-binaries
- name: Build & Test x86-64 testnet
timeout-minutes: 10
run: |
mvn clean compile package -DskipTests -Dton_branch=testnet
cp target/MyLocalTon.jar artifacts/MyLocalTon-x86-64-testnet.jar
java -jar artifacts/MyLocalTon-x86-64-testnet.jar nogui debug
java -jar artifacts/MyLocalTon-x86-64-testnet.jar nogui debug test-binaries
- name: Upload artifacts
uses: actions/upload-artifact@master
Expand Down
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,28 @@ In case you are using MacPorts instead of Homebrew on Mac please execute the fol

## Java installation

If you are new to Java, please follow this guide on how to install OpenJDK 17:

- On Ubuntu
https://techviewleo.com/install-java-openjdk-on-ubuntu-linux/
- On Windows
https://java.tutorials24x7.com/blog/how-to-install-openjdk-17-on-windows
- On MacOS
https://knasmueller.net/how-to-install-java-openjdk-17-on-macos-big-sur

In case you have several versions of Java use the following command in order to select the default Java version:

`sudo update-alternatives --config java`
| Linux | MacOS | Windows |
|---------------------------------------|-------------------------------|----------------------------------------------|
| ```sudo apt install openjdk-17-jdk``` | ```brew install openjdk@17``` | ```choco install openjdk --version=17.0.2``` |

## Microsoft Visual C++ Redistributable installation (for Windows only)

Please install Microsoft Visual C++ Redistributable 2015 (and above) x64.
https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170

## Installation and usage
## MyLocalTon installation

| Archicture | Linux / MacOS | Windows |
|------------|--------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
| x86-64 | ```wget https://github.com/neodix42/MyLocalTon/releases/latest/download/MyLocalTon-x86-64.jar``` | [download](https://github.com/neodix42/MyLocalTon/releases/latest/download/MyLocalTon-x86-64.jar) |
| arm64 | ```wget https://github.com/neodix42/MyLocalTon/releases/latest/download/MyLocalTon-arm64.jar``` | [download](https://github.com/neodix42/MyLocalTon/releases/latest/download/MyLocalTon-arm64.jar) |

Go to https://github.com/neodiX42/MyLocalTon/releases. Open Assets section and download MyLocalTon for your architecture
## MyLocalTon usage

Open console and execute the following command:
`java -jar MyLocalTon-x86-64.jar [nogui] [ton-http-api] [explorer] [ip.addr.xxx.xxx] [test-binaries] [debug]`

for ARM64 architecture use:

`java -jar MyLocalTon-x86-64.jar` or
`java -jar MyLocalTon-arm64.jar`

## Upgrade
Expand Down Expand Up @@ -113,4 +110,8 @@ pip3 install --user ton-http-api
wget https://www.python.org/ftp/python/3.12.0/python-3.12.0-amd64.exe
python -m ensurepip --upgrade
start pip3 install -U ton-http-api
```
```

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=neodix42/MyLocalTon&type=Date)](https://star-history.com/#neodix42/mylocalton&Date)
25 changes: 24 additions & 1 deletion src/main/java/org/ton/main/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import org.ton.actions.MyLocalTon;
import org.ton.db.DbPool;
import org.ton.executors.dhtserver.DhtServer;
import org.ton.executors.validatorengine.ValidatorEngine;
import org.ton.executors.validatorengine.ValidatorEngineExecutor;
import org.ton.settings.MyLocalTonSettings;
import org.ton.settings.Node;
import org.ton.ui.controllers.MainController;
Expand All @@ -22,9 +24,11 @@

import java.awt.*;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
Expand Down Expand Up @@ -95,7 +99,7 @@ public static void setRoot(String fxml) throws IOException {
scene.setRoot(fxmlLoader.load());
}

public static void main(MyLocalTonSettings settings, MyLocalTon myLocalTon) throws Throwable {
public static void main(MyLocalTonSettings settings, MyLocalTon myLocalTon, String[] args) throws Throwable {

// start GUI
if (!GraphicsEnvironment.isHeadless()) {
Expand All @@ -106,6 +110,25 @@ public static void main(MyLocalTonSettings settings, MyLocalTon myLocalTon) thro
Node genesisNode = settings.getGenesisNode();
genesisNode.extractBinaries();

if (!Arrays.asList(args).isEmpty()) {
for (String arg : args) {

if (arg.equalsIgnoreCase("test-binaries")) {
Pair<Process, Future<String>> validator = new ValidatorEngineExecutor().execute(genesisNode, "-V");
// Future<String> f = validator.getRight();
log.info("test feature code {}", validator.getRight().get());
log.info("test exit code {}", validator.getLeft().exitValue());
if (validator.getLeft().exitValue() != 0) {
System.out.println("Simple binary test failed.");
System.exit(10);
} else {
System.out.println("Simple binary test passed.");
System.exit(0);
}
}
}
}

// initialize DB
dbPool = new DbPool(settings);

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/ton/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public static void main(String[] args) throws Throwable {
System.setProperty("java.awt.headless", "true");
}

if (arg.equalsIgnoreCase("ton-http-api")) {
log.info("enabling ton-http-api on start (default port 8081)");
settings.getUiSettings().setEnableTonHttpApi(true);
}

if (arg.equalsIgnoreCase("explorer")) {
log.info("enabling ton-blockchain explorer on start (default port 8000)");
settings.getUiSettings().setEnableBlockchainExplorer(true);
}

if (InetAddresses.isInetAddress(arg)) {
log.info("listening on public IP " + arg);
settings.getGenesisNode().setPublicIp(arg);
Expand All @@ -88,7 +98,7 @@ public static void main(String[] args) throws Throwable {

log.info("Starting application at path {}", MyLocalTonUtils.getMyPath());

App.main(settings, myLocalTon);
App.main(settings, myLocalTon, args);

} else {
log.error("Instance already running.");
Expand Down

0 comments on commit c47826a

Please sign in to comment.