Skip to content

Commit df7145e

Browse files
committed
Add Protonet warning before running stress test
1 parent 0123dab commit df7145e

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package convex.core;
2+
3+
import convex.core.data.Hash;
4+
5+
public class Networks {
6+
7+
public static final Hash PRONONET_GENESIS=Hash.parse("0xb0e44f2a645abfa539f5b96b7a0eabb0f902866feaff0f7c12d1213e02333f13");
8+
}

convex-core/src/main/java/convex/core/cvm/Peer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,4 +677,12 @@ public boolean isReadyToPublish() {
677677
if (ps.getBalance()<CPoSConstants.MINIMUM_EFFECTIVE_STAKE) return false;
678678
return true;
679679
}
680+
681+
/**
682+
* Gets the genesis state hash for this peer
683+
* @return
684+
*/
685+
public Hash getGenesisHash() {
686+
return getGenesisState().getHash();
687+
}
680688
}

convex-gui/src/main/java/convex/gui/server/StressPanel.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import javax.swing.JCheckBox;
2020
import javax.swing.JComboBox;
2121
import javax.swing.JLabel;
22+
import javax.swing.JOptionPane;
2223
import javax.swing.JPanel;
2324
import javax.swing.JSpinner;
2425
import javax.swing.JSplitPane;
@@ -30,6 +31,7 @@
3031
import org.slf4j.LoggerFactory;
3132

3233
import convex.api.Convex;
34+
import convex.core.Networks;
3335
import convex.core.Result;
3436
import convex.core.crypto.AKeyPair;
3537
import convex.core.cvm.transactions.ATransaction;
@@ -38,6 +40,7 @@
3840
import convex.core.cvm.transactions.Transfer;
3941
import convex.core.data.ACell;
4042
import convex.core.data.AVector;
43+
import convex.core.data.Hash;
4144
import convex.core.cvm.Address;
4245
import convex.core.data.Strings;
4346
import convex.core.lang.Reader;
@@ -83,6 +86,12 @@ public StressPanel(Convex peerView) {
8386
btnRun = new JButton("Run Test");
8487
actionPanel.add(btnRun);
8588
btnRun.addActionListener(e -> {
89+
Hash network=peerView.getLocalServer().getPeer().getGenesisHash();
90+
if (network.equals(Networks.PRONONET_GENESIS)) {
91+
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);
92+
if (confirm!=JOptionPane.OK_OPTION) return;
93+
}
94+
8695
btnRun.setEnabled(false);
8796
Address address=peerConvex.getAddress();
8897
AKeyPair kp=peerConvex.getKeyPair();
@@ -238,7 +247,7 @@ protected String doStressRun() throws Exception {
238247

239248
// Generate client accounts
240249
StringBuilder cmdsb=new StringBuilder();
241-
cmdsb.append("(let [f (fn [k] (let [a (create-account k)] (transfer a 1000000000) a))] ");
250+
cmdsb.append("(let [f (fn [k] (let [a (deploy `(do (set-key ~k) (set-controller #13))] (transfer a 1000000000) a))] ");
242251
cmdsb.append(" (mapv f [");
243252
for (int i=0; i<clientCount; i++) {
244253
AKeyPair kp=AKeyPair.generate();

0 commit comments

Comments
 (0)