diff --git a/README.md b/README.md index a0206cb..4c7c490 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msv ## MyLocalTon usage `java -jar MyLocalTon-x86-64.jar [nogui] [ton-http-api] [explorer] [ip.addr.xxx.xxx] [test-binaries] [test-tonlib -] [with-validators-N] [debug]` +] [with-validators-N] [custom-binaries=] [debug]` for ARM64 architecture use: @@ -71,6 +71,7 @@ for ARM64 architecture use: * `explorer` - enables native ton blockchain explorer on start. Runs on port `8000`. * `ip.addr.xxx.xxx` - used to bind specific IP to MyLocalTon instead of 127.0.0.1. * `with-validators-N` - used to start MyLocalTon with N additional validators. +* `custom-binaries=absolute-path` - used to start MyLocalTon with custom TON binaries. The folder should contain validator-engine, validator-engine-console, lite-client, fift, func, generate-random-id, create-state, dht-server, tonlibjson, blockchain-explorer binaries and also **smartcont** and lib **folders** in its root folder. * `debug` - used to start MyLocalTon in debug mode, that produces lots of useful log files. ### Lite-client diff --git a/src/main/java/org/ton/executors/validatorengine/ValidatorEngine.java b/src/main/java/org/ton/executors/validatorengine/ValidatorEngine.java index 6996a77..68dd909 100644 --- a/src/main/java/org/ton/executors/validatorengine/ValidatorEngine.java +++ b/src/main/java/org/ton/executors/validatorengine/ValidatorEngine.java @@ -191,8 +191,8 @@ private boolean generateZeroState(Node node) throws IOException { String createStateResult = new CreateStateExecutor().execute(node, node.getTonBinDir() + "smartcont" + File.separator + "gen-zerostate.fif"); -// log.debug("creating zero-state output: {}", createStateResult); - log.debug("creating zero-state output"); + log.debug("creating zero-state output: {}", createStateResult); +// log.debug("creating zero-state output"); String mainWalletAddrBoth = sb(createStateResult, "wallet address = ", "(Saving address to file"); String electorSmcAddrBoth = sb(createStateResult, "elector smart contract address = ", "(Saving address to file"); diff --git a/src/main/java/org/ton/main/App.java b/src/main/java/org/ton/main/App.java index 0c39443..ac68ae8 100644 --- a/src/main/java/org/ton/main/App.java +++ b/src/main/java/org/ton/main/App.java @@ -112,6 +112,9 @@ public static void main(MyLocalTonSettings settings, MyLocalTon myLocalTon, Stri Node genesisNode = settings.getGenesisNode(); genesisNode.extractBinaries(); + if (nonNull(settings.getCustomTonBinariesPath())) { + genesisNode.setTonCustomBinDir(settings.getCustomTonBinariesPath()); + } if (!Arrays.asList(args).isEmpty()) { for (String arg : args) { @@ -243,6 +246,7 @@ public static void main(MyLocalTonSettings settings, MyLocalTon myLocalTon, Stri //creating additional validator node log.info("creating validator {}", node.getNodeName()); node.setTonLogLevel(settings.getGenesisNode().getTonLogLevel()); + node.setTonCustomBinDir(settings.getGenesisNode().getTonCustomBinDir()); //delete unfinished or failed node creation FileUtils.deleteQuietly(new File(MyLocalTonSettings.MY_APP_DIR + File.separator + node.getNodeName())); diff --git a/src/main/java/org/ton/main/Main.java b/src/main/java/org/ton/main/Main.java index baf202a..9b0ebea 100644 --- a/src/main/java/org/ton/main/Main.java +++ b/src/main/java/org/ton/main/Main.java @@ -3,6 +3,7 @@ import com.google.common.net.InetAddresses; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.ton.actions.MyLocalTon; import org.ton.settings.MyLocalTonSettings; @@ -63,6 +64,12 @@ public static void main(String[] args) throws Throwable { System.setProperty("java.awt.headless", "true"); } + if (arg.contains("custom-binaries")) { + String path = StringUtils.remove(arg, "custom-binaries="); + settings.setCustomTonBinariesPath(path); + log.info("using custom TON binaries at path {}", path); + } + if (arg.equalsIgnoreCase("ton-http-api")) { log.info("enabling ton-http-api on start (default port 8081)"); settings.getUiSettings().setEnableTonHttpApi(true); diff --git a/src/main/java/org/ton/settings/GenesisNode.java b/src/main/java/org/ton/settings/GenesisNode.java index d2d056e..ba03bc7 100644 --- a/src/main/java/org/ton/settings/GenesisNode.java +++ b/src/main/java/org/ton/settings/GenesisNode.java @@ -42,6 +42,7 @@ public class GenesisNode implements Serializable, Node { String tonLogLevel = "INFO"; public String myLocalTonLogLevel = "INFO"; + String tonCustomBinDir; String validatorPrvKeyHex; String validatorPrvKeyBase64; diff --git a/src/main/java/org/ton/settings/MyLocalTonSettings.java b/src/main/java/org/ton/settings/MyLocalTonSettings.java index 9011ca8..f39aa45 100644 --- a/src/main/java/org/ton/settings/MyLocalTonSettings.java +++ b/src/main/java/org/ton/settings/MyLocalTonSettings.java @@ -123,6 +123,7 @@ public MyLocalTonSettings() { public Map elections = new ConcurrentSkipListMap<>(); Boolean veryFirstElections = Boolean.TRUE; + String customTonBinariesPath; //options - account and keys @Getter diff --git a/src/main/java/org/ton/settings/Node.java b/src/main/java/org/ton/settings/Node.java index 440f81f..6de9420 100644 --- a/src/main/java/org/ton/settings/Node.java +++ b/src/main/java/org/ton/settings/Node.java @@ -24,6 +24,9 @@ default String getTonDbDir() { } default String getTonBinDir() { + if (nonNull(getTonCustomBinDir())) { + return getTonCustomBinDir() + File.separator; + } return CURRENT_DIR + File.separator + MY_LOCAL_TON + File.separator + this.getNodeName() + File.separator + "bin" + File.separator; } @@ -323,4 +326,7 @@ default boolean nodeShutdown() { void setTonLogLevel(String logLevel); + void setTonCustomBinDir(String path); + String getTonCustomBinDir(); + } diff --git a/src/main/java/org/ton/settings/Node2.java b/src/main/java/org/ton/settings/Node2.java index 50d9794..08b3721 100644 --- a/src/main/java/org/ton/settings/Node2.java +++ b/src/main/java/org/ton/settings/Node2.java @@ -41,6 +41,7 @@ public class Node2 implements Serializable, Node { Long validatorSyncBefore = 3600L; // 1h, initial sync download all blocks for last given seconds default=3600, 1 hour String tonLogLevel = "ERROR"; + String tonCustomBinDir; String validatorMonitoringPubKeyHex; String validatorMonitoringPubKeyInteger; diff --git a/src/main/java/org/ton/settings/Node3.java b/src/main/java/org/ton/settings/Node3.java index b879b3b..c67610b 100644 --- a/src/main/java/org/ton/settings/Node3.java +++ b/src/main/java/org/ton/settings/Node3.java @@ -41,6 +41,7 @@ public class Node3 implements Serializable, Node { Long validatorSyncBefore = 3600L; // 1h, initial sync download all blocks for last given seconds default=3600, 1 hour String tonLogLevel = "ERROR"; + String tonCustomBinDir; String validatorMonitoringPubKeyHex; String validatorMonitoringPubKeyInteger; diff --git a/src/main/java/org/ton/settings/Node4.java b/src/main/java/org/ton/settings/Node4.java index 96648b2..f53c201 100644 --- a/src/main/java/org/ton/settings/Node4.java +++ b/src/main/java/org/ton/settings/Node4.java @@ -41,6 +41,7 @@ public class Node4 implements Serializable, Node { Long validatorSyncBefore = 3600L; // 1h, initial sync download all blocks for last given seconds default=3600, 1 hour String tonLogLevel = "ERROR"; + String tonCustomBinDir; String validatorMonitoringPubKeyHex; String validatorMonitoringPubKeyInteger; diff --git a/src/main/java/org/ton/settings/Node5.java b/src/main/java/org/ton/settings/Node5.java index a2af9ae..a86f47e 100644 --- a/src/main/java/org/ton/settings/Node5.java +++ b/src/main/java/org/ton/settings/Node5.java @@ -41,6 +41,7 @@ public class Node5 implements Serializable, Node { Long validatorSyncBefore = 3600L; // 1h, initial sync download all blocks for last given seconds default=3600, 1 hour String tonLogLevel = "ERROR"; + String tonCustomBinDir; String validatorMonitoringPubKeyHex; String validatorMonitoringPubKeyInteger; diff --git a/src/main/java/org/ton/settings/Node6.java b/src/main/java/org/ton/settings/Node6.java index 55f9d4c..6c7dd74 100644 --- a/src/main/java/org/ton/settings/Node6.java +++ b/src/main/java/org/ton/settings/Node6.java @@ -41,6 +41,7 @@ public class Node6 implements Serializable, Node { Long validatorSyncBefore = 3600L; // 1h, initial sync download all blocks for last given seconds default=3600, 1 hour String tonLogLevel = "ERROR"; + String tonCustomBinDir; String validatorMonitoringPubKeyHex; String validatorMonitoringPubKeyInteger; diff --git a/src/main/java/org/ton/settings/Node7.java b/src/main/java/org/ton/settings/Node7.java index f623f60..ac3710c 100644 --- a/src/main/java/org/ton/settings/Node7.java +++ b/src/main/java/org/ton/settings/Node7.java @@ -41,6 +41,7 @@ public class Node7 implements Serializable, Node { Long validatorSyncBefore = 3600L; // 1h, initial sync download all blocks for last given seconds default=3600, 1 hour String tonLogLevel = "ERROR"; + String tonCustomBinDir; String validatorMonitoringPubKeyHex; String validatorMonitoringPubKeyInteger; diff --git a/src/main/java/org/ton/utils/Extractor.java b/src/main/java/org/ton/utils/Extractor.java index 746063d..a92f3a9 100644 --- a/src/main/java/org/ton/utils/Extractor.java +++ b/src/main/java/org/ton/utils/Extractor.java @@ -4,6 +4,7 @@ import net.lingala.zip4j.ZipFile; import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.ton.actions.MyLocalTon; import org.ton.settings.MyLocalTonSettings; import java.io.File; @@ -15,6 +16,7 @@ import java.nio.file.StandardCopyOption; import static java.util.Objects.isNull; +import static java.util.Objects.nonNull; @Slf4j public class Extractor { @@ -58,6 +60,13 @@ private void extractBinaries() throws IOException { Files.createDirectories(Paths.get(MY_LOCAL_TON_ROOT_DIR + nodeName + File.separator + DB + File.separator + "static")); Files.createDirectories(Paths.get(MY_LOCAL_TON_ROOT_DIR + nodeName + File.separator + DB + File.separator + "keyring")); Files.createDirectories(Paths.get(MY_LOCAL_TON_ROOT_DIR + nodeName + File.separator + DB + File.separator + "log")); + if (nonNull(MyLocalTon.getInstance().getSettings().getCustomTonBinariesPath())) { + Files.createDirectories(Paths.get(MyLocalTon.getInstance().getSettings().getCustomTonBinariesPath()+ File.separator + "tonlib-keystore")); + Files.createDirectories(Paths.get(MyLocalTon.getInstance().getSettings().getCustomTonBinariesPath() + File.separator + "wallets")); + Files.createDirectories(Paths.get(MyLocalTon.getInstance().getSettings().getCustomTonBinariesPath()+ File.separator + "zerostate")); + Files.createDirectories(Paths.get(MyLocalTon.getInstance().getSettings().getCustomTonBinariesPath()+ File.separator + "certs")); + + } if (SystemUtils.IS_OS_WINDOWS) {