From df7145eccd695723cf5206723271c23c2e08c438 Mon Sep 17 00:00:00 2001 From: mikera Date: Wed, 25 Dec 2024 11:05:57 +0000 Subject: [PATCH] Add Protonet warning before running stress test --- convex-core/src/main/java/convex/core/Networks.java | 8 ++++++++ convex-core/src/main/java/convex/core/cvm/Peer.java | 8 ++++++++ .../src/main/java/convex/gui/server/StressPanel.java | 11 ++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 convex-core/src/main/java/convex/core/Networks.java diff --git a/convex-core/src/main/java/convex/core/Networks.java b/convex-core/src/main/java/convex/core/Networks.java new file mode 100644 index 000000000..c25542314 --- /dev/null +++ b/convex-core/src/main/java/convex/core/Networks.java @@ -0,0 +1,8 @@ +package convex.core; + +import convex.core.data.Hash; + +public class Networks { + + public static final Hash PRONONET_GENESIS=Hash.parse("0xb0e44f2a645abfa539f5b96b7a0eabb0f902866feaff0f7c12d1213e02333f13"); +} diff --git a/convex-core/src/main/java/convex/core/cvm/Peer.java b/convex-core/src/main/java/convex/core/cvm/Peer.java index 5bbc25120..770b6fac3 100644 --- a/convex-core/src/main/java/convex/core/cvm/Peer.java +++ b/convex-core/src/main/java/convex/core/cvm/Peer.java @@ -677,4 +677,12 @@ public boolean isReadyToPublish() { if (ps.getBalance() { + Hash network=peerView.getLocalServer().getPeer().getGenesisHash(); + if (network.equals(Networks.PRONONET_GENESIS)) { + int confirm=JOptionPane.showConfirmDialog(this, "This is the live network. Running a stress test is likley to be expensive! Are you really sure you want to do this?", "Run test on Live network?", JOptionPane.WARNING_MESSAGE); + if (confirm!=JOptionPane.OK_OPTION) return; + } + btnRun.setEnabled(false); Address address=peerConvex.getAddress(); AKeyPair kp=peerConvex.getKeyPair(); @@ -238,7 +247,7 @@ protected String doStressRun() throws Exception { // Generate client accounts StringBuilder cmdsb=new StringBuilder(); - cmdsb.append("(let [f (fn [k] (let [a (create-account k)] (transfer a 1000000000) a))] "); + cmdsb.append("(let [f (fn [k] (let [a (deploy `(do (set-key ~k) (set-controller #13))] (transfer a 1000000000) a))] "); cmdsb.append(" (mapv f ["); for (int i=0; i