Skip to content

Commit

Permalink
Merge pull request #833 from kyonRay/master-2.0
Browse files Browse the repository at this point in the history
release v2.10.0
  • Loading branch information
kyonRay authored Mar 8, 2024
2 parents 5f55b21 + a813205 commit c540421
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 95 deletions.
8 changes: 5 additions & 3 deletions .ci/ci_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ LOG_INFO() {

download_build_chain()
{
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)
LOG_INFO "--- current tag: $tag"
curl -LO "https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/v2.7.2/build_chain.sh" && chmod u+x build_chain.sh
curl -LO "https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/v2.9.1/build_chain.sh" && chmod u+x build_chain.sh
}

prepare_environment()
Expand Down Expand Up @@ -56,6 +54,10 @@ bash gradlew integrationTest --info
}

cp src/integration-test/resources/config-example.toml src/integration-test/resources/config.toml
LOG_INFO "------ check java version -------"
java -version
LOG_INFO "------ check openssl version -------"
openssl version
LOG_INFO "------ download_build_chain---------"
download_build_chain
LOG_INFO "------ check_standard_node---------"
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "CodeQL"

on:
push:
branches: [ 'master*', 'dev*', 'release-*' ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ 'master', 'dev*', 'release-*' ]
schedule:
- cron: '57 14 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# 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
queries: +security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
63 changes: 63 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Console GitHub Actions
on:
pull_request:
release:
types: [ published, created, edited ]
env:
CCACHE_DIR: ${{ github.workspace }}/ccache

jobs:
build:
name: build
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, windows-2019, macos-latest ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: install Ubuntu dependencies
if: runner.os == 'Linux'
run: sudo apt update && sudo apt install -y git curl libssl-dev build-essential openssl
- name: install macOS dependencies
if: runner.os == 'macOS'
run: brew install [email protected]
- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8.0.345'
- name: run build test
if: runner.os == 'Windows'
run: ./gradlew.bat build
- name: run integration testing
if: runner.os != 'Windows'
run: /bin/bash -x .ci/ci_check.sh

build-centos:
name: build-centos
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04 ]
container: docker.io/centos:7
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8.0.345'
- name: install CentOS dependencies
run: yum install -y epel-release centos-release-scl which git openssl-devel openssl wget
- name: run integration testing
run: /bin/bash -x .ci/ci_check.sh
- name: upload coverage
run: curl -LO https://codecov.io/bash && /bin/bash ./bash
15 changes: 15 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
### v2.10.0

(2024-03-08)

更新:

- 合约生成Java文件的功能使用org.fisco-bcos.code-generator:bcos-code-generator中的方法,弃用 `org.fisco-bcos.java-sdk:fisco-bcos-java-sdk``sdk-codegen` 模块。
- 升级Java SDK版本为2.10.0。

修复:

- 修复在使用Solidity复杂数据结构、复杂事件场景时,生成的Java文件出现编译、运行错误的问题。
- 修复 `get_account.sh` 脚本在openssl v3.0 版本下检查失败的问题。
- 修复在读取密钥时可能存在的安全问题。

### v2.9.2
(2022-10-31)

Expand Down
14 changes: 10 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,20 @@ List logger = [
// In this section you declare the dependencies for your production and test code
dependencies {
compile logger
compile 'org.fisco-bcos:solcJ:0.4.25.2'
compile ('org.fisco-bcos:solcJ:0.4.25.2'){
exclude group: 'com.fasterxml.jackson.core'
}

//compile 'org.fisco-bcos:solcJ:0.6.10.2'
//compile 'org.fisco-bcos:solcJ:0.5.2.2'
compile ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:2.9.3')

compile ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:2.10.0')
compile ("com.fasterxml.jackson.core:jackson-databind:2.15.2")
compile('org.fisco-bcos.code-generator:bcos-code-generator:1.4.0') {
exclude group: "org.fisco-bcos.java-sdk"
exclude group: "org.slf4j"
}
compile("commons-cli:commons-cli:1.3.1")
compile 'org.jline:jline:3.12.0'
compile 'org.jline:jline:3.25.0'
compile 'io.bretty:console-table-builder:1.2'
compile 'com.github.jsqlparser:jsqlparser:2.0'
testCompile 'com.github.stefanbirkner:system-rules:1.18.0'
Expand Down
2 changes: 1 addition & 1 deletion release_note.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.9.2
v2.10.0
4 changes: 3 additions & 1 deletion src/main/java/console/ConsoleInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ private AccountInfo loadAccountRandomly(BcosSDK bcosSDK, Client client) {
String subDir = client.getCryptoSuite().getKeyPairFactory().getKeyStoreSubDir();
String keyStoreFileDir = keyStoreDirPath + File.separator + subDir;
File keyStoreFileDirPath = new File(keyStoreFileDir);
logger.debug("loadAccountRandomly, keyStoreFileDirPath:{}", keyStoreFileDir);
if (logger.isDebugEnabled()) {
logger.debug("loadAccountRandomly, keyStoreFileDirPath:{}", keyStoreFileDir);
}
if (!keyStoreFileDirPath.exists() || !keyStoreFileDirPath.isDirectory()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public ConsoleFilesCompleter(Path solidityPath) {
this.solidityPath = solidityPath;
}

@Override
protected String getDisplay(Terminal terminal, Path p) {
String name = p.getFileName().toString();
// do not display .sol
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/console/common/ConsoleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.fisco.bcos.sdk.channel.model.ChannelPrococolExceiption;
import org.fisco.bcos.sdk.channel.model.EnumNodeVersion;
import org.fisco.bcos.sdk.client.Client;
import org.fisco.bcos.sdk.codegen.CodeGenMain;
import org.fisco.bcos.sdk.model.PrecompiledRetCode;
import org.fisco.bcos.sdk.model.RetCode;
import org.fisco.bcos.sdk.transaction.model.dto.TransactionResponse;
Expand Down Expand Up @@ -309,8 +308,9 @@ public static void compileSolToJava(
String abiFile = abiDir + contractName + ".abi";
String binFile = binDir + contractName + ".bin";
String smBinFile = binDir + "/sm/" + contractName + ".bin";
CodeGenMain.main(
org.fisco.bcos.codegen.CodeGenMain.main(
Arrays.asList(
"-v", "V2",
"-a", abiFile,
"-b", binFile,
"-s", smBinFile,
Expand All @@ -325,7 +325,7 @@ public static void compileAllSolToJava(
String javaDir, String packageName, File solFileList, String abiDir, String binDir)
throws IOException {
File[] solFiles = solFileList.listFiles();
if (solFiles.length == 0) {
if (solFiles == null || solFiles.length == 0) {
System.out.println("The contracts directory is empty.");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/console/common/ConsoleVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class ConsoleVersion {

public static final String Version = "2.9.3";
public static final String Version = "2.10.0";

public static void main(String[] args) {
System.out.println("console version: " + Version);
Expand Down
111 changes: 34 additions & 77 deletions src/main/java/console/contract/utils/ContractCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import console.contract.model.AbiAndBin;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import org.apache.commons.io.FileUtils;
import org.fisco.bcos.sdk.codegen.CodeGenUtils;
import org.fisco.bcos.sdk.codegen.exceptions.CodeGenException;
Expand Down Expand Up @@ -75,6 +76,7 @@ public static AbiAndBin compileSolToBinAndAbi(File contractFile, String abiDir,
throws CompileContractException, IOException {
return compileSolToBinAndAbi(contractFile, abiDir, binDir, null);
}

// compile with libraries option
public static AbiAndBin compileSolToBinAndAbi(
File contractFile, String abiDir, String binDir, String librariesOption)
Expand Down Expand Up @@ -160,46 +162,23 @@ public static void checkBinaryCode(String contractName, String binary)
public static void saveAbiAndBin(
Integer groupId, AbiAndBin abiAndBin, String contractName, String contractAddress)
throws IOException {
File abiPath =
new File(
COMPILED_PATH
+ File.separator
+ groupId
+ File.separator
+ contractName
+ File.separator
+ contractAddress
+ File.separator
+ contractName
+ ABI_POSTFIX);
File binPath =
new File(
COMPILED_PATH
+ File.separator
+ groupId
+ File.separator
+ contractName
+ File.separator
+ contractAddress
+ File.separator
+ contractName
+ BIN_POSTFIX);
File smBinPath =
new File(
COMPILED_PATH
+ File.separator
+ groupId
+ File.separator
+ contractName
+ File.separator
+ contractAddress
+ File.separator
+ contractName
+ SM_POSTFIX
+ BIN_POSTFIX);
FileUtils.writeStringToFile(abiPath, abiAndBin.getAbi());
FileUtils.writeStringToFile(binPath, abiAndBin.getBin());
FileUtils.writeStringToFile(smBinPath, abiAndBin.getSmBin());
String contractDir =
COMPILED_PATH
+ File.separator
+ groupId
+ File.separator
+ contractName
+ File.separator
+ contractAddress
+ File.separator
+ contractName;
contractDir = contractDir.replace("..", "");
File abiPath = new File(contractDir + ABI_POSTFIX);
File binPath = new File(contractDir + BIN_POSTFIX);
File smBinPath = new File(contractDir + SM_POSTFIX + BIN_POSTFIX);
FileUtils.writeStringToFile(abiPath, abiAndBin.getAbi(), Charset.defaultCharset());
FileUtils.writeStringToFile(binPath, abiAndBin.getBin(), Charset.defaultCharset());
FileUtils.writeStringToFile(smBinPath, abiAndBin.getSmBin(), Charset.defaultCharset());
}

public static AbiAndBin loadAbiAndBin(
Expand All @@ -222,43 +201,21 @@ public static AbiAndBin loadAbiAndBin(
String contractAddress,
boolean needCompile)
throws IOException, CodeGenException, CompileContractException {
File abiPath =
new File(
COMPILED_PATH
+ File.separator
+ groupId
+ File.separator
+ contractName
+ File.separator
+ contractAddress
+ File.separator
+ contractName
+ ABI_POSTFIX);
File binPath =
new File(
COMPILED_PATH
+ File.separator
+ groupId
+ File.separator
+ contractName
+ File.separator
+ contractAddress
+ File.separator
+ contractName
+ BIN_POSTFIX);
File smBinPath =
new File(
COMPILED_PATH
+ File.separator
+ groupId
+ File.separator
+ contractName
+ File.separator
+ contractAddress
+ File.separator
+ contractName
+ SM_POSTFIX
+ BIN_POSTFIX);

String contractDir =
COMPILED_PATH
+ File.separator
+ groupId
+ File.separator
+ contractName
+ File.separator
+ contractAddress
+ File.separator
+ contractName;
contractDir = contractDir.replace("..", "");
File abiPath = new File(contractDir + ABI_POSTFIX);
File binPath = new File(contractDir + BIN_POSTFIX);
File smBinPath = new File(contractDir + SM_POSTFIX + BIN_POSTFIX);
if (!abiPath.exists() || !binPath.exists() || !smBinPath.exists()) {
if (needCompile) {
AbiAndBin abiAndBin = ContractCompiler.compileContract(contractNameOrPath);
Expand Down
Loading

0 comments on commit c540421

Please sign in to comment.