Skip to content

Commit

Permalink
sync 2.1.1 to master (#434)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ywy2090 authored Oct 29, 2019
1 parent 1ef3e2d commit d9fff8c
Show file tree
Hide file tree
Showing 16 changed files with 618 additions and 247 deletions.
4 changes: 2 additions & 2 deletions .ci/ci_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ set -e
curl -LO https://raw.githubusercontent.com/FISCO-BCOS/FISCO-BCOS/dev/tools/build_chain.sh && chmod u+x build_chain.sh
bash <(curl -s https://raw.githubusercontent.com/FISCO-BCOS/FISCO-BCOS/dev/tools/ci/download_bin.sh) -b dev -m
echo "127.0.0.1:4 agency1 1,2,3" > ipconf
./build_chain.sh -e bin/fisco-bcos -f ipconf -p 30300,20200,8545 -v 2.0.0
./build_chain.sh -e bin/fisco-bcos -f ipconf -p 30300,20200,8545 -v 2.1.0
./nodes/127.0.0.1/start_all.sh
./nodes/127.0.0.1/fisco-bcos -v
cp nodes/127.0.0.1/sdk/* src/integration-test/resources/
mv src/integration-test/resources/applicationContext-sample.xml src/integration-test/resources/applicationContext.xml
./gradlew verifyGoogleJavaFormat
./gradlew build
./gradlew test
./gradlew integrationTest
./gradlew integrationTest
17 changes: 17 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
### v2.1.1

(2019-10-29)

* 增加
1. 生成`java`合约代码添加`input``output`的解析接口

* 更新
1. 修复`SDK`与节点握手协议的漏洞
2. 部署合约`SDK`时不再通过轮询方式判断是否成功
3. 修复`TransactionReceipt`类的`isStatusOK`接口抛出异常的问题

* 兼容

1. 兼容Channel Message v1协议
2. 兼容FISCO BCOS 2.1以下的sdk证书名node.crt和node.key

### v2.1.0

(2019-09-17)
Expand Down
2 changes: 1 addition & 1 deletion release_note.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.1.0
v2.1.1
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void run() {
Thread.currentThread().interrupt();
}

logger.info(
logger.debug(
" event filter manager, filter: {}, callback: {}",
registerIDToFilter.size(),
filterIDToCallback.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ private boolean validTopics() {
}

for (Object topic : getTopics()) {
if (topic == null) {
continue;
}
if (topic instanceof String) {
// if valid topic
if (((String) topic).isEmpty()) {
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/org/fisco/bcos/channel/event/filter/TopicTools.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.fisco.bcos.channel.event.filter;

import java.math.BigInteger;
import org.fisco.bcos.web3j.abi.TypeEncoder;
import org.fisco.bcos.web3j.abi.datatypes.Bytes;
import org.fisco.bcos.web3j.crypto.Hash;
import org.fisco.bcos.web3j.crypto.WalletUtils;
import org.fisco.bcos.web3j.utils.Numeric;

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

public static String addressToTopic(String s) {
return s;

if (!WalletUtils.isValidAddress(s)) {
throw new IllegalArgumentException("invalid address");
}

return "0x000000000000000000000000" + Numeric.cleanHexPrefix(s);
}

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

public static String byteNToTopic(byte[] b) {
return Numeric.toHexString(b);
// byte[] can't be more than 32 byte
if (b.length > 32) {
throw new IllegalArgumentException("byteN can't be more than 32 byte");
}

Bytes bs = new Bytes(b.length, b);
return Numeric.prependHexPrefix(TypeEncoder.encode(bs));
}
}
94 changes: 88 additions & 6 deletions src/main/java/org/fisco/bcos/fisco/EnumNodeVersion.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.fisco.bcos.fisco;

import org.fisco.bcos.channel.protocol.ChannelPrococolExceiption;

public enum EnumNodeVersion {
BCOS_2_0_0_RC1("2.0.0-rc1"),
BCOS_2_0_0_RC2("2.0.0-rc2"),
Expand All @@ -22,11 +24,91 @@ public void setVersion(String version) {
this.version = version;
}

public static boolean channelProtocolHandleShakeSupport(String version) {
return !(version.equals(BCOS_2_0_0_RC1.getVersion())
|| version.equals(BCOS_2_0_0_RC2.getVersion())
|| version.equals(BCOS_2_0_0_RC3.getVersion())
|| version.equals(BCOS_2_0_0.getVersion())
|| version.equals(BCOS_2_0_1.getVersion()));
// the object of node version
class Version {
private int major;
private int minor;
private int patch;
private String ext;

@Override
public String toString() {
return "Version [major="
+ major
+ ", minor="
+ minor
+ ", patch="
+ patch
+ ", ext="
+ ext
+ "]";
}

public int getMajor() {
return major;
}

public void setMajor(int major) {
this.major = major;
}

public int getMinor() {
return minor;
}

public void setMinor(int minor) {
this.minor = minor;
}

public int getPatch() {
return patch;
}

public void setPatch(int patch) {
this.patch = patch;
}

public String getExt() {
return ext;
}

public void setExt(String ext) {
this.ext = ext;
}
}

private static Version getClassVersion(String version) throws ChannelPrococolExceiption {
try {
// node version str format : "a.b.c" or "a.b.c-rcx"
String[] s0 = version.trim().split("-");

Version v = EnumNodeVersion.BCOS_2_0_0.new Version();
if (s0.length > 1) {
v.setExt(s0[1]);
}

//
String[] s1 = s0[0].split("\\.");
if (s1.length >= 3) {
v.setMajor(Integer.parseInt(s1[0].trim()));
v.setMinor(Integer.parseInt(s1[1].trim()));
v.setPatch(Integer.parseInt(s1[2].trim()));
} else { // invaid format
throw new ChannelPrococolExceiption(
" invalid node version format, version: " + version);
}

return v;
} catch (Exception e) {
throw new ChannelPrococolExceiption(
" invalid node version format, version: " + version);
}
}

public static boolean channelProtocolHandleShakeSupport(String version)
throws ChannelPrococolExceiption {
Version v = getClassVersion(version);
// 2.1.0 and above
return (v.getMajor() == 2) && (v.getMinor() >= 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class Bytes extends BytesType {

public static final String TYPE_NAME = "bytes";

protected Bytes(int byteSize, byte[] value) {
public Bytes(int byteSize, byte[] value) {
super(value, TYPE_NAME + value.length);
if (!isValid(byteSize, value)) {
throw new UnsupportedOperationException(
Expand Down
Loading

0 comments on commit d9fff8c

Please sign in to comment.