Skip to content

Commit

Permalink
Merge pull request #766 from WeBankBlockchain/lab-dev
Browse files Browse the repository at this point in the history
Lab-dev(rc2) to lab
  • Loading branch information
CodingCattwo authored May 9, 2022
2 parents f3823fa + d8e4bd1 commit 6db5cfd
Show file tree
Hide file tree
Showing 194 changed files with 8,593 additions and 6,150 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ v0.*.*.js
v0.*.*.js.gz
/output/
/conf/
/liquid/


17 changes: 17 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@

### lab-rc2(2022-05-07)

**Add**
- 新增支持liquid合约的编译、部署、调用
- 支持BFS、CNS、权限管理、Event查看与事件订阅等功能

**Fix**
- 适配兼容FISCO BCOS v3.0.0-rc2

**兼容性**
- 支持FISCO-BCOS v3.0.0-rc2 及以上版本
- WeBASE-Node-Manager lab-rc2
- WeBASE-Sign lab-rc1

详细了解,请阅读[**技术文档**](https://webasedoc.readthedocs.io/zh_CN/lab/)


### lab-rc1(2021-12-09)

**Add**
Expand Down
21 changes: 13 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ repositories {
url "http://maven.aliyun.com/nexus/content/groups/public/"
}
mavenCentral()
maven { url "https://oss.sonatype.org/service/local/staging/deploy/maven2" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url 'https://dl.bintray.com/ethereum/maven/' }
maven { url 'http://repo.typesafe.com/typesafe/maven-releases/' }
mavenLocal()

}

def spring_version="4.3.29.RELEASE"
def spring_version="5.2.20.RELEASE"
List spring =[
"org.springframework:spring-core:$spring_version",
"org.springframework:spring-beans:$spring_version",
Expand All @@ -40,7 +41,7 @@ List spring =[

]

def spring_boot_version="1.5.22.RELEASE"
def spring_boot_version="2.3.12.RELEASE"
List spring_boot =[
"org.springframework.boot:spring-boot-starter-web:$spring_boot_version",
"org.springframework.boot:spring-boot-autoconfigure:$spring_boot_version",
Expand All @@ -56,7 +57,7 @@ List swagger = [
]


def log4j_version="2.15.0"
def log4j_version="2.17.1"
List logger = [
"org.apache.logging.log4j:log4j-api:$log4j_version",
"org.apache.logging.log4j:log4j-core:$log4j_version",
Expand All @@ -71,11 +72,12 @@ List jaxb = [
"javax.activation:activation:1.1.1"
]

def jackson_version = "2.11.4"
def jackson_version = "2.13.2"
List jackson = [
"com.fasterxml.jackson.core:jackson-annotations:$jackson_version",
"com.fasterxml.jackson.core:jackson-core:$jackson_version",
"com.fasterxml.jackson.core:jackson-databind:$jackson_version",
// "com.fasterxml.jackson.core:jackson-databind:$jackson_version",
"com.fasterxml.jackson.core:jackson-databind:2.13.2.2",
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
]

Expand All @@ -97,20 +99,23 @@ List scaffold = [

dependencies {
compile spring,spring_boot,swagger,logger,jaxb,jackson,tomcat,scaffold
compile ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.0.0-rc1')
compile ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.0.0-rc2-bugfix-SNAPSHOT')
// cover
compile 'javax.servlet:javax.servlet-api:4.0.1'
// support guomi/ecdsa same time, support solcJ-0.5.2
compile 'org.fisco-bcos:solcJ:0.4.25-rc1'
compile 'com.h2database:h2:1.4.200'
// compile 'org.fusesource:sigar:1.6.4'
annotationProcessor 'org.projectlombok:lombok:1.18.6'
compile 'org.projectlombok:lombok:1.18.6'
compile 'com.github.jsqlparser:jsqlparser:2.0'
compile 'org.apache.commons:commons-lang3:3.8.1'

// cover low version
compile 'org.slf4j:jcl-over-slf4j:1.7.30'
// cover low version guava
compile 'com.google.guava:guava:29.0-jre'
compile 'org.yaml:snakeyaml:1.30'
compile 'javax.validation:validation-api:2.0.1.Final'

testCompile('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
Expand Down
2 changes: 1 addition & 1 deletion release_note.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lab-rc1
lab-rc2
4 changes: 2 additions & 2 deletions src/main/java/com/webank/webase/front/abi/AbiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public BasePageResponse getAbiListByGroupId(@PathVariable("groupId") String grou
if (pageNumber < 1) {
throw new FrontException(ConstantCode.PARAM_ERROR);
}
Pageable pageable = new PageRequest(pageNumber - 1, pageSize,
new Sort(Sort.Direction.DESC, "createTime"));
Pageable pageable = PageRequest.of(pageNumber - 1, pageSize,
Sort.by(Sort.Direction.DESC, "createTime"));
resList = abiService.getListByGroupId(groupId, pageable);

log.debug("end getAbiListByGroupId resList count. {}", resList.size());
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/webank/webase/front/abi/AbiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void insertAbiInfo(ReqImportAbi param) {
String groupId = param.getGroupId();
String contractName = param.getContractName();
String contractAddress = param.getContractAddress();
int isWasm = param.getIsWasm() ? 1 : 0;
String contractAbiStr;
try {
contractAbiStr = JsonUtils.toJSONString(param.getContractAbi());
Expand All @@ -105,6 +106,7 @@ public void insertAbiInfo(ReqImportAbi param) {
saveAbi.setContractBin(contractBin);
saveAbi.setCreateTime(LocalDateTime.now());
saveAbi.setModifyTime(LocalDateTime.now());
saveAbi.setIsWasm(isWasm);
abiRepository.save(saveAbi);

log.debug("insertAbiInfo saveMethod in abi");
Expand Down Expand Up @@ -139,7 +141,7 @@ public void updateAbiInfo(ReqImportAbi param) {

public void delete(Long id) {
checkAbiIdExist(id);
abiRepository.delete(id);
abiRepository.deleteById(id);
}

public AbiInfo getAbiById(Long abiId) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/webank/webase/front/abi/entity/AbiInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ public class AbiInfo {
// private Integer contractStatus;
private LocalDateTime createTime;
private LocalDateTime modifyTime;
/**
* 0-solidity, 1-liquid
*/
private Integer isWasm;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.webank.webase.front.abi.entity;

import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.NotBlank;

import javax.validation.constraints.NotNull;
import java.util.List;
Expand All @@ -37,4 +37,6 @@ public class ReqImportAbi {
private String contractAddress;
@NotNull
private List<Object> contractAbi;

private Boolean isWasm = false;
}
54 changes: 44 additions & 10 deletions src/main/java/com/webank/webase/front/base/code/ConstantCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public class ConstantCode {
public static final RetCode PARAM_ADDRESS_IS_INVALID = RetCode.mark(201201, "address is invalid");
// permission
public static final RetCode PERMISSION_DENIED = RetCode.mark(201202, "permission denied, please check chain administrator permission");
public static final RetCode ALREADY_ADMIN_OF_CONTRACT = RetCode.mark(201204, "the account has been the admin of concurrt contract.");

// sys config
public static final RetCode UNSUPPORTED_SYSTEM_CONFIG_KEY = RetCode.mark(201208, "unsupported for this system config key");
public static final RetCode SET_SYSTEM_CONFIG_GAS_RANGE_ERROR = RetCode.mark(201209,
Expand Down Expand Up @@ -193,13 +195,6 @@ public class ConstantCode {
public static final RetCode ABI_INFO_NOT_EXISTS = RetCode.mark(201256, "abi info of this id not exists");
public static final RetCode PARAM_FAIL_ABI_ID_EMPTY = RetCode.mark(201257, "Abi Id cannot be empty");

// upload solc js file
public static final RetCode PARAM_FAIL_SOLC_FILE_EMPTY = RetCode.mark(201261, "Solc js file cannot be empty");
public static final RetCode PARAM_FAIL_SOLC_FILE_NAME_EMPTY = RetCode.mark(201262, "Solc js file name cannot be empty");
public static final RetCode PARAM_FAIL_FILE_NAME_EXISTS = RetCode.mark(201263, "Solc js file name already exist");
public static final RetCode PARAM_FAIL_FILE_NAME_NOT_EXISTS = RetCode.mark(201263, "Solc js file name not exist in db");
public static final RetCode SAVE_SOLC_FILE_ERROR = RetCode.mark(201264, "Save solc js file error");
public static final RetCode READ_SOLC_FILE_ERROR = RetCode.mark(201265, "read solc js file error, please check if file deleted");

// chain governance
public static final RetCode CHAIN_THRESHOLD_PARAM_ERROR = RetCode.mark(201301, "threshold must be greater than zero");
Expand All @@ -224,8 +219,8 @@ public class ConstantCode {
public static final RetCode WEB3J_PEM_P12_MANAGER_DEPENDENCY_ERROR = RetCode.mark(201503, "pem/p12 manager get key pair error for bc dependency error");
public static final RetCode REQUEST_SIGN_RETURN_ERROR = RetCode.mark(201504, "sign service return error");
// transaction
public static final RetCode TX_RECEIPT_CODE_ERROR = RetCode.mark(201510, "transaction receipt status return error");
public static final RetCode CONTRACT_ABI_PARSE_JSON_ERROR = RetCode.mark(201511, "contract abi parse json error");
public static final RetCode TX_RECEIPT_NOT_EXIST_ERROR = RetCode.mark(201510, "transaction receipt of this hash not exist");
public static final RetCode BLOCK_NOT_EXIST_ERROR = RetCode.mark(201511, "block of this hash not exist");
public static final RetCode CALL_CONTRACT_IO_EXCEPTION = RetCode.mark(201512, "call contract error for io exception");
public static final RetCode GET_TX_RECEIPT_EXEC_ERROR = RetCode.mark(201513, "get transaction receipt fail for exec");
public static final RetCode GET_TX_RECEIPT_TIMEOUT_ERROR = RetCode.mark(201514, "get transaction receipt fail for time out");
Expand All @@ -244,6 +239,9 @@ public class ConstantCode {
public static final RetCode ALREADY_EXISTS_IN_SEALER_LIST = RetCode.mark(-51104, "The node already exists in the sealerList");
public static final RetCode ALREADY_EXISTS_IN_OBSERVER_LIST = RetCode.mark(-51105, "The node already exists in the observerList");
//public static final RetCode ALREADY_EXISTS_IN_OBSERVER_LIST = RetCode.mark(51105, "The");
public static final RetCode PEERS_NOT_CONNECTED = RetCode.mark(201128, "group peers not connected");
public static final RetCode GENESIS_CONF_NOT_FOUND = RetCode.mark(201131, "group genesis conf not found");


/* fit in 3.0 */
public static final RetCode BCOS_SDK_EMPTY = RetCode.mark(201600, "BcosSDK is empty, call config api to init one bcosSDK");
Expand All @@ -254,10 +252,46 @@ public class ConstantCode {
public static final RetCode BUILD_NEW_CLIENT_FAILED = RetCode.mark(201605, "Build client instance of new group failed");
public static final RetCode CLIENT_ONLY_SUPPORT_WASM = RetCode.mark(201606, "This group only support Liquid contract of wasm");
public static final RetCode CLIENT_NOT_CONNECTED_WITH_THIS_GROUP = RetCode.mark(201607, "This group not connected with front's rpc peers");
public static final RetCode GROUP_SOL_WASM_NOT_MATCH = RetCode.mark(201608, "Deploying contract not match with the group(solidity/liquid)");
public static final RetCode LIQUID_CONTRACT_ALREADY_COMPILING = RetCode.mark(201609, "This liquid contract already compiling, please wait...");
public static final RetCode LIQUID_CONTRACT_TASK_NOT_EXIST = RetCode.mark(201610, "Contract compile task not exist");

public static final RetCode ADD_SEALER_WEIGHT_CANNOT_NULL = RetCode.mark(201621, "Sealer's weight cannot be null");

/* proposal */
public static final RetCode PROPOSAL_IS_VOTING = RetCode.mark(201622, "Proposal is voting, the previous vote need to be finished");
public static final RetCode PROPOSAL_IS_NOT_VOTABLE = RetCode.mark(201623, "The proposal is not votable , please ensure the proposal");
public static final RetCode PROPOSAL_IS_ALREADY_VOTED = RetCode.mark(201624, "The acconut address has already voted the proposal");
public static final RetCode PROPOSAL_NOT_EXIST = RetCode.mark(201625, "The proposal is not exist");
public static final RetCode PROPOSAL_NOT_NEW_CREATED = RetCode.mark(201626,"Only newly created proposal can be revoked");
public static final RetCode PROPOSAL_NOT_END = RetCode.mark(201627," Current proposal not end");


/* rc2 liquid */
public static final RetCode EXEC_JAVA_COMMAND_TIMEOUT = RetCode.mark(201631, "Java Command exec timeout");
public static final RetCode EXEC_JAVA_COMMAND_RETURN_FAILED = RetCode.mark(201632, "Java Command return error");
public static final RetCode DEPLOY_LIQUID_ADDRESS_CANNOT_EMPTY = RetCode.mark(201633, "When deploying liquid, contract address must not be empty");
public static final RetCode LIQUID_ENV_NOT_CONFIG = RetCode.mark(201634, "Liquid environment not configured in the host of webase-front");
public static final RetCode LIQUID_NEW_PROJECT_FAILED = RetCode.mark(201635, "Create new liquid project failed, please check 'liquid' directory in webase-front");
public static final RetCode LIQUID_NEW_PROJECT_SED_GITEE_FAILED = RetCode.mark(201636, "Create new liquid project and set gitee url failed");
public static final RetCode WRITE_CONTRACT_SOURCE_FAILED = RetCode.mark(201637, "Write liquid contract source into lib.rs file failed");
public static final RetCode LIQUID_COMPILE_FAILED = RetCode.mark(201638, "Compile liquid contract failed, please check contract source");
public static final RetCode LIQUID_TARGET_FILE_NOT_EXIST = RetCode.mark(201639, "Liquid compile target file not exist, please check 'liquid' directory in webase-front");
public static final RetCode LIQUID_READ_ABI_BIN_FAILED = RetCode.mark(201640, "Read liquid contract's abi and bin file failed, please check 'liquid' directory in webase-front");

public static final RetCode BUILD_NEW_EVENT_SUBSCRIBE_FAILED = RetCode.mark(201665, "Build eventSubscribe instance of new group failed");

public static final RetCode ADD_SEALER_WEIGHT_CANNOT_NULL = RetCode.mark(201621, "Sealer's weight cannot be null");
/* permission */
public static final RetCode EXEC_ENV_IS_WASM = RetCode.mark(201670, "exec env is wasm, don't support");
public static final RetCode MUST_BE_GOVERNOR = RetCode.mark(201671, "the account must be the governor.");
public static final RetCode MUST_BE_PROPOSER = RetCode.mark(201672, "the account must be the proposer of proposal.");
public static final RetCode OPEN_TABLE_FAILED = RetCode.mark(201673,"Open table failed, please check the existence of the table");
public static final RetCode NOT_SET_METHOD_AUTH_TYPE = RetCode.mark(201674,"The contract method auth type not set, please set method auth type first.");

/* bfs path */
public static final RetCode BFS_INVALID_PATH = RetCode.mark(201680, "the PATH is invalid.");

/* cns path */
public static final RetCode CONTRACT_NAME_VERSION_EXIST = RetCode.mark(201685, "contract name and version already exist");

}
11 changes: 10 additions & 1 deletion src/main/java/com/webank/webase/front/base/code/RetCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public class RetCode {
private Integer code;
private String message;
private String attachment;

public RetCode() {}

Expand All @@ -40,8 +41,16 @@ public static RetCode mark(Integer code) {
return new RetCode(code, null);
}

public RetCode attach(Object attachment) {
if (attachment != null){
this.attachment = String.valueOf(attachment);
}
return this;
}

@Override
public String toString() {
return "{" + "\"code\":" + code + ", \"msg\":\"" + message + "\"}";
return "{" + "\"code\":" + code + ", \"msg\":\"" + message
+ ", \"attachment\":\"" + attachment + "\"}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,63 @@

import com.webank.webase.front.base.properties.Constants;
import lombok.Data;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

import java.util.concurrent.TimeUnit;

/**
* Restful request template configuration
*/
@Data
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
return new RestTemplate(factory);
}

@Autowired
private Constants constants;
/**
* httpRequestFactory.
*
* @return
*/

@Bean
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory factory = getHttpFactoryForDeploy();
// ms
factory.setReadTimeout(constants.getHttp_read_timeOut());
// ms
factory.setConnectTimeout(constants.getHttp_connect_timeOut());
return new RestTemplate(factory);
}

PoolingHttpClientConnectionManager pollingConnectionManager = new PoolingHttpClientConnectionManager(
30, TimeUnit.SECONDS);
// max connection
pollingConnectionManager.setMaxTotal(constants.getRestTemplateMaxTotal());

pollingConnectionManager.setDefaultMaxPerRoute(constants.getRestTemplateMaxPerRoute());
HttpClientBuilder httpClientBuilder = HttpClients.custom();
httpClientBuilder.setConnectionManager(pollingConnectionManager);
// add Keep-Alive
httpClientBuilder
.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy());
HttpClient httpClient = httpClientBuilder.build();
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory =
new HttpComponentsClientHttpRequestFactory(httpClient);
clientHttpRequestFactory.setReadTimeout(constants.getHttp_read_timeOut());
clientHttpRequestFactory.setConnectTimeout(constants.getHttp_connect_timeOut());
return clientHttpRequestFactory;
/**
* factory for deploy.
*/
@Bean()
@Scope("prototype")
public SimpleClientHttpRequestFactory getHttpFactoryForDeploy() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
return factory;
}

// @Bean
// public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
//
// PoolingHttpClientConnectionManager pollingConnectionManager = new PoolingHttpClientConnectionManager(
// 30, TimeUnit.SECONDS);
// // max connection
// pollingConnectionManager.setMaxTotal(constants.getRestTemplateMaxTotal());
//
// pollingConnectionManager.setDefaultMaxPerRoute(constants.getRestTemplateMaxPerRoute());
// HttpClientBuilder httpClientBuilder = HttpClients.custom();
// httpClientBuilder.setConnectionManager(pollingConnectionManager);
// // add Keep-Alive
// httpClientBuilder
// .setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy());
// HttpClient httpClient = httpClientBuilder.build();
// HttpComponentsClientHttpRequestFactory clientHttpRequestFactory =
// new HttpComponentsClientHttpRequestFactory(httpClient);
// clientHttpRequestFactory.setReadTimeout(constants.getHttp_read_timeOut());
// clientHttpRequestFactory.setConnectTimeout(constants.getHttp_connect_timeOut());
// return clientHttpRequestFactory;
// }
}
Loading

0 comments on commit 6db5cfd

Please sign in to comment.