Skip to content

Commit d9fff8c

Browse files
authored
sync 2.1.1 to master (#434)
* fix channel protocol handshake support bug. (#424) * remove print in TransactionDecoderTest * fix channel protocol handshake support bug. * call executeTransaction when deploy contract. (#425) * add input/output decoder in java codegen (#426) * add input/output decoder in java codegen * fix event filter address to topic bug * fix java codegen bug. * update web3sdk version in release.txt * fix TransactionException message set . (#428) * add TransactonReceipt code. (#429) * update event filter manager log level from info to debug (#430) * update ChangeLog.md
1 parent 1ef3e2d commit d9fff8c

File tree

16 files changed

+618
-247
lines changed

16 files changed

+618
-247
lines changed

.ci/ci_check.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ set -e
55
curl -LO https://raw.githubusercontent.com/FISCO-BCOS/FISCO-BCOS/dev/tools/build_chain.sh && chmod u+x build_chain.sh
66
bash <(curl -s https://raw.githubusercontent.com/FISCO-BCOS/FISCO-BCOS/dev/tools/ci/download_bin.sh) -b dev -m
77
echo "127.0.0.1:4 agency1 1,2,3" > ipconf
8-
./build_chain.sh -e bin/fisco-bcos -f ipconf -p 30300,20200,8545 -v 2.0.0
8+
./build_chain.sh -e bin/fisco-bcos -f ipconf -p 30300,20200,8545 -v 2.1.0
99
./nodes/127.0.0.1/start_all.sh
1010
./nodes/127.0.0.1/fisco-bcos -v
1111
cp nodes/127.0.0.1/sdk/* src/integration-test/resources/
1212
mv src/integration-test/resources/applicationContext-sample.xml src/integration-test/resources/applicationContext.xml
1313
./gradlew verifyGoogleJavaFormat
1414
./gradlew build
1515
./gradlew test
16-
./gradlew integrationTest
16+
./gradlew integrationTest

Changelog.md

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
### v2.1.1
2+
3+
(2019-10-29)
4+
5+
* 增加
6+
1. 生成`java`合约代码添加`input``output`的解析接口
7+
8+
* 更新
9+
1. 修复`SDK`与节点握手协议的漏洞
10+
2. 部署合约`SDK`时不再通过轮询方式判断是否成功
11+
3. 修复`TransactionReceipt`类的`isStatusOK`接口抛出异常的问题
12+
13+
* 兼容
14+
15+
1. 兼容Channel Message v1协议
16+
2. 兼容FISCO BCOS 2.1以下的sdk证书名node.crt和node.key
17+
118
### v2.1.0
219

320
(2019-09-17)

release_note.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.1.0
1+
v2.1.1

src/main/java/org/fisco/bcos/channel/event/filter/EventLogFilterManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void run() {
151151
Thread.currentThread().interrupt();
152152
}
153153

154-
logger.info(
154+
logger.debug(
155155
" event filter manager, filter: {}, callback: {}",
156156
registerIDToFilter.size(),
157157
filterIDToCallback.size());

src/main/java/org/fisco/bcos/channel/event/filter/EventLogUserParams.java

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ private boolean validTopics() {
100100
}
101101

102102
for (Object topic : getTopics()) {
103+
if (topic == null) {
104+
continue;
105+
}
103106
if (topic instanceof String) {
104107
// if valid topic
105108
if (((String) topic).isEmpty()) {

src/main/java/org/fisco/bcos/channel/event/filter/TopicTools.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.fisco.bcos.channel.event.filter;
22

33
import java.math.BigInteger;
4+
import org.fisco.bcos.web3j.abi.TypeEncoder;
5+
import org.fisco.bcos.web3j.abi.datatypes.Bytes;
46
import org.fisco.bcos.web3j.crypto.Hash;
7+
import org.fisco.bcos.web3j.crypto.WalletUtils;
58
import org.fisco.bcos.web3j.utils.Numeric;
69

710
public class TopicTools {
@@ -20,7 +23,12 @@ public static String boolToTopic(boolean b) {
2023
}
2124

2225
public static String addressToTopic(String s) {
23-
return s;
26+
27+
if (!WalletUtils.isValidAddress(s)) {
28+
throw new IllegalArgumentException("invalid address");
29+
}
30+
31+
return "0x000000000000000000000000" + Numeric.cleanHexPrefix(s);
2432
}
2533

2634
public static String stringToTopic(String s) {
@@ -34,6 +42,12 @@ public static String bytesToTopic(byte[] b) {
3442
}
3543

3644
public static String byteNToTopic(byte[] b) {
37-
return Numeric.toHexString(b);
45+
// byte[] can't be more than 32 byte
46+
if (b.length > 32) {
47+
throw new IllegalArgumentException("byteN can't be more than 32 byte");
48+
}
49+
50+
Bytes bs = new Bytes(b.length, b);
51+
return Numeric.prependHexPrefix(TypeEncoder.encode(bs));
3852
}
3953
}

src/main/java/org/fisco/bcos/fisco/EnumNodeVersion.java

+88-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.fisco.bcos.fisco;
22

3+
import org.fisco.bcos.channel.protocol.ChannelPrococolExceiption;
4+
35
public enum EnumNodeVersion {
46
BCOS_2_0_0_RC1("2.0.0-rc1"),
57
BCOS_2_0_0_RC2("2.0.0-rc2"),
@@ -22,11 +24,91 @@ public void setVersion(String version) {
2224
this.version = version;
2325
}
2426

25-
public static boolean channelProtocolHandleShakeSupport(String version) {
26-
return !(version.equals(BCOS_2_0_0_RC1.getVersion())
27-
|| version.equals(BCOS_2_0_0_RC2.getVersion())
28-
|| version.equals(BCOS_2_0_0_RC3.getVersion())
29-
|| version.equals(BCOS_2_0_0.getVersion())
30-
|| version.equals(BCOS_2_0_1.getVersion()));
27+
// the object of node version
28+
class Version {
29+
private int major;
30+
private int minor;
31+
private int patch;
32+
private String ext;
33+
34+
@Override
35+
public String toString() {
36+
return "Version [major="
37+
+ major
38+
+ ", minor="
39+
+ minor
40+
+ ", patch="
41+
+ patch
42+
+ ", ext="
43+
+ ext
44+
+ "]";
45+
}
46+
47+
public int getMajor() {
48+
return major;
49+
}
50+
51+
public void setMajor(int major) {
52+
this.major = major;
53+
}
54+
55+
public int getMinor() {
56+
return minor;
57+
}
58+
59+
public void setMinor(int minor) {
60+
this.minor = minor;
61+
}
62+
63+
public int getPatch() {
64+
return patch;
65+
}
66+
67+
public void setPatch(int patch) {
68+
this.patch = patch;
69+
}
70+
71+
public String getExt() {
72+
return ext;
73+
}
74+
75+
public void setExt(String ext) {
76+
this.ext = ext;
77+
}
78+
}
79+
80+
private static Version getClassVersion(String version) throws ChannelPrococolExceiption {
81+
try {
82+
// node version str format : "a.b.c" or "a.b.c-rcx"
83+
String[] s0 = version.trim().split("-");
84+
85+
Version v = EnumNodeVersion.BCOS_2_0_0.new Version();
86+
if (s0.length > 1) {
87+
v.setExt(s0[1]);
88+
}
89+
90+
//
91+
String[] s1 = s0[0].split("\\.");
92+
if (s1.length >= 3) {
93+
v.setMajor(Integer.parseInt(s1[0].trim()));
94+
v.setMinor(Integer.parseInt(s1[1].trim()));
95+
v.setPatch(Integer.parseInt(s1[2].trim()));
96+
} else { // invaid format
97+
throw new ChannelPrococolExceiption(
98+
" invalid node version format, version: " + version);
99+
}
100+
101+
return v;
102+
} catch (Exception e) {
103+
throw new ChannelPrococolExceiption(
104+
" invalid node version format, version: " + version);
105+
}
106+
}
107+
108+
public static boolean channelProtocolHandleShakeSupport(String version)
109+
throws ChannelPrococolExceiption {
110+
Version v = getClassVersion(version);
111+
// 2.1.0 and above
112+
return (v.getMajor() == 2) && (v.getMinor() >= 1);
31113
}
32114
}

src/main/java/org/fisco/bcos/web3j/abi/datatypes/Bytes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class Bytes extends BytesType {
55

66
public static final String TYPE_NAME = "bytes";
77

8-
protected Bytes(int byteSize, byte[] value) {
8+
public Bytes(int byteSize, byte[] value) {
99
super(value, TYPE_NAME + value.length);
1010
if (!isValid(byteSize, value)) {
1111
throw new UnsupportedOperationException(

0 commit comments

Comments
 (0)