Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d17805d
add 3 cases for iscontract
mumianhua Mar 21, 2024
9e815fe
upgrade dependency version
XvZipo Apr 23, 2024
961acfa
upgrade dependency version
XvZipo Apr 23, 2024
38a1a6e
upgrade dependency version
XvZipo Apr 23, 2024
306a0d9
upgrade dependency version
XvZipo Apr 23, 2024
eef77dc
upgrade dependency version
XvZipo Apr 23, 2024
b3d7b5a
upgrade dependency version
XvZipo Apr 23, 2024
292d453
downgrade dependency version logback
XvZipo Apr 23, 2024
3a43079
upgrade dependency version logback
XvZipo Apr 23, 2024
ceb2ce0
upgrade dependency version slf4j
XvZipo Apr 23, 2024
1454933
upgrade dependency version logback
XvZipo Apr 23, 2024
8b6ace1
delete dependency version sf4j
XvZipo Apr 23, 2024
2f12b66
upgrade dependency version sf4j
XvZipo Apr 23, 2024
66d29af
downgrade dependency version logback
XvZipo Apr 23, 2024
2c564d6
upgrade dependency version logback
XvZipo Apr 23, 2024
e330bc5
upgrade dependency version grpc-netty 1.63
XvZipo Apr 24, 2024
3db9107
upgrade dependency version bcprov-jdk18on
XvZipo Apr 24, 2024
4ff9045
upgrade dependency version guava
XvZipo Apr 24, 2024
51910a3
upgrade dependency version aspectjrt
XvZipo Apr 24, 2024
976ed40
upgrade dependency version zeromq
XvZipo Apr 24, 2024
aad4ad1
delete briandilley.jsonrpc4j
XvZipo Apr 24, 2024
8ab0f85
update guava-jre
XvZipo Apr 24, 2024
ef615e9
delete httpasyncclient
XvZipo Apr 24, 2024
7e5ca66
update dependency
XvZipo Apr 24, 2024
582c3e2
update zeromq and delete AspectJ
XvZipo Apr 24, 2024
1a10f02
downgrade logback-classic to 1.2.13
XvZipo Apr 24, 2024
601b17d
upgrade logback-classic to 1.3.14
XvZipo Apr 24, 2024
a278bdd
add trident 0.9.0 case
XvZipo May 20, 2024
1060343
modify testng.conf to set 81,82 proposal as 1,1500
XvZipo May 20, 2024
5509d94
delete old jar file
XvZipo May 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ subprojects {
}

dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
compile "org.slf4j:jcl-over-slf4j:1.7.25"
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
compile group: 'org.slf4j', name: 'slf4j-api', version: '2.0.2'
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '2.0.2'
compile "org.slf4j:jcl-over-slf4j:2.0.2"
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.3.14'
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
testCompileOnly 'org.projectlombok:lombok:1.18.12'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
compile group: 'com.google.guava', name: 'guava', version: '24.1-jre'
compile group: 'com.google.guava', name: 'guava', version: '24.1.1-jre'
compile "com.google.code.findbugs:jsr305:3.0.0"
compile group: 'org.springframework', name: 'spring-context', version: '4.2.4.RELEASE'
compile group: 'org.springframework', name: 'spring-tx', version: '4.2.4.RELEASE'
compile group: 'org.springframework', name: 'spring-context', version: '5.3.27'
compile group: 'org.springframework', name: 'spring-tx', version: '5.3.27'
compile "org.apache.commons:commons-lang3:3.4"
compile group: 'org.apache.commons', name: 'commons-math', version: '2.2'
compile "org.apache.commons:commons-collections4:4.0"
compile "org.apache.commons:commons-collections4:4.1"
compile group: 'joda-time', name: 'joda-time', version: '2.3'
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.12.11'
compile group: 'org.mongodb', name: 'bson', version: '4.6.0'
Expand Down
10 changes: 5 additions & 5 deletions protocol/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.google.protobuf'

dependencies {
compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.4.0'
compile group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.4.0'
compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.16.3'
compile group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.20.0'
compile group: 'net.jcip', name: 'jcip-annotations', version: '1.0'

// checkstyleConfig "com.puppycrawl.tools:checkstyle:${versions.checkstyle}"
// google grpc
compile group: 'io.grpc', name: 'grpc-netty', version: '1.14.0'
compile group: 'io.grpc', name: 'grpc-protobuf', version: '1.14.0'
compile group: 'io.grpc', name: 'grpc-stub', version: '1.14.0'
compile group: 'io.grpc', name: 'grpc-netty', version: '1.60.0'
compile group: 'io.grpc', name: 'grpc-protobuf', version: '1.60.0'
compile group: 'io.grpc', name: 'grpc-stub', version: '1.60.0'
// end google grpc

compile group: 'com.google.api.grpc', name: 'googleapis-common-protos', version: '0.0.3'
Expand Down
26 changes: 13 additions & 13 deletions testcase/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies {

compile group: 'com.typesafe', name: 'config', version: '1.3.2'

compile "com.cedarsoftware:java-util:1.8.0"
compile "com.cedarsoftware:java-util:1.11.0"

compile group: 'com.beust', name: 'jcommander', version: '1.72'

Expand All @@ -55,8 +55,8 @@ dependencies {

compile group: 'com.google.inject', name: 'guice', version: '4.1.0'

compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.10.3'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.7.1'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.6'

compile group: 'io.dropwizard.metrics', name: 'metrics-core', version: '3.1.2'
compile group: 'com.github.davidb', name: 'metrics-influxdb', version: '0.8.2'
Expand All @@ -66,14 +66,14 @@ dependencies {
compile 'org.aspectj:aspectjrt:1.8.13'
compile 'org.aspectj:aspectjweaver:1.8.13'
compile 'org.aspectj:aspectjtools:1.8.13'
compile 'com.googlecode.cqengine:cqengine:2.12.4'
compile group: 'com.google.api.grpc', name: 'googleapis-common-protos', version: '0.0.3'
// compile 'com.googlecode.cqengine:cqengine:3.6.0'
// compile group: 'com.google.api.grpc', name: 'googleapis-common-protos', version: '0.0.3'

// http
compile 'org.eclipse.jetty:jetty-server:9.4.11.v20180605'
compile 'org.eclipse.jetty:jetty-server:9.4.53.v20231009'
compile 'org.eclipse.jetty:jetty-servlet:9.4.11.v20180605'
compile 'com.alibaba:fastjson:1.2.70'
compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.1'
compile 'com.alibaba:fastjson:1.2.83'
compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.5'
// end http

// https://mvnrepository.com/artifact/com.github.briandilley.jsonrpc4j/jsonrpc4j
Expand All @@ -83,7 +83,7 @@ dependencies {
compileOnly group: 'javax.portlet', name: 'portlet-api', version: '3.0.1'

compile "io.vavr:vavr:0.9.2"
compile group: 'org.pf4j', name: 'pf4j', version: '2.5.0'
compile group: 'org.pf4j', name: 'pf4j', version: '3.10.0'

compile group: 'org.zeromq', name: 'jeromq', version: '0.5.0'
compile 'io.github.tronprotocol:zksnark-java-sdk:1.0.0'
Expand All @@ -92,10 +92,10 @@ dependencies {

// compile group: 'org.iq80.leveldb', name: 'leveldb', version: '0.12'
compile group: leveldbGroup, name: leveldbName, version: leveldbVersion
implementation 'io.grpc:grpc-netty-shaded:1.31.0'
implementation 'io.grpc:grpc-netty:1.31.0'
implementation 'io.grpc:grpc-protobuf:1.31.0'
implementation 'io.grpc:grpc-stub:1.31.0'
implementation 'io.grpc:grpc-netty-shaded:1.60.0'
implementation 'io.grpc:grpc-netty:1.60.0'
implementation 'io.grpc:grpc-protobuf:1.63.0'
implementation 'io.grpc:grpc-stub:1.60.0'
implementation 'com.google.guava:guava:28.0-jre'
implementation fileTree(dir: 'libs', include: '*.jar')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.alibaba.fastjson.parser.ParserConfig;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.google.protobuf.ByteString;
import com.googlecode.cqengine.query.simple.In;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.google.gson.JsonObject;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import javassist.bytecode.BadBytecode;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class isContractCommand001 {
.getString("foundationAccount.key2");
private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey);
byte[] contractAddress = null;
byte[] contractA = null;
byte[] contractC = null;
ECKey ecKey1 = new ECKey(Utils.getRandom());
byte[] contractExcAddress = ecKey1.getAddress();
String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes());
Expand Down Expand Up @@ -71,6 +73,17 @@ public void beforeClass() {
contractAddress = PublicMethed
.deployContract(contractName, abi, code, "", maxFeeLimit, 0L, 100, null, contractExcKey,
contractExcAddress, blockingStubFull);


contractName = "C";
retMap = PublicMethed.getBycodeAbi(filePath, contractName);
code = retMap.get("byteCode").toString();
abi = retMap.get("abI").toString();
contractC = PublicMethed
.deployContract(contractName, abi, code, "", maxFeeLimit, 0L, 100, null, contractExcKey,
contractExcAddress, blockingStubFull);

PublicMethed.waitProduceNextBlock(blockingStubFull);
}


Expand Down Expand Up @@ -332,6 +345,99 @@ public void test05ActiveContractBeforeDeploy() {
Assert.assertEquals("CONTRACT_VALIDATE_ERROR", response.getCode().name());
Assert.assertFalse(response.getResult());
}

@Test(enabled = true, description = "deploy A in create2, A trigger B's iscontract in it's constructor")
public void test06TriggerInCreate2Constructor() {
String contractName = "A";
String filePath = "src/test/resources/soliditycode/TvmIsContract001.sol";
HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName);
String code = retMap.get("byteCode").toString();
String hexB = ByteArray.toHexString(contractAddress);
String testContractCode = code;
testContractCode += "000000000000000000000000" + hexB;
Long salt = 7L;

String param = "\"" + testContractCode + "\"," + salt;

String triggerTxid = PublicMethed.triggerContract(contractC,
"create2(bytes,uint256)", param, false, 0L,
1000000000L, "0", 0, contractExcAddress, contractExcKey, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
Optional<Protocol.TransactionInfo> info = PublicMethed
.getTransactionInfoById(triggerTxid, blockingStubFull);
Assert.assertTrue(info.get().getResultValue() == 0);

String hexA = "41" + ByteArray.toHexString(info.get().getContractResult(0).toByteArray()).substring(24);
logger.info("hexA: " + hexA);
contractA = ByteArray.fromHexString(hexA);
TransactionExtention transactionExtention = PublicMethed
.triggerConstantContractForExtention(contractA, "testConstructorView()", "", false, 0,
0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull);
logger.info("trigger A testConstructorView : " + transactionExtention.toString());
Assert.assertEquals("SUCCESS", transactionExtention.getResult().getCode().toString());
Assert
.assertEquals(1, ByteArray.toInt(transactionExtention.getConstantResult(0).toByteArray()));
}

@Test(enabled = true, description = "deploy A in create, A trigger B's iscontract in it's constructor")
public void test07TriggerInCreateConstructor() {
String contractName = "A";
String filePath = "src/test/resources/soliditycode/TvmIsContract001.sol";
HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName);
String code = retMap.get("byteCode").toString();
String hexB = ByteArray.toHexString(contractAddress);
String testContractCode = code;
testContractCode += "000000000000000000000000" + hexB;

String param = "\"" + testContractCode + "\"";

String triggerTxid = PublicMethed.triggerContract(contractC,
"create(bytes)", param, false, 0L,
1000000000L, "0", 0, contractExcAddress, contractExcKey, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
Optional<Protocol.TransactionInfo> info = PublicMethed
.getTransactionInfoById(triggerTxid, blockingStubFull);
Assert.assertTrue(info.get().getResultValue() == 0);

String hexA = "41" + ByteArray.toHexString(info.get().getContractResult(0).toByteArray()).substring(24);
logger.info("hexA: " + hexA);
contractA = ByteArray.fromHexString(hexA);
TransactionExtention transactionExtention = PublicMethed
.triggerConstantContractForExtention(contractA, "testConstructorView()", "", false, 0,
0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull);
logger.info("trigger A testConstructorView : " + transactionExtention.toString());
Assert.assertEquals("SUCCESS", transactionExtention.getResult().getCode().toString());
Assert
.assertEquals(1, ByteArray.toInt(transactionExtention.getConstantResult(0).toByteArray()));
}


@Test(enabled = true, description = "A call B's iscontract in it's constructor")
public void test08ConstructorCall() {
String filePath = "src/test/resources/soliditycode/TvmIsContract001.sol";
String contractName = "A";
HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName);
String code = retMap.get("byteCode").toString();
String abi = retMap.get("abI").toString();
String param = "\"" + Base58.encode58Check(contractAddress) + "\"";
String txid = PublicMethed
.deployContractWithConstantParame(contractName, abi, code, "constructor(address)",param,null,
maxFeeLimit, 0L, 100,
null, contractExcKey, contractExcAddress, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);
Optional<Protocol.TransactionInfo> info = PublicMethed.getTransactionInfoById(txid, blockingStubFull);
Assert.assertTrue(info.get().getResultValue() == 0);
byte[] aContract = info.get().getContractAddress().toByteArray();

TransactionExtention transactionExtention = PublicMethed
.triggerConstantContractForExtention(aContract, "testConstructorView()", "", false, 0,
0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull);
logger.info("test08 A call B in constructor :" + transactionExtention.toString());
Assert.assertEquals("SUCCESS", transactionExtention.getResult().getCode().toString());
Assert
.assertEquals(1, ByteArray.toInt(transactionExtention.getConstantResult(0).toByteArray()));
}

/**
* constructor.
*/
Expand Down
38 changes: 38 additions & 0 deletions testcase/src/test/resources/soliditycode/TvmIsContract001.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,41 @@ function testConstructorView() public view returns(bool){
return isContrct;
}
}


contract A{
bool public isContrct;
constructor (address B) public {
(bool success, bytes memory data) = address(B).call(abi.encodeWithSignature("testIsContractView(address)",address(this)));
isContrct = success;

}
function testConstructorView() public view returns(bool){
return isContrct;
}
}

contract C{

function create2(bytes memory code, uint256 salt) public returns(address){
address addr;
assembly {
addr := create2(0, add(code, 0x20), mload(code), salt)
if iszero(extcodesize(addr)) {
revert(0, 0)
}
}
return addr;
}

function create(bytes memory code) public returns(address){
address addr;
assembly {
addr := create(0, add(code, 0x20), mload(code))
if iszero(extcodesize(addr)) {
revert(0, 0)
}
}
return addr;
}
}