Skip to content

Commit 79b6d57

Browse files
authored
Merge pull request #551 from cyjseagull/release-2.3.0-master-new
Release 2.3.0 to master
2 parents c2c6d0c + 2e08375 commit 79b6d57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3038
-382
lines changed

.ci/ci_check_commit.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
scan_code_script="cobra/cobra.py -f json -o /tmp/report.json -t "
6-
ignore_files=(Constant.java PerformanceOkDSync.java SM2Algorithm.java SM2KeyGenerator.java test)
6+
ignore_files=(RevertResolver.java ECCParams.java ECKeyPair.java KeyUtils.java Permission.java Frozen.java ECDSASign.java Constant.java PerformanceOkDSync.java SM2Algorithm.java SM2KeyGenerator.java test)
77

88
LOG_ERROR() {
99
content=${1}

build.gradle

+5
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ dependencies {
9696
compile 'org.projectlombok:lombok:1.18.2'
9797
}
9898

99+
99100
//archivesBaseName = 'web3sdk'
100101
//group = 'org.fisco-bcos'
101102
//version = '2.0.5'
@@ -149,6 +150,10 @@ try {
149150
println(" .git directory not exist.");
150151
}
151152

153+
tasks.withType(Test) {
154+
maxParallelForks = 1
155+
}
156+
152157
// 1 dist jar
153158
jar {
154159
destinationDir file('dist/apps')

release_note.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.2.3
1+
v2.3.0

solidity/Table.sol

+45-35
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,67 @@ pragma solidity ^0.4.24;
22

33
contract TableFactory {
44
function openTable(string) public constant returns (Table); //open table
5-
function createTable(string,string,string) public returns(int); //create table
5+
function createTable(string, string, string) public returns (int256); //create table
66
}
77

88
//select condition
99
contract Condition {
10-
function EQ(string, int) public;
10+
function EQ(string, int256) public;
1111
function EQ(string, string) public;
12-
13-
function NE(string, int) public;
14-
function NE(string, string) public;
15-
16-
function GT(string, int) public;
17-
function GE(string, int) public;
18-
19-
function LT(string, int) public;
20-
function LE(string, int) public;
21-
22-
function limit(int) public;
23-
function limit(int, int) public;
12+
13+
function NE(string, int256) public;
14+
function NE(string, string) public;
15+
16+
function GT(string, int256) public;
17+
function GE(string, int256) public;
18+
19+
function LT(string, int256) public;
20+
function LE(string, int256) public;
21+
22+
function limit(int256) public;
23+
function limit(int256, int256) public;
2424
}
2525

26-
//one record
26+
//one record
2727
contract Entry {
28-
function getInt(string) public constant returns(int);
29-
function getAddress(string) public constant returns(address);
30-
function getBytes64(string) public constant returns(byte[64]);
31-
function getBytes32(string) public constant returns(bytes32);
32-
function getString(string) public constant returns(string);
33-
34-
function set(string, int) public;
28+
function getInt(string) public constant returns (int256);
29+
function getUInt(string) public constant returns (int256);
30+
function getAddress(string) public constant returns (address);
31+
function getBytes64(string) public constant returns (bytes1[64]);
32+
function getBytes32(string) public constant returns (bytes32);
33+
function getString(string) public constant returns (string);
34+
35+
function set(string, int256) public;
36+
function set(string, uint256) public;
3537
function set(string, string) public;
3638
function set(string, address) public;
3739
}
3840

3941
//record sets
4042
contract Entries {
41-
function get(int) public constant returns(Entry);
42-
function size() public constant returns(int);
43+
function get(int256) public constant returns (Entry);
44+
function size() public constant returns (int256);
4345
}
4446

4547
//Table main contract
4648
contract Table {
47-
//select api
48-
function select(string, Condition) public constant returns(Entries);
49-
//insert api
50-
function insert(string, Entry) public returns(int);
51-
//update api
52-
function update(string, Entry, Condition) public returns(int);
53-
//remove api
54-
function remove(string, Condition) public returns(int);
55-
56-
function newEntry() public constant returns(Entry);
57-
function newCondition() public constant returns(Condition);
49+
function select(string, Condition) public constant returns (Entries);
50+
function insert(string, Entry) public returns (int256);
51+
function update(string, Entry, Condition) public returns (int256);
52+
function remove(string, Condition) public returns (int256);
53+
54+
function newEntry() public constant returns (Entry);
55+
function newCondition() public constant returns (Condition);
56+
}
57+
58+
contract KVTableFactory {
59+
function openTable(string) public constant returns (KVTable);
60+
function createTable(string, string, string) public returns (int256);
61+
}
62+
63+
//KVTable per permiary key has only one Entry
64+
contract KVTable {
65+
function get(string) public constant returns (bool, Entry);
66+
function set(string, Entry) public returns (int256);
67+
function newEntry() public constant returns (Entry);
5868
}

solidity/TableTest.sol

+56-48
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,97 @@
11
pragma solidity ^0.4.24;
22
pragma experimental ABIEncoderV2;
3-
43
import "./Table.sol";
54

65
contract TableTest {
7-
event CreateResult(int count);
8-
event InsertResult(int count);
9-
event UpdateResult(int count);
10-
event RemoveResult(int count);
11-
12-
//create table
13-
function create() public returns(int){
14-
TableFactory tf = TableFactory(0x1001); //The fixed address is 0x1001 for TableFactory
15-
16-
int count = tf.createTable("t_test", "name", "item_id,item_name");
17-
emit CreateResult(count);
18-
return count;
6+
event CreateResult(int256 count);
7+
event InsertResult(int256 count);
8+
event UpdateResult(int256 count);
9+
event RemoveResult(int256 count);
10+
11+
TableFactory tableFactory;
12+
string constant TABLE_NAME = "t_test";
13+
constructor() public {
14+
tableFactory = TableFactory(0x1001); //The fixed address is 0x1001 for TableFactory
15+
// the parameters of createTable are tableName,keyField,"vlaueFiled1,vlaueFiled2,vlaueFiled3,..."
16+
tableFactory.createTable(TABLE_NAME, "name", "item_id,item_name");
1917
}
2018

2119
//select records
22-
function select(string name) public constant returns(string[], int[], string[]){
23-
TableFactory tf = TableFactory(0x1001);
24-
Table table = tf.openTable("t_test");
25-
20+
function select(string name)
21+
public
22+
view
23+
returns (string[], int256[], string[])
24+
{
25+
Table table = tableFactory.openTable(TABLE_NAME);
26+
2627
Condition condition = table.newCondition();
27-
28+
2829
Entries entries = table.select(name, condition);
29-
string[] memory user_name_bytes_list = new string[](uint256(entries.size()));
30-
int[] memory item_id_list = new int[](uint256(entries.size()));
31-
string[] memory item_name_bytes_list = new string[](uint256(entries.size()));
32-
33-
for(int i=0; i<entries.size(); ++i) {
30+
string[] memory user_name_bytes_list = new string[](
31+
uint256(entries.size())
32+
);
33+
int256[] memory item_id_list = new int256[](uint256(entries.size()));
34+
string[] memory item_name_bytes_list = new string[](
35+
uint256(entries.size())
36+
);
37+
38+
for (int256 i = 0; i < entries.size(); ++i) {
3439
Entry entry = entries.get(i);
35-
40+
3641
user_name_bytes_list[uint256(i)] = entry.getString("name");
3742
item_id_list[uint256(i)] = entry.getInt("item_id");
38-
item_name_bytes_list[uint256(i)] = entry.getString("item_name");
43+
item_name_bytes_list[uint256(i)] = entry.getString("item_name");
3944
}
40-
45+
4146
return (user_name_bytes_list, item_id_list, item_name_bytes_list);
4247
}
4348
//insert records
44-
function insert(string name, int item_id, string item_name) public returns(int) {
45-
TableFactory tf = TableFactory(0x1001);
46-
Table table = tf.openTable("t_test");
47-
49+
function insert(string name, int256 item_id, string item_name)
50+
public
51+
returns (int256)
52+
{
53+
Table table = tableFactory.openTable(TABLE_NAME);
54+
4855
Entry entry = table.newEntry();
4956
entry.set("name", name);
5057
entry.set("item_id", item_id);
5158
entry.set("item_name", item_name);
52-
53-
int count = table.insert(name, entry);
59+
60+
int256 count = table.insert(name, entry);
5461
emit InsertResult(count);
55-
62+
5663
return count;
5764
}
5865
//update records
59-
function update(string name, int item_id, string item_name) public returns(int) {
60-
TableFactory tf = TableFactory(0x1001);
61-
Table table = tf.openTable("t_test");
62-
66+
function update(string name, int256 item_id, string item_name)
67+
public
68+
returns (int256)
69+
{
70+
Table table = tableFactory.openTable(TABLE_NAME);
71+
6372
Entry entry = table.newEntry();
6473
entry.set("item_name", item_name);
65-
74+
6675
Condition condition = table.newCondition();
6776
condition.EQ("name", name);
6877
condition.EQ("item_id", item_id);
69-
70-
int count = table.update(name, entry, condition);
78+
79+
int256 count = table.update(name, entry, condition);
7180
emit UpdateResult(count);
72-
81+
7382
return count;
7483
}
7584
//remove records
76-
function remove(string name, int item_id) public returns(int){
77-
TableFactory tf = TableFactory(0x1001);
78-
Table table = tf.openTable("t_test");
79-
85+
function remove(string name, int256 item_id) public returns (int256) {
86+
Table table = tableFactory.openTable(TABLE_NAME);
87+
8088
Condition condition = table.newCondition();
8189
condition.EQ("name", name);
8290
condition.EQ("item_id", item_id);
83-
84-
int count = table.remove(name, condition);
91+
92+
int256 count = table.remove(name, condition);
8593
emit RemoveResult(count);
86-
94+
8795
return count;
8896
}
8997
}

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

+8-7
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
import org.fisco.bcos.web3j.protocol.core.methods.response.Log;
7272
import org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt;
7373
import org.fisco.bcos.web3j.protocol.exceptions.TransactionException;
74+
import org.fisco.bcos.web3j.tuples.generated.Tuple2;
75+
import org.fisco.bcos.web3j.tx.RevertResolver;
7476
import org.fisco.bcos.web3j.tx.txdecode.LogResult;
7577
import org.fisco.bcos.web3j.utils.Strings;
7678
import org.slf4j.Logger;
@@ -716,13 +718,6 @@ public void run(Timeout timeout) throws Exception {
716718
}
717719
}
718720

719-
/**
720-
* When SDK start, the initial subscribed topics information set by user will be sent to the
721-
* node. User can update subscribed topics again by following steps: 1. Set the topics you want
722-
* to subscribe to again Service service // Servcie object Set<String> topics // topics that
723-
* subscribe again service.setTopics(topics) 2. send update topics message to all nodes
724-
* service.updateTopicsToNode();
725-
*/
726721
public void updateTopicsToNode() {
727722

728723
logger.info(" updateTopicToNode, groupId: {}, topics: {}", groupId, getTopics());
@@ -1548,6 +1543,12 @@ public void onReceiveTransactionMessage(String seq, TransactionReceipt receipt)
15481543
}
15491544

15501545
try {
1546+
Tuple2<Boolean, String> revertMessage =
1547+
RevertResolver.tryResolveRevertMessage(receipt);
1548+
if (revertMessage.getValue1()) {
1549+
logger.debug(" revert message: {}", revertMessage.getValue2());
1550+
receipt.setMessage(revertMessage.getValue2());
1551+
}
15511552
callback.onResponse(receipt);
15521553
} catch (Exception e) {
15531554
logger.error("Error process transactionMessage: ", e);

src/main/java/org/fisco/bcos/channel/dto/ChannelMessage2.java

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

33
import io.netty.buffer.ByteBuf;
4+
import java.io.UnsupportedEncodingException;
45
import org.fisco.bcos.channel.handler.Message;
56
import org.slf4j.Logger;
67
import org.slf4j.LoggerFactory;
@@ -36,14 +37,22 @@ public void readExtra(ByteBuf in) {
3637
@Override
3738
public void writeHeader(ByteBuf out) {
3839
// total length
39-
length = Message.HEADER_LENGTH + 1 + topic.length() + data.length;
40+
try {
41+
length = Message.HEADER_LENGTH + 1 + topic.getBytes("utf-8").length + data.length;
42+
} catch (UnsupportedEncodingException e) {
43+
throw new RuntimeException(" topic string to utf8 failed, topic: " + topic);
44+
}
4045

4146
super.writeHeader(out);
4247
}
4348

4449
@Override
4550
public void writeExtra(ByteBuf out) {
46-
out.writeByte(1 + topic.length());
51+
try {
52+
out.writeByte(1 + topic.getBytes("utf-8").length);
53+
} catch (UnsupportedEncodingException e) {
54+
throw new RuntimeException(" topic string to utf8 failed, topic: " + topic);
55+
}
4756
out.writeBytes(topic.getBytes());
4857

4958
out.writeBytes(data);

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

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

3+
import java.util.Collections;
34
import java.util.List;
45
import org.fisco.bcos.web3j.abi.TypeReference;
56
import org.fisco.bcos.web3j.abi.Utils;
@@ -17,6 +18,12 @@ public Function(
1718
this.outputParameters = Utils.convert(outputParameters);
1819
}
1920

21+
public Function() {
22+
this.name = "";
23+
this.inputParameters = Collections.<Type>emptyList();
24+
this.outputParameters = Collections.<TypeReference<Type>>emptyList();
25+
}
26+
2027
public String getName() {
2128
return name;
2229
}

0 commit comments

Comments
 (0)