From 7386b04f83347f7267a9d599839debc76294f621 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 23 May 2023 10:04:57 +0530 Subject: [PATCH 01/26] Added sapphire end-points --- .../fetchnodedetails/FetchNodeDetails.java | 25 ++------- .../fetchnodedetails/types/NodeDetails.java | 52 +++++++++++++++---- 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index cd3488d..4b28bbf 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -1,17 +1,13 @@ package org.torusresearch.fetchnodedetails; - import org.torusresearch.fetchnodedetails.types.NodeDetails; -import org.torusresearch.fetchnodedetails.types.NodeInfo; import org.torusresearch.fetchnodedetails.types.TorusNetwork; -import org.torusresearch.fetchnodedetails.types.TorusNodePub; import org.web3j.crypto.Credentials; import org.web3j.crypto.Hash; import org.web3j.protocol.Web3j; import org.web3j.protocol.http.HttpService; import org.web3j.tx.gas.DefaultGasProvider; -import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.concurrent.CompletableFuture; @@ -24,6 +20,8 @@ public class FetchNodeDetails { public static String PROXY_ADDRESS_AQUA = "0x29Dea82a0509153b91040ee13cDBba0f03efb625"; public static String PROXY_ADDRESS_CELESTE = "0x6Bffb4e89453069E7487f0fa5c9f4a2D771cce6c"; + private String fndServerEndpoint = "https://fnd.tor.us/node-details"; + public static HashMap NETWORK_MAP = new HashMap() { { @@ -35,7 +33,6 @@ public class FetchNodeDetails { } }; - public static NodeDetails NODE_DETAILS_MAINNET = new NodeDetails("19", "0xf20336e16B5182637f09821c27BDe29b0AFcfe80", new String[]{"https://torus-19.torusnode.com/jrpc", "https://torus-node.ens.domains/jrpc", "https://torus-node.matic.network/jrpc", "https://torus.zilliqa.network/jrpc", "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", "https://torus-node.binancex.dev/jrpc", "https://torusnode.ont.io/jrpc"}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5"), new BigInteger("6"), new BigInteger("7"), new BigInteger("8"), new BigInteger("9"),}, new TorusNodePub[]{new TorusNodePub("bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", "82b49a7caf70def38cdad2740af45c1e4f969650105c5019a29bb18b21a9acb5"), new TorusNodePub("c208cac4ef9a47d386097a9c915b28e9cb89213abee8d26a17198ee261201b0d", "c7db2fe4631109f40833de9dc78d07e35706549ee48fa557b33e4e75e1047873"), new TorusNodePub("ca1766bb426d4ca5582818a0c5439d560ea64f5baa060793ab29dd3d0ceacfe", "d46c1d08c40e1306e1bca328c2287b8268166b11a1ba4b8442ea2ad0c5e32152"), new TorusNodePub("c3934dd2f6f4b3d2e1e398cc501e143c1e1a381b52feb6d1525af34d16253768", "71f5141a5035799099f5ea3e241e66946bc55dc857ac3bd7d6fcdb8dcd3eeeef"), new TorusNodePub("22e66f1929631d00bf026227581597f085fd94fd952fc0dca9f0833398b5c064", "6088b3912e10a1e9d50355a609c10db7d188f16a2e2fd7357e51bf4f6a74f0a1"), new TorusNodePub("9dc9fa410f3ce9eb70df70cdea00a49f2c4cc7a31c08c0dab5f863ed35ff5139", "627a291cb87a75c61da3f65d6818e1e05e360217179817ed27e8c73bca7ec122"), new TorusNodePub("118b9fc07e97b096d899b9f6658463ce6a8caa64038e37fc969df4e6023dd8c6", "baf9fa4e51770f4796ea165dd03a769b8606681a38954a0a92c4cbffd6609ce9"), new TorusNodePub("8a6d8b925da15a273dec3d8f8395ec35cd6878f274b2b180e4e106999db64043", "96f67f870c157743da0b1eb84d89bf30500d74dc84c11f501ee1cb013acc8c46"), new TorusNodePub("39cecb62e863729f572f7dfc46c24867981bf04bb405fed0df39e33984bfade5", "61c2364434012e68a2be2e9952805037e52629d7762fafc8e10e9fb5bad8f790")}, false); private final String proxyAddress; private final NodeDetails nodeDetails = new NodeDetails(); @@ -67,29 +64,13 @@ public CompletableFuture getNodeDetails(String verifier, String ver this.torusLookup.getNodeSet(verifier, hashedVerifierId).sendAsync().whenCompleteAsync((nodeEndPoints, err) -> { if (err != null) { if (this.proxyAddress.equals(FetchNodeDetails.PROXY_ADDRESS_MAINNET)) { - cf.complete(FetchNodeDetails.NODE_DETAILS_MAINNET); + //cf.complete(FetchNodeDetails.NODE_DETAILS_MAINNET); } else { cf.completeExceptionally(err); } return; } try { - String[] updatedEndpoints = new String[nodeEndPoints.component3().size()]; - TorusNodePub[] updatedNodePub = new TorusNodePub[nodeEndPoints.component3().size()]; - - for (int i = 0; i < nodeEndPoints.component3().size(); i++) { - NodeInfo endPointElement = new NodeInfo(String.valueOf(nodeEndPoints.component2().get(i)), new BigInteger(String.valueOf(nodeEndPoints.component3().get(i)), 10).toString(16).replace("0x", ""), new BigInteger(String.valueOf(nodeEndPoints.component4().get(i)), 10).toString(16).replace("0x", "")); - - String endpoint = "https://" + endPointElement.getDeclaredIp().split(":")[0] + "/jrpc"; - updatedEndpoints[i] = endpoint; - updatedNodePub[i] = new TorusNodePub(endPointElement.getPubKx(), endPointElement.getPubKy()); - } - this.nodeDetails.setNodeListAddress(this.proxyAddress); - this.nodeDetails.setCurrentEpoch(nodeEndPoints.component1().toString()); - this.nodeDetails.setTorusNodeEndpoints(updatedEndpoints); - this.nodeDetails.setTorusNodePub(updatedNodePub); - this.nodeDetails.setTorusIndexes(nodeEndPoints.component5().toArray(new BigInteger[0])); - this.nodeDetails.setUpdated(true); cf.complete(this.nodeDetails); } catch (Exception err2) { cf.completeExceptionally(err2); diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/NodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/types/NodeDetails.java index 1f49b51..0e9a677 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/NodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/NodeDetails.java @@ -6,8 +6,10 @@ public class NodeDetails { private String currentEpoch; - private String nodeListAddress; private String[] torusNodeEndpoints; + private String[] torusNodeSSSEndpoints; + private String[] torusNodeRSSEndpoints; + private String[] torusNodeTSSEndpoints; private BigInteger[] torusIndexes; private TorusNodePub[] torusNodePub; private Boolean updated = false; @@ -15,10 +17,14 @@ public class NodeDetails { public NodeDetails() { } - public NodeDetails(String _currentEpoch, String _nodeListAddress, String[] _torusNodeEndpoints, BigInteger[] _torusIndexes, TorusNodePub[] _torusNodePub, Boolean _updated) { + public NodeDetails(String _currentEpoch, String[] _torusNodeEndpoints, + String[] _torusNodeSSSEndpoints, String[] _torusNodeRSSEndpoints, String[] _torusNodeTSSEndpoints, + BigInteger[] _torusIndexes, TorusNodePub[] _torusNodePub, Boolean _updated) { this.currentEpoch = _currentEpoch; - this.nodeListAddress = _nodeListAddress; this.torusNodeEndpoints = _torusNodeEndpoints.clone(); + this.torusNodeSSSEndpoints = _torusNodeSSSEndpoints.clone(); + this.torusNodeRSSEndpoints = _torusNodeRSSEndpoints.clone(); + this.torusNodeTSSEndpoints = _torusNodeTSSEndpoints.clone(); this.torusIndexes = _torusIndexes.clone(); this.torusNodePub = _torusNodePub.clone(); this.updated = _updated; @@ -48,12 +54,28 @@ public void setCurrentEpoch(String currentEpoch) { this.currentEpoch = currentEpoch; } - public String getNodeListAddress() { - return nodeListAddress; + public String[] getTorusNodeSSSEndpoints() { + return torusNodeSSSEndpoints; } - public void setNodeListAddress(String nodeListAddress) { - this.nodeListAddress = nodeListAddress; + public void setTorusNodeSSSEndpoints(String[] torusNodeSSSEndpoints) { + this.torusNodeSSSEndpoints = torusNodeSSSEndpoints; + } + + public String[] getTorusNodeRSSEndpoints() { + return torusNodeRSSEndpoints; + } + + public void setTorusNodeRSSEndpoints(String[] torusNodeRSSEndpoints) { + this.torusNodeRSSEndpoints = torusNodeRSSEndpoints; + } + + public String[] getTorusNodeTSSEndpoints() { + return torusNodeTSSEndpoints; + } + + public void setTorusNodeTSSEndpoints(String[] torusNodeTSSEndpoints) { + this.torusNodeTSSEndpoints = torusNodeTSSEndpoints; } public String[] getTorusNodeEndpoints() { @@ -76,8 +98,10 @@ public void setTorusNodePub(TorusNodePub[] torusNodePub) { public String toString() { return "NodeDetails{" + "currentEpoch='" + currentEpoch + '\'' + - ", nodeListAddress='" + nodeListAddress + '\'' + ", torusNodeEndpoints=" + Arrays.toString(torusNodeEndpoints) + + ", torusNodeSSSEndpoints=" + Arrays.toString(torusNodeSSSEndpoints) + + ", torusNodeRSSEndpoints=" + Arrays.toString(torusNodeRSSEndpoints) + + ", torusNodeTSSEndpoints=" + Arrays.toString(torusNodeTSSEndpoints) + ", torusIndexes=" + Arrays.toString(torusIndexes) + ", torusNodePub=" + Arrays.toString(torusNodePub) + ", updated=" + updated + @@ -89,15 +113,21 @@ public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof NodeDetails)) return false; NodeDetails that = (NodeDetails) o; - return Objects.equals(getCurrentEpoch(), that.getCurrentEpoch()) && Objects.equals(getNodeListAddress(), that.getNodeListAddress()) - && Arrays.equals(getTorusNodeEndpoints(), that.getTorusNodeEndpoints()) && Arrays.equals(getTorusIndexes(), that.getTorusIndexes()) && + return Objects.equals(getCurrentEpoch(), that.getCurrentEpoch()) && Arrays.equals(getTorusNodeEndpoints(), that.getTorusNodeEndpoints()) + && Arrays.equals(getTorusNodeSSSEndpoints(), that.getTorusNodeSSSEndpoints()) + && Arrays.equals(getTorusNodeRSSEndpoints(), that.getTorusNodeRSSEndpoints()) + && Arrays.equals(getTorusNodeTSSEndpoints(), that.getTorusNodeTSSEndpoints()) + && Arrays.equals(getTorusIndexes(), that.getTorusIndexes()) && Arrays.equals(getTorusNodePub(), that.getTorusNodePub()) && Objects.equals(getUpdated(), that.getUpdated()); } @Override public int hashCode() { - int result = Objects.hash(getCurrentEpoch(), getNodeListAddress(), getUpdated()); + int result = Objects.hash(getCurrentEpoch(), getUpdated()); result = 31 * result + Arrays.hashCode(getTorusNodeEndpoints()); + result = 31 * result + Arrays.hashCode(getTorusNodeSSSEndpoints()); + result = 31 * result + Arrays.hashCode(getTorusNodeRSSEndpoints()); + result = 31 * result + Arrays.hashCode(getTorusNodeTSSEndpoints()); result = 31 * result + Arrays.hashCode(getTorusIndexes()); result = 31 * result + Arrays.hashCode(getTorusNodePub()); return result; From 1c8d855d83b1162b890ed48db380ad96091cf2c9 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Thu, 25 May 2023 15:28:10 +0530 Subject: [PATCH 02/26] Added sapphire torus networks and Utils.java --- .../fetchnodedetails/FetchNodeDetails.java | 42 ++++++++++++- .../fetchnodedetails/types/TorusNetwork.java | 5 +- .../fetchnodedetails/types/Utils.java | 63 +++++++++++++++++++ 3 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index 4b28bbf..ffb3ec2 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -1,13 +1,17 @@ package org.torusresearch.fetchnodedetails; import org.torusresearch.fetchnodedetails.types.NodeDetails; +import org.torusresearch.fetchnodedetails.types.NodeInfo; import org.torusresearch.fetchnodedetails.types.TorusNetwork; +import org.torusresearch.fetchnodedetails.types.TorusNodePub; +import org.torusresearch.fetchnodedetails.types.Utils; import org.web3j.crypto.Credentials; import org.web3j.crypto.Hash; import org.web3j.protocol.Web3j; import org.web3j.protocol.http.HttpService; import org.web3j.tx.gas.DefaultGasProvider; +import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.concurrent.CompletableFuture; @@ -22,6 +26,7 @@ public class FetchNodeDetails { private String fndServerEndpoint = "https://fnd.tor.us/node-details"; + public static NodeDetails NODE_DETAILS_MAINNET = new NodeDetails("19", new String[]{"https://torus-19.torusnode.com/jrpc", "https://torus-node.ens.domains/jrpc", "https://torus-node.matic.network/jrpc", "https://torus.zilliqa.network/jrpc", "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", "https://torus-node.binancex.dev/jrpc", "https://torusnode.ont.io/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5"), new BigInteger("6"), new BigInteger("7"), new BigInteger("8"), new BigInteger("9"),}, new TorusNodePub[]{new TorusNodePub("bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", "82b49a7caf70def38cdad2740af45c1e4f969650105c5019a29bb18b21a9acb5"), new TorusNodePub("c208cac4ef9a47d386097a9c915b28e9cb89213abee8d26a17198ee261201b0d", "c7db2fe4631109f40833de9dc78d07e35706549ee48fa557b33e4e75e1047873"), new TorusNodePub("ca1766bb426d4ca5582818a0c5439d560ea64f5baa060793ab29dd3d0ceacfe", "d46c1d08c40e1306e1bca328c2287b8268166b11a1ba4b8442ea2ad0c5e32152"), new TorusNodePub("c3934dd2f6f4b3d2e1e398cc501e143c1e1a381b52feb6d1525af34d16253768", "71f5141a5035799099f5ea3e241e66946bc55dc857ac3bd7d6fcdb8dcd3eeeef"), new TorusNodePub("22e66f1929631d00bf026227581597f085fd94fd952fc0dca9f0833398b5c064", "6088b3912e10a1e9d50355a609c10db7d188f16a2e2fd7357e51bf4f6a74f0a1"), new TorusNodePub("9dc9fa410f3ce9eb70df70cdea00a49f2c4cc7a31c08c0dab5f863ed35ff5139", "627a291cb87a75c61da3f65d6818e1e05e360217179817ed27e8c73bca7ec122"), new TorusNodePub("118b9fc07e97b096d899b9f6658463ce6a8caa64038e37fc969df4e6023dd8c6", "baf9fa4e51770f4796ea165dd03a769b8606681a38954a0a92c4cbffd6609ce9"), new TorusNodePub("8a6d8b925da15a273dec3d8f8395ec35cd6878f274b2b180e4e106999db64043", "96f67f870c157743da0b1eb84d89bf30500d74dc84c11f501ee1cb013acc8c46"), new TorusNodePub("39cecb62e863729f572f7dfc46c24867981bf04bb405fed0df39e33984bfade5", "61c2364434012e68a2be2e9952805037e52629d7762fafc8e10e9fb5bad8f790")}, false); public static HashMap NETWORK_MAP = new HashMap() { { @@ -30,14 +35,28 @@ public class FetchNodeDetails { put(TorusNetwork.CYAN, "polygon-mainnet"); put(TorusNetwork.AQUA, "polygon-mainnet"); put(TorusNetwork.CELESTE, "polygon-mainnet"); + put(TorusNetwork.SAPPHIRE_DEVNET, "sapphire_devnet"); + put(TorusNetwork.SAPPHIRE_TESTNET, "sapphire_testnet"); + put(TorusNetwork.SAPPHIRE_MAINNET, "sapphire_mainnet"); + } }; + public static HashMap SIGNER_MAP = new HashMap() { + { + put(TorusNetwork.MAINNET, "https://signer.tor.us"); + put(TorusNetwork.TESTNET, "https://signer.tor.us"); + put(TorusNetwork.CYAN, "https://signer-polygon.tor.us"); + put(TorusNetwork.AQUA, "https://signer-polygon.tor.us"); + put(TorusNetwork.CELESTE, "https://signer-polygon.tor.us"); + } + }; private final String proxyAddress; private final NodeDetails nodeDetails = new NodeDetails(); private final String providerUrl; private TorusLookup torusLookup; + private TorusNetwork torusNetwork = TorusNetwork.MAINNET; public FetchNodeDetails() { this(TorusNetwork.MAINNET, "0xf20336e16B5182637f09821c27BDe29b0AFcfe80"); @@ -45,6 +64,7 @@ public FetchNodeDetails() { public FetchNodeDetails(TorusNetwork network, String proxyAddress) { this.proxyAddress = proxyAddress; + this.torusNetwork = network; this.providerUrl = "https://" + NETWORK_MAP.get(network) + ".infura.io/v3/" + "b8cdb0e4cff24599a286bf8e87ff1c96"; this.setupWeb3(); } @@ -57,20 +77,38 @@ public FetchNodeDetails(String providerUrl, String proxyAddress) { public CompletableFuture getNodeDetails(String verifier, String verifierId) { // For mainnet & ropsten, verifierId combination doesn't change the network details - if (this.nodeDetails.getUpdated() && (this.proxyAddress.equals(PROXY_ADDRESS_MAINNET) || this.proxyAddress.equals(PROXY_ADDRESS_TESTNET))) + if (this.nodeDetails.getUpdated() && (this.torusNetwork.equals(TorusNetwork.AQUA) || this.torusNetwork.equals(TorusNetwork.CYAN) + || this.torusNetwork.equals(TorusNetwork.CELESTE))) return CompletableFuture.supplyAsync(() -> this.nodeDetails); byte[] hashedVerifierId = Hash.sha3(verifierId.getBytes(StandardCharsets.UTF_8)); CompletableFuture cf = new CompletableFuture<>(); this.torusLookup.getNodeSet(verifier, hashedVerifierId).sendAsync().whenCompleteAsync((nodeEndPoints, err) -> { if (err != null) { if (this.proxyAddress.equals(FetchNodeDetails.PROXY_ADDRESS_MAINNET)) { - //cf.complete(FetchNodeDetails.NODE_DETAILS_MAINNET); + cf.complete(FetchNodeDetails.NODE_DETAILS_MAINNET); } else { cf.completeExceptionally(err); } return; } try { + String[] updatedEndpoints = new String[nodeEndPoints.component3().size()]; + TorusNodePub[] updatedNodePub = new TorusNodePub[nodeEndPoints.component3().size()]; + + for (int i = 0; i < nodeEndPoints.component3().size(); i++) { + NodeInfo endPointElement = new NodeInfo(String.valueOf(nodeEndPoints.component2().get(i)), new BigInteger(String.valueOf(nodeEndPoints.component3().get(i)), 10).toString(16).replace("0x", ""), new BigInteger(String.valueOf(nodeEndPoints.component4().get(i)), 10).toString(16).replace("0x", "")); + + String endpoint = "https://" + endPointElement.getDeclaredIp().split(":")[0] + "/jrpc"; + updatedEndpoints[i] = endpoint; + updatedNodePub[i] = new TorusNodePub(endPointElement.getPubKx(), endPointElement.getPubKy()); + } + this.nodeDetails.setCurrentEpoch(nodeEndPoints.component1().toString()); + this.nodeDetails.setTorusNodeEndpoints(updatedEndpoints); + this.nodeDetails.setTorusNodePub(updatedNodePub); + this.nodeDetails.setTorusIndexes(nodeEndPoints.component5().toArray(new BigInteger[0])); + this.nodeDetails.setUpdated(true); + + Utils.fetchLocalConfig(this.torusNetwork); cf.complete(this.nodeDetails); } catch (Exception err2) { cf.completeExceptionally(err2); diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java index d400243..3b5c4a5 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java @@ -5,7 +5,10 @@ public enum TorusNetwork { TESTNET("testnet"), CYAN("cyan"), AQUA("aqua"), - CELESTE("celeste"); + CELESTE("celeste"), + SAPPHIRE_DEVNET("sapphire_devnet"), + SAPPHIRE_TESTNET("sapphire_testnet"), + SAPPHIRE_MAINNET("sapphire_mainnet"); private final String val; diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java new file mode 100644 index 0000000..1870d86 --- /dev/null +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java @@ -0,0 +1,63 @@ +package org.torusresearch.fetchnodedetails.types; + +import java.math.BigInteger; + +public class Utils { + + public static NodeDetails NODE_DETAILS_MAINNET = new NodeDetails("19", new String[]{"https://torus-19.torusnode.com/jrpc", "https://torus-node.ens.domains/jrpc", "https://torus-node.matic.network/jrpc", "https://torus.zilliqa.network/jrpc", "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", "https://torus-node.binancex.dev/jrpc", "https://torusnode.ont.io/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5"), new BigInteger("6"), new BigInteger("7"), new BigInteger("8"), new BigInteger("9"),}, new TorusNodePub[]{new TorusNodePub("bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", "82b49a7caf70def38cdad2740af45c1e4f969650105c5019a29bb18b21a9acb5"), new TorusNodePub("c208cac4ef9a47d386097a9c915b28e9cb89213abee8d26a17198ee261201b0d", "c7db2fe4631109f40833de9dc78d07e35706549ee48fa557b33e4e75e1047873"), new TorusNodePub("ca1766bb426d4ca5582818a0c5439d560ea64f5baa060793ab29dd3d0ceacfe", "d46c1d08c40e1306e1bca328c2287b8268166b11a1ba4b8442ea2ad0c5e32152"), new TorusNodePub("c3934dd2f6f4b3d2e1e398cc501e143c1e1a381b52feb6d1525af34d16253768", "71f5141a5035799099f5ea3e241e66946bc55dc857ac3bd7d6fcdb8dcd3eeeef"), new TorusNodePub("22e66f1929631d00bf026227581597f085fd94fd952fc0dca9f0833398b5c064", "6088b3912e10a1e9d50355a609c10db7d188f16a2e2fd7357e51bf4f6a74f0a1"), new TorusNodePub("9dc9fa410f3ce9eb70df70cdea00a49f2c4cc7a31c08c0dab5f863ed35ff5139", "627a291cb87a75c61da3f65d6818e1e05e360217179817ed27e8c73bca7ec122"), new TorusNodePub("118b9fc07e97b096d899b9f6658463ce6a8caa64038e37fc969df4e6023dd8c6", "baf9fa4e51770f4796ea165dd03a769b8606681a38954a0a92c4cbffd6609ce9"), new TorusNodePub("8a6d8b925da15a273dec3d8f8395ec35cd6878f274b2b180e4e106999db64043", "96f67f870c157743da0b1eb84d89bf30500d74dc84c11f501ee1cb013acc8c46"), new TorusNodePub("39cecb62e863729f572f7dfc46c24867981bf04bb405fed0df39e33984bfade5", "61c2364434012e68a2be2e9952805037e52629d7762fafc8e10e9fb5bad8f790")}, false); + public static NodeDetails NODE_DETAILS_TESTNET = new NodeDetails("15", new String[]{"https://teal-15-1.torusnode.com/jrpc", + "https://teal-15-3.torusnode.com/jrpc", + "https://teal-15-4.torusnode.com/jrpc", + "https://teal-15-5.torusnode.com/jrpc", + "https://teal-15-2.torusnode.com/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, new TorusNodePub[]{new TorusNodePub("1363aad8868cacd7f8946c590325cd463106fb3731f08811ab4302d2deae35c3", "d77eebe5cdf466b475ec892d5b4cffbe0c1670525debbd97eee6dae2f87a7cbe"), new TorusNodePub("7c8cc521c48690f016bea593f67f88ad24f447dd6c31bbab541e59e207bf029d", "b359f0a82608db2e06b953b36d0c9a473a00458117ca32a5b0f4563a7d539636"), new TorusNodePub("8a86543ca17df5687719e2549caa024cf17fe0361e119e741eaee668f8dd0a6f", "9cdb254ff915a76950d6d13d78ef054d5d0dc34e2908c00bb009a6e4da701891"), new TorusNodePub("25a98d9ae006aed1d77e81d58be8f67193d13d01a9888e2923841894f4b0bf9c", "f63d40df480dacf68922004ed36dbab9e2969181b047730a5ce0797fb6958249"), new TorusNodePub("d908f41f8e06324a8a7abcf702adb6a273ce3ae63d86a3d22723e1bbf1438c9a", "d908f41f8e06324a8a7abcf702adb6a273ce3ae63d86a3d22723e1bbf1438c9a")}, false); + public static NodeDetails NODE_DETAILS_SAPPHIRE_MAINNET = new NodeDetails("1", new String[]{"https://sapphire-1.auth.network", "https://sapphire-2.auth.network", "https://sapphire-3.auth.network", "https://sapphire-4.auth.network", "https://sapphire-5.auth.network"}, + new String[]{"https://sapphire-1.auth.network/sss/jrpc", "https://sapphire-2.auth.network/sss/jrpc", "https://sapphire-3.auth.network/sss/jrpc", "https://sapphire-4.auth.network/sss/jrpc", "https://sapphire-5.auth.network/sss/jrpc"}, + new String[]{"https://sapphire-1.auth.network/rss", "https://sapphire-2.auth.network/rss", "https://sapphire-3.auth.network/rss", "https://sapphire-4.auth.network/rss", "https://sapphire-5.auth.network/rss"}, + new String[]{"https://sapphire-1.auth.network/tss", "https://sapphire-2.auth.network/tss", "https://sapphire-3.auth.network/tss", "https://sapphire-4.auth.network/tss", "https://sapphire-5.auth.network/tss"}, + new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, + new TorusNodePub[]{new TorusNodePub("e0925898fee0e9e941fdca7ee88deec99939ae9407e923535c4d4a3a3ff8b052", "54b9fea924e3f3e40791f9987f4234ae4222412d65b74068032fa5d8b63375c1"), + new TorusNodePub("9124cf1e280aab32ba50dffd2de81cecabc13d82d2c1fe9de82f3b3523f9b637", "fca939a1ceb42ce745c55b21ef094f543b457630cb63a94ef4f1afeee2b1f107"), + new TorusNodePub("555f681a63d469cc6c3a58a97e29ebd277425f0e6159708e7c7bf05f18f89476", "606f2bcc0884fa5b64366fc3e8362e4939841b56acd60d5f4553cf36b891ac4e"), + new TorusNodePub("2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247"), + new TorusNodePub("3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4")}, + true); + public static NodeDetails NODE_DETAILS_SAPPHIRE_TESTNET = new NodeDetails("1", new String[]{"https://lrc1.authnetwork.dev", "https://lrc2.authnetwork.dev", "https://lrc3.authnetwork.dev", "https://lrc4.authnetwork.dev", "https://lrc5.authnetwork.dev",}, + new String[]{"https://lrc1.authnetwork.dev/sss/jrpc", "https://lrc2.authnetwork.dev/sss/jrpc", "https://lrc3.authnetwork.dev/sss/jrpc", "https://lrc4.authnetwork.dev/sss/jrpc", "https://lrc5.authnetwork.dev/sss/jrpc"}, + new String[]{"https://lrc1.authnetwork.dev/rss", "https://lrc2.authnetwork.dev/rss", "https://lrc3.authnetwork.dev/rss", "https://lrc4.authnetwork.dev/rss", "https://lrc5.authnetwork.dev/rss"}, + new String[]{"https://lrc1.authnetwork.dev/tss", "https://lrc2.authnetwork.dev/tss", "https://lrc3.authnetwork.dev/tss", "https://lrc4.authnetwork.dev/tss", "https://lrc5.authnetwork.dev/tss"}, + new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, + new TorusNodePub[]{new TorusNodePub("d0e57d0fb29f37888a71c5d1d8312b191121b53e7e77968ca59e5c2ceee89386", "2190e5e78c02ecdd4e5e04a01d3c12d847d53682ade7b6f715df1e1f3911081d"), + new TorusNodePub("69d4fcd1ab4dedc06ac0bafaccac8e5459275ec12a8b3feaef26646ece902e38", "2319469c4344d78140ed9672c5231a0d045467dec66c77b53dfbefc56496ff3c"), + new TorusNodePub("9b0ea52ef5d8fc68e02b3ea242b2b11556ab5746b92779a7c4d61ff57c054710", "0f9fc9e706e0a2d2b5c8511177583cdf5fa5379e2c3c1ed4db74aaded08b1a28"), + new TorusNodePub("e08bb1de0c017241be3c8e2ab3e788b64cb83d77ddd5517424626d1e3a4a5406", "d4a87ae195e1f55fe4751caf22123d495cc4b51df48f234c956262fd1d8baafc"), + new TorusNodePub("29154aaa5b76bdb5082ea9616769f1940e56de5c6d8afb8cc75fbd228302d961", "3535fb808e205f5589ca2dd28014103771266148ebc372f364dae0f3905dd811")}, + true); + public static NodeDetails NODE_DETAILS_SAPPHIRE_DEVNET = new NodeDetails("1", new String[]{"https://sapphire-dev-2-1.authnetwork.dev", "https://sapphire-dev-2-2.authnetwork.dev", "https://sapphire-dev-2-3.authnetwork.dev", "https://sapphire-dev-2-4.authnetwork.dev", "https://sapphire-dev-2-5.authnetwork.dev"}, + new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc"}, + new String[]{"https://sapphire-dev-2-1.authnetwork.dev/rss", "https://sapphire-dev-2-2.authnetwork.dev/rss", "https://sapphire-dev-2-3.authnetwork.dev/rss", "https://sapphire-dev-2-4.authnetwork.dev/rss", "https://sapphire-dev-2-5.authnetwork.dev/rss"}, + new String[]{"https://sapphire-dev-2-1.authnetwork.dev/tss", "https://sapphire-dev-2-2.authnetwork.dev/tss", "https://sapphire-dev-2-3.authnetwork.dev/tss", "https://sapphire-dev-2-4.authnetwork.dev/tss", "https://sapphire-dev-2-5.authnetwork.dev/tss"}, + new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, + new TorusNodePub[]{new TorusNodePub("f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7"), + new TorusNodePub("bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a"), + new TorusNodePub("b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c"), + new TorusNodePub("7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b"), + new TorusNodePub("bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4")}, + true); + + public static NodeDetails fetchLocalConfig(TorusNetwork network) { + NodeDetails nodeDetails = null; + switch (network) { + case SAPPHIRE_DEVNET: + nodeDetails = NODE_DETAILS_SAPPHIRE_DEVNET; + case SAPPHIRE_TESTNET: + nodeDetails = NODE_DETAILS_SAPPHIRE_TESTNET; + case SAPPHIRE_MAINNET: + nodeDetails = NODE_DETAILS_SAPPHIRE_MAINNET; + case MAINNET: + nodeDetails = NODE_DETAILS_MAINNET; + case TESTNET: + nodeDetails = NODE_DETAILS_TESTNET; + } + return nodeDetails; + } +} From a15380a7c4d2d58829cbf9c40d9a9eb70c359ec2 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 26 May 2023 12:57:13 +0530 Subject: [PATCH 03/26] Added sapphire config json and test-cases for sapphire networks --- build.gradle | 3 + .../fetchnodedetails/FetchNodeDetails.java | 90 +++++-------------- .../fetchnodedetails/types/APIUtils.java | 85 ++++++++++++++++++ .../fetchnodedetails/types/FNDResponse.java | 27 ++++++ .../fetchnodedetails/types/NodeDetails.java | 3 +- .../fetchnodedetails/types/Utils.java | 8 ++ .../FetchNodeDetailsTest.java | 30 ++++++- .../fetchnodedetailstest/config/Config.java | 10 ++- .../fetchnodedetailstest/config/aqua.json | 4 +- .../fetchnodedetailstest/config/celeste.json | 2 +- .../fetchnodedetailstest/config/mainnet.json | 5 +- .../config/sapphire_devnet.json | 60 +++++++++++++ .../config/sapphire_mainnet.json | 60 +++++++++++++ .../config/sapphire_testnet.json | 60 +++++++++++++ .../fetchnodedetailstest/config/testnet.json | 2 +- 15 files changed, 372 insertions(+), 77 deletions(-) create mode 100644 src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java create mode 100644 src/main/java/org/torusresearch/fetchnodedetails/types/FNDResponse.java create mode 100644 src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json create mode 100644 src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json create mode 100644 src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json diff --git a/build.gradle b/build.gradle index 5c8c446..bf28f60 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,9 @@ repositories { dependencies { implementation 'org.web3j:core:4.8.8-android' + implementation 'com.squareup.okhttp3:okhttp:4.9.3' + implementation 'com.google.code.gson:gson:2.9.0' + implementation 'org.json:json:20220924' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' testImplementation 'org.slf4j:slf4j-simple:1.7.36' diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index ffb3ec2..46782cf 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -1,18 +1,16 @@ package org.torusresearch.fetchnodedetails; +import com.google.gson.GsonBuilder; + +import org.json.JSONObject; +import org.torusresearch.fetchnodedetails.types.APIUtils; +import org.torusresearch.fetchnodedetails.types.FNDResponse; import org.torusresearch.fetchnodedetails.types.NodeDetails; -import org.torusresearch.fetchnodedetails.types.NodeInfo; import org.torusresearch.fetchnodedetails.types.TorusNetwork; import org.torusresearch.fetchnodedetails.types.TorusNodePub; import org.torusresearch.fetchnodedetails.types.Utils; -import org.web3j.crypto.Credentials; -import org.web3j.crypto.Hash; -import org.web3j.protocol.Web3j; -import org.web3j.protocol.http.HttpService; -import org.web3j.tx.gas.DefaultGasProvider; import java.math.BigInteger; -import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.concurrent.CompletableFuture; @@ -24,8 +22,6 @@ public class FetchNodeDetails { public static String PROXY_ADDRESS_AQUA = "0x29Dea82a0509153b91040ee13cDBba0f03efb625"; public static String PROXY_ADDRESS_CELESTE = "0x6Bffb4e89453069E7487f0fa5c9f4a2D771cce6c"; - private String fndServerEndpoint = "https://fnd.tor.us/node-details"; - public static NodeDetails NODE_DETAILS_MAINNET = new NodeDetails("19", new String[]{"https://torus-19.torusnode.com/jrpc", "https://torus-node.ens.domains/jrpc", "https://torus-node.matic.network/jrpc", "https://torus.zilliqa.network/jrpc", "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", "https://torus-node.binancex.dev/jrpc", "https://torusnode.ont.io/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5"), new BigInteger("6"), new BigInteger("7"), new BigInteger("8"), new BigInteger("9"),}, new TorusNodePub[]{new TorusNodePub("bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", "82b49a7caf70def38cdad2740af45c1e4f969650105c5019a29bb18b21a9acb5"), new TorusNodePub("c208cac4ef9a47d386097a9c915b28e9cb89213abee8d26a17198ee261201b0d", "c7db2fe4631109f40833de9dc78d07e35706549ee48fa557b33e4e75e1047873"), new TorusNodePub("ca1766bb426d4ca5582818a0c5439d560ea64f5baa060793ab29dd3d0ceacfe", "d46c1d08c40e1306e1bca328c2287b8268166b11a1ba4b8442ea2ad0c5e32152"), new TorusNodePub("c3934dd2f6f4b3d2e1e398cc501e143c1e1a381b52feb6d1525af34d16253768", "71f5141a5035799099f5ea3e241e66946bc55dc857ac3bd7d6fcdb8dcd3eeeef"), new TorusNodePub("22e66f1929631d00bf026227581597f085fd94fd952fc0dca9f0833398b5c064", "6088b3912e10a1e9d50355a609c10db7d188f16a2e2fd7357e51bf4f6a74f0a1"), new TorusNodePub("9dc9fa410f3ce9eb70df70cdea00a49f2c4cc7a31c08c0dab5f863ed35ff5139", "627a291cb87a75c61da3f65d6818e1e05e360217179817ed27e8c73bca7ec122"), new TorusNodePub("118b9fc07e97b096d899b9f6658463ce6a8caa64038e37fc969df4e6023dd8c6", "baf9fa4e51770f4796ea165dd03a769b8606681a38954a0a92c4cbffd6609ce9"), new TorusNodePub("8a6d8b925da15a273dec3d8f8395ec35cd6878f274b2b180e4e106999db64043", "96f67f870c157743da0b1eb84d89bf30500d74dc84c11f501ee1cb013acc8c46"), new TorusNodePub("39cecb62e863729f572f7dfc46c24867981bf04bb405fed0df39e33984bfade5", "61c2364434012e68a2be2e9952805037e52629d7762fafc8e10e9fb5bad8f790")}, false); public static HashMap NETWORK_MAP = new HashMap() { @@ -42,19 +38,8 @@ public class FetchNodeDetails { } }; - public static HashMap SIGNER_MAP = new HashMap() { - { - put(TorusNetwork.MAINNET, "https://signer.tor.us"); - put(TorusNetwork.TESTNET, "https://signer.tor.us"); - put(TorusNetwork.CYAN, "https://signer-polygon.tor.us"); - put(TorusNetwork.AQUA, "https://signer-polygon.tor.us"); - put(TorusNetwork.CELESTE, "https://signer-polygon.tor.us"); - } - }; - private final String proxyAddress; private final NodeDetails nodeDetails = new NodeDetails(); - private final String providerUrl; private TorusLookup torusLookup; private TorusNetwork torusNetwork = TorusNetwork.MAINNET; @@ -65,61 +50,34 @@ public FetchNodeDetails() { public FetchNodeDetails(TorusNetwork network, String proxyAddress) { this.proxyAddress = proxyAddress; this.torusNetwork = network; - this.providerUrl = "https://" + NETWORK_MAP.get(network) + ".infura.io/v3/" + "b8cdb0e4cff24599a286bf8e87ff1c96"; - this.setupWeb3(); } - public FetchNodeDetails(String providerUrl, String proxyAddress) { + public FetchNodeDetails(String proxyAddress) { this.proxyAddress = proxyAddress; - this.providerUrl = providerUrl; - this.setupWeb3(); } public CompletableFuture getNodeDetails(String verifier, String verifierId) { // For mainnet & ropsten, verifierId combination doesn't change the network details - if (this.nodeDetails.getUpdated() && (this.torusNetwork.equals(TorusNetwork.AQUA) || this.torusNetwork.equals(TorusNetwork.CYAN) - || this.torusNetwork.equals(TorusNetwork.CELESTE))) + if (this.nodeDetails.getUpdated() && (this.torusNetwork.equals(TorusNetwork.MAINNET) || this.torusNetwork.equals(TorusNetwork.TESTNET) + || this.torusNetwork.equals(TorusNetwork.SAPPHIRE_MAINNET) || this.torusNetwork.equals(TorusNetwork.SAPPHIRE_TESTNET) || + this.torusNetwork.equals(TorusNetwork.SAPPHIRE_DEVNET))) return CompletableFuture.supplyAsync(() -> this.nodeDetails); - byte[] hashedVerifierId = Hash.sha3(verifierId.getBytes(StandardCharsets.UTF_8)); - CompletableFuture cf = new CompletableFuture<>(); - this.torusLookup.getNodeSet(verifier, hashedVerifierId).sendAsync().whenCompleteAsync((nodeEndPoints, err) -> { - if (err != null) { - if (this.proxyAddress.equals(FetchNodeDetails.PROXY_ADDRESS_MAINNET)) { - cf.complete(FetchNodeDetails.NODE_DETAILS_MAINNET); - } else { - cf.completeExceptionally(err); - } - return; - } - try { - String[] updatedEndpoints = new String[nodeEndPoints.component3().size()]; - TorusNodePub[] updatedNodePub = new TorusNodePub[nodeEndPoints.component3().size()]; - for (int i = 0; i < nodeEndPoints.component3().size(); i++) { - NodeInfo endPointElement = new NodeInfo(String.valueOf(nodeEndPoints.component2().get(i)), new BigInteger(String.valueOf(nodeEndPoints.component3().get(i)), 10).toString(16).replace("0x", ""), new BigInteger(String.valueOf(nodeEndPoints.component4().get(i)), 10).toString(16).replace("0x", "")); - - String endpoint = "https://" + endPointElement.getDeclaredIp().split(":")[0] + "/jrpc"; - updatedEndpoints[i] = endpoint; - updatedNodePub[i] = new TorusNodePub(endPointElement.getPubKx(), endPointElement.getPubKy()); - } - this.nodeDetails.setCurrentEpoch(nodeEndPoints.component1().toString()); - this.nodeDetails.setTorusNodeEndpoints(updatedEndpoints); - this.nodeDetails.setTorusNodePub(updatedNodePub); - this.nodeDetails.setTorusIndexes(nodeEndPoints.component5().toArray(new BigInteger[0])); - this.nodeDetails.setUpdated(true); - - Utils.fetchLocalConfig(this.torusNetwork); - cf.complete(this.nodeDetails); - } catch (Exception err2) { - cf.completeExceptionally(err2); - } - }); + CompletableFuture cf = new CompletableFuture<>(); + try { + String fndServerEndpoint = "https://fnd.tor.us/node-details"; + String url = fndServerEndpoint + "?network=" + this.torusNetwork + "&verifier=" + verifier + "&verifierId=" + verifierId; + CompletableFuture response = APIUtils.get(url); + JSONObject jsonObject = new JSONObject(response.get()); + FNDResponse fndResponse = + new GsonBuilder().disableHtmlEscaping().create().fromJson(jsonObject.toString(), FNDResponse.class); + cf.complete(fndResponse.getNodeDetails()); + return cf; + } catch (Exception ex) { + cf.completeExceptionally(new Exception("Failed to fetch node details from server")); + } + NodeDetails nodeDetails = Utils.fetchLocalConfig(this.torusNetwork); + cf.complete(nodeDetails); return cf; } - - private void setupWeb3() { - Web3j web3j = Web3j.build(new HttpService(this.providerUrl)); - Credentials credentials = Credentials.create("0x5bbbef76458bf30511c9ee6ed56783644eb339258d02656755c68098c4809130"); - this.torusLookup = new TorusLookup(this.proxyAddress, web3j, credentials, new DefaultGasProvider()); - } } diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java b/src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java new file mode 100644 index 0000000..6312522 --- /dev/null +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java @@ -0,0 +1,85 @@ +package org.torusresearch.fetchnodedetails.types; + +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.internal.http2.Header; + +public class APIUtils { + public static final MediaType JSON = MediaType.get("application/json; charset=utf-8"); + private static final OkHttpClient client = new OkHttpClient().newBuilder().writeTimeout(12, TimeUnit.SECONDS).build(); + + private APIUtils() { + } + + public static Callback toCallback(CompletableFuture future) { + return new Callback() { + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(e); + } + + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) { + try { + future.complete(Objects.requireNonNull(response.body()).string()); + } catch (IOException e) { + e.printStackTrace(); + future.completeExceptionally(e); + } + } + }; + } + + public static CompletableFuture post(String url, String data) { + return _post(url, data, new Header[0]); + } + + public static CompletableFuture post(String url, String data, Header[] headers) { + return _post(url, data, headers); + } + + public static CompletableFuture get(String url) { + return _get(url, new Header[0]); + } + + public static CompletableFuture get(String url, Header[] headers) { + return _get(url, headers); + } + + private static CompletableFuture _post(String url, String data, Header[] headers) { + RequestBody body = RequestBody.create(data, JSON); + Request.Builder requestBuilder = new Request.Builder() + .url(url) + .post(body); + for (Header header : headers) { + requestBuilder.addHeader(header.name.utf8(), header.value.utf8()); + } + Request request = requestBuilder.build(); + CompletableFuture future = new CompletableFuture<>(); + client.newCall(request).enqueue(toCallback(future)); + return future; + } + + private static CompletableFuture _get(String url, Header[] headers) { + Request.Builder requestBuilder = new Request.Builder().url(url); + for (Header header : headers) { + requestBuilder.addHeader(header.name.utf8(), header.value.utf8()); + } + Request request = requestBuilder.build(); + CompletableFuture future = new CompletableFuture<>(); + client.newCall(request).enqueue(toCallback(future)); + return future; + } +} diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/FNDResponse.java b/src/main/java/org/torusresearch/fetchnodedetails/types/FNDResponse.java new file mode 100644 index 0000000..ce22c49 --- /dev/null +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/FNDResponse.java @@ -0,0 +1,27 @@ +package org.torusresearch.fetchnodedetails.types; + +public class FNDResponse { + private NodeDetails nodeDetails; + private boolean success; + + public FNDResponse(NodeDetails nodeDetails, boolean success) { + this.nodeDetails = nodeDetails; + this.success = success; + } + + public NodeDetails getNodeDetails() { + return nodeDetails; + } + + public void setNodeDetails(NodeDetails nodeDetails) { + this.nodeDetails = nodeDetails; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } +} diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/NodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/types/NodeDetails.java index 0e9a677..f19e10e 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/NodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/NodeDetails.java @@ -1,10 +1,11 @@ package org.torusresearch.fetchnodedetails.types; +import java.io.Serializable; import java.math.BigInteger; import java.util.Arrays; import java.util.Objects; -public class NodeDetails { +public class NodeDetails implements Serializable { private String currentEpoch; private String[] torusNodeEndpoints; private String[] torusNodeSSSEndpoints; diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java index 1870d86..87b13a8 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java @@ -5,11 +5,13 @@ public class Utils { public static NodeDetails NODE_DETAILS_MAINNET = new NodeDetails("19", new String[]{"https://torus-19.torusnode.com/jrpc", "https://torus-node.ens.domains/jrpc", "https://torus-node.matic.network/jrpc", "https://torus.zilliqa.network/jrpc", "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", "https://torus-node.binancex.dev/jrpc", "https://torusnode.ont.io/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5"), new BigInteger("6"), new BigInteger("7"), new BigInteger("8"), new BigInteger("9"),}, new TorusNodePub[]{new TorusNodePub("bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", "82b49a7caf70def38cdad2740af45c1e4f969650105c5019a29bb18b21a9acb5"), new TorusNodePub("c208cac4ef9a47d386097a9c915b28e9cb89213abee8d26a17198ee261201b0d", "c7db2fe4631109f40833de9dc78d07e35706549ee48fa557b33e4e75e1047873"), new TorusNodePub("ca1766bb426d4ca5582818a0c5439d560ea64f5baa060793ab29dd3d0ceacfe", "d46c1d08c40e1306e1bca328c2287b8268166b11a1ba4b8442ea2ad0c5e32152"), new TorusNodePub("c3934dd2f6f4b3d2e1e398cc501e143c1e1a381b52feb6d1525af34d16253768", "71f5141a5035799099f5ea3e241e66946bc55dc857ac3bd7d6fcdb8dcd3eeeef"), new TorusNodePub("22e66f1929631d00bf026227581597f085fd94fd952fc0dca9f0833398b5c064", "6088b3912e10a1e9d50355a609c10db7d188f16a2e2fd7357e51bf4f6a74f0a1"), new TorusNodePub("9dc9fa410f3ce9eb70df70cdea00a49f2c4cc7a31c08c0dab5f863ed35ff5139", "627a291cb87a75c61da3f65d6818e1e05e360217179817ed27e8c73bca7ec122"), new TorusNodePub("118b9fc07e97b096d899b9f6658463ce6a8caa64038e37fc969df4e6023dd8c6", "baf9fa4e51770f4796ea165dd03a769b8606681a38954a0a92c4cbffd6609ce9"), new TorusNodePub("8a6d8b925da15a273dec3d8f8395ec35cd6878f274b2b180e4e106999db64043", "96f67f870c157743da0b1eb84d89bf30500d74dc84c11f501ee1cb013acc8c46"), new TorusNodePub("39cecb62e863729f572f7dfc46c24867981bf04bb405fed0df39e33984bfade5", "61c2364434012e68a2be2e9952805037e52629d7762fafc8e10e9fb5bad8f790")}, false); + public static NodeDetails NODE_DETAILS_TESTNET = new NodeDetails("15", new String[]{"https://teal-15-1.torusnode.com/jrpc", "https://teal-15-3.torusnode.com/jrpc", "https://teal-15-4.torusnode.com/jrpc", "https://teal-15-5.torusnode.com/jrpc", "https://teal-15-2.torusnode.com/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, new TorusNodePub[]{new TorusNodePub("1363aad8868cacd7f8946c590325cd463106fb3731f08811ab4302d2deae35c3", "d77eebe5cdf466b475ec892d5b4cffbe0c1670525debbd97eee6dae2f87a7cbe"), new TorusNodePub("7c8cc521c48690f016bea593f67f88ad24f447dd6c31bbab541e59e207bf029d", "b359f0a82608db2e06b953b36d0c9a473a00458117ca32a5b0f4563a7d539636"), new TorusNodePub("8a86543ca17df5687719e2549caa024cf17fe0361e119e741eaee668f8dd0a6f", "9cdb254ff915a76950d6d13d78ef054d5d0dc34e2908c00bb009a6e4da701891"), new TorusNodePub("25a98d9ae006aed1d77e81d58be8f67193d13d01a9888e2923841894f4b0bf9c", "f63d40df480dacf68922004ed36dbab9e2969181b047730a5ce0797fb6958249"), new TorusNodePub("d908f41f8e06324a8a7abcf702adb6a273ce3ae63d86a3d22723e1bbf1438c9a", "d908f41f8e06324a8a7abcf702adb6a273ce3ae63d86a3d22723e1bbf1438c9a")}, false); + public static NodeDetails NODE_DETAILS_SAPPHIRE_MAINNET = new NodeDetails("1", new String[]{"https://sapphire-1.auth.network", "https://sapphire-2.auth.network", "https://sapphire-3.auth.network", "https://sapphire-4.auth.network", "https://sapphire-5.auth.network"}, new String[]{"https://sapphire-1.auth.network/sss/jrpc", "https://sapphire-2.auth.network/sss/jrpc", "https://sapphire-3.auth.network/sss/jrpc", "https://sapphire-4.auth.network/sss/jrpc", "https://sapphire-5.auth.network/sss/jrpc"}, new String[]{"https://sapphire-1.auth.network/rss", "https://sapphire-2.auth.network/rss", "https://sapphire-3.auth.network/rss", "https://sapphire-4.auth.network/rss", "https://sapphire-5.auth.network/rss"}, @@ -21,6 +23,7 @@ public class Utils { new TorusNodePub("2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247"), new TorusNodePub("3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4")}, true); + public static NodeDetails NODE_DETAILS_SAPPHIRE_TESTNET = new NodeDetails("1", new String[]{"https://lrc1.authnetwork.dev", "https://lrc2.authnetwork.dev", "https://lrc3.authnetwork.dev", "https://lrc4.authnetwork.dev", "https://lrc5.authnetwork.dev",}, new String[]{"https://lrc1.authnetwork.dev/sss/jrpc", "https://lrc2.authnetwork.dev/sss/jrpc", "https://lrc3.authnetwork.dev/sss/jrpc", "https://lrc4.authnetwork.dev/sss/jrpc", "https://lrc5.authnetwork.dev/sss/jrpc"}, new String[]{"https://lrc1.authnetwork.dev/rss", "https://lrc2.authnetwork.dev/rss", "https://lrc3.authnetwork.dev/rss", "https://lrc4.authnetwork.dev/rss", "https://lrc5.authnetwork.dev/rss"}, @@ -32,6 +35,7 @@ public class Utils { new TorusNodePub("e08bb1de0c017241be3c8e2ab3e788b64cb83d77ddd5517424626d1e3a4a5406", "d4a87ae195e1f55fe4751caf22123d495cc4b51df48f234c956262fd1d8baafc"), new TorusNodePub("29154aaa5b76bdb5082ea9616769f1940e56de5c6d8afb8cc75fbd228302d961", "3535fb808e205f5589ca2dd28014103771266148ebc372f364dae0f3905dd811")}, true); + public static NodeDetails NODE_DETAILS_SAPPHIRE_DEVNET = new NodeDetails("1", new String[]{"https://sapphire-dev-2-1.authnetwork.dev", "https://sapphire-dev-2-2.authnetwork.dev", "https://sapphire-dev-2-3.authnetwork.dev", "https://sapphire-dev-2-4.authnetwork.dev", "https://sapphire-dev-2-5.authnetwork.dev"}, new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc"}, new String[]{"https://sapphire-dev-2-1.authnetwork.dev/rss", "https://sapphire-dev-2-2.authnetwork.dev/rss", "https://sapphire-dev-2-3.authnetwork.dev/rss", "https://sapphire-dev-2-4.authnetwork.dev/rss", "https://sapphire-dev-2-5.authnetwork.dev/rss"}, @@ -60,4 +64,8 @@ public static NodeDetails fetchLocalConfig(TorusNetwork network) { } return nodeDetails; } + + public static boolean isEmpty(final CharSequence cs) { + return cs == null || cs.length() == 0; + } } diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java index a6a0cf1..f57968a 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java @@ -1,17 +1,17 @@ package org.torusresearch.fetchnodedetailstest; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.torusresearch.fetchnodedetails.FetchNodeDetails; -import org.torusresearch.fetchnodedetails.types.TorusNetwork; import org.torusresearch.fetchnodedetails.types.NodeDetails; +import org.torusresearch.fetchnodedetails.types.TorusNetwork; import org.torusresearch.fetchnodedetailstest.config.Config; import java.io.UnsupportedEncodingException; import java.util.concurrent.ExecutionException; -import static org.junit.jupiter.api.Assertions.assertEquals; - class FetchNodeDetailsTest { FetchNodeDetails fetchNodeDetails; @@ -54,4 +54,28 @@ public void shouldGetNodeDetailsCeleste() throws ExecutionException, Interrupted NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.CELESTE, nodeDetails); } + + @DisplayName("Gets the Node details for SapphireDevnet") + @Test + public void shouldGetNodeDetailsSapphireDevnet() throws ExecutionException, InterruptedException { + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_DEVNET, FetchNodeDetails.PROXY_ADDRESS_CELESTE); + NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); + assertEquals(Config.SAPPHIRE_DEVNET, nodeDetails); + } + + @DisplayName("Gets the Node details for SapphireTestnet") + @Test + public void shouldGetNodeDetailsSapphireTestnet() throws ExecutionException, InterruptedException { + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_TESTNET, FetchNodeDetails.PROXY_ADDRESS_CELESTE); + NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); + assertEquals(Config.SAPPHIRE_TESTNET, nodeDetails); + } + + @DisplayName("Gets the Node details for SapphireMainnet") + @Test + public void shouldGetNodeDetailsSapphireMainnet() throws ExecutionException, InterruptedException { + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_MAINNET, FetchNodeDetails.PROXY_ADDRESS_CELESTE); + NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); + assertEquals(Config.SAPPHIRE_MAINNET, nodeDetails); + } } \ No newline at end of file diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/Config.java b/src/test/java/org/torusresearch/fetchnodedetailstest/config/Config.java index 8d05596..46e16d0 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/Config.java +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/Config.java @@ -1,9 +1,9 @@ package org.torusresearch.fetchnodedetailstest.config; import com.google.gson.Gson; + import org.torusresearch.fetchnodedetails.types.NodeDetails; -import java.io.File; import java.io.FileReader; import java.io.Reader; @@ -14,6 +14,9 @@ public class Config { public static NodeDetails AQUA; public static NodeDetails CELESTE; + public static NodeDetails SAPPHIRE_DEVNET; + public static NodeDetails SAPPHIRE_TESTNET; + public static NodeDetails SAPPHIRE_MAINNET; static { try { @@ -23,6 +26,9 @@ public class Config { CYAN = getNodeDetailsFromFile(basePath + "cyan.json"); AQUA = getNodeDetailsFromFile(basePath + "aqua.json"); CELESTE = getNodeDetailsFromFile(basePath + "celeste.json"); + SAPPHIRE_DEVNET = getNodeDetailsFromFile(basePath + "sapphire_devnet.json"); + SAPPHIRE_TESTNET = getNodeDetailsFromFile(basePath + "sapphire_testnet.json"); + SAPPHIRE_MAINNET = getNodeDetailsFromFile(basePath + "sapphire_mainnet.json"); } catch (Exception ex) { ex.printStackTrace(); } @@ -35,7 +41,7 @@ static NodeDetails getNodeDetailsFromFile(String path) { Gson gson = new Gson(); // create a reader - Reader reader = new FileReader(new File(path)); + Reader reader = new FileReader(path); // convert JSON file to map NodeDetails details = gson.fromJson(reader, NodeDetails.class); diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json index 0f17525..18b0a53 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json @@ -14,12 +14,12 @@ "Y": "d5752873e522f98b4ded27690aadfda57ff5dc2fd0c3055b9d83663441667010" }, { - "X": "e1b5debe1d9b42eb9917a5fe84fa5f48cae7a770b1f49f0546fbe26b1efaff3", + "X": "0e1b5debe1d9b42eb9917a5fe84fa5f48cae7a770b1f49f0546fbe26b1efaff3", "Y": "8947458cbfd8b40c7bc6160c7c746c2dca65c7d6ffdccd5579203b92a020b4ad" }, { "X": "98c3582b138b375b643984094882c17ca7ee090787c0a7065d229672845aa25e", - "Y": "2c3923bd015faac2cf3d91ab4cf8c6cdd4eb9f99e407a35703edf17e8c35d" + "Y": "02c3923bd015faac2cf3d91ab4cf8c6cdd4eb9f99e407a35703edf17e8c35d" }, { "X": "e7ef4c1ea43bd385ab8bfb02a5aedcd33bed35b95980c0729e9a35edd02a8597", diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/celeste.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/celeste.json index e403fb4..7556d32 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/celeste.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/celeste.json @@ -11,7 +11,7 @@ "torusNodePub": [ { "X": "184a61fc08255c33ac8d57da86d957725e45157a4dfe6b80838b9c0acf450133", - "Y": "6b2189341bc8ba97cd849f58bac8d6fa4484c42d57a529797a4d615bf20fbcd" + "Y": "06b2189341bc8ba97cd849f58bac8d6fa4484c42d57a529797a4d615bf20fbcd" }, { "X": "3ca052df886a84096c2b2eded87cbfacab06d5e231b75a0fe8b6bc7fa4ed04a1", diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json index 5de691b..1b4e06a 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json @@ -12,6 +12,9 @@ "https://torus-node.binancex.dev/jrpc", "https://torusnode.ont.io/jrpc" ], + "torusNodeSSSEndpoints": null, + "torusNodeRSSEndpoints": null, + "torusNodeTSSEndpoints": null, "torusNodePub": [ { "X": "bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", @@ -51,5 +54,5 @@ } ], "torusIndexes": [1, 2, 3, 4, 5, 6, 7, 8, 9], - "updated": true + "updated": false } diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json new file mode 100644 index 0000000..9d3e2e5 --- /dev/null +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json @@ -0,0 +1,60 @@ +{ + "currentEpoch": "1", + "torusNodeEndpoints": [ + "https://sapphire-dev-2-1.authnetwork.dev", + "https://sapphire-dev-2-2.authnetwork.dev", + "https://sapphire-dev-2-3.authnetwork.dev", + "https://sapphire-dev-2-4.authnetwork.dev", + "https://sapphire-dev-2-5.authnetwork.dev" + ], + "torusNodeSSSEndpoints": [ + "https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc" + ], + "torusNodeRSSEndpoints": [ + "https://sapphire-dev-2-1.authnetwork.dev/rss", + "https://sapphire-dev-2-2.authnetwork.dev/rss", + "https://sapphire-dev-2-3.authnetwork.dev/rss", + "https://sapphire-dev-2-4.authnetwork.dev/rss", + "https://sapphire-dev-2-5.authnetwork.dev/rss" + ], + "torusNodeTSSEndpoints": [ + "https://sapphire-dev-2-1.authnetwork.dev/tss", + "https://sapphire-dev-2-2.authnetwork.dev/tss", + "https://sapphire-dev-2-3.authnetwork.dev/tss", + "https://sapphire-dev-2-4.authnetwork.dev/tss", + "https://sapphire-dev-2-5.authnetwork.dev/tss" + ], + "torusNodePub": [ + { + "X": "f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", + "Y": "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7" + }, + { + "X": "bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", + "Y": "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a" + }, + { + "X": "b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", + "Y": "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c" + }, + { + "X": "7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", + "Y": "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b" + }, + { + "X": "bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", + "Y": "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4" + } + ], + "torusIndexes": [ + 1, + 2, + 3, + 4, + 5 + ] +} \ No newline at end of file diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json new file mode 100644 index 0000000..c6d73d2 --- /dev/null +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json @@ -0,0 +1,60 @@ +{ + "currentEpoch": "1", + "torusNodeEndpoints": [ + "https://sapphire-1.auth.network", + "https://sapphire-2.auth.network", + "https://sapphire-3.auth.network", + "https://sapphire-4.auth.network", + "https://sapphire-5.auth.network" + ], + "torusNodeSSSEndpoints": [ + "https://sapphire-1.auth.network/sss/jrpc", + "https://sapphire-2.auth.network/sss/jrpc", + "https://sapphire-3.auth.network/sss/jrpc", + "https://sapphire-4.auth.network/sss/jrpc", + "https://sapphire-5.auth.network/sss/jrpc" + ], + "torusNodeRSSEndpoints": [ + "https://sapphire-1.auth.network/rss", + "https://sapphire-2.auth.network/rss", + "https://sapphire-3.auth.network/rss", + "https://sapphire-4.auth.network/rss", + "https://sapphire-5.auth.network/rss" + ], + "torusNodeTSSEndpoints": [ + "https://sapphire-1.auth.network/tss", + "https://sapphire-2.auth.network/tss", + "https://sapphire-3.auth.network/tss", + "https://sapphire-4.auth.network/tss", + "https://sapphire-5.auth.network/tss" + ], + "torusNodePub": [ + { + "X": "e0925898fee0e9e941fdca7ee88deec99939ae9407e923535c4d4a3a3ff8b052", + "Y": "54b9fea924e3f3e40791f9987f4234ae4222412d65b74068032fa5d8b63375c1" + }, + { + "X": "9124cf1e280aab32ba50dffd2de81cecabc13d82d2c1fe9de82f3b3523f9b637", + "Y": "fca939a1ceb42ce745c55b21ef094f543b457630cb63a94ef4f1afeee2b1f107" + }, + { + "X": "555f681a63d469cc6c3a58a97e29ebd277425f0e6159708e7c7bf05f18f89476", + "Y": "606f2bcc0884fa5b64366fc3e8362e4939841b56acd60d5f4553cf36b891ac4e" + }, + { + "X": "2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", + "Y": "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247" + }, + { + "X": "3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", + "Y": "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4" + } + ], + "torusIndexes": [ + 1, + 2, + 3, + 4, + 5 + ] +} \ No newline at end of file diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json new file mode 100644 index 0000000..8b978df --- /dev/null +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json @@ -0,0 +1,60 @@ +{ + "currentEpoch": "1", + "torusNodeEndpoints": [ + "https://sapphire-dev-2-1.authnetwork.dev", + "https://sapphire-dev-2-2.authnetwork.dev", + "https://sapphire-dev-2-3.authnetwork.dev", + "https://sapphire-dev-2-4.authnetwork.dev", + "https://sapphire-dev-2-5.authnetwork.dev" + ], + "torusNodeSSSEndpoints": [ + "https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc" + ], + "torusNodeRSSEndpoints": [ + "https://sapphire-dev-2-1.authnetwork.dev/rss", + "https://sapphire-dev-2-2.authnetwork.dev/rss", + "https://sapphire-dev-2-3.authnetwork.dev/rss", + "https://sapphire-dev-2-4.authnetwork.dev/rss", + "https://sapphire-dev-2-5.authnetwork.dev/rss" + ], + "torusNodeTSSEndpoints": [ + "https://sapphire-dev-2-1.authnetwork.dev/tss", + "https://sapphire-dev-2-2.authnetwork.dev/tss", + "https://sapphire-dev-2-3.authnetwork.dev/tss", + "https://sapphire-dev-2-4.authnetwork.dev/tss", + "https://sapphire-dev-2-5.authnetwork.dev/tss" + ], + "torusNodePub": [ + { + "X": "e0925898fee0e9e941fdca7ee88deec99939ae9407e923535c4d4a3a3ff8b052", + "Y": "54b9fea924e3f3e40791f9987f4234ae4222412d65b74068032fa5d8b63375c1" + }, + { + "X": "9124cf1e280aab32ba50dffd2de81cecabc13d82d2c1fe9de82f3b3523f9b637", + "Y": "fca939a1ceb42ce745c55b21ef094f543b457630cb63a94ef4f1afeee2b1f107" + }, + { + "X": "555f681a63d469cc6c3a58a97e29ebd277425f0e6159708e7c7bf05f18f89476", + "Y": "606f2bcc0884fa5b64366fc3e8362e4939841b56acd60d5f4553cf36b891ac4e" + }, + { + "X": "2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", + "Y": "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247" + }, + { + "X": "3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", + "Y": "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4" + } + ], + "torusIndexes": [ + 1, + 2, + 3, + 4, + 5 + ] +} \ No newline at end of file diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json index 2273d9d..509f869 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json @@ -31,5 +31,5 @@ } ], "torusIndexes": [1, 2, 3, 4, 5], - "updated": true + "updated": false } From ac6f1cba16d9af73ec574f7bab195e2b12d3598b Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 26 May 2023 13:12:54 +0530 Subject: [PATCH 04/26] code refactoring --- .../java/org/torusresearch/fetchnodedetails/types/Utils.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java index 87b13a8..c85a80e 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java @@ -64,8 +64,4 @@ public static NodeDetails fetchLocalConfig(TorusNetwork network) { } return nodeDetails; } - - public static boolean isEmpty(final CharSequence cs) { - return cs == null || cs.length() == 0; - } } From 67f9c816bbe127562c710352a8bddd2ae8e9c5d5 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 26 May 2023 13:27:30 +0530 Subject: [PATCH 05/26] code refactoring --- .../fetchnodedetails/FetchNodeDetails.java | 17 ++--------------- .../FetchNodeDetailsTest.java | 14 +++++++------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index 46782cf..f82fc1d 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -16,12 +16,6 @@ public class FetchNodeDetails { - public static String PROXY_ADDRESS_MAINNET = "0xf20336e16B5182637f09821c27BDe29b0AFcfe80"; - public static String PROXY_ADDRESS_TESTNET = "0xd084604e5FA387FbC2Da8bAab07fDD6aDED4614A"; - public static String PROXY_ADDRESS_CYAN = "0x9f072ba19b3370e512aa1b4bfcdaf97283168005"; - public static String PROXY_ADDRESS_AQUA = "0x29Dea82a0509153b91040ee13cDBba0f03efb625"; - public static String PROXY_ADDRESS_CELESTE = "0x6Bffb4e89453069E7487f0fa5c9f4a2D771cce6c"; - public static NodeDetails NODE_DETAILS_MAINNET = new NodeDetails("19", new String[]{"https://torus-19.torusnode.com/jrpc", "https://torus-node.ens.domains/jrpc", "https://torus-node.matic.network/jrpc", "https://torus.zilliqa.network/jrpc", "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", "https://torus-node.binancex.dev/jrpc", "https://torusnode.ont.io/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5"), new BigInteger("6"), new BigInteger("7"), new BigInteger("8"), new BigInteger("9"),}, new TorusNodePub[]{new TorusNodePub("bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", "82b49a7caf70def38cdad2740af45c1e4f969650105c5019a29bb18b21a9acb5"), new TorusNodePub("c208cac4ef9a47d386097a9c915b28e9cb89213abee8d26a17198ee261201b0d", "c7db2fe4631109f40833de9dc78d07e35706549ee48fa557b33e4e75e1047873"), new TorusNodePub("ca1766bb426d4ca5582818a0c5439d560ea64f5baa060793ab29dd3d0ceacfe", "d46c1d08c40e1306e1bca328c2287b8268166b11a1ba4b8442ea2ad0c5e32152"), new TorusNodePub("c3934dd2f6f4b3d2e1e398cc501e143c1e1a381b52feb6d1525af34d16253768", "71f5141a5035799099f5ea3e241e66946bc55dc857ac3bd7d6fcdb8dcd3eeeef"), new TorusNodePub("22e66f1929631d00bf026227581597f085fd94fd952fc0dca9f0833398b5c064", "6088b3912e10a1e9d50355a609c10db7d188f16a2e2fd7357e51bf4f6a74f0a1"), new TorusNodePub("9dc9fa410f3ce9eb70df70cdea00a49f2c4cc7a31c08c0dab5f863ed35ff5139", "627a291cb87a75c61da3f65d6818e1e05e360217179817ed27e8c73bca7ec122"), new TorusNodePub("118b9fc07e97b096d899b9f6658463ce6a8caa64038e37fc969df4e6023dd8c6", "baf9fa4e51770f4796ea165dd03a769b8606681a38954a0a92c4cbffd6609ce9"), new TorusNodePub("8a6d8b925da15a273dec3d8f8395ec35cd6878f274b2b180e4e106999db64043", "96f67f870c157743da0b1eb84d89bf30500d74dc84c11f501ee1cb013acc8c46"), new TorusNodePub("39cecb62e863729f572f7dfc46c24867981bf04bb405fed0df39e33984bfade5", "61c2364434012e68a2be2e9952805037e52629d7762fafc8e10e9fb5bad8f790")}, false); public static HashMap NETWORK_MAP = new HashMap() { @@ -38,24 +32,17 @@ public class FetchNodeDetails { } }; - private final String proxyAddress; private final NodeDetails nodeDetails = new NodeDetails(); - private TorusLookup torusLookup; private TorusNetwork torusNetwork = TorusNetwork.MAINNET; public FetchNodeDetails() { - this(TorusNetwork.MAINNET, "0xf20336e16B5182637f09821c27BDe29b0AFcfe80"); + this(TorusNetwork.MAINNET); } - public FetchNodeDetails(TorusNetwork network, String proxyAddress) { - this.proxyAddress = proxyAddress; + public FetchNodeDetails(TorusNetwork network) { this.torusNetwork = network; } - public FetchNodeDetails(String proxyAddress) { - this.proxyAddress = proxyAddress; - } - public CompletableFuture getNodeDetails(String verifier, String verifierId) { // For mainnet & ropsten, verifierId combination doesn't change the network details if (this.nodeDetails.getUpdated() && (this.torusNetwork.equals(TorusNetwork.MAINNET) || this.torusNetwork.equals(TorusNetwork.TESTNET) diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java index f57968a..41963d2 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java @@ -26,7 +26,7 @@ public void shouldGetNodeDetailsMainnet() throws ExecutionException, Interrupted @DisplayName("Gets the Node details for Testnet") @Test public void shouldGetNodeDetailsRopsten() throws ExecutionException, InterruptedException, UnsupportedEncodingException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.TESTNET, FetchNodeDetails.PROXY_ADDRESS_TESTNET); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.TESTNET); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.TESTNET, nodeDetails); } @@ -34,7 +34,7 @@ public void shouldGetNodeDetailsRopsten() throws ExecutionException, Interrupted @DisplayName("Gets the Node details for Cyan") @Test public void shouldGetNodeDetailsCyan() throws ExecutionException, InterruptedException, UnsupportedEncodingException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.CYAN, FetchNodeDetails.PROXY_ADDRESS_CYAN); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.CYAN); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.CYAN, nodeDetails); } @@ -42,7 +42,7 @@ public void shouldGetNodeDetailsCyan() throws ExecutionException, InterruptedExc @DisplayName("Gets the Node details for Aqua") @Test public void shouldGetNodeDetailsAqua() throws ExecutionException, InterruptedException, UnsupportedEncodingException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.AQUA, FetchNodeDetails.PROXY_ADDRESS_AQUA); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.AQUA); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.AQUA, nodeDetails); } @@ -50,7 +50,7 @@ public void shouldGetNodeDetailsAqua() throws ExecutionException, InterruptedExc @DisplayName("Gets the Node details for Celeste") @Test public void shouldGetNodeDetailsCeleste() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.CELESTE, FetchNodeDetails.PROXY_ADDRESS_CELESTE); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.CELESTE); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.CELESTE, nodeDetails); } @@ -58,7 +58,7 @@ public void shouldGetNodeDetailsCeleste() throws ExecutionException, Interrupted @DisplayName("Gets the Node details for SapphireDevnet") @Test public void shouldGetNodeDetailsSapphireDevnet() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_DEVNET, FetchNodeDetails.PROXY_ADDRESS_CELESTE); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_DEVNET); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.SAPPHIRE_DEVNET, nodeDetails); } @@ -66,7 +66,7 @@ public void shouldGetNodeDetailsSapphireDevnet() throws ExecutionException, Inte @DisplayName("Gets the Node details for SapphireTestnet") @Test public void shouldGetNodeDetailsSapphireTestnet() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_TESTNET, FetchNodeDetails.PROXY_ADDRESS_CELESTE); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_TESTNET); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.SAPPHIRE_TESTNET, nodeDetails); } @@ -74,7 +74,7 @@ public void shouldGetNodeDetailsSapphireTestnet() throws ExecutionException, Int @DisplayName("Gets the Node details for SapphireMainnet") @Test public void shouldGetNodeDetailsSapphireMainnet() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_MAINNET, FetchNodeDetails.PROXY_ADDRESS_CELESTE); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_MAINNET); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.SAPPHIRE_MAINNET, nodeDetails); } From d667a0f4da4016514ec9a1ad52642ea537869b26 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 26 May 2023 13:33:47 +0530 Subject: [PATCH 06/26] code refactoring --- .../torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java index 41963d2..329475b 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java @@ -65,6 +65,7 @@ public void shouldGetNodeDetailsSapphireDevnet() throws ExecutionException, Inte @DisplayName("Gets the Node details for SapphireTestnet") @Test + // TODO: Currently sapphire testnet is down public void shouldGetNodeDetailsSapphireTestnet() throws ExecutionException, InterruptedException { fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_TESTNET); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); From f55c81af61012cb6d7d4020d1a0280eaee65b909 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Mon, 29 May 2023 10:03:55 +0530 Subject: [PATCH 07/26] code refactoring --- .../torusresearch/fetchnodedetails/FetchNodeDetails.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index f82fc1d..6a8652f 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -11,7 +11,9 @@ import org.torusresearch.fetchnodedetails.types.Utils; import java.math.BigInteger; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.concurrent.CompletableFuture; public class FetchNodeDetails { @@ -32,6 +34,8 @@ public class FetchNodeDetails { } }; + private List multi_cluster_networks = Arrays.asList("AQUA", "CELESTE", "CYAN"); + private final NodeDetails nodeDetails = new NodeDetails(); private TorusNetwork torusNetwork = TorusNetwork.MAINNET; @@ -45,9 +49,7 @@ public FetchNodeDetails(TorusNetwork network) { public CompletableFuture getNodeDetails(String verifier, String verifierId) { // For mainnet & ropsten, verifierId combination doesn't change the network details - if (this.nodeDetails.getUpdated() && (this.torusNetwork.equals(TorusNetwork.MAINNET) || this.torusNetwork.equals(TorusNetwork.TESTNET) - || this.torusNetwork.equals(TorusNetwork.SAPPHIRE_MAINNET) || this.torusNetwork.equals(TorusNetwork.SAPPHIRE_TESTNET) || - this.torusNetwork.equals(TorusNetwork.SAPPHIRE_DEVNET))) + if (this.nodeDetails.getUpdated() && !(multi_cluster_networks.contains(this.torusNetwork.name()))) return CompletableFuture.supplyAsync(() -> this.nodeDetails); CompletableFuture cf = new CompletableFuture<>(); From 2d8d4501203d222267dd29785c370210f79fe9d8 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 30 May 2023 09:01:09 +0530 Subject: [PATCH 08/26] code refactoring --- .../torusresearch/fetchnodedetails/FetchNodeDetails.java | 2 +- .../torusresearch/fetchnodedetails/types/TorusNetwork.java | 2 +- .../fetchnodedetailstest/FetchNodeDetailsTest.java | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index 6a8652f..41c9f54 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -34,7 +34,7 @@ public class FetchNodeDetails { } }; - private List multi_cluster_networks = Arrays.asList("AQUA", "CELESTE", "CYAN"); + private List multi_cluster_networks = Arrays.asList("aqua", "celeste", "cyan"); private final NodeDetails nodeDetails = new NodeDetails(); private TorusNetwork torusNetwork = TorusNetwork.MAINNET; diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java index 3b5c4a5..04bb1de 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java @@ -7,7 +7,7 @@ public enum TorusNetwork { AQUA("aqua"), CELESTE("celeste"), SAPPHIRE_DEVNET("sapphire_devnet"), - SAPPHIRE_TESTNET("sapphire_testnet"), + SAPPHIRE_TESTNET("sapphire_devnet"), SAPPHIRE_MAINNET("sapphire_mainnet"); diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java index 329475b..b3ab91f 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java @@ -63,14 +63,13 @@ public void shouldGetNodeDetailsSapphireDevnet() throws ExecutionException, Inte assertEquals(Config.SAPPHIRE_DEVNET, nodeDetails); } - @DisplayName("Gets the Node details for SapphireTestnet") - @Test + // TODO: Currently sapphire testnet is down - public void shouldGetNodeDetailsSapphireTestnet() throws ExecutionException, InterruptedException { + /*public void shouldGetNodeDetailsSapphireTestnet() throws ExecutionException, InterruptedException { fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_TESTNET); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.SAPPHIRE_TESTNET, nodeDetails); - } + }*/ @DisplayName("Gets the Node details for SapphireMainnet") @Test From 1abeabaee1a7c747980263d90aeb1fb44276872f Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Mon, 3 Jul 2023 12:26:36 +0530 Subject: [PATCH 09/26] Updated sapphire networks configuration, modified test cases and added legacy network migration info. --- .../fetchnodedetails/FetchNodeDetails.java | 31 +++++++--- .../types/LegacyNetworkMigrationInfo.java | 27 ++++++++ .../fetchnodedetails/types/TorusNetwork.java | 11 ++-- .../types/TorusSapphireNetwork.java | 17 +++++ .../fetchnodedetails/types/Utils.java | 42 +++++++------ .../FetchNodeDetailsTest.java | 25 ++++---- .../config/sapphire_devnet.json | 10 +-- .../config/sapphire_mainnet.json | 10 +-- .../config/sapphire_testnet.json | 30 ++++----- .../fetchnodedetailstest/config/testnet.json | 62 +++++++++++++------ 10 files changed, 178 insertions(+), 87 deletions(-) create mode 100644 src/main/java/org/torusresearch/fetchnodedetails/types/LegacyNetworkMigrationInfo.java create mode 100644 src/main/java/org/torusresearch/fetchnodedetails/types/TorusSapphireNetwork.java diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index 41c9f54..0babf76 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -5,6 +5,7 @@ import org.json.JSONObject; import org.torusresearch.fetchnodedetails.types.APIUtils; import org.torusresearch.fetchnodedetails.types.FNDResponse; +import org.torusresearch.fetchnodedetails.types.LegacyNetworkMigrationInfo; import org.torusresearch.fetchnodedetails.types.NodeDetails; import org.torusresearch.fetchnodedetails.types.TorusNetwork; import org.torusresearch.fetchnodedetails.types.TorusNodePub; @@ -18,15 +19,21 @@ public class FetchNodeDetails { + public static String PROXY_ADDRESS_MAINNET = "0xf20336e16B5182637f09821c27BDe29b0AFcfe80"; + public static String PROXY_ADDRESS_TESTNET = "0xd084604e5FA387FbC2Da8bAab07fDD6aDED4614A"; + public static String PROXY_ADDRESS_CYAN = "0x9f072ba19b3370e512aa1b4bfcdaf97283168005"; + public static String PROXY_ADDRESS_AQUA = "0x29Dea82a0509153b91040ee13cDBba0f03efb625"; + public static String PROXY_ADDRESS_CELESTE = "0x6Bffb4e89453069E7487f0fa5c9f4a2D771cce6c"; + public static NodeDetails NODE_DETAILS_MAINNET = new NodeDetails("19", new String[]{"https://torus-19.torusnode.com/jrpc", "https://torus-node.ens.domains/jrpc", "https://torus-node.matic.network/jrpc", "https://torus.zilliqa.network/jrpc", "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", "https://torus-node.binancex.dev/jrpc", "https://torusnode.ont.io/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5"), new BigInteger("6"), new BigInteger("7"), new BigInteger("8"), new BigInteger("9"),}, new TorusNodePub[]{new TorusNodePub("bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", "82b49a7caf70def38cdad2740af45c1e4f969650105c5019a29bb18b21a9acb5"), new TorusNodePub("c208cac4ef9a47d386097a9c915b28e9cb89213abee8d26a17198ee261201b0d", "c7db2fe4631109f40833de9dc78d07e35706549ee48fa557b33e4e75e1047873"), new TorusNodePub("ca1766bb426d4ca5582818a0c5439d560ea64f5baa060793ab29dd3d0ceacfe", "d46c1d08c40e1306e1bca328c2287b8268166b11a1ba4b8442ea2ad0c5e32152"), new TorusNodePub("c3934dd2f6f4b3d2e1e398cc501e143c1e1a381b52feb6d1525af34d16253768", "71f5141a5035799099f5ea3e241e66946bc55dc857ac3bd7d6fcdb8dcd3eeeef"), new TorusNodePub("22e66f1929631d00bf026227581597f085fd94fd952fc0dca9f0833398b5c064", "6088b3912e10a1e9d50355a609c10db7d188f16a2e2fd7357e51bf4f6a74f0a1"), new TorusNodePub("9dc9fa410f3ce9eb70df70cdea00a49f2c4cc7a31c08c0dab5f863ed35ff5139", "627a291cb87a75c61da3f65d6818e1e05e360217179817ed27e8c73bca7ec122"), new TorusNodePub("118b9fc07e97b096d899b9f6658463ce6a8caa64038e37fc969df4e6023dd8c6", "baf9fa4e51770f4796ea165dd03a769b8606681a38954a0a92c4cbffd6609ce9"), new TorusNodePub("8a6d8b925da15a273dec3d8f8395ec35cd6878f274b2b180e4e106999db64043", "96f67f870c157743da0b1eb84d89bf30500d74dc84c11f501ee1cb013acc8c46"), new TorusNodePub("39cecb62e863729f572f7dfc46c24867981bf04bb405fed0df39e33984bfade5", "61c2364434012e68a2be2e9952805037e52629d7762fafc8e10e9fb5bad8f790")}, false); public static HashMap NETWORK_MAP = new HashMap() { { - put(TorusNetwork.MAINNET, "mainnet"); - put(TorusNetwork.TESTNET, "goerli"); - put(TorusNetwork.CYAN, "polygon-mainnet"); - put(TorusNetwork.AQUA, "polygon-mainnet"); - put(TorusNetwork.CELESTE, "polygon-mainnet"); + put(TorusNetwork.LEGACY_MAINNET, "mainnet"); + put(TorusNetwork.LEGACY_TESTNET, "goerli"); + put(TorusNetwork.LEGACY_CYAN, "polygon-mainnet"); + put(TorusNetwork.LEGACY_AQUA, "polygon-mainnet"); + put(TorusNetwork.LEGACY_CELESTE, "polygon-mainnet"); put(TorusNetwork.SAPPHIRE_DEVNET, "sapphire_devnet"); put(TorusNetwork.SAPPHIRE_TESTNET, "sapphire_testnet"); put(TorusNetwork.SAPPHIRE_MAINNET, "sapphire_mainnet"); @@ -34,13 +41,23 @@ public class FetchNodeDetails { } }; + public static HashMap LEGACY_NETWORKS_ROUTE_MAP = new HashMap() { + { + put(TorusNetwork.LEGACY_AQUA, new LegacyNetworkMigrationInfo(false, "aqua", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.LEGACY_CELESTE, new LegacyNetworkMigrationInfo(false, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.LEGACY_CYAN, new LegacyNetworkMigrationInfo(false, "cyan", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.LEGACY_MAINNET, new LegacyNetworkMigrationInfo(false, "mainnet", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.LEGACY_TESTNET, new LegacyNetworkMigrationInfo(true, "teal", TorusNetwork.SAPPHIRE_TESTNET)); + } + }; + private List multi_cluster_networks = Arrays.asList("aqua", "celeste", "cyan"); private final NodeDetails nodeDetails = new NodeDetails(); - private TorusNetwork torusNetwork = TorusNetwork.MAINNET; + private TorusNetwork torusNetwork = TorusNetwork.LEGACY_MAINNET; public FetchNodeDetails() { - this(TorusNetwork.MAINNET); + this(TorusNetwork.LEGACY_MAINNET); } public FetchNodeDetails(TorusNetwork network) { diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/LegacyNetworkMigrationInfo.java b/src/main/java/org/torusresearch/fetchnodedetails/types/LegacyNetworkMigrationInfo.java new file mode 100644 index 0000000..d5418b5 --- /dev/null +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/LegacyNetworkMigrationInfo.java @@ -0,0 +1,27 @@ +package org.torusresearch.fetchnodedetails.types; + +public class LegacyNetworkMigrationInfo { + + private Boolean migrationCompleted = false; + private String networkIdentifier; + private TorusNetwork networkMigratedTo; + + + public LegacyNetworkMigrationInfo(Boolean migrationCompleted, String networkIdentifier, TorusNetwork networkMigratedTo) { + this.migrationCompleted = migrationCompleted; + this.networkIdentifier = networkIdentifier; + this.networkMigratedTo = networkMigratedTo; + } + + public Boolean getMigrationCompleted() { + return migrationCompleted; + } + + public String getNetworkIdentifier() { + return networkIdentifier; + } + + public TorusNetwork getNetworkMigratedTo() { + return networkMigratedTo; + } +} diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java index 04bb1de..aee64be 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java @@ -1,16 +1,15 @@ package org.torusresearch.fetchnodedetails.types; public enum TorusNetwork { - MAINNET("mainnet"), - TESTNET("testnet"), - CYAN("cyan"), - AQUA("aqua"), - CELESTE("celeste"), + LEGACY_MAINNET("mainnet"), + LEGACY_TESTNET("testnet"), + LEGACY_CYAN("cyan"), + LEGACY_AQUA("aqua"), + LEGACY_CELESTE("celeste"), SAPPHIRE_DEVNET("sapphire_devnet"), SAPPHIRE_TESTNET("sapphire_devnet"), SAPPHIRE_MAINNET("sapphire_mainnet"); - private final String val; TorusNetwork(String s) { diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusSapphireNetwork.java b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusSapphireNetwork.java new file mode 100644 index 0000000..1eba688 --- /dev/null +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusSapphireNetwork.java @@ -0,0 +1,17 @@ +package org.torusresearch.fetchnodedetails.types; + +public enum TorusSapphireNetwork { + SAPPHIRE_DEVNET("sapphire_devnet"), + SAPPHIRE_TESTNET("sapphire_devnet"), + SAPPHIRE_MAINNET("sapphire_mainnet"); + + private final String val; + + TorusSapphireNetwork(String s) { + this.val = s; + } + + public String toString() { + return val; + } +} diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java index c85a80e..8e6f9ea 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java @@ -6,13 +6,19 @@ public class Utils { public static NodeDetails NODE_DETAILS_MAINNET = new NodeDetails("19", new String[]{"https://torus-19.torusnode.com/jrpc", "https://torus-node.ens.domains/jrpc", "https://torus-node.matic.network/jrpc", "https://torus.zilliqa.network/jrpc", "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", "https://torus-node.binancex.dev/jrpc", "https://torusnode.ont.io/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5"), new BigInteger("6"), new BigInteger("7"), new BigInteger("8"), new BigInteger("9"),}, new TorusNodePub[]{new TorusNodePub("bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", "82b49a7caf70def38cdad2740af45c1e4f969650105c5019a29bb18b21a9acb5"), new TorusNodePub("c208cac4ef9a47d386097a9c915b28e9cb89213abee8d26a17198ee261201b0d", "c7db2fe4631109f40833de9dc78d07e35706549ee48fa557b33e4e75e1047873"), new TorusNodePub("ca1766bb426d4ca5582818a0c5439d560ea64f5baa060793ab29dd3d0ceacfe", "d46c1d08c40e1306e1bca328c2287b8268166b11a1ba4b8442ea2ad0c5e32152"), new TorusNodePub("c3934dd2f6f4b3d2e1e398cc501e143c1e1a381b52feb6d1525af34d16253768", "71f5141a5035799099f5ea3e241e66946bc55dc857ac3bd7d6fcdb8dcd3eeeef"), new TorusNodePub("22e66f1929631d00bf026227581597f085fd94fd952fc0dca9f0833398b5c064", "6088b3912e10a1e9d50355a609c10db7d188f16a2e2fd7357e51bf4f6a74f0a1"), new TorusNodePub("9dc9fa410f3ce9eb70df70cdea00a49f2c4cc7a31c08c0dab5f863ed35ff5139", "627a291cb87a75c61da3f65d6818e1e05e360217179817ed27e8c73bca7ec122"), new TorusNodePub("118b9fc07e97b096d899b9f6658463ce6a8caa64038e37fc969df4e6023dd8c6", "baf9fa4e51770f4796ea165dd03a769b8606681a38954a0a92c4cbffd6609ce9"), new TorusNodePub("8a6d8b925da15a273dec3d8f8395ec35cd6878f274b2b180e4e106999db64043", "96f67f870c157743da0b1eb84d89bf30500d74dc84c11f501ee1cb013acc8c46"), new TorusNodePub("39cecb62e863729f572f7dfc46c24867981bf04bb405fed0df39e33984bfade5", "61c2364434012e68a2be2e9952805037e52629d7762fafc8e10e9fb5bad8f790")}, false); - public static NodeDetails NODE_DETAILS_TESTNET = new NodeDetails("15", new String[]{"https://teal-15-1.torusnode.com/jrpc", - "https://teal-15-3.torusnode.com/jrpc", - "https://teal-15-4.torusnode.com/jrpc", - "https://teal-15-5.torusnode.com/jrpc", - "https://teal-15-2.torusnode.com/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, new TorusNodePub[]{new TorusNodePub("1363aad8868cacd7f8946c590325cd463106fb3731f08811ab4302d2deae35c3", "d77eebe5cdf466b475ec892d5b4cffbe0c1670525debbd97eee6dae2f87a7cbe"), new TorusNodePub("7c8cc521c48690f016bea593f67f88ad24f447dd6c31bbab541e59e207bf029d", "b359f0a82608db2e06b953b36d0c9a473a00458117ca32a5b0f4563a7d539636"), new TorusNodePub("8a86543ca17df5687719e2549caa024cf17fe0361e119e741eaee668f8dd0a6f", "9cdb254ff915a76950d6d13d78ef054d5d0dc34e2908c00bb009a6e4da701891"), new TorusNodePub("25a98d9ae006aed1d77e81d58be8f67193d13d01a9888e2923841894f4b0bf9c", "f63d40df480dacf68922004ed36dbab9e2969181b047730a5ce0797fb6958249"), new TorusNodePub("d908f41f8e06324a8a7abcf702adb6a273ce3ae63d86a3d22723e1bbf1438c9a", "d908f41f8e06324a8a7abcf702adb6a273ce3ae63d86a3d22723e1bbf1438c9a")}, false); + public static NodeDetails NODE_DETAILS_TESTNET = new NodeDetails("1", new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc",}, + new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc"}, + new String[]{"https://sapphire-dev-2-1.authnetwork.dev/rss/teal", "https://sapphire-dev-2-2.authnetwork.dev/rss/teal", "https://sapphire-dev-2-3.authnetwork.dev/rss/teal", "https://sapphire-dev-2-4.authnetwork.dev/rss/teal", "https://sapphire-dev-2-5.authnetwork.dev/rss/teal"}, + new String[]{"https://sapphire-dev-2-1.authnetwork.dev/tss/teal", "https://sapphire-dev-2-2.authnetwork.dev/tss/teal", "https://sapphire-dev-2-3.authnetwork.dev/tss/teal", "https://sapphire-dev-2-4.authnetwork.dev/tss/teal", "https://sapphire-dev-2-5.authnetwork.dev/tss/teal"}, + new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, + new TorusNodePub[]{new TorusNodePub("f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7"), + new TorusNodePub("bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a"), + new TorusNodePub("b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c"), + new TorusNodePub("7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b"), + new TorusNodePub("bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4")}, + false); - public static NodeDetails NODE_DETAILS_SAPPHIRE_MAINNET = new NodeDetails("1", new String[]{"https://sapphire-1.auth.network", "https://sapphire-2.auth.network", "https://sapphire-3.auth.network", "https://sapphire-4.auth.network", "https://sapphire-5.auth.network"}, + public static NodeDetails NODE_DETAILS_SAPPHIRE_MAINNET = new NodeDetails("1", new String[]{"https://sapphire-1.auth.network/sss/jrpc", "https://sapphire-2.auth.network/sss/jrpc", "https://sapphire-3.auth.network/sss/jrpc", "https://sapphire-4.auth.network/sss/jrpc", "https://sapphire-5.auth.network/sss/jrpc"}, new String[]{"https://sapphire-1.auth.network/sss/jrpc", "https://sapphire-2.auth.network/sss/jrpc", "https://sapphire-3.auth.network/sss/jrpc", "https://sapphire-4.auth.network/sss/jrpc", "https://sapphire-5.auth.network/sss/jrpc"}, new String[]{"https://sapphire-1.auth.network/rss", "https://sapphire-2.auth.network/rss", "https://sapphire-3.auth.network/rss", "https://sapphire-4.auth.network/rss", "https://sapphire-5.auth.network/rss"}, new String[]{"https://sapphire-1.auth.network/tss", "https://sapphire-2.auth.network/tss", "https://sapphire-3.auth.network/tss", "https://sapphire-4.auth.network/tss", "https://sapphire-5.auth.network/tss"}, @@ -24,19 +30,19 @@ public class Utils { new TorusNodePub("3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4")}, true); - public static NodeDetails NODE_DETAILS_SAPPHIRE_TESTNET = new NodeDetails("1", new String[]{"https://lrc1.authnetwork.dev", "https://lrc2.authnetwork.dev", "https://lrc3.authnetwork.dev", "https://lrc4.authnetwork.dev", "https://lrc5.authnetwork.dev",}, - new String[]{"https://lrc1.authnetwork.dev/sss/jrpc", "https://lrc2.authnetwork.dev/sss/jrpc", "https://lrc3.authnetwork.dev/sss/jrpc", "https://lrc4.authnetwork.dev/sss/jrpc", "https://lrc5.authnetwork.dev/sss/jrpc"}, - new String[]{"https://lrc1.authnetwork.dev/rss", "https://lrc2.authnetwork.dev/rss", "https://lrc3.authnetwork.dev/rss", "https://lrc4.authnetwork.dev/rss", "https://lrc5.authnetwork.dev/rss"}, - new String[]{"https://lrc1.authnetwork.dev/tss", "https://lrc2.authnetwork.dev/tss", "https://lrc3.authnetwork.dev/tss", "https://lrc4.authnetwork.dev/tss", "https://lrc5.authnetwork.dev/tss"}, + public static NodeDetails NODE_DETAILS_SAPPHIRE_TESTNET = new NodeDetails("1", new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc",}, + new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc"}, + new String[]{"https://sapphire-dev-2-1.authnetwork.dev/rss", "https://sapphire-dev-2-2.authnetwork.dev/rss", "https://sapphire-dev-2-3.authnetwork.dev/rss", "https://sapphire-dev-2-4.authnetwork.dev/rss", "https://sapphire-dev-2-5.authnetwork.dev/rss"}, + new String[]{"https://sapphire-dev-2-1.authnetwork.dev/tss", "https://sapphire-dev-2-2.authnetwork.dev/tss", "https://sapphire-dev-2-3.authnetwork.dev/tss", "https://sapphire-dev-2-4.authnetwork.dev/tss", "https://sapphire-dev-2-5.authnetwork.dev/tss"}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, - new TorusNodePub[]{new TorusNodePub("d0e57d0fb29f37888a71c5d1d8312b191121b53e7e77968ca59e5c2ceee89386", "2190e5e78c02ecdd4e5e04a01d3c12d847d53682ade7b6f715df1e1f3911081d"), - new TorusNodePub("69d4fcd1ab4dedc06ac0bafaccac8e5459275ec12a8b3feaef26646ece902e38", "2319469c4344d78140ed9672c5231a0d045467dec66c77b53dfbefc56496ff3c"), - new TorusNodePub("9b0ea52ef5d8fc68e02b3ea242b2b11556ab5746b92779a7c4d61ff57c054710", "0f9fc9e706e0a2d2b5c8511177583cdf5fa5379e2c3c1ed4db74aaded08b1a28"), - new TorusNodePub("e08bb1de0c017241be3c8e2ab3e788b64cb83d77ddd5517424626d1e3a4a5406", "d4a87ae195e1f55fe4751caf22123d495cc4b51df48f234c956262fd1d8baafc"), - new TorusNodePub("29154aaa5b76bdb5082ea9616769f1940e56de5c6d8afb8cc75fbd228302d961", "3535fb808e205f5589ca2dd28014103771266148ebc372f364dae0f3905dd811")}, + new TorusNodePub[]{new TorusNodePub("f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7"), + new TorusNodePub("bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a"), + new TorusNodePub("b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c"), + new TorusNodePub("7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b"), + new TorusNodePub("bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4")}, true); - public static NodeDetails NODE_DETAILS_SAPPHIRE_DEVNET = new NodeDetails("1", new String[]{"https://sapphire-dev-2-1.authnetwork.dev", "https://sapphire-dev-2-2.authnetwork.dev", "https://sapphire-dev-2-3.authnetwork.dev", "https://sapphire-dev-2-4.authnetwork.dev", "https://sapphire-dev-2-5.authnetwork.dev"}, + public static NodeDetails NODE_DETAILS_SAPPHIRE_DEVNET = new NodeDetails("1", new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc"}, new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc"}, new String[]{"https://sapphire-dev-2-1.authnetwork.dev/rss", "https://sapphire-dev-2-2.authnetwork.dev/rss", "https://sapphire-dev-2-3.authnetwork.dev/rss", "https://sapphire-dev-2-4.authnetwork.dev/rss", "https://sapphire-dev-2-5.authnetwork.dev/rss"}, new String[]{"https://sapphire-dev-2-1.authnetwork.dev/tss", "https://sapphire-dev-2-2.authnetwork.dev/tss", "https://sapphire-dev-2-3.authnetwork.dev/tss", "https://sapphire-dev-2-4.authnetwork.dev/tss", "https://sapphire-dev-2-5.authnetwork.dev/tss"}, @@ -57,9 +63,9 @@ public static NodeDetails fetchLocalConfig(TorusNetwork network) { nodeDetails = NODE_DETAILS_SAPPHIRE_TESTNET; case SAPPHIRE_MAINNET: nodeDetails = NODE_DETAILS_SAPPHIRE_MAINNET; - case MAINNET: + case LEGACY_MAINNET: nodeDetails = NODE_DETAILS_MAINNET; - case TESTNET: + case LEGACY_TESTNET: nodeDetails = NODE_DETAILS_TESTNET; } return nodeDetails; diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java index b3ab91f..f43e11b 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java @@ -9,7 +9,6 @@ import org.torusresearch.fetchnodedetails.types.TorusNetwork; import org.torusresearch.fetchnodedetailstest.config.Config; -import java.io.UnsupportedEncodingException; import java.util.concurrent.ExecutionException; class FetchNodeDetailsTest { @@ -17,7 +16,7 @@ class FetchNodeDetailsTest { @DisplayName("Gets the Node details for Mainnet") @Test - public void shouldGetNodeDetailsMainnet() throws ExecutionException, InterruptedException, UnsupportedEncodingException { + public void shouldGetNodeDetailsMainnet() throws ExecutionException, InterruptedException { fetchNodeDetails = new FetchNodeDetails(); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.MAINNET, nodeDetails); @@ -25,24 +24,24 @@ public void shouldGetNodeDetailsMainnet() throws ExecutionException, Interrupted @DisplayName("Gets the Node details for Testnet") @Test - public void shouldGetNodeDetailsRopsten() throws ExecutionException, InterruptedException, UnsupportedEncodingException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.TESTNET); + public void shouldGetNodeDetailsRopsten() throws ExecutionException, InterruptedException { + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.LEGACY_TESTNET); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.TESTNET, nodeDetails); } @DisplayName("Gets the Node details for Cyan") @Test - public void shouldGetNodeDetailsCyan() throws ExecutionException, InterruptedException, UnsupportedEncodingException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.CYAN); + public void shouldGetNodeDetailsCyan() throws ExecutionException, InterruptedException { + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.LEGACY_CYAN); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.CYAN, nodeDetails); } @DisplayName("Gets the Node details for Aqua") @Test - public void shouldGetNodeDetailsAqua() throws ExecutionException, InterruptedException, UnsupportedEncodingException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.AQUA); + public void shouldGetNodeDetailsAqua() throws ExecutionException, InterruptedException { + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.LEGACY_AQUA); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.AQUA, nodeDetails); } @@ -50,7 +49,7 @@ public void shouldGetNodeDetailsAqua() throws ExecutionException, InterruptedExc @DisplayName("Gets the Node details for Celeste") @Test public void shouldGetNodeDetailsCeleste() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.CELESTE); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.LEGACY_CELESTE); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.CELESTE, nodeDetails); } @@ -63,13 +62,13 @@ public void shouldGetNodeDetailsSapphireDevnet() throws ExecutionException, Inte assertEquals(Config.SAPPHIRE_DEVNET, nodeDetails); } - - // TODO: Currently sapphire testnet is down - /*public void shouldGetNodeDetailsSapphireTestnet() throws ExecutionException, InterruptedException { + @DisplayName("Gets the Node details for SapphireTestnet") + @Test + public void shouldGetNodeDetailsSapphireTestnet() throws ExecutionException, InterruptedException { fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_TESTNET); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.SAPPHIRE_TESTNET, nodeDetails); - }*/ + } @DisplayName("Gets the Node details for SapphireMainnet") @Test diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json index 9d3e2e5..0876fa8 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json @@ -1,11 +1,11 @@ { "currentEpoch": "1", "torusNodeEndpoints": [ - "https://sapphire-dev-2-1.authnetwork.dev", - "https://sapphire-dev-2-2.authnetwork.dev", - "https://sapphire-dev-2-3.authnetwork.dev", - "https://sapphire-dev-2-4.authnetwork.dev", - "https://sapphire-dev-2-5.authnetwork.dev" + "https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc" ], "torusNodeSSSEndpoints": [ "https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json index c6d73d2..fd038bd 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json @@ -1,11 +1,11 @@ { "currentEpoch": "1", "torusNodeEndpoints": [ - "https://sapphire-1.auth.network", - "https://sapphire-2.auth.network", - "https://sapphire-3.auth.network", - "https://sapphire-4.auth.network", - "https://sapphire-5.auth.network" + "https://sapphire-1.auth.network/sss/jrpc", + "https://sapphire-2.auth.network/sss/jrpc", + "https://sapphire-3.auth.network/sss/jrpc", + "https://sapphire-4.auth.network/sss/jrpc", + "https://sapphire-5.auth.network/sss/jrpc" ], "torusNodeSSSEndpoints": [ "https://sapphire-1.auth.network/sss/jrpc", diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json index 8b978df..0876fa8 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json @@ -1,11 +1,11 @@ { "currentEpoch": "1", "torusNodeEndpoints": [ - "https://sapphire-dev-2-1.authnetwork.dev", - "https://sapphire-dev-2-2.authnetwork.dev", - "https://sapphire-dev-2-3.authnetwork.dev", - "https://sapphire-dev-2-4.authnetwork.dev", - "https://sapphire-dev-2-5.authnetwork.dev" + "https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", + "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc" ], "torusNodeSSSEndpoints": [ "https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", @@ -30,24 +30,24 @@ ], "torusNodePub": [ { - "X": "e0925898fee0e9e941fdca7ee88deec99939ae9407e923535c4d4a3a3ff8b052", - "Y": "54b9fea924e3f3e40791f9987f4234ae4222412d65b74068032fa5d8b63375c1" + "X": "f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", + "Y": "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7" }, { - "X": "9124cf1e280aab32ba50dffd2de81cecabc13d82d2c1fe9de82f3b3523f9b637", - "Y": "fca939a1ceb42ce745c55b21ef094f543b457630cb63a94ef4f1afeee2b1f107" + "X": "bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", + "Y": "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a" }, { - "X": "555f681a63d469cc6c3a58a97e29ebd277425f0e6159708e7c7bf05f18f89476", - "Y": "606f2bcc0884fa5b64366fc3e8362e4939841b56acd60d5f4553cf36b891ac4e" + "X": "b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", + "Y": "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c" }, { - "X": "2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", - "Y": "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247" + "X": "7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", + "Y": "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b" }, { - "X": "3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", - "Y": "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4" + "X": "bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", + "Y": "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4" } ], "torusIndexes": [ diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json index 509f869..b2b4db5 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json @@ -1,35 +1,61 @@ { - "currentEpoch": "15", - "nodeListAddress": "0xd084604e5FA387FbC2Da8bAab07fDD6aDED4614A", + "currentEpoch": "1", "torusNodeEndpoints": [ - "https://teal-15-1.torusnode.com/jrpc", - "https://teal-15-3.torusnode.com/jrpc", - "https://teal-15-4.torusnode.com/jrpc", - "https://teal-15-5.torusnode.com/jrpc", - "https://teal-15-2.torusnode.com/jrpc" + "https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", + "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", + "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", + "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", + "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc" + ], + "torusNodeSSSEndpoints": [ + "https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", + "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", + "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", + "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", + "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc" + ], + "torusNodeRSSEndpoints": [ + "https://sapphire-dev-2-1.authnetwork.dev/rss/teal", + "https://sapphire-dev-2-2.authnetwork.dev/rss/teal", + "https://sapphire-dev-2-3.authnetwork.dev/rss/teal", + "https://sapphire-dev-2-4.authnetwork.dev/rss/teal", + "https://sapphire-dev-2-5.authnetwork.dev/rss/teal" + ], + "torusNodeTSSEndpoints": [ + "https://sapphire-dev-2-1.authnetwork.dev/tss/teal", + "https://sapphire-dev-2-2.authnetwork.dev/tss/teal", + "https://sapphire-dev-2-3.authnetwork.dev/tss/teal", + "https://sapphire-dev-2-4.authnetwork.dev/tss/teal", + "https://sapphire-dev-2-5.authnetwork.dev/tss/teal" ], "torusNodePub": [ { - "X": "1363aad8868cacd7f8946c590325cd463106fb3731f08811ab4302d2deae35c3", - "Y": "d77eebe5cdf466b475ec892d5b4cffbe0c1670525debbd97eee6dae2f87a7cbe" + "X": "f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", + "Y": "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7" }, { - "X": "7c8cc521c48690f016bea593f67f88ad24f447dd6c31bbab541e59e207bf029d", - "Y": "b359f0a82608db2e06b953b36d0c9a473a00458117ca32a5b0f4563a7d539636" + "X": "bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", + "Y": "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a" }, { - "X": "8a86543ca17df5687719e2549caa024cf17fe0361e119e741eaee668f8dd0a6f", - "Y": "9cdb254ff915a76950d6d13d78ef054d5d0dc34e2908c00bb009a6e4da701891" + "X": "b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", + "Y": "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c" }, { - "X": "25a98d9ae006aed1d77e81d58be8f67193d13d01a9888e2923841894f4b0bf9c", - "Y": "f63d40df480dacf68922004ed36dbab9e2969181b047730a5ce0797fb6958249" + "X": "7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", + "Y": "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b" }, { - "X": "d908f41f8e06324a8a7abcf702adb6a273ce3ae63d86a3d22723e1bbf1438c9a", - "Y": "f977530b3ec0e525438c72d1e768380cbc5fb3b38a760ee925053b2e169428ce" + "X": "bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", + "Y": "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4" } ], - "torusIndexes": [1, 2, 3, 4, 5], + "torusIndexes": [ + 1, + 2, + 3, + 4, + 5 + ], "updated": false } From b6f3e302e077789fc68be0d13ea909770dc9abc0 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Mon, 3 Jul 2023 12:30:56 +0530 Subject: [PATCH 10/26] code refactoring --- .../types/TorusSapphireNetwork.java | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 src/main/java/org/torusresearch/fetchnodedetails/types/TorusSapphireNetwork.java diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusSapphireNetwork.java b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusSapphireNetwork.java deleted file mode 100644 index 1eba688..0000000 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusSapphireNetwork.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.torusresearch.fetchnodedetails.types; - -public enum TorusSapphireNetwork { - SAPPHIRE_DEVNET("sapphire_devnet"), - SAPPHIRE_TESTNET("sapphire_devnet"), - SAPPHIRE_MAINNET("sapphire_mainnet"); - - private final String val; - - TorusSapphireNetwork(String s) { - this.val = s; - } - - public String toString() { - return val; - } -} From 6ea77689634fd75a618f5a73cd34f5ea94b9a67f Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Mon, 3 Jul 2023 13:27:06 +0530 Subject: [PATCH 11/26] code refactoring --- .../fetchnodedetails/FetchNodeDetails.java | 26 +++++++++---------- .../fetchnodedetails/types/TorusNetwork.java | 10 +++---- .../fetchnodedetails/types/Utils.java | 4 +-- .../FetchNodeDetailsTest.java | 8 +++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index 0babf76..0b6f57c 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -29,11 +29,11 @@ public class FetchNodeDetails { public static HashMap NETWORK_MAP = new HashMap() { { - put(TorusNetwork.LEGACY_MAINNET, "mainnet"); - put(TorusNetwork.LEGACY_TESTNET, "goerli"); - put(TorusNetwork.LEGACY_CYAN, "polygon-mainnet"); - put(TorusNetwork.LEGACY_AQUA, "polygon-mainnet"); - put(TorusNetwork.LEGACY_CELESTE, "polygon-mainnet"); + put(TorusNetwork.MAINNET, "mainnet"); + put(TorusNetwork.TESTNET, "goerli"); + put(TorusNetwork.CYAN, "polygon-mainnet"); + put(TorusNetwork.AQUA, "polygon-mainnet"); + put(TorusNetwork.CELESTE, "polygon-mainnet"); put(TorusNetwork.SAPPHIRE_DEVNET, "sapphire_devnet"); put(TorusNetwork.SAPPHIRE_TESTNET, "sapphire_testnet"); put(TorusNetwork.SAPPHIRE_MAINNET, "sapphire_mainnet"); @@ -41,23 +41,23 @@ public class FetchNodeDetails { } }; - public static HashMap LEGACY_NETWORKS_ROUTE_MAP = new HashMap() { + public static HashMap NETWORKS_ROUTE_MAP = new HashMap() { { - put(TorusNetwork.LEGACY_AQUA, new LegacyNetworkMigrationInfo(false, "aqua", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.LEGACY_CELESTE, new LegacyNetworkMigrationInfo(false, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.LEGACY_CYAN, new LegacyNetworkMigrationInfo(false, "cyan", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.LEGACY_MAINNET, new LegacyNetworkMigrationInfo(false, "mainnet", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.LEGACY_TESTNET, new LegacyNetworkMigrationInfo(true, "teal", TorusNetwork.SAPPHIRE_TESTNET)); + put(TorusNetwork.AQUA, new LegacyNetworkMigrationInfo(false, "aqua", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.CELESTE, new LegacyNetworkMigrationInfo(false, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.CYAN, new LegacyNetworkMigrationInfo(false, "cyan", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.MAINNET, new LegacyNetworkMigrationInfo(false, "mainnet", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.TESTNET, new LegacyNetworkMigrationInfo(true, "teal", TorusNetwork.SAPPHIRE_TESTNET)); } }; private List multi_cluster_networks = Arrays.asList("aqua", "celeste", "cyan"); private final NodeDetails nodeDetails = new NodeDetails(); - private TorusNetwork torusNetwork = TorusNetwork.LEGACY_MAINNET; + private TorusNetwork torusNetwork = TorusNetwork.MAINNET; public FetchNodeDetails() { - this(TorusNetwork.LEGACY_MAINNET); + this(TorusNetwork.MAINNET); } public FetchNodeDetails(TorusNetwork network) { diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java index aee64be..be7eba4 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java @@ -1,11 +1,11 @@ package org.torusresearch.fetchnodedetails.types; public enum TorusNetwork { - LEGACY_MAINNET("mainnet"), - LEGACY_TESTNET("testnet"), - LEGACY_CYAN("cyan"), - LEGACY_AQUA("aqua"), - LEGACY_CELESTE("celeste"), + MAINNET("mainnet"), + TESTNET("testnet"), + CYAN("cyan"), + AQUA("aqua"), + CELESTE("celeste"), SAPPHIRE_DEVNET("sapphire_devnet"), SAPPHIRE_TESTNET("sapphire_devnet"), SAPPHIRE_MAINNET("sapphire_mainnet"); diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java index 8e6f9ea..1d0d0f7 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java @@ -63,9 +63,9 @@ public static NodeDetails fetchLocalConfig(TorusNetwork network) { nodeDetails = NODE_DETAILS_SAPPHIRE_TESTNET; case SAPPHIRE_MAINNET: nodeDetails = NODE_DETAILS_SAPPHIRE_MAINNET; - case LEGACY_MAINNET: + case MAINNET: nodeDetails = NODE_DETAILS_MAINNET; - case LEGACY_TESTNET: + case TESTNET: nodeDetails = NODE_DETAILS_TESTNET; } return nodeDetails; diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java index f43e11b..a751e6a 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java @@ -25,7 +25,7 @@ public void shouldGetNodeDetailsMainnet() throws ExecutionException, Interrupted @DisplayName("Gets the Node details for Testnet") @Test public void shouldGetNodeDetailsRopsten() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.LEGACY_TESTNET); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.TESTNET); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.TESTNET, nodeDetails); } @@ -33,7 +33,7 @@ public void shouldGetNodeDetailsRopsten() throws ExecutionException, Interrupted @DisplayName("Gets the Node details for Cyan") @Test public void shouldGetNodeDetailsCyan() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.LEGACY_CYAN); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.CYAN); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.CYAN, nodeDetails); } @@ -41,7 +41,7 @@ public void shouldGetNodeDetailsCyan() throws ExecutionException, InterruptedExc @DisplayName("Gets the Node details for Aqua") @Test public void shouldGetNodeDetailsAqua() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.LEGACY_AQUA); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.AQUA); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.AQUA, nodeDetails); } @@ -49,7 +49,7 @@ public void shouldGetNodeDetailsAqua() throws ExecutionException, InterruptedExc @DisplayName("Gets the Node details for Celeste") @Test public void shouldGetNodeDetailsCeleste() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.LEGACY_CELESTE); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.CELESTE); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.CELESTE, nodeDetails); } From be65b95d62b895b35c0d4caad9ac6f7b47b1083a Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Mon, 3 Jul 2023 17:28:31 +0530 Subject: [PATCH 12/26] Added legacy support in FetchNodeDetails.java --- .../fetchnodedetails/FetchNodeDetails.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index 0b6f57c..df92a34 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -7,11 +7,18 @@ import org.torusresearch.fetchnodedetails.types.FNDResponse; import org.torusresearch.fetchnodedetails.types.LegacyNetworkMigrationInfo; import org.torusresearch.fetchnodedetails.types.NodeDetails; +import org.torusresearch.fetchnodedetails.types.NodeInfo; import org.torusresearch.fetchnodedetails.types.TorusNetwork; import org.torusresearch.fetchnodedetails.types.TorusNodePub; import org.torusresearch.fetchnodedetails.types.Utils; +import org.web3j.crypto.Credentials; +import org.web3j.crypto.Hash; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.http.HttpService; +import org.web3j.tx.gas.DefaultGasProvider; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -53,6 +60,9 @@ public class FetchNodeDetails { private List multi_cluster_networks = Arrays.asList("aqua", "celeste", "cyan"); + private String proxyAddress; + private String providerUrl; + private TorusLookup torusLookup; private final NodeDetails nodeDetails = new NodeDetails(); private TorusNetwork torusNetwork = TorusNetwork.MAINNET; @@ -60,10 +70,62 @@ public FetchNodeDetails() { this(TorusNetwork.MAINNET); } + public FetchNodeDetails(TorusNetwork network, String proxyAddress) { + this.proxyAddress = proxyAddress; + this.torusNetwork = network; + this.providerUrl = "https://" + NETWORK_MAP.get(network) + ".infura.io/v3/" + "b8cdb0e4cff24599a286bf8e87ff1c96"; + this.setupWeb3(); + } + + public FetchNodeDetails(String providerUrl, String proxyAddress) { + this.proxyAddress = proxyAddress; + this.providerUrl = providerUrl; + this.setupWeb3(); + } + public FetchNodeDetails(TorusNetwork network) { this.torusNetwork = network; } + public CompletableFuture getLegacyNodeDetails(String verifier, String verifierId) { + // For mainnet & ropsten, verifierId combination doesn't change the network details + if (this.nodeDetails.getUpdated() && (this.proxyAddress.equals(PROXY_ADDRESS_MAINNET) || this.proxyAddress.equals(PROXY_ADDRESS_TESTNET))) + return CompletableFuture.supplyAsync(() -> this.nodeDetails); + byte[] hashedVerifierId = Hash.sha3(verifierId.getBytes(StandardCharsets.UTF_8)); + CompletableFuture cf = new CompletableFuture<>(); + this.torusLookup.getNodeSet(verifier, hashedVerifierId).sendAsync().whenCompleteAsync((nodeEndPoints, err) -> { + if (err != null) { + if (this.proxyAddress.equals(FetchNodeDetails.PROXY_ADDRESS_MAINNET)) { + cf.complete(FetchNodeDetails.NODE_DETAILS_MAINNET); + } else { + cf.completeExceptionally(err); + } + return; + } + try { + String[] updatedEndpoints = new String[nodeEndPoints.component3().size()]; + TorusNodePub[] updatedNodePub = new TorusNodePub[nodeEndPoints.component3().size()]; + + for (int i = 0; i < nodeEndPoints.component3().size(); i++) { + NodeInfo endPointElement = new NodeInfo(String.valueOf(nodeEndPoints.component2().get(i)), new BigInteger(String.valueOf(nodeEndPoints.component3().get(i)), 10).toString(16).replace("0x", ""), new BigInteger(String.valueOf(nodeEndPoints.component4().get(i)), 10).toString(16).replace("0x", "")); + + String endpoint = "https://" + endPointElement.getDeclaredIp().split(":")[0] + "/jrpc"; + updatedEndpoints[i] = endpoint; + updatedNodePub[i] = new TorusNodePub(endPointElement.getPubKx(), endPointElement.getPubKy()); + } + this.nodeDetails.setCurrentEpoch(nodeEndPoints.component1().toString()); + this.nodeDetails.setTorusNodeEndpoints(updatedEndpoints); + this.nodeDetails.setTorusNodePub(updatedNodePub); + this.nodeDetails.setTorusIndexes(nodeEndPoints.component5().toArray(new BigInteger[0])); + this.nodeDetails.setUpdated(true); + cf.complete(this.nodeDetails); + } catch (Exception err2) { + cf.completeExceptionally(err2); + } + }); + return cf; + } + public CompletableFuture getNodeDetails(String verifier, String verifierId) { // For mainnet & ropsten, verifierId combination doesn't change the network details if (this.nodeDetails.getUpdated() && !(multi_cluster_networks.contains(this.torusNetwork.name()))) @@ -86,4 +148,10 @@ public CompletableFuture getNodeDetails(String verifier, String ver cf.complete(nodeDetails); return cf; } + + private void setupWeb3() { + Web3j web3j = Web3j.build(new HttpService(this.providerUrl)); + Credentials credentials = Credentials.create("0x5bbbef76458bf30511c9ee6ed56783644eb339258d02656755c68098c4809130"); + this.torusLookup = new TorusLookup(this.proxyAddress, web3j, credentials, new DefaultGasProvider()); + } } From 073d6963c46bb5b4c22d3e6c74d23e7d11abe6a9 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 4 Jul 2023 16:19:28 +0530 Subject: [PATCH 13/26] code refactored --- .../fetchnodedetails/FetchNodeDetails.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index df92a34..55b854b 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -48,13 +48,13 @@ public class FetchNodeDetails { } }; - public static HashMap NETWORKS_ROUTE_MAP = new HashMap() { + public static HashMap NETWORKS_ROUTE_MAP = new HashMap() { { - put(TorusNetwork.AQUA, new LegacyNetworkMigrationInfo(false, "aqua", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.CELESTE, new LegacyNetworkMigrationInfo(false, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.CYAN, new LegacyNetworkMigrationInfo(false, "cyan", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.MAINNET, new LegacyNetworkMigrationInfo(false, "mainnet", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.TESTNET, new LegacyNetworkMigrationInfo(true, "teal", TorusNetwork.SAPPHIRE_TESTNET)); + put(TorusNetwork.AQUA.toString(), new LegacyNetworkMigrationInfo(false, "aqua", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.CELESTE.toString(), new LegacyNetworkMigrationInfo(false, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.CYAN.toString(), new LegacyNetworkMigrationInfo(false, "cyan", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.MAINNET.toString(), new LegacyNetworkMigrationInfo(false, "mainnet", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.TESTNET.toString(), new LegacyNetworkMigrationInfo(true, "teal", TorusNetwork.SAPPHIRE_TESTNET)); } }; From 5c6c3fed776f619b57f354f55d2ab2a79748ec7b Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 4 Jul 2023 16:26:01 +0530 Subject: [PATCH 14/26] code refactored --- .../org/torusresearch/fetchnodedetails/FetchNodeDetails.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index 55b854b..2118a85 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -48,7 +48,7 @@ public class FetchNodeDetails { } }; - public static HashMap NETWORKS_ROUTE_MAP = new HashMap() { + public static HashMap LEGACY_NETWORKS_ROUTE_MAP = new HashMap() { { put(TorusNetwork.AQUA.toString(), new LegacyNetworkMigrationInfo(false, "aqua", TorusNetwork.SAPPHIRE_MAINNET)); put(TorusNetwork.CELESTE.toString(), new LegacyNetworkMigrationInfo(false, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); From ad219e8a74ff443acce5fc7f0633d8f6eea8d2a3 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Wed, 5 Jul 2023 09:14:21 +0530 Subject: [PATCH 15/26] code refactored --- .../org/torusresearch/fetchnodedetails/types/TorusNetwork.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java index be7eba4..6d9e8f7 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java @@ -7,7 +7,7 @@ public enum TorusNetwork { AQUA("aqua"), CELESTE("celeste"), SAPPHIRE_DEVNET("sapphire_devnet"), - SAPPHIRE_TESTNET("sapphire_devnet"), + SAPPHIRE_TESTNET("sapphire_testnet"), SAPPHIRE_MAINNET("sapphire_mainnet"); private final String val; From 7dcf847a740fa1b9729f733ae26a3e19260636f8 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Wed, 12 Jul 2023 13:42:35 +0530 Subject: [PATCH 16/26] code refactored --- .../org/torusresearch/fetchnodedetailstest/config/mainnet.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json index 1b4e06a..90d5aee 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json @@ -1,11 +1,10 @@ { "currentEpoch": "19", - "nodeListAddress": "0xf20336e16B5182637f09821c27BDe29b0AFcfe80", "torusNodeEndpoints": [ "https://torus-19.torusnode.com/jrpc", "https://torus-node.ens.domains/jrpc", "https://torus-node.matic.network/jrpc", - "https://torus.zilliqa.network/jrpc", + "https://zilliqa.tor.us/jrpc", "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", From a8782d48c16225e973b72ee855b9f137c4c2e292 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 22 Aug 2023 14:37:03 +0530 Subject: [PATCH 17/26] refactor: removing sapphire-devnet network Signed-off-by: Gaurav Goel --- .../fetchnodedetails/FetchNodeDetails.java | 3 +- .../fetchnodedetails/types/TorusNetwork.java | 1 - .../fetchnodedetails/types/Utils.java | 2 - .../FetchNodeDetailsTest.java | 8 --- .../fetchnodedetailstest/config/mainnet.json | 2 +- .../config/sapphire_testnet.json | 60 ------------------- 6 files changed, 2 insertions(+), 74 deletions(-) delete mode 100644 src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index 2118a85..e291a93 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -42,7 +42,6 @@ public class FetchNodeDetails { put(TorusNetwork.AQUA, "polygon-mainnet"); put(TorusNetwork.CELESTE, "polygon-mainnet"); put(TorusNetwork.SAPPHIRE_DEVNET, "sapphire_devnet"); - put(TorusNetwork.SAPPHIRE_TESTNET, "sapphire_testnet"); put(TorusNetwork.SAPPHIRE_MAINNET, "sapphire_mainnet"); } @@ -54,7 +53,7 @@ public class FetchNodeDetails { put(TorusNetwork.CELESTE.toString(), new LegacyNetworkMigrationInfo(false, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); put(TorusNetwork.CYAN.toString(), new LegacyNetworkMigrationInfo(false, "cyan", TorusNetwork.SAPPHIRE_MAINNET)); put(TorusNetwork.MAINNET.toString(), new LegacyNetworkMigrationInfo(false, "mainnet", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.TESTNET.toString(), new LegacyNetworkMigrationInfo(true, "teal", TorusNetwork.SAPPHIRE_TESTNET)); + put(TorusNetwork.TESTNET.toString(), new LegacyNetworkMigrationInfo(true, "teal", TorusNetwork.SAPPHIRE_DEVNET)); } }; diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java index 6d9e8f7..cb783e1 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/TorusNetwork.java @@ -7,7 +7,6 @@ public enum TorusNetwork { AQUA("aqua"), CELESTE("celeste"), SAPPHIRE_DEVNET("sapphire_devnet"), - SAPPHIRE_TESTNET("sapphire_testnet"), SAPPHIRE_MAINNET("sapphire_mainnet"); private final String val; diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java index 1d0d0f7..03e1a84 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java @@ -59,8 +59,6 @@ public static NodeDetails fetchLocalConfig(TorusNetwork network) { switch (network) { case SAPPHIRE_DEVNET: nodeDetails = NODE_DETAILS_SAPPHIRE_DEVNET; - case SAPPHIRE_TESTNET: - nodeDetails = NODE_DETAILS_SAPPHIRE_TESTNET; case SAPPHIRE_MAINNET: nodeDetails = NODE_DETAILS_SAPPHIRE_MAINNET; case MAINNET: diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java index a751e6a..8d14726 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java @@ -62,14 +62,6 @@ public void shouldGetNodeDetailsSapphireDevnet() throws ExecutionException, Inte assertEquals(Config.SAPPHIRE_DEVNET, nodeDetails); } - @DisplayName("Gets the Node details for SapphireTestnet") - @Test - public void shouldGetNodeDetailsSapphireTestnet() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_TESTNET); - NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); - assertEquals(Config.SAPPHIRE_TESTNET, nodeDetails); - } - @DisplayName("Gets the Node details for SapphireMainnet") @Test public void shouldGetNodeDetailsSapphireMainnet() throws ExecutionException, InterruptedException { diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json index 90d5aee..a35b1e7 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json @@ -8,7 +8,7 @@ "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", - "https://torus-node.binancex.dev/jrpc", + "https://binancex.tor.us/jrpc", "https://torusnode.ont.io/jrpc" ], "torusNodeSSSEndpoints": null, diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json deleted file mode 100644 index 0876fa8..0000000 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_testnet.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "currentEpoch": "1", - "torusNodeEndpoints": [ - "https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", - "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", - "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", - "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", - "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc" - ], - "torusNodeSSSEndpoints": [ - "https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", - "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", - "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", - "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", - "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc" - ], - "torusNodeRSSEndpoints": [ - "https://sapphire-dev-2-1.authnetwork.dev/rss", - "https://sapphire-dev-2-2.authnetwork.dev/rss", - "https://sapphire-dev-2-3.authnetwork.dev/rss", - "https://sapphire-dev-2-4.authnetwork.dev/rss", - "https://sapphire-dev-2-5.authnetwork.dev/rss" - ], - "torusNodeTSSEndpoints": [ - "https://sapphire-dev-2-1.authnetwork.dev/tss", - "https://sapphire-dev-2-2.authnetwork.dev/tss", - "https://sapphire-dev-2-3.authnetwork.dev/tss", - "https://sapphire-dev-2-4.authnetwork.dev/tss", - "https://sapphire-dev-2-5.authnetwork.dev/tss" - ], - "torusNodePub": [ - { - "X": "f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", - "Y": "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7" - }, - { - "X": "bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", - "Y": "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a" - }, - { - "X": "b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", - "Y": "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c" - }, - { - "X": "7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", - "Y": "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b" - }, - { - "X": "bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", - "Y": "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4" - } - ], - "torusIndexes": [ - 1, - 2, - 3, - 4, - 5 - ] -} \ No newline at end of file From a476951a00f6c3e5b652ccfc40767d8909384f16 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Mon, 28 Aug 2023 18:04:55 +0530 Subject: [PATCH 18/26] refactor: Mainnet migration changes added. Signed-off-by: Gaurav Goel --- .../fetchnodedetails/FetchNodeDetails.java | 2 +- .../fetchnodedetailstest/config/mainnet.json | 86 ++++++++++--------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index e291a93..895d455 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -52,7 +52,7 @@ public class FetchNodeDetails { put(TorusNetwork.AQUA.toString(), new LegacyNetworkMigrationInfo(false, "aqua", TorusNetwork.SAPPHIRE_MAINNET)); put(TorusNetwork.CELESTE.toString(), new LegacyNetworkMigrationInfo(false, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); put(TorusNetwork.CYAN.toString(), new LegacyNetworkMigrationInfo(false, "cyan", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.MAINNET.toString(), new LegacyNetworkMigrationInfo(false, "mainnet", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.MAINNET.toString(), new LegacyNetworkMigrationInfo(true, "mainnet", TorusNetwork.SAPPHIRE_MAINNET)); put(TorusNetwork.TESTNET.toString(), new LegacyNetworkMigrationInfo(true, "teal", TorusNetwork.SAPPHIRE_DEVNET)); } }; diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json index a35b1e7..5c82b59 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json @@ -1,57 +1,61 @@ { - "currentEpoch": "19", + "currentEpoch": "1", "torusNodeEndpoints": [ - "https://torus-19.torusnode.com/jrpc", - "https://torus-node.ens.domains/jrpc", - "https://torus-node.matic.network/jrpc", - "https://zilliqa.tor.us/jrpc", - "https://torus-mainnet.cosmos.network/jrpc", - "https://torus2.etherscan.com/jrpc", - "https://torus-node-v2.skalelabs.com/jrpc", - "https://binancex.tor.us/jrpc", - "https://torusnode.ont.io/jrpc" + "https://sapphire-1.auth.network/sss/mainnet/jrpc", + "https://sapphire-2.auth.network/sss/mainnet/jrpc", + "https://sapphire-3.auth.network/sss/mainnet/jrpc", + "https://sapphire-4.auth.network/sss/mainnet/jrpc", + "https://sapphire-5.auth.network/sss/mainnet/jrpc" + ], + "torusNodeSSSEndpoints": [ + "https://sapphire-1.auth.network/sss/mainnet/jrpc", + "https://sapphire-2.auth.network/sss/mainnet/jrpc", + "https://sapphire-3.auth.network/sss/mainnet/jrpc", + "https://sapphire-4.auth.network/sss/mainnet/jrpc", + "https://sapphire-5.auth.network/sss/mainnet/jrpc" + ], + "torusNodeRSSEndpoints": [ + "https://sapphire-1.auth.network/rss/mainnet", + "https://sapphire-2.auth.network/rss/mainnet", + "https://sapphire-3.auth.network/rss/mainnet", + "https://sapphire-4.auth.network/rss/mainnet", + "https://sapphire-5.auth.network/rss/mainnet" + ], + "torusNodeTSSEndpoints": [ + "https://sapphire-1.auth.network/tss/mainnet", + "https://sapphire-2.auth.network/tss/mainnet", + "https://sapphire-3.auth.network/tss/mainnet", + "https://sapphire-4.auth.network/tss/mainnet", + "https://sapphire-5.auth.network/tss/mainnet" ], - "torusNodeSSSEndpoints": null, - "torusNodeRSSEndpoints": null, - "torusNodeTSSEndpoints": null, "torusNodePub": [ { - "X": "bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", - "Y": "82b49a7caf70def38cdad2740af45c1e4f969650105c5019a29bb18b21a9acb5" - }, - { - "X": "c208cac4ef9a47d386097a9c915b28e9cb89213abee8d26a17198ee261201b0d", - "Y": "c7db2fe4631109f40833de9dc78d07e35706549ee48fa557b33e4e75e1047873" - }, - { - "X": "ca1766bb426d4ca5582818a0c5439d560ea64f5baa060793ab29dd3d0ceacfe", - "Y": "d46c1d08c40e1306e1bca328c2287b8268166b11a1ba4b8442ea2ad0c5e32152" - }, - { - "X": "c3934dd2f6f4b3d2e1e398cc501e143c1e1a381b52feb6d1525af34d16253768", - "Y": "71f5141a5035799099f5ea3e241e66946bc55dc857ac3bd7d6fcdb8dcd3eeeef" + "X": "e0925898fee0e9e941fdca7ee88deec99939ae9407e923535c4d4a3a3ff8b052", + "Y": "54b9fea924e3f3e40791f9987f4234ae4222412d65b74068032fa5d8b63375c1" }, { - "X": "22e66f1929631d00bf026227581597f085fd94fd952fc0dca9f0833398b5c064", - "Y": "6088b3912e10a1e9d50355a609c10db7d188f16a2e2fd7357e51bf4f6a74f0a1" + "X": "9124cf1e280aab32ba50dffd2de81cecabc13d82d2c1fe9de82f3b3523f9b637", + "Y": "fca939a1ceb42ce745c55b21ef094f543b457630cb63a94ef4f1afeee2b1f107" }, { - "X": "9dc9fa410f3ce9eb70df70cdea00a49f2c4cc7a31c08c0dab5f863ed35ff5139", - "Y": "627a291cb87a75c61da3f65d6818e1e05e360217179817ed27e8c73bca7ec122" + "X": "555f681a63d469cc6c3a58a97e29ebd277425f0e6159708e7c7bf05f18f89476", + "Y": "606f2bcc0884fa5b64366fc3e8362e4939841b56acd60d5f4553cf36b891ac4e" }, { - "X": "118b9fc07e97b096d899b9f6658463ce6a8caa64038e37fc969df4e6023dd8c6", - "Y": "baf9fa4e51770f4796ea165dd03a769b8606681a38954a0a92c4cbffd6609ce9" + "X": "2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", + "Y": "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247" }, { - "X": "8a6d8b925da15a273dec3d8f8395ec35cd6878f274b2b180e4e106999db64043", - "Y": "96f67f870c157743da0b1eb84d89bf30500d74dc84c11f501ee1cb013acc8c46" - }, - { - "X": "39cecb62e863729f572f7dfc46c24867981bf04bb405fed0df39e33984bfade5", - "Y": "61c2364434012e68a2be2e9952805037e52629d7762fafc8e10e9fb5bad8f790" + "X": "3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", + "Y": "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4" } ], - "torusIndexes": [1, 2, 3, 4, 5, 6, 7, 8, 9], + "torusIndexes": [ + 1, + 2, + 3, + 4, + 5 + ], "updated": false -} +} \ No newline at end of file From 26f5bd41c310ed9b88c99f34e130fd992fe081c3 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 5 Sep 2023 12:50:12 +0530 Subject: [PATCH 19/26] refactor: remove unused code in APiUtils and remove org.json:json library Signed-off-by: Gaurav Goel --- build.gradle | 1 - .../fetchnodedetails/types/APIUtils.java | 23 ------------------- 2 files changed, 24 deletions(-) diff --git a/build.gradle b/build.gradle index bf28f60..d7c2c84 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,6 @@ dependencies { implementation 'org.web3j:core:4.8.8-android' implementation 'com.squareup.okhttp3:okhttp:4.9.3' implementation 'com.google.code.gson:gson:2.9.0' - implementation 'org.json:json:20220924' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' testImplementation 'org.slf4j:slf4j-simple:1.7.36' diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java b/src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java index 6312522..291af48 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java @@ -12,7 +12,6 @@ import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; -import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.internal.http2.Header; @@ -42,14 +41,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) { }; } - public static CompletableFuture post(String url, String data) { - return _post(url, data, new Header[0]); - } - - public static CompletableFuture post(String url, String data, Header[] headers) { - return _post(url, data, headers); - } - public static CompletableFuture get(String url) { return _get(url, new Header[0]); } @@ -58,20 +49,6 @@ public static CompletableFuture get(String url, Header[] headers) { return _get(url, headers); } - private static CompletableFuture _post(String url, String data, Header[] headers) { - RequestBody body = RequestBody.create(data, JSON); - Request.Builder requestBuilder = new Request.Builder() - .url(url) - .post(body); - for (Header header : headers) { - requestBuilder.addHeader(header.name.utf8(), header.value.utf8()); - } - Request request = requestBuilder.build(); - CompletableFuture future = new CompletableFuture<>(); - client.newCall(request).enqueue(toCallback(future)); - return future; - } - private static CompletableFuture _get(String url, Header[] headers) { Request.Builder requestBuilder = new Request.Builder().url(url); for (Header header : headers) { From 2551a1e40b0b51929f0d075adb9db5e6182081a6 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 5 Sep 2023 12:50:40 +0530 Subject: [PATCH 20/26] refactor: remove unused code in APiUtils and remove org.json:json library Signed-off-by: Gaurav Goel --- .../org/torusresearch/fetchnodedetails/FetchNodeDetails.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index 895d455..f393d24 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -2,7 +2,6 @@ import com.google.gson.GsonBuilder; -import org.json.JSONObject; import org.torusresearch.fetchnodedetails.types.APIUtils; import org.torusresearch.fetchnodedetails.types.FNDResponse; import org.torusresearch.fetchnodedetails.types.LegacyNetworkMigrationInfo; @@ -135,9 +134,8 @@ public CompletableFuture getNodeDetails(String verifier, String ver String fndServerEndpoint = "https://fnd.tor.us/node-details"; String url = fndServerEndpoint + "?network=" + this.torusNetwork + "&verifier=" + verifier + "&verifierId=" + verifierId; CompletableFuture response = APIUtils.get(url); - JSONObject jsonObject = new JSONObject(response.get()); FNDResponse fndResponse = - new GsonBuilder().disableHtmlEscaping().create().fromJson(jsonObject.toString(), FNDResponse.class); + new GsonBuilder().disableHtmlEscaping().create().fromJson(response.get(), FNDResponse.class); cf.complete(fndResponse.getNodeDetails()); return cf; } catch (Exception ex) { From 2696997151b05423e27e8a7c00e254fbbe1da4af Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 5 Sep 2023 19:42:55 +0530 Subject: [PATCH 21/26] refactor: remove old code Signed-off-by: Gaurav Goel --- build.gradle | 1 - .../fetchnodedetails/FetchNodeDetails.java | 78 ------------------- .../fetchnodedetails/TorusLookup.java | 70 ----------------- 3 files changed, 149 deletions(-) delete mode 100644 src/main/java/org/torusresearch/fetchnodedetails/TorusLookup.java diff --git a/build.gradle b/build.gradle index d7c2c84..6109576 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,6 @@ repositories { } dependencies { - implementation 'org.web3j:core:4.8.8-android' implementation 'com.squareup.okhttp3:okhttp:4.9.3' implementation 'com.google.code.gson:gson:2.9.0' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index f393d24..e731dfa 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -6,18 +6,9 @@ import org.torusresearch.fetchnodedetails.types.FNDResponse; import org.torusresearch.fetchnodedetails.types.LegacyNetworkMigrationInfo; import org.torusresearch.fetchnodedetails.types.NodeDetails; -import org.torusresearch.fetchnodedetails.types.NodeInfo; import org.torusresearch.fetchnodedetails.types.TorusNetwork; -import org.torusresearch.fetchnodedetails.types.TorusNodePub; import org.torusresearch.fetchnodedetails.types.Utils; -import org.web3j.crypto.Credentials; -import org.web3j.crypto.Hash; -import org.web3j.protocol.Web3j; -import org.web3j.protocol.http.HttpService; -import org.web3j.tx.gas.DefaultGasProvider; -import java.math.BigInteger; -import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -25,14 +16,6 @@ public class FetchNodeDetails { - public static String PROXY_ADDRESS_MAINNET = "0xf20336e16B5182637f09821c27BDe29b0AFcfe80"; - public static String PROXY_ADDRESS_TESTNET = "0xd084604e5FA387FbC2Da8bAab07fDD6aDED4614A"; - public static String PROXY_ADDRESS_CYAN = "0x9f072ba19b3370e512aa1b4bfcdaf97283168005"; - public static String PROXY_ADDRESS_AQUA = "0x29Dea82a0509153b91040ee13cDBba0f03efb625"; - public static String PROXY_ADDRESS_CELESTE = "0x6Bffb4e89453069E7487f0fa5c9f4a2D771cce6c"; - - public static NodeDetails NODE_DETAILS_MAINNET = new NodeDetails("19", new String[]{"https://torus-19.torusnode.com/jrpc", "https://torus-node.ens.domains/jrpc", "https://torus-node.matic.network/jrpc", "https://torus.zilliqa.network/jrpc", "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", "https://torus-node.binancex.dev/jrpc", "https://torusnode.ont.io/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5"), new BigInteger("6"), new BigInteger("7"), new BigInteger("8"), new BigInteger("9"),}, new TorusNodePub[]{new TorusNodePub("bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", "82b49a7caf70def38cdad2740af45c1e4f969650105c5019a29bb18b21a9acb5"), new TorusNodePub("c208cac4ef9a47d386097a9c915b28e9cb89213abee8d26a17198ee261201b0d", "c7db2fe4631109f40833de9dc78d07e35706549ee48fa557b33e4e75e1047873"), new TorusNodePub("ca1766bb426d4ca5582818a0c5439d560ea64f5baa060793ab29dd3d0ceacfe", "d46c1d08c40e1306e1bca328c2287b8268166b11a1ba4b8442ea2ad0c5e32152"), new TorusNodePub("c3934dd2f6f4b3d2e1e398cc501e143c1e1a381b52feb6d1525af34d16253768", "71f5141a5035799099f5ea3e241e66946bc55dc857ac3bd7d6fcdb8dcd3eeeef"), new TorusNodePub("22e66f1929631d00bf026227581597f085fd94fd952fc0dca9f0833398b5c064", "6088b3912e10a1e9d50355a609c10db7d188f16a2e2fd7357e51bf4f6a74f0a1"), new TorusNodePub("9dc9fa410f3ce9eb70df70cdea00a49f2c4cc7a31c08c0dab5f863ed35ff5139", "627a291cb87a75c61da3f65d6818e1e05e360217179817ed27e8c73bca7ec122"), new TorusNodePub("118b9fc07e97b096d899b9f6658463ce6a8caa64038e37fc969df4e6023dd8c6", "baf9fa4e51770f4796ea165dd03a769b8606681a38954a0a92c4cbffd6609ce9"), new TorusNodePub("8a6d8b925da15a273dec3d8f8395ec35cd6878f274b2b180e4e106999db64043", "96f67f870c157743da0b1eb84d89bf30500d74dc84c11f501ee1cb013acc8c46"), new TorusNodePub("39cecb62e863729f572f7dfc46c24867981bf04bb405fed0df39e33984bfade5", "61c2364434012e68a2be2e9952805037e52629d7762fafc8e10e9fb5bad8f790")}, false); - public static HashMap NETWORK_MAP = new HashMap() { { put(TorusNetwork.MAINNET, "mainnet"); @@ -58,9 +41,6 @@ public class FetchNodeDetails { private List multi_cluster_networks = Arrays.asList("aqua", "celeste", "cyan"); - private String proxyAddress; - private String providerUrl; - private TorusLookup torusLookup; private final NodeDetails nodeDetails = new NodeDetails(); private TorusNetwork torusNetwork = TorusNetwork.MAINNET; @@ -68,62 +48,10 @@ public FetchNodeDetails() { this(TorusNetwork.MAINNET); } - public FetchNodeDetails(TorusNetwork network, String proxyAddress) { - this.proxyAddress = proxyAddress; - this.torusNetwork = network; - this.providerUrl = "https://" + NETWORK_MAP.get(network) + ".infura.io/v3/" + "b8cdb0e4cff24599a286bf8e87ff1c96"; - this.setupWeb3(); - } - - public FetchNodeDetails(String providerUrl, String proxyAddress) { - this.proxyAddress = proxyAddress; - this.providerUrl = providerUrl; - this.setupWeb3(); - } - public FetchNodeDetails(TorusNetwork network) { this.torusNetwork = network; } - public CompletableFuture getLegacyNodeDetails(String verifier, String verifierId) { - // For mainnet & ropsten, verifierId combination doesn't change the network details - if (this.nodeDetails.getUpdated() && (this.proxyAddress.equals(PROXY_ADDRESS_MAINNET) || this.proxyAddress.equals(PROXY_ADDRESS_TESTNET))) - return CompletableFuture.supplyAsync(() -> this.nodeDetails); - byte[] hashedVerifierId = Hash.sha3(verifierId.getBytes(StandardCharsets.UTF_8)); - CompletableFuture cf = new CompletableFuture<>(); - this.torusLookup.getNodeSet(verifier, hashedVerifierId).sendAsync().whenCompleteAsync((nodeEndPoints, err) -> { - if (err != null) { - if (this.proxyAddress.equals(FetchNodeDetails.PROXY_ADDRESS_MAINNET)) { - cf.complete(FetchNodeDetails.NODE_DETAILS_MAINNET); - } else { - cf.completeExceptionally(err); - } - return; - } - try { - String[] updatedEndpoints = new String[nodeEndPoints.component3().size()]; - TorusNodePub[] updatedNodePub = new TorusNodePub[nodeEndPoints.component3().size()]; - - for (int i = 0; i < nodeEndPoints.component3().size(); i++) { - NodeInfo endPointElement = new NodeInfo(String.valueOf(nodeEndPoints.component2().get(i)), new BigInteger(String.valueOf(nodeEndPoints.component3().get(i)), 10).toString(16).replace("0x", ""), new BigInteger(String.valueOf(nodeEndPoints.component4().get(i)), 10).toString(16).replace("0x", "")); - - String endpoint = "https://" + endPointElement.getDeclaredIp().split(":")[0] + "/jrpc"; - updatedEndpoints[i] = endpoint; - updatedNodePub[i] = new TorusNodePub(endPointElement.getPubKx(), endPointElement.getPubKy()); - } - this.nodeDetails.setCurrentEpoch(nodeEndPoints.component1().toString()); - this.nodeDetails.setTorusNodeEndpoints(updatedEndpoints); - this.nodeDetails.setTorusNodePub(updatedNodePub); - this.nodeDetails.setTorusIndexes(nodeEndPoints.component5().toArray(new BigInteger[0])); - this.nodeDetails.setUpdated(true); - cf.complete(this.nodeDetails); - } catch (Exception err2) { - cf.completeExceptionally(err2); - } - }); - return cf; - } - public CompletableFuture getNodeDetails(String verifier, String verifierId) { // For mainnet & ropsten, verifierId combination doesn't change the network details if (this.nodeDetails.getUpdated() && !(multi_cluster_networks.contains(this.torusNetwork.name()))) @@ -145,10 +73,4 @@ public CompletableFuture getNodeDetails(String verifier, String ver cf.complete(nodeDetails); return cf; } - - private void setupWeb3() { - Web3j web3j = Web3j.build(new HttpService(this.providerUrl)); - Credentials credentials = Credentials.create("0x5bbbef76458bf30511c9ee6ed56783644eb339258d02656755c68098c4809130"); - this.torusLookup = new TorusLookup(this.proxyAddress, web3j, credentials, new DefaultGasProvider()); - } } diff --git a/src/main/java/org/torusresearch/fetchnodedetails/TorusLookup.java b/src/main/java/org/torusresearch/fetchnodedetails/TorusLookup.java deleted file mode 100644 index 9532663..0000000 --- a/src/main/java/org/torusresearch/fetchnodedetails/TorusLookup.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.torusresearch.fetchnodedetails; - -import org.web3j.abi.TypeReference; -import org.web3j.abi.datatypes.DynamicArray; -import org.web3j.abi.datatypes.Type; -import org.web3j.abi.datatypes.Utf8String; -import org.web3j.abi.datatypes.generated.Uint256; -import org.web3j.crypto.Credentials; -import org.web3j.protocol.Web3j; -import org.web3j.protocol.core.RemoteFunctionCall; -import org.web3j.tuples.generated.Tuple5; -import org.web3j.tx.Contract; -import org.web3j.tx.gas.ContractGasProvider; - -import java.math.BigInteger; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.concurrent.Callable; - -/** - *

Auto generated code. - *

Do not modify! - *

Please use the web3j command line tools, - * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the - * codegen module to update. - * - *

Generated with web3j version 1.4.1. - */ -@SuppressWarnings("rawtypes") -public class TorusLookup extends Contract { - public static final String BINARY = "0x608060405234801561001057600080fd5b5060405161145938038061145983398101604081905261002f91610095565b600080546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600180546001600160a01b0319166001600160a01b03929092169190911790556100c5565b6000602082840312156100a757600080fd5b81516001600160a01b03811681146100be57600080fd5b9392505050565b611385806100d46000396000f3fe608060405234801561001057600080fd5b50600436106100a35760003560e01c8063a9487fd911610076578063decde7661161005b578063decde76614610144578063f2fde38b14610157578063f4f59bed1461016a57600080fd5b8063a9487fd91461010d578063d59936e91461012057600080fd5b80633f3787d2146100a8578063715018a6146100bd5780638da5cb5b146100c55780638f32d59b146100ef575b600080fd5b6100bb6100b6366004610ce0565b61017d565b005b6100bb6101f7565b6000546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b6000546001600160a01b0316331460405190151581526020016100e6565b6100bb61011b366004610ded565b610294565b61013361012e366004610eb1565b6104af565b6040516100e6959493929190610f89565b6100d2610152366004610eb1565b6109a7565b6100bb610165366004610ce0565b6109ee565b6100bb610178366004610ded565b610a4d565b6000546001600160a01b031633146101d55760405162461bcd60e51b815260206004820152601660248201527527bbb730b136329d103737ba103a34329037bbb732b960511b60448201526064015b60405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b0316331461024a5760405162461bcd60e51b815260206004820152601660248201527527bbb730b136329d103737ba103a34329037bbb732b960511b60448201526064016101cc565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146102e75760405162461bcd60e51b815260206004820152601660248201527527bbb730b136329d103737ba103a34329037bbb732b960511b60448201526064016101cc565b60015460405163ac205deb60e01b81526000916001600160a01b03169063ac205deb90610318908690600401611030565b600060405180830381865afa158015610335573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261035d9190810190611090565b9350505050806103af5760405162461bcd60e51b815260206004820152601c60248201527f506c65617365206372656174652076657269666965722066697273740000000060448201526064016101cc565b60006002846040516103c1919061111f565b908152604080519182900360209081018320805480830285018301909352828452919083018282801561041d57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116103ff575b505050505090506000815111156104765760405162461bcd60e51b815260206004820152601f60248201527f566572696669657220616c7265616479206861732061206e6f6465207365740060448201526064016101cc565b82600285604051610487919061111f565b908152602001604051809103902090805190602001906104a8929190610c51565b5050505050565b600060608060608060006002886040516104c9919061111f565b908152604080519182900360209081018320805480830285018301909352828452919083018282801561052557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610507575b505050505090508051600014156105b05760405166191959985d5b1d60ca1b815260029060070190815260408051918290036020908101832080548083028501830190935282845291908301828280156105a857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161058a575b505050505090505b80516105fe5760405162461bcd60e51b815260206004820152601f60248201527f536574204e6f6465536574202d3e2076657269666965722f64656661756c740060448201526064016101cc565b805160009061060d908961113b565b905060008282815181106106235761062361115d565b6020026020010151905060008190506000816001600160a01b031663766718086040518163ffffffff1660e01b8152600401602060405180830381865afa158015610672573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106969190611173565b6040516309a8116160e11b8152600481018290529091506000906001600160a01b0384169063135022c290602401600060405180830381865afa1580156106e1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610709919081019061118c565b50509450505050506000815167ffffffffffffffff81111561072d5761072d610d04565b604051908082528060200260200182016040528015610756578160200160208202803683370190505b5090506000825167ffffffffffffffff81111561077557610775610d04565b6040519080825280602002602001820160405280156107a857816020015b60608152602001906001900390816107935790505b5090506000835167ffffffffffffffff8111156107c7576107c7610d04565b6040519080825280602002602001820160405280156107f0578160200160208202803683370190505b5090506000845167ffffffffffffffff81111561080f5761080f610d04565b604051908082528060200260200182016040528015610838578160200160208202803683370190505b50905060005b855181101561098957610852816001611278565b8582815181106108645761086461115d565b60200260200101818152505060008060008a6001600160a01b031663bafb35818a86815181106108965761089661115d565b60200260200101516040518263ffffffff1660e01b81526004016108c991906001600160a01b0391909116815260200190565b600060405180830381865afa1580156108e6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261090e9190810190611290565b5050935093505092508287858151811061092a5761092a61115d565b6020026020010181905250818685815181106109485761094861115d565b602002602001018181525050808585815181106109675761096761115d565b602002602001018181525050505050808061098190611334565b91505061083e565b50949d50909b50995091975090955050505050509295509295909350565b815160208184018101805160028252928201918501919091209190528054829081106109d257600080fd5b6000918252602090912001546001600160a01b03169150829050565b6000546001600160a01b03163314610a415760405162461bcd60e51b815260206004820152601660248201527527bbb730b136329d103737ba103a34329037bbb732b960511b60448201526064016101cc565b610a4a81610ba0565b50565b6000546001600160a01b03163314610aa05760405162461bcd60e51b815260206004820152601660248201527527bbb730b136329d103737ba103a34329037bbb732b960511b60448201526064016101cc565b60015460405163ac205deb60e01b81526000916001600160a01b03169063ac205deb90610ad1908690600401611030565b600060405180830381865afa158015610aee573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b169190810190611090565b935050505080610b685760405162461bcd60e51b815260206004820152601c60248201527f506c65617365206372656174652076657269666965722066697273740000000060448201526064016101cc565b81600284604051610b79919061111f565b90815260200160405180910390209080519060200190610b9a929190610c51565b50505050565b6001600160a01b038116610bf65760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c653a206e6f207a65726f2061646472657373000000000000000060448201526064016101cc565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b828054828255906000526020600020908101928215610ca6579160200282015b82811115610ca657825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190610c71565b50610cb2929150610cb6565b5090565b5b80821115610cb25760008155600101610cb7565b6001600160a01b0381168114610a4a57600080fd5b600060208284031215610cf257600080fd5b8135610cfd81610ccb565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610d4357610d43610d04565b604052919050565b600067ffffffffffffffff821115610d6557610d65610d04565b50601f01601f191660200190565b600082601f830112610d8457600080fd5b8135610d97610d9282610d4b565b610d1a565b818152846020838601011115610dac57600080fd5b816020850160208301376000918101602001919091529392505050565b600067ffffffffffffffff821115610de357610de3610d04565b5060051b60200190565b60008060408385031215610e0057600080fd5b823567ffffffffffffffff80821115610e1857600080fd5b610e2486838701610d73565b9350602091508185013581811115610e3b57600080fd5b85019050601f81018613610e4e57600080fd5b8035610e5c610d9282610dc9565b81815260059190911b82018301908381019088831115610e7b57600080fd5b928401925b82841015610ea2578335610e9381610ccb565b82529284019290840190610e80565b80955050505050509250929050565b60008060408385031215610ec457600080fd5b823567ffffffffffffffff811115610edb57600080fd5b610ee785828601610d73565b95602094909401359450505050565b60005b83811015610f11578181015183820152602001610ef9565b83811115610b9a5750506000910152565b60008151808452610f3a816020860160208601610ef6565b601f01601f19169290920160200192915050565b600081518084526020808501945080840160005b83811015610f7e57815187529582019590820190600101610f62565b509495945050505050565b600060a08201878352602060a08185015281885180845260c08601915060c08160051b8701019350828a0160005b82811015610fe55760bf19888703018452610fd3868351610f22565b95509284019290840190600101610fb7565b50505050508281036040840152610ffc8187610f4e565b905082810360608401526110108186610f4e565b905082810360808401526110248185610f4e565b98975050505050505050565b602081526000610cfd6020830184610f22565b600082601f83011261105457600080fd5b8151611062610d9282610d4b565b81815284602083860101111561107757600080fd5b611088826020830160208701610ef6565b949350505050565b600080600080608085870312156110a657600080fd5b84516110b181610ccb565b602086015190945067ffffffffffffffff808211156110cf57600080fd5b6110db88838901611043565b945060408701519150808211156110f157600080fd5b506110fe87828801611043565b9250506060850151801515811461111457600080fd5b939692955090935050565b60008251611131818460208701610ef6565b9190910192915050565b60008261115857634e487b7160e01b600052601260045260246000fd5b500690565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561118557600080fd5b5051919050565b600080600080600080600060e0888a0312156111a757600080fd5b8751965060208089015196506040890151955060608901519450608089015167ffffffffffffffff8111156111db57600080fd5b8901601f81018b136111ec57600080fd5b80516111fa610d9282610dc9565b81815260059190911b8201830190838101908d83111561121957600080fd5b928401925b8284101561124057835161123181610ccb565b8252928401929084019061121e565b809750505050505060a0880151915060c0880151905092959891949750929550565b634e487b7160e01b600052601160045260246000fd5b6000821982111561128b5761128b611262565b500190565b60008060008060008060c087890312156112a957600080fd5b865167ffffffffffffffff808211156112c157600080fd5b6112cd8a838b01611043565b975060208901519650604089015195506060890151945060808901519150808211156112f857600080fd5b6113048a838b01611043565b935060a089015191508082111561131a57600080fd5b5061132789828a01611043565b9150509295509295509295565b600060001982141561134857611348611262565b506001019056fea2646970667358221220ff4c563c9b5bbc18744cd81e5b7c83da3779a5a6e7fbab8be085b388cee415ec64736f6c634300080b0033"; - - public static final String FUNC_GETNODESET = "getNodeSet"; - - protected static final HashMap _addresses; - - static { - _addresses = new HashMap(); - } - - protected TorusLookup(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { - super(BINARY, contractAddress, web3j, credentials, contractGasProvider); - } - - public RemoteFunctionCall, List, List, List>> getNodeSet(String _verifier, byte[] hashedVerifierId) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_GETNODESET, - Arrays.asList(new org.web3j.abi.datatypes.Utf8String(_verifier), - new org.web3j.abi.datatypes.generated.Bytes32(hashedVerifierId)), - Arrays.asList(new TypeReference() { - }, new TypeReference>() { - }, new TypeReference>() { - }, new TypeReference>() { - }, new TypeReference>() { - })); - return new RemoteFunctionCall, List, List, List>>(function, - new Callable, List, List, List>>() { - @Override - public Tuple5, List, List, List> call() throws Exception { - List results = executeCallMultipleValueReturn(function); - return new Tuple5, List, List, List>( - (BigInteger) results.get(0).getValue(), - convertToNative((List) results.get(1).getValue()), - convertToNative((List) results.get(2).getValue()), - convertToNative((List) results.get(3).getValue()), - convertToNative((List) results.get(4).getValue())); - } - }); - } -} From 05b6d2d8074ebf4518c8e2463e513dc1fb0c9b82 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 24 Oct 2023 08:33:17 +0530 Subject: [PATCH 22/26] updated test cases for aqua and cyan after migration Signed-off-by: Gaurav Goel --- .../fetchnodedetails/FetchNodeDetails.java | 6 +-- .../fetchnodedetailstest/config/aqua.json | 53 ++++++++++++------ .../fetchnodedetailstest/config/cyan.json | 54 +++++++++++++------ 3 files changed, 77 insertions(+), 36 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index e731dfa..02bf01c 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -31,9 +31,9 @@ public class FetchNodeDetails { public static HashMap LEGACY_NETWORKS_ROUTE_MAP = new HashMap() { { - put(TorusNetwork.AQUA.toString(), new LegacyNetworkMigrationInfo(false, "aqua", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.CELESTE.toString(), new LegacyNetworkMigrationInfo(false, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.CYAN.toString(), new LegacyNetworkMigrationInfo(false, "cyan", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.AQUA.toString(), new LegacyNetworkMigrationInfo(true, "aqua", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.CELESTE.toString(), new LegacyNetworkMigrationInfo(true, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.CYAN.toString(), new LegacyNetworkMigrationInfo(true, "cyan", TorusNetwork.SAPPHIRE_MAINNET)); put(TorusNetwork.MAINNET.toString(), new LegacyNetworkMigrationInfo(true, "mainnet", TorusNetwork.SAPPHIRE_MAINNET)); put(TorusNetwork.TESTNET.toString(), new LegacyNetworkMigrationInfo(true, "teal", TorusNetwork.SAPPHIRE_DEVNET)); } diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json index 18b0a53..96ac05f 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json @@ -2,34 +2,55 @@ "currentEpoch": "1", "nodeListAddress": "0x29Dea82a0509153b91040ee13cDBba0f03efb625", "torusNodeEndpoints": [ - "https://node-1.cluster-2.aqua.web3auth.io/jrpc", - "https://node-2.cluster-2.aqua.web3auth.io/jrpc", - "https://node-3.cluster-2.aqua.web3auth.io/jrpc", - "https://node-4.cluster-2.aqua.web3auth.io/jrpc", - "https://node-5.cluster-2.aqua.web3auth.io/jrpc" + "https://sapphire-1.auth.network/sss/aqua/jrpc", + "https://sapphire-2.auth.network/sss/aqua/jrpc", + "https://sapphire-3.auth.network/sss/aqua/jrpc", + "https://sapphire-4.auth.network/sss/aqua/jrpc", + "https://sapphire-5.auth.network/sss/aqua/jrpc" + ], + "torusNodeSSSEndpoints": [ + "https://sapphire-1.auth.network/sss/aqua/jrpc", + "https://sapphire-2.auth.network/sss/aqua/jrpc", + "https://sapphire-3.auth.network/sss/aqua/jrpc", + "https://sapphire-4.auth.network/sss/aqua/jrpc", + "https://sapphire-5.auth.network/sss/aqua/jrpc" + ], + "torusNodeRSSEndpoints": [ + "https://sapphire-1.auth.network/rss/aqua", + "https://sapphire-2.auth.network/rss/aqua", + "https://sapphire-3.auth.network/rss/aqua", + "https://sapphire-4.auth.network/rss/aqua", + "https://sapphire-5.auth.network/rss/aqua" + ], + "torusNodeTSSEndpoints": [ + "https://sapphire-1.auth.network/tss/aqua", + "https://sapphire-2.auth.network/tss/aqua", + "https://sapphire-3.auth.network/tss/aqua", + "https://sapphire-4.auth.network/tss/aqua", + "https://sapphire-5.auth.network/tss/aqua" ], "torusNodePub": [ { - "X": "7d376a4a7ce6bba7a8a49001aaa2de3f24e0f56ee73a77c6678ec00363616f25", - "Y": "d5752873e522f98b4ded27690aadfda57ff5dc2fd0c3055b9d83663441667010" + "X": "e0925898fee0e9e941fdca7ee88deec99939ae9407e923535c4d4a3a3ff8b052", + "Y": "54b9fea924e3f3e40791f9987f4234ae4222412d65b74068032fa5d8b63375c1" }, { - "X": "0e1b5debe1d9b42eb9917a5fe84fa5f48cae7a770b1f49f0546fbe26b1efaff3", - "Y": "8947458cbfd8b40c7bc6160c7c746c2dca65c7d6ffdccd5579203b92a020b4ad" + "X": "9124cf1e280aab32ba50dffd2de81cecabc13d82d2c1fe9de82f3b3523f9b637", + "Y": "fca939a1ceb42ce745c55b21ef094f543b457630cb63a94ef4f1afeee2b1f107" }, { - "X": "98c3582b138b375b643984094882c17ca7ee090787c0a7065d229672845aa25e", - "Y": "02c3923bd015faac2cf3d91ab4cf8c6cdd4eb9f99e407a35703edf17e8c35d" + "X": "555f681a63d469cc6c3a58a97e29ebd277425f0e6159708e7c7bf05f18f89476", + "Y": "606f2bcc0884fa5b64366fc3e8362e4939841b56acd60d5f4553cf36b891ac4e" }, { - "X": "e7ef4c1ea43bd385ab8bfb02a5aedcd33bed35b95980c0729e9a35edd02a8597", - "Y": "d540aa7d1c9cafd2216e089b8c795a9034368960729103c9a2c875d76b81fc6d" + "X": "2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", + "Y": "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247" }, { - "X": "bb7d3500ead64d0bccd97f24b5c848ff6cbe867c0c03ca9f2922626ac5d1e49d", - "Y": "865ea03db0501bc9ffa83600202de437c7c10aa511c58ba54683b4d5f56ae314" + "X": "3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", + "Y": "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4" } ], "torusIndexes": [1, 2, 3, 4, 5], - "updated": true + "updated": false } \ No newline at end of file diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/cyan.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/cyan.json index 3c68dd0..ef5c7a8 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/cyan.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/cyan.json @@ -1,35 +1,55 @@ { "currentEpoch": "1", - "nodeListAddress": "0x9f072ba19b3370e512aa1b4bfcdaf97283168005", "torusNodeEndpoints": [ - "https://node-1.torus-cluster-1.com/jrpc", - "https://node-2.torus-cluster-1.com/jrpc", - "https://node-3.torus-cluster-1.com/jrpc", - "https://node-4.torus-cluster-1.com/jrpc", - "https://node-5.torus-cluster-1.com/jrpc" + "https://sapphire-1.auth.network/sss/cyan/jrpc", + "https://sapphire-2.auth.network/sss/cyan/jrpc", + "https://sapphire-3.auth.network/sss/cyan/jrpc", + "https://sapphire-4.auth.network/sss/cyan/jrpc", + "https://sapphire-5.auth.network/sss/cyan/jrpc" + ], + "torusNodeSSSEndpoints": [ + "https://sapphire-1.auth.network/sss/cyan/jrpc", + "https://sapphire-2.auth.network/sss/cyan/jrpc", + "https://sapphire-3.auth.network/sss/cyan/jrpc", + "https://sapphire-4.auth.network/sss/cyan/jrpc", + "https://sapphire-5.auth.network/sss/cyan/jrpc" + ], + "torusNodeRSSEndpoints": [ + "https://sapphire-1.auth.network/rss/cyan", + "https://sapphire-2.auth.network/rss/cyan", + "https://sapphire-3.auth.network/rss/cyan", + "https://sapphire-4.auth.network/rss/cyan", + "https://sapphire-5.auth.network/rss/cyan" + ], + "torusNodeTSSEndpoints": [ + "https://sapphire-1.auth.network/tss/cyan", + "https://sapphire-2.auth.network/tss/cyan", + "https://sapphire-3.auth.network/tss/cyan", + "https://sapphire-4.auth.network/tss/cyan", + "https://sapphire-5.auth.network/tss/cyan" ], "torusNodePub": [ { - "X": "805f81fd2fdc0d207b5a8b6643cd8f885bb761942f31fd6e138fcf8871d44cff", - "Y": "10bd6ec1675147256fbc4094c05191975a175d49ae8716ee83409929e6a302e7" + "X": "e0925898fee0e9e941fdca7ee88deec99939ae9407e923535c4d4a3a3ff8b052", + "Y": "54b9fea924e3f3e40791f9987f4234ae4222412d65b74068032fa5d8b63375c1" }, { - "X": "28394dafddfa20cb9ef5c9c26c31415c613565c3bbd9a82af8bfc88376e65353", - "Y": "5507f59c00d585fbed0ca08773a24faea4724e2b68be3da1e7281d5968251f1b" + "X": "9124cf1e280aab32ba50dffd2de81cecabc13d82d2c1fe9de82f3b3523f9b637", + "Y": "fca939a1ceb42ce745c55b21ef094f543b457630cb63a94ef4f1afeee2b1f107" }, { - "X": "4a190019eea47a45e6edb6a871a850b67fb72dcd9e255a07156c31dbf3a40035", - "Y": "565aa310a9e736f03d0693df4723880cafe25edba46c9ee88ace6453044d5ae9" + "X": "555f681a63d469cc6c3a58a97e29ebd277425f0e6159708e7c7bf05f18f89476", + "Y": "606f2bcc0884fa5b64366fc3e8362e4939841b56acd60d5f4553cf36b891ac4e" }, { - "X": "8a0f03b3ad07b1bd6068bb0aad3fe9feea5181643b04d292c65769c96b5990f8", - "Y": "4b34b66a7d91ff85f330a3c012a7bf45f5509be57bdf61885a906214d818a695" + "X": "2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", + "Y": "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247" }, { - "X": "dcf3b3c5a9e43533b875862b4dcfd5614535e7838d9a916f3f735e28e345cd9d", - "Y": "856d980747c1d171972b2ea34831670763d4b493ea7537b295b4be4c25b012fc" + "X": "3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", + "Y": "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4" } ], "torusIndexes": [1, 2, 3, 4, 5], - "updated": true + "updated": false } From 0c950305b7fc9414ebe454427242cf209c86e51e Mon Sep 17 00:00:00 2001 From: chaitanyapotti Date: Wed, 1 Nov 2023 19:31:03 +0800 Subject: [PATCH 23/26] fully working --- .../fetchnodedetails/FetchNodeDetails.java | 47 ++++++------- .../fetchnodedetails/types/APIUtils.java | 2 +- .../fetchnodedetails/types/EpochInfo.java | 64 ----------------- .../fetchnodedetails/types/NodeInfo.java | 36 ---------- .../fetchnodedetails/types/Utils.java | 68 +++++++++++++++---- .../fetchnodedetailstest/config/Config.java | 2 - .../fetchnodedetailstest/config/aqua.json | 2 +- .../fetchnodedetailstest/config/cyan.json | 2 +- .../fetchnodedetailstest/config/mainnet.json | 2 +- .../config/sapphire_devnet.json | 3 +- .../config/sapphire_mainnet.json | 3 +- .../fetchnodedetailstest/config/testnet.json | 2 +- 12 files changed, 82 insertions(+), 151 deletions(-) delete mode 100644 src/main/java/org/torusresearch/fetchnodedetails/types/EpochInfo.java delete mode 100644 src/main/java/org/torusresearch/fetchnodedetails/types/NodeInfo.java diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index 02bf01c..f5b2614 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -16,30 +16,7 @@ public class FetchNodeDetails { - public static HashMap NETWORK_MAP = new HashMap() { - { - put(TorusNetwork.MAINNET, "mainnet"); - put(TorusNetwork.TESTNET, "goerli"); - put(TorusNetwork.CYAN, "polygon-mainnet"); - put(TorusNetwork.AQUA, "polygon-mainnet"); - put(TorusNetwork.CELESTE, "polygon-mainnet"); - put(TorusNetwork.SAPPHIRE_DEVNET, "sapphire_devnet"); - put(TorusNetwork.SAPPHIRE_MAINNET, "sapphire_mainnet"); - - } - }; - - public static HashMap LEGACY_NETWORKS_ROUTE_MAP = new HashMap() { - { - put(TorusNetwork.AQUA.toString(), new LegacyNetworkMigrationInfo(true, "aqua", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.CELESTE.toString(), new LegacyNetworkMigrationInfo(true, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.CYAN.toString(), new LegacyNetworkMigrationInfo(true, "cyan", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.MAINNET.toString(), new LegacyNetworkMigrationInfo(true, "mainnet", TorusNetwork.SAPPHIRE_MAINNET)); - put(TorusNetwork.TESTNET.toString(), new LegacyNetworkMigrationInfo(true, "teal", TorusNetwork.SAPPHIRE_DEVNET)); - } - }; - - private List multi_cluster_networks = Arrays.asList("aqua", "celeste", "cyan"); + private List multi_cluster_networks = Arrays.asList("celeste"); private final NodeDetails nodeDetails = new NodeDetails(); private TorusNetwork torusNetwork = TorusNetwork.MAINNET; @@ -64,13 +41,29 @@ public CompletableFuture getNodeDetails(String verifier, String ver CompletableFuture response = APIUtils.get(url); FNDResponse fndResponse = new GsonBuilder().disableHtmlEscaping().create().fromJson(response.get(), FNDResponse.class); - cf.complete(fndResponse.getNodeDetails()); + this.setNodeDetails(fndResponse.getNodeDetails(), true); + cf.complete(this.nodeDetails); return cf; } catch (Exception ex) { - cf.completeExceptionally(new Exception("Failed to fetch node details from server")); + ex.printStackTrace(); } NodeDetails nodeDetails = Utils.fetchLocalConfig(this.torusNetwork); - cf.complete(nodeDetails); + if (nodeDetails == null) cf.completeExceptionally(new Exception("Failed to fetch node details")); + else { + this.setNodeDetails(nodeDetails, false); + cf.complete(this.nodeDetails); + } return cf; } + + private void setNodeDetails(NodeDetails nodeDetails, boolean updated) { + this.nodeDetails.setTorusNodeEndpoints(nodeDetails.getTorusNodeEndpoints()); + this.nodeDetails.setTorusNodePub(nodeDetails.getTorusNodePub()); + this.nodeDetails.setCurrentEpoch(nodeDetails.getCurrentEpoch()); + this.nodeDetails.setUpdated(updated); + this.nodeDetails.setTorusIndexes(nodeDetails.getTorusIndexes()); + this.nodeDetails.setTorusNodeRSSEndpoints(nodeDetails.getTorusNodeRSSEndpoints()); + this.nodeDetails.setTorusNodeSSSEndpoints(nodeDetails.getTorusNodeSSSEndpoints()); + this.nodeDetails.setTorusNodeTSSEndpoints(nodeDetails.getTorusNodeTSSEndpoints()); + } } diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java b/src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java index 291af48..bfd009b 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/APIUtils.java @@ -17,7 +17,7 @@ public class APIUtils { public static final MediaType JSON = MediaType.get("application/json; charset=utf-8"); - private static final OkHttpClient client = new OkHttpClient().newBuilder().writeTimeout(12, TimeUnit.SECONDS).build(); + private static final OkHttpClient client = new OkHttpClient().newBuilder().writeTimeout(10, TimeUnit.SECONDS).build(); private APIUtils() { } diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/EpochInfo.java b/src/main/java/org/torusresearch/fetchnodedetails/types/EpochInfo.java deleted file mode 100644 index 096de19..0000000 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/EpochInfo.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.torusresearch.fetchnodedetails.types; - -import java.util.Arrays; - -public final class EpochInfo { - private final String id; - private final String n; - private final String k; - private final String t; - private final String[] nodeList; - private final String prevEpoch; - private final String nextEpoch; - - public EpochInfo(String _id, String _n, String _k, String _t, String[] _nodeList, String _prevEpoch, String _nextEpoch) { - this.id = _id; - this.n = _n; - this.k = _k; - this.t = _t; - this.nodeList = _nodeList.clone(); - this.prevEpoch = _prevEpoch; - this.nextEpoch = _nextEpoch; - } - - public String getId() { - return id; - } - - public String getK() { - return k; - } - - public String getN() { - return n; - } - - public String getNextEpoch() { - return nextEpoch; - } - - public String getPrevEpoch() { - return prevEpoch; - } - - public String getT() { - return t; - } - - public String[] getNodeList() { - return nodeList.clone(); - } - - @Override - public String toString() { - return "EpochInfo{" + - "id='" + id + '\'' + - ", n='" + n + '\'' + - ", k='" + k + '\'' + - ", t='" + t + '\'' + - ", nodeList=" + Arrays.toString(nodeList) + - ", prevEpoch='" + prevEpoch + '\'' + - ", nextEpoch='" + nextEpoch + '\'' + - '}'; - } -} diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/NodeInfo.java b/src/main/java/org/torusresearch/fetchnodedetails/types/NodeInfo.java deleted file mode 100644 index fc49564..0000000 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/NodeInfo.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.torusresearch.fetchnodedetails.types; - -public final class NodeInfo { - private final String declaredIp; - private final String pubKx; - private final String pubKy; - - public NodeInfo(String _declaredIp, String _pubKx, String _pubKy) { - this.declaredIp = _declaredIp; - this.pubKx = _pubKx; - this.pubKy = _pubKy; - } - - - public String getDeclaredIp() { - return declaredIp; - } - - public String getPubKx() { - return pubKx; - } - - public String getPubKy() { - return pubKy; - } - - - @Override - public String toString() { - return "NodeInfo{" + - ", position='" + declaredIp + '\'' + - ", pubKx='" + pubKx + '\'' + - ", pubKy='" + pubKy + '\'' + - '}'; - } -} diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java index 03e1a84..28c3e2e 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java @@ -1,10 +1,19 @@ package org.torusresearch.fetchnodedetails.types; import java.math.BigInteger; +import java.util.HashMap; public class Utils { - public static NodeDetails NODE_DETAILS_MAINNET = new NodeDetails("19", new String[]{"https://torus-19.torusnode.com/jrpc", "https://torus-node.ens.domains/jrpc", "https://torus-node.matic.network/jrpc", "https://torus.zilliqa.network/jrpc", "https://torus-mainnet.cosmos.network/jrpc", "https://torus2.etherscan.com/jrpc", "https://torus-node-v2.skalelabs.com/jrpc", "https://torus-node.binancex.dev/jrpc", "https://torusnode.ont.io/jrpc"}, new String[]{}, new String[]{}, new String[]{}, new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5"), new BigInteger("6"), new BigInteger("7"), new BigInteger("8"), new BigInteger("9"),}, new TorusNodePub[]{new TorusNodePub("bbe83c64177c3775550e6ba6ac2bc059f6847d644c9e4894e42c60d7974d8c2b", "82b49a7caf70def38cdad2740af45c1e4f969650105c5019a29bb18b21a9acb5"), new TorusNodePub("c208cac4ef9a47d386097a9c915b28e9cb89213abee8d26a17198ee261201b0d", "c7db2fe4631109f40833de9dc78d07e35706549ee48fa557b33e4e75e1047873"), new TorusNodePub("ca1766bb426d4ca5582818a0c5439d560ea64f5baa060793ab29dd3d0ceacfe", "d46c1d08c40e1306e1bca328c2287b8268166b11a1ba4b8442ea2ad0c5e32152"), new TorusNodePub("c3934dd2f6f4b3d2e1e398cc501e143c1e1a381b52feb6d1525af34d16253768", "71f5141a5035799099f5ea3e241e66946bc55dc857ac3bd7d6fcdb8dcd3eeeef"), new TorusNodePub("22e66f1929631d00bf026227581597f085fd94fd952fc0dca9f0833398b5c064", "6088b3912e10a1e9d50355a609c10db7d188f16a2e2fd7357e51bf4f6a74f0a1"), new TorusNodePub("9dc9fa410f3ce9eb70df70cdea00a49f2c4cc7a31c08c0dab5f863ed35ff5139", "627a291cb87a75c61da3f65d6818e1e05e360217179817ed27e8c73bca7ec122"), new TorusNodePub("118b9fc07e97b096d899b9f6658463ce6a8caa64038e37fc969df4e6023dd8c6", "baf9fa4e51770f4796ea165dd03a769b8606681a38954a0a92c4cbffd6609ce9"), new TorusNodePub("8a6d8b925da15a273dec3d8f8395ec35cd6878f274b2b180e4e106999db64043", "96f67f870c157743da0b1eb84d89bf30500d74dc84c11f501ee1cb013acc8c46"), new TorusNodePub("39cecb62e863729f572f7dfc46c24867981bf04bb405fed0df39e33984bfade5", "61c2364434012e68a2be2e9952805037e52629d7762fafc8e10e9fb5bad8f790")}, false); + public static HashMap LEGACY_NETWORKS_ROUTE_MAP = new HashMap() { + { + put(TorusNetwork.AQUA.toString(), new LegacyNetworkMigrationInfo(true, "aqua", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.CELESTE.toString(), new LegacyNetworkMigrationInfo(false, "celeste", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.CYAN.toString(), new LegacyNetworkMigrationInfo(true, "cyan", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.MAINNET.toString(), new LegacyNetworkMigrationInfo(true, "mainnet", TorusNetwork.SAPPHIRE_MAINNET)); + put(TorusNetwork.TESTNET.toString(), new LegacyNetworkMigrationInfo(true, "teal", TorusNetwork.SAPPHIRE_DEVNET)); + } + }; public static NodeDetails NODE_DETAILS_TESTNET = new NodeDetails("1", new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc",}, new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc"}, @@ -18,6 +27,43 @@ public class Utils { new TorusNodePub("bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4")}, false); + public static NodeDetails NODE_DETAILS_MAINNET = new NodeDetails("1", new String[]{"https://sapphire-1.auth.network/sss/mainnet/jrpc", "https://sapphire-2.auth.network/sss/mainnet/jrpc", "https://sapphire-3.auth.network/sss/mainnet/jrpc", "https://sapphire-4.auth.network/sss/mainnet/jrpc", "https://sapphire-5.auth.network/sss/mainnet/jrpc"}, + new String[]{"https://sapphire-1.auth.network/sss/mainnet/jrpc", "https://sapphire-2.auth.network/sss/mainnet/jrpc", "https://sapphire-3.auth.network/sss/mainnet/jrpc", "https://sapphire-4.auth.network/sss/mainnet/jrpc", "https://sapphire-5.auth.network/sss/mainnet/jrpc"}, + new String[]{"https://sapphire-1.auth.network/rss/mainnet", "https://sapphire-2.auth.network/rss/mainnet", "https://sapphire-3.auth.network/rss/mainnet", "https://sapphire-4.auth.network/rss/mainnet", "https://sapphire-5.auth.network/rss/mainnet"}, + new String[]{"https://sapphire-1.auth.network/tss/mainnet", "https://sapphire-2.auth.network/tss/mainnet", "https://sapphire-3.auth.network/tss/mainnet", "https://sapphire-4.auth.network/tss/mainnet", "https://sapphire-5.auth.network/tss/mainnet"}, + new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, + new TorusNodePub[]{new TorusNodePub("e0925898fee0e9e941fdca7ee88deec99939ae9407e923535c4d4a3a3ff8b052", "54b9fea924e3f3e40791f9987f4234ae4222412d65b74068032fa5d8b63375c1"), + new TorusNodePub("9124cf1e280aab32ba50dffd2de81cecabc13d82d2c1fe9de82f3b3523f9b637", "fca939a1ceb42ce745c55b21ef094f543b457630cb63a94ef4f1afeee2b1f107"), + new TorusNodePub("555f681a63d469cc6c3a58a97e29ebd277425f0e6159708e7c7bf05f18f89476", "606f2bcc0884fa5b64366fc3e8362e4939841b56acd60d5f4553cf36b891ac4e"), + new TorusNodePub("2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247"), + new TorusNodePub("3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4")}, + false); + + public static NodeDetails NODE_DETAILS_CYAN = new NodeDetails("1", new String[]{"https://sapphire-1.auth.network/sss/cyan/jrpc", "https://sapphire-2.auth.network/sss/cyan/jrpc", "https://sapphire-3.auth.network/sss/cyan/jrpc", "https://sapphire-4.auth.network/sss/cyan/jrpc", "https://sapphire-5.auth.network/sss/cyan/jrpc"}, + new String[]{"https://sapphire-1.auth.network/sss/cyan/jrpc", "https://sapphire-2.auth.network/sss/cyan/jrpc", "https://sapphire-3.auth.network/sss/cyan/jrpc", "https://sapphire-4.auth.network/sss/cyan/jrpc", "https://sapphire-5.auth.network/sss/cyan/jrpc"}, + new String[]{"https://sapphire-1.auth.network/rss/cyan", "https://sapphire-2.auth.network/rss/cyan", "https://sapphire-3.auth.network/rss/cyan", "https://sapphire-4.auth.network/rss/cyan", "https://sapphire-5.auth.network/rss/cyan"}, + new String[]{"https://sapphire-1.auth.network/tss/cyan", "https://sapphire-2.auth.network/tss/cyan", "https://sapphire-3.auth.network/tss/cyan", "https://sapphire-4.auth.network/tss/cyan", "https://sapphire-5.auth.network/tss/cyan"}, + new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, + new TorusNodePub[]{new TorusNodePub("e0925898fee0e9e941fdca7ee88deec99939ae9407e923535c4d4a3a3ff8b052", "54b9fea924e3f3e40791f9987f4234ae4222412d65b74068032fa5d8b63375c1"), + new TorusNodePub("9124cf1e280aab32ba50dffd2de81cecabc13d82d2c1fe9de82f3b3523f9b637", "fca939a1ceb42ce745c55b21ef094f543b457630cb63a94ef4f1afeee2b1f107"), + new TorusNodePub("555f681a63d469cc6c3a58a97e29ebd277425f0e6159708e7c7bf05f18f89476", "606f2bcc0884fa5b64366fc3e8362e4939841b56acd60d5f4553cf36b891ac4e"), + new TorusNodePub("2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247"), + new TorusNodePub("3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4")}, + false); + + public static NodeDetails NODE_DETAILS_AQUA = new NodeDetails("1", new String[]{"https://sapphire-1.auth.network/sss/aqua/jrpc", "https://sapphire-2.auth.network/sss/aqua/jrpc", "https://sapphire-3.auth.network/sss/aqua/jrpc", "https://sapphire-4.auth.network/sss/aqua/jrpc", "https://sapphire-5.auth.network/sss/aqua/jrpc"}, + new String[]{"https://sapphire-1.auth.network/sss/aqua/jrpc", "https://sapphire-2.auth.network/sss/aqua/jrpc", "https://sapphire-3.auth.network/sss/aqua/jrpc", "https://sapphire-4.auth.network/sss/aqua/jrpc", "https://sapphire-5.auth.network/sss/aqua/jrpc"}, + new String[]{"https://sapphire-1.auth.network/rss/aqua", "https://sapphire-2.auth.network/rss/aqua", "https://sapphire-3.auth.network/rss/aqua", "https://sapphire-4.auth.network/rss/aqua", "https://sapphire-5.auth.network/rss/aqua"}, + new String[]{"https://sapphire-1.auth.network/tss/aqua", "https://sapphire-2.auth.network/tss/aqua", "https://sapphire-3.auth.network/tss/aqua", "https://sapphire-4.auth.network/tss/aqua", "https://sapphire-5.auth.network/tss/aqua"}, + new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, + new TorusNodePub[]{new TorusNodePub("e0925898fee0e9e941fdca7ee88deec99939ae9407e923535c4d4a3a3ff8b052", "54b9fea924e3f3e40791f9987f4234ae4222412d65b74068032fa5d8b63375c1"), + new TorusNodePub("9124cf1e280aab32ba50dffd2de81cecabc13d82d2c1fe9de82f3b3523f9b637", "fca939a1ceb42ce745c55b21ef094f543b457630cb63a94ef4f1afeee2b1f107"), + new TorusNodePub("555f681a63d469cc6c3a58a97e29ebd277425f0e6159708e7c7bf05f18f89476", "606f2bcc0884fa5b64366fc3e8362e4939841b56acd60d5f4553cf36b891ac4e"), + new TorusNodePub("2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247"), + new TorusNodePub("3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4")}, + false); + + public static NodeDetails NODE_DETAILS_SAPPHIRE_MAINNET = new NodeDetails("1", new String[]{"https://sapphire-1.auth.network/sss/jrpc", "https://sapphire-2.auth.network/sss/jrpc", "https://sapphire-3.auth.network/sss/jrpc", "https://sapphire-4.auth.network/sss/jrpc", "https://sapphire-5.auth.network/sss/jrpc"}, new String[]{"https://sapphire-1.auth.network/sss/jrpc", "https://sapphire-2.auth.network/sss/jrpc", "https://sapphire-3.auth.network/sss/jrpc", "https://sapphire-4.auth.network/sss/jrpc", "https://sapphire-5.auth.network/sss/jrpc"}, new String[]{"https://sapphire-1.auth.network/rss", "https://sapphire-2.auth.network/rss", "https://sapphire-3.auth.network/rss", "https://sapphire-4.auth.network/rss", "https://sapphire-5.auth.network/rss"}, @@ -28,19 +74,7 @@ public class Utils { new TorusNodePub("555f681a63d469cc6c3a58a97e29ebd277425f0e6159708e7c7bf05f18f89476", "606f2bcc0884fa5b64366fc3e8362e4939841b56acd60d5f4553cf36b891ac4e"), new TorusNodePub("2b5f58d8e340f1ab922e89b3a69a68930edfe51364644a456335e179bc130128", "4b4daa05939426e3cbe7d08f0e773d2bf36f64c00d04620ee6df2a7af4d2247"), new TorusNodePub("3ecbb6a68afe72cf34ec6c0a12b5cb78a0d2e83ba402983b6adbc5f36219861a", "dc1031c5cc8f0472bd521a62a64ebca9e163902c247bf05937daf4ae835091e4")}, - true); - - public static NodeDetails NODE_DETAILS_SAPPHIRE_TESTNET = new NodeDetails("1", new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc",}, - new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc"}, - new String[]{"https://sapphire-dev-2-1.authnetwork.dev/rss", "https://sapphire-dev-2-2.authnetwork.dev/rss", "https://sapphire-dev-2-3.authnetwork.dev/rss", "https://sapphire-dev-2-4.authnetwork.dev/rss", "https://sapphire-dev-2-5.authnetwork.dev/rss"}, - new String[]{"https://sapphire-dev-2-1.authnetwork.dev/tss", "https://sapphire-dev-2-2.authnetwork.dev/tss", "https://sapphire-dev-2-3.authnetwork.dev/tss", "https://sapphire-dev-2-4.authnetwork.dev/tss", "https://sapphire-dev-2-5.authnetwork.dev/tss"}, - new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("3"), new BigInteger("4"), new BigInteger("5")}, - new TorusNodePub[]{new TorusNodePub("f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7"), - new TorusNodePub("bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a"), - new TorusNodePub("b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c"), - new TorusNodePub("7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b"), - new TorusNodePub("bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4")}, - true); + false); public static NodeDetails NODE_DETAILS_SAPPHIRE_DEVNET = new NodeDetails("1", new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc"}, new String[]{"https://sapphire-dev-2-1.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/jrpc"}, @@ -52,7 +86,7 @@ public class Utils { new TorusNodePub("b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c"), new TorusNodePub("7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b"), new TorusNodePub("bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4")}, - true); + false); public static NodeDetails fetchLocalConfig(TorusNetwork network) { NodeDetails nodeDetails = null; @@ -63,6 +97,10 @@ public static NodeDetails fetchLocalConfig(TorusNetwork network) { nodeDetails = NODE_DETAILS_SAPPHIRE_MAINNET; case MAINNET: nodeDetails = NODE_DETAILS_MAINNET; + case AQUA: + nodeDetails = NODE_DETAILS_AQUA; + case CYAN: + nodeDetails = NODE_DETAILS_CYAN; case TESTNET: nodeDetails = NODE_DETAILS_TESTNET; } diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/Config.java b/src/test/java/org/torusresearch/fetchnodedetailstest/config/Config.java index 46e16d0..6519ac9 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/Config.java +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/Config.java @@ -15,7 +15,6 @@ public class Config { public static NodeDetails AQUA; public static NodeDetails CELESTE; public static NodeDetails SAPPHIRE_DEVNET; - public static NodeDetails SAPPHIRE_TESTNET; public static NodeDetails SAPPHIRE_MAINNET; static { @@ -27,7 +26,6 @@ public class Config { AQUA = getNodeDetailsFromFile(basePath + "aqua.json"); CELESTE = getNodeDetailsFromFile(basePath + "celeste.json"); SAPPHIRE_DEVNET = getNodeDetailsFromFile(basePath + "sapphire_devnet.json"); - SAPPHIRE_TESTNET = getNodeDetailsFromFile(basePath + "sapphire_testnet.json"); SAPPHIRE_MAINNET = getNodeDetailsFromFile(basePath + "sapphire_mainnet.json"); } catch (Exception ex) { ex.printStackTrace(); diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json index 96ac05f..6ddacd1 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/aqua.json @@ -52,5 +52,5 @@ } ], "torusIndexes": [1, 2, 3, 4, 5], - "updated": false + "updated": true } \ No newline at end of file diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/cyan.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/cyan.json index ef5c7a8..f1f577c 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/cyan.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/cyan.json @@ -51,5 +51,5 @@ } ], "torusIndexes": [1, 2, 3, 4, 5], - "updated": false + "updated": true } diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json index 5c82b59..404bfaf 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/mainnet.json @@ -57,5 +57,5 @@ 4, 5 ], - "updated": false + "updated": true } \ No newline at end of file diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json index 0876fa8..6e0db85 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_devnet.json @@ -56,5 +56,6 @@ 3, 4, 5 - ] + ], + "updated": true } \ No newline at end of file diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json index fd038bd..acc6a91 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/sapphire_mainnet.json @@ -56,5 +56,6 @@ 3, 4, 5 - ] + ], + "updated": true } \ No newline at end of file diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json b/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json index b2b4db5..b5b4146 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/config/testnet.json @@ -57,5 +57,5 @@ 4, 5 ], - "updated": false + "updated": true } From fdb07bcacca4c4d18015bff086456f1dcbc916b4 Mon Sep 17 00:00:00 2001 From: chaitanyapotti Date: Wed, 1 Nov 2023 19:32:53 +0800 Subject: [PATCH 24/26] DEFAULT NETWORK SHOULD BE SAPPHIRE MAINNET --- .../org/torusresearch/fetchnodedetails/FetchNodeDetails.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index f5b2614..0c7ef7f 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -19,10 +19,10 @@ public class FetchNodeDetails { private List multi_cluster_networks = Arrays.asList("celeste"); private final NodeDetails nodeDetails = new NodeDetails(); - private TorusNetwork torusNetwork = TorusNetwork.MAINNET; + private TorusNetwork torusNetwork = TorusNetwork.SAPPHIRE_MAINNET; public FetchNodeDetails() { - this(TorusNetwork.MAINNET); + this(TorusNetwork.SAPPHIRE_MAINNET); } public FetchNodeDetails(TorusNetwork network) { From 6fc4940b9d1151295f1c43b578d5bf5035a55f82 Mon Sep 17 00:00:00 2001 From: chaitanyapotti Date: Wed, 1 Nov 2023 19:33:37 +0800 Subject: [PATCH 25/26] fix test --- .../fetchnodedetailstest/FetchNodeDetailsTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java index 8d14726..bd4c176 100644 --- a/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java +++ b/src/test/java/org/torusresearch/fetchnodedetailstest/FetchNodeDetailsTest.java @@ -17,7 +17,7 @@ class FetchNodeDetailsTest { @DisplayName("Gets the Node details for Mainnet") @Test public void shouldGetNodeDetailsMainnet() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(); + fetchNodeDetails = new FetchNodeDetails(TorusNetwork.MAINNET); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.MAINNET, nodeDetails); } @@ -65,7 +65,7 @@ public void shouldGetNodeDetailsSapphireDevnet() throws ExecutionException, Inte @DisplayName("Gets the Node details for SapphireMainnet") @Test public void shouldGetNodeDetailsSapphireMainnet() throws ExecutionException, InterruptedException { - fetchNodeDetails = new FetchNodeDetails(TorusNetwork.SAPPHIRE_MAINNET); + fetchNodeDetails = new FetchNodeDetails(); NodeDetails nodeDetails = this.fetchNodeDetails.getNodeDetails("google", "hello@tor.us").get(); assertEquals(Config.SAPPHIRE_MAINNET, nodeDetails); } From 21d3a4102d6f9d117950cf1affedf97db687dee7 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Wed, 1 Nov 2023 17:21:01 +0530 Subject: [PATCH 26/26] NETWORK_MAP and SIGNER_MAP added in Utils.java Signed-off-by: Gaurav Goel --- .../fetchnodedetails/FetchNodeDetails.java | 2 -- .../fetchnodedetails/types/Utils.java | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java index 0c7ef7f..efde8a8 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/FetchNodeDetails.java @@ -4,13 +4,11 @@ import org.torusresearch.fetchnodedetails.types.APIUtils; import org.torusresearch.fetchnodedetails.types.FNDResponse; -import org.torusresearch.fetchnodedetails.types.LegacyNetworkMigrationInfo; import org.torusresearch.fetchnodedetails.types.NodeDetails; import org.torusresearch.fetchnodedetails.types.TorusNetwork; import org.torusresearch.fetchnodedetails.types.Utils; import java.util.Arrays; -import java.util.HashMap; import java.util.List; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java index 28c3e2e..0ef21d1 100644 --- a/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java +++ b/src/main/java/org/torusresearch/fetchnodedetails/types/Utils.java @@ -2,6 +2,7 @@ import java.math.BigInteger; import java.util.HashMap; +import java.util.Map; public class Utils { @@ -106,4 +107,26 @@ public static NodeDetails fetchLocalConfig(TorusNetwork network) { } return nodeDetails; } + + public static final Map NETWORK_MAP = new HashMap() { + { + put(TorusNetwork.MAINNET, "mainnet"); + put(TorusNetwork.TESTNET, "goerli"); + put(TorusNetwork.CYAN, "polygon-mainnet"); + put(TorusNetwork.AQUA, "polygon-mainnet"); + put(TorusNetwork.CELESTE, "polygon-mainnet"); + + } + }; + + public static final Map SIGNER_MAP = new HashMap() { + { + put(TorusNetwork.MAINNET, "https://signer.tor.us"); + put(TorusNetwork.TESTNET, "https://signer.tor.us"); + put(TorusNetwork.CYAN, "https://signer-polygon.tor.us"); + put(TorusNetwork.AQUA, "https://signer-polygon.tor.us"); + put(TorusNetwork.CELESTE, "https://signer-polygon.tor.us"); + + } + }; }