Skip to content

Commit

Permalink
Merge pull request #677 from kyonRay/dev
Browse files Browse the repository at this point in the history
<sync>(project): sync code from master.
  • Loading branch information
kyonRay authored Aug 30, 2022
2 parents 5ef96d3 + fce98d5 commit f9914e8
Show file tree
Hide file tree
Showing 16 changed files with 225 additions and 128 deletions.
30 changes: 30 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## v3.0.0
(2022-8-23)

请阅读控制台 v3.x+文档:

- [中文用户手册](https://fisco-bcos-doc.readthedocs.io/zh_CN/latest/docs/develop/console/index.html)

### 新增

* 使用重构后的ABI Code Generator工具 `bcos-code-generator`https://github.com/FISCO-BCOS/code-generator
* 新增 disableSSL 配置选项,支持与节点无SSL通信

### 更新

* 升级`fisco-bcos-java-sdk``3.0.0`版本,请阅读Java SDK v3.x+文档:[Java SDK v3.x+文档](https://fisco-bcos-doc.readthedocs.io/zh_CN/latest/docs/develop/sdk/java_sdk/index.html)
* 升级`evm-static-analysis``1.0.0-rc3`
* 升级`Log4j`等外部依赖到较新版本

### 修复

* 修复控制台合约路径补全问题
* 修复控制台不更新本地ABI缓存的问题
* 在Solidity 0.8.11以上支持`base-path`功能

### 兼容性说明

- 支持[FISCO BCOS 3.0.0版本](https://github.com/FISCO-BCOS/FISCO-BCOS/releases/tag/v3.0.0)版本
- 不兼容 FISCO BCOS 2.0+ 版本
- 不兼容 FISCO BCOS 3.0-rc+ 版本

## v3.0.0-rc4
(2022-7-1)

Expand Down
91 changes: 47 additions & 44 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.sherter.google-java-format' version '0.8'
id 'com.github.sherter.google-java-format' version '0.8'
}
apply plugin: 'maven'
apply plugin: 'java'
Expand All @@ -14,17 +14,17 @@ targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
maven { url "https://oss.sonatype.org/service/local/staging/deploy/maven2"}
maven { url "https://oss.sonatype.org/service/local/staging/deploy/maven2" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}

googleJavaFormat {
options style: 'AOSP'
source = sourceSets*.allJava
include '**/*.java'
options style: 'AOSP'
source = sourceSets*.allJava
include '**/*.java'
}

def log4j_version="2.17.1"
def log4j_version = "2.18.0"
List logger = [
"org.apache.logging.log4j:log4j-api:$log4j_version",
"org.apache.logging.log4j:log4j-core:$log4j_version",
Expand All @@ -38,23 +38,26 @@ dependencies {
//compile 'org.fisco-bcos:solcJ:0.4.25.1'
//compile 'org.fisco-bcos:solcJ:0.6.10.1'
//compile 'org.fisco-bcos:solcJ:0.5.2.1'
compile 'org.fisco-bcos:solcJ:0.8.11.0'
compile 'org.fisco-bcos:solcJ:0.8.11.1'

// compile 'org.fisco-bcos:solcJ:0.6.10.2-SNAPSHOT'

compile ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.0.0-rc4')
compile ('org.fisco-bcos:evm-static-analysis:1.0.0-rc2')
compile ('io.netty:netty-common:4.1.70.Final')
compile ('commons-cli:commons-cli:1.3.1')
compile ('org.jline:jline:3.12.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')
testCompile ('junit:junit:4.1')
compile('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.0.0')
compile('org.fisco-bcos:evm-static-analysis:1.0.0-rc3')
compile('commons-cli:commons-cli:1.3.1')
compile('org.jline:jline:3.12.0')
compile('io.bretty:console-table-builder:1.2')
compile('com.github.jsqlparser:jsqlparser:2.0')
compile('org.fisco-bcos.code-generator:bcos-code-generator:1.0.0') {
exclude group: "org.fisco-bcos.java-sdk"
exclude group: "org.slf4j"
}
testCompile('com.github.stefanbirkner:system-rules:1.18.0')
testCompile('junit:junit:4.13.1')
}

configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
exclude group: 'ch.qos.logback', module: 'logback-classic'
exclude group: 'io.zipkin.brave', module: 'brave-tests'
}


Expand All @@ -67,7 +70,7 @@ sourceSets {
srcDir 'src/main/resources'
}
}
integrationTest {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
Expand Down Expand Up @@ -96,30 +99,30 @@ jar {
exclude '**/*.key'

doLast {
copy {
from configurations.runtime
into 'dist/lib'
}
copy {
copy {
from configurations.runtime
into 'dist/lib'
}
copy {
from file('src/integration-test/resources/clog.ini')
from file('src/integration-test/resources/config-example.toml')
from file('src/integration-test/resources/group-generate-config.toml')
from file('src/main/resources/log4j2.xml')
into 'dist/conf'
}
copy {
from file('tools/start.sh')
from file('tools/get_account.sh')
from file('tools/get_gm_account.sh')
from file('tools/contract2java.sh')
from file('tools/console.sh')
into 'dist/'
}
copy {
from file('src/main/resources/contract/')
into 'dist/contracts/'
}
new File('dist/contracts/console').mkdirs()
new File('dist/contracts/sdk').mkdirs()
}
from file('src/integration-test/resources/config-example.toml')
from file('src/integration-test/resources/group-generate-config.toml')
from file('src/main/resources/log4j2.xml')
into 'dist/conf'
}
copy {
from file('tools/start.sh')
from file('tools/get_account.sh')
from file('tools/get_gm_account.sh')
from file('tools/contract2java.sh')
from file('tools/console.sh')
into 'dist/'
}
copy {
from file('src/main/resources/contract/')
into 'dist/contracts/'
}
new File('dist/contracts/console').mkdirs()
new File('dist/contracts/sdk').mkdirs()
}
}
3 changes: 2 additions & 1 deletion src/integration-test/resources/config-example.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[cryptoMaterial]

certPath = "conf" # The certification path
certPath = "conf" # The certification path
disableSsl = "false" # Communication with nodes without SSL
useSMCrypto = "false" # RPC SM crypto type

# The following configurations take the certPath by default if commented
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public ConsoleFilesCompleter(File contractFile) {
public ConsoleFilesCompleter(File contractFile, boolean isWasm) {
this(contractFile);
this.isWasm = isWasm;
this.solidityCompleter = !isWasm;
}

public ConsoleFilesCompleter(Path contractPath) {
Expand Down Expand Up @@ -70,10 +71,7 @@ public void complete(
assert commandLine != null;
assert candidates != null;
String buffer = commandLine.word().substring(0, commandLine.wordCursor());
if (solidityCompleter) {
complete(buffer, reader, commandLine, candidates, true);
}
complete(buffer, reader, commandLine, candidates, false);
complete(buffer, reader, commandLine, candidates, solidityCompleter);
}

public void complete(
Expand Down Expand Up @@ -109,11 +107,11 @@ public void complete(
current = getUserDir();
}
}
try {
try (DirectoryStream<Path> directoryStream =
Files.newDirectoryStream(current, this::accept)) {
if (!Files.exists(current)) {
return;
}
DirectoryStream<Path> directoryStream = Files.newDirectoryStream(current, this::accept);
directoryStream.forEach(
p -> {
if (!Files.exists(p)) {
Expand All @@ -137,9 +135,6 @@ public void complete(
return;
}
}
if (solidityCompleter && completeSol && !isWasm) {
value = value.substring(0, value.length() - SOL_STR.length());
}
if (Files.isDirectory(p)) {
candidates.add(
new Candidate(
Expand All @@ -158,6 +153,9 @@ public void complete(
null,
false));
} else {
if (solidityCompleter && completeSol) {
value = value.substring(0, value.length() - SOL_STR.length());
}
candidates.add(
new Candidate(
value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import console.contract.model.AbiAndBin;
import console.contract.utils.ContractCompiler;
import java.util.List;
import org.fisco.bcos.codegen.v3.utils.CodeGenUtils;
import org.fisco.bcos.sdk.v3.client.Client;
import org.fisco.bcos.sdk.v3.codec.wrapper.ABIDefinition;
import org.fisco.bcos.sdk.v3.codegen.CodeGenUtils;
import org.jline.reader.Candidate;
import org.jline.reader.LineReader;
import org.jline.reader.ParsedLine;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/console/common/ConsoleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.FileUtils;
import org.fisco.bcos.codegen.CodeGenMain;
import org.fisco.bcos.sdk.v3.codec.datatypes.Array;
import org.fisco.bcos.sdk.v3.codec.datatypes.Bytes;
import org.fisco.bcos.sdk.v3.codec.datatypes.DynamicBytes;
import org.fisco.bcos.sdk.v3.codec.datatypes.StructType;
import org.fisco.bcos.sdk.v3.codec.datatypes.Type;
import org.fisco.bcos.sdk.v3.codec.datatypes.generated.tuples.generated.Tuple2;
import org.fisco.bcos.sdk.v3.codegen.CodeGenMain;
import org.fisco.bcos.sdk.v3.utils.Numeric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -57,6 +57,7 @@ public class ConsoleUtils {
public static final int ADDRESS_SIZE = 160;
public static final int ADDRESS_LENGTH_IN_HEX = ADDRESS_SIZE >> 2;
public static final String EMPTY_ADDRESS = "0x0000000000000000000000000000000000000000";
public static final String COMPILE_WITH_BASE_PATH = "0.8";

public static void printJson(String jsonStr) {
System.out.println(formatJson(jsonStr));
Expand Down Expand Up @@ -335,6 +336,7 @@ public static void compileSolToJava(

CodeGenMain.main(
Arrays.asList(
"-v", "V3",
"-a", abiFilePath,
"-b", binFilePath,
"-s", smBinFilePath,
Expand Down Expand Up @@ -784,6 +786,7 @@ public static void main(String[] args) {
String smBinFile = cmd.getOptionValue(SM_BIN_OPTION);
CodeGenMain.main(
Arrays.asList(
"-v", "V3",
"-a", abiFile,
"-b", binFile,
"-s", smBinFile,
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 = "3.0.0-rc4";
public static final String Version = "3.0.0";

public static void main(String[] args) {
System.out.println("console version: " + Version);
Expand Down
20 changes: 15 additions & 5 deletions src/main/java/console/contract/ConsoleContractImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import java.util.Objects;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.fisco.bcos.codegen.v3.exceptions.CodeGenException;
import org.fisco.bcos.codegen.v3.utils.CodeGenUtils;
import org.fisco.bcos.sdk.v3.client.Client;
import org.fisco.bcos.sdk.v3.client.exceptions.ClientException;
import org.fisco.bcos.sdk.v3.client.protocol.response.Abi;
Expand All @@ -42,8 +44,6 @@
import org.fisco.bcos.sdk.v3.codec.wrapper.ABIObject;
import org.fisco.bcos.sdk.v3.codec.wrapper.ContractABIDefinition;
import org.fisco.bcos.sdk.v3.codec.wrapper.ContractCodecTools;
import org.fisco.bcos.sdk.v3.codegen.CodeGenUtils;
import org.fisco.bcos.sdk.v3.codegen.exceptions.CodeGenException;
import org.fisco.bcos.sdk.v3.contract.precompiled.bfs.BFSService;
import org.fisco.bcos.sdk.v3.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.v3.model.CryptoType;
Expand Down Expand Up @@ -858,15 +858,25 @@ private String getSolidityAbi(String contractFileName) throws Exception {
}
String contractName = solFile.getName().split("\\.")[0];

List<SolidityCompiler.Option> defaultOptions = Arrays.asList(ABI, BIN, METADATA);
List<SolidityCompiler.Option> options = new ArrayList<>(defaultOptions);

if (org.fisco.solc.compiler.Version.version.compareToIgnoreCase(
ConsoleUtils.COMPILE_WITH_BASE_PATH)
>= 0) {
SolidityCompiler.Option basePath =
new SolidityCompiler.CustomOption(
"base-path", solFile.getParentFile().getCanonicalPath());
options.add(basePath);
}

// compile ecdsa
SolidityCompiler.Result res =
SolidityCompiler.compile(
solFile,
(client.getCryptoType() == CryptoType.SM_TYPE),
true,
ABI,
BIN,
METADATA);
options.toArray(new SolidityCompiler.Option[0]));

if (logger.isDebugEnabled()) {
logger.debug(
Expand Down
Loading

0 comments on commit f9914e8

Please sign in to comment.