Skip to content

Commit 2189feb

Browse files
authored
Merge pull request #757 from FISCO-BCOS/release-2.6.5
sync code from 2.6.5
2 parents 2788e9f + 42b1ed0 commit 2189feb

File tree

7 files changed

+75
-301
lines changed

7 files changed

+75
-301
lines changed

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@ dependencies {
6868
// compile 'io.netty:netty-tcnative:2.0.25.Final'
6969
// compile 'io.netty:netty-tcnative-boringssl-static:2.0.27.Final'
7070
// compile 'org.fisco-bcos:netty-sm-ssl-context:1.0.0-SNAPSHOT'
71-
compile ('org.fisco-bcos:netty-sm-ssl-context:1.2.0') {
71+
compile ('org.fisco-bcos:netty-sm-ssl-context:1.5.2') {
7272
exclude module:"log4j"
7373
}
7474

7575
// compile 'org.ethereum:solcJ-all:0.4.25'
76-
compile 'io.netty:netty-all:4.1.53.Final'
7776
compile 'com.google.guava:guava:29.0-jre'
7877
compile 'commons-configuration:commons-configuration:1.10'
7978
compile 'org.apache.httpcomponents:httpclient:4.5.5'

publish.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ dependencies {
5959

6060
// compile 'io.netty:netty-tcnative:2.0.25.Final'
6161
// compile 'io.netty:netty-tcnative-boringssl-static:2.0.27.Final'
62-
compile ('org.fisco-bcos:netty-sm-ssl-context:1.2.0') {
62+
compile ('org.fisco-bcos:netty-sm-ssl-context:1.5.2') {
6363
exclude module:"log4j"
6464
}
6565

6666
// compile 'org.ethereum:solcJ-all:0.4.25'
67-
compile 'io.netty:netty-all:4.1.53.Final'
67+
// compile 'io.netty:netty-all:4.1.53.Final'
6868
compile 'com.google.guava:guava:29.0-jre'
6969
compile 'commons-configuration:commons-configuration:1.10'
7070
compile 'org.apache.httpcomponents:httpclient:4.5.5'
@@ -90,7 +90,7 @@ dependencies {
9090

9191
archivesBaseName = 'web3sdk'
9292
group = 'org.fisco-bcos'
93-
version = '2.6.4'
93+
version = '2.6.6'
9494

9595
// Additional attribute definition
9696

src/main/java/org/fisco/bcos/channel/client/ReceiptEncoder.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5+
import org.fisco.bcos.fisco.EnumNodeVersion;
56
import org.fisco.bcos.web3j.protocol.core.methods.response.Log;
67
import org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt;
78
import org.fisco.bcos.web3j.rlp.RlpEncoder;
@@ -12,14 +13,16 @@
1213

1314
// encode transaction receipt by Rlp into hex string
1415
public class ReceiptEncoder {
15-
public static String encode(TransactionReceipt transactionReceipt) {
16-
List<RlpType> values = asRlpValues(transactionReceipt);
16+
public static String encode(
17+
TransactionReceipt transactionReceipt, EnumNodeVersion.Version version) {
18+
List<RlpType> values = asRlpValues(transactionReceipt, version);
1719
RlpList rlpList = new RlpList(values);
1820
byte[] rlpBytes = RlpEncoder.encode(rlpList);
1921
return Numeric.toHexString(rlpBytes);
2022
}
2123

22-
private static List<RlpType> asRlpValues(TransactionReceipt transactionReceipt) {
24+
private static List<RlpType> asRlpValues(
25+
TransactionReceipt transactionReceipt, EnumNodeVersion.Version version) {
2326
List<RlpType> result = new ArrayList<>();
2427
// bytes
2528
result.add(RlpString.create(Numeric.hexStringToByteArray(transactionReceipt.getRoot())));
@@ -38,6 +41,11 @@ private static List<RlpType> asRlpValues(TransactionReceipt transactionReceipt)
3841

3942
result.add(RlpString.create(Numeric.hexStringToByteArray(transactionReceipt.getOutput())));
4043

44+
// gas used
45+
if (version != null && version.getMinor() >= 9) {
46+
result.add(RlpString.create(Numeric.toBigInt(transactionReceipt.getRemainGasRaw())));
47+
}
48+
4149
// List
4250
List<Log> logs = transactionReceipt.getLogs();
4351
List<RlpType> logList = new ArrayList<>();

src/main/java/org/fisco/bcos/channel/client/TransactionResource.java

Lines changed: 0 additions & 140 deletions
This file was deleted.

src/main/java/org/fisco/bcos/web3j/protocol/core/methods/response/TransactionReceipt.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class TransactionReceipt {
1212
private String blockHash;
1313
private String blockNumber;
1414
private String gasUsed;
15+
private String remainGas;
1516
private String contractAddress;
1617
private String root;
1718
// status is only present on Byzantium transactions onwards
@@ -34,6 +35,7 @@ public TransactionReceipt(
3435
String transactionIndex,
3536
String blockHash,
3637
String blockNumber,
38+
String remainGas,
3739
String gasUsed,
3840
String contractAddress,
3941
String root,
@@ -49,6 +51,7 @@ public TransactionReceipt(
4951
this.transactionIndex = transactionIndex;
5052
this.blockHash = blockHash;
5153
this.blockNumber = blockNumber;
54+
this.remainGas = remainGas;
5255
this.gasUsed = gasUsed;
5356
this.contractAddress = contractAddress;
5457
this.root = root;
@@ -120,6 +123,19 @@ public void setBlockNumber(String blockNumber) {
120123
this.blockNumber = blockNumber;
121124
}
122125

126+
@JsonIgnore
127+
public String getRemainGasRaw() {
128+
return remainGas;
129+
}
130+
131+
public BigInteger getRemainGas() {
132+
return Numeric.decodeQuantity(remainGas);
133+
}
134+
135+
public void setRemainGas(String remainGas) {
136+
this.remainGas = remainGas;
137+
}
138+
123139
public BigInteger getGasUsed() {
124140
return Numeric.decodeQuantity(gasUsed);
125141
}
@@ -261,6 +277,11 @@ public boolean equals(Object o) {
261277
if (gasUsed != null ? !gasUsed.equals(that.gasUsed) : that.gasUsed != null) {
262278
return false;
263279
}
280+
281+
if (remainGas != null ? !remainGas.equals(that.remainGas) : that.remainGas != null) {
282+
return false;
283+
}
284+
264285
if (getContractAddress() != null
265286
? !getContractAddress().equals(that.getContractAddress())
266287
: that.getContractAddress() != null) {
@@ -303,6 +324,7 @@ public int hashCode() {
303324
result = 31 * result + (getBlockHash() != null ? getBlockHash().hashCode() : 0);
304325
result = 31 * result + (blockNumber != null ? blockNumber.hashCode() : 0);
305326
result = 31 * result + (gasUsed != null ? gasUsed.hashCode() : 0);
327+
result = 31 * result + (remainGas != null ? remainGas.hashCode() : 0);
306328
result = 31 * result + (getContractAddress() != null ? getContractAddress().hashCode() : 0);
307329
result = 31 * result + (getRoot() != null ? getRoot().hashCode() : 0);
308330
result = 31 * result + (getStatus() != null ? getStatus().hashCode() : 0);
@@ -333,6 +355,9 @@ public String toString() {
333355
+ ", gasUsed='"
334356
+ gasUsed
335357
+ '\''
358+
+ ", remainGas='"
359+
+ remainGas
360+
+ '\''
336361
+ ", contractAddress='"
337362
+ contractAddress
338363
+ '\''

src/main/java/org/fisco/bcos/web3j/tx/MerkleProofUtility.java

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.util.List;
55
import org.fisco.bcos.channel.client.Merkle;
66
import org.fisco.bcos.channel.client.ReceiptEncoder;
7+
import org.fisco.bcos.channel.protocol.ChannelPrococolExceiption;
8+
import org.fisco.bcos.fisco.EnumNodeVersion;
79
import org.fisco.bcos.web3j.crypto.Hash;
810
import org.fisco.bcos.web3j.protocol.core.methods.response.MerkleProofUnit;
911
import org.fisco.bcos.web3j.protocol.core.methods.response.Transaction;
@@ -55,7 +57,15 @@ public static boolean verifyTransaction(
5557
* @return
5658
*/
5759
public static boolean verifyTransactionReceipt(
58-
String receiptRoot, TransactionReceiptWithProof.ReceiptAndProof receiptAndProof) {
60+
String receiptRoot,
61+
TransactionReceiptWithProof.ReceiptAndProof receiptAndProof,
62+
String supportedVersion) {
63+
64+
EnumNodeVersion.Version classVersion = null;
65+
try {
66+
classVersion = EnumNodeVersion.getClassVersion(supportedVersion);
67+
} catch (ChannelPrococolExceiption e) {
68+
}
5969

6070
TransactionReceipt transactionReceipt = receiptAndProof.getTransactionReceipt();
6171

@@ -67,7 +77,14 @@ public static boolean verifyTransactionReceipt(
6777
transactionReceipt.setGasUsed("0x" + transactionReceipt.getGasUsed().toString(16));
6878
}
6979

70-
String receiptRlp = ReceiptEncoder.encode(transactionReceipt);
80+
if (classVersion != null && classVersion.getMinor() >= 9) {
81+
if (!transactionReceipt.getRemainGasRaw().startsWith("0x")) {
82+
transactionReceipt.setRemainGas(
83+
"0x" + transactionReceipt.getRemainGas().toString(16));
84+
}
85+
}
86+
87+
String receiptRlp = ReceiptEncoder.encode(transactionReceipt, classVersion);
7188
String rlpHash = Hash.sha3(receiptRlp);
7289
String input = Numeric.toHexString(byteIndex) + rlpHash.substring(2);
7390

@@ -125,17 +142,31 @@ public static boolean verifyTransaction(
125142
public static boolean verifyTransactionReceipt(
126143
String receiptRoot,
127144
TransactionReceipt transactionReceipt,
128-
List<MerkleProofUnit> receiptProof) {
145+
List<MerkleProofUnit> receiptProof,
146+
String supportedVersion) {
129147

130148
if (!transactionReceipt.getGasUsedRaw().startsWith("0x")) {
131149
transactionReceipt.setGasUsed("0x" + transactionReceipt.getGasUsed().toString(16));
132150
}
133151

152+
EnumNodeVersion.Version classVersion = null;
153+
try {
154+
classVersion = EnumNodeVersion.getClassVersion(supportedVersion);
155+
} catch (ChannelPrococolExceiption e) {
156+
}
157+
158+
if (classVersion != null && classVersion.getMinor() >= 9) {
159+
if (!transactionReceipt.getRemainGasRaw().startsWith("0x")) {
160+
transactionReceipt.setRemainGas(
161+
"0x" + transactionReceipt.getRemainGas().toString(16));
162+
}
163+
}
164+
134165
// transaction index
135166
byte[] byteIndex =
136167
RlpEncoder.encode(RlpString.create(transactionReceipt.getTransactionIndex()));
137168

138-
String receiptRlp = ReceiptEncoder.encode(transactionReceipt);
169+
String receiptRlp = ReceiptEncoder.encode(transactionReceipt, classVersion);
139170
String rlpHash = Hash.sha3(receiptRlp);
140171
String input = Numeric.toHexString(byteIndex) + rlpHash.substring(2);
141172

0 commit comments

Comments
 (0)