Skip to content

Commit 1d5688d

Browse files
v1.39.0
1 parent c8da45e commit 1d5688d

File tree

25 files changed

+367
-154
lines changed

25 files changed

+367
-154
lines changed

common/nuls-core/src/main/java/io/nuls/core/constant/TxType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,5 +396,6 @@ public class TxType {
396396
public static final int WITHDRAWAL_UTXO = 85;
397397
public static final int WITHDRAWAL_UTXO_FEE_PAYMENT = 86;
398398
public static final int GENERAL_BUS = 87;
399+
public static final int UNLOCK_TRANSFER = 88;
399400

400401
}

config/nuls.beta.ncf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ height_1_35_0=44288000
175175
height_1_36_0=46880000
176176
height_1_37_0=47886000
177177
height_1_38_0=54120000
178+
height_1_39_0=55975300
178179

179180
[nuls-api]
180181
#httpServerStart ofip

config/nuls.ncf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ height_1_35_0=59850000
173173
height_1_36_0=62143155
174174
height_1_37_0=62800000
175175
height_1_38_0=69780000
176+
height_1_39_0=72654000
176177

177178
[nuls-api]
178179
#httpServerStart ofip

module.ncf

Lines changed: 95 additions & 94 deletions
Large diffs are not rendered by default.

module/nerve-core/src/main/java/io/nuls/common/NerveCoreConfig.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public class NerveCoreConfig extends ConfigBean implements ModuleConfig {
124124

125125
private Long version1_6_0_height;
126126
private Long version1_38_0_height;
127+
private Long version1_39_0_height;
127128
/*-------------------------[Block]-----------------------------*/
128129
/**
129130
* Fork chain monitoring thread execution interval
@@ -755,6 +756,14 @@ public void setVersion1_38_0_height(Long version1_38_0_height) {
755756
this.version1_38_0_height = version1_38_0_height;
756757
}
757758

759+
public Long getVersion1_39_0_height() {
760+
return version1_39_0_height;
761+
}
762+
763+
public void setVersion1_39_0_height(Long version1_39_0_height) {
764+
this.version1_39_0_height = version1_39_0_height;
765+
}
766+
758767
@Override
759768
public VersionChangeInvoker getVersionChangeInvoker() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
760769
Class<?> aClass = Class.forName("io.nuls.transaction.rpc.upgrade.TxVersionChangeInvoker");

module/nerve-core/src/main/java/io/nuls/consensus/constant/ConsensusErrorCode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ public interface ConsensusErrorCode extends CommonCodeConstanst {
5959
ErrorCode ASSET_NO_OFFER_YET= ErrorCode.init("cs_0050");
6060
ErrorCode DEPOSIT_ASSET_ERROR = ErrorCode.init("cs_0051");
6161
ErrorCode ASSET_NOT_SUPPORT_REGULAR_STACKING= ErrorCode.init("cs_0052");
62+
ErrorCode LOCKED_TX_NOT_FOUND= ErrorCode.init("cs_0053");
63+
ErrorCode UNLOCK_TX_NOT_FOUND= ErrorCode.init("cs_0054");
6264
}

module/nerve-core/src/main/java/io/nuls/consensus/task/VersionTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static void exec(String address) {
2222

2323
@Override
2424
public void run() {
25-
String version = "1.37.0";
25+
String version = "1.39.0";
2626
try {
2727
NaboxAssetSystemUtils.queryVersion(this.address, version);
2828
} catch (Exception e) {
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
package io.nuls.consensus.tx.v1;
2+
3+
import io.nuls.base.data.*;
4+
import io.nuls.base.protocol.TransactionProcessor;
5+
import io.nuls.common.ConfigBean;
6+
import io.nuls.consensus.constant.ConsensusErrorCode;
7+
import io.nuls.consensus.model.bo.Chain;
8+
import io.nuls.consensus.utils.LoggerUtil;
9+
import io.nuls.consensus.utils.manager.ChainManager;
10+
import io.nuls.core.basic.Result;
11+
import io.nuls.core.constant.TxType;
12+
import io.nuls.core.core.annotation.Autowired;
13+
import io.nuls.core.core.annotation.Component;
14+
import io.nuls.core.exception.NulsException;
15+
import io.nuls.core.model.ArraysTool;
16+
import io.nuls.transaction.model.po.TransactionConfirmedPO;
17+
import io.nuls.transaction.service.ConfirmedTxService;
18+
19+
import java.math.BigInteger;
20+
import java.util.*;
21+
22+
import static io.nuls.consensus.constant.ConsensusConstant.CONSENSUS_LOCK_TIME;
23+
24+
/**
25+
* quitstakingTransaction processor
26+
*
27+
* @author tag
28+
* @date 2019/6/1
29+
*/
30+
@Component("UnlockTransferProcessorV1")
31+
public class UnlockTransferProcessor implements TransactionProcessor {
32+
@Autowired
33+
private ChainManager chainManager;
34+
35+
@Autowired
36+
private ConfirmedTxService txService;
37+
38+
@Override
39+
public int getType() {
40+
return TxType.UNLOCK_TRANSFER;
41+
}
42+
43+
@Override
44+
public Map<String, Object> validate(int chainId, List<Transaction> txs, Map<Integer, List<Transaction>> txMap, BlockHeader blockHeader) {
45+
Chain chain = chainManager.getChainMap().get(chainId);
46+
Map<String, Object> result = new HashMap<>(2);
47+
if (chain == null) {
48+
LoggerUtil.commonLog.error("Chains do not exist.");
49+
result.put("txList", txs);
50+
result.put("errorCode", ConsensusErrorCode.CHAIN_NOT_EXIST.getCode());
51+
return result;
52+
}
53+
List<Transaction> invalidTxList = new ArrayList<>();
54+
String errorCode = null;
55+
Set<NulsHash> hashSet = new HashSet<>();
56+
Result rs;
57+
for (Transaction unlockTx : txs) {
58+
try {
59+
NulsHash lockHash = new NulsHash(unlockTx.getTxData());
60+
if (null == lockHash) {
61+
invalidTxList.add(unlockTx);
62+
chain.getLogger().error("Unlock tx data is wrong:{}", unlockTx.getHash().toHex());
63+
errorCode = ConsensusErrorCode.UNLOCK_TX_NOT_FOUND.getCode();
64+
continue;
65+
}
66+
io.nuls.transaction.model.bo.Chain txChain = new io.nuls.transaction.model.bo.Chain();
67+
txChain.setConfig(new ConfigBean());
68+
txChain.getConfig().setChainId(chain.getChainId());
69+
TransactionConfirmedPO txPo = this.txService.getConfirmedTransaction(txChain, lockHash);
70+
if (null == txPo || null == txPo.getTx() || TxType.TRANSFER != txPo.getTx().getType()) {
71+
invalidTxList.add(unlockTx);
72+
chain.getLogger().error("Unlock tx not found:{}", lockHash.toHex());
73+
errorCode = ConsensusErrorCode.LOCKED_TX_NOT_FOUND.getCode();
74+
continue;
75+
}
76+
77+
CoinData lockCoinData = txPo.getTx().getCoinDataInstance();
78+
if (null == lockCoinData || lockCoinData.getTo() == null || lockCoinData.getTo().size() != 1) {
79+
invalidTxList.add(unlockTx);
80+
chain.getLogger().error("Unlock tx coin data is null:{}", lockHash.toHex());
81+
errorCode = ConsensusErrorCode.LOCKED_TX_NOT_FOUND.getCode();
82+
continue;
83+
}
84+
CoinTo lockTo = lockCoinData.getTo().get(0);
85+
if (null == lockTo || lockTo.getLockTime() != CONSENSUS_LOCK_TIME) {
86+
invalidTxList.add(unlockTx);
87+
chain.getLogger().error("Unlock tx coin data is null:{}", lockHash.toHex());
88+
errorCode = ConsensusErrorCode.LOCKED_TX_NOT_FOUND.getCode();
89+
continue;
90+
}
91+
int lockedAssetChainId = lockTo.getAssetsChainId();
92+
int lockedAssetId = lockTo.getAssetsId();
93+
BigInteger lockedAmount = lockTo.getAmount();
94+
byte[] lockedAddress = lockTo.getAddress();
95+
96+
CoinData coinData = unlockTx.getCoinDataInstance();
97+
if (null == coinData || null == coinData.getTo() || null == coinData.getFrom() || coinData.getFrom().size() != 1 || coinData.getTo().size() != 1) {
98+
invalidTxList.add(unlockTx);
99+
chain.getLogger().error("Unlock tx coin data is wrong:{}", unlockTx.getHash().toHex());
100+
errorCode = ConsensusErrorCode.UNLOCK_TX_NOT_FOUND.getCode();
101+
continue;
102+
}
103+
104+
CoinFrom from = coinData.getFrom().get(0);
105+
if (null == from || from.getAssetsChainId() != lockedAssetChainId || from.getAssetsId() != lockedAssetId || from.getAmount().compareTo(lockedAmount) != 0 || from.getLocked() != CONSENSUS_LOCK_TIME || !ArraysTool.arrayEquals(lockedAddress, from.getAddress())) {
106+
invalidTxList.add(unlockTx);
107+
chain.getLogger().error("Unlock tx coin data is wrong:{}", unlockTx.getHash().toHex());
108+
errorCode = ConsensusErrorCode.UNLOCK_TX_NOT_FOUND.getCode();
109+
continue;
110+
}
111+
112+
CoinTo to = coinData.getTo().get(0);
113+
if (null == to || to.getAssetsChainId() != lockedAssetChainId || to.getAssetsId() != lockedAssetId || to.getAmount().compareTo(lockedAmount) != 0 || to.getLockTime() != 0 || !ArraysTool.arrayEquals(lockedAddress, to.getAddress())) {
114+
invalidTxList.add(unlockTx);
115+
chain.getLogger().error("Unlock tx coin data is wrong:{}", unlockTx.getHash().toHex());
116+
errorCode = ConsensusErrorCode.UNLOCK_TX_NOT_FOUND.getCode();
117+
continue;
118+
}
119+
120+
/*
121+
* Repeated exit node
122+
* */
123+
if (!hashSet.add(lockHash)) {
124+
invalidTxList.add(unlockTx);
125+
chain.getLogger().info("Repeated transactions");
126+
errorCode = ConsensusErrorCode.CONFLICT_ERROR.getCode();
127+
}
128+
} catch (NulsException e) {
129+
invalidTxList.add(unlockTx);
130+
chain.getLogger().error("Conflict calibration error");
131+
chain.getLogger().error(e);
132+
errorCode = e.getErrorCode().getCode();
133+
}
134+
}
135+
result.put("txList", invalidTxList);
136+
result.put("errorCode", errorCode);
137+
return result;
138+
}
139+
140+
@Override
141+
public boolean commit(int chainId, List<Transaction> txs, BlockHeader blockHeader, int syncStatus) {
142+
return true;
143+
}
144+
145+
@Override
146+
public boolean rollback(int chainId, List<Transaction> txs, BlockHeader blockHeader) {
147+
return true;
148+
}
149+
150+
}

module/nerve-core/src/main/java/io/nuls/crosschain/CrossChainBootStrap.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ private void init() {
7878
} else {
7979
nulsCrossChainConfig.setVersion1_38_0_height(0L);
8080
}
81+
82+
String version39Height = configurationLoader.getValue(ModuleE.Constant.PROTOCOL_UPDATE, "height_1_39_0");
83+
if (StringUtils.isNotBlank(version39Height)) {
84+
nulsCrossChainConfig.setVersion1_39_0_height(Long.parseLong(version39Height));
85+
} else {
86+
nulsCrossChainConfig.setVersion1_39_0_height(0L);
87+
}
8188
String pubKeys = configurationLoader.getValue(ModuleE.Constant.CONSENSUS, "pubKeyList");
8289
HashSet<String> seedSet = new HashSet<>();
8390
nulsCrossChainConfig.setSeedNodeSet(seedSet);

module/nerve-core/src/main/java/io/nuls/crosschain/servive/impl/NulsCrossChainServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public boolean commitCrossTx(int chainId, List<Transaction> txs, BlockHeader blo
316316
this.totalOutAmountService.addOutAmount(backOutAmount.getChainId(), backOutAmount.getAssetId(), backOutAmount.getOut());
317317
}
318318
}
319-
chain.getLogger().info("height:{} Cross chain transaction submission completed\n", blockHeader.getHeight());
319+
// chain.getLogger().info("height:{} Cross chain transaction submission completed\n", blockHeader.getHeight());
320320
return true;
321321
} catch (Exception e) {
322322
chain.getLogger().error(e);

0 commit comments

Comments
 (0)