mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 09:54:07 +00:00
fix rocksdb bugs
This commit is contained in:
parent
c077d425ab
commit
363a20049a
@ -43,7 +43,7 @@ dependencies {
|
|||||||
implementation 'com.sun.mail:javax.mail:1.6.2'
|
implementation 'com.sun.mail:javax.mail:1.6.2'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
|
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
|
||||||
implementation 'org.bdware.bdcontract:sdk-java:1.0.0'
|
implementation 'org.bdware.bdcontract:sdk-java:1.0.0'
|
||||||
implementation 'org.bdware.doip:doip-audit-tool:0.9.4'
|
implementation 'org.bdware.doip:doip-audit-tool:1.0.8'
|
||||||
implementation fileTree(dir: 'lib', include: '*.jar')
|
implementation fileTree(dir: 'lib', include: '*.jar')
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
}
|
}
|
||||||
@ -58,7 +58,8 @@ jar {
|
|||||||
libs = libs + " libs/" + it.name
|
libs = libs + " libs/" + it.name
|
||||||
}
|
}
|
||||||
from {
|
from {
|
||||||
// uncomment this when publish!
|
// uncomment this when publish,
|
||||||
|
// while develop at local use "false"
|
||||||
configurations.runtimeClasspath.filter {
|
configurations.runtimeClasspath.filter {
|
||||||
// it.getAbsolutePath().contains("/lib/")
|
// it.getAbsolutePath().contains("/lib/")
|
||||||
false
|
false
|
||||||
|
@ -39,7 +39,6 @@ import org.bdware.sc.util.JsonUtil;
|
|||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
import wrp.jdk.nashorn.api.scripting.ScriptObjectMirror;
|
|
||||||
|
|
||||||
import javax.script.ScriptContext;
|
import javax.script.ScriptContext;
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
@ -477,18 +476,6 @@ public class ContractProcess {
|
|||||||
cn = zipBundle.mergeContractNode();
|
cn = zipBundle.mergeContractNode();
|
||||||
// check functionNodes
|
// check functionNodes
|
||||||
List<FunctionNode> functionNodes = cn.getFunctions();
|
List<FunctionNode> functionNodes = cn.getFunctions();
|
||||||
LOGGER.debug(
|
|
||||||
"functionNodes jointInfo: "
|
|
||||||
+ JsonUtil.toPrettyJson(
|
|
||||||
functionNodes.stream()
|
|
||||||
.map(
|
|
||||||
x -> {
|
|
||||||
JoinInfo joinInfo = x.getJoinInfo();
|
|
||||||
return null == joinInfo
|
|
||||||
? "null"
|
|
||||||
: joinInfo;
|
|
||||||
})
|
|
||||||
.toArray()));
|
|
||||||
injectHandlers();
|
injectHandlers();
|
||||||
|
|
||||||
this.contract.setYjsType(cn.getYjsType());
|
this.contract.setYjsType(cn.getYjsType());
|
||||||
@ -644,6 +631,8 @@ public class ContractProcess {
|
|||||||
return ver;
|
return ver;
|
||||||
}
|
}
|
||||||
handleLog();
|
handleLog();
|
||||||
|
LOGGER.info("load script, contract:" + JsonUtil.toJson(contract.getScriptStr()));
|
||||||
|
LOGGER.info("load cn:" + JsonUtil.toJson(cn));
|
||||||
String ret =
|
String ret =
|
||||||
JsonUtil.toJson(engine.loadContract(contract, cn, cn.getInstrumentBranch()));
|
JsonUtil.toJson(engine.loadContract(contract, cn, cn.getInstrumentBranch()));
|
||||||
invokeOnCreate(contract.getCreateParam());
|
invokeOnCreate(contract.getCreateParam());
|
||||||
@ -897,6 +886,7 @@ public class ContractProcess {
|
|||||||
}
|
}
|
||||||
String reqID = request.getRequestID();
|
String reqID = request.getRequestID();
|
||||||
if (cachedRequests.contains(reqID)) {
|
if (cachedRequests.contains(reqID)) {
|
||||||
|
LOGGER.info("[Hit Cache]:" + reqID);
|
||||||
try {
|
try {
|
||||||
String cachedResult = edion.get(reqID);
|
String cachedResult = edion.get(reqID);
|
||||||
if (cachedResult != null && !cachedResult.isEmpty()) {
|
if (cachedResult != null && !cachedResult.isEmpty()) {
|
||||||
@ -946,10 +936,6 @@ public class ContractProcess {
|
|||||||
result = engine.executeContract(request);
|
result = engine.executeContract(request);
|
||||||
|
|
||||||
result.analysis = bo.toString();
|
result.analysis = bo.toString();
|
||||||
// System.out.println(
|
|
||||||
// "[withEvaluatesAnalysis ContractProcess] result.analysis =
|
|
||||||
// "
|
|
||||||
// + result.analysis);
|
|
||||||
engine.redirectTracePS(previous);
|
engine.redirectTracePS(previous);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -958,15 +944,12 @@ public class ContractProcess {
|
|||||||
result = engine.executeContract(request);
|
result = engine.executeContract(request);
|
||||||
engine.redirectTracePS(previous);
|
engine.redirectTracePS(previous);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
|
|
||||||
// System.out.println("res" + result.result);
|
|
||||||
// result.addProperty("result",maskResult.getMaskResult(maskConf,
|
|
||||||
// ret.get("result")).toString());
|
|
||||||
|
|
||||||
String ret = JsonUtil.toJson(result);
|
String ret = JsonUtil.toJson(result);
|
||||||
|
if (reqID != null && reqID.endsWith("_mul")) {
|
||||||
cachedRequests.add(reqID);
|
cachedRequests.add(reqID);
|
||||||
edion.put(reqID, ret);
|
edion.put(reqID, ret);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ByteArrayOutputStream bo = new ByteArrayOutputStream();
|
ByteArrayOutputStream bo = new ByteArrayOutputStream();
|
||||||
@ -976,7 +959,6 @@ public class ContractProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String evaluatesAnalysis(String getFunction) {
|
public String evaluatesAnalysis(String getFunction) {
|
||||||
// System.out.println("当前的function:" + getFunction);
|
|
||||||
Map<String, byte[]> clzs = engine.dumpClass();
|
Map<String, byte[]> clzs = engine.dumpClass();
|
||||||
Map<String, MethodNode> methods = new HashMap<>();
|
Map<String, MethodNode> methods = new HashMap<>();
|
||||||
for (byte[] clz : clzs.values()) {
|
for (byte[] clz : clzs.values()) {
|
||||||
|
@ -91,7 +91,8 @@ public class DOIPUtil {
|
|||||||
return respDO.toString();
|
return respDO.toString();
|
||||||
} catch (Exception ie) {
|
} catch (Exception ie) {
|
||||||
ie.printStackTrace();
|
ie.printStackTrace();
|
||||||
return "send doip message error: " + ie.getMessage();
|
return ret.body.getDataAsJsonString();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +103,8 @@ public class DOIPUtil {
|
|||||||
|
|
||||||
public String retrieve(String doi, String args) {
|
public String retrieve(String doi, String args) {
|
||||||
DoipMessage msg = (new DoipMessageFactory.DoipMessageBuilder()).createRequest(doi, BasicOperations.Retrieve.getName())
|
DoipMessage msg = (new DoipMessageFactory.DoipMessageBuilder()).createRequest(doi, BasicOperations.Retrieve.getName())
|
||||||
.setBody(args.getBytes(StandardCharsets.UTF_8)).create();
|
.create();
|
||||||
|
msg.header.parameters.addAttribute("element", "");
|
||||||
return convertDoipMsgToString(syncGetMessage(msg));
|
return convertDoipMsgToString(syncGetMessage(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import org.bdware.sc.compiler.PermissionStub;
|
|||||||
import org.bdware.sc.node.Permission;
|
import org.bdware.sc.node.Permission;
|
||||||
import org.rocksdb.Options;
|
import org.rocksdb.Options;
|
||||||
import org.rocksdb.RocksDB;
|
import org.rocksdb.RocksDB;
|
||||||
import org.rocksdb.RocksDBException;
|
|
||||||
import org.rocksdb.RocksIterator;
|
import org.rocksdb.RocksIterator;
|
||||||
import wrp.jdk.nashorn.internal.runtime.PropertyMap;
|
import wrp.jdk.nashorn.internal.runtime.PropertyMap;
|
||||||
import wrp.jdk.nashorn.internal.runtime.ScriptObject;
|
import wrp.jdk.nashorn.internal.runtime.ScriptObject;
|
||||||
@ -30,8 +29,7 @@ public class RocksDBUtil {
|
|||||||
RocksDB rocksDB;
|
RocksDB rocksDB;
|
||||||
String path;
|
String path;
|
||||||
|
|
||||||
public RocksDBUtil(String path, boolean readOnly) {
|
public void tryLoad(String path, boolean readOnly) throws Exception {
|
||||||
try {
|
|
||||||
this.path = path;
|
this.path = path;
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
options.setCreateIfMissing(true);
|
options.setCreateIfMissing(true);
|
||||||
@ -47,12 +45,27 @@ public class RocksDBUtil {
|
|||||||
} else {
|
} else {
|
||||||
rocksDB = RocksDB.open(options, dir.getAbsolutePath());
|
rocksDB = RocksDB.open(options, dir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
} catch (RocksDBException e) {
|
}
|
||||||
|
|
||||||
|
public RocksDBUtil(String path, boolean readOnly) {
|
||||||
|
try {
|
||||||
|
tryLoad(path, readOnly);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.info("======TRY Load Again 2s later====");
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000L);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
tryLoad(path, readOnly);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOGGER.info("======LOAD FAILED!====");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static RocksDBUtil loadDB(String path, boolean readOnly) {
|
public static synchronized RocksDBUtil loadDB(String path, boolean readOnly) {
|
||||||
if (cacheDB.containsKey(path)) {
|
if (cacheDB.containsKey(path)) {
|
||||||
return cacheDB.get(path);
|
return cacheDB.get(path);
|
||||||
}
|
}
|
||||||
@ -125,4 +138,8 @@ public class RocksDBUtil {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String clean() {
|
||||||
|
return "todo";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@ public class UtilRegistry {
|
|||||||
String.format(
|
String.format(
|
||||||
"%sUtil = %s.%sUtil%s;\n",
|
"%sUtil = %s.%sUtil%s;\n",
|
||||||
s, UtilRegistry.class.getPackage().getName(), s, open ? "" : "Stub");
|
s, UtilRegistry.class.getPackage().getName(), s, open ? "" : "Stub");
|
||||||
LOGGER.debug(ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -270,6 +270,7 @@ public class DesktopEngine extends JSEngine {
|
|||||||
ScriptEngine.FILENAME,
|
ScriptEngine.FILENAME,
|
||||||
fun.getFileName(),
|
fun.getFileName(),
|
||||||
ScriptContext.ENGINE_SCOPE);
|
ScriptContext.ENGINE_SCOPE);
|
||||||
|
LOGGER.info("loadFun:" + str);
|
||||||
compileFunction(str, isInsnLimit);
|
compileFunction(str, isInsnLimit);
|
||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
return wrapperException(e, fun);
|
return wrapperException(e, fun);
|
||||||
@ -496,6 +497,7 @@ public class DesktopEngine extends JSEngine {
|
|||||||
} else {
|
} else {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
ret = executeWithoutLock(fun, input);
|
ret = executeWithoutLock(fun, input);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//System.out.println("[DesktopEngine MaskConfig]"+ContractProcess.instance.getProjectConfig().getMaskConfig().config.toString());
|
//System.out.println("[DesktopEngine MaskConfig]"+ContractProcess.instance.getProjectConfig().getMaskConfig().config.toString());
|
||||||
@ -526,10 +528,10 @@ public class DesktopEngine extends JSEngine {
|
|||||||
if (syncUtil.startFlag && !recovering) {
|
if (syncUtil.startFlag && !recovering) {
|
||||||
switch (syncUtil.currType) {
|
switch (syncUtil.currType) {
|
||||||
case Trace:
|
case Trace:
|
||||||
syncUtil.traceRecordUtil.eachFinish();
|
// syncUtil.traceRecordUtil.eachFinish();
|
||||||
break;
|
break;
|
||||||
case Trans:
|
case Trans:
|
||||||
syncUtil.transRecordUtil.eachFinish();
|
// syncUtil.transRecordUtil.eachFinish();
|
||||||
break;
|
break;
|
||||||
case Memory:
|
case Memory:
|
||||||
default:
|
default:
|
||||||
|
@ -15,8 +15,8 @@ public class LedgerUtilTest {
|
|||||||
public static void main(String[] arg) {
|
public static void main(String[] arg) {
|
||||||
String ip = "39.104.202.92";
|
String ip = "39.104.202.92";
|
||||||
ip = "39.104.205.122";
|
ip = "39.104.205.122";
|
||||||
ip = "39.104.202.92";
|
ip = "39.104.201.40";
|
||||||
Client c = new Client(ip, 18021);
|
Client c = new Client(ip, 21121);
|
||||||
System.out.println(c.clientVersionSync().getVersion());
|
System.out.println(c.clientVersionSync().getVersion());
|
||||||
System.out.println(c.getLedgersSync().toString());
|
System.out.println(c.getLedgersSync().toString());
|
||||||
String from = "0xb60e8dd61c5d32be8058bb8eb970870f07233155";
|
String from = "0xb60e8dd61c5d32be8058bb8eb970870f07233155";
|
||||||
@ -38,6 +38,8 @@ public class LedgerUtilTest {
|
|||||||
str = "d16da370021447c1c1136f97f9975069b1f22ddb";
|
str = "d16da370021447c1c1136f97f9975069b1f22ddb";
|
||||||
str = "448b314de358384a55b9c5d2eae7596cff4e3587";
|
str = "448b314de358384a55b9c5d2eae7596cff4e3587";
|
||||||
str ="a114aa22365c2d61ee1c242c755d82c035783e41";
|
str ="a114aa22365c2d61ee1c242c755d82c035783e41";
|
||||||
|
str = "d9be17b4287ed9a548901ef0e738f65f25dc7041";
|
||||||
|
str="e90dbc995add64b26fa483b1b0ad7747b19ad579";
|
||||||
byte[] bytes = ByteUtils.fromHexString(str);
|
byte[] bytes = ByteUtils.fromHexString(str);
|
||||||
String hash = ByteUtil.encodeBASE64(bytes);
|
String hash = ByteUtil.encodeBASE64(bytes);
|
||||||
System.out.println(URLEncoder.encode(hash));
|
System.out.println(URLEncoder.encode(hash));
|
||||||
|
Loading…
Reference in New Issue
Block a user