Skip to content

Commit c540421

Browse files
authored
Merge pull request #833 from kyonRay/master-2.0
release v2.10.0
2 parents 5f55b21 + a813205 commit c540421

File tree

14 files changed

+202
-95
lines changed

14 files changed

+202
-95
lines changed

.ci/ci_check.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ LOG_INFO() {
88

99
download_build_chain()
1010
{
11-
tag=$(curl -sS "https://gitee.com/api/v5/repos/FISCO-BCOS/FISCO-BCOS/tags" | grep -oe "\"name\":\"v[2-9]*\.[0-9]*\.[0-9]*\"" | cut -d \" -f 4 | sort -V | tail -n 1)
12-
LOG_INFO "--- current tag: $tag"
13-
curl -LO "https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/v2.7.2/build_chain.sh" && chmod u+x build_chain.sh
11+
curl -LO "https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/v2.9.1/build_chain.sh" && chmod u+x build_chain.sh
1412
}
1513

1614
prepare_environment()
@@ -56,6 +54,10 @@ bash gradlew integrationTest --info
5654
}
5755

5856
cp src/integration-test/resources/config-example.toml src/integration-test/resources/config.toml
57+
LOG_INFO "------ check java version -------"
58+
java -version
59+
LOG_INFO "------ check openssl version -------"
60+
openssl version
5961
LOG_INFO "------ download_build_chain---------"
6062
download_build_chain
6163
LOG_INFO "------ check_standard_node---------"

.github/workflows/codeql.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ 'master*', 'dev*', 'release-*' ]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [ 'master', 'dev*', 'release-*' ]
9+
schedule:
10+
- cron: '57 14 * * 0'
11+
12+
jobs:
13+
analyze:
14+
name: Analyze
15+
runs-on: ubuntu-latest
16+
permissions:
17+
actions: read
18+
contents: read
19+
security-events: write
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
language: [ 'java' ]
25+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
26+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v3
31+
32+
# Initializes the CodeQL tools for scanning.
33+
- name: Initialize CodeQL
34+
uses: github/codeql-action/init@v2
35+
with:
36+
languages: ${{ matrix.language }}
37+
# If you wish to specify custom queries, you can do so here or in a config file.
38+
# By default, queries listed here will override any specified in a config file.
39+
# Prefix the list here with "+" to use these queries and those in the config file.
40+
41+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
42+
queries: +security-and-quality
43+
44+
45+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
46+
# If this step fails, then you should remove it and run the build manually (see below)
47+
- name: Autobuild
48+
uses: github/codeql-action/autobuild@v2
49+
50+
# ℹ️ Command-line programs to run using the OS shell.
51+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
52+
53+
# If the Autobuild fails above, remove it and uncomment the following three lines.
54+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
55+
56+
# - run: |
57+
# echo "Run, Build Application using script"
58+
# ./location_of_script_within_repo/buildscript.sh
59+
60+
- name: Perform CodeQL Analysis
61+
uses: github/codeql-action/analyze@v2
62+
with:
63+
category: "/language:${{matrix.language}}"

.github/workflows/workflow.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Console GitHub Actions
2+
on:
3+
pull_request:
4+
release:
5+
types: [ published, created, edited ]
6+
env:
7+
CCACHE_DIR: ${{ github.workspace }}/ccache
8+
9+
jobs:
10+
build:
11+
name: build
12+
runs-on: ${{ matrix.os }}
13+
continue-on-error: true
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ ubuntu-20.04, windows-2019, macos-latest ]
18+
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 5
22+
- name: install Ubuntu dependencies
23+
if: runner.os == 'Linux'
24+
run: sudo apt update && sudo apt install -y git curl libssl-dev build-essential openssl
25+
- name: install macOS dependencies
26+
if: runner.os == 'macOS'
27+
run: brew install openssl@1.1
28+
- name: Set up JDK 1.8
29+
uses: actions/setup-java@v3
30+
with:
31+
distribution: 'zulu'
32+
java-version: '8.0.345'
33+
- name: run build test
34+
if: runner.os == 'Windows'
35+
run: ./gradlew.bat build
36+
- name: run integration testing
37+
if: runner.os != 'Windows'
38+
run: /bin/bash -x .ci/ci_check.sh
39+
40+
build-centos:
41+
name: build-centos
42+
runs-on: ${{ matrix.os }}
43+
continue-on-error: true
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
os: [ ubuntu-20.04 ]
48+
container: docker.io/centos:7
49+
steps:
50+
- uses: actions/checkout@v2
51+
with:
52+
fetch-depth: 5
53+
- name: Set up JDK 1.8
54+
uses: actions/setup-java@v3
55+
with:
56+
distribution: 'zulu'
57+
java-version: '8.0.345'
58+
- name: install CentOS dependencies
59+
run: yum install -y epel-release centos-release-scl which git openssl-devel openssl wget
60+
- name: run integration testing
61+
run: /bin/bash -x .ci/ci_check.sh
62+
- name: upload coverage
63+
run: curl -LO https://codecov.io/bash && /bin/bash ./bash

Changelog.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
### v2.10.0
2+
3+
(2024-03-08)
4+
5+
更新:
6+
7+
- 合约生成Java文件的功能使用org.fisco-bcos.code-generator:bcos-code-generator中的方法,弃用 `org.fisco-bcos.java-sdk:fisco-bcos-java-sdk``sdk-codegen` 模块。
8+
- 升级Java SDK版本为2.10.0。
9+
10+
修复:
11+
12+
- 修复在使用Solidity复杂数据结构、复杂事件场景时,生成的Java文件出现编译、运行错误的问题。
13+
- 修复 `get_account.sh` 脚本在openssl v3.0 版本下检查失败的问题。
14+
- 修复在读取密钥时可能存在的安全问题。
15+
116
### v2.9.2
217
(2022-10-31)
318

build.gradle

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,20 @@ List logger = [
3535
// In this section you declare the dependencies for your production and test code
3636
dependencies {
3737
compile logger
38-
compile 'org.fisco-bcos:solcJ:0.4.25.2'
38+
compile ('org.fisco-bcos:solcJ:0.4.25.2'){
39+
exclude group: 'com.fasterxml.jackson.core'
40+
}
3941

4042
//compile 'org.fisco-bcos:solcJ:0.6.10.2'
4143
//compile 'org.fisco-bcos:solcJ:0.5.2.2'
42-
compile ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:2.9.3')
43-
44+
compile ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:2.10.0')
45+
compile ("com.fasterxml.jackson.core:jackson-databind:2.15.2")
46+
compile('org.fisco-bcos.code-generator:bcos-code-generator:1.4.0') {
47+
exclude group: "org.fisco-bcos.java-sdk"
48+
exclude group: "org.slf4j"
49+
}
4450
compile("commons-cli:commons-cli:1.3.1")
45-
compile 'org.jline:jline:3.12.0'
51+
compile 'org.jline:jline:3.25.0'
4652
compile 'io.bretty:console-table-builder:1.2'
4753
compile 'com.github.jsqlparser:jsqlparser:2.0'
4854
testCompile 'com.github.stefanbirkner:system-rules:1.18.0'

release_note.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.9.2
1+
v2.10.0

src/main/java/console/ConsoleInitializer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ private AccountInfo loadAccountRandomly(BcosSDK bcosSDK, Client client) {
174174
String subDir = client.getCryptoSuite().getKeyPairFactory().getKeyStoreSubDir();
175175
String keyStoreFileDir = keyStoreDirPath + File.separator + subDir;
176176
File keyStoreFileDirPath = new File(keyStoreFileDir);
177-
logger.debug("loadAccountRandomly, keyStoreFileDirPath:{}", keyStoreFileDir);
177+
if (logger.isDebugEnabled()) {
178+
logger.debug("loadAccountRandomly, keyStoreFileDirPath:{}", keyStoreFileDir);
179+
}
178180
if (!keyStoreFileDirPath.exists() || !keyStoreFileDirPath.isDirectory()) {
179181
return null;
180182
}

src/main/java/console/command/completer/ConsoleFilesCompleter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public ConsoleFilesCompleter(Path solidityPath) {
3939
this.solidityPath = solidityPath;
4040
}
4141

42-
@Override
4342
protected String getDisplay(Terminal terminal, Path p) {
4443
String name = p.getFileName().toString();
4544
// do not display .sol

src/main/java/console/common/ConsoleUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.fisco.bcos.sdk.channel.model.ChannelPrococolExceiption;
3434
import org.fisco.bcos.sdk.channel.model.EnumNodeVersion;
3535
import org.fisco.bcos.sdk.client.Client;
36-
import org.fisco.bcos.sdk.codegen.CodeGenMain;
3736
import org.fisco.bcos.sdk.model.PrecompiledRetCode;
3837
import org.fisco.bcos.sdk.model.RetCode;
3938
import org.fisco.bcos.sdk.transaction.model.dto.TransactionResponse;
@@ -309,8 +308,9 @@ public static void compileSolToJava(
309308
String abiFile = abiDir + contractName + ".abi";
310309
String binFile = binDir + contractName + ".bin";
311310
String smBinFile = binDir + "/sm/" + contractName + ".bin";
312-
CodeGenMain.main(
311+
org.fisco.bcos.codegen.CodeGenMain.main(
313312
Arrays.asList(
313+
"-v", "V2",
314314
"-a", abiFile,
315315
"-b", binFile,
316316
"-s", smBinFile,
@@ -325,7 +325,7 @@ public static void compileAllSolToJava(
325325
String javaDir, String packageName, File solFileList, String abiDir, String binDir)
326326
throws IOException {
327327
File[] solFiles = solFileList.listFiles();
328-
if (solFiles.length == 0) {
328+
if (solFiles == null || solFiles.length == 0) {
329329
System.out.println("The contracts directory is empty.");
330330
return;
331331
}

src/main/java/console/common/ConsoleVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class ConsoleVersion {
44

5-
public static final String Version = "2.9.3";
5+
public static final String Version = "2.10.0";
66

77
public static void main(String[] args) {
88
System.out.println("console version: " + Version);

src/main/java/console/contract/utils/ContractCompiler.java

Lines changed: 34 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import console.contract.model.AbiAndBin;
2525
import java.io.File;
2626
import java.io.IOException;
27+
import java.nio.charset.Charset;
2728
import org.apache.commons.io.FileUtils;
2829
import org.fisco.bcos.sdk.codegen.CodeGenUtils;
2930
import org.fisco.bcos.sdk.codegen.exceptions.CodeGenException;
@@ -75,6 +76,7 @@ public static AbiAndBin compileSolToBinAndAbi(File contractFile, String abiDir,
7576
throws CompileContractException, IOException {
7677
return compileSolToBinAndAbi(contractFile, abiDir, binDir, null);
7778
}
79+
7880
// compile with libraries option
7981
public static AbiAndBin compileSolToBinAndAbi(
8082
File contractFile, String abiDir, String binDir, String librariesOption)
@@ -160,46 +162,23 @@ public static void checkBinaryCode(String contractName, String binary)
160162
public static void saveAbiAndBin(
161163
Integer groupId, AbiAndBin abiAndBin, String contractName, String contractAddress)
162164
throws IOException {
163-
File abiPath =
164-
new File(
165-
COMPILED_PATH
166-
+ File.separator
167-
+ groupId
168-
+ File.separator
169-
+ contractName
170-
+ File.separator
171-
+ contractAddress
172-
+ File.separator
173-
+ contractName
174-
+ ABI_POSTFIX);
175-
File binPath =
176-
new File(
177-
COMPILED_PATH
178-
+ File.separator
179-
+ groupId
180-
+ File.separator
181-
+ contractName
182-
+ File.separator
183-
+ contractAddress
184-
+ File.separator
185-
+ contractName
186-
+ BIN_POSTFIX);
187-
File smBinPath =
188-
new File(
189-
COMPILED_PATH
190-
+ File.separator
191-
+ groupId
192-
+ File.separator
193-
+ contractName
194-
+ File.separator
195-
+ contractAddress
196-
+ File.separator
197-
+ contractName
198-
+ SM_POSTFIX
199-
+ BIN_POSTFIX);
200-
FileUtils.writeStringToFile(abiPath, abiAndBin.getAbi());
201-
FileUtils.writeStringToFile(binPath, abiAndBin.getBin());
202-
FileUtils.writeStringToFile(smBinPath, abiAndBin.getSmBin());
165+
String contractDir =
166+
COMPILED_PATH
167+
+ File.separator
168+
+ groupId
169+
+ File.separator
170+
+ contractName
171+
+ File.separator
172+
+ contractAddress
173+
+ File.separator
174+
+ contractName;
175+
contractDir = contractDir.replace("..", "");
176+
File abiPath = new File(contractDir + ABI_POSTFIX);
177+
File binPath = new File(contractDir + BIN_POSTFIX);
178+
File smBinPath = new File(contractDir + SM_POSTFIX + BIN_POSTFIX);
179+
FileUtils.writeStringToFile(abiPath, abiAndBin.getAbi(), Charset.defaultCharset());
180+
FileUtils.writeStringToFile(binPath, abiAndBin.getBin(), Charset.defaultCharset());
181+
FileUtils.writeStringToFile(smBinPath, abiAndBin.getSmBin(), Charset.defaultCharset());
203182
}
204183

205184
public static AbiAndBin loadAbiAndBin(
@@ -222,43 +201,21 @@ public static AbiAndBin loadAbiAndBin(
222201
String contractAddress,
223202
boolean needCompile)
224203
throws IOException, CodeGenException, CompileContractException {
225-
File abiPath =
226-
new File(
227-
COMPILED_PATH
228-
+ File.separator
229-
+ groupId
230-
+ File.separator
231-
+ contractName
232-
+ File.separator
233-
+ contractAddress
234-
+ File.separator
235-
+ contractName
236-
+ ABI_POSTFIX);
237-
File binPath =
238-
new File(
239-
COMPILED_PATH
240-
+ File.separator
241-
+ groupId
242-
+ File.separator
243-
+ contractName
244-
+ File.separator
245-
+ contractAddress
246-
+ File.separator
247-
+ contractName
248-
+ BIN_POSTFIX);
249-
File smBinPath =
250-
new File(
251-
COMPILED_PATH
252-
+ File.separator
253-
+ groupId
254-
+ File.separator
255-
+ contractName
256-
+ File.separator
257-
+ contractAddress
258-
+ File.separator
259-
+ contractName
260-
+ SM_POSTFIX
261-
+ BIN_POSTFIX);
204+
205+
String contractDir =
206+
COMPILED_PATH
207+
+ File.separator
208+
+ groupId
209+
+ File.separator
210+
+ contractName
211+
+ File.separator
212+
+ contractAddress
213+
+ File.separator
214+
+ contractName;
215+
contractDir = contractDir.replace("..", "");
216+
File abiPath = new File(contractDir + ABI_POSTFIX);
217+
File binPath = new File(contractDir + BIN_POSTFIX);
218+
File smBinPath = new File(contractDir + SM_POSTFIX + BIN_POSTFIX);
262219
if (!abiPath.exists() || !binPath.exists() || !smBinPath.exists()) {
263220
if (needCompile) {
264221
AbiAndBin abiAndBin = ContractCompiler.compileContract(contractNameOrPath);

0 commit comments

Comments
 (0)