Skip to content

Commit 7c4fd02

Browse files
committed
Merge branch 'master' into hotfix/v3.2.2_energy_limit
2 parents fbb019a + 7ddd2d6 commit 7c4fd02

File tree

15 files changed

+1031
-93
lines changed

15 files changed

+1031
-93
lines changed

src/main/java/org/tron/core/config/Parameter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface ChainConstant {
2323
int BLOCK_FILLED_SLOTS_NUMBER = 128;
2424
int MAX_VOTE_NUMBER = 30;
2525
int MAX_FROZEN_NUMBER = 1;
26-
int BLOCK_VERSION = 5;
26+
int BLOCK_VERSION = 6;
2727
}
2828

2929
interface NodeConstant {

src/main/java/org/tron/core/db/Manager.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,13 +1604,8 @@ public synchronized void preValidateTransactionSign(BlockCapsule block)
16041604
}
16051605

16061606
public void rePush(TransactionCapsule tx) {
1607-
1608-
try {
1609-
if (transactionStore.get(tx.getTransactionId().getBytes()) != null) {
1610-
return;
1611-
}
1612-
} catch (BadItemException e) {
1613-
// do nothing
1607+
if (transactionStore.has(tx.getTransactionId().getBytes())) {
1608+
return;
16141609
}
16151610

16161611
try {

src/main/java/org/tron/program/SolidityNode.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.tron.core.config.DefaultConfig;
2626
import org.tron.core.config.args.Args;
2727
import org.tron.core.db.Manager;
28-
import org.tron.core.net.message.BlockMessage;
2928
import org.tron.core.services.RpcApiService;
3029
import org.tron.core.services.http.solidity.SolidityNodeHttpApiService;
3130
import org.tron.protos.Protocol.Block;
@@ -51,7 +50,7 @@ public class SolidityNode {
5150

5251
private AtomicLong lastSolidityBlockNum = new AtomicLong();
5352

54-
private long startTime = System.currentTimeMillis();
53+
private int maxBlockCacheSize = 10_000;
5554

5655
private volatile boolean syncFlag = true;
5756

@@ -89,7 +88,7 @@ private void getSyncBlock() {
8988
long blockNum = getNextSyncBlockId();
9089
while (blockNum != 0) {
9190
try {
92-
if (blockMap.size() > 10000) {
91+
if (blockMap.size() > maxBlockCacheSize) {
9392
sleep(1000);
9493
continue;
9594
}
@@ -137,7 +136,7 @@ private void getAdvBlock() {
137136
long blockNum = ID.incrementAndGet();
138137
while (flag) {
139138
try {
140-
if (blockNum > remoteLastSolidityBlockNum.get()) {
139+
if (blockNum > remoteLastSolidityBlockNum.get() || blockMap.size() > maxBlockCacheSize) {
141140
sleep(3000);
142141
remoteLastSolidityBlockNum.set(getLastSolidityBlockNum());
143142
continue;
@@ -200,12 +199,11 @@ private void processBlock() {
200199
loopProcessBlock(block);
201200
blockBakQueue.put(block);
202201
logger.info(
203-
"Success to process block: {}, blockMapSize: {}, blockQueueSize: {}, blockBakQueue: {}, cost {}.",
202+
"Success to process block: {}, blockMapSize: {}, blockQueueSize: {}, blockBakQueue: {}.",
204203
block.getBlockHeader().getRawData().getNumber(),
205204
blockMap.size(),
206205
blockQueue.size(),
207-
blockBakQueue.size(),
208-
(System.currentTimeMillis() - startTime));
206+
blockBakQueue.size());
209207
} catch (Exception e) {
210208
logger.error(e.getMessage());
211209
sleep(100);

src/test/java/org/tron/core/net/node/BroadTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public void testConsumerAdvObjToFetch() throws InterruptedException {
176176
}
177177
}
178178
}
179-
Assert.assertTrue(count >= 2);
179+
Assert.assertTrue(count >= 1);
180180
}
181181

182182
private static boolean go = false;

src/test/java/stest/tron/wallet/account/WalletTestAccount006.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public void beforeClass() {
7070

7171
@Test(enabled = true)
7272
public void testGetAccountNet() {
73+
ecKey = new ECKey(Utils.getRandom());
74+
account006Address = ecKey.getAddress();
75+
account006Key = ByteArray.toHexString(ecKey.getPrivKeyBytes());
7376
//Sendcoin to this account
7477
ByteString addressBS1 = ByteString.copyFrom(account006Address);
7578
Account request1 = Account.newBuilder().setAddress(addressBS1).build();

src/test/java/stest/tron/wallet/account/WalletTestAccount011.java

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package stest.tron.wallet.account;
22

3+
import com.google.protobuf.ByteString;
34
import io.grpc.ManagedChannel;
45
import io.grpc.ManagedChannelBuilder;
56
import java.util.concurrent.TimeUnit;
@@ -9,15 +10,20 @@
910
import org.testng.annotations.BeforeClass;
1011
import org.testng.annotations.BeforeSuite;
1112
import org.testng.annotations.Test;
12-
import org.tron.api.GrpcAPI.AccountResourceMessage;
13+
import org.tron.api.GrpcAPI.BytesMessage;
14+
import org.tron.api.GrpcAPI.EasyTransferByPrivateMessage;
15+
import org.tron.api.GrpcAPI.EasyTransferMessage;
1316
import org.tron.api.GrpcAPI.EmptyMessage;
1417
import org.tron.api.WalletGrpc;
1518
import org.tron.api.WalletSolidityGrpc;
1619
import org.tron.common.crypto.ECKey;
1720
import org.tron.common.utils.ByteArray;
1821
import org.tron.common.utils.Utils;
1922
import org.tron.core.Wallet;
23+
import org.tron.protos.Contract;
24+
import org.tron.protos.Protocol;
2025
import org.tron.protos.Protocol.Account;
26+
import org.tron.protos.Protocol.TransactionSign;
2127
import stest.tron.wallet.common.client.Configuration;
2228
import stest.tron.wallet.common.client.Parameter.CommonConstant;
2329
import stest.tron.wallet.common.client.utils.PublicMethed;
@@ -71,6 +77,64 @@ public void testgenerateAddress() {
7177
blockingStubSolidity.generateAddress(builder.build());
7278
}
7379

80+
@Test(enabled = true)
81+
public void testeasyTransfer() {
82+
ecKey1 = new ECKey(Utils.getRandom());
83+
account011Address = ecKey1.getAddress();
84+
account011Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes());
85+
PublicMethed.printAddress(testKey002);
86+
PublicMethed.printAddress(account011Key);
87+
Assert.assertTrue(PublicMethed.sendcoin(account011Address,10000000L,fromAddress,
88+
testKey002,blockingStubFull));
89+
90+
91+
String password = Long.toString(System.currentTimeMillis());
92+
BytesMessage.Builder builder = BytesMessage.newBuilder();
93+
builder.setValue(ByteString.copyFrom(password.getBytes()));
94+
BytesMessage result = blockingStubFull.createAddress(builder.build());
95+
byte[] address = result.getValue().toByteArray();
96+
97+
Account fromAccount = PublicMethed.queryAccount(account011Key,blockingStubFull);
98+
final long beforeFromBaslance = fromAccount.getBalance();
99+
100+
EasyTransferByPrivateMessage.Builder builder1 = EasyTransferByPrivateMessage.newBuilder();
101+
builder1.setPrivateKey(ByteString.copyFrom(ByteArray.fromHexString(account011Key)));
102+
builder1.setToAddress(ByteString.copyFrom(address));
103+
builder1.setAmount(2000000L);
104+
Assert.assertTrue(blockingStubFull.easyTransferByPrivate(builder1.build())
105+
.getResult().getCodeValue() == 0);
106+
107+
fromAccount = PublicMethed.queryAccount(account011Key,blockingStubFull);
108+
final long afterFromBaslance = fromAccount.getBalance();
109+
logger.info("beforeFromBaslance is " + beforeFromBaslance);
110+
logger.info("afterFromBaslance is " + afterFromBaslance);
111+
logger.info("min is " + (beforeFromBaslance - afterFromBaslance));
112+
Assert.assertTrue(beforeFromBaslance - afterFromBaslance == 2000000L + 100000);
113+
114+
115+
EasyTransferMessage.Builder builder2 = EasyTransferMessage.newBuilder();
116+
builder2.setPassPhrase(ByteString.copyFrom(password.getBytes()));
117+
builder2.setToAddress(ByteString.copyFrom(account011Address));
118+
builder2.setAmount(100);
119+
Assert.assertTrue(blockingStubFull.easyTransfer(builder2.build()).getResult()
120+
.getCodeValue() == 0);
121+
122+
Contract.TransferContract.Builder builder5 = Contract.TransferContract.newBuilder();
123+
ByteString bsTo = ByteString.copyFrom(address);
124+
ByteString bsOwner = ByteString.copyFrom(account011Address);
125+
builder5.setToAddress(bsTo);
126+
builder5.setOwnerAddress(bsOwner);
127+
builder5.setAmount(100L);
128+
129+
Contract.TransferContract contract = builder5.build();
130+
Protocol.Transaction transaction = blockingStubFull.createTransaction(contract);
131+
132+
TransactionSign.Builder builder4 = TransactionSign.newBuilder();
133+
builder4.setPrivateKey(ByteString.copyFrom(ByteArray.fromHexString(account011Key)));
134+
builder4.setTransaction(transaction);
135+
blockingStubFull.getTransactionSign(builder4.build());
136+
blockingStubFull.getTransactionSign2(builder4.build());
137+
}
74138

75139
@AfterClass(enabled = true)
76140
public void shutdown() throws InterruptedException {

0 commit comments

Comments
 (0)