Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.3.1 dev #613

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
24 changes: 14 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ List logger = [

dependencies {
constraints {
compile group: 'io.netty', name: 'netty-all', version: '4.1.77.Final'
compile group: 'io.netty', name: 'netty-all', version: '4.1.53.Final'
compile 'io.netty:netty-codec-haproxy:4.1.89.Final'
compile group: 'org.fisco-bcos', name: 'tcnative', version: '2.0.51.0'
//compile group: 'org.fisco-bcos', name: 'tcnative', version: '2.0.51.0'
}

compile 'org.quartz-scheduler:quartz:2.3.2'
Expand All @@ -158,7 +158,8 @@ dependencies {
compile 'org.bouncycastle:bcprov-jdk15on:1.69'
compile 'commons-codec:commons-codec:1.14'
compile 'javax.activation:activation:1.1.1'
compile 'org.fisco-bcos:tcnative'
//compile 'org.fisco-bcos:tcnative'
//implementation files("./lib/netty-tcnative-openssl-static-2.0.39.Final.jar")
compile 'org.apache.httpcomponents:httpclient:4.5.13'
compile 'io.netty:netty-all'

Expand All @@ -169,9 +170,9 @@ dependencies {

sourceSets {
main {
resources {
exclude '/*'
}
// resources {
// exclude '/*'
// }
}
}

Expand Down Expand Up @@ -222,6 +223,10 @@ jar {
from configurations.runtime
into 'dist/lib'
}
copy {
from file('lib/')
into 'dist/lib'
}
copy {
from file('.').listFiles().findAll { File f -> (f.name.endsWith('.sh') || f.name.endsWith('.env')) }
into 'dist'
Expand All @@ -235,10 +240,9 @@ jar {
}

task makeStubJAR(type: org.gradle.api.tasks.bundling.Jar) {
baseName 'stub'
from 'build/classes/java/main/com/webank/wecross/stub'
from 'src/main/java/com/webank/wecross/stub'
into 'com/webank/wecross/stub/'
baseName 'wecross-java-stub'
into 'com/webank/wecross/stub', { from 'build/classes/java/main/com/webank/wecross/stub' }
into 'com/webank/wecross/exception', { from 'build/classes/java/main/com/webank/wecross/exception' }

destinationDir file('dist/stub/')
}
Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion scripts/add_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ help() {
echo $1
cat <<EOF
Usage:
-t <type> [Required] type of chain: BCOS2.0, GM_BCOS2.0, Fabric1.4, Fabric2.0, BCOS3_ECDSA_EVM, BCOS3_GM_EVM, BCOS3_ECDSA_WASM, BCOS3_GM_WASM
-t <type> [Required] type of chain: BCOS2.0, GM_BCOS2.0, Fabric1.4, Fabric2.0, BCOS3_ECDSA_EVM, BCOS3_GM_EVM, BCOS3_ECDSA_WASM, BCOS3_GM_WASM, ChainMakerWithCert, ChainMakerGMWithCert, ChainMakerWithPublic, ChainMakerGMWithPublic
-n <name> [Required] name of chain
-d <dir> [Optional] generated target_directory, default conf/chains/
-h [Optional] Help
Expand All @@ -19,6 +19,7 @@ e.g
bash $0 -t BCOS3_GM_EVM -n my_gm_bcos3_chain
bash $0 -t Fabric1.4 -n my_fabric_chain
bash $0 -t Fabric2.0 -n my_fabric_chain
bash $0 -t ChainMakerWithCert -n chainMaker
EOF

exit 0
Expand Down
55 changes: 51 additions & 4 deletions scripts/deploy_system_contract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ help() {
Usage:
-c <chain name> [Required] chain name
-u <upgrade> [Optional] upgrade proxy/hub contract if proxy/hub contract has been deployed, default deploy proxy/hub contract
-t <type> [Required] type of chain, support: BCOS2.0, GM_BCOS2.0, Fabric1.4, Fabric2.0, BCOS3_ECDSA_EVM, BCOS3_GM_EVM, BCOS3_ECDSA_WASM, BCOS3_GM_WASM
-t <type> [Required] type of chain, support: BCOS2.0, GM_BCOS2.0, Fabric1.4, Fabric2.0, BCOS3_ECDSA_EVM, BCOS3_GM_EVM, ChainMakerWithCert, ChainMakerGMWithCert, ChainMakerWithPublic, ChainMakerGMWithPublic
-P <proxy contract> [Optional] upgrade/deploy operation on proxy contract
-H <hub contract> [Optional] upgrade/deploy operation on hub contract
-h [Optional] Help
Expand All @@ -35,6 +35,10 @@ e.g
bash $0 -t Fabric2.0 -c chains/fabric2 -H
bash $0 -t Fabric2.0 -c chains/fabric2 -u -P
bash $0 -t Fabric2.0 -c chains/fabric2 -u -H
bash $0 -t ChainMakerWithCert -c chains/chainmaker -P
bash $0 -t ChainMakerWithCert -c chains/chainmaker -H
bash $0 -t ChainMakerWithCert -c chains/chainmaker -u -P
bash $0 -t ChainMakerWithCert -c chains/chainmaker -u -H
EOF

exit 0
Expand Down Expand Up @@ -69,7 +73,7 @@ bcos_proxy_contract() {
"GM_BCOS2.0")
packageName="bcos.guomi"
;;
"BCOS3_ECDSA_EVM" | "BCOS3_GM_EVM" | "BCOS3_ECDSA_WASM" | "BCOS3_GM_WASM")
"BCOS3_ECDSA_EVM" | "BCOS3_GM_EVM")
packageName="bcos3"
;;
esac
Expand All @@ -93,7 +97,7 @@ bcos_hub_contract() {
"GM_BCOS2.0")
packageName="bcos.guomi"
;;
"BCOS3_ECDSA_EVM" | "BCOS3_GM_EVM" | "BCOS3_ECDSA_WASM" | "BCOS3_GM_WASM")
"BCOS3_ECDSA_EVM" | "BCOS3_GM_EVM")
packageName="bcos3"
;;
esac
Expand Down Expand Up @@ -185,6 +189,42 @@ update_fabric2_hub_contract() {
java -Djdk.tls.client.protocols=TLSv1.2 -Djava.security.properties=${SECURIY_FILE} -Djdk.sunec.disableNative=false -Djdk.tls.namedGroups="SM2,secp256k1,x25519,secp256r1,secp384r1,secp521r1,x448" -cp conf/:lib/*:plugin/* com.webank.wecross.stub.fabric2.hub.HubChaincodeDeployment upgrade "${chainName}"
}

deploy_or_update_chainmaker_proxy_contract() {
local chainName="$1"
local deploy="$2"
local type="$3"
local packageName=""
case $type in
"ChainMakerWithCert" | "ChainMakerGMWithCert" | "ChainMakerWithPublic" | "ChainMakerGMWithPublic")
packageName="chainmaker"
;;
esac

local op="deploy"
if [[ "${deploy}" == "false" ]]; then
op="upgrade"
fi
java -Djava.security.properties=${SECURIY_FILE} -Djdk.sunec.disableNative=false -Djdk.tls.namedGroups="SM2,secp256k1,x25519,secp256r1,secp384r1,secp521r1,x448" -cp conf/:lib/*:plugin/* com.webank.wecross.stub."${packageName}".preparation.ProxyDeployContract "${op}" "${chainName}"
}

deploy_or_update_chainmaker_hub_contract() {
local chainName="$1"
local deploy="$2"
local type="$3"
local packageName=""
case $type in
"ChainMakerWithCert" | "ChainMakerGMWithCert" | "ChainMakerWithPublic" | "ChainMakerGMWithPublic")
packageName="chainmaker"
;;
esac

local op="deploy"
if [[ "${deploy}" == "false" ]]; then
op="upgrade"
fi
java -Djava.security.properties=${SECURIY_FILE} -Djdk.sunec.disableNative=false -Djdk.tls.namedGroups="SM2,secp256k1,x25519,secp256r1,secp384r1,secp521r1,x448" -cp conf/:lib/*:plugin/* com.webank.wecross.stub."${packageName}".preparation.HubDeployContract "${op}" "${chainName}"
}

main() {
local type="$1"
local chain="$2"
Expand All @@ -201,7 +241,7 @@ main() {
LOG_INFO " deploy_system_contract, type: ${type}, chain: ${chain}, deploy: ${deploy}, contract: ${contract}"

case $type in
"BCOS2.0" | "BCOS3_ECDSA_EVM" | "GM_BCOS2.0" | "BCOS3_GM_EVM" | "BCOS3_ECDSA_WASM" | "BCOS3_GM_WASM")
"BCOS2.0" | "BCOS3_ECDSA_EVM" | "GM_BCOS2.0" | "BCOS3_GM_EVM")
if [[ "${contract}" == "proxy" ]]; then
bcos_proxy_contract "${chain}" "${deploy}" "${type}"
elif [[ "${contract}" == "hub" ]]; then
Expand Down Expand Up @@ -230,6 +270,13 @@ main() {
update_fabric2_hub_contract "${chain}"
fi
;;
"ChainMakerWithCert" | "ChainMakerGMWithCert" | "ChainMakerWithPublic" | "ChainMakerGMWithPublic")
if [[ "${contract}" == "proxy" ]]; then
deploy_or_update_chainmaker_proxy_contract "${chain}" "${deploy}" "${type}"
elif [[ "${contract}" == "hub" ]]; then
deploy_or_update_chainmaker_hub_contract "${chain}" "${deploy}" "${type}"
fi
;;
*)
echo "Unrecognized type" && help
;;
Expand Down
2 changes: 1 addition & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
dirpath="$(cd "$(dirname "$0")" && pwd)"
cd ${dirpath}
export LANG='zh_CN.utf8'
export LANG='en_US.UTF-8'

APPS_FOLDER=$(pwd)/apps
PLUGLIN_FOLDER=$(pwd)/plugin
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'wecross'
rootProject.name = 'WeCross'
21 changes: 15 additions & 6 deletions src/main/java/com/webank/wecross/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@ public class Generator {
private static final int ARGS_LENGTH = 3;
private static ApplicationContext context;

public static void main(String[] args) {
public static void connectionChain(String type, String path) throws Exception {
context = new AnnotationConfigApplicationContext(StubManagerConfig.class);
StubManager stubManager = context.getBean(StubManager.class);
StubFactory stubFactory = stubManager.getStubFactory(type);
stubFactory.generateConnection(path, new String[] {});
}

public static void addChainAccount(String type, String path) throws Exception {
context = new AnnotationConfigApplicationContext(StubManagerConfig.class);
StubManager stubManager = context.getBean(StubManager.class);
StubFactory stubFactory = stubManager.getStubFactory(type);
stubFactory.generateAccount(path, new String[] {});
}

public static void main(String[] args) {
if (args.length < ARGS_LENGTH) {
System.out.println("Usage: connection/account <type> <path> <args>");
return;
Expand All @@ -23,14 +35,11 @@ public static void main(String[] args) {
String path = args[2];
System.out.println(String.format("operator: " + op + " type: " + type + " path: " + path));

StubManager stubManager = context.getBean(StubManager.class);
try {
StubFactory stubFactory = stubManager.getStubFactory(type);

if (op.equals("connection")) {
stubFactory.generateConnection(path, new String[] {});
connectionChain(type, path);
} else if (op.equals("account")) {
stubFactory.generateAccount(path, new String[] {});
addChainAccount(type, path);
} else {
System.err.println("Unknown operation: " + op);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public class NetworkQueryStatus {
/** 70000+ is HTLC error real_state = 70000 + HTLCErrorCode */
public static final int HTLC_ERROR = 70000;

/** 80000+ are errors for uploading a resource */
public static final int UPLOAD_RESOURCE_ERROR = 80000;

public static final int UPLOAD_RESOURCE_EXIST = 80001;

public static String getStatusMessage(int status) {
return getStatusMessage(status, "Error code: " + status);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/webank/wecross/common/WeCrossDefault.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ public class WeCrossDefault {
"BCOS2.0",
"GM_BCOS2.0",
"Fabric1.4",
"Fabric2.0");
"Fabric2.0",
"CHAINMAKER");
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public AuthFilter newAuthFilter() {
remoteAuthFilter.setClientConnection(clientConnection);
remoteAuthFilter.registerAuthUri("/auth/register");
remoteAuthFilter.registerAuthUri("/auth/login");
remoteAuthFilter.registerAuthUri("/admin/auth/loginWithoutPwd");
remoteAuthFilter.registerAuthUri("/auth/logout");
remoteAuthFilter.registerAuthUri("/auth/addChainAccount");
remoteAuthFilter.registerAuthUri("/auth/removeChainAccount");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public void onResourcesChange(List<ResourceInfo> resourceInfos) {
chain.updateLocalResources(resourceInfos);
zoneManager.newSeq();
}

@Override
public void onANewResource(ResourceInfo resourceInfo) {
chain.addResource(resourceInfo);
}
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void onFailed(WeCrossException e) {
public <T extends Response> void asyncSend(
Request<?> request, TypeReference typeReference, Callback<T> callback) {
try {
String url = "https://" + clientConnection.getServer() + request.getMethod();
String url = "http://" + clientConnection.getServer() + request.getMethod();
if (logger.isDebugEnabled()) {
logger.debug("request: {}; url: {}", request.toString(), url);
}
Expand Down Expand Up @@ -187,7 +187,7 @@ public void asyncSendInternal(
Iterable<Map.Entry<String, String>> headers,
String body,
Handler handler) {
String url = "https://" + clientConnection.getServer() + uri;
String url = "http://" + clientConnection.getServer() + uri;
BoundRequestBuilder requestBuilder = httpClient.prepare(method, url).setBody(body);

for (Map.Entry<String, String> header : headers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void initializeRequestMapper(WeCrossHost host) {
registerURIHandler(new URIMethod("GET", "/conn/listChains"), connectionURIHandler);
registerURIHandler(new URIMethod("GET", "/conn/listZones"), connectionURIHandler);
registerURIHandler(new URIMethod("POST", "/conn/addChain"), connectionURIHandler);
registerURIHandler(new URIMethod("POST", "/conn/connectChain"), connectionURIHandler);
registerURIHandler(new URIMethod("POST", "/conn/updateChain"), connectionURIHandler);
registerURIHandler(new URIMethod("POST", "/conn/removeChain"), connectionURIHandler);
registerURIHandler(new URIMethod("GET", "/conn/listPeers"), connectionURIHandler);
Expand All @@ -102,6 +103,9 @@ public void initializeRequestMapper(WeCrossHost host) {
ResourceURIHandler resourceURIHandler = new ResourceURIHandler(host);
registerURIHandler(RESOURCE_URIMETHOD, resourceURIHandler);

UpLoadFileURIHandler upLoadFileURIHandler = new UpLoadFileURIHandler();
registerURIHandler(new URIMethod("POST", "/upload/chain"), upLoadFileURIHandler);

logger.info(" initialize size: {}", requestURIMapper.size());
logger.info(" URIMethod: {} ", requestURIMapper.keySet());
}
Expand Down
Loading