From 6449b7a18b7f4726668e56a5180e9564865479fa Mon Sep 17 00:00:00 2001 From: JimmyShi22 <417711026@qq.com> Date: Thu, 21 Mar 2024 22:03:56 +0800 Subject: [PATCH 1/5] not the same exit 1 --- .../java/org/fisco/bcos/sdk/demo/perf/DMCTransferDag.java | 1 + .../java/org/fisco/bcos/sdk/demo/perf/DMCTransferMyself.java | 1 + .../java/org/fisco/bcos/sdk/demo/perf/DMCTransferRing.java | 1 + .../java/org/fisco/bcos/sdk/demo/perf/DMCTransferStar.java | 4 ++-- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferDag.java b/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferDag.java index 4b5c7f2..60793e1 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferDag.java +++ b/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferDag.java @@ -280,6 +280,7 @@ public void run() { + total.toString() + ", expectBalance is " + expectBalance.toString()); + System.exit(1); } System.out.println("check finished, total balance equal expectBalance!"); } diff --git a/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferMyself.java b/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferMyself.java index 1fa560c..16d61b8 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferMyself.java +++ b/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferMyself.java @@ -276,6 +276,7 @@ public void run() { + total.intValue() + ", expectBalance is " + expectBalance.intValue()); + System.exit(1); } System.out.println("check finished! check finished, total balance equal expectBalance! "); } diff --git a/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferRing.java b/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferRing.java index 82e9546..c19bc37 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferRing.java +++ b/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferRing.java @@ -372,6 +372,7 @@ public void run() { + total.toString() + ", expectBalance is " + expectBalance); + System.exit(1); } System.out.println( "check finished, total balance equal expectBalance! " + total.intValue()); diff --git a/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferStar.java b/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferStar.java index 536895c..a54d1ec 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferStar.java +++ b/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferStar.java @@ -289,8 +289,8 @@ public void run() { + total.intValue() + ", expectBalance is " + expectBalance.intValue()); - } else { - System.out.println("check finished, total balance equal expectBalance !"); + System.exit(1); } + System.out.println("check finished, total balance equal expectBalance !"); } } From 72a03ae8781e16313b5e8b4735eb2bef77e7b015 Mon Sep 17 00:00:00 2001 From: jimmyshi <417711026@qq.com> Date: Thu, 9 May 2024 15:51:10 +0800 Subject: [PATCH 2/5] Support to check: bugfix_staticcall_noaddr_return & bugfix_support_transfer_receive_fallback (#222) --- .../demo/contract/sol/BalanceReceiveTest.sol | 163 ++++++++++++++++++ .../sdk/demo/contract/sol/BalanceTest.sol | 21 ++- .../sdk/demo/contract/sol/ContractTestAll.sol | 14 +- .../bcos/sdk/demo/contract/sol/StaticCall.sol | 1 + 4 files changed, 188 insertions(+), 11 deletions(-) create mode 100644 src/main/java/org/fisco/bcos/sdk/demo/contract/sol/BalanceReceiveTest.sol diff --git a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/BalanceReceiveTest.sol b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/BalanceReceiveTest.sol new file mode 100644 index 0000000..7c54281 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/BalanceReceiveTest.sol @@ -0,0 +1,163 @@ +pragma solidity ^0.6.0; +pragma experimental ABIEncoderV2; + +contract ReceiveAndCallbackFunction { + event Info(string, uint256); + // receive function + receive() external payable { + require(msg.value > 10, "receive() msg.value is zero"); + emit Info("receive() msg.value", msg.value); + } + + // fallback function + fallback() external payable { + require(msg.value > 0, "fallback() msg.value is zero"); + emit Info("fallback() msg.value", msg.value); + } +} + +contract OnlyReceiveFunction { + event Info(string, uint256); + // receive function + receive() external payable { + require(msg.value > 10, "receive() msg.value is zero"); + emit Info("receive() msg.value", msg.value); + } +} + +contract OnlyFallbackFunction { + + event Info(string, uint256); + + // fallback function + fallback() external payable { + require(msg.value > 0, "fallback() msg.value is zero"); + emit Info("fallback() msg.value", msg.value); + } +} + + +contract BalanceReceiveTest { + modifier mustHasBalance() { + require(address(this).balance > 0, "balance not enough"); + _; + } + + function callTransfer(address payable to, uint256 amount) public payable { + to.transfer(amount); + } + + function callFallback(address payable to, uint256 amount) public payable { + (bool success, bytes memory reason) = to.call{value: amount}("aaa()"); + require(success, string(abi.encodePacked("callFallback failed: ", reason))); + } + + function checkOnlyFallbackFunction() public payable { + uint256 callValue = 7; + + OnlyFallbackFunction contractAddress = new OnlyFallbackFunction(); + // must success + try this.callTransfer(address(contractAddress), callValue) { + } catch (bytes memory reason) { + require(false, string(abi.encodePacked("checkOnlyFallbackFunction callTransfer with value failed: ", reason))); + } + + require(address(contractAddress).balance == callValue, "checkReceive failed: balance not equal"); + + // must failed transfer 0 + try this.callTransfer(address(contractAddress), 0) { + require(false, "checkOnlyFallbackFunction callTransfer without value should revert"); + } catch { + } + + // must success on fallback value is not 0 + try this.callFallback(address(contractAddress), callValue) { + } catch (bytes memory reason) { + require(false, string(abi.encodePacked("checkOnlyFallbackFunction callFallback with value failed: ", reason))); + } + + require(address(contractAddress).balance == callValue * 2, "checkReceive failed: balance not equal"); + + // must failed on fallback value is 0 + try this.callFallback(address(contractAddress), 0) { + require(false, "checkOnlyFallbackFunction callFallback without value should revert"); + } catch { + } + } + + function checkOnlyReceiveFunction() public payable { + uint256 callValue = 17; + + OnlyReceiveFunction contractAddress = new OnlyReceiveFunction(); + // must success + try this.callTransfer(address(contractAddress), callValue) { + } catch (bytes memory reason) { + require(false, string(abi.encodePacked("checkOnlyReceiveFunction callTransfer with value failed: ", reason))); + } + + require(address(contractAddress).balance == callValue, "checkReceive failed: balance not equal"); + + // must failed transfer lesser than 10 + try this.callTransfer(address(contractAddress), 1) { + require(false, "checkOnlyReceiveFunction callTransfer without value should revert"); + } catch { + } + + // must failed on fallback value is over 10 + try this.callFallback(address(contractAddress), callValue) { + require(false, "checkOnlyReceiveFunction callFallback with value should revert"); + } catch { + } + + require(address(contractAddress).balance == callValue, "checkReceive failed: balance not equal"); + + // must failed on fallback value is lesser than 10 + try this.callFallback(address(contractAddress), 1) { + require(false, "checkOnlyReceiveFunction callFallback without value should revert"); + } catch { + } + } + + function checkReceiveAndFallbackFunction() public payable { + uint256 callValue = 17; + ReceiveAndCallbackFunction contractAddress = new ReceiveAndCallbackFunction(); + // must success + try this.callTransfer(address(contractAddress), callValue) { + } catch (bytes memory reason) { + require(false, string(abi.encodePacked("checkReceiveAndFallbackFunction callTransfer with value failed: ", reason))); + } + + require(address(contractAddress).balance == callValue, "checkReceive failed: balance not equal"); + + // must failed transfer 0 + try this.callTransfer(address(contractAddress), 1) { + require(false, "checkReceiveAndFallbackFunction callTransfer without value should revert"); + } catch { + } + require(address(contractAddress).balance == callValue, "checkReceive failed: balance not equal"); + + uint256 callValue2 = 5; + + // must success on fallback value is not 0 + try this.callFallback(address(contractAddress), callValue2) { + } catch (bytes memory reason) { + require(false, string(abi.encodePacked("checkReceiveAndFallbackFunction callFallback with value failed: ", reason))); + } + + require(address(contractAddress).balance == callValue + callValue2, "checkReceive failed: balance not equal"); + + // must failed on fallback value is 0 + try this.callFallback(address(contractAddress), 0) { + require(false, "checkReceiveAndFallbackFunction callFallback without value should revert"); + } catch { + } + + require(address(contractAddress).balance == callValue + callValue2, "checkReceive failed2: balance not equal"); + } + + function check() public payable mustHasBalance { + checkOnlyFallbackFunction(); + checkOnlyReceiveFunction(); + checkReceiveAndFallbackFunction(); + } +} \ No newline at end of file diff --git a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/BalanceTest.sol b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/BalanceTest.sol index 2684e73..207e585 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/BalanceTest.sol +++ b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/BalanceTest.sol @@ -91,7 +91,6 @@ contract BalanceTest { } } - return; // foreach errorAddresses for (uint256 i = 0; i < errorAddresses.length; i++) { address payable addr = errorAddresses[i]; @@ -115,6 +114,19 @@ contract BalanceTest { require(balanceBeforeSelf - balanceAfterSelf == 1, "self balance should be decreased by amount"); } + event Info2(string info, address addr, uint256 value); + function testTransferBalanceToOrigin() public mustHasBalance { + uint256 balanceBefore = getBalance(tx.origin); + uint256 balanceBeforeSelf = getSelfBalance(); + address payable origin = payable(tx.origin); + origin.transfer(1); + uint256 balanceAfter = getBalance(tx.origin); + uint256 balanceAfterSelf = getSelfBalance(); + require(balanceAfter - balanceBefore == 1, "balance should be increased by amount"); + require(balanceBeforeSelf - balanceAfterSelf == 1, "self balance should be decreased by amount"); + Info2("testTransferBalanceToOrigin", tx.origin, balanceAfter); + } + function testSelfdestruct() public payable { uint256 balanceBefore = getBalance(msg.sender); uint256 balanceBeforeSelf = getSelfBalance(); @@ -168,15 +180,14 @@ contract BalanceTest { testCallNotPayableWithValue(); testDeployWithValue(); testTransferBalance(); + testTransferBalanceToOrigin(); testBaseFee(); testGasPrice(); testMsgValue(); + testTransferBalanceToPrecompiled(); testSelfdestruct(); - - //testSelfdestructZeroAddress(); - //testDeployNotPayableWithValue() - //testTransferBalanceToPrecompiled(); + /* testTransferIndelegateCall check sender testTransferToPrecompiledIndelegateCall testTransferBalance(); diff --git a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/ContractTestAll.sol b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/ContractTestAll.sol index c807db6..d14dd1c 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/ContractTestAll.sol +++ b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/ContractTestAll.sol @@ -11,16 +11,14 @@ import "./ECRecoverTest.sol"; import "./DeployTreeTest.sol"; // DMC import "./BalanceTest.sol"; import "./BalancePrecompiledTest.sol"; +import "./BalanceReceiveTest.sol"; contract ContractTestAll { function checkOne(string memory name, address addr, bool needProxyCheck, uint256 callValue) private { - try ContractTestAll(addr).check{value: callValue}() { // just a little trick to call check() in the target contract - // success - } catch (bytes memory reason) { - revert(string(abi.encodePacked(name, " check failed: ", reason))); - } + (bool success, bytes memory reason) = address(addr).call{value: callValue}(abi.encodeWithSignature("check()")); + require(success, string(abi.encodePacked(name, " check failed: ", reason))); if (!needProxyCheck) { return; @@ -28,7 +26,7 @@ contract ContractTestAll { // use proxy to call check() Proxy proxy = new ProxyImpl(addr); - (bool success, bytes memory reason) = address(proxy).call{value: callValue}(abi.encodeWithSignature("check()")); + (success, reason) = address(proxy).call{value: callValue}(abi.encodeWithSignature("check()")); require(success, string(abi.encodePacked(name, " proxy check failed: ", reason))); } @@ -49,5 +47,9 @@ contract ContractTestAll { checkOne("DeployTreeTest", address(new DeployTreeTest()), true, 0); // DMC checkOne("BalanceTest", address(new BalanceTest()), true, callValue); checkOne("BalancePrecompiledTest", address(new BalancePrecompiledTest()), false, 0); + checkOne("BalanceReceiveTest", address(new BalanceReceiveTest()), true, callValue); } + + // fallback + fallback() external payable {} } diff --git a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol index 7e43736..6df61c6 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol +++ b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol @@ -82,6 +82,7 @@ contract StaticCall { function testEmptyAddr() public { (bool ok, bytes memory result) = address(0x10016666666).staticcall(abi.encodeWithSignature("get()")); require(ok, "addr not exist but must return ok to be the same as eth"); + require(result.length == 0, "result must be empty"); } function check() public initIfNot { From 7abb1a1e343a7368519efa3f0c56334049eee181 Mon Sep 17 00:00:00 2001 From: jimmyshi <417711026@qq.com> Date: Thu, 9 May 2024 17:39:38 +0800 Subject: [PATCH 3/5] check length (#223) --- .../java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol index 6df61c6..7a59c81 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol +++ b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol @@ -91,6 +91,7 @@ contract StaticCall { (ok, result) = address(helloWorld).staticcall(abi.encodeWithSignature("set(string)", "aaa")); require(!ok, "staticcall a state write function must return not ok"); + require(result.length == 0, string(abi.encodePacked("staticcall failed for has result: ", result))); testEmptyAddr(); From b1748f6daeb284fc600b411a2e99dea9ca8d4899 Mon Sep 17 00:00:00 2001 From: jimmyshi <417711026@qq.com> Date: Fri, 10 May 2024 10:49:54 +0800 Subject: [PATCH 4/5] (test contract): Fix staticcall check solidity & sync code from main (#224) * (build): update java sdk to 3.7.0. (#217) * rm unnecessary code (#218) * sync code from main and rm staticcall test (#221) * not the same exit 1 * omit staticcall * fix staticcall check solidity * comment update --------- Co-authored-by: Kyon <32325790+kyonRay@users.noreply.github.com> --- build.gradle | 8 +- .../bcos/sdk/demo/contract/DmcTransfer.java | 315 +++++++++++------- .../sdk/demo/contract/sol/ContractTestAll.sol | 22 +- .../sol/RecursiveDelegateCallTest.sol | 2 +- .../bcos/sdk/demo/contract/sol/StaticCall.sol | 38 ++- .../bcos/sdk/demo/perf/DMCTransferStar.java | 5 +- 6 files changed, 241 insertions(+), 149 deletions(-) diff --git a/build.gradle b/build.gradle index c082e4e..58da8e9 100644 --- a/build.gradle +++ b/build.gradle @@ -11,14 +11,14 @@ println("Notice: current gradle version is " + gradle.gradleVersion) // Additional attribute definition ext { // jackson version - javaSDKVersion="3.6.0" + javaSDKVersion="3.7.0-SNAPSHOT" //solcJVersion = "0.4.25.1" //solcJVersion = "0.5.2.1" //solcJVersion = "0.6.10.1" solcJVersion = "0.8.11.1" guavaVersion = "32.0.1-jre" commonsCollections4Version = "4.4" - springVersion = '5.3.30' + springVersion = '5.3.32' } tasks.withType(JavaCompile) { @@ -81,7 +81,7 @@ List spring = [ "org.springframework:spring-tx:$springVersion", ] -def log4j_version= '2.19.0' +def log4j_version= '2.22.1' List logger = [ "org.apache.logging.log4j:log4j-api:$log4j_version", "org.apache.logging.log4j:log4j-core:$log4j_version", @@ -104,7 +104,7 @@ dependencies { force true } api ("org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:${javaSDKVersion}") - api('org.fisco-bcos.code-generator:bcos-code-generator:1.2.0') { + api('org.fisco-bcos.code-generator:bcos-code-generator:1.4.0') { exclude group : "org.fisco-bcos.java-sdk" exclude group : "org.slf4j" exclude group : " com.fasterxml.jackson.core" diff --git a/src/main/java/org/fisco/bcos/sdk/demo/contract/DmcTransfer.java b/src/main/java/org/fisco/bcos/sdk/demo/contract/DmcTransfer.java index 95f69d5..7fdc5d4 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/contract/DmcTransfer.java +++ b/src/main/java/org/fisco/bcos/sdk/demo/contract/DmcTransfer.java @@ -24,15 +24,23 @@ @SuppressWarnings("unchecked") public class DmcTransfer extends Contract { - public static final String[] BINARY_ARRAY = {"608060405234801561001057600080fd5b506106d2806100206000396000f3fe608060405234801561001057600080fd5b50600436106100565760003560e01c8062a8efc71461005b5780635e6eacaa14610070578063a6c2f8d614610083578063b69ef8a814610096578063d91921ed146100ab575b600080fd5b61006e610069366004610421565b6100be565b005b61006e61007e36600461043a565b6100d1565b61006e6100913660046104a1565b610287565b60015460405190815260200160405180910390f35b61006e6100b9366004610421565b6102b3565b6001546100cb90826102c0565b60015550565b816100db8161058f565b9250506100e860016102b3565b816100f1575050565b336000818152602081815260408083208054825181850281018501909352808352919290919083018282801561015057602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610132575b50505050509050600081518561016691906105a6565b9050600082518261017791906105c8565b61018190876105e7565b905061018c816102b3565b60015460005b845181101561027b5760008582815181106101af576101af6105fe565b6020908102919091010151604051632f37565560e11b815260048101879052891515602482015290915081906001600160a01b03821690635e6eacaa90604401600060405180830381600087803b15801561020957600080fd5b505af192505050801561021a575060015b61025157881561022957600080fd5b6102338685610614565b93506001600160a01b03821630141561024c5760018490555b610268565b6001600160a01b0382163014156102685760015493505b5050806102749061062c565b9050610192565b50600155505050505050565b6001600160a01b03821660009081526020818152604090912082516102ae928401906103a7565b505050565b6001546100cb9082610309565b600061030283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061036d565b9392505050565b6000806103168385610614565b9050838110156103025760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064015b60405180910390fd5b600081848411156103915760405162461bcd60e51b81526004016103649190610647565b50600061039e84866105e7565b95945050505050565b8280548282559060005260206000209081019282156103fc579160200282015b828111156103fc57825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906103c7565b5061040892915061040c565b5090565b5b80821115610408576000815560010161040d565b60006020828403121561043357600080fd5b5035919050565b6000806040838503121561044d57600080fd5b823591506020830135801515811461046457600080fd5b809150509250929050565b80356001600160a01b038116811461048657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600080604083850312156104b457600080fd5b6104bd8361046f565b915060208084013567ffffffffffffffff808211156104db57600080fd5b818601915086601f8301126104ef57600080fd5b8135818111156105015761050161048b565b8060051b604051601f19603f830116810181811085821117156105265761052661048b565b60405291825284820192508381018501918983111561054457600080fd5b938501935b828510156105695761055a8561046f565b84529385019392850192610549565b8096505050505050509250929050565b634e487b7160e01b600052601160045260246000fd5b60008161059e5761059e610579565b506000190190565b6000826105c357634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156105e2576105e2610579565b500290565b6000828210156105f9576105f9610579565b500390565b634e487b7160e01b600052603260045260246000fd5b6000821982111561062757610627610579565b500190565b600060001982141561064057610640610579565b5060010190565b600060208083528351808285015260005b8181101561067457858101830151858201604001528201610658565b81811115610686576000604083870101525b50601f01601f191692909201604001939250505056fea2646970667358221220a6ed16977372430ce4c6f37746399b0289ad8d2136f625c694fe2868b65257d864736f6c634300080b0033"}; + public static final String[] BINARY_ARRAY = { + "608060405234801561001057600080fd5b506106d2806100206000396000f3fe608060405234801561001057600080fd5b50600436106100565760003560e01c8062a8efc71461005b5780635e6eacaa14610070578063a6c2f8d614610083578063b69ef8a814610096578063d91921ed146100ab575b600080fd5b61006e610069366004610421565b6100be565b005b61006e61007e36600461043a565b6100d1565b61006e6100913660046104a1565b610287565b60015460405190815260200160405180910390f35b61006e6100b9366004610421565b6102b3565b6001546100cb90826102c0565b60015550565b816100db8161058f565b9250506100e860016102b3565b816100f1575050565b336000818152602081815260408083208054825181850281018501909352808352919290919083018282801561015057602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610132575b50505050509050600081518561016691906105a6565b9050600082518261017791906105c8565b61018190876105e7565b905061018c816102b3565b60015460005b845181101561027b5760008582815181106101af576101af6105fe565b6020908102919091010151604051632f37565560e11b815260048101879052891515602482015290915081906001600160a01b03821690635e6eacaa90604401600060405180830381600087803b15801561020957600080fd5b505af192505050801561021a575060015b61025157881561022957600080fd5b6102338685610614565b93506001600160a01b03821630141561024c5760018490555b610268565b6001600160a01b0382163014156102685760015493505b5050806102749061062c565b9050610192565b50600155505050505050565b6001600160a01b03821660009081526020818152604090912082516102ae928401906103a7565b505050565b6001546100cb9082610309565b600061030283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061036d565b9392505050565b6000806103168385610614565b9050838110156103025760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064015b60405180910390fd5b600081848411156103915760405162461bcd60e51b81526004016103649190610647565b50600061039e84866105e7565b95945050505050565b8280548282559060005260206000209081019282156103fc579160200282015b828111156103fc57825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906103c7565b5061040892915061040c565b5090565b5b80821115610408576000815560010161040d565b60006020828403121561043357600080fd5b5035919050565b6000806040838503121561044d57600080fd5b823591506020830135801515811461046457600080fd5b809150509250929050565b80356001600160a01b038116811461048657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600080604083850312156104b457600080fd5b6104bd8361046f565b915060208084013567ffffffffffffffff808211156104db57600080fd5b818601915086601f8301126104ef57600080fd5b8135818111156105015761050161048b565b8060051b604051601f19603f830116810181811085821117156105265761052661048b565b60405291825284820192508381018501918983111561054457600080fd5b938501935b828510156105695761055a8561046f565b84529385019392850192610549565b8096505050505050509250929050565b634e487b7160e01b600052601160045260246000fd5b60008161059e5761059e610579565b506000190190565b6000826105c357634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156105e2576105e2610579565b500290565b6000828210156105f9576105f9610579565b500390565b634e487b7160e01b600052603260045260246000fd5b6000821982111561062757610627610579565b500190565b600060001982141561064057610640610579565b5060010190565b600060208083528351808285015260005b8181101561067457858101830151858201604001528201610658565b81811115610686576000604083870101525b50601f01601f191692909201604001939250505056fea2646970667358221220a6ed16977372430ce4c6f37746399b0289ad8d2136f625c694fe2868b65257d864736f6c634300080b0033" + }; - public static final String BINARY = org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", BINARY_ARRAY); + public static final String BINARY = + org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", BINARY_ARRAY); - public static final String[] SM_BINARY_ARRAY = {"608060405234801561001057600080fd5b506106d0806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80631270f54c1461005c5780633c2e91ce146100715780638193b44d14610084578063e8a6467114610099578063ef996b45146100ac575b600080fd5b61006f61006a36600461041f565b6100bf565b005b61006f61007f36600461041f565b6100d2565b60015460405190815260200160405180910390f35b61006f6100a7366004610438565b6100df565b61006f6100ba36600461049f565b610295565b6001546100cc90826102c1565b60015550565b6001546100cc908261032d565b816100e98161058d565b9250506100f660016100bf565b816100ff575050565b336000818152602081815260408083208054825181850281018501909352808352919290919083018282801561015e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610140575b50505050509050600081518561017491906105a4565b9050600082518261018591906105c6565b61018f90876105e5565b905061019a816100bf565b60015460005b84518110156102895760008582815181106101bd576101bd6105fc565b602090810291909101015160405163e8a6467160e01b815260048101879052891515602482015290915081906001600160a01b0382169063e8a6467190604401600060405180830381600087803b15801561021757600080fd5b505af1925050508015610228575060015b61025f57881561023757600080fd5b6102418685610612565b93506001600160a01b03821630141561025a5760018490555b610276565b6001600160a01b0382163014156102765760015493505b5050806102829061062a565b90506101a0565b50600155505050505050565b6001600160a01b03821660009081526020818152604090912082516102bc928401906103a5565b505050565b6000806102ce8385610612565b90508381101561032657604051636381e58960e11b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064015b60405180910390fd5b9392505050565b600061032683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506000818484111561038f57604051636381e58960e11b815260040161031d9190610645565b50600061039c84866105e5565b95945050505050565b8280548282559060005260206000209081019282156103fa579160200282015b828111156103fa57825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906103c5565b5061040692915061040a565b5090565b5b80821115610406576000815560010161040b565b60006020828403121561043157600080fd5b5035919050565b6000806040838503121561044b57600080fd5b823591506020830135801515811461046257600080fd5b809150509250929050565b80356001600160a01b038116811461048457600080fd5b919050565b63b95aa35560e01b600052604160045260246000fd5b600080604083850312156104b257600080fd5b6104bb8361046d565b915060208084013567ffffffffffffffff808211156104d957600080fd5b818601915086601f8301126104ed57600080fd5b8135818111156104ff576104ff610489565b8060051b604051601f19603f8301168101818110858211171561052457610524610489565b60405291825284820192508381018501918983111561054257600080fd5b938501935b82851015610567576105588561046d565b84529385019392850192610547565b8096505050505050509250929050565b63b95aa35560e01b600052601160045260246000fd5b60008161059c5761059c610577565b506000190190565b6000826105c15763b95aa35560e01b600052601260045260246000fd5b500490565b60008160001904831182151516156105e0576105e0610577565b500290565b6000828210156105f7576105f7610577565b500390565b63b95aa35560e01b600052603260045260246000fd5b6000821982111561062557610625610577565b500190565b600060001982141561063e5761063e610577565b5060010190565b600060208083528351808285015260005b8181101561067257858101830151858201604001528201610656565b81811115610684576000604083870101525b50601f01601f191692909201604001939250505056fea26469706673582212207747ecb6921432258f311e36330e177c93fcba4f7054bc1e0c76be893548d5d664736f6c634300080b0033"}; + public static final String[] SM_BINARY_ARRAY = { + "608060405234801561001057600080fd5b506106d0806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80631270f54c1461005c5780633c2e91ce146100715780638193b44d14610084578063e8a6467114610099578063ef996b45146100ac575b600080fd5b61006f61006a36600461041f565b6100bf565b005b61006f61007f36600461041f565b6100d2565b60015460405190815260200160405180910390f35b61006f6100a7366004610438565b6100df565b61006f6100ba36600461049f565b610295565b6001546100cc90826102c1565b60015550565b6001546100cc908261032d565b816100e98161058d565b9250506100f660016100bf565b816100ff575050565b336000818152602081815260408083208054825181850281018501909352808352919290919083018282801561015e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610140575b50505050509050600081518561017491906105a4565b9050600082518261018591906105c6565b61018f90876105e5565b905061019a816100bf565b60015460005b84518110156102895760008582815181106101bd576101bd6105fc565b602090810291909101015160405163e8a6467160e01b815260048101879052891515602482015290915081906001600160a01b0382169063e8a6467190604401600060405180830381600087803b15801561021757600080fd5b505af1925050508015610228575060015b61025f57881561023757600080fd5b6102418685610612565b93506001600160a01b03821630141561025a5760018490555b610276565b6001600160a01b0382163014156102765760015493505b5050806102829061062a565b90506101a0565b50600155505050505050565b6001600160a01b03821660009081526020818152604090912082516102bc928401906103a5565b505050565b6000806102ce8385610612565b90508381101561032657604051636381e58960e11b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064015b60405180910390fd5b9392505050565b600061032683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506000818484111561038f57604051636381e58960e11b815260040161031d9190610645565b50600061039c84866105e5565b95945050505050565b8280548282559060005260206000209081019282156103fa579160200282015b828111156103fa57825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906103c5565b5061040692915061040a565b5090565b5b80821115610406576000815560010161040b565b60006020828403121561043157600080fd5b5035919050565b6000806040838503121561044b57600080fd5b823591506020830135801515811461046257600080fd5b809150509250929050565b80356001600160a01b038116811461048457600080fd5b919050565b63b95aa35560e01b600052604160045260246000fd5b600080604083850312156104b257600080fd5b6104bb8361046d565b915060208084013567ffffffffffffffff808211156104d957600080fd5b818601915086601f8301126104ed57600080fd5b8135818111156104ff576104ff610489565b8060051b604051601f19603f8301168101818110858211171561052457610524610489565b60405291825284820192508381018501918983111561054257600080fd5b938501935b82851015610567576105588561046d565b84529385019392850192610547565b8096505050505050509250929050565b63b95aa35560e01b600052601160045260246000fd5b60008161059c5761059c610577565b506000190190565b6000826105c15763b95aa35560e01b600052601260045260246000fd5b500490565b60008160001904831182151516156105e0576105e0610577565b500290565b6000828210156105f7576105f7610577565b500390565b63b95aa35560e01b600052603260045260246000fd5b6000821982111561062557610625610577565b500190565b600060001982141561063e5761063e610577565b5060010190565b600060208083528351808285015260005b8181101561067257858101830151858201604001528201610656565b81811115610684576000604083870101525b50601f01601f191692909201604001939250505056fea26469706673582212207747ecb6921432258f311e36330e177c93fcba4f7054bc1e0c76be893548d5d664736f6c634300080b0033" + }; - public static final String SM_BINARY = org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", SM_BINARY_ARRAY); + public static final String SM_BINARY = + org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", SM_BINARY_ARRAY); - public static final String[] ABI_ARRAY = {"[{\"conflictFields\":[{\"kind\":4,\"value\":[1]}],\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"}],\"name\":\"addBalance\",\"outputs\":[],\"selector\":[3642302957,309392716],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":0}],\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"to\",\"type\":\"address[]\"}],\"name\":\"addNextCall\",\"outputs\":[],\"selector\":[2797795542,4019809093],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":4,\"value\":[1]}],\"inputs\":[],\"name\":\"balance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"selector\":[3063871656,2173940813],\"stateMutability\":\"view\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":4,\"value\":[1]}],\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"}],\"name\":\"subBalance\",\"outputs\":[],\"selector\":[11071431,1009684942],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":0}],\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"allowRevert\",\"type\":\"bool\"}],\"name\":\"takeShare\",\"outputs\":[],\"selector\":[1584311466,3903211121],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"}; + public static final String[] ABI_ARRAY = { + "[{\"conflictFields\":[{\"kind\":4,\"value\":[1]}],\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"}],\"name\":\"addBalance\",\"outputs\":[],\"selector\":[3642302957,309392716],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":0}],\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"to\",\"type\":\"address[]\"}],\"name\":\"addNextCall\",\"outputs\":[],\"selector\":[2797795542,4019809093],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":4,\"value\":[1]}],\"inputs\":[],\"name\":\"balance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"selector\":[3063871656,2173940813],\"stateMutability\":\"view\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":4,\"value\":[1]}],\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"}],\"name\":\"subBalance\",\"outputs\":[],\"selector\":[11071431,1009684942],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"conflictFields\":[{\"kind\":0}],\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"allowRevert\",\"type\":\"bool\"}],\"name\":\"takeShare\",\"outputs\":[],\"selector\":[1584311466,3903211121],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" + }; public static final String ABI = org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", ABI_ARRAY); @@ -59,218 +67,269 @@ public static String getABI() { } public TransactionReceipt addBalance(BigInteger num) { - final Function function = new Function( - FUNC_ADDBALANCE, - Arrays.asList(new Uint256(num)), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_ADDBALANCE, + Arrays.asList(new Uint256(num)), + Collections.>emptyList(), + 0); return executeTransaction(function); } public Function getMethodAddBalanceRawFunction(BigInteger num) throws ContractException { - final Function function = new Function(FUNC_ADDBALANCE, - Arrays.asList(new Uint256(num)), - Arrays.>asList()); + final Function function = + new Function( + FUNC_ADDBALANCE, + Arrays.asList(new Uint256(num)), + Arrays.>asList()); return function; } public String getSignedTransactionForAddBalance(BigInteger num) { - final Function function = new Function( - FUNC_ADDBALANCE, - Arrays.asList(new Uint256(num)), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_ADDBALANCE, + Arrays.asList(new Uint256(num)), + Collections.>emptyList(), + 0); return createSignedTransaction(function); } public String addBalance(BigInteger num, TransactionCallback callback) { - final Function function = new Function( - FUNC_ADDBALANCE, - Arrays.asList(new Uint256(num)), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_ADDBALANCE, + Arrays.asList(new Uint256(num)), + Collections.>emptyList(), + 0); return asyncExecuteTransaction(function, callback); } public Tuple1 getAddBalanceInput(TransactionReceipt transactionReceipt) { String data = transactionReceipt.getInput().substring(10); - final Function function = new Function(FUNC_ADDBALANCE, - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); - List results = this.functionReturnDecoder.decode(data, function.getOutputParameters()); - return new Tuple1( - - (BigInteger) results.get(0).getValue() - ); + final Function function = + new Function( + FUNC_ADDBALANCE, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + List results = + this.functionReturnDecoder.decode(data, function.getOutputParameters()); + return new Tuple1((BigInteger) results.get(0).getValue()); } public TransactionReceipt addNextCall(String from, List to) { - final Function function = new Function( - FUNC_ADDNEXTCALL, - Arrays.asList(new Address(from), - new DynamicArray
( - Address.class, - org.fisco.bcos.sdk.v3.codec.Utils.typeMap(to, Address.class))), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_ADDNEXTCALL, + Arrays.asList( + new Address(from), + new DynamicArray
( + Address.class, + org.fisco.bcos.sdk.v3.codec.Utils.typeMap( + to, Address.class))), + Collections.>emptyList(), + 0); return executeTransaction(function); } - public Function getMethodAddNextCallRawFunction(String from, List to) throws - ContractException { - final Function function = new Function(FUNC_ADDNEXTCALL, - Arrays.asList(new Address(from), - new DynamicArray
( - Address.class, - org.fisco.bcos.sdk.v3.codec.Utils.typeMap(to, Address.class))), - Arrays.>asList()); + public Function getMethodAddNextCallRawFunction(String from, List to) + throws ContractException { + final Function function = + new Function( + FUNC_ADDNEXTCALL, + Arrays.asList( + new Address(from), + new DynamicArray
( + Address.class, + org.fisco.bcos.sdk.v3.codec.Utils.typeMap( + to, Address.class))), + Arrays.>asList()); return function; } public String getSignedTransactionForAddNextCall(String from, List to) { - final Function function = new Function( - FUNC_ADDNEXTCALL, - Arrays.asList(new Address(from), - new DynamicArray
( - Address.class, - org.fisco.bcos.sdk.v3.codec.Utils.typeMap(to, Address.class))), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_ADDNEXTCALL, + Arrays.asList( + new Address(from), + new DynamicArray
( + Address.class, + org.fisco.bcos.sdk.v3.codec.Utils.typeMap( + to, Address.class))), + Collections.>emptyList(), + 0); return createSignedTransaction(function); } public String addNextCall(String from, List to, TransactionCallback callback) { - final Function function = new Function( - FUNC_ADDNEXTCALL, - Arrays.asList(new Address(from), - new DynamicArray
( - Address.class, - org.fisco.bcos.sdk.v3.codec.Utils.typeMap(to, Address.class))), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_ADDNEXTCALL, + Arrays.asList( + new Address(from), + new DynamicArray
( + Address.class, + org.fisco.bcos.sdk.v3.codec.Utils.typeMap( + to, Address.class))), + Collections.>emptyList(), + 0); return asyncExecuteTransaction(function, callback); } public Tuple2> getAddNextCallInput(TransactionReceipt transactionReceipt) { String data = transactionReceipt.getInput().substring(10); - final Function function = new Function(FUNC_ADDNEXTCALL, - Arrays.asList(), - Arrays.>asList(new TypeReference
() {}, new TypeReference>() {})); - List results = this.functionReturnDecoder.decode(data, function.getOutputParameters()); + final Function function = + new Function( + FUNC_ADDNEXTCALL, + Arrays.asList(), + Arrays.>asList( + new TypeReference
() {}, + new TypeReference>() {})); + List results = + this.functionReturnDecoder.decode(data, function.getOutputParameters()); return new Tuple2>( - - (String) results.get(0).getValue(), - convertToNative((List
) results.get(1).getValue()) - ); + (String) results.get(0).getValue(), + convertToNative((List
) results.get(1).getValue())); } public BigInteger balance() throws ContractException { - final Function function = new Function(FUNC_BALANCE, - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); + final Function function = + new Function( + FUNC_BALANCE, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); return executeCallWithSingleValueReturn(function, BigInteger.class); } public Function getMethodBalanceRawFunction() throws ContractException { - final Function function = new Function(FUNC_BALANCE, - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); + final Function function = + new Function( + FUNC_BALANCE, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); return function; } public TransactionReceipt subBalance(BigInteger num) { - final Function function = new Function( - FUNC_SUBBALANCE, - Arrays.asList(new Uint256(num)), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_SUBBALANCE, + Arrays.asList(new Uint256(num)), + Collections.>emptyList(), + 0); return executeTransaction(function); } public Function getMethodSubBalanceRawFunction(BigInteger num) throws ContractException { - final Function function = new Function(FUNC_SUBBALANCE, - Arrays.asList(new Uint256(num)), - Arrays.>asList()); + final Function function = + new Function( + FUNC_SUBBALANCE, + Arrays.asList(new Uint256(num)), + Arrays.>asList()); return function; } public String getSignedTransactionForSubBalance(BigInteger num) { - final Function function = new Function( - FUNC_SUBBALANCE, - Arrays.asList(new Uint256(num)), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_SUBBALANCE, + Arrays.asList(new Uint256(num)), + Collections.>emptyList(), + 0); return createSignedTransaction(function); } public String subBalance(BigInteger num, TransactionCallback callback) { - final Function function = new Function( - FUNC_SUBBALANCE, - Arrays.asList(new Uint256(num)), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_SUBBALANCE, + Arrays.asList(new Uint256(num)), + Collections.>emptyList(), + 0); return asyncExecuteTransaction(function, callback); } public Tuple1 getSubBalanceInput(TransactionReceipt transactionReceipt) { String data = transactionReceipt.getInput().substring(10); - final Function function = new Function(FUNC_SUBBALANCE, - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); - List results = this.functionReturnDecoder.decode(data, function.getOutputParameters()); - return new Tuple1( - - (BigInteger) results.get(0).getValue() - ); + final Function function = + new Function( + FUNC_SUBBALANCE, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + List results = + this.functionReturnDecoder.decode(data, function.getOutputParameters()); + return new Tuple1((BigInteger) results.get(0).getValue()); } public TransactionReceipt takeShare(BigInteger num, Boolean allowRevert) { - final Function function = new Function( - FUNC_TAKESHARE, - Arrays.asList(new Uint256(num), - new Bool(allowRevert)), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_TAKESHARE, + Arrays.asList(new Uint256(num), new Bool(allowRevert)), + Collections.>emptyList(), + 0); return executeTransaction(function); } - public Function getMethodTakeShareRawFunction(BigInteger num, Boolean allowRevert) throws - ContractException { - final Function function = new Function(FUNC_TAKESHARE, - Arrays.asList(new Uint256(num), - new Bool(allowRevert)), - Arrays.>asList()); + public Function getMethodTakeShareRawFunction(BigInteger num, Boolean allowRevert) + throws ContractException { + final Function function = + new Function( + FUNC_TAKESHARE, + Arrays.asList(new Uint256(num), new Bool(allowRevert)), + Arrays.>asList()); return function; } public String getSignedTransactionForTakeShare(BigInteger num, Boolean allowRevert) { - final Function function = new Function( - FUNC_TAKESHARE, - Arrays.asList(new Uint256(num), - new Bool(allowRevert)), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_TAKESHARE, + Arrays.asList(new Uint256(num), new Bool(allowRevert)), + Collections.>emptyList(), + 0); return createSignedTransaction(function); } public String takeShare(BigInteger num, Boolean allowRevert, TransactionCallback callback) { - final Function function = new Function( - FUNC_TAKESHARE, - Arrays.asList(new Uint256(num), - new Bool(allowRevert)), - Collections.>emptyList(), 0); + final Function function = + new Function( + FUNC_TAKESHARE, + Arrays.asList(new Uint256(num), new Bool(allowRevert)), + Collections.>emptyList(), + 0); return asyncExecuteTransaction(function, callback); } public Tuple2 getTakeShareInput(TransactionReceipt transactionReceipt) { String data = transactionReceipt.getInput().substring(10); - final Function function = new Function(FUNC_TAKESHARE, - Arrays.asList(), - Arrays.>asList(new TypeReference() {}, new TypeReference() {})); - List results = this.functionReturnDecoder.decode(data, function.getOutputParameters()); + final Function function = + new Function( + FUNC_TAKESHARE, + Arrays.asList(), + Arrays.>asList( + new TypeReference() {}, new TypeReference() {})); + List results = + this.functionReturnDecoder.decode(data, function.getOutputParameters()); return new Tuple2( - - (BigInteger) results.get(0).getValue(), - (Boolean) results.get(1).getValue() - ); + (BigInteger) results.get(0).getValue(), (Boolean) results.get(1).getValue()); } - public static DmcTransfer load(String contractAddress, Client client, - CryptoKeyPair credential) { + public static DmcTransfer load( + String contractAddress, Client client, CryptoKeyPair credential) { return new DmcTransfer(contractAddress, client, credential); } - public static DmcTransfer deploy(Client client, CryptoKeyPair credential) throws - ContractException { - return deploy(DmcTransfer.class, client, credential, getBinary(client.getCryptoSuite()), getABI(), null, null); + public static DmcTransfer deploy(Client client, CryptoKeyPair credential) + throws ContractException { + return deploy( + DmcTransfer.class, + client, + credential, + getBinary(client.getCryptoSuite()), + getABI(), + null, + null); } } diff --git a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/ContractTestAll.sol b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/ContractTestAll.sol index d14dd1c..ffa9588 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/ContractTestAll.sol +++ b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/ContractTestAll.sol @@ -14,20 +14,23 @@ import "./BalancePrecompiledTest.sol"; import "./BalanceReceiveTest.sol"; contract ContractTestAll { + event Info(string, uint256, uint256); function checkOne(string memory name, address addr, bool needProxyCheck, uint256 callValue) private { - + uint256 gasBefore = gasleft(); (bool success, bytes memory reason) = address(addr).call{value: callValue}(abi.encodeWithSignature("check()")); require(success, string(abi.encodePacked(name, " check failed: ", reason))); - if (!needProxyCheck) { - return; - } + uint256 gasBeforeProxy = gasleft(); - // use proxy to call check() - Proxy proxy = new ProxyImpl(addr); - (success, reason) = address(proxy).call{value: callValue}(abi.encodeWithSignature("check()")); - require(success, string(abi.encodePacked(name, " proxy check failed: ", reason))); + if (needProxyCheck) { + // use proxy to call check() + Proxy proxy = new ProxyImpl(addr); + (success, reason) = address(proxy).call{value: callValue}(abi.encodeWithSignature("check()")); + require(success, string(abi.encodePacked(name, " proxy check failed: ", reason))); + } + uint256 gasAfter = gasleft(); + emit Info(string(abi.encodePacked(name, " gas used ")), gasBefore - gasBeforeProxy, gasBeforeProxy - gasAfter); } function check() public payable { @@ -41,13 +44,14 @@ contract ContractTestAll { checkOne("EventTest", address(new EventTest()), true, 0); checkOne("LibraryTest", address(new LibraryTest()), true, 0); checkOne("ProxyTest", address(new ProxyTest()), true, 0); - checkOne("StaticCall", address(new StaticCall()), true, 0); checkOne("TablePrecompiledTest", address(new TablePrecompiledTest()), true, 0); checkOne("ECRecoverTest", address(new ECRecoverTest()), true, 0); checkOne("DeployTreeTest", address(new DeployTreeTest()), true, 0); // DMC checkOne("BalanceTest", address(new BalanceTest()), true, callValue); checkOne("BalancePrecompiledTest", address(new BalancePrecompiledTest()), false, 0); checkOne("BalanceReceiveTest", address(new BalanceReceiveTest()), true, callValue); + + checkOne("StaticCall", address(new StaticCall()), false, 0); // must at last for gas will be used up by staticcall failed } // fallback diff --git a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/RecursiveDelegateCallTest.sol b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/RecursiveDelegateCallTest.sol index ada03f9..1b6482c 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/RecursiveDelegateCallTest.sol +++ b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/RecursiveDelegateCallTest.sol @@ -85,7 +85,7 @@ contract RecursiveNode { } function recursiveCheck(address[] memory contracts, uint i, Info memory info) public payable { - return; + if (i >= contracts.length) { return; } diff --git a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol index 7a59c81..88f34e6 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol +++ b/src/main/java/org/fisco/bcos/sdk/demo/contract/sol/StaticCall.sol @@ -1,5 +1,7 @@ pragma solidity >=0.6.0 <0.8.12; +import "./ProxyTest.sol"; + contract StaticCall { HelloWorld helloWorld = new HelloWorld(); event Result(bytes); @@ -85,21 +87,47 @@ contract StaticCall { require(result.length == 0, "result must be empty"); } - function check() public initIfNot { + function checkOk() public initIfNot { (bool ok, bytes memory result) = address(helloWorld).staticcall(abi.encodeWithSignature("get()")); require(ok); - (ok, result) = address(helloWorld).staticcall(abi.encodeWithSignature("set(string)", "aaa")); - require(!ok, "staticcall a state write function must return not ok"); - require(result.length == 0, string(abi.encodePacked("staticcall failed for has result: ", result))); + testASMOk(); + } + function checkFailed() public { testEmptyAddr(); - testASMOk(); + (bool ok, bytes memory result) = address(helloWorld).staticcall(abi.encodeWithSignature("set(string)", "aaa")); + require(!ok, "staticcall a state write function must return not ok"); + require(result.length == 0, string(abi.encodePacked("staticcall failed for has result: ", result))); + testASMFailed(); testASMUintFailed(); } + event Info(string, uint256); + function check() public { + uint256 gasBefore = gasleft(); + checkOk(); + uint256 gasAfter = gasleft(); + emit Info("gas used on checkOk(): ", gasBefore - gasAfter); + + Proxy proxy = new ProxyImpl(address(this)); + gasBefore = gasleft(); + (bool success, bytes memory reason) = address(proxy).call(abi.encodeWithSignature("checkOk()")); + gasAfter = gasleft(); + require(success, string(abi.encodePacked("checkOk() by proxy failed: ", reason))); + emit Info("gas used on checkOk() by proxy: ", gasBefore - gasAfter); + + // staticcall failed will cost half of the gas + // There are many staticcall failed in checkFailed(), will cost most of the gas. So we need to put it in the end. + gasBefore = gasleft(); + (success, reason) = address(proxy).call(abi.encodeWithSignature("checkFailed()")); + gasAfter = gasleft(); + require(success, string(abi.encodePacked("checkFailed() by proxy failed: ", reason))); + emit Info("gas used on checkFailed() by proxy: ", gasBefore - gasAfter); + } + function get() public view returns (string memory) { return helloWorld.get(); } diff --git a/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferStar.java b/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferStar.java index a54d1ec..750cca0 100644 --- a/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferStar.java +++ b/src/main/java/org/fisco/bcos/sdk/demo/perf/DMCTransferStar.java @@ -175,9 +175,10 @@ public void run() { myContractAddress.add(contractsAddr[index]); contracts[index].addNextCall(userAddress, myContractAddress); - contracts[index].addNextCall(contractsAddr[index], starCenterAddr); + contracts[index].addNextCall( + contractsAddr[index], starCenterAddr); - //contracts[index].addNextCall(userAddress, starCenterAddr); + // contracts[index].addNextCall(userAddress, starCenterAddr); callRelationshipLatch.countDown(); } }); From 588b887da90ae0a856e5983e46fefd3bf11182ca Mon Sep 17 00:00:00 2001 From: kyonRay Date: Tue, 2 Jul 2024 17:15:28 +0800 Subject: [PATCH 5/5] (build): use 3.7.0 sdk. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 58da8e9..5a8c585 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ println("Notice: current gradle version is " + gradle.gradleVersion) // Additional attribute definition ext { // jackson version - javaSDKVersion="3.7.0-SNAPSHOT" + javaSDKVersion="3.7.0" //solcJVersion = "0.4.25.1" //solcJVersion = "0.5.2.1" //solcJVersion = "0.6.10.1"