5
5
import com .google .protobuf .Any ;
6
6
import com .google .protobuf .ByteString ;
7
7
import java .math .BigInteger ;
8
+ import java .util .Arrays ;
8
9
import java .util .HashMap ;
9
- import java .util .List ;
10
10
import java .util .Objects ;
11
11
import java .util .concurrent .atomic .AtomicLong ;
12
12
import lombok .Getter ;
23
23
import org .tron .protos .Contract .FreezeBalanceContract ;
24
24
import org .tron .protos .Contract .UnfreezeBalanceContract ;
25
25
import org .tron .protos .Protocol .Transaction ;
26
- import org .tron .protos .Protocol .Transaction .Contract ;
27
26
import org .tron .protos .Protocol .Transaction .Contract .ContractType ;
28
27
import org .tron .stresstest .dispatch .strategy .Level2Strategy ;
29
28
@@ -74,8 +73,20 @@ public abstract class AbstractTransactionCreator extends Level2Strategy {
74
73
.getString ("address.commonContractAddress5" );
75
74
protected String commonContractAddress6 = Configuration .getByPath ("stress.conf" )
76
75
.getString ("address.commonContractAddress6" );
76
+ protected String commonContractAddress7 = Configuration .getByPath ("stress.conf" )
77
+ .getString ("address.commonContractAddress7" );
78
+ protected String commonContractAddress8 = Configuration .getByPath ("stress.conf" )
79
+ .getString ("address.commonContractAddress8" );
80
+ protected String commonContractAddress9 = Configuration .getByPath ("stress.conf" )
81
+ .getString ("address.commonContractAddress9" );
82
+ protected String commonContractAddress10 = Configuration .getByPath ("stress.conf" )
83
+ .getString ("address.commonContractAddress10" );
84
+ protected String commonContractAddress11 = Configuration .getByPath ("stress.conf" )
85
+ .getString ("address.commonContractAddress11" );
77
86
protected String SideGatewayContractAddress = Configuration .getByPath ("stress.conf" )
78
87
.getString ("address.SideGatewayContractAddress" );
88
+ protected String MainGatewayContractAddress = Configuration .getByPath ("stress.conf" )
89
+ .getString ("address.MainGatewayContractAddress" );
79
90
protected String SideTRC20ContractContractAddress = Configuration .getByPath ("stress.conf" )
80
91
.getString ("address.SideTRC20ContractContractAddress" );
81
92
@@ -93,7 +104,7 @@ public abstract class AbstractTransactionCreator extends Level2Strategy {
93
104
long time = System .currentTimeMillis ();
94
105
AtomicLong count = new AtomicLong ();
95
106
96
- public Transaction createTransaction (com .google .protobuf .Message message ,
107
+ public synchronized Transaction createTransaction (com .google .protobuf .Message message ,
97
108
ContractType contractType ) {
98
109
Transaction .raw .Builder transactionBuilder = Transaction .raw .newBuilder ().addContract (
99
110
Transaction .Contract .newBuilder ().setType (contractType ).setParameter (
@@ -253,36 +264,36 @@ public Transaction setExpiration(Transaction transaction, long expiration) {
253
264
}
254
265
255
266
public static Transaction sign (Transaction transaction , ECKey myKey ) {
256
- Transaction .Builder transactionBuilderSigned = transaction .toBuilder ();
257
- byte [] hash = Sha256Hash .hash (transaction .getRawData ().toByteArray ());
258
- List <Contract > listContract = transaction .getRawData ().getContractList ();
259
- for (int i = 0 ; i < listContract .size (); i ++) {
260
- ECDSASignature signature = myKey .sign (hash );
261
- ByteString bsSign = ByteString .copyFrom (signature .toByteArray ());
262
- transactionBuilderSigned .addSignature (
263
- bsSign );
264
- }
265
-
266
- transaction = transactionBuilderSigned .build ();
267
- return transaction ;
268
- // byte[] chainId = decodeFromBase58Check("TUmGh8c2VcpfmJ7rBYq1FU9hneXhz3P8z3");
269
267
// Transaction.Builder transactionBuilderSigned = transaction.toBuilder();
270
268
// byte[] hash = Sha256Hash.hash(transaction.getRawData().toByteArray());
271
- //
272
- // byte[] newHash;
273
- // if (false) {
274
- // newHash = hash;
275
- // } else {
276
- // byte[] hashWithChainId = Arrays.copyOf(hash, hash.length + chainId.length);
277
- // System.arraycopy(chainId, 0, hashWithChainId, hash.length, chainId.length);
278
- // newHash = Sha256Hash.hash(hashWithChainId);
269
+ // List<Contract> listContract = transaction.getRawData().getContractList();
270
+ // for (int i = 0; i < listContract.size(); i++) {
271
+ // ECDSASignature signature = myKey.sign(hash);
272
+ // ByteString bsSign = ByteString.copyFrom(signature.toByteArray());
273
+ // transactionBuilderSigned.addSignature(
274
+ // bsSign);
279
275
// }
280
276
//
281
- // ECDSASignature signature = myKey.sign(newHash);
282
- // ByteString bsSign = ByteString.copyFrom(signature.toByteArray());
283
- // transactionBuilderSigned.addSignature(bsSign);
284
277
// transaction = transactionBuilderSigned.build();
285
278
// return transaction;
279
+ byte [] chainId = decodeFromBase58Check ("TYYrjz9W9ii98zMEF7KoL24KhGRXqWpjEJ" );
280
+ Transaction .Builder transactionBuilderSigned = transaction .toBuilder ();
281
+ byte [] hash = Sha256Hash .hash (transaction .getRawData ().toByteArray ());
282
+
283
+ byte [] newHash ;
284
+ if (false ) {
285
+ newHash = hash ;
286
+ } else {
287
+ byte [] hashWithChainId = Arrays .copyOf (hash , hash .length + chainId .length );
288
+ System .arraycopy (chainId , 0 , hashWithChainId , hash .length , chainId .length );
289
+ newHash = Sha256Hash .hash (hashWithChainId );
290
+ }
291
+
292
+ ECDSASignature signature = myKey .sign (newHash );
293
+ ByteString bsSign = ByteString .copyFrom (signature .toByteArray ());
294
+ transactionBuilderSigned .addSignature (bsSign );
295
+ transaction = transactionBuilderSigned .build ();
296
+ return transaction ;
286
297
}
287
298
288
299
public static Transaction mutiSignNew (Transaction transaction , String [] permissionKeyString ) {
@@ -446,7 +457,8 @@ public org.tron.protos.Contract.AssetIssueContract createAssetIssueContract(
446
457
return builder .build ();
447
458
}
448
459
449
- public org .tron .protos .Contract .TriggerSmartContract triggerCallContract (byte [] address ,
460
+ public org .tron .protos .Contract .TriggerSmartContract triggerCallContract (
461
+ byte [] address ,
450
462
byte [] contractAddress ,
451
463
long callValue , byte [] data ) {
452
464
org .tron .protos .Contract .TriggerSmartContract .Builder builder = org .tron .protos .Contract .TriggerSmartContract
@@ -460,6 +472,20 @@ public org.tron.protos.Contract.TriggerSmartContract triggerCallContract(byte[]
460
472
return builder .build ();
461
473
}
462
474
475
+ public org .tron .protos .Contract .TriggerSmartContract triggerCallContract (byte [] address ,
476
+ byte [] contractAddress ,
477
+ long callValue , byte [] data , long tokenValue , String tokenId ) {
478
+ org .tron .protos .Contract .TriggerSmartContract .Builder builder = org .tron .protos .Contract .TriggerSmartContract
479
+ .newBuilder ();
480
+ builder .setOwnerAddress (ByteString .copyFrom (address ));
481
+ builder .setContractAddress (ByteString .copyFrom (contractAddress ));
482
+ builder .setData (ByteString .copyFrom (data ));
483
+ builder .setCallValue (callValue );
484
+ builder .setCallTokenValue (tokenValue );
485
+ builder .setTokenId (Long .parseLong (tokenId ));
486
+ return builder .build ();
487
+ }
488
+
463
489
public FreezeBalanceContract createFreezeBalanceContract (byte [] ownerAddress , long frozen_balance ,
464
490
long frozen_duration , int resourceCode , String receiverAddress ) {
465
491
org .tron .protos .Contract .FreezeBalanceContract .Builder builder = org .tron .protos .Contract .FreezeBalanceContract
0 commit comments