diff --git a/.github/ISSUE_TEMPLATE/report-a-bug.md b/.github/ISSUE_TEMPLATE/report-a-bug.md index cfadd364c21..a0d68121565 100644 --- a/.github/ISSUE_TEMPLATE/report-a-bug.md +++ b/.github/ISSUE_TEMPLATE/report-a-bug.md @@ -7,20 +7,39 @@ assignees: '' --- -#### System information - -java-tron version: `java -jar FullNode.jar -v` -OS & Version: Windows/Linux/OSX -Commit hash : (if `develop`) + + + + +#### Software Versions + + + #### Expected behaviour + #### Actual behaviour + + +#### Frequency + #### Steps to reproduce the behaviour +1. [Step 1] +2. [Step 2] +3. [Step ...] #### Backtrace diff --git a/.github/ISSUE_TEMPLATE/request-a-feature.md b/.github/ISSUE_TEMPLATE/request-a-feature.md index 5099a72008b..261f1088ded 100644 --- a/.github/ISSUE_TEMPLATE/request-a-feature.md +++ b/.github/ISSUE_TEMPLATE/request-a-feature.md @@ -6,13 +6,23 @@ labels: 'type:feature' assignees: '' --- +# Background # Rationale Why should this feature exist? + What are the use-cases? +# Specification + +# Test Specification + +# Scope Of Impact + + # Implementation Do you have ideas regarding the implementation of this feature? + Are you willing to implement this feature? diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4ab98d5cf3c..5a0f120e116 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -33,7 +33,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -46,7 +46,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -59,6 +59,6 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/math-check.yml b/.github/workflows/math-check.yml new file mode 100644 index 00000000000..0f0255815d5 --- /dev/null +++ b/.github/workflows/math-check.yml @@ -0,0 +1,93 @@ +name: Check Math Usage + +on: + push: + branches: [ 'master', 'release_**' ] + pull_request: + branches: [ 'develop', 'release_**' ] + workflow_dispatch: + +jobs: + check-math: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Check for java.lang.Math usage + id: check-math + shell: bash + run: | + echo "Checking for java.lang.Math usage..." + + touch math_usage.txt + + while IFS= read -r file; do + filename=$(basename "$file") + if [[ "$filename" == "StrictMathWrapper.java" || "$filename" == "MathWrapper.java" ]]; then + continue + fi + + perl -0777 -ne ' + s/"([^"\\]|\\.)*"//g; + s/'\''([^'\''\\]|\\.)*'\''//g; + s!/\*([^*]|\*[^/])*\*/!!g; + s!//[^\n]*!!g; + $hasMath = 0; + $hasMath = 1 if /^[\s]*import[\s]+java\.lang\.Math\b/m; + $hasMath = 1 if /\bjava\s*\.\s*lang\s*\.\s*Math\s*\./; + $hasMath = 1 if /(?> math_usage.txt + done < <(find . -type f -name "*.java") + + sort -u math_usage.txt -o math_usage.txt + + if [ -s math_usage.txt ]; then + echo "❌ Error: Forbidden Math usage found in the following files:" + cat math_usage.txt + echo "math_found=true" >> $GITHUB_OUTPUT + echo "Please use org.tron.common.math.StrictMathWrapper instead of direct Math usage." + else + echo "✅ No forbidden Math usage found" + echo "math_found=false" >> $GITHUB_OUTPUT + fi + + - name: Upload findings + if: steps.check-math.outputs.math_found == 'true' + uses: actions/upload-artifact@v4 + with: + name: math-usage-report + path: math_usage.txt + + - name: Create comment + if: github.event_name == 'pull_request' && steps.check-math.outputs.math_found == 'true' + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + const findings = fs.readFileSync('math_usage.txt', 'utf8'); + const body = `### ❌ Math Usage Detection Results + + Found forbidden usage of \`java.lang.Math\` in the following files: + + \`\`\` + ${findings} + \`\`\` + + **Please review if this usage is intended.** + > [!CAUTION] + > Note: You should use \`org.tron.common.math.StrictMathWrapper\`. + > If you need to use \`java.lang.Math\`, please provide a justification. + `; + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: body + }); + + - name: Fail if Math usage found + if: steps.check-math.outputs.math_found == 'true' + run: exit 1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d8dc83ad51b..79bf8567a61 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -151,7 +151,7 @@ Please make sure your submission meets the following code style: ### Commit Messages -Commit messages should follow the rule below, we provide a template corresponding instructions. +Commit messages should follow the rule below, we provide a template with corresponding instructions. Template: ``` @@ -182,7 +182,7 @@ The subject contains a succinct description of the change: 4. Do not end the subject line with a period. 5. Avoid meaningless commits. It is recommended to use the git rebase command. -Message body use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior. +Message body uses the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior. Here is an example: ``` @@ -217,7 +217,7 @@ If the purpose of this submission is to modify one issue, you need to refer to t ### Special Situations And How To Deal With Them -As a reviewer, you may find yourself in one of the sitations below. Here’s how to deal with those: +As a reviewer, you may find yourself in one of the situations below. Here’s how to deal with those: The author doesn’t follow up: ping them after a while (i.e. after a few days). If there is no further response, close the PR or complete the work yourself. diff --git a/README.md b/README.md index 4d1d7b0b3b6..0d0eeb6ef71 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ Java implementation of the Tron Protocol -

@@ -42,8 +41,9 @@

## Table of Contents + - [What’s TRON?](#whats-tron) -- [Building the Source Code](#building-the-source) +- [Building the Source Code](#building-the-source-code) - [Running java-tron](#running-java-tron) - [Community](#community) - [Contribution](#contribution) @@ -51,98 +51,113 @@ - [Integrity Check](#integrity-check) - [License](#license) -## What's TRON? +# What's TRON? TRON is a project dedicated to building the infrastructure for a truly decentralized Internet. -* Tron Protocol, one of the largest blockchain-based operating systems in the world, offers scalable, high-availability and high-throughput support that underlies all the decentralized applications in the TRON ecosystem. +- Tron Protocol, one of the largest blockchain-based operating systems in the world, offers scalable, high-availability and high-throughput support that underlies all the decentralized applications in the TRON ecosystem. -* Tron Virtual Machine (TVM) allows anyone to develop decentralized applications (DAPPs) for themselves or their communities with smart contracts thereby making decentralized crowdfunding and token issuance easier than ever. +- Tron Virtual Machine (TVM) allows anyone to develop decentralized applications (DAPPs) for themselves or their communities with smart contracts thereby making decentralized crowdfunding and token issuance easier than ever. TRON enables large-scale development and engagement. With over 2000 transactions per second (TPS), high concurrency, low latency, and massive data transmission. It is ideal for building decentralized entertainment applications. Free features and incentive systems allow developers to create premium app experiences for users. -# Building the source -Building java-tron requires `git` and 64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet. Make sure you operate on `Linux` and `MacOS` operating systems. +# Building the Source Code + +Building java-tron requires `git` package and 64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet. Make sure you operate on `Linux` and `MacOS` operating systems. Clone the repo and switch to the `master` branch - ```bash - $ git clone https://github.com/tronprotocol/java-tron.git - $ cd java-tron - $ git checkout -t origin/master - ``` -then run the following command to build java-tron, the `FullNode.jar` file can be found in `java-tron/build/libs/` after build successful. ```bash -$ ./gradlew clean build -x test +$ git clone https://github.com/tronprotocol/java-tron.git +$ cd java-tron +$ git checkout -t origin/master ``` +then run the following command to build java-tron, the `FullNode.jar` file can be found in `java-tron/build/libs/` after build successfully. + +```bash +$ ./gradlew clean build -x test +``` # Running java-tron + Running java-tron requires 64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet. Make sure you operate on `Linux` and `MacOS` operating systems. -Get the mainnet configuration file: [main_net_config.conf](https://github.com/tronprotocol/tron-deployment/blob/master/main_net_config.conf), other network configuration files can be find [here](https://github.com/tronprotocol/tron-deployment). +Get the mainnet configuration file: [main_net_config.conf](https://github.com/tronprotocol/tron-deployment/blob/master/main_net_config.conf), other network configuration files can be found [here](https://github.com/tronprotocol/tron-deployment). + ## Hardware Requirements + Minimum: -* CPU with 8 cores -* 16GB RAM -* 2TB free storage space to sync the Mainnet + +- CPU with 8 cores +- 16GB RAM +- 3TB free storage space to sync the Mainnet Recommended: -* CPU with 16+ cores(32+ cores for a super representative) -* 32GB+ RAM(64GB+ for a super representative) -* High Performance SSD with at least 2.5TB free space -* 100+ MB/s download Internet service +- CPU with 16+ cores(32+ cores for a super representative) +- 32GB+ RAM(64GB+ for a super representative) +- High Performance SSD with at least 4TB free space +- 100+ MB/s download Internet service ## Running a full node for mainnet -Full node has full historical data, it is the entry point into the TRON network , it can be used by other processes as a gateway into the TRON network via HTTP and GRPC endpoints. You can interact with the TRON network through full node:transfer assets, deploy contracts, interact with contracts and so on. `-c ` parameter specifies a configuration file to run a full node: - ```bash - $ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \ - -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \ - -XX:MaxDirectMemorySize=1G -XX:+PrintGCDetails \ - -XX:+PrintGCDateStamps -Xloggc:gc.log \ - -XX:+UseConcMarkSweepGC -XX:NewRatio=2 \ - -XX:+CMSScavengeBeforeRemark -XX:+ParallelRefProcEnabled \ - -XX:+HeapDumpOnOutOfMemoryError \ - -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \ - -jar FullNode.jar -c main_net_config.conf >> start.log 2>&1 & - ``` + +Full node has full historical data, it is the entry point into the TRON network, it can be used by other processes as a gateway into the TRON network via HTTP and GRPC endpoints. You can interact with the TRON network through full node:transfer assets, deploy contracts, interact with contracts and so on. `-c` parameter specifies a configuration file to run a full node: + +```bash +$ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \ + -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \ + -XX:MaxDirectMemorySize=1G -XX:+PrintGCDetails \ + -XX:+PrintGCDateStamps -Xloggc:gc.log \ + -XX:+UseConcMarkSweepGC -XX:NewRatio=2 \ + -XX:+CMSScavengeBeforeRemark -XX:+ParallelRefProcEnabled \ + -XX:+HeapDumpOnOutOfMemoryError \ + -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \ + -jar FullNode.jar -c main_net_config.conf >> start.log 2>&1 & +``` + ## Running a super representative node for mainnet -Adding the `--witness` parameter to the startup command, full node will run as a super representative node. The super representative node supports all the functions of the full node and also supports block production. Before running, make sure you have a super representative account and get votes from others,once the number of obtained votes ranks in the top 27, your super representative node will participate in block production. -Fill in the private key of super representative address into the `localwitness` list in the `main_net_config.conf`, here is an example: - ``` - localwitness = [ - 650950B193DDDDB35B6E48912DD28F7AB0E7140C1BFDEFD493348F02295BD812 - ] - ``` +Adding the `--witness` parameter to the startup command, full node will run as a super representative node. The super representative node supports all the functions of the full node and also supports block production. Before running, make sure you have a super representative account and get votes from others. Once the number of obtained votes ranks in the top 27, your super representative node will participate in block production. + +Fill in the private key of a super representative address into the `localwitness` list in the `main_net_config.conf`. Here is an example: + +``` + localwitness = [ + + ] +``` then run the following command to start the node: - ```bash - $ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \ - -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \ - -XX:MaxDirectMemorySize=1G -XX:+PrintGCDetails \ - -XX:+PrintGCDateStamps -Xloggc:gc.log \ - -XX:+UseConcMarkSweepGC -XX:NewRatio=2 \ - -XX:+CMSScavengeBeforeRemark -XX:+ParallelRefProcEnabled \ - -XX:+HeapDumpOnOutOfMemoryError \ - -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \ - -jar FullNode.jar --witness -c main_net_config.conf >> start.log 2>&1 & - ``` + +```bash +$ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \ + -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \ + -XX:MaxDirectMemorySize=1G -XX:+PrintGCDetails \ + -XX:+PrintGCDateStamps -Xloggc:gc.log \ + -XX:+UseConcMarkSweepGC -XX:NewRatio=2 \ + -XX:+CMSScavengeBeforeRemark -XX:+ParallelRefProcEnabled \ + -XX:+HeapDumpOnOutOfMemoryError \ + -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \ + -jar FullNode.jar --witness -c main_net_config.conf >> start.log 2>&1 & +``` ## Quick Start Tool -An easier way to build and run java-tron is to use `start.sh`, `start.sh` is a quick start script written in shell language, you can use it to build and run java-tron quickly and easily. + +An easier way to build and run java-tron is to use `start.sh`. `start.sh` is a quick start script written in the Shell language. You can use it to build and run java-tron quickly and easily. Here are some common use cases of the scripting tool -* Use `start.sh` to start a full node with the downloaded `FullNode.jar` -* Use `start.sh` to download the latest `FullNode.jar` and start a full node. -* Use `start.sh` to download the latest source code and compile a `FullNode.jar` and then start a full node. + +- Use `start.sh` to start a full node with the downloaded `FullNode.jar` +- Use `start.sh` to download the latest `FullNode.jar` and start a full node. +- Use `start.sh` to download the latest source code and compile a `FullNode.jar` and then start a full node. For more details, please refer to the tool [guide](./shell.md). ## Run inside Docker container One of the quickest ways to get `java-tron` up and running on your machine is by using Docker: + ```shell $ docker run -d --name="java-tron" \ -v /your_path/output-directory:/java-tron/output-directory \ @@ -155,6 +170,7 @@ $ docker run -d --name="java-tron" \ This will mount the `output-directory` and `logs` directories on the host, the docker.sh tool can also be used to simplify the use of docker, see more [here](docker/docker.md). # Community + [Tron Developers & SRs](https://discord.gg/hqKvyAM) is Tron's official Discord channel. Feel free to join this channel if you have any questions. [Core Devs Community](https://t.me/troncoredevscommunity) is the Telegram channel for java-tron community developers. If you want to contribute to java-tron, please join this channel. @@ -162,22 +178,27 @@ This will mount the `output-directory` and `logs` directories on the host, the d [tronprotocol/allcoredev](https://gitter.im/tronprotocol/allcoredev) is the official Gitter channel for developers. # Contribution -Thank you for considering to help out with the source code! If you'd like to contribute to java-tron, please see the [Contribution Guide](./CONTRIBUTING.md) for more details. +Thank you for considering to help out with the source code! If you'd like to contribute to java-tron, please see the [Contribution Guide](./CONTRIBUTING.md) for more details. # Resources -* [Medium](https://medium.com/@coredevs) java-tron's official technical articles are published there. -* [Documentation](https://tronprotocol.github.io/documentation-en/introduction/) java-tron's official technical documentation website. -* [Test network](http://nileex.io/) A stable test network of TRON contributed by TRON community. -* [Tronscan](https://tronscan.org/#/) TRON network blockchain browser. -* [Wallet-cli](https://github.com/tronprotocol/wallet-cli) TRON network wallet using command line. -* [TIP](https://github.com/tronprotocol/tips) TRON Improvement Proposal (TIP) describes standards for the TRON network. -* [TP](https://github.com/tronprotocol/tips/tree/master/tp) TRON Protocol (TP) describes standards already implemented in TRON network but not published as a TIP. + +- [Medium](https://medium.com/@coredevs) java-tron's official technical articles are published there. +- [Documentation](https://tronprotocol.github.io/documentation-en/introduction/) java-tron's official technical documentation website. +- [Test network](http://nileex.io/) A stable test network of TRON contributed by TRON community. +- [Tronscan](https://tronscan.org/#/) TRON network blockchain browser. +- [Wallet-cli](https://github.com/tronprotocol/wallet-cli) TRON network wallet using command line. +- [TIP](https://github.com/tronprotocol/tips) TRON Improvement Proposal (TIP) describes standards for the TRON network. +- [TP](https://github.com/tronprotocol/tips/tree/master/tp) TRON Protocol (TP) describes standards already implemented in TRON network but not published as a TIP. + # Integrity Check -* After January 3, 2023, releases are signed the gpg key: + +- After January 3, 2023, the release files will be signed using a GPG key pair, and the correctness of the signature will be verified using the following public key: ``` pub: 1254 F859 D2B1 BD9F 66E7 107D F859 BCB4 4A28 290B uid: build@tron.network ``` + # License + java-tron is released under the [LGPLv3 license](https://github.com/tronprotocol/java-tron/blob/master/LICENSE). diff --git a/Tron protobuf protocol document.md b/Tron protobuf protocol document.md index 852ff313797..d8e621ed69a 100644 --- a/Tron protobuf protocol document.md +++ b/Tron protobuf protocol document.md @@ -546,11 +546,11 @@ Transaction and transaction-related messages. message `raw` - `ref_block_bytes`: Deprecated. + `ref_block_bytes`: intercepted part of the now block bytes in transaction head. - `ref_block_num`: now block number in transaction head. + `ref_block_num`: Deprecated. - `ref_block_hash`: now block hash in transaction head. + `ref_block_hash`:intercepted part of the now block hash in transaction head.. `expiration`: the expiration time in transaction head. @@ -565,15 +565,15 @@ Transaction and transaction-related messages. ```java message raw { bytes ref_block_bytes = 1; - int64 ref_block_num = 3; + int64 ref_block_num = 3; bytes ref_block_hash = 4; - int64 expiration = 8; + int64 expiration = 8; repeated authority auths = 9; - bytes data = 10; + bytes data = 10; repeated Contract contract = 11; - bytes scripts = 12; + bytes scripts = 12; int64 timestamp = 14; - int64 fee_limit = 18; + int64 fee_limit = 18; } ``` @@ -975,7 +975,7 @@ Contract and contract-related messages. - message `VoteAssetContract` - `owner_address`: assress of contract owner. + `owner_address`: address of contract owner. `vote_address`: voted address of asset. @@ -1059,7 +1059,7 @@ Contract and contract-related messages. `total_supply`: maximum of asset. - `frozen_supply`: frozen supplt of asset. + `frozen_supply`: frozen supply of asset. `trx_num`: trx num defines token price. @@ -1079,11 +1079,11 @@ Contract and contract-related messages. `free_asset_net_limit`: free bandwidth limit each account owns when transfers asset. - `public_free_asset_net_limit`: free bandwidth limit for all acoounts. + `public_free_asset_net_limit`: free bandwidth limit for all accounts. `public_free_asset_net_usage`: free bandwidth usage of all accounts. - `public_latest_free_net_time`: the latest bandwidth consumption time fo token transfer. + `public_latest_free_net_time`: the latest bandwidth consumption time for token transfer. ```java message AssetIssueContract { @@ -1131,7 +1131,7 @@ Contract and contract-related messages. `owner_address`: owner address. - `to_address`: reveiver address. + `to_address`: receiver address. `asset_name`: target asset name. @@ -1461,7 +1461,7 @@ Contract and contract-related messages. `owner_address`: address of owner. - `owner`: autuority to execute all contracts. + `owner`: authority to execute all contracts. `witness`: used by SR for generating blocks. @@ -1514,7 +1514,7 @@ Contract and contract-related messages. `binding_signature`: signature to verify transaction. - `transparent_to_address`: transparent address of reveiver. + `transparent_to_address`: transparent address of receiver. `to_amount`: amount to transparent to_address @@ -1536,7 +1536,7 @@ Contract and contract-related messages. ### Smart Contract -message `SmartContract` has mutiple attributes and nested message `ABI` +message `SmartContract` has multiple attributes and nested message `ABI` - message `SmartContract` @@ -1559,7 +1559,7 @@ message `SmartContract` has mutiple attributes and nested message `ABI` - message `Param` - `indexed`: `true` if the field is part of the log’s topics, `false` if it one of the log’s data segment. + `indexed`: `true` if the field is part of the log’s topics, `false` if it is one of the log’s data segment. `name`: name of the parameter. @@ -1757,7 +1757,7 @@ message `SmartContract` has mutiple attributes and nested message `ABI` `tree`: incremental merkle tree. - `filled`: this is a array, it contains the root of the subtree which can be combined with the param tree to be a new merkle tree. + `filled`: this is an array, it contains the root of the subtree which can be combined with the param tree to be a new merkle tree. `cursor`: the node that can be combined to a subtree, when they are combined to a subtree, compute its root and put it into the filled. @@ -1782,7 +1782,7 @@ message `SmartContract` has mutiple attributes and nested message `ABI` `vouchers`: this is an array, each items represents the merklevoucher of the outputpoint. - `paths`: his is an array each items represents the path of the outputpoint. + `paths`: this is an array each items represents the path of the outputpoint. ```java message IncrementalMerkleVoucherInfo { @@ -2124,13 +2124,13 @@ message `SmartContract` has mutiple attributes and nested message `ABI` - #### Node Information - Node information is separaed into several parts and implemented by nested messages. + Node information is separated into several parts and implemented by nested messages. - message `NodeInfo` - `beginSyncNum`: beginning block height for synchornize. + `beginSyncNum`: beginning block height for synchronize. `block`: head block id. @@ -2154,13 +2154,13 @@ message `SmartContract` has mutiple attributes and nested message `ABI` - message `PeerInfo`: - `lastSyncBlock`: last block id for synchornize. + `lastSyncBlock`: last block id for synchronize. `remainNum`: number of remaining blocks. `lastBlockUpdateTime`: latest block update time . - `syncFlag`: is synchroniing or not. + `syncFlag`: is synchronizing or not. `headBlockTimeWeBothHave`: timestamp of common head block. @@ -2172,7 +2172,7 @@ message `SmartContract` has mutiple attributes and nested message `ABI` `port`: listening port. - `nodeId`: ramdomly generated node ID + `nodeId`: randomly generated node ID `connectTime`: connection time period from established. diff --git a/actuator/build.gradle b/actuator/build.gradle index a0ce72b0ee6..1143dc83618 100644 --- a/actuator/build.gradle +++ b/actuator/build.gradle @@ -1,25 +1,9 @@ description = "actuator – a series of transactions for blockchain." -// Dependency versions -// --------------------------------------- - -def junitVersion = "4.13.2" -def mockitoVersion = "2.1.0" -def testNgVersion = "6.11" -def slf4jVersion = "1.7.25" -// -------------------------------------- - dependencies { - compile project(":chainbase") - compile project(":protocol") - compile project(":crypto") - testImplementation "junit:junit:$junitVersion" - testImplementation "org.mockito:mockito-core:$mockitoVersion" - - compile "org.slf4j:jcl-over-slf4j:$slf4jVersion" - compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69' - compile group: 'commons-codec', name: 'commons-codec', version: '1.11' - compile 'org.reflections:reflections:0.9.11' + api project(":chainbase") + api project(":protocol") + api project(":crypto") } test { diff --git a/actuator/src/main/java/org/tron/core/actuator/AbstractActuator.java b/actuator/src/main/java/org/tron/core/actuator/AbstractActuator.java index c88baf9b3ca..c9f83c520bd 100644 --- a/actuator/src/main/java/org/tron/core/actuator/AbstractActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/AbstractActuator.java @@ -2,9 +2,14 @@ import com.google.protobuf.Any; import com.google.protobuf.GeneratedMessageV3; +import org.tron.common.math.Maths; +import org.tron.common.utils.Commons; import org.tron.common.utils.ForkController; import org.tron.core.ChainBaseManager; +import org.tron.core.capsule.AccountCapsule; import org.tron.core.capsule.TransactionCapsule; +import org.tron.core.exception.BalanceInsufficientException; +import org.tron.core.store.AccountStore; import org.tron.protos.Protocol.Transaction.Contract; import org.tron.protos.Protocol.Transaction.Contract.ContractType; @@ -63,4 +68,61 @@ public AbstractActuator setForkUtils(ForkController forkController) { return this; } + public long addExact(long x, long y) { + return Maths.addExact(x, y, this.disableJavaLangMath()); + } + + public long addExact(int x, int y) { + return Maths.addExact(x, y, this.disableJavaLangMath()); + } + + public long floorDiv(long x, long y) { + return Maths.floorDiv(x, y, this.disableJavaLangMath()); + } + + public long floorDiv(long x, int y) { + return this.floorDiv(x, (long) y); + } + + public long multiplyExact(long x, long y) { + return Maths.multiplyExact(x, y, this.disableJavaLangMath()); + } + + public long multiplyExact(long x, int y) { + return this.multiplyExact(x, (long) y); + } + + public int multiplyExact(int x, int y) { + return Maths.multiplyExact(x, y, this.disableJavaLangMath()); + } + + public long subtractExact(long x, long y) { + return Maths.subtractExact(x, y, this.disableJavaLangMath()); + } + + public int min(int a, int b) { + return Maths.min(a, b, this.disableJavaLangMath()); + } + + public long min(long a, long b) { + return Maths.min(a, b, this.disableJavaLangMath()); + } + + public void adjustBalance(AccountStore accountStore, byte[] accountAddress, long amount) + throws BalanceInsufficientException { + AccountCapsule account = accountStore.getUnchecked(accountAddress); + this.adjustBalance(accountStore, account, amount); + } + + /** + * judge balance. + */ + public void adjustBalance(AccountStore accountStore, AccountCapsule account, long amount) + throws BalanceInsufficientException { + Commons.adjustBalance(accountStore, account, amount, this.disableJavaLangMath()); + } + + boolean disableJavaLangMath() { + return chainBaseManager.getDynamicPropertiesStore().disableJavaLangMath(); + } } diff --git a/actuator/src/main/java/org/tron/core/actuator/AccountPermissionUpdateActuator.java b/actuator/src/main/java/org/tron/core/actuator/AccountPermissionUpdateActuator.java index fcc4d775d43..f2eafb20a5e 100644 --- a/actuator/src/main/java/org/tron/core/actuator/AccountPermissionUpdateActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/AccountPermissionUpdateActuator.java @@ -8,7 +8,6 @@ import java.util.Objects; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.tron.common.utils.Commons; import org.tron.common.utils.DecodeUtil; import org.tron.core.capsule.AccountCapsule; import org.tron.core.capsule.TransactionResultCapsule; @@ -52,11 +51,11 @@ public boolean execute(Object object) throws ContractExeException { accountPermissionUpdateContract.getActivesList()); accountStore.put(ownerAddress, account); - Commons.adjustBalance(accountStore, ownerAddress, -fee); + adjustBalance(accountStore, ownerAddress, -fee); if (chainBaseManager.getDynamicPropertiesStore().supportBlackHoleOptimization()) { chainBaseManager.getDynamicPropertiesStore().burnTrx(fee); } else { - Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee); + adjustBalance(accountStore, accountStore.getBlackhole(), fee); } result.setStatus(fee, code.SUCESS); @@ -111,7 +110,7 @@ private boolean checkPermission(Permission permission) throws ContractValidateEx throw new ContractValidateException("key's weight should be greater than 0"); } try { - weightSum = Math.addExact(weightSum, key.getWeight()); + weightSum = addExact(weightSum, key.getWeight()); } catch (ArithmeticException e) { throw new ContractValidateException(e.getMessage()); } diff --git a/actuator/src/main/java/org/tron/core/actuator/AssetIssueActuator.java b/actuator/src/main/java/org/tron/core/actuator/AssetIssueActuator.java index 55218897c5d..331b45f106a 100644 --- a/actuator/src/main/java/org/tron/core/actuator/AssetIssueActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/AssetIssueActuator.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Objects; import lombok.extern.slf4j.Slf4j; -import org.tron.common.utils.Commons; import org.tron.common.utils.DecodeUtil; import org.tron.core.capsule.AccountCapsule; import org.tron.core.capsule.AssetIssueCapsule; @@ -84,11 +83,11 @@ public boolean execute(Object result) throws ContractExeException { .put(assetIssueCapsuleV2.createDbV2Key(), assetIssueCapsuleV2); } - Commons.adjustBalance(accountStore, ownerAddress, -fee); + adjustBalance(accountStore, ownerAddress, -fee); if (dynamicStore.supportBlackHoleOptimization()) { dynamicStore.burnTrx(fee); } else { - Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);//send to blackhole + adjustBalance(accountStore, accountStore.getBlackhole(), fee);//send to blackhole } AccountCapsule accountCapsule = accountStore.get(ownerAddress); List frozenSupplyList = assetIssueContract.getFrozenSupplyList(); diff --git a/actuator/src/main/java/org/tron/core/actuator/CreateAccountActuator.java b/actuator/src/main/java/org/tron/core/actuator/CreateAccountActuator.java index 1c6aca4d7d7..352f394d6cb 100755 --- a/actuator/src/main/java/org/tron/core/actuator/CreateAccountActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/CreateAccountActuator.java @@ -6,7 +6,6 @@ import com.google.protobuf.InvalidProtocolBufferException; import java.util.Objects; import lombok.extern.slf4j.Slf4j; -import org.tron.common.utils.Commons; import org.tron.common.utils.DecodeUtil; import org.tron.common.utils.StringUtil; import org.tron.core.capsule.AccountCapsule; @@ -48,13 +47,12 @@ public boolean execute(Object result) accountStore .put(accountCreateContract.getAccountAddress().toByteArray(), accountCapsule); - Commons - .adjustBalance(accountStore, accountCreateContract.getOwnerAddress().toByteArray(), -fee); + adjustBalance(accountStore, accountCreateContract.getOwnerAddress().toByteArray(), -fee); // Add to blackhole address if (dynamicStore.supportBlackHoleOptimization()) { dynamicStore.burnTrx(fee); } else { - Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee); + adjustBalance(accountStore, accountStore.getBlackhole(), fee); } ret.setStatus(fee, code.SUCESS); } catch (BalanceInsufficientException | InvalidProtocolBufferException e) { diff --git a/actuator/src/main/java/org/tron/core/actuator/DelegateResourceActuator.java b/actuator/src/main/java/org/tron/core/actuator/DelegateResourceActuator.java index 161f22cfb17..9e7b0efa5ce 100755 --- a/actuator/src/main/java/org/tron/core/actuator/DelegateResourceActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/DelegateResourceActuator.java @@ -15,7 +15,6 @@ import java.util.Arrays; import java.util.Objects; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ArrayUtils; import org.tron.common.utils.DecodeUtil; import org.tron.common.utils.StringUtil; import org.tron.core.capsule.AccountCapsule; @@ -162,7 +161,8 @@ public boolean validate() throws ContractValidateException { } long netUsage = (long) (accountNetUsage * TRX_PRECISION * ((double) (dynamicStore.getTotalNetWeight()) / dynamicStore.getTotalNetLimit())); - long v2NetUsage = getV2NetUsage(ownerCapsule, netUsage); + long v2NetUsage = getV2NetUsage(ownerCapsule, netUsage, + this.disableJavaLangMath()); if (ownerCapsule.getFrozenV2BalanceForBandwidth() - v2NetUsage < delegateBalance) { throw new ContractValidateException( "delegateBalance must be less than or equal to available FreezeBandwidthV2 balance"); @@ -175,7 +175,8 @@ public boolean validate() throws ContractValidateException { long energyUsage = (long) (ownerCapsule.getEnergyUsage() * TRX_PRECISION * ((double) (dynamicStore.getTotalEnergyWeight()) / dynamicStore.getTotalEnergyCurrentLimit())); - long v2EnergyUsage = getV2EnergyUsage(ownerCapsule, energyUsage); + long v2EnergyUsage = getV2EnergyUsage(ownerCapsule, energyUsage, + this.disableJavaLangMath()); if (ownerCapsule.getFrozenV2BalanceForEnergy() - v2EnergyUsage < delegateBalance) { throw new ContractValidateException( "delegateBalance must be less than or equal to available FreezeEnergyV2 balance"); diff --git a/actuator/src/main/java/org/tron/core/actuator/ExchangeCreateActuator.java b/actuator/src/main/java/org/tron/core/actuator/ExchangeCreateActuator.java index b7f5b90da45..27d3da509b4 100755 --- a/actuator/src/main/java/org/tron/core/actuator/ExchangeCreateActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/ExchangeCreateActuator.java @@ -9,7 +9,6 @@ import java.util.Arrays; import java.util.Objects; import lombok.extern.slf4j.Slf4j; -import org.tron.common.utils.Commons; import org.tron.common.utils.DecodeUtil; import org.tron.common.utils.StringUtil; import org.tron.core.capsule.AccountCapsule; @@ -121,7 +120,7 @@ public boolean execute(Object object) throws ContractExeException { if (dynamicStore.supportBlackHoleOptimization()) { dynamicStore.burnTrx(fee); } else { - Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee); + adjustBalance(accountStore, accountStore.getBlackhole(), fee); } ret.setExchangeId(id); ret.setStatus(fee, code.SUCESS); diff --git a/actuator/src/main/java/org/tron/core/actuator/ExchangeInjectActuator.java b/actuator/src/main/java/org/tron/core/actuator/ExchangeInjectActuator.java index 7848f898ced..482f5bdf081 100755 --- a/actuator/src/main/java/org/tron/core/actuator/ExchangeInjectActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/ExchangeInjectActuator.java @@ -71,14 +71,14 @@ public boolean execute(Object object) throws ContractExeException { if (Arrays.equals(tokenID, firstTokenID)) { anotherTokenID = secondTokenID; - anotherTokenQuant = Math - .floorDiv(Math.multiplyExact(secondTokenBalance, tokenQuant), firstTokenBalance); + anotherTokenQuant = floorDiv(multiplyExact( + secondTokenBalance, tokenQuant), firstTokenBalance); exchangeCapsule.setBalance(firstTokenBalance + tokenQuant, secondTokenBalance + anotherTokenQuant); } else { anotherTokenID = firstTokenID; - anotherTokenQuant = Math - .floorDiv(Math.multiplyExact(firstTokenBalance, tokenQuant), secondTokenBalance); + anotherTokenQuant = floorDiv(multiplyExact( + firstTokenBalance, tokenQuant), secondTokenBalance); exchangeCapsule.setBalance(firstTokenBalance + anotherTokenQuant, secondTokenBalance + tokenQuant); } diff --git a/actuator/src/main/java/org/tron/core/actuator/ExchangeTransactionActuator.java b/actuator/src/main/java/org/tron/core/actuator/ExchangeTransactionActuator.java index 612f673832e..6f50d61c235 100755 --- a/actuator/src/main/java/org/tron/core/actuator/ExchangeTransactionActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/ExchangeTransactionActuator.java @@ -66,7 +66,8 @@ public boolean execute(Object object) throws ContractExeException { long tokenQuant = exchangeTransactionContract.getQuant(); byte[] anotherTokenID; - long anotherTokenQuant = exchangeCapsule.transaction(tokenID, tokenQuant); + long anotherTokenQuant = exchangeCapsule.transaction(tokenID, tokenQuant, + dynamicStore.allowStrictMath()); if (Arrays.equals(tokenID, firstTokenID)) { anotherTokenID = secondTokenID; @@ -205,7 +206,8 @@ public boolean validate() throws ContractValidateException { } } - long anotherTokenQuant = exchangeCapsule.transaction(tokenID, tokenQuant); + long anotherTokenQuant = exchangeCapsule.transaction(tokenID, tokenQuant, + dynamicStore.allowStrictMath()); if (anotherTokenQuant < tokenExpected) { throw new ContractValidateException("token required must greater than expected"); } diff --git a/actuator/src/main/java/org/tron/core/actuator/ExchangeWithdrawActuator.java b/actuator/src/main/java/org/tron/core/actuator/ExchangeWithdrawActuator.java index 8929305d68c..fb8fe9384d3 100755 --- a/actuator/src/main/java/org/tron/core/actuator/ExchangeWithdrawActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/ExchangeWithdrawActuator.java @@ -76,16 +76,12 @@ public boolean execute(Object object) throws ContractExeException { BigInteger bigTokenQuant = new BigInteger(String.valueOf(tokenQuant)); if (Arrays.equals(tokenID, firstTokenID)) { anotherTokenID = secondTokenID; -// anotherTokenQuant = Math -// .floorDiv(Math.multiplyExact(secondTokenBalance, tokenQuant), firstTokenBalance); anotherTokenQuant = bigSecondTokenBalance.multiply(bigTokenQuant) .divide(bigFirstTokenBalance).longValueExact(); exchangeCapsule.setBalance(firstTokenBalance - tokenQuant, secondTokenBalance - anotherTokenQuant); } else { anotherTokenID = firstTokenID; -// anotherTokenQuant = Math -// .floorDiv(Math.multiplyExact(firstTokenBalance, tokenQuant), secondTokenBalance); anotherTokenQuant = bigFirstTokenBalance.multiply(bigTokenQuant) .divide(bigSecondTokenBalance).longValueExact(); exchangeCapsule.setBalance(firstTokenBalance - anotherTokenQuant, @@ -210,8 +206,6 @@ public boolean validate() throws ContractValidateException { BigDecimal bigSecondTokenBalance = new BigDecimal(String.valueOf(secondTokenBalance)); BigDecimal bigTokenQuant = new BigDecimal(String.valueOf(tokenQuant)); if (Arrays.equals(tokenID, firstTokenID)) { -// anotherTokenQuant = Math -// .floorDiv(Math.multiplyExact(secondTokenBalance, tokenQuant), firstTokenBalance); anotherTokenQuant = bigSecondTokenBalance.multiply(bigTokenQuant) .divideToIntegralValue(bigFirstTokenBalance).longValueExact(); if (firstTokenBalance < tokenQuant || secondTokenBalance < anotherTokenQuant) { @@ -230,8 +224,6 @@ public boolean validate() throws ContractValidateException { } } else { -// anotherTokenQuant = Math -// .floorDiv(Math.multiplyExact(firstTokenBalance, tokenQuant), secondTokenBalance); anotherTokenQuant = bigFirstTokenBalance.multiply(bigTokenQuant) .divideToIntegralValue(bigSecondTokenBalance).longValueExact(); if (secondTokenBalance < tokenQuant || firstTokenBalance < anotherTokenQuant) { diff --git a/actuator/src/main/java/org/tron/core/actuator/MarketCancelOrderActuator.java b/actuator/src/main/java/org/tron/core/actuator/MarketCancelOrderActuator.java index f859e580253..31b5e87e12d 100644 --- a/actuator/src/main/java/org/tron/core/actuator/MarketCancelOrderActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/MarketCancelOrderActuator.java @@ -23,7 +23,6 @@ import com.google.protobuf.InvalidProtocolBufferException; import java.util.Objects; import lombok.extern.slf4j.Slf4j; -import org.tron.common.utils.Commons; import org.tron.common.utils.DecodeUtil; import org.tron.core.capsule.AccountCapsule; import org.tron.core.capsule.MarketOrderCapsule; @@ -100,7 +99,7 @@ public boolean execute(Object object) throws ContractExeException { if (dynamicStore.supportBlackHoleOptimization()) { dynamicStore.burnTrx(fee); } else { - Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee); + adjustBalance(accountStore, accountStore.getBlackhole(), fee); } // 1. return balance and token MarketUtils diff --git a/actuator/src/main/java/org/tron/core/actuator/MarketSellAssetActuator.java b/actuator/src/main/java/org/tron/core/actuator/MarketSellAssetActuator.java index 15e5a98f86a..d196cdef06f 100644 --- a/actuator/src/main/java/org/tron/core/actuator/MarketSellAssetActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/MarketSellAssetActuator.java @@ -129,7 +129,7 @@ public boolean execute(Object object) throws ContractExeException { if (dynamicStore.supportBlackHoleOptimization()) { dynamicStore.burnTrx(fee); } else { - Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee); + adjustBalance(accountStore, accountStore.getBlackhole(), fee); } // 1. transfer of balance transferBalanceOrToken(accountCapsule); @@ -244,7 +244,7 @@ public boolean validate() throws ContractValidateException { long fee = calcFee(); if (Arrays.equals(sellTokenID, "_".getBytes())) { - if (ownerAccount.getBalance() < Math.addExact(sellTokenQuantity, fee)) { + if (ownerAccount.getBalance() < addExact(sellTokenQuantity, fee)) { throw new ContractValidateException("No enough balance !"); } } else { @@ -401,7 +401,8 @@ private void matchSingleOrder(MarketOrderCapsule takerOrderCapsule, // makerSellTokenQuantity_A/makerBuyTokenQuantity_TRX long takerBuyTokenQuantityRemain = MarketUtils - .multiplyAndDivide(takerSellRemainQuantity, makerSellQuantity, makerBuyQuantity); + .multiplyAndDivide(takerSellRemainQuantity, makerSellQuantity, makerBuyQuantity, + this.disableJavaLangMath()); if (takerBuyTokenQuantityRemain == 0) { // quantity too small, return sellToken to user @@ -424,7 +425,8 @@ private void matchSingleOrder(MarketOrderCapsule takerOrderCapsule, // makerBuyTokenQuantity_TRX / makerSellTokenQuantity_A makerBuyTokenQuantityReceive = MarketUtils - .multiplyAndDivide(makerSellRemainQuantity, makerBuyQuantity, makerSellQuantity); + .multiplyAndDivide(makerSellRemainQuantity, makerBuyQuantity, makerSellQuantity, + this.disableJavaLangMath()); takerBuyTokenQuantityReceive = makerOrderCapsule.getSellTokenQuantityRemain(); long takerSellTokenLeft = @@ -447,7 +449,7 @@ private void matchSingleOrder(MarketOrderCapsule takerOrderCapsule, takerOrderCapsule.setSellTokenQuantityRemain(0); MarketUtils.updateOrderState(takerOrderCapsule, State.INACTIVE, marketAccountStore); - makerOrderCapsule.setSellTokenQuantityRemain(Math.subtractExact( + makerOrderCapsule.setSellTokenQuantityRemain(subtractExact( makerOrderCapsule.getSellTokenQuantityRemain(), takerBuyTokenQuantityRemain)); } else { // taker > maker @@ -458,7 +460,8 @@ private void matchSingleOrder(MarketOrderCapsule takerOrderCapsule, // makerSellTokenQuantityRemain_A/makerBuyTokenQuantityCurrent_TRX = // makerSellTokenQuantity_A/makerBuyTokenQuantity_TRX makerBuyTokenQuantityReceive = MarketUtils - .multiplyAndDivide(makerSellRemainQuantity, makerBuyQuantity, makerSellQuantity); + .multiplyAndDivide(makerSellRemainQuantity, makerBuyQuantity, makerSellQuantity, + this.disableJavaLangMath()); MarketUtils.updateOrderState(makerOrderCapsule, State.INACTIVE, marketAccountStore); if (makerBuyTokenQuantityReceive == 0) { @@ -475,7 +478,7 @@ private void matchSingleOrder(MarketOrderCapsule takerOrderCapsule, return; } else { makerOrderCapsule.setSellTokenQuantityRemain(0); - takerOrderCapsule.setSellTokenQuantityRemain(Math.subtractExact( + takerOrderCapsule.setSellTokenQuantityRemain(subtractExact( takerOrderCapsule.getSellTokenQuantityRemain(), makerBuyTokenQuantityReceive)); } } @@ -524,7 +527,8 @@ private MarketOrderCapsule createAndSaveOrder(AccountCapsule accountCapsule, private void transferBalanceOrToken(AccountCapsule accountCapsule) { if (Arrays.equals(sellTokenID, "_".getBytes())) { - accountCapsule.setBalance(Math.subtractExact(accountCapsule.getBalance(), sellTokenQuantity)); + accountCapsule.setBalance(subtractExact( + accountCapsule.getBalance(), sellTokenQuantity)); } else { accountCapsule .reduceAssetAmountV2(sellTokenID, sellTokenQuantity, dynamicStore, assetIssueStore); @@ -537,7 +541,7 @@ private void addTrxOrToken(MarketOrderCapsule orderCapsule, long num, byte[] buyTokenId = orderCapsule.getBuyTokenId(); if (Arrays.equals(buyTokenId, "_".getBytes())) { - accountCapsule.setBalance(Math.addExact(accountCapsule.getBalance(), num)); + accountCapsule.setBalance(addExact(accountCapsule.getBalance(), num)); } else { accountCapsule .addAssetAmountV2(buyTokenId, num, dynamicStore, assetIssueStore); @@ -550,7 +554,7 @@ private void addTrxOrToken(MarketOrderCapsule orderCapsule, long num) { byte[] buyTokenId = orderCapsule.getBuyTokenId(); if (Arrays.equals(buyTokenId, "_".getBytes())) { - accountCapsule.setBalance(Math.addExact(accountCapsule.getBalance(), num)); + accountCapsule.setBalance(addExact(accountCapsule.getBalance(), num)); } else { accountCapsule .addAssetAmountV2(buyTokenId, num, dynamicStore, assetIssueStore); diff --git a/actuator/src/main/java/org/tron/core/actuator/ParticipateAssetIssueActuator.java b/actuator/src/main/java/org/tron/core/actuator/ParticipateAssetIssueActuator.java index 77e345b2a92..7fdf15acd18 100755 --- a/actuator/src/main/java/org/tron/core/actuator/ParticipateAssetIssueActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/ParticipateAssetIssueActuator.java @@ -64,8 +64,8 @@ public boolean execute(Object object) throws ContractExeException { //subtract from owner address byte[] ownerAddress = participateAssetIssueContract.getOwnerAddress().toByteArray(); AccountCapsule ownerAccount = accountStore.get(ownerAddress); - long balance = Math.subtractExact(ownerAccount.getBalance(), cost); - balance = Math.subtractExact(balance, fee); + long balance = subtractExact(ownerAccount.getBalance(), cost); + balance = subtractExact(balance, fee); ownerAccount.setBalance(balance); byte[] key = participateAssetIssueContract.getAssetName().toByteArray(); @@ -74,14 +74,14 @@ public boolean execute(Object object) throws ContractExeException { assetIssueCapsule = Commons .getAssetIssueStoreFinal(dynamicStore, assetIssueStore, assetIssueV2Store).get(key); - long exchangeAmount = Math.multiplyExact(cost, assetIssueCapsule.getNum()); - exchangeAmount = Math.floorDiv(exchangeAmount, assetIssueCapsule.getTrxNum()); + long exchangeAmount = multiplyExact(cost, assetIssueCapsule.getNum()); + exchangeAmount = floorDiv(exchangeAmount, assetIssueCapsule.getTrxNum()); ownerAccount.addAssetAmountV2(key, exchangeAmount, dynamicStore, assetIssueStore); //add to to_address byte[] toAddress = participateAssetIssueContract.getToAddress().toByteArray(); AccountCapsule toAccount = accountStore.get(toAddress); - toAccount.setBalance(Math.addExact(toAccount.getBalance(), cost)); + toAccount.setBalance(addExact(toAccount.getBalance(), cost)); if (!toAccount.reduceAssetAmountV2(key, exchangeAmount, dynamicStore, assetIssueStore)) { throw new ContractExeException("reduceAssetAmount failed !"); } @@ -156,7 +156,7 @@ public boolean validate() throws ContractValidateException { try { //Whether the balance is enough long fee = calcFee(); - if (ownerAccount.getBalance() < Math.addExact(amount, fee)) { + if (ownerAccount.getBalance() < addExact(amount, fee)) { throw new ContractValidateException("No enough balance !"); } @@ -181,8 +181,8 @@ public boolean validate() throws ContractValidateException { int trxNum = assetIssueCapsule.getTrxNum(); int num = assetIssueCapsule.getNum(); - long exchangeAmount = Math.multiplyExact(amount, num); - exchangeAmount = Math.floorDiv(exchangeAmount, trxNum); + long exchangeAmount = multiplyExact(amount, num); + exchangeAmount = floorDiv(exchangeAmount, trxNum); if (exchangeAmount <= 0) { throw new ContractValidateException("Can not process the exchange!"); } diff --git a/actuator/src/main/java/org/tron/core/actuator/ShieldedTransferActuator.java b/actuator/src/main/java/org/tron/core/actuator/ShieldedTransferActuator.java index 284650f1ffb..2773dc07d26 100644 --- a/actuator/src/main/java/org/tron/core/actuator/ShieldedTransferActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/ShieldedTransferActuator.java @@ -96,9 +96,9 @@ public boolean execute(Object result) //adjust and verify total shielded pool value try { - Commons.adjustTotalShieldedPoolValue( - Math.addExact(Math.subtractExact(shieldedTransferContract.getToAmount(), - shieldedTransferContract.getFromAmount()), fee), dynamicStore); + Commons.adjustTotalShieldedPoolValue(addExact(subtractExact( + shieldedTransferContract.getToAmount(), + shieldedTransferContract.getFromAmount()), fee), dynamicStore); } catch (ArithmeticException | BalanceInsufficientException e) { logger.debug(e.getMessage(), e); ret.setStatus(0, code.FAILED); @@ -327,9 +327,11 @@ private void checkProof(List spendDescriptions, long totalShieldedPoolValue = dynamicStore .getTotalShieldedPoolValue(); try { - valueBalance = Math.addExact(Math.subtractExact(shieldedTransferContract.getToAmount(), + valueBalance = addExact(subtractExact( + shieldedTransferContract.getToAmount(), shieldedTransferContract.getFromAmount()), fee); - totalShieldedPoolValue = Math.subtractExact(totalShieldedPoolValue, valueBalance); + totalShieldedPoolValue = subtractExact( + totalShieldedPoolValue, valueBalance); } catch (ArithmeticException e) { logger.debug(e.getMessage(), e); throw new ZkProofValidateException(e.getMessage(), true); @@ -452,7 +454,7 @@ private void validateTransparent(ShieldedTransferContract shieldedTransferContra AccountCapsule toAccount = accountStore.get(toAddress); if (toAccount != null) { try { - Math.addExact(getZenBalance(toAccount), toAmount); + addExact(getZenBalance(toAccount), toAmount); } catch (ArithmeticException e) { logger.debug(e.getMessage(), e); throw new ContractValidateException(e.getMessage()); diff --git a/actuator/src/main/java/org/tron/core/actuator/TransferActuator.java b/actuator/src/main/java/org/tron/core/actuator/TransferActuator.java index 5e3d605aed7..a0deabf8f00 100755 --- a/actuator/src/main/java/org/tron/core/actuator/TransferActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/TransferActuator.java @@ -7,7 +7,6 @@ import java.util.Arrays; import java.util.Objects; import lombok.extern.slf4j.Slf4j; -import org.tron.common.utils.Commons; import org.tron.common.utils.DecodeUtil; import org.tron.common.utils.StringUtil; import org.tron.core.capsule.AccountCapsule; @@ -58,13 +57,13 @@ public boolean execute(Object object) throws ContractExeException { fee = fee + dynamicStore.getCreateNewAccountFeeInSystemContract(); } - Commons.adjustBalance(accountStore, ownerAddress, -(Math.addExact(fee, amount))); + adjustBalance(accountStore, ownerAddress, -(addExact(fee, amount))); if (dynamicStore.supportBlackHoleOptimization()) { dynamicStore.burnTrx(fee); } else { - Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee); + adjustBalance(accountStore, accountStore.getBlackhole(), fee); } - Commons.adjustBalance(accountStore, toAddress, amount); + adjustBalance(accountStore, toAddress, amount); ret.setStatus(fee, code.SUCESS); } catch (BalanceInsufficientException | ArithmeticException | InvalidProtocolBufferException e) { logger.debug(e.getMessage(), e); @@ -156,7 +155,7 @@ public boolean validate() throws ContractValidateException { } } - if (balance < Math.addExact(amount, fee)) { + if (balance < addExact(amount, fee)) { logger.warn("Balance is not sufficient. Account: {}, balance: {}, amount: {}, fee: {}.", StringUtil.encode58Check(ownerAddress), balance, amount, fee); throw new ContractValidateException( @@ -164,7 +163,7 @@ public boolean validate() throws ContractValidateException { } if (toAccount != null) { - Math.addExact(toAccount.getBalance(), amount); + addExact(toAccount.getBalance(), amount); } } catch (ArithmeticException e) { logger.debug(e.getMessage(), e); diff --git a/actuator/src/main/java/org/tron/core/actuator/TransferAssetActuator.java b/actuator/src/main/java/org/tron/core/actuator/TransferAssetActuator.java index de2b2faec86..d93263055eb 100644 --- a/actuator/src/main/java/org/tron/core/actuator/TransferAssetActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/TransferAssetActuator.java @@ -83,11 +83,11 @@ public boolean execute(Object result) throws ContractExeException { .addAssetAmountV2(assetName.toByteArray(), amount, dynamicStore, assetIssueStore); accountStore.put(toAddress, toAccountCapsule); - Commons.adjustBalance(accountStore, ownerAccountCapsule, -fee); + adjustBalance(accountStore, ownerAccountCapsule, -fee); if (dynamicStore.supportBlackHoleOptimization()) { dynamicStore.burnTrx(fee); } else { - Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee); + adjustBalance(accountStore, accountStore.getBlackhole(), fee); } ret.setStatus(fee, code.SUCESS); } catch (BalanceInsufficientException e) { @@ -177,7 +177,7 @@ public boolean validate() throws ContractValidateException { assetBalance = toAccount.getAsset(dynamicStore, ByteArray.toStr(assetName)); if (assetBalance != null) { try { - assetBalance = Math.addExact(assetBalance, amount); //check if overflow + assetBalance = addExact(assetBalance, amount); //check if overflow } catch (Exception e) { logger.debug(e.getMessage(), e); throw new ContractValidateException(e.getMessage()); diff --git a/actuator/src/main/java/org/tron/core/actuator/UnDelegateResourceActuator.java b/actuator/src/main/java/org/tron/core/actuator/UnDelegateResourceActuator.java index 79a09664180..2f2eed7fded 100755 --- a/actuator/src/main/java/org/tron/core/actuator/UnDelegateResourceActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/UnDelegateResourceActuator.java @@ -82,7 +82,7 @@ public boolean execute(Object result) throws ContractExeException { * ((double) (dynamicStore.getTotalNetLimit()) / dynamicStore.getTotalNetWeight())); transferUsage = (long) (receiverCapsule.getNetUsage() * ((double) (unDelegateBalance) / receiverCapsule.getAllFrozenBalanceForBandwidth())); - transferUsage = Math.min(unDelegateMaxUsage, transferUsage); + transferUsage = min(unDelegateMaxUsage, transferUsage); receiverCapsule.addAcquiredDelegatedFrozenV2BalanceForBandwidth(-unDelegateBalance); } @@ -105,7 +105,7 @@ public boolean execute(Object result) throws ContractExeException { * ((double) (dynamicStore.getTotalEnergyCurrentLimit()) / dynamicStore.getTotalEnergyWeight())); transferUsage = (long) (receiverCapsule.getEnergyUsage() * ((double) (unDelegateBalance) / receiverCapsule.getAllFrozenBalanceForEnergy())); - transferUsage = Math.min(unDelegateMaxUsage, transferUsage); + transferUsage = min(unDelegateMaxUsage, transferUsage); receiverCapsule.addAcquiredDelegatedFrozenV2BalanceForEnergy(-unDelegateBalance); } diff --git a/actuator/src/main/java/org/tron/core/actuator/VMActuator.java b/actuator/src/main/java/org/tron/core/actuator/VMActuator.java index 326e2472757..9da41574ff0 100644 --- a/actuator/src/main/java/org/tron/core/actuator/VMActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/VMActuator.java @@ -1,9 +1,11 @@ package org.tron.core.actuator; -import static java.lang.Math.max; -import static java.lang.Math.min; import static org.apache.commons.lang3.ArrayUtils.getLength; import static org.apache.commons.lang3.ArrayUtils.isNotEmpty; +import static org.tron.common.math.Maths.addExact; +import static org.tron.common.math.Maths.floorDiv; +import static org.tron.common.math.Maths.max; +import static org.tron.common.math.Maths.min; import static org.tron.protos.contract.Common.ResourceCode.ENERGY; import com.google.protobuf.ByteString; @@ -38,6 +40,7 @@ import org.tron.core.utils.TransactionUtil; import org.tron.core.vm.EnergyCost; import org.tron.core.vm.LogInfoTriggerParser; +import org.tron.core.vm.Op; import org.tron.core.vm.OperationRegistry; import org.tron.core.vm.VM; import org.tron.core.vm.VMConstant; @@ -123,9 +126,9 @@ public void validate(Object object) throws ContractValidateException { trx = context.getTrxCap().getInstance(); // If tx`s fee limit is set, use it to calc max energy limit for constant call if (isConstantCall && trx.getRawData().getFeeLimit() > 0) { - maxEnergyLimit = Math.min(maxEnergyLimit, trx.getRawData().getFeeLimit() + maxEnergyLimit = min(maxEnergyLimit, trx.getRawData().getFeeLimit() / context.getStoreFactory().getChainBaseManager() - .getDynamicPropertiesStore().getEnergyFee()); + .getDynamicPropertiesStore().getEnergyFee(), VMConfig.disableJavaLangMath()); } blockCap = context.getBlockCap(); if ((VMConfig.allowTvmFreeze() || VMConfig.allowTvmFreezeV2()) @@ -189,6 +192,13 @@ public void execute(Object object) throws ContractExeException { VM.play(program, OperationRegistry.getTable()); result = program.getResult(); + if (VMConfig.allowEnergyAdjustment()) { + // If the last op consumed too much execution time, the CPU time limit for the whole tx can be exceeded. + // This is not fair for other txs in the same block. + // So when allowFairEnergyAdjustment is on, the CPU time limit will be checked at the end of tx execution. + program.checkCPUTimeLimit(Op.getNameOf(program.getLastOp()) + "(TX_LAST_OP)"); + } + if (TrxType.TRX_CONTRACT_CREATION_TYPE == trxType && !result.isRevert()) { byte[] code = program.getResult().getHReturn(); if (code.length != 0 && VMConfig.allowTvmLondon() && code[0] == (byte) 0xEF) { @@ -555,8 +565,10 @@ public long getAccountEnergyLimitWithFixRatio(AccountCapsule account, long feeLi receipt.setCallerEnergyLeft(leftFrozenEnergy); } - long energyFromBalance = max(account.getBalance() - callValue, 0) / sunPerEnergy; - long availableEnergy = Math.addExact(leftFrozenEnergy, energyFromBalance); + long energyFromBalance = max(account.getBalance() - callValue, 0, + VMConfig.disableJavaLangMath()) / sunPerEnergy; + long availableEnergy = addExact(leftFrozenEnergy, energyFromBalance, + VMConfig.disableJavaLangMath()); long energyFromFeeLimit = feeLimit / sunPerEnergy; if (VMConfig.allowTvmFreezeV2()) { @@ -572,12 +584,13 @@ public long getAccountEnergyLimitWithFixRatio(AccountCapsule account, long feeLi receipt.setCallerEnergyWindowSizeV2(account.getWindowSizeV2(ENERGY)); account.setEnergyUsage( energyProcessor.increase(account, ENERGY, - account.getEnergyUsage(), min(leftFrozenEnergy, energyFromFeeLimit), now, now)); + account.getEnergyUsage(), min(leftFrozenEnergy, energyFromFeeLimit, + VMConfig.disableJavaLangMath()), now, now)); receipt.setCallerEnergyMergedUsage(account.getEnergyUsage()); receipt.setCallerEnergyMergedWindowSize(account.getWindowSize(ENERGY)); rootRepository.updateAccount(account.createDbKey(), account); } - return min(availableEnergy, energyFromFeeLimit); + return min(availableEnergy, energyFromFeeLimit, VMConfig.disableJavaLangMath()); } @@ -590,9 +603,10 @@ private long getAccountEnergyLimitWithFloatRatio(AccountCapsule account, long fe } // can change the calc way long leftEnergyFromFreeze = rootRepository.getAccountLeftEnergyFromFreeze(account); - callValue = max(callValue, 0); - long energyFromBalance = Math - .floorDiv(max(account.getBalance() - callValue, 0), sunPerEnergy); + callValue = max(callValue, 0, VMConfig.disableJavaLangMath()); + long energyFromBalance = floorDiv(max( + account.getBalance() - callValue, 0, VMConfig.disableJavaLangMath()), sunPerEnergy, + VMConfig.disableJavaLangMath()); long energyFromFeeLimit; long totalBalanceForEnergyFreeze = account.getAllFrozenBalanceForEnergy(); @@ -611,13 +625,14 @@ private long getAccountEnergyLimitWithFloatRatio(AccountCapsule account, long fe .multiply(BigInteger.valueOf(feeLimit)) .divide(BigInteger.valueOf(totalBalanceForEnergyFreeze)).longValueExact(); } else { - energyFromFeeLimit = Math - .addExact(leftEnergyFromFreeze, - (feeLimit - leftBalanceForEnergyFreeze) / sunPerEnergy); + energyFromFeeLimit = addExact( + leftEnergyFromFreeze, (feeLimit - leftBalanceForEnergyFreeze) / sunPerEnergy, + VMConfig.disableJavaLangMath()); } } - return min(Math.addExact(leftEnergyFromFreeze, energyFromBalance), energyFromFeeLimit); + return min(addExact(leftEnergyFromFreeze, energyFromBalance, + VMConfig.disableJavaLangMath()), energyFromFeeLimit, VMConfig.disableJavaLangMath()); } public long getTotalEnergyLimit(AccountCapsule creator, AccountCapsule caller, @@ -692,7 +707,8 @@ public long getTotalEnergyLimitWithFixRatio(AccountCapsule creator, AccountCapsu long creatorEnergyLimit = 0; ContractCapsule contractCapsule = rootRepository .getContract(contract.getContractAddress().toByteArray()); - long consumeUserResourcePercent = contractCapsule.getConsumeUserResourcePercent(); + long consumeUserResourcePercent = contractCapsule.getConsumeUserResourcePercent( + VMConfig.disableJavaLangMath()); long originEnergyLimit = contractCapsule.getOriginEnergyLimit(); if (originEnergyLimit < 0) { @@ -707,7 +723,8 @@ public long getTotalEnergyLimitWithFixRatio(AccountCapsule creator, AccountCapsu } } if (consumeUserResourcePercent <= 0) { - creatorEnergyLimit = min(originEnergyLeft, originEnergyLimit); + creatorEnergyLimit = min(originEnergyLeft, originEnergyLimit, + VMConfig.disableJavaLangMath()); } else { if (consumeUserResourcePercent < VMConstant.ONE_HUNDRED) { // creatorEnergyLimit = @@ -718,8 +735,8 @@ public long getTotalEnergyLimitWithFixRatio(AccountCapsule creator, AccountCapsu BigInteger.valueOf(callerEnergyLimit) .multiply(BigInteger.valueOf(VMConstant.ONE_HUNDRED - consumeUserResourcePercent)) .divide(BigInteger.valueOf(consumeUserResourcePercent)).longValueExact(), - min(originEnergyLeft, originEnergyLimit) - ); + min(originEnergyLeft, originEnergyLimit, VMConfig.disableJavaLangMath()), + VMConfig.disableJavaLangMath()); } } if (VMConfig.allowTvmFreezeV2()) { @@ -740,7 +757,8 @@ public long getTotalEnergyLimitWithFixRatio(AccountCapsule creator, AccountCapsu receipt.setOriginEnergyMergedWindowSize(creator.getWindowSize(ENERGY)); rootRepository.updateAccount(creator.createDbKey(), creator); } - return Math.addExact(callerEnergyLimit, creatorEnergyLimit); + return addExact(callerEnergyLimit, creatorEnergyLimit, + VMConfig.disableJavaLangMath()); } private long getTotalEnergyLimitWithFloatRatio(AccountCapsule creator, AccountCapsule caller, @@ -756,13 +774,17 @@ private long getTotalEnergyLimitWithFloatRatio(AccountCapsule creator, AccountCa ContractCapsule contractCapsule = rootRepository .getContract(contract.getContractAddress().toByteArray()); - long consumeUserResourcePercent = contractCapsule.getConsumeUserResourcePercent(); + long consumeUserResourcePercent = contractCapsule.getConsumeUserResourcePercent( + VMConfig.disableJavaLangMath()); if (creatorEnergyLimit * consumeUserResourcePercent > (VMConstant.ONE_HUNDRED - consumeUserResourcePercent) * callerEnergyLimit) { - return Math.floorDiv(callerEnergyLimit * VMConstant.ONE_HUNDRED, consumeUserResourcePercent); + return floorDiv( + callerEnergyLimit * VMConstant.ONE_HUNDRED, consumeUserResourcePercent, + VMConfig.disableJavaLangMath()); } else { - return Math.addExact(callerEnergyLimit, creatorEnergyLimit); + return addExact(callerEnergyLimit, creatorEnergyLimit, + VMConfig.disableJavaLangMath()); } } diff --git a/actuator/src/main/java/org/tron/core/actuator/WitnessCreateActuator.java b/actuator/src/main/java/org/tron/core/actuator/WitnessCreateActuator.java index ee223a32ffa..fc908a1713f 100755 --- a/actuator/src/main/java/org/tron/core/actuator/WitnessCreateActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/WitnessCreateActuator.java @@ -6,7 +6,6 @@ import com.google.protobuf.InvalidProtocolBufferException; import java.util.Objects; import lombok.extern.slf4j.Slf4j; -import org.tron.common.utils.Commons; import org.tron.common.utils.DecodeUtil; import org.tron.common.utils.StringUtil; import org.tron.core.capsule.AccountCapsule; @@ -140,12 +139,11 @@ private void createWitness(final WitnessCreateContract witnessCreateContract) } accountStore.put(accountCapsule.createDbKey(), accountCapsule); long cost = dynamicStore.getAccountUpgradeCost(); - Commons - .adjustBalance(accountStore, witnessCreateContract.getOwnerAddress().toByteArray(), -cost); + adjustBalance(accountStore, witnessCreateContract.getOwnerAddress().toByteArray(), -cost); if (dynamicStore.supportBlackHoleOptimization()) { dynamicStore.burnTrx(cost); } else { - Commons.adjustBalance(accountStore, accountStore.getBlackhole(), +cost); + adjustBalance(accountStore, accountStore.getBlackhole(), +cost); } dynamicStore.addTotalCreateWitnessCost(cost); } diff --git a/actuator/src/main/java/org/tron/core/utils/ProposalUtil.java b/actuator/src/main/java/org/tron/core/utils/ProposalUtil.java index 0f55bbae9b7..0bad940da7e 100644 --- a/actuator/src/main/java/org/tron/core/utils/ProposalUtil.java +++ b/actuator/src/main/java/org/tron/core/utils/ProposalUtil.java @@ -1,5 +1,7 @@ package org.tron.core.utils; +import static org.tron.core.Constant.CREATE_ACCOUNT_TRANSACTION_MAX_BYTE_SIZE; +import static org.tron.core.Constant.CREATE_ACCOUNT_TRANSACTION_MIN_BYTE_SIZE; import static org.tron.core.Constant.DYNAMIC_ENERGY_INCREASE_FACTOR_RANGE; import static org.tron.core.Constant.DYNAMIC_ENERGY_MAX_FACTOR_RANGE; import static org.tron.core.config.Parameter.ChainConstant.ONE_YEAR_BLOCK_NUMBERS; @@ -728,6 +730,115 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore, } break; } + case ALLOW_OLD_REWARD_OPT: { + if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_7_4)) { + throw new ContractValidateException( + "Bad chain parameter id [ALLOW_OLD_REWARD_OPT]"); + } + if (dynamicPropertiesStore.allowOldRewardOpt()) { + throw new ContractValidateException( + "[ALLOW_OLD_REWARD_OPT] has been valid, no need to propose again"); + } + if (value != 1) { + throw new ContractValidateException( + "This value[ALLOW_OLD_REWARD_OPT] is only allowed to be 1"); + } + if (!dynamicPropertiesStore.useNewRewardAlgorithm()) { + throw new ContractValidateException( + "[ALLOW_NEW_REWARD] or [ALLOW_TVM_VOTE] proposal must be approved " + + "before [ALLOW_OLD_REWARD_OPT] can be proposed"); + } + break; + } + case ALLOW_ENERGY_ADJUSTMENT: { + if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_7_5)) { + throw new ContractValidateException( + "Bad chain parameter id [ALLOW_ENERGY_ADJUSTMENT]"); + } + if (dynamicPropertiesStore.getAllowEnergyAdjustment() == 1) { + throw new ContractValidateException( + "[ALLOW_ENERGY_ADJUSTMENT] has been valid, no need to propose again"); + } + if (value != 1) { + throw new ContractValidateException( + "This value[ALLOW_ENERGY_ADJUSTMENT] is only allowed to be 1"); + } + break; + } + case MAX_CREATE_ACCOUNT_TX_SIZE: { + if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_7_5)) { + throw new ContractValidateException( + "Bad chain parameter id [MAX_CREATE_ACCOUNT_TX_SIZE]"); + } + if (value < CREATE_ACCOUNT_TRANSACTION_MIN_BYTE_SIZE + || value > CREATE_ACCOUNT_TRANSACTION_MAX_BYTE_SIZE) { + throw new ContractValidateException( + "This value[MAX_CREATE_ACCOUNT_TX_SIZE] is only allowed to be greater than or equal " + + "to " + CREATE_ACCOUNT_TRANSACTION_MIN_BYTE_SIZE + " and less than or equal to " + + CREATE_ACCOUNT_TRANSACTION_MAX_BYTE_SIZE + "!"); + } + break; + } + case ALLOW_STRICT_MATH: { + if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_7_7)) { + throw new ContractValidateException( + "Bad chain parameter id [ALLOW_STRICT_MATH]"); + } + if (dynamicPropertiesStore.allowStrictMath()) { + throw new ContractValidateException( + "[ALLOW_STRICT_MATH] has been valid, no need to propose again"); + } + if (value != 1) { + throw new ContractValidateException( + "This value[ALLOW_STRICT_MATH] is only allowed to be 1"); + } + break; + } + case CONSENSUS_LOGIC_OPTIMIZATION: { + if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_8_0)) { + throw new ContractValidateException( + "Bad chain parameter id [CONSENSUS_LOGIC_OPTIMIZATION]"); + } + if (dynamicPropertiesStore.getConsensusLogicOptimization() == 1) { + throw new ContractValidateException( + "[CONSENSUS_LOGIC_OPTIMIZATION] has been valid, no need to propose again"); + } + if (value != 1) { + throw new ContractValidateException( + "This value[CONSENSUS_LOGIC_OPTIMIZATION] is only allowed to be 1"); + } + break; + } + case ALLOW_TVM_CANCUN: { + if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_8_0)) { + throw new ContractValidateException( + "Bad chain parameter id [ALLOW_TVM_CANCUN]"); + } + if (dynamicPropertiesStore.getAllowTvmCancun() == 1) { + throw new ContractValidateException( + "[ALLOW_TVM_CANCUN] has been valid, no need to propose again"); + } + if (value != 1) { + throw new ContractValidateException( + "This value[ALLOW_TVM_CANCUN] is only allowed to be 1"); + } + break; + } + case ALLOW_TVM_BLOB: { + if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_8_0)) { + throw new ContractValidateException( + "Bad chain parameter id [ALLOW_TVM_BLOB]"); + } + if (dynamicPropertiesStore.getAllowTvmBlob() == 1) { + throw new ContractValidateException( + "[ALLOW_TVM_BLOB] has been valid, no need to propose again"); + } + if (value != 1) { + throw new ContractValidateException( + "This value[ALLOW_TVM_BLOB] is only allowed to be 1"); + } + break; + } default: break; } @@ -803,7 +914,14 @@ public enum ProposalType { // current value, value range DYNAMIC_ENERGY_MAX_FACTOR(75), // 0, [0, 100_000] ALLOW_TVM_SHANGHAI(76), // 0, 1 ALLOW_CANCEL_ALL_UNFREEZE_V2(77), // 0, 1 - MAX_DELEGATE_LOCK_PERIOD(78); // (86400, 10512000] + MAX_DELEGATE_LOCK_PERIOD(78), // (86400, 10512000] + ALLOW_OLD_REWARD_OPT(79), // 0, 1 + ALLOW_ENERGY_ADJUSTMENT(81), // 0, 1 + MAX_CREATE_ACCOUNT_TX_SIZE(82), // [500, 10000] + ALLOW_TVM_CANCUN(83), // 0, 1 + ALLOW_STRICT_MATH(87), // 0, 1 + CONSENSUS_LOGIC_OPTIMIZATION(88), // 0, 1 + ALLOW_TVM_BLOB(89); // 0, 1 private long code; diff --git a/actuator/src/main/java/org/tron/core/utils/TransactionUtil.java b/actuator/src/main/java/org/tron/core/utils/TransactionUtil.java index 7044564b1e1..53d6caf5691 100644 --- a/actuator/src/main/java/org/tron/core/utils/TransactionUtil.java +++ b/actuator/src/main/java/org/tron/core/utils/TransactionUtil.java @@ -16,6 +16,7 @@ package org.tron.core.utils; import static org.tron.common.crypto.Hash.sha3omit12; +import static org.tron.common.math.Maths.max; import static org.tron.core.config.Parameter.ChainConstant.DELEGATE_COST_BASE_SIZE; import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION; @@ -39,7 +40,6 @@ import org.tron.common.parameter.CommonParameter; import org.tron.common.utils.Sha256Hash; import org.tron.core.ChainBaseManager; -import org.tron.core.Constant; import org.tron.core.capsule.AccountCapsule; import org.tron.core.capsule.TransactionCapsule; import org.tron.core.exception.PermissionException; @@ -52,7 +52,6 @@ import org.tron.protos.Protocol.Transaction.Result.contractResult; import org.tron.protos.contract.SmartContractOuterClass.CreateSmartContract; import org.tron.protos.contract.SmartContractOuterClass.TriggerSmartContract; -import org.tron.protos.Protocol.Transaction.Contract.ContractType; import org.tron.protos.contract.BalanceContract.DelegateResourceContract; @Slf4j(topic = "capsule") @@ -270,7 +269,7 @@ public static long estimateConsumeBandWidthSize(DynamicPropertiesStore dps, long DelegateResourceContract.Builder builder2 = DelegateResourceContract.newBuilder() .setBalance(TRX_PRECISION); long builder2Size = builder2.build().getSerializedSize(); - long addSize = Math.max(builderSize - builder2Size, 0L); + long addSize = max(builderSize - builder2Size, 0L, dps.disableJavaLangMath()); return DELEGATE_COST_BASE_SIZE + addSize; } diff --git a/actuator/src/main/java/org/tron/core/vm/EnergyCost.java b/actuator/src/main/java/org/tron/core/vm/EnergyCost.java index 3b62b2f549a..b758438c940 100644 --- a/actuator/src/main/java/org/tron/core/vm/EnergyCost.java +++ b/actuator/src/main/java/org/tron/core/vm/EnergyCost.java @@ -57,6 +57,8 @@ public class EnergyCost { private static final long SUICIDE = 0; private static final long STOP = 0; private static final long CREATE_DATA = 200; + private static final long TLOAD = 100; + private static final long TSTORE = 100; public static long getZeroTierCost(Program ignored) { return ZERO_TIER; @@ -232,6 +234,26 @@ public static long getSstoreCost(Program program) { } + public static long getTLoadCost(Program ignored) { + return TLOAD; + } + + public static long getTStoreCost(Program ignored) { + return TSTORE; + } + + public static long getMCopyCost(Program program) { + Stack stack = program.getStack(); + long oldMemSize = program.getMemSize(); + + DataWord dstOffset = stack.peek(); + DataWord srcOffset = stack.get(stack.size() - 2); + DataWord maxOffset = dstOffset.compareTo(srcOffset) > 0 ? dstOffset : srcOffset; + return VERY_LOW_TIER + calcMemEnergy(oldMemSize, + memNeeded(maxOffset, stack.get(stack.size() - 3)), + stack.get(stack.size() - 3).longValueSafe(), Op.MCOPY); + } + public static long getLogCost(Program program) { Stack stack = program.getStack(); long oldMemSize = program.getMemSize(); @@ -259,12 +281,19 @@ public static long getSuicideCost(Program ignored) { return SUICIDE; } + public static long getSuicideCost2(Program program) { + DataWord inheritorAddress = program.getStack().peek(); + if (isDeadAccount(program, inheritorAddress)) { + return getSuicideCost(program) + NEW_ACCT_CALL; + } + return getSuicideCost(program); + } + public static long getBalanceCost(Program ignored) { return BALANCE; } public static long getFreezeCost(Program program) { - Stack stack = program.getStack(); DataWord receiverAddressWord = stack.get(stack.size() - 3); if (isDeadAccount(program, receiverAddressWord)) { @@ -306,7 +335,27 @@ public static long getUnDelegateResourceCost(Program ignored) { } public static long getVoteWitnessCost(Program program) { + Stack stack = program.getStack(); + long oldMemSize = program.getMemSize(); + DataWord amountArrayLength = stack.get(stack.size() - 1).clone(); + DataWord amountArrayOffset = stack.get(stack.size() - 2); + DataWord witnessArrayLength = stack.get(stack.size() - 3).clone(); + DataWord witnessArrayOffset = stack.get(stack.size() - 4); + + DataWord wordSize = new DataWord(DataWord.WORD_SIZE); + + amountArrayLength.mul(wordSize); + BigInteger amountArrayMemoryNeeded = memNeeded(amountArrayOffset, amountArrayLength); + + witnessArrayLength.mul(wordSize); + BigInteger witnessArrayMemoryNeeded = memNeeded(witnessArrayOffset, witnessArrayLength); + + return VOTE_WITNESS + calcMemEnergy(oldMemSize, + (amountArrayMemoryNeeded.compareTo(witnessArrayMemoryNeeded) > 0 + ? amountArrayMemoryNeeded : witnessArrayMemoryNeeded), 0, Op.VOTEWITNESS); + } + public static long getVoteWitnessCost2(Program program) { Stack stack = program.getStack(); long oldMemSize = program.getMemSize(); DataWord amountArrayLength = stack.get(stack.size() - 1).clone(); @@ -317,9 +366,11 @@ public static long getVoteWitnessCost(Program program) { DataWord wordSize = new DataWord(DataWord.WORD_SIZE); amountArrayLength.mul(wordSize); + amountArrayLength.add(wordSize); // dynamic array length is at least 32 bytes BigInteger amountArrayMemoryNeeded = memNeeded(amountArrayOffset, amountArrayLength); witnessArrayLength.mul(wordSize); + witnessArrayLength.add(wordSize); // dynamic array length is at least 32 bytes BigInteger witnessArrayMemoryNeeded = memNeeded(witnessArrayOffset, witnessArrayLength); return VOTE_WITNESS + calcMemEnergy(oldMemSize, diff --git a/actuator/src/main/java/org/tron/core/vm/Op.java b/actuator/src/main/java/org/tron/core/vm/Op.java index f6987c12942..ed2d8eb2f53 100644 --- a/actuator/src/main/java/org/tron/core/vm/Op.java +++ b/actuator/src/main/java/org/tron/core/vm/Op.java @@ -120,6 +120,10 @@ public class Op { public static final int SELFBALANCE = 0x47; // (0x48) Get block's basefee public static final int BASEFEE = 0x48; + // (0x49) Get blob hash + public static final int BLOBHASH = 0x49; + // (0x4a) Get block's blob basefee + public static final int BLOBBASEFEE = 0x4a; /* Memory, Storage and Flow Operations */ // (0x50) Remove item from stack @@ -145,6 +149,12 @@ public class Op { // (0x5a) Get the amount of available gas public static final int GAS = 0x5a; public static final int JUMPDEST = 0x5b; + // (0x5c) Load word from transient storage + public static final int TLOAD = 0x5c; + // (0x5d) Save word to transient storage + public static final int TSTORE = 0x5d; + // (0x5e) Copy word from memory + public static final int MCOPY = 0x5e; /* Push Operations */ // Place item on stack diff --git a/actuator/src/main/java/org/tron/core/vm/OperationActions.java b/actuator/src/main/java/org/tron/core/vm/OperationActions.java index 5ed6ead075f..f10fb37dd7e 100644 --- a/actuator/src/main/java/org/tron/core/vm/OperationActions.java +++ b/actuator/src/main/java/org/tron/core/vm/OperationActions.java @@ -643,6 +643,51 @@ public static void jumpDestAction(Program program) { program.step(); } + public static void tLoadAction(Program program) { + DataWord key = program.stackPop(); + DataWord address = program.getContractAddress(); + + byte[] data = + program.getContractState().getTransientStorageValue(address.getData(), key.getData()); + DataWord value = data != null ? new DataWord(data).clone() : DataWord.ZERO(); + + program.stackPush(value); + program.step(); + } + + public static void tStoreAction(Program program) { + if (program.isStaticCall()) { + throw new Program.StaticCallModificationException(); + } + DataWord key = program.stackPop(); + DataWord value = program.stackPop(); + DataWord address = program.getContractAddress(); + + program.getContractState() + .updateTransientStorageValue(address.getData(), key.getData(), value.getData()); + program.step(); + } + + public static void mCopyAction(Program program) { + int dstOffset = program.stackPop().intValueSafe(); + int srcOffset = program.stackPop().intValueSafe(); + int length = program.stackPop().intValueSafe(); + + program.memoryCopy(dstOffset, srcOffset, length); + program.step(); + } + + public static void blobHashAction(Program program) { + program.stackPop(); + program.stackPush(DataWord.ZERO()); + program.step(); + } + + public static void blobBaseFeeAction(Program program) { + program.stackPush(DataWord.ZERO()); + program.step(); + } + public static void push0Action(Program program) { program.stackPush(DataWord.ZERO()); program.step(); @@ -989,6 +1034,9 @@ public static void exeCall(Program program, DataWord adjustedCallEnergy, PrecompiledContracts.PrecompiledContract contract = PrecompiledContracts.getContractForAddress(codeAddress); if (contract != null) { + if (program.isConstantCall()) { + contract = PrecompiledContracts.getOptimizedContractForConstant(contract); + } program.callToPrecompiledAddress(msg, contract); } else { program.callToAddress(msg); diff --git a/actuator/src/main/java/org/tron/core/vm/OperationRegistry.java b/actuator/src/main/java/org/tron/core/vm/OperationRegistry.java index e4b1e174702..be29238a775 100644 --- a/actuator/src/main/java/org/tron/core/vm/OperationRegistry.java +++ b/actuator/src/main/java/org/tron/core/vm/OperationRegistry.java @@ -12,6 +12,7 @@ public enum Version { TRON_V1_1, TRON_V1_2, TRON_V1_3, + TRON_V1_4, // add more // TRON_V2, // ETH @@ -24,6 +25,7 @@ public enum Version { tableMap.put(Version.TRON_V1_1, newTronV11OperationSet()); tableMap.put(Version.TRON_V1_2, newTronV12OperationSet()); tableMap.put(Version.TRON_V1_3, newTronV13OperationSet()); + tableMap.put(Version.TRON_V1_4, newTronV14OperationSet()); } public static JumpTable newTronV10OperationSet() { @@ -55,18 +57,28 @@ public static JumpTable newTronV13OperationSet() { return table; } + public static JumpTable newTronV14OperationSet() { + JumpTable table = newTronV13OperationSet(); + appendCancunOperations(table); + return table; + } + // Just for warming up class to avoid out_of_time public static void init() {} public static JumpTable getTable() { // always get the table which has the newest version - JumpTable table = tableMap.get(Version.TRON_V1_3); + JumpTable table = tableMap.get(Version.TRON_V1_4); // next make the corresponding changes, exclude activating opcode if (VMConfig.allowHigherLimitForMaxCpuTimeOfOneTx()) { adjustMemOperations(table); } + if (VMConfig.allowEnergyAdjustment()) { + adjustForFairEnergy(table); + } + return table; } @@ -635,4 +647,52 @@ public static void appendShangHaiOperations(JumpTable table) { OperationActions::push0Action, proposal)); } + + public static void adjustForFairEnergy(JumpTable table) { + table.set(new Operation( + Op.VOTEWITNESS, 4, 1, + EnergyCost::getVoteWitnessCost2, + OperationActions::voteWitnessAction, + VMConfig::allowTvmVote)); + + table.set(new Operation( + Op.SUICIDE, 1, 0, + EnergyCost::getSuicideCost2, + OperationActions::suicideAction)); + } + + public static void appendCancunOperations(JumpTable table) { + BooleanSupplier proposal = VMConfig::allowTvmCancun; + BooleanSupplier tvmBlobProposal = VMConfig::allowTvmBlob; + + table.set(new Operation( + Op.TLOAD, 1, 1, + EnergyCost::getTLoadCost, + OperationActions::tLoadAction, + proposal)); + + table.set(new Operation( + Op.TSTORE, 2, 0, + EnergyCost::getTStoreCost, + OperationActions::tStoreAction, + proposal)); + + table.set(new Operation( + Op.MCOPY, 3, 0, + EnergyCost::getMCopyCost, + OperationActions::mCopyAction, + proposal)); + + table.set(new Operation( + Op.BLOBHASH, 1, 1, + EnergyCost::getVeryLowTierCost, + OperationActions::blobHashAction, + tvmBlobProposal)); + + table.set(new Operation( + Op.BLOBBASEFEE, 0, 1, + EnergyCost::getBaseTierCost, + OperationActions::blobBaseFeeAction, + tvmBlobProposal)); + } } diff --git a/actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java b/actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java index be7b9423f5c..7913d7928fa 100644 --- a/actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java +++ b/actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java @@ -1,6 +1,8 @@ package org.tron.core.vm; import static java.util.Arrays.copyOfRange; +import static org.tron.common.math.Maths.max; +import static org.tron.common.math.Maths.min; import static org.tron.common.runtime.vm.DataWord.WORD_SIZE; import static org.tron.common.utils.BIUtil.addSafely; import static org.tron.common.utils.BIUtil.isLessThan; @@ -16,6 +18,8 @@ import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION; import com.google.protobuf.ByteString; + +import java.lang.reflect.Constructor; import java.math.BigInteger; import java.security.MessageDigest; import java.util.ArrayList; @@ -194,6 +198,14 @@ public class PrecompiledContracts { private static final DataWord blake2FAddr = new DataWord( "0000000000000000000000000000000000000000000000000000000000020009"); + public static PrecompiledContract getOptimizedContractForConstant(PrecompiledContract contract) { + try { + Constructor constructor = contract.getClass().getDeclaredConstructor(); + return (PrecompiledContracts.PrecompiledContract) constructor.newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } public static PrecompiledContract getContractForAddress(DataWord address) { @@ -614,14 +626,16 @@ public long getEnergyForData(byte[] data) { int expLen = parseLen(data, 1); int modLen = parseLen(data, 2); - byte[] expHighBytes = parseBytes(data, addSafely(ARGS_OFFSET, baseLen), Math.min(expLen, 32)); - long multComplexity = getMultComplexity(Math.max(baseLen, modLen)); + byte[] expHighBytes = parseBytes(data, addSafely(ARGS_OFFSET, baseLen), min(expLen, 32, + VMConfig.disableJavaLangMath())); + + long multComplexity = getMultComplexity(max(baseLen, modLen, VMConfig.disableJavaLangMath())); long adjExpLen = getAdjustedExponentLength(expHighBytes, expLen); // use big numbers to stay safe in case of overflow BigInteger energy = BigInteger.valueOf(multComplexity) - .multiply(BigInteger.valueOf(Math.max(adjExpLen, 1))) + .multiply(BigInteger.valueOf(max(adjExpLen, 1, VMConfig.disableJavaLangMath()))) .divide(GQUAD_DIVISOR); return isLessThan(energy, BigInteger.valueOf(Long.MAX_VALUE)) ? energy.longValueExact() diff --git a/actuator/src/main/java/org/tron/core/vm/VMConstant.java b/actuator/src/main/java/org/tron/core/vm/VMConstant.java index 4e7f6b29e3f..abbb6ae6d38 100644 --- a/actuator/src/main/java/org/tron/core/vm/VMConstant.java +++ b/actuator/src/main/java/org/tron/core/vm/VMConstant.java @@ -10,6 +10,8 @@ public class VMConstant { public static final int ONE_THOUSAND = 1000; public static final long SUN_PER_ENERGY = 100; + public static final String WITHDRAW_EXPIRE_BALANCE = "WithdrawExpireBalance"; + private VMConstant() { } } diff --git a/actuator/src/main/java/org/tron/core/vm/VMUtils.java b/actuator/src/main/java/org/tron/core/vm/VMUtils.java index abdf6c7fe4c..2f469e0579a 100644 --- a/actuator/src/main/java/org/tron/core/vm/VMUtils.java +++ b/actuator/src/main/java/org/tron/core/vm/VMUtils.java @@ -2,6 +2,7 @@ import static java.lang.String.format; import static org.apache.commons.codec.binary.Base64.encodeBase64String; +import static org.tron.common.math.Maths.addExact; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -12,7 +13,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; -import java.util.Map; import java.util.zip.Deflater; import java.util.zip.DeflaterOutputStream; import lombok.extern.slf4j.Slf4j; @@ -20,6 +20,7 @@ import org.tron.common.utils.ByteUtil; import org.tron.common.utils.Commons; import org.tron.common.utils.DecodeUtil; +import org.tron.core.Constant; import org.tron.core.capsule.AccountCapsule; import org.tron.core.exception.ContractValidateException; import org.tron.core.vm.config.VMConfig; @@ -33,6 +34,11 @@ public final class VMUtils { private VMUtils() { } + public static int getAddressSize() { + return VMConfig.allowEnergyAdjustment() ? + Constant.TRON_ADDRESS_SIZE : Constant.STANDARD_ADDRESS_SIZE; + } + public static void closeQuietly(Closeable closeable) { try { if (closeable != null) { @@ -164,7 +170,7 @@ public static boolean validateForSmartContract(Repository deposit, byte[] ownerA "Validate InternalTransfer error, balance is not sufficient."); } - Math.addExact(toAccount.getBalance(), amount); + addExact(toAccount.getBalance(), amount, VMConfig.disableJavaLangMath()); } catch (ArithmeticException e) { logger.debug(e.getMessage(), e); throw new ContractValidateException(e.getMessage()); @@ -225,7 +231,8 @@ public static boolean validateForSmartContract(Repository deposit, byte[] ownerA ByteArray.toStr(tokenIdWithoutLeadingZero)); if (assetBalance != null) { try { - assetBalance = Math.addExact(assetBalance, amount); //check if overflow + addExact(assetBalance, amount, + VMConfig.disableJavaLangMath()); //check if overflow } catch (Exception e) { logger.debug(e.getMessage(), e); throw new ContractValidateException(e.getMessage()); diff --git a/actuator/src/main/java/org/tron/core/vm/config/ConfigLoader.java b/actuator/src/main/java/org/tron/core/vm/config/ConfigLoader.java index 463d8c8995a..1ec8a75d669 100644 --- a/actuator/src/main/java/org/tron/core/vm/config/ConfigLoader.java +++ b/actuator/src/main/java/org/tron/core/vm/config/ConfigLoader.java @@ -39,6 +39,11 @@ public static void load(StoreFactory storeFactory) { VMConfig.initDynamicEnergyIncreaseFactor(ds.getDynamicEnergyIncreaseFactor()); VMConfig.initDynamicEnergyMaxFactor(ds.getDynamicEnergyMaxFactor()); VMConfig.initAllowTvmShangHai(ds.getAllowTvmShangHai()); + VMConfig.initAllowEnergyAdjustment(ds.getAllowEnergyAdjustment()); + VMConfig.initAllowStrictMath(ds.getAllowStrictMath()); + VMConfig.initAllowTvmCancun(ds.getAllowTvmCancun()); + VMConfig.initDisableJavaLangMath(ds.getConsensusLogicOptimization()); + VMConfig.initAllowTvmBlob(ds.getAllowTvmBlob()); } } } diff --git a/actuator/src/main/java/org/tron/core/vm/nativecontract/CancelAllUnfreezeV2Processor.java b/actuator/src/main/java/org/tron/core/vm/nativecontract/CancelAllUnfreezeV2Processor.java index 888071a177b..ec1f4363205 100644 --- a/actuator/src/main/java/org/tron/core/vm/nativecontract/CancelAllUnfreezeV2Processor.java +++ b/actuator/src/main/java/org/tron/core/vm/nativecontract/CancelAllUnfreezeV2Processor.java @@ -7,6 +7,8 @@ import static org.tron.protos.contract.Common.ResourceCode.BANDWIDTH; import static org.tron.protos.contract.Common.ResourceCode.ENERGY; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; import lombok.extern.slf4j.Slf4j; import org.tron.common.utils.DecodeUtil; @@ -14,6 +16,7 @@ import org.tron.core.capsule.AccountCapsule; import org.tron.core.exception.ContractExeException; import org.tron.core.exception.ContractValidateException; +import org.tron.core.vm.VMConstant; import org.tron.core.vm.nativecontract.param.CancelAllUnfreezeV2Param; import org.tron.core.vm.repository.Repository; import org.tron.protos.Protocol; @@ -38,13 +41,17 @@ public void validate(CancelAllUnfreezeV2Param param, Repository repo) throws Con } } - public long execute(CancelAllUnfreezeV2Param param, Repository repo) throws ContractExeException { + public Map execute(CancelAllUnfreezeV2Param param, Repository repo) throws ContractExeException { + Map result = new HashMap<>(); byte[] ownerAddress = param.getOwnerAddress(); AccountCapsule ownerCapsule = repo.getAccount(ownerAddress); long now = repo.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp(); long withdrawExpireBalance = 0L; for (Protocol.Account.UnFreezeV2 unFreezeV2: ownerCapsule.getUnfrozenV2List()) { if (unFreezeV2.getUnfreezeExpireTime() > now) { + String resourceName = unFreezeV2.getType().name(); + result.put(resourceName, result.getOrDefault(resourceName, 0L) + unFreezeV2.getUnfreezeAmount()); + updateFrozenInfoAndTotalResourceWeight(ownerCapsule, unFreezeV2, repo); } else { // withdraw @@ -57,7 +64,9 @@ public long execute(CancelAllUnfreezeV2Param param, Repository repo) throws Cont ownerCapsule.clearUnfrozenV2(); repo.updateAccount(ownerCapsule.createDbKey(), ownerCapsule); - return withdrawExpireBalance; + + result.put(VMConstant.WITHDRAW_EXPIRE_BALANCE, withdrawExpireBalance); + return result; } public void updateFrozenInfoAndTotalResourceWeight( diff --git a/actuator/src/main/java/org/tron/core/vm/nativecontract/DelegateResourceProcessor.java b/actuator/src/main/java/org/tron/core/vm/nativecontract/DelegateResourceProcessor.java index bb0d4e8297c..d03af04aaf3 100644 --- a/actuator/src/main/java/org/tron/core/vm/nativecontract/DelegateResourceProcessor.java +++ b/actuator/src/main/java/org/tron/core/vm/nativecontract/DelegateResourceProcessor.java @@ -10,7 +10,6 @@ import com.google.protobuf.ByteString; import java.util.Arrays; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ArrayUtils; import org.tron.common.utils.DecodeUtil; import org.tron.common.utils.StringUtil; import org.tron.core.ChainBaseManager; @@ -23,6 +22,7 @@ import org.tron.core.exception.ContractValidateException; import org.tron.core.store.DelegatedResourceAccountIndexStore; import org.tron.core.store.DynamicPropertiesStore; +import org.tron.core.vm.config.VMConfig; import org.tron.core.vm.nativecontract.param.DelegateResourceParam; import org.tron.core.vm.repository.Repository; import org.tron.protos.Protocol; @@ -54,6 +54,7 @@ public void validate(DelegateResourceParam param, Repository repo) throws Contra throw new ContractValidateException("delegateBalance must be greater than or equal to 1 TRX"); } + boolean disableJavaLangMath = VMConfig.disableJavaLangMath(); switch (param.getResourceType()) { case BANDWIDTH: { BandwidthProcessor processor = new BandwidthProcessor(ChainBaseManager.getInstance()); @@ -62,7 +63,7 @@ public void validate(DelegateResourceParam param, Repository repo) throws Contra long netUsage = (long) (ownerCapsule.getNetUsage() * TRX_PRECISION * ((double) (repo.getTotalNetWeight()) / dynamicStore.getTotalNetLimit())); - long v2NetUsage = getV2NetUsage(ownerCapsule, netUsage); + long v2NetUsage = getV2NetUsage(ownerCapsule, netUsage, disableJavaLangMath); if (ownerCapsule.getFrozenV2BalanceForBandwidth() - v2NetUsage < delegateBalance) { throw new ContractValidateException( @@ -78,7 +79,7 @@ public void validate(DelegateResourceParam param, Repository repo) throws Contra long energyUsage = (long) (ownerCapsule.getEnergyUsage() * TRX_PRECISION * ((double) (repo.getTotalEnergyWeight()) / dynamicStore.getTotalEnergyCurrentLimit())); - long v2EnergyUsage = getV2EnergyUsage(ownerCapsule, energyUsage); + long v2EnergyUsage = getV2EnergyUsage(ownerCapsule, energyUsage, disableJavaLangMath); if (ownerCapsule.getFrozenV2BalanceForEnergy() - v2EnergyUsage < delegateBalance) { throw new ContractValidateException( diff --git a/actuator/src/main/java/org/tron/core/vm/nativecontract/UnDelegateResourceProcessor.java b/actuator/src/main/java/org/tron/core/vm/nativecontract/UnDelegateResourceProcessor.java index d521e596e3e..99bcecdbd44 100644 --- a/actuator/src/main/java/org/tron/core/vm/nativecontract/UnDelegateResourceProcessor.java +++ b/actuator/src/main/java/org/tron/core/vm/nativecontract/UnDelegateResourceProcessor.java @@ -1,5 +1,6 @@ package org.tron.core.vm.nativecontract; +import static org.tron.common.math.Maths.min; import static org.tron.core.actuator.ActuatorConstant.ACCOUNT_EXCEPTION_STR; import static org.tron.core.actuator.ActuatorConstant.STORE_NOT_EXIST; import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION; @@ -21,6 +22,7 @@ import org.tron.core.exception.ContractValidateException; import org.tron.core.store.DelegatedResourceAccountIndexStore; import org.tron.core.store.DynamicPropertiesStore; +import org.tron.core.vm.config.VMConfig; import org.tron.core.vm.nativecontract.param.UnDelegateResourceParam; import org.tron.core.vm.repository.Repository; @@ -115,7 +117,7 @@ public void execute(UnDelegateResourceParam param, Repository repo) { * dynamicStore.getTotalNetLimit() / repo.getTotalNetWeight()); transferUsage = (long) (receiverCapsule.getNetUsage() * ((double) (unDelegateBalance) / receiverCapsule.getAllFrozenBalanceForBandwidth())); - transferUsage = Math.min(unDelegateMaxUsage, transferUsage); + transferUsage = min(unDelegateMaxUsage, transferUsage, VMConfig.disableJavaLangMath()); receiverCapsule.addAcquiredDelegatedFrozenV2BalanceForBandwidth(-unDelegateBalance); } @@ -139,7 +141,7 @@ public void execute(UnDelegateResourceParam param, Repository repo) { * dynamicStore.getTotalEnergyCurrentLimit() / repo.getTotalEnergyWeight()); transferUsage = (long) (receiverCapsule.getEnergyUsage() * ((double) (unDelegateBalance) / receiverCapsule.getAllFrozenBalanceForEnergy())); - transferUsage = Math.min(unDelegateMaxUsage, transferUsage); + transferUsage = min(unDelegateMaxUsage, transferUsage, VMConfig.disableJavaLangMath()); receiverCapsule.addAcquiredDelegatedFrozenV2BalanceForEnergy(-unDelegateBalance); } diff --git a/actuator/src/main/java/org/tron/core/vm/nativecontract/UnfreezeBalanceProcessor.java b/actuator/src/main/java/org/tron/core/vm/nativecontract/UnfreezeBalanceProcessor.java index 211784d279b..53981a22d34 100644 --- a/actuator/src/main/java/org/tron/core/vm/nativecontract/UnfreezeBalanceProcessor.java +++ b/actuator/src/main/java/org/tron/core/vm/nativecontract/UnfreezeBalanceProcessor.java @@ -136,10 +136,12 @@ public long execute(UnfreezeBalanceParam param, Repository repo) { if (receiverCapsule != null) { switch (param.getResourceType()) { case BANDWIDTH: - receiverCapsule.safeAddAcquiredDelegatedFrozenBalanceForBandwidth(-unfreezeBalance); + receiverCapsule.safeAddAcquiredDelegatedFrozenBalanceForBandwidth(-unfreezeBalance, + VMConfig.disableJavaLangMath()); break; case ENERGY: - receiverCapsule.safeAddAcquiredDelegatedFrozenBalanceForEnergy(-unfreezeBalance); + receiverCapsule.safeAddAcquiredDelegatedFrozenBalanceForEnergy(-unfreezeBalance, + VMConfig.disableJavaLangMath()); break; default: //this should never happen diff --git a/actuator/src/main/java/org/tron/core/vm/nativecontract/UnfreezeBalanceV2Processor.java b/actuator/src/main/java/org/tron/core/vm/nativecontract/UnfreezeBalanceV2Processor.java index 56366bbdb0c..af2cbf63a43 100644 --- a/actuator/src/main/java/org/tron/core/vm/nativecontract/UnfreezeBalanceV2Processor.java +++ b/actuator/src/main/java/org/tron/core/vm/nativecontract/UnfreezeBalanceV2Processor.java @@ -84,7 +84,7 @@ public void validate(UnfreezeBalanceV2Param param, Repository repo) if (!checkUnfreezeBalance(accountCapsule, param.getUnfreezeBalance(), param.getResourceType())) { throw new ContractValidateException( - "Invalid unfreeze_balance, [" + param.getUnfreezeBalance() + "] is error"); + "Invalid unfreeze_balance, [" + param.getUnfreezeBalance() + "] is invalid"); } } diff --git a/actuator/src/main/java/org/tron/core/vm/program/ContractState.java b/actuator/src/main/java/org/tron/core/vm/program/ContractState.java index 657558b3725..e095201e393 100644 --- a/actuator/src/main/java/org/tron/core/vm/program/ContractState.java +++ b/actuator/src/main/java/org/tron/core/vm/program/ContractState.java @@ -229,6 +229,11 @@ public void putDelegatedResourceAccountIndex(Key key, Value value) { repository.putDelegatedResourceAccountIndex(key, value); } + @Override + public void putTransientStorageValue(Key address, Key key, Value value) { + repository.putTransientStorageValue(address, key, value); + } + @Override public long addTokenBalance(byte[] address, byte[] tokenId, long value) { return repository.addTokenBalance(address, tokenId, value); @@ -314,6 +319,11 @@ public DelegatedResourceAccountIndexCapsule getDelegatedResourceAccountIndex(byt return repository.getDelegatedResourceAccountIndex(key); } + @Override + public byte[] getTransientStorageValue(byte[] address, byte[] key) { + return repository.getTransientStorageValue(address, key); + } + @Override public void updateDynamicProperty(byte[] word, BytesCapsule bytesCapsule) { repository.updateDynamicProperty(word, bytesCapsule); @@ -354,6 +364,11 @@ public void updateDelegatedResourceAccountIndex(byte[] word, DelegatedResourceAc repository.updateDelegatedResourceAccountIndex(word, delegatedResourceAccountIndexCapsule); } + @Override + public void updateTransientStorageValue(byte[] address, byte[] key, byte[] value) { + repository.updateTransientStorageValue(address, key, value); + } + @Override public void putDynamicProperty(Key key, Value value) { repository.putDynamicProperty(key, value); diff --git a/actuator/src/main/java/org/tron/core/vm/program/Memory.java b/actuator/src/main/java/org/tron/core/vm/program/Memory.java index e5cbebad2b9..4249a7e2634 100644 --- a/actuator/src/main/java/org/tron/core/vm/program/Memory.java +++ b/actuator/src/main/java/org/tron/core/vm/program/Memory.java @@ -1,14 +1,16 @@ package org.tron.core.vm.program; -import static java.lang.Math.ceil; -import static java.lang.Math.min; import static java.lang.String.format; +import static org.tron.common.math.Maths.addExact; +import static org.tron.common.math.Maths.ceil; +import static org.tron.common.math.Maths.min; import static org.tron.common.utils.ByteUtil.EMPTY_BYTE_ARRAY; import static org.tron.common.utils.ByteUtil.oneByteToHexString; import java.util.LinkedList; import java.util.List; import org.tron.common.runtime.vm.DataWord; +import org.tron.core.vm.config.VMConfig; import org.tron.core.vm.program.listener.ProgramListener; import org.tron.core.vm.program.listener.ProgramListenerAware; @@ -103,17 +105,17 @@ public void extend(int address, int size) { if (size <= 0) { return; } - - final int newSize = Math.addExact(address, size); + final int newSize = addExact(address, size, VMConfig.disableJavaLangMath()); int toAllocate = newSize - internalSize(); if (toAllocate > 0) { - addChunks((int) ceil((double) toAllocate / CHUNK_SIZE)); + addChunks((int) ceil((double) toAllocate / CHUNK_SIZE, VMConfig.disableJavaLangMath())); } toAllocate = newSize - softSize; if (toAllocate > 0) { - toAllocate = (int) ceil((double) toAllocate / WORD_SIZE) * WORD_SIZE; - softSize = Math.addExact(softSize, toAllocate); + toAllocate = (int) ceil((double) toAllocate / WORD_SIZE, + VMConfig.disableJavaLangMath()) * WORD_SIZE; + softSize = addExact(softSize, toAllocate, VMConfig.disableJavaLangMath()); if (programListener != null) { programListener.onMemoryExtend(toAllocate); @@ -181,10 +183,18 @@ public List getChunks() { return new LinkedList<>(chunks); } + public void copy(int destPos, int srcPos, int size) { + if (size <= 0) { + return; + } + byte[] data = read(srcPos, size); + write(destPos, data, size, false); + } + private int captureMax(int chunkIndex, int chunkOffset, int size, byte[] src, int srcPos) { byte[] chunk = chunks.get(chunkIndex); - int toCapture = min(size, chunk.length - chunkOffset); + int toCapture = min(size, chunk.length - chunkOffset, VMConfig.disableJavaLangMath()); System.arraycopy(src, srcPos, chunk, chunkOffset, toCapture); return toCapture; @@ -193,7 +203,7 @@ private int captureMax(int chunkIndex, int chunkOffset, int size, byte[] src, in private int grabMax(int chunkIndex, int chunkOffset, int size, byte[] dest, int destPos) { byte[] chunk = chunks.get(chunkIndex); - int toGrab = min(size, chunk.length - chunkOffset); + int toGrab = min(size, chunk.length - chunkOffset, VMConfig.disableJavaLangMath()); System.arraycopy(chunk, chunkOffset, dest, destPos, toGrab); diff --git a/actuator/src/main/java/org/tron/core/vm/program/Program.java b/actuator/src/main/java/org/tron/core/vm/program/Program.java index e02ba225c6b..5da0b02ecb7 100644 --- a/actuator/src/main/java/org/tron/core/vm/program/Program.java +++ b/actuator/src/main/java/org/tron/core/vm/program/Program.java @@ -1,12 +1,15 @@ package org.tron.core.vm.program; -import static java.lang.StrictMath.min; import static java.lang.String.format; import static org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY; import static org.apache.commons.lang3.ArrayUtils.getLength; import static org.apache.commons.lang3.ArrayUtils.isEmpty; import static org.apache.commons.lang3.ArrayUtils.isNotEmpty; import static org.apache.commons.lang3.ArrayUtils.nullToEmpty; +import static org.tron.common.math.Maths.addExact; +import static org.tron.common.math.Maths.max; +import static org.tron.common.math.Maths.min; +import static org.tron.common.math.Maths.multiplyExact; import static org.tron.common.utils.ByteUtil.stripLeadingZeroes; import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION; import static org.tron.protos.contract.Common.ResourceCode.BANDWIDTH; @@ -159,11 +162,13 @@ public Program(byte[] ops, byte[] codeAddress, ProgramInvoke programInvoke, this.nonce = internalTransaction.getNonce(); } + @SuppressWarnings("unused") static String formatBinData(byte[] binData, int startPC) { StringBuilder ret = new StringBuilder(); for (int i = 0; i < binData.length; i += 16) { ret.append(Utils.align("" + Integer.toHexString(startPC + (i)) + ":", ' ', 8, false)); - ret.append(Hex.toHexString(binData, i, min(16, binData.length - i))).append('\n'); + ret.append(Hex.toHexString(binData, i, min(16, binData.length - i, + VMConfig.disableJavaLangMath()))).append('\n'); } return ret.toString(); } @@ -275,6 +280,10 @@ public void setLastOp(byte op) { this.lastOp = op; } + public byte getLastOp() { + return this.lastOp; + } + /** * Returns the last fully executed OP. */ @@ -425,6 +434,10 @@ public byte[] memoryChunk(int offset, int size) { return memory.read(offset, size); } + public void memoryCopy(int dst, int src, int size) { + memory.copy(dst, src, size); + } + /** * . Allocates extra memory in the program for a specified size, calculated from a given offset * @@ -457,7 +470,8 @@ public void suicide(DataWord obtainerAddress) { InternalTransaction internalTx = addInternalTx(null, owner, obtainer, balance, null, "suicide", nonce, getContractState().getAccount(owner).getAssetMapV2()); - if (FastByteComparisons.compareTo(owner, 0, 20, obtainer, 0, 20) == 0) { + int ADDRESS_SIZE = VMUtils.getAddressSize(); + if (FastByteComparisons.compareTo(owner, 0, ADDRESS_SIZE, obtainer, 0, ADDRESS_SIZE) == 0) { // if owner == obtainer just zeroing account according to Yellow Paper getContractState().addBalance(owner, -balance); byte[] blackHoleAddress = getContractState().getBlackHoleAddress(); @@ -624,7 +638,7 @@ private void withdrawRewardAndCancelVote(byte[] owner, Repository repo) { long balance = ownerCapsule.getBalance(); long allowance = ownerCapsule.getAllowance(); ownerCapsule.setInstance(ownerCapsule.getInstance().toBuilder() - .setBalance(Math.addExact(balance, allowance)) + .setBalance(addExact(balance, allowance, VMConfig.disableJavaLangMath())) .setAllowance(0) .setLatestWithdrawTime(getTimestamp().longValue() * 1000) .build()); @@ -1222,7 +1236,8 @@ public DataWord getContractAddress() { public DataWord getBlockHash(int index) { if (index < this.getNumber().longValue() - && index >= Math.max(256, this.getNumber().longValue()) - 256) { + && index >= max(256, this.getNumber().longValue(), + VMConfig.disableJavaLangMath()) - 256) { BlockCapsule blockCapsule = contractState.getBlockByNum(index); @@ -1991,13 +2006,22 @@ public boolean cancelAllUnfreezeV2Action() { CancelAllUnfreezeV2Processor processor = new CancelAllUnfreezeV2Processor(); processor.validate(param, repository); - long withdrawExpireBalance = processor.execute(param, repository); + Map result = processor.execute(param, repository); repository.commit(); - if (withdrawExpireBalance > 0) { + + if (result.get(VMConstant.WITHDRAW_EXPIRE_BALANCE) > 0) { increaseNonce(); - addInternalTx(null, owner, owner, withdrawExpireBalance, null, + addInternalTx(null, owner, owner, result.get(VMConstant.WITHDRAW_EXPIRE_BALANCE), null, "withdrawExpireUnfreezeWhileCanceling", nonce, null); } + + if (internalTx != null && CommonParameter.getInstance().saveCancelAllUnfreezeV2Details) { + internalTx.setExtra(String.format("{\"%s\":%d,\"%s\":%d,\"%s\":%d}", + BANDWIDTH.name(), result.getOrDefault(BANDWIDTH.name(), 0L), + ENERGY.name(), result.getOrDefault(ENERGY.name(), 0L), + TRON_POWER.name(), result.getOrDefault(TRON_POWER.name(), 0L))); + } + return true; } catch (ContractValidateException e) { logger.warn("TVM CancelAllUnfreezeV2: validate failure. Reason: {}", e.getMessage()); @@ -2146,11 +2170,12 @@ public boolean voteWitness(int witnessArrayOffset, int witnessArrayLength, try { VoteWitnessParam param = new VoteWitnessParam(); param.setVoterAddress(owner); - - byte[] witnessArrayData = memoryChunk(Math.addExact(witnessArrayOffset, DataWord.WORD_SIZE), - Math.multiplyExact(witnessArrayLength, DataWord.WORD_SIZE)); - byte[] amountArrayData = memoryChunk(Math.addExact(amountArrayOffset, DataWord.WORD_SIZE), - Math.multiplyExact(amountArrayLength, DataWord.WORD_SIZE)); + byte[] witnessArrayData = memoryChunk( + addExact(witnessArrayOffset, DataWord.WORD_SIZE, VMConfig.disableJavaLangMath()), + multiplyExact(witnessArrayLength, DataWord.WORD_SIZE, VMConfig.disableJavaLangMath())); + byte[] amountArrayData = memoryChunk( + addExact(amountArrayOffset, DataWord.WORD_SIZE, VMConfig.disableJavaLangMath()), + multiplyExact(amountArrayLength, DataWord.WORD_SIZE, VMConfig.disableJavaLangMath())); for (int i = 0; i < witnessArrayLength; i++) { DataWord witness = new DataWord(Arrays.copyOfRange(witnessArrayData, @@ -2225,7 +2250,9 @@ public long updateContextContractFactor() { contractState.getDynamicPropertiesStore().getCurrentCycleNumber(), VMConfig.getDynamicEnergyThreshold(), VMConfig.getDynamicEnergyIncreaseFactor(), - VMConfig.getDynamicEnergyMaxFactor())) { + VMConfig.getDynamicEnergyMaxFactor(), + VMConfig.allowStrictMath(), + VMConfig.disableJavaLangMath())) { contractState.updateContractState(getContextAddress(), contractStateCapsule ); } diff --git a/actuator/src/main/java/org/tron/core/vm/program/invoke/ProgramInvokeMockImpl.java b/actuator/src/main/java/org/tron/core/vm/program/invoke/ProgramInvokeMockImpl.java index e22c5d06578..567ac72931a 100644 --- a/actuator/src/main/java/org/tron/core/vm/program/invoke/ProgramInvokeMockImpl.java +++ b/actuator/src/main/java/org/tron/core/vm/program/invoke/ProgramInvokeMockImpl.java @@ -210,6 +210,10 @@ public void setOwnerAddress(byte[] ownerAddress) { this.ownerAddress = Arrays.clone(ownerAddress); } + public void setStaticCall(boolean isStatic) { + isStaticCall = isStatic; + } + @Override public boolean isStaticCall() { return isStaticCall; diff --git a/actuator/src/main/java/org/tron/core/vm/repository/Repository.java b/actuator/src/main/java/org/tron/core/vm/repository/Repository.java index b4324bb8d18..664ee26ee92 100644 --- a/actuator/src/main/java/org/tron/core/vm/repository/Repository.java +++ b/actuator/src/main/java/org/tron/core/vm/repository/Repository.java @@ -41,6 +41,8 @@ public interface Repository { DelegatedResourceAccountIndexCapsule getDelegatedResourceAccountIndex(byte[] key); + byte[] getTransientStorageValue(byte[] address, byte[] key); + void deleteContract(byte[] address); void createContract(byte[] address, ContractCapsule contractCapsule); @@ -71,6 +73,8 @@ public interface Repository { void updateDelegatedResourceAccountIndex(byte[] word, DelegatedResourceAccountIndexCapsule delegatedResourceAccountIndexCapsule); + void updateTransientStorageValue(byte[] address, byte[] key, byte[] value); + void saveCode(byte[] address, byte[] code); byte[] getCode(byte[] address); @@ -113,6 +117,8 @@ public interface Repository { void putDelegatedResourceAccountIndex(Key key, Value value); + void putTransientStorageValue(Key address, Key key, Value value); + long addTokenBalance(byte[] address, byte[] tokenId, long value); long getTokenBalance(byte[] address, byte[] tokenId); diff --git a/actuator/src/main/java/org/tron/core/vm/repository/RepositoryImpl.java b/actuator/src/main/java/org/tron/core/vm/repository/RepositoryImpl.java index 50fa5385c23..a064cbf6c8a 100644 --- a/actuator/src/main/java/org/tron/core/vm/repository/RepositoryImpl.java +++ b/actuator/src/main/java/org/tron/core/vm/repository/RepositoryImpl.java @@ -1,9 +1,12 @@ package org.tron.core.vm.repository; -import static java.lang.Long.max; +import static org.tron.common.math.Maths.addExact; +import static org.tron.common.math.Maths.max; +import static org.tron.common.math.Maths.round; import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCED_INTERVAL; import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION; +import com.google.common.collect.HashBasedTable; import com.google.protobuf.ByteString; import java.util.HashMap; import java.util.Optional; @@ -131,6 +134,7 @@ public class RepositoryImpl implements Repository { private final HashMap> votesCache = new HashMap<>(); private final HashMap> delegationCache = new HashMap<>(); private final HashMap> delegatedResourceAccountIndexCache = new HashMap<>(); + private final HashBasedTable> transientStorage = HashBasedTable.create(); public static void removeLruCache(byte[] address) { } @@ -185,7 +189,7 @@ public long getAccountLeftEnergyFromFreeze(AccountCapsule accountCapsule) { long newEnergyUsage = recover(energyUsage, latestConsumeTime, now, windowSize); - return max(energyLimit - newEnergyUsage, 0); // us + return max(energyLimit - newEnergyUsage, 0, VMConfig.disableJavaLangMath()); // us } @Override @@ -442,6 +446,27 @@ public DelegatedResourceAccountIndexCapsule getDelegatedResourceAccountIndex(byt return delegatedResourceAccountIndexCapsule; } + public byte[] getTransientStorageValue(byte[] address, byte[] key) { + Key cacheAddress = new Key(address); + Key cacheKey = new Key(key); + if (transientStorage.contains(cacheAddress, cacheKey)) { + return transientStorage.get(cacheAddress, cacheKey).getValue(); + } + + byte[] value; + if (parent != null) { + value = parent.getTransientStorageValue(address, key); + } else { + value = null; + } + + if (value != null) { + transientStorage.put(cacheAddress, cacheKey, Value.create(value)); + } + + return value; + } + @Override public void deleteContract(byte[] address) { @@ -565,6 +590,11 @@ public void updateDelegatedResourceAccountIndex( Key.create(word), Value.create(delegatedResourceAccountIndexCapsule, Type.DIRTY)); } + @Override + public void updateTransientStorageValue(byte[] address, byte[] key, byte[] value) { + transientStorage.put(Key.create(address), Key.create(key), Value.create(value, Type.DIRTY)); + } + @Override public void saveCode(byte[] address, byte[] code) { codeCache.put(Key.create(address), Value.create(code, Type.CREATE)); @@ -681,7 +711,7 @@ public long addBalance(byte[] address, long value) { StringUtil.createReadableString(accountCapsule.createDbKey()) + " insufficient balance"); } - accountCapsule.setBalance(Math.addExact(balance, value)); + accountCapsule.setBalance(addExact(balance, value, VMConfig.disableJavaLangMath())); Key key = Key.create(address); accountCache.put(key, Value.create(accountCapsule, accountCache.get(key).getType().addType(Type.DIRTY))); @@ -709,6 +739,7 @@ public void commit() { commitVotesCache(repository); commitDelegationCache(repository); commitDelegatedResourceAccountIndexCache(repository); + commitTransientStorage(repository); } @Override @@ -767,6 +798,11 @@ public void putDelegatedResourceAccountIndex(Key key, Value value) { delegatedResourceAccountIndexCache.put(key, value); } + @Override + public void putTransientStorageValue(Key address, Key key, Value value) { + transientStorage.put(address, key, value); + } + @Override public long addTokenBalance(byte[] address, byte[] tokenId, long value) { byte[] tokenIdWithoutLeadingZero = ByteUtil.stripLeadingZeroes(tokenId); @@ -841,7 +877,7 @@ private long increase(long lastUsage, long usage, long lastTime, long now, long if (lastTime + windowSize > now) { long delta = now - lastTime; double decay = (windowSize - delta) / (double) windowSize; - averageLastUsage = Math.round(averageLastUsage * decay); + averageLastUsage = round(averageLastUsage * decay, VMConfig.disableJavaLangMath()); } else { averageLastUsage = 0; } @@ -1013,6 +1049,17 @@ private void commitDelegatedResourceAccountIndexCache(Repository deposit) { })); } + public void commitTransientStorage(Repository deposit) { + if (deposit != null) { + transientStorage.cellSet().forEach(cell -> { + if (cell.getValue().getType().isDirty() || cell.getValue().getType().isCreate()) { + deposit.putTransientStorageValue( + cell.getRowKey(), cell.getColumnKey(), cell.getValue()); + } + }); + } + } + /** * Get the block id from the number. */ diff --git a/actuator/src/main/java/org/tron/core/vm/utils/FreezeV2Util.java b/actuator/src/main/java/org/tron/core/vm/utils/FreezeV2Util.java index 7bc760f9edf..762d9318e7b 100644 --- a/actuator/src/main/java/org/tron/core/vm/utils/FreezeV2Util.java +++ b/actuator/src/main/java/org/tron/core/vm/utils/FreezeV2Util.java @@ -1,5 +1,8 @@ package org.tron.core.vm.utils; +import static org.tron.common.math.Maths.max; +import static org.tron.common.math.Maths.min; + import java.util.List; import java.util.stream.Collectors; @@ -132,7 +135,8 @@ public static long queryAvailableUnfreezeV2Size(byte[] address, Repository repos long now = repository.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp(); int unfreezingV2Count = accountCapsule.getUnfreezingV2Count(now); - return Long.max(UnfreezeBalanceV2Actuator.getUNFREEZE_MAX_TIMES() - unfreezingV2Count, 0L); + return max(UnfreezeBalanceV2Actuator.getUNFREEZE_MAX_TIMES() - unfreezingV2Count, 0L, + VMConfig.disableJavaLangMath()); } public static long queryDelegatableResource(byte[] address, long type, Repository repository) { @@ -161,8 +165,8 @@ public static long queryDelegatableResource(byte[] address, long type, Repositor return frozenV2Resource; } - long v2NetUsage = getV2NetUsage(accountCapsule, usage); - return Math.max(0L, frozenV2Resource - v2NetUsage); + long v2NetUsage = getV2NetUsage(accountCapsule, usage, VMConfig.disableJavaLangMath()); + return max(0L, frozenV2Resource - v2NetUsage, VMConfig.disableJavaLangMath()); } if (type == 1) { @@ -181,8 +185,8 @@ public static long queryDelegatableResource(byte[] address, long type, Repositor return frozenV2Resource; } - long v2EnergyUsage = getV2EnergyUsage(accountCapsule, usage); - return Math.max(0L, frozenV2Resource - v2EnergyUsage); + long v2EnergyUsage = getV2EnergyUsage(accountCapsule, usage, VMConfig.disableJavaLangMath()); + return max(0L, frozenV2Resource - v2EnergyUsage, VMConfig.disableJavaLangMath()); } return 0L; @@ -218,7 +222,7 @@ public static Triple checkUndelegateResource(byte[] address, l return Triple.of(0L, 0L, 0L); } - amount = Math.min(amount, resourceLimit); + amount = min(amount, resourceLimit, VMConfig.disableJavaLangMath()); if (resourceLimit <= usagePair.getLeft()) { return Triple.of(0L, amount, usagePair.getRight()); } @@ -238,20 +242,22 @@ private static List getTotalWithdrawList(List= Math - .ceil((double) versionEnum.getHardForkRate() * stats.length / 100); + return count >= ceil((double) versionEnum.getHardForkRate() * stats.length / 100, + manager.getDynamicPropertiesStore().disableJavaLangMath()); } diff --git a/chainbase/src/main/java/org/tron/core/ChainBaseManager.java b/chainbase/src/main/java/org/tron/core/ChainBaseManager.java index e43d442534a..21f0bac8d77 100644 --- a/chainbase/src/main/java/org/tron/core/ChainBaseManager.java +++ b/chainbase/src/main/java/org/tron/core/ChainBaseManager.java @@ -244,6 +244,10 @@ public class ChainBaseManager { @Setter private long lowestBlockNum = -1; // except num = 0. + @Getter + @Setter + private long latestSaveBlockTime; + // for test only public List getWitnesses() { return witnessScheduleStore.getActiveWitnesses(); @@ -376,11 +380,21 @@ public static synchronized void init(ChainBaseManager manager) { AssetUtil.setDynamicPropertiesStore(manager.getDynamicPropertiesStore()); } + public long getNextBlockSlotTime() { + long slotCount = 1; + if (dynamicPropertiesStore.getStateFlag() == 1) { + slotCount += dynamicPropertiesStore.getMaintenanceSkipSlots(); + } + return dynamicPropertiesStore.getLatestBlockHeaderTimestamp() + + slotCount * BLOCK_PRODUCED_INTERVAL; + } + @PostConstruct private void init() { this.lowestBlockNum = this.blockIndexStore.getLimitNumber(1, 1).stream() .map(BlockId::getNum).findFirst().orElse(0L); this.nodeType = getLowestBlockNum() > 1 ? NodeType.LITE : NodeType.FULL; + this.latestSaveBlockTime = System.currentTimeMillis(); } public void shutdown() { diff --git a/chainbase/src/main/java/org/tron/core/capsule/AccountCapsule.java b/chainbase/src/main/java/org/tron/core/capsule/AccountCapsule.java index b60fed63cda..1af7b55c8b2 100644 --- a/chainbase/src/main/java/org/tron/core/capsule/AccountCapsule.java +++ b/chainbase/src/main/java/org/tron/core/capsule/AccountCapsule.java @@ -15,9 +15,23 @@ package org.tron.core.capsule; +import static org.tron.common.math.Maths.addExact; +import static org.tron.common.math.Maths.max; +import static org.tron.common.math.Maths.subtractExact; +import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCED_INTERVAL; +import static org.tron.core.config.Parameter.ChainConstant.WINDOW_SIZE_MS; +import static org.tron.core.config.Parameter.ChainConstant.WINDOW_SIZE_PRECISION; +import static org.tron.protos.contract.Common.ResourceCode; +import static org.tron.protos.contract.Common.ResourceCode.BANDWIDTH; +import static org.tron.protos.contract.Common.ResourceCode.ENERGY; +import static org.tron.protos.contract.Common.ResourceCode.TRON_POWER; + import com.google.common.collect.Maps; import com.google.protobuf.ByteString; import com.google.protobuf.InvalidProtocolBufferException; +import java.util.List; +import java.util.Map; +import java.util.Objects; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.tron.common.utils.ByteArray; @@ -27,8 +41,8 @@ import org.tron.protos.Protocol.Account; import org.tron.protos.Protocol.Account.AccountResource; import org.tron.protos.Protocol.Account.Builder; -import org.tron.protos.Protocol.Account.Frozen; import org.tron.protos.Protocol.Account.FreezeV2; +import org.tron.protos.Protocol.Account.Frozen; import org.tron.protos.Protocol.Account.UnFreezeV2; import org.tron.protos.Protocol.AccountType; import org.tron.protos.Protocol.Key; @@ -38,19 +52,6 @@ import org.tron.protos.contract.AccountContract.AccountCreateContract; import org.tron.protos.contract.AccountContract.AccountUpdateContract; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static java.lang.Math.ceil; -import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCED_INTERVAL; -import static org.tron.core.config.Parameter.ChainConstant.WINDOW_SIZE_MS; -import static org.tron.core.config.Parameter.ChainConstant.WINDOW_SIZE_PRECISION; -import static org.tron.protos.contract.Common.ResourceCode.BANDWIDTH; -import static org.tron.protos.contract.Common.ResourceCode.ENERGY; -import static org.tron.protos.contract.Common.ResourceCode.TRON_POWER; -import static org.tron.protos.contract.Common.ResourceCode; - @Slf4j(topic = "capsule") public class AccountCapsule implements ProtoCapsule, Comparable { @@ -401,15 +402,18 @@ public void addAcquiredDelegatedFrozenV2BalanceForBandwidth(long balance) { this.account.getAcquiredDelegatedFrozenV2BalanceForBandwidth() + balance).build(); } - public void safeAddAcquiredDelegatedFrozenBalanceForBandwidth(long balance) { + public void safeAddAcquiredDelegatedFrozenBalanceForBandwidth(long balance, boolean useStrict) { this.account = this.account.toBuilder().setAcquiredDelegatedFrozenBalanceForBandwidth( - Math.max(0, this.account.getAcquiredDelegatedFrozenBalanceForBandwidth() + balance)) + max(0, this.account.getAcquiredDelegatedFrozenBalanceForBandwidth() + balance, + useStrict)) .build(); } - public void safeAddAcquiredDelegatedFrozenV2BalanceForBandwidth(long balance) { + @SuppressWarnings("unused") + public void safeAddAcquiredDelegatedFrozenV2BalanceForBandwidth(long balance, boolean useStrict) { this.account = this.account.toBuilder().setAcquiredDelegatedFrozenV2BalanceForBandwidth( - Math.max(0, this.account.getAcquiredDelegatedFrozenV2BalanceForBandwidth() + balance)) + max(0, this.account.getAcquiredDelegatedFrozenV2BalanceForBandwidth() + balance, + useStrict)) .build(); } @@ -496,10 +500,11 @@ public void addAcquiredDelegatedFrozenV2BalanceForEnergy(long balance) { this.account = this.account.toBuilder().setAccountResource(newAccountResource).build(); } - public void safeAddAcquiredDelegatedFrozenBalanceForEnergy(long balance) { + public void safeAddAcquiredDelegatedFrozenBalanceForEnergy(long balance, boolean useStrict) { AccountResource newAccountResource = getAccountResource().toBuilder() .setAcquiredDelegatedFrozenBalanceForEnergy( - Math.max(0, getAccountResource().getAcquiredDelegatedFrozenBalanceForEnergy() + balance)) + max(0, getAccountResource().getAcquiredDelegatedFrozenBalanceForEnergy() + balance, + useStrict)) .build(); this.account = this.account.toBuilder() @@ -507,10 +512,11 @@ public void safeAddAcquiredDelegatedFrozenBalanceForEnergy(long balance) { .build(); } - public void safeAddAcquiredDelegatedFrozenV2BalanceForEnergy(long balance) { + @SuppressWarnings("unused") + public void safeAddAcquiredDelegatedFrozenV2BalanceForEnergy(long balance, boolean useStrict) { AccountResource newAccountResource = getAccountResource().toBuilder() - .setAcquiredDelegatedFrozenV2BalanceForEnergy(Math.max(0, getAccountResource() - .getAcquiredDelegatedFrozenV2BalanceForEnergy() + balance)).build(); + .setAcquiredDelegatedFrozenV2BalanceForEnergy(max(0, getAccountResource() + .getAcquiredDelegatedFrozenV2BalanceForEnergy() + balance, useStrict)).build(); this.account = this.account.toBuilder().setAccountResource(newAccountResource).build(); } @@ -711,14 +717,15 @@ public boolean assetBalanceEnoughV2(byte[] key, long amount, return amount > 0 && null != currentAmount && amount <= currentAmount; } - public boolean addAssetAmount(byte[] key, long amount) { + public boolean addAssetAmount(byte[] key, long amount, boolean useStrict) { Map assetMap = this.account.getAssetMap(); String nameKey = ByteArray.toStr(key); Long currentAmount = assetMap.get(nameKey); if (currentAmount == null) { currentAmount = 0L; } - this.account = this.account.toBuilder().putAsset(nameKey, Math.addExact(currentAmount, amount)) + this.account = this.account.toBuilder().putAsset(nameKey, + addExact(currentAmount, amount, useStrict)) .build(); return true; } @@ -726,6 +733,7 @@ public boolean addAssetAmount(byte[] key, long amount) { public boolean addAssetAmountV2(byte[] key, long amount, DynamicPropertiesStore dynamicPropertiesStore, AssetIssueStore assetIssueStore) { importAsset(key); + boolean disableJavaLangMath = dynamicPropertiesStore.disableJavaLangMath(); //key is token name if (dynamicPropertiesStore.getAllowSameTokenName() == 0) { Map assetMap = this.account.getAssetMap(); @@ -737,8 +745,8 @@ public boolean addAssetAmountV2(byte[] key, long amount, currentAmount = 0L; } this.account = this.account.toBuilder() - .putAsset(nameKey, Math.addExact(currentAmount, amount)) - .putAssetV2(tokenID, Math.addExact(currentAmount, amount)) + .putAsset(nameKey, addExact(currentAmount, amount, disableJavaLangMath)) + .putAssetV2(tokenID, addExact(currentAmount, amount, disableJavaLangMath)) .build(); } //key is token id @@ -750,19 +758,19 @@ public boolean addAssetAmountV2(byte[] key, long amount, currentAmount = 0L; } this.account = this.account.toBuilder() - .putAssetV2(tokenIDStr, Math.addExact(currentAmount, amount)) + .putAssetV2(tokenIDStr, addExact(currentAmount, amount, disableJavaLangMath)) .build(); } return true; } - public boolean reduceAssetAmount(byte[] key, long amount) { + public boolean reduceAssetAmount(byte[] key, long amount, boolean disableJavaLangMath) { Map assetMap = this.account.getAssetMap(); String nameKey = ByteArray.toStr(key); Long currentAmount = assetMap.get(nameKey); if (amount > 0 && null != currentAmount && amount <= currentAmount) { this.account = this.account.toBuilder() - .putAsset(nameKey, Math.subtractExact(currentAmount, amount)).build(); + .putAsset(nameKey, subtractExact(currentAmount, amount, disableJavaLangMath)).build(); return true; } @@ -773,6 +781,7 @@ public boolean reduceAssetAmountV2(byte[] key, long amount, DynamicPropertiesStore dynamicPropertiesStore, AssetIssueStore assetIssueStore) { importAsset(key); //key is token name + boolean disableJavaLangMath = dynamicPropertiesStore.disableJavaLangMath(); if (dynamicPropertiesStore.getAllowSameTokenName() == 0) { Map assetMap = this.account.getAssetMap(); AssetIssueCapsule assetIssueCapsule = assetIssueStore.get(key); @@ -781,8 +790,8 @@ public boolean reduceAssetAmountV2(byte[] key, long amount, Long currentAmount = assetMap.get(nameKey); if (amount > 0 && null != currentAmount && amount <= currentAmount) { this.account = this.account.toBuilder() - .putAsset(nameKey, Math.subtractExact(currentAmount, amount)) - .putAssetV2(tokenID, Math.subtractExact(currentAmount, amount)) + .putAsset(nameKey, subtractExact(currentAmount, amount, disableJavaLangMath)) + .putAssetV2(tokenID, subtractExact(currentAmount, amount, disableJavaLangMath)) .build(); return true; } @@ -794,7 +803,7 @@ public boolean reduceAssetAmountV2(byte[] key, long amount, Long currentAmount = assetMapV2.get(tokenID); if (amount > 0 && null != currentAmount && amount <= currentAmount) { this.account = this.account.toBuilder() - .putAssetV2(tokenID, Math.subtractExact(currentAmount, amount)) + .putAssetV2(tokenID, subtractExact(currentAmount, amount, disableJavaLangMath)) .build(); return true; } diff --git a/chainbase/src/main/java/org/tron/core/capsule/BlockCapsule.java b/chainbase/src/main/java/org/tron/core/capsule/BlockCapsule.java index 8baafcb5dd5..01ff7fb5365 100755 --- a/chainbase/src/main/java/org/tron/core/capsule/BlockCapsule.java +++ b/chainbase/src/main/java/org/tron/core/capsule/BlockCapsule.java @@ -56,7 +56,6 @@ public class BlockCapsule implements ProtoCapsule { private Block block; private List transactions = new ArrayList<>(); - private StringBuilder toStringBuff = new StringBuilder(); private boolean isSwitch; @Getter @Setter @@ -314,7 +313,7 @@ public boolean hasWitnessSignature() { @Override public String toString() { - toStringBuff.setLength(0); + StringBuilder toStringBuff = new StringBuilder(); toStringBuff.append("BlockCapsule \n[ "); toStringBuff.append("hash=").append(getBlockId()).append("\n"); diff --git a/chainbase/src/main/java/org/tron/core/capsule/ContractCapsule.java b/chainbase/src/main/java/org/tron/core/capsule/ContractCapsule.java index cb6292ed290..f566a128d6b 100644 --- a/chainbase/src/main/java/org/tron/core/capsule/ContractCapsule.java +++ b/chainbase/src/main/java/org/tron/core/capsule/ContractCapsule.java @@ -15,8 +15,8 @@ package org.tron.core.capsule; -import static java.lang.Math.max; -import static java.lang.Math.min; +import static org.tron.common.math.Maths.max; +import static org.tron.common.math.Maths.min; import com.google.protobuf.Any; import com.google.protobuf.ByteString; @@ -109,9 +109,9 @@ public byte[] getOriginAddress() { return this.smartContract.getOriginAddress().toByteArray(); } - public long getConsumeUserResourcePercent() { + public long getConsumeUserResourcePercent(boolean disableMath) { long percent = this.smartContract.getConsumeUserResourcePercent(); - return max(0, min(percent, Constant.ONE_HUNDRED)); + return max(0, min(percent, Constant.ONE_HUNDRED, disableMath), disableMath); } public long getOriginEnergyLimit() { diff --git a/chainbase/src/main/java/org/tron/core/capsule/ContractStateCapsule.java b/chainbase/src/main/java/org/tron/core/capsule/ContractStateCapsule.java index 8633534280b..bd932ea50ae 100644 --- a/chainbase/src/main/java/org/tron/core/capsule/ContractStateCapsule.java +++ b/chainbase/src/main/java/org/tron/core/capsule/ContractStateCapsule.java @@ -1,5 +1,8 @@ package org.tron.core.capsule; +import static org.tron.common.math.Maths.max; +import static org.tron.common.math.Maths.min; +import static org.tron.common.math.Maths.pow; import static org.tron.core.Constant.DYNAMIC_ENERGY_DECREASE_DIVISION; import static org.tron.core.Constant.DYNAMIC_ENERGY_FACTOR_DECIMAL; @@ -77,12 +80,15 @@ public boolean catchUpToCycle(DynamicPropertiesStore dps) { dps.getCurrentCycleNumber(), dps.getDynamicEnergyThreshold(), dps.getDynamicEnergyIncreaseFactor(), - dps.getDynamicEnergyMaxFactor() + dps.getDynamicEnergyMaxFactor(), + dps.allowStrictMath(), + dps.disableJavaLangMath() ); } public boolean catchUpToCycle( - long newCycle, long threshold, long increaseFactor, long maxFactor + long newCycle, long threshold, long increaseFactor, long maxFactor, + boolean useStrictMath, boolean disableMath ) { long lastCycle = getUpdateCycle(); @@ -106,9 +112,10 @@ public boolean catchUpToCycle( double increasePercent = 1 + (double) increaseFactor / precisionFactor; this.contractState = ContractState.newBuilder() .setUpdateCycle(lastCycle) - .setEnergyFactor(Math.min( + .setEnergyFactor(min( maxFactor, - (long) ((getEnergyFactor() + precisionFactor) * increasePercent) - precisionFactor)) + (long) ((getEnergyFactor() + precisionFactor) * increasePercent) - precisionFactor, + disableMath)) .build(); } @@ -119,9 +126,9 @@ public boolean catchUpToCycle( } // Calc the decrease percent (decrease factor [75% ~ 100%]) - double decreasePercent = Math.pow( + double decreasePercent = pow( 1 - (double) increaseFactor / DYNAMIC_ENERGY_DECREASE_DIVISION / precisionFactor, - cycleCount + cycleCount, useStrictMath ); // Decrease to this cycle @@ -130,9 +137,10 @@ public boolean catchUpToCycle( // That means we merge this special case to normal cases) this.contractState = ContractState.newBuilder() .setUpdateCycle(newCycle) - .setEnergyFactor(Math.max( + .setEnergyFactor(max( 0, - (long) ((getEnergyFactor() + precisionFactor) * decreasePercent) - precisionFactor)) + (long) ((getEnergyFactor() + precisionFactor) * decreasePercent) - precisionFactor, + disableMath)) .build(); return true; diff --git a/chainbase/src/main/java/org/tron/core/capsule/ExchangeCapsule.java b/chainbase/src/main/java/org/tron/core/capsule/ExchangeCapsule.java index 1cf91301b43..0dec7d60820 100644 --- a/chainbase/src/main/java/org/tron/core/capsule/ExchangeCapsule.java +++ b/chainbase/src/main/java/org/tron/core/capsule/ExchangeCapsule.java @@ -112,9 +112,9 @@ public byte[] createDbKey() { return calculateDbKey(getID()); } - public long transaction(byte[] sellTokenID, long sellTokenQuant) { + public long transaction(byte[] sellTokenID, long sellTokenQuant, boolean useStrictMath) { long supply = 1_000_000_000_000_000_000L; - ExchangeProcessor processor = new ExchangeProcessor(supply); + ExchangeProcessor processor = new ExchangeProcessor(supply, useStrictMath); long buyTokenQuant = 0; long firstTokenBalance = this.exchange.getFirstTokenBalance(); diff --git a/chainbase/src/main/java/org/tron/core/capsule/ExchangeProcessor.java b/chainbase/src/main/java/org/tron/core/capsule/ExchangeProcessor.java index e1b536b3e7a..91f5c101b58 100644 --- a/chainbase/src/main/java/org/tron/core/capsule/ExchangeProcessor.java +++ b/chainbase/src/main/java/org/tron/core/capsule/ExchangeProcessor.java @@ -1,14 +1,17 @@ package org.tron.core.capsule; import lombok.extern.slf4j.Slf4j; +import org.tron.common.math.Maths; @Slf4j(topic = "capsule") public class ExchangeProcessor { private long supply; + private final boolean useStrictMath; - public ExchangeProcessor(long supply) { + public ExchangeProcessor(long supply, boolean useStrictMath) { this.supply = supply; + this.useStrictMath = useStrictMath; } private long exchangeToSupply(long balance, long quant) { @@ -16,7 +19,8 @@ private long exchangeToSupply(long balance, long quant) { long newBalance = balance + quant; logger.debug("balance + quant: " + newBalance); - double issuedSupply = -supply * (1.0 - Math.pow(1.0 + (double) quant / newBalance, 0.0005)); + double issuedSupply = -supply * (1.0 + - Maths.pow(1.0 + (double) quant / newBalance, 0.0005, this.useStrictMath)); logger.debug("issuedSupply: " + issuedSupply); long out = (long) issuedSupply; supply += out; @@ -27,8 +31,8 @@ private long exchangeToSupply(long balance, long quant) { private long exchangeFromSupply(long balance, long supplyQuant) { supply -= supplyQuant; - double exchangeBalance = - balance * (Math.pow(1.0 + (double) supplyQuant / supply, 2000.0) - 1.0); + double exchangeBalance = balance + * (Maths.pow(1.0 + (double) supplyQuant / supply, 2000.0, this.useStrictMath) - 1.0); logger.debug("exchangeBalance: " + exchangeBalance); return (long) exchangeBalance; diff --git a/chainbase/src/main/java/org/tron/core/capsule/ReceiptCapsule.java b/chainbase/src/main/java/org/tron/core/capsule/ReceiptCapsule.java index 7d003b6b0e4..06513a0edc7 100644 --- a/chainbase/src/main/java/org/tron/core/capsule/ReceiptCapsule.java +++ b/chainbase/src/main/java/org/tron/core/capsule/ReceiptCapsule.java @@ -1,5 +1,8 @@ package org.tron.core.capsule; +import static org.tron.common.math.Maths.min; +import static org.tron.common.math.Maths.multiplyExact; + import java.util.Objects; import lombok.Getter; import lombok.Setter; @@ -215,12 +218,14 @@ public void payEnergyBill(DynamicPropertiesStore dynamicPropertiesStore, receipt.getEnergyUsageTotal(), receipt.getResult(), energyProcessor, now); return; } + boolean disableJavaLangMath = dynamicPropertiesStore.disableJavaLangMath(); if ((!Objects.isNull(origin)) && caller.getAddress().equals(origin.getAddress())) { payEnergyBill(dynamicPropertiesStore, accountStore, forkController, caller, receipt.getEnergyUsageTotal(), receipt.getResult(), energyProcessor, now); } else { - long originUsage = Math.multiplyExact(receipt.getEnergyUsageTotal(), percent) / 100; + long originUsage = multiplyExact(receipt.getEnergyUsageTotal(), percent, disableJavaLangMath) + / 100; originUsage = getOriginUsage(dynamicPropertiesStore, origin, originEnergyLimit, energyProcessor, originUsage); @@ -236,17 +241,20 @@ public void payEnergyBill(DynamicPropertiesStore dynamicPropertiesStore, private long getOriginUsage(DynamicPropertiesStore dynamicPropertiesStore, AccountCapsule origin, long originEnergyLimit, EnergyProcessor energyProcessor, long originUsage) { - + boolean disableJavaLangMath = dynamicPropertiesStore.disableJavaLangMath(); if (dynamicPropertiesStore.getAllowTvmFreeze() == 1 || dynamicPropertiesStore.supportUnfreezeDelay()) { - return Math.min(originUsage, Math.min(originEnergyLeft, originEnergyLimit)); + return min(originUsage, min(originEnergyLeft, originEnergyLimit, disableJavaLangMath), + disableJavaLangMath); } if (checkForEnergyLimit(dynamicPropertiesStore)) { - return Math.min(originUsage, - Math.min(energyProcessor.getAccountLeftEnergyFromFreeze(origin), originEnergyLimit)); + return min(originUsage, + min(energyProcessor.getAccountLeftEnergyFromFreeze(origin), originEnergyLimit, + disableJavaLangMath), disableJavaLangMath); } - return Math.min(originUsage, energyProcessor.getAccountLeftEnergyFromFreeze(origin)); + return min(originUsage, energyProcessor.getAccountLeftEnergyFromFreeze(origin), + disableJavaLangMath); } private void payEnergyBill( @@ -301,7 +309,7 @@ private void payEnergyBill( } else { //send to blackHole Commons.adjustBalance(accountStore, accountStore.getBlackhole(), - energyFee); + energyFee, dynamicPropertiesStore.disableJavaLangMath()); } } diff --git a/chainbase/src/main/java/org/tron/core/capsule/TransactionCapsule.java b/chainbase/src/main/java/org/tron/core/capsule/TransactionCapsule.java index 9598fd99a6b..95f436b19f0 100755 --- a/chainbase/src/main/java/org/tron/core/capsule/TransactionCapsule.java +++ b/chainbase/src/main/java/org/tron/core/capsule/TransactionCapsule.java @@ -17,6 +17,7 @@ import static org.tron.common.utils.StringUtil.encode58Check; import static org.tron.common.utils.WalletUtil.checkPermissionOperations; +import static org.tron.core.Constant.MAX_CONTRACT_RESULT_SIZE; import static org.tron.core.exception.P2pException.TypeEnum.PROTOBUF_ERROR; import com.google.common.primitives.Bytes; @@ -58,6 +59,7 @@ import org.tron.core.exception.P2pException; import org.tron.core.exception.PermissionException; import org.tron.core.exception.SignatureFormatException; +import org.tron.core.exception.TransactionExpirationException; import org.tron.core.exception.ValidateSignatureException; import org.tron.core.store.AccountStore; import org.tron.core.store.DynamicPropertiesStore; @@ -102,7 +104,6 @@ public class TransactionCapsule implements ProtoCapsule { @Setter private TransactionTrace trxTrace; - private StringBuilder toStringBuff = new StringBuilder(); @Getter @Setter private long time; @@ -115,6 +116,9 @@ public class TransactionCapsule implements ProtoCapsule { @Getter @Setter private boolean isTransactionCreate = false; + @Getter + @Setter + private boolean isInBlock = false; public byte[] getOwnerAddress() { if (this.ownerAddress == null) { @@ -731,6 +735,15 @@ public long getResultSerializedSize() { return size; } + public long getResultSizeWithMaxContractRet() { + long size = 0; + for (Result result : this.transaction.getRetList()) { + size += result.toBuilder().clearContractRet().build().getSerializedSize() + + MAX_CONTRACT_RESULT_SIZE; + } + return size; + } + @Override public Transaction getInstance() { return this.transaction; @@ -738,8 +751,7 @@ public Transaction getInstance() { @Override public String toString() { - - toStringBuff.setLength(0); + StringBuilder toStringBuff = new StringBuilder(); toStringBuff.append("TransactionCapsule \n[ "); toStringBuff.append("hash=").append(getTransactionId()).append("\n"); @@ -844,4 +856,39 @@ public BalanceContract.TransferContract getTransferContract() { return null; } } + + public void removeRedundantRet() { + Transaction tx = this.getInstance(); + List tmpList = new ArrayList<>(tx.getRetList()); + int contractCount = tx.getRawData().getContractCount(); + if (tx.getRetCount() > contractCount && contractCount > 0) { + Transaction.Builder transactionBuilder = tx.toBuilder().clearRet(); + for (int i = 0; i < contractCount; i++) { + Result result = tmpList.get(i); + transactionBuilder.addRet(result); + } + this.transaction = transactionBuilder.build(); + } + } + + public void checkExpiration(long nextSlotTime) throws TransactionExpirationException { + if (getExpiration() < nextSlotTime) { + throw new TransactionExpirationException(String.format( + "Transaction expiration time is %d, but next slot time is %d", + getExpiration(), nextSlotTime)); + } + } + + public boolean retCountIsGreatThanContractCount() { + int contractCount = getContractCount(); + return getRetCount() > contractCount && contractCount > 0; + } + + public int getRetCount() { + return this.getInstance().getRetCount(); + } + + public int getContractCount() { + return this.getInstance().getRawData().getContractCount(); + } } diff --git a/chainbase/src/main/java/org/tron/core/capsule/utils/MarketUtils.java b/chainbase/src/main/java/org/tron/core/capsule/utils/MarketUtils.java index f345a96df81..d711ac0d63b 100644 --- a/chainbase/src/main/java/org/tron/core/capsule/utils/MarketUtils.java +++ b/chainbase/src/main/java/org/tron/core/capsule/utils/MarketUtils.java @@ -15,6 +15,10 @@ package org.tron.core.capsule.utils; +import static org.tron.common.math.Maths.addExact; +import static org.tron.common.math.Maths.floorDiv; +import static org.tron.common.math.Maths.multiplyExact; + import com.google.protobuf.ByteString; import java.math.BigInteger; import java.util.Arrays; @@ -230,8 +234,8 @@ public static byte[] createPairKey(byte[] sellTokenId, byte[] buyTokenId) { public static int comparePrice(long price1SellQuantity, long price1BuyQuantity, long price2SellQuantity, long price2BuyQuantity) { try { - return Long.compare(Math.multiplyExact(price1BuyQuantity, price2SellQuantity), - Math.multiplyExact(price2BuyQuantity, price1SellQuantity)); + return Long.compare(multiplyExact(price1BuyQuantity, price2SellQuantity, true), + multiplyExact(price2BuyQuantity, price1SellQuantity, true)); } catch (ArithmeticException ex) { // do nothing here, because we will use BigInteger to compute again @@ -246,25 +250,6 @@ public static int comparePrice(long price1SellQuantity, long price1BuyQuantity, .compareTo(price2BuyQuantityBI.multiply(price1SellQuantityBI)); } - /** - * ex. - * for sellToken is A, buyToken is TRX. - * price_A_maker * sellQuantity_maker = Price_TRX * buyQuantity_maker - * ==> price_A_maker = Price_TRX * buyQuantity_maker/sellQuantity_maker - * - * price_A_maker_1 < price_A_maker_2 - * ==> buyQuantity_maker_1/sellQuantity_maker_1 < buyQuantity_maker_2/sellQuantity_maker_2 - * ==> buyQuantity_maker_1*sellQuantity_maker_2 < buyQuantity_maker_2 * sellQuantity_maker_1 - */ - public static int comparePrice(MarketPrice price1, MarketPrice price2) { - return comparePrice(price1.getSellTokenQuantity(), price1.getBuyTokenQuantity(), - price2.getSellTokenQuantity(), price2.getBuyTokenQuantity()); - } - - public static boolean isLowerPrice(MarketPrice price1, MarketPrice price2) { - return comparePrice(price1, price2) == -1; - } - /** * if takerPrice >= makerPrice, return True * note: here are two different token pairs @@ -297,10 +282,10 @@ public static void updateOrderState(MarketOrderCapsule orderCapsule, } } - public static long multiplyAndDivide(long a, long b, long c) { + public static long multiplyAndDivide(long a, long b, long c, boolean disableMath) { try { - long tmp = Math.multiplyExact(a, b); - return Math.floorDiv(tmp, c); + long tmp = multiplyExact(a, b, disableMath); + return floorDiv(tmp, c, disableMath); } catch (ArithmeticException ex) { // do nothing here, because we will use BigInteger to compute again } @@ -320,8 +305,9 @@ public static void returnSellTokenRemain(MarketOrderCapsule orderCapsule, byte[] sellTokenId = orderCapsule.getSellTokenId(); long sellTokenQuantityRemain = orderCapsule.getSellTokenQuantityRemain(); if (Arrays.equals(sellTokenId, "_".getBytes())) { - accountCapsule.setBalance(Math.addExact( - accountCapsule.getBalance(), sellTokenQuantityRemain)); + accountCapsule.setBalance(addExact( + accountCapsule.getBalance(), sellTokenQuantityRemain, + dynamicStore.disableJavaLangMath())); } else { accountCapsule .addAssetAmountV2(sellTokenId, sellTokenQuantityRemain, dynamicStore, assetIssueStore); diff --git a/chainbase/src/main/java/org/tron/core/capsule/utils/MerkleTree.java b/chainbase/src/main/java/org/tron/core/capsule/utils/MerkleTree.java index 47ac45c9fb8..94d22f4b474 100644 --- a/chainbase/src/main/java/org/tron/core/capsule/utils/MerkleTree.java +++ b/chainbase/src/main/java/org/tron/core/capsule/utils/MerkleTree.java @@ -5,10 +5,12 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import lombok.Getter; +import net.jcip.annotations.NotThreadSafe; import org.tron.common.parameter.CommonParameter; import org.tron.common.utils.Sha256Hash; @Getter +@NotThreadSafe public class MerkleTree { private static volatile MerkleTree instance; diff --git a/chainbase/src/main/java/org/tron/core/db/BandwidthProcessor.java b/chainbase/src/main/java/org/tron/core/db/BandwidthProcessor.java index f13002f2dfa..2488686bfb0 100644 --- a/chainbase/src/main/java/org/tron/core/db/BandwidthProcessor.java +++ b/chainbase/src/main/java/org/tron/core/db/BandwidthProcessor.java @@ -1,8 +1,10 @@ package org.tron.core.db; +import static org.tron.core.Constant.PER_SIGN_LENGTH; import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION; import static org.tron.protos.Protocol.Transaction.Contract.ContractType.ShieldedTransferContract; import static org.tron.protos.Protocol.Transaction.Contract.ContractType.TransferAssetContract; +import static org.tron.protos.contract.Common.ResourceCode.BANDWIDTH; import com.google.protobuf.ByteString; import java.util.HashMap; @@ -19,13 +21,12 @@ import org.tron.core.capsule.TransactionCapsule; import org.tron.core.exception.AccountResourceInsufficientException; import org.tron.core.exception.ContractValidateException; +import org.tron.core.exception.TooBigTransactionException; import org.tron.core.exception.TooBigTransactionResultException; import org.tron.protos.Protocol.Transaction.Contract; import org.tron.protos.contract.AssetIssueContractOuterClass.TransferAssetContract; import org.tron.protos.contract.BalanceContract.TransferContract; -import static org.tron.protos.contract.Common.ResourceCode.BANDWIDTH; - @Slf4j(topic = "DB") public class BandwidthProcessor extends ResourceProcessor { @@ -95,8 +96,17 @@ public void updateUsage(AssetIssueCapsule assetIssueCapsule, long now) { @Override public void consume(TransactionCapsule trx, TransactionTrace trace) throws ContractValidateException, AccountResourceInsufficientException, - TooBigTransactionResultException { + TooBigTransactionResultException, TooBigTransactionException { List contracts = trx.getInstance().getRawData().getContractList(); + long resultSizeWithMaxContractRet = trx.getResultSizeWithMaxContractRet(); + boolean optimizeTxs = !trx.isInBlock() || chainBaseManager + .getDynamicPropertiesStore().allowConsensusLogicOptimization(); + if (!trx.isInBlock() && resultSizeWithMaxContractRet > + Constant.MAX_RESULT_SIZE_IN_TX * contracts.size()) { + throw new TooBigTransactionResultException(String.format( + "Too big transaction result, TxId %s, the result size is %d bytes, maxResultSize %d", + trx.getTransactionId(), resultSizeWithMaxContractRet, Constant.MAX_RESULT_SIZE_IN_TX)); + } if (trx.getResultSerializedSize() > Constant.MAX_RESULT_SIZE_IN_TX * contracts.size()) { throw new TooBigTransactionResultException(); } @@ -127,6 +137,17 @@ public void consume(TransactionCapsule trx, TransactionTrace trace) } long now = chainBaseManager.getHeadSlot(); if (contractCreateNewAccount(contract)) { + if (optimizeTxs) { + long maxCreateAccountTxSize = dynamicPropertiesStore.getMaxCreateAccountTxSize(); + int signatureCount = trx.getInstance().getSignatureCount(); + long createAccountBytesSize = trx.getInstance().toBuilder().clearRet() + .build().getSerializedSize() - (signatureCount * PER_SIGN_LENGTH); + if (createAccountBytesSize > maxCreateAccountTxSize) { + throw new TooBigTransactionException(String.format( + "Too big new account transaction, TxId %s, the size is %d bytes, maxTxSize %d", + trx.getTransactionId(), createAccountBytesSize, maxCreateAccountTxSize)); + } + } consumeForCreateNewAccount(accountCapsule, bytesSize, now, trace); continue; } diff --git a/chainbase/src/main/java/org/tron/core/db/EnergyProcessor.java b/chainbase/src/main/java/org/tron/core/db/EnergyProcessor.java index 5cd0f796374..30d778d0990 100644 --- a/chainbase/src/main/java/org/tron/core/db/EnergyProcessor.java +++ b/chainbase/src/main/java/org/tron/core/db/EnergyProcessor.java @@ -1,6 +1,7 @@ package org.tron.core.db; -import static java.lang.Long.max; +import static org.tron.common.math.Maths.max; +import static org.tron.common.math.Maths.min; import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCED_INTERVAL; import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION; @@ -78,11 +79,9 @@ public void updateAdaptiveTotalEnergyLimit() { / AdaptiveResourceLimitConstants.EXPAND_RATE_DENOMINATOR; // logger.info(totalEnergyAverageUsage + "<" + targetTotalEnergyLimit + "\n" + result); } - - result = Math.min( - Math.max(result, totalEnergyLimit), - totalEnergyLimit * dynamicPropertiesStore.getAdaptiveResourceLimitMultiplier() - ); + result = min(max(result, totalEnergyLimit, this.disableJavaLangMath()), + totalEnergyLimit * dynamicPropertiesStore.getAdaptiveResourceLimitMultiplier(), + this.disableJavaLangMath()); dynamicPropertiesStore.saveTotalEnergyCurrentLimit(result); logger.debug("Adjust totalEnergyCurrentLimit, old: {}, new: {}.", @@ -178,7 +177,7 @@ public long getAccountLeftEnergyFromFreeze(AccountCapsule accountCapsule) { long newEnergyUsage = recovery(accountCapsule, ENERGY, energyUsage, latestConsumeTime, now); - return max(energyLimit - newEnergyUsage, 0); // us + return max(energyLimit - newEnergyUsage, 0, this.disableJavaLangMath()); // us } private long getHeadSlot() { diff --git a/chainbase/src/main/java/org/tron/core/db/ResourceProcessor.java b/chainbase/src/main/java/org/tron/core/db/ResourceProcessor.java index a7a22390958..7e170f9dab5 100644 --- a/chainbase/src/main/java/org/tron/core/db/ResourceProcessor.java +++ b/chainbase/src/main/java/org/tron/core/db/ResourceProcessor.java @@ -1,5 +1,7 @@ package org.tron.core.db; +import static org.tron.common.math.Maths.min; +import static org.tron.common.math.Maths.round; import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCED_INTERVAL; import static org.tron.core.config.Parameter.ChainConstant.WINDOW_SIZE_PRECISION; @@ -11,6 +13,7 @@ import org.tron.core.exception.AccountResourceInsufficientException; import org.tron.core.exception.BalanceInsufficientException; import org.tron.core.exception.ContractValidateException; +import org.tron.core.exception.TooBigTransactionException; import org.tron.core.exception.TooBigTransactionResultException; import org.tron.core.store.AccountStore; import org.tron.core.store.DynamicPropertiesStore; @@ -35,7 +38,7 @@ protected ResourceProcessor(DynamicPropertiesStore dynamicPropertiesStore, } abstract void consume(TransactionCapsule trx, TransactionTrace trace) - throws ContractValidateException, AccountResourceInsufficientException, TooBigTransactionResultException; + throws ContractValidateException, AccountResourceInsufficientException, TooBigTransactionResultException, TooBigTransactionException; protected long increase(long lastUsage, long usage, long lastTime, long now) { return increase(lastUsage, usage, lastTime, now, windowSize); @@ -50,7 +53,8 @@ protected long increase(long lastUsage, long usage, long lastTime, long now, lon if (lastTime + windowSize > now) { long delta = now - lastTime; double decay = (windowSize - delta) / (double) windowSize; - averageLastUsage = Math.round(averageLastUsage * decay); + averageLastUsage = round(averageLastUsage * decay, + this.disableJavaLangMath()); } else { averageLastUsage = 0; } @@ -78,7 +82,8 @@ public long increase(AccountCapsule accountCapsule, ResourceCode resourceCode, if (lastTime + oldWindowSize > now) { long delta = now - lastTime; double decay = (oldWindowSize - delta) / (double) oldWindowSize; - averageLastUsage = Math.round(averageLastUsage * decay); + averageLastUsage = round(averageLastUsage * decay, + this.disableJavaLangMath()); } else { averageLastUsage = 0; } @@ -110,7 +115,8 @@ public long increaseV2(AccountCapsule accountCapsule, ResourceCode resourceCode, if (lastTime + oldWindowSize > now) { long delta = now - lastTime; double decay = (oldWindowSize - delta) / (double) oldWindowSize; - averageLastUsage = Math.round(averageLastUsage * decay); + averageLastUsage = round(averageLastUsage * decay, + this.disableJavaLangMath()); } else { averageLastUsage = 0; } @@ -126,7 +132,8 @@ public long increaseV2(AccountCapsule accountCapsule, ResourceCode resourceCode, long remainWindowSize = oldWindowSizeV2 - (now - lastTime) * WINDOW_SIZE_PRECISION; long newWindowSize = divideCeil( remainUsage * remainWindowSize + usage * this.windowSize * WINDOW_SIZE_PRECISION, newUsage); - newWindowSize = Math.min(newWindowSize, this.windowSize * WINDOW_SIZE_PRECISION); + newWindowSize = min(newWindowSize, this.windowSize * WINDOW_SIZE_PRECISION, + this.disableJavaLangMath()); accountCapsule.setNewWindowSizeV2(resourceCode, newWindowSize); return newUsage; } @@ -188,7 +195,8 @@ public void unDelegateIncreaseV2(AccountCapsule owner, final AccountCapsule rece divideCeil( ownerUsage * remainOwnerWindowSizeV2 + transferUsage * remainReceiverWindowSizeV2, newOwnerUsage); - newOwnerWindowSize = Math.min(newOwnerWindowSize, this.windowSize * WINDOW_SIZE_PRECISION); + newOwnerWindowSize = min(newOwnerWindowSize, this.windowSize * WINDOW_SIZE_PRECISION, + this.disableJavaLangMath()); owner.setNewWindowSizeV2(resourceCode, newOwnerWindowSize); owner.setUsage(resourceCode, newOwnerUsage); owner.setLatestTime(resourceCode, now); @@ -215,13 +223,15 @@ protected boolean consumeFeeForBandwidth(AccountCapsule accountCapsule, long fee try { long latestOperationTime = dynamicPropertiesStore.getLatestBlockHeaderTimestamp(); accountCapsule.setLatestOperationTime(latestOperationTime); - Commons.adjustBalance(accountStore, accountCapsule, -fee); + Commons.adjustBalance(accountStore, accountCapsule, -fee, + this.disableJavaLangMath()); if (dynamicPropertiesStore.supportTransactionFeePool()) { dynamicPropertiesStore.addTransactionFeePool(fee); } else if (dynamicPropertiesStore.supportBlackHoleOptimization()) { dynamicPropertiesStore.burnTrx(fee); } else { - Commons.adjustBalance(accountStore, accountStore.getBlackhole().createDbKey(), +fee); + Commons.adjustBalance(accountStore, accountStore.getBlackhole().createDbKey(), +fee, + this.disableJavaLangMath()); } return true; @@ -234,11 +244,13 @@ protected boolean consumeFeeForNewAccount(AccountCapsule accountCapsule, long fe try { long latestOperationTime = dynamicPropertiesStore.getLatestBlockHeaderTimestamp(); accountCapsule.setLatestOperationTime(latestOperationTime); - Commons.adjustBalance(accountStore, accountCapsule, -fee); + Commons.adjustBalance(accountStore, accountCapsule, -fee, + this.disableJavaLangMath()); if (dynamicPropertiesStore.supportBlackHoleOptimization()) { dynamicPropertiesStore.burnTrx(fee); } else { - Commons.adjustBalance(accountStore, accountStore.getBlackhole().createDbKey(), +fee); + Commons.adjustBalance(accountStore, accountStore.getBlackhole().createDbKey(), +fee, + this.disableJavaLangMath()); } return true; @@ -246,4 +258,8 @@ protected boolean consumeFeeForNewAccount(AccountCapsule accountCapsule, long fe return false; } } + + protected boolean disableJavaLangMath() { + return dynamicPropertiesStore.disableJavaLangMath(); + } } diff --git a/chainbase/src/main/java/org/tron/core/db/StorageMarket.java b/chainbase/src/main/java/org/tron/core/db/StorageMarket.java deleted file mode 100644 index 10a3b656565..00000000000 --- a/chainbase/src/main/java/org/tron/core/db/StorageMarket.java +++ /dev/null @@ -1,234 +0,0 @@ -package org.tron.core.db; - -import lombok.extern.slf4j.Slf4j; -import org.tron.core.capsule.AccountCapsule; -import org.tron.core.store.AccountStore; -import org.tron.core.store.DynamicPropertiesStore; - -@Slf4j(topic = "DB") -public class StorageMarket { - private static final String LOG_MSG = "NewTotalPool: {}, newTotalReserved: {}."; - private static final long MS_PER_YEAR = 365 * 24 * 3600 * 1000L; - private AccountStore accountStore; - private DynamicPropertiesStore dynamicPropertiesStore; - private long supply = 1_000_000_000_000_000L; - - - public StorageMarket(AccountStore accountStore, DynamicPropertiesStore dynamicPropertiesStore) { - this.accountStore = accountStore; - this.dynamicPropertiesStore = dynamicPropertiesStore; - } - - private long exchangeToSupply(boolean isTRX, long quant) { - logger.info("IsTRX: {}.", isTRX); - long balance = isTRX ? dynamicPropertiesStore.getTotalStoragePool() : - dynamicPropertiesStore.getTotalStorageReserved(); - logger.info("Balance: {}.", balance); - long newBalance = balance + quant; - logger.info("Balance + quant: {}.", balance + quant); - -// if (isTRX) { -// dbManager.getDynamicPropertiesStore().saveTotalStoragePool(newBalance); -// } else { -// dbManager.getDynamicPropertiesStore().saveTotalStorageReserved(newBalance); -// } - - double issuedSupply = -supply * (1.0 - Math.pow(1.0 + (double) quant / newBalance, 0.0005)); - logger.info("IssuedSupply: {}.", issuedSupply); - long out = (long) issuedSupply; - supply += out; - - return out; - } - - private long exchangeToSupply2(boolean isTRX, long quant) { - logger.info("IsTRX: {}.", isTRX); - long balance = isTRX ? dynamicPropertiesStore.getTotalStoragePool() : - dynamicPropertiesStore.getTotalStorageReserved(); - logger.info("Balance: {}.", balance); - long newBalance = balance - quant; - logger.info("Balance - quant: {}.", balance - quant); - -// if (isTRX) { -// dbManager.getDynamicPropertiesStore().saveTotalStoragePool(newBalance); -// } else { -// dbManager.getDynamicPropertiesStore().saveTotalStorageReserved(newBalance); -// } - - double issuedSupply = -supply * (1.0 - Math.pow(1.0 + (double) quant / newBalance, 0.0005)); - logger.info("IssuedSupply: {}.", issuedSupply); - long out = (long) issuedSupply; - supply += out; - - return out; - } - - private long exchange_from_supply(boolean isTRX, long supplyQuant) { - long balance = isTRX ? dynamicPropertiesStore.getTotalStoragePool() : - dynamicPropertiesStore.getTotalStorageReserved(); - supply -= supplyQuant; - - double exchangeBalance = - balance * (Math.pow(1.0 + (double) supplyQuant / supply, 2000.0) - 1.0); - logger.info("ExchangeBalance: {}.", exchangeBalance); - long out = (long) exchangeBalance; - - if (isTRX) { - out = Math.round(exchangeBalance / 100000) * 100000; - logger.info("Out: {}.", out); - } - - return out; - } - - public long exchange(long from, boolean isTRX) { - long relay = exchangeToSupply(isTRX, from); - return exchange_from_supply(!isTRX, relay); - } - - public long calculateTax(long duration, long limit) { - // todo: Support for change by the committee - double ratePerYear = dynamicPropertiesStore.getStorageExchangeTaxRate() / 100.0; - double millisecondPerYear = MS_PER_YEAR; - double feeRate = duration / millisecondPerYear * ratePerYear; - long storageTax = (long) (limit * feeRate); - logger.info("StorageTax: {}.", storageTax); - return storageTax; - } - - - public long tryPayTax(long duration, long limit) { - long storageTax = calculateTax(duration, limit); - long tax = exchange(storageTax, false); - logger.info("Tax: {}.", tax); - - long newTotalTax = dynamicPropertiesStore.getTotalStorageTax() + tax; - long newTotalPool = dynamicPropertiesStore.getTotalStoragePool() - tax; - long newTotalReserved = dynamicPropertiesStore.getTotalStorageReserved() - + storageTax; - logger.info("Reserved: {}.", dynamicPropertiesStore.getTotalStorageReserved()); - boolean eq = dynamicPropertiesStore.getTotalStorageReserved() - == 128L * 1024 * 1024 * 1024; - logger.info("Reserved == 128GB: {}.", eq); - logger.info("NewTotalTax: {}, newTotalPool: {}, newTotalReserved: {}.", - newTotalTax, newTotalPool, newTotalReserved); - - return storageTax; - } - - public long payTax(long duration, long limit) { - long storageTax = calculateTax(duration, limit); - long tax = exchange(storageTax, false); - logger.info("Tax: {}.", tax); - - long newTotalTax = dynamicPropertiesStore.getTotalStorageTax() + tax; - long newTotalPool = dynamicPropertiesStore.getTotalStoragePool() - tax; - long newTotalReserved = dynamicPropertiesStore.getTotalStorageReserved() - + storageTax; - logger.info("Reserved: {}.", dynamicPropertiesStore.getTotalStorageReserved()); - boolean eq = dynamicPropertiesStore.getTotalStorageReserved() - == 128L * 1024 * 1024 * 1024; - logger.info("Reserved == 128GB: {}.", eq); - logger.info("NewTotalTax: {}, newTotalPool: {}, newTotalReserved: {}.", - newTotalTax, newTotalPool, newTotalReserved); - dynamicPropertiesStore.saveTotalStorageTax(newTotalTax); - dynamicPropertiesStore.saveTotalStoragePool(newTotalPool); - dynamicPropertiesStore.saveTotalStorageReserved(newTotalReserved); - - return storageTax; - } - - public long tryBuyStorageBytes(long storageBought) { - long relay = exchangeToSupply2(false, storageBought); - return exchange_from_supply(true, relay); - } - - public long tryBuyStorage(long quant) { - return exchange(quant, true); - } - - public long trySellStorage(long bytes) { - return exchange(bytes, false); - } - - public AccountCapsule buyStorageBytes(AccountCapsule accountCapsule, long storageBought) { - long now = dynamicPropertiesStore.getLatestBlockHeaderTimestamp(); - long currentStorageLimit = accountCapsule.getStorageLimit(); - - long relay = exchangeToSupply2(false, storageBought); - long quant = exchange_from_supply(true, relay); - - long newBalance = accountCapsule.getBalance() - quant; - logger.info("New balance: {}.", newBalance); - - long newStorageLimit = currentStorageLimit + storageBought; - logger.info("StorageBought: {}, newStorageLimit: {}.", storageBought, newStorageLimit); - - accountCapsule.setLatestExchangeStorageTime(now); - accountCapsule.setStorageLimit(newStorageLimit); - accountCapsule.setBalance(newBalance); - accountStore.put(accountCapsule.createDbKey(), accountCapsule); - - long newTotalPool = dynamicPropertiesStore.getTotalStoragePool() + quant; - long newTotalReserved = dynamicPropertiesStore.getTotalStorageReserved() - - storageBought; - logger.info(LOG_MSG, newTotalPool, newTotalReserved); - dynamicPropertiesStore.saveTotalStoragePool(newTotalPool); - dynamicPropertiesStore.saveTotalStorageReserved(newTotalReserved); - return accountCapsule; - } - - - public void buyStorage(AccountCapsule accountCapsule, long quant) { - long now = dynamicPropertiesStore.getLatestBlockHeaderTimestamp(); - long currentStorageLimit = accountCapsule.getStorageLimit(); - - long newBalance = accountCapsule.getBalance() - quant; - logger.info("New balance: {}.", newBalance); - - long storageBought = exchange(quant, true); - long newStorageLimit = currentStorageLimit + storageBought; - logger.info("StorageBought: {}, newStorageLimit: {}.", storageBought, newStorageLimit); - - accountCapsule.setLatestExchangeStorageTime(now); - accountCapsule.setStorageLimit(newStorageLimit); - accountCapsule.setBalance(newBalance); - accountStore.put(accountCapsule.createDbKey(), accountCapsule); - - long newTotalPool = dynamicPropertiesStore.getTotalStoragePool() + quant; - long newTotalReserved = dynamicPropertiesStore.getTotalStorageReserved() - - storageBought; - logger.info(LOG_MSG, newTotalPool, newTotalReserved); - dynamicPropertiesStore.saveTotalStoragePool(newTotalPool); - dynamicPropertiesStore.saveTotalStorageReserved(newTotalReserved); - - } - - public void sellStorage(AccountCapsule accountCapsule, long bytes) { - long now = dynamicPropertiesStore.getLatestBlockHeaderTimestamp(); - long currentStorageLimit = accountCapsule.getStorageLimit(); - - long quant = exchange(bytes, false); - long newBalance = accountCapsule.getBalance() + quant; - - long newStorageLimit = currentStorageLimit - bytes; - logger.info("Quant: {}, newStorageLimit: {}.", quant, newStorageLimit); - - accountCapsule.setLatestExchangeStorageTime(now); - accountCapsule.setStorageLimit(newStorageLimit); - accountCapsule.setBalance(newBalance); - accountStore.put(accountCapsule.createDbKey(), accountCapsule); - - long newTotalPool = dynamicPropertiesStore.getTotalStoragePool() - quant; - long newTotalReserved = dynamicPropertiesStore.getTotalStorageReserved() - + bytes; - logger.info(LOG_MSG, newTotalPool, newTotalReserved); - dynamicPropertiesStore.saveTotalStoragePool(newTotalPool); - dynamicPropertiesStore.saveTotalStorageReserved(newTotalReserved); - - } - - public long getAccountLeftStorageInByteFromBought(AccountCapsule accountCapsule) { - return accountCapsule.getStorageLimit() - accountCapsule.getStorageUsage(); - } -} diff --git a/chainbase/src/main/java/org/tron/core/db/TransactionTrace.java b/chainbase/src/main/java/org/tron/core/db/TransactionTrace.java index e9c4feb7e18..c3776921244 100644 --- a/chainbase/src/main/java/org/tron/core/db/TransactionTrace.java +++ b/chainbase/src/main/java/org/tron/core/db/TransactionTrace.java @@ -1,8 +1,9 @@ package org.tron.core.db; +import static org.tron.common.math.Maths.max; +import static org.tron.common.math.Maths.min; import static org.tron.common.runtime.InternalTransaction.TrxType.TRX_CONTRACT_CALL_TYPE; import static org.tron.common.runtime.InternalTransaction.TrxType.TRX_CONTRACT_CREATION_TYPE; -import static org.tron.core.config.Parameter.ChainConstant.WINDOW_SIZE_PRECISION; import static org.tron.protos.contract.Common.ResourceCode.ENERGY; import java.util.Objects; @@ -39,7 +40,6 @@ import org.tron.protos.Protocol.Transaction; import org.tron.protos.Protocol.Transaction.Contract.ContractType; import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.contract.Common; import org.tron.protos.contract.SmartContractOuterClass.SmartContract.ABI; import org.tron.protos.contract.SmartContractOuterClass.TriggerSmartContract; @@ -244,9 +244,11 @@ public void pay() throws BalanceInsufficientException { callerAccount = callContract.getOwnerAddress().toByteArray(); originAccount = contractCapsule.getOriginAddress(); - percent = Math - .max(Constant.ONE_HUNDRED - contractCapsule.getConsumeUserResourcePercent(), 0); - percent = Math.min(percent, Constant.ONE_HUNDRED); + boolean disableJavaLangMath = dynamicPropertiesStore.disableJavaLangMath(); + percent = max(Constant.ONE_HUNDRED - contractCapsule.getConsumeUserResourcePercent( + disableJavaLangMath), 0, disableJavaLangMath); + percent = min(percent, Constant.ONE_HUNDRED, + disableJavaLangMath); originEnergyLimit = contractCapsule.getOriginEnergyLimit(); break; default: @@ -299,7 +301,7 @@ private void resetAccountUsage(AccountCapsule accountCap, // If area merging happened during suicide, use the current window size long newSize = mergedSize == currentSize ? size : currentSize; // Calc new usage by fixed x-axes - long newUsage = Long.max(0, newArea / newSize); + long newUsage = max(0, newArea / newSize, dynamicPropertiesStore.disableJavaLangMath()); // Reset account usage and window size accountCap.setEnergyUsage(newUsage); accountCap.setNewWindowSize(ENERGY, newUsage == 0 ? 0L : newSize); @@ -316,7 +318,7 @@ private void resetAccountUsageV2(AccountCapsule accountCap, long newSize = mergedSize == currentSize ? size : currentSize; long newSize2 = mergedSize == currentSize ? size2 : currentSize2; // Calc new usage by fixed x-axes - long newUsage = Long.max(0, newArea / newSize); + long newUsage = max(0, newArea / newSize, dynamicPropertiesStore.disableJavaLangMath()); // Reset account usage and window size accountCap.setEnergyUsage(newUsage); accountCap.setNewWindowSizeV2(ENERGY, newUsage == 0 ? 0L : newSize2); diff --git a/chainbase/src/main/java/org/tron/core/db/common/iterator/DBIterator.java b/chainbase/src/main/java/org/tron/core/db/common/iterator/DBIterator.java index f706623693f..afbacac35db 100755 --- a/chainbase/src/main/java/org/tron/core/db/common/iterator/DBIterator.java +++ b/chainbase/src/main/java/org/tron/core/db/common/iterator/DBIterator.java @@ -1,9 +1,71 @@ package org.tron.core.db.common.iterator; +import com.google.common.collect.Iterators; +import com.google.common.collect.UnmodifiableIterator; +import com.google.common.primitives.Bytes; import java.io.Closeable; import java.util.Iterator; import java.util.Map.Entry; +import java.util.NoSuchElementException; -public interface DBIterator extends Iterator>, Closeable { +public interface DBIterator extends Iterator>, AutoCloseable, Closeable { + void seek(byte[] key); + + void seekToFirst(); + + void seekToLast(); + + /** + * An iterator is either positioned at a key/value pair, or + * not valid. This method returns true iff the iterator is valid. + * + * REQUIRES: iterator not closed + * + * @throws IllegalStateException if the iterator is closed. + * @return an iterator is either positioned at a key/value pair + */ + boolean valid(); + + /** + * The underlying storage for + * the returned slice is valid only until the next modification of + * the iterator. + * + * REQUIRES: valid() && !closed + * + * @throws IllegalStateException if the iterator is closed. + * @throws NoSuchElementException if the iterator is not valid. + * + * @return the key for the current entry + */ + byte[] getKey(); + + /** + * The underlying storage for + * the returned slice is valid only until the next modification of + * the iterator. + * + * REQUIRES: valid() && !closed + * + * @throws IllegalStateException if the iterator is closed. + * @throws NoSuchElementException if the iterator is not valid. + * + * @return the value for the current entry + */ + byte[] getValue(); + + /** + * @throws IllegalStateException if the iterator is closed. + */ + void checkState(); + + /** + * @throws NoSuchElementException if the iterator is not valid. + */ + default void checkValid() { + if (!valid()) { + throw new NoSuchElementException(); + } + } } diff --git a/chainbase/src/main/java/org/tron/core/db/common/iterator/RockStoreIterator.java b/chainbase/src/main/java/org/tron/core/db/common/iterator/RockStoreIterator.java index a8c4cff2066..541f71348af 100644 --- a/chainbase/src/main/java/org/tron/core/db/common/iterator/RockStoreIterator.java +++ b/chainbase/src/main/java/org/tron/core/db/common/iterator/RockStoreIterator.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.util.Map.Entry; import java.util.NoSuchElementException; +import java.util.concurrent.atomic.AtomicBoolean; import lombok.extern.slf4j.Slf4j; import org.rocksdb.RocksIterator; @@ -13,7 +14,7 @@ public final class RockStoreIterator implements DBIterator { private final RocksIterator dbIterator; private boolean first = true; - private boolean valid = true; + private final AtomicBoolean close = new AtomicBoolean(false); public RockStoreIterator(RocksIterator dbIterator) { this.dbIterator = dbIterator; @@ -21,12 +22,14 @@ public RockStoreIterator(RocksIterator dbIterator) { @Override public void close() throws IOException { - dbIterator.close(); + if (close.compareAndSet(false, true)) { + dbIterator.close(); + } } @Override public boolean hasNext() { - if (!valid) { + if (close.get()) { return false; } boolean hasNext = false; @@ -37,13 +40,12 @@ public boolean hasNext() { first = false; } if (!(hasNext = dbIterator.isValid())) { // false is last item - dbIterator.close(); - valid = false; + close(); } } catch (Exception e) { logger.error(e.getMessage(), e); try { - dbIterator.close(); + close(); } catch (Exception e1) { logger.error(e.getMessage(), e); } @@ -53,7 +55,7 @@ public boolean hasNext() { @Override public Entry next() { - if (!valid) { + if (close.get()) { throw new NoSuchElementException(); } byte[] key = dbIterator.key(); @@ -76,4 +78,50 @@ public byte[] setValue(byte[] value) { } }; } -} \ No newline at end of file + + @Override + public void seek(byte[] key) { + checkState(); + dbIterator.seek(key); + this.first = false; + } + + @Override + public void seekToFirst() { + checkState(); + dbIterator.seekToFirst(); + this.first = false; + } + + @Override + public void seekToLast() { + checkState(); + dbIterator.seekToLast(); + this.first = false; + } + + @Override + public boolean valid() { + checkState(); + return dbIterator.isValid(); + } + + @Override + public byte[] getKey() { + checkValid(); + return dbIterator.key(); + } + + @Override + public byte[] getValue() { + checkValid(); + return dbIterator.value(); + } + + @Override + public void checkState() { + if (close.get()) { + throw new IllegalStateException("iterator has been closed"); + } + } +} diff --git a/chainbase/src/main/java/org/tron/core/db/common/iterator/StoreIterator.java b/chainbase/src/main/java/org/tron/core/db/common/iterator/StoreIterator.java index 292bb421e54..d771716a7e8 100755 --- a/chainbase/src/main/java/org/tron/core/db/common/iterator/StoreIterator.java +++ b/chainbase/src/main/java/org/tron/core/db/common/iterator/StoreIterator.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.util.Map.Entry; import java.util.NoSuchElementException; +import java.util.concurrent.atomic.AtomicBoolean; import lombok.extern.slf4j.Slf4j; import org.iq80.leveldb.DBIterator; @@ -13,7 +14,7 @@ public final class StoreIterator implements org.tron.core.db.common.iterator.DBI private final DBIterator dbIterator; private boolean first = true; - private boolean valid = true; + private final AtomicBoolean close = new AtomicBoolean(false); public StoreIterator(DBIterator dbIterator) { this.dbIterator = dbIterator; @@ -21,12 +22,14 @@ public StoreIterator(DBIterator dbIterator) { @Override public void close() throws IOException { - dbIterator.close(); + if (close.compareAndSet(false, true)) { + dbIterator.close(); + } } @Override public boolean hasNext() { - if (!valid) { + if (close.get()) { return false; } @@ -39,8 +42,7 @@ public boolean hasNext() { } if (!(hasNext = dbIterator.hasNext())) { // false is last item - dbIterator.close(); - valid = false; + close(); } } catch (Exception e) { logger.error(e.getMessage(), e); @@ -51,7 +53,7 @@ public boolean hasNext() { @Override public Entry next() { - if (!valid) { + if (close.get()) { throw new NoSuchElementException(); } return dbIterator.next(); @@ -61,4 +63,51 @@ public Entry next() { public void remove() { throw new UnsupportedOperationException(); } + + @Override + public void seek(byte[] key) { + checkState(); + dbIterator.seek(key); + this.first = false; + } + + @Override + public void seekToFirst() { + checkState(); + dbIterator.seekToFirst(); + this.first = false; + } + + @Override + public void seekToLast() { + checkState(); + dbIterator.seekToLast(); + this.first = false; + } + + @Override + public boolean valid() { + checkState(); + return dbIterator.hasNext(); + } + + @Override + public byte[] getKey() { + checkValid(); + return dbIterator.peekNext().getKey(); + } + + @Override + public byte[] getValue() { + checkValid(); + return dbIterator.peekNext().getValue(); + } + + @Override + public void checkState() { + if (close.get()) { + throw new IllegalStateException("iterator has been closed"); + } + } } + diff --git a/chainbase/src/main/java/org/tron/core/db2/core/SnapshotManager.java b/chainbase/src/main/java/org/tron/core/db2/core/SnapshotManager.java index f0f169ae340..eb27141a82c 100644 --- a/chainbase/src/main/java/org/tron/core/db2/core/SnapshotManager.java +++ b/chainbase/src/main/java/org/tron/core/db2/core/SnapshotManager.java @@ -20,7 +20,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.locks.LockSupport; import java.util.stream.Collectors; import javax.annotation.PostConstruct; import lombok.Getter; @@ -42,6 +41,7 @@ import org.tron.core.db2.common.Value; import org.tron.core.db2.common.WrappedByteArray; import org.tron.core.exception.RevokingStoreIllegalStateException; +import org.tron.core.exception.TronError; import org.tron.core.store.CheckPointV2Store; import org.tron.core.store.CheckTmpStore; @@ -68,7 +68,6 @@ public class SnapshotManager implements RevokingDatabase { private volatile int flushCount = 0; - private Thread exitThread; private volatile boolean hitDown; private Map flushServices = new HashMap<>(); @@ -105,15 +104,6 @@ public void init() { } }, 10000, 3600, TimeUnit.MILLISECONDS); } - exitThread = new Thread(() -> { - LockSupport.park(); - // to Guarantee Some other thread invokes unpark with the current thread as the target - if (hitDown) { - System.exit(1); - } - }); - exitThread.setName("exit-thread"); - exitThread.start(); } public static String simpleDecode(byte[] bytes) { @@ -281,13 +271,6 @@ public void shutdown() { ExecutorServiceManager.shutdownAndAwaitTermination(pruneCheckpointThread, pruneName); flushServices.forEach((key, value) -> ExecutorServiceManager.shutdownAndAwaitTermination(value, "flush-service-" + key)); - try { - exitThread.interrupt(); - // help GC - exitThread = null; - } catch (Exception e) { - logger.warn("exitThread interrupt error", e); - } } public void updateSolidity(int hops) { @@ -298,7 +281,7 @@ public void updateSolidity(int hops) { } } - private boolean shouldBeRefreshed() { + public boolean shouldBeRefreshed() { return flushCount >= maxFlushCount; } @@ -367,12 +350,12 @@ public void flush() { } catch (TronDBException e) { logger.error(" Find fatal error, program will be exited soon.", e); hitDown = true; - LockSupport.unpark(exitThread); + throw new TronError(e, TronError.ErrCode.DB_FLUSH); } } } - private void createCheckpoint() { + public void createCheckpoint() { TronDatabase checkPointStore = null; boolean syncFlag; try { @@ -430,7 +413,7 @@ private TronDatabase getCheckpointDB(String dbName) { return new CheckPointV2Store(CHECKPOINT_V2_DIR+"/"+dbName); } - private List getCheckpointList() { + public List getCheckpointList() { String dbPath = Paths.get(StorageUtils.getOutputDirectoryByDbName(CHECKPOINT_V2_DIR), CommonParameter.getInstance().getStorage().getDbDirectory()).toString(); File file = new File(Paths.get(dbPath, CHECKPOINT_V2_DIR).toString()); @@ -490,10 +473,10 @@ public void check() { if (!isV2Open()) { List cpList = getCheckpointList(); if (cpList != null && cpList.size() != 0) { - logger.error("checkpoint check failed, the checkpoint version of database not match your " + - "config file, please set storage.checkpoint.version = 2 in your config file " + - "and restart the node."); - System.exit(-1); + String msg = "checkpoint check failed, the checkpoint version of database not match your " + + "config file, please set storage.checkpoint.version = 2 in your config file " + + "and restart the node."; + throw new TronError(msg, TronError.ErrCode.CHECKPOINT_VERSION); } checkV1(); } else { diff --git a/chainbase/src/main/java/org/tron/core/service/MortgageService.java b/chainbase/src/main/java/org/tron/core/service/MortgageService.java index e9b00a38201..b1fd279c2db 100644 --- a/chainbase/src/main/java/org/tron/core/service/MortgageService.java +++ b/chainbase/src/main/java/org/tron/core/service/MortgageService.java @@ -1,15 +1,18 @@ package org.tron.core.service; -import com.google.protobuf.ByteString; +import static org.tron.common.math.Maths.min; + import java.math.BigInteger; -import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.bouncycastle.util.encoders.Hex; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.tron.common.utils.Pair; import org.tron.common.utils.StringUtil; import org.tron.core.capsule.AccountCapsule; import org.tron.core.capsule.WitnessCapsule; @@ -18,7 +21,6 @@ import org.tron.core.store.DelegationStore; import org.tron.core.store.DynamicPropertiesStore; import org.tron.core.store.WitnessStore; -import org.tron.protos.Protocol.Vote; @Slf4j(topic = "mortgage") @Component @@ -37,6 +39,9 @@ public class MortgageService { @Setter private AccountStore accountStore; + @Autowired + private RewardViCalService rewardViCalService; + public void initStore(WitnessStore witnessStore, DelegationStore delegationStore, DynamicPropertiesStore dynamicPropertiesStore, AccountStore accountStore) { this.witnessStore = witnessStore; @@ -46,7 +51,8 @@ public void initStore(WitnessStore witnessStore, DelegationStore delegationStore } public void payStandbyWitness() { - List witnessStandbys = witnessStore.getWitnessStandby(); + List witnessStandbys = witnessStore.getWitnessStandby( + dynamicPropertiesStore.allowWitnessSortOptimization()); long voteSum = witnessStandbys.stream().mapToLong(WitnessCapsule::getVoteCount).sum(); if (voteSum < 1) { return; @@ -162,21 +168,21 @@ public long queryReward(byte[] address) { return reward + accountCapsule.getAllowance(); } - private long computeReward(long cycle, AccountCapsule accountCapsule) { + private long computeReward(long cycle, List> votes) { long reward = 0; - for (Vote vote : accountCapsule.getVotesList()) { - byte[] srAddress = vote.getVoteAddress().toByteArray(); + for (Pair vote : votes) { + byte[] srAddress = vote.getKey(); long totalReward = delegationStore.getReward(cycle, srAddress); + if (totalReward <= 0) { + continue; + } long totalVote = delegationStore.getWitnessVote(cycle, srAddress); if (totalVote == DelegationStore.REMARK || totalVote == 0) { continue; } - long userVote = vote.getVoteCount(); + long userVote = vote.getValue(); double voteRate = (double) userVote / totalVote; reward += voteRate * totalReward; - logger.debug("ComputeReward {}, {}, {}, {}, {}, {}, {}.", cycle, - Hex.toHexString(accountCapsule.getAddress().toByteArray()), Hex.toHexString(srAddress), - userVote, totalVote, totalReward, reward); } return reward; } @@ -197,23 +203,25 @@ private long computeReward(long beginCycle, long endCycle, AccountCapsule accoun long reward = 0; long newAlgorithmCycle = dynamicPropertiesStore.getNewRewardAlgorithmEffectiveCycle(); + List> srAddresses = accountCapsule.getVotesList().stream() + .map(vote -> new Pair<>(vote.getVoteAddress().toByteArray(), vote.getVoteCount())) + .collect(Collectors.toList()); if (beginCycle < newAlgorithmCycle) { - long oldEndCycle = Math.min(endCycle, newAlgorithmCycle); - for (long cycle = beginCycle; cycle < oldEndCycle; cycle++) { - reward += computeReward(cycle, accountCapsule); - } + long oldEndCycle = min(endCycle, newAlgorithmCycle, + dynamicPropertiesStore.disableJavaLangMath()); + reward = getOldReward(beginCycle, oldEndCycle, srAddresses); beginCycle = oldEndCycle; } if (beginCycle < endCycle) { - for (Vote vote : accountCapsule.getVotesList()) { - byte[] srAddress = vote.getVoteAddress().toByteArray(); + for (Pair vote : srAddresses) { + byte[] srAddress = vote.getKey(); BigInteger beginVi = delegationStore.getWitnessVi(beginCycle - 1, srAddress); BigInteger endVi = delegationStore.getWitnessVi(endCycle - 1, srAddress); BigInteger deltaVi = endVi.subtract(beginVi); if (deltaVi.signum() <= 0) { continue; } - long userVote = vote.getVoteCount(); + long userVote = vote.getValue(); reward += deltaVi.multiply(BigInteger.valueOf(userVote)) .divide(DelegationStore.DECIMAL_OF_VI_REWARD).longValue(); } @@ -221,10 +229,6 @@ private long computeReward(long beginCycle, long endCycle, AccountCapsule accoun return reward; } - public WitnessCapsule getWitnessByAddress(ByteString address) { - return witnessStore.get(address.toByteArray()); - } - public void adjustAllowance(byte[] address, long amount) { try { if (amount <= 0) { @@ -253,8 +257,14 @@ public void adjustAllowance(AccountStore accountStore, byte[] accountAddress, lo accountStore.put(account.createDbKey(), account); } - private void sortWitness(List list) { - list.sort(Comparator.comparingLong((ByteString b) -> getWitnessByAddress(b).getVoteCount()) - .reversed().thenComparing(Comparator.comparingInt(ByteString::hashCode).reversed())); + private long getOldReward(long begin, long end, List> votes) { + if (dynamicPropertiesStore.allowOldRewardOpt()) { + return rewardViCalService.getNewRewardAlgorithmReward(begin, end, votes); + } + long reward = 0; + for (long cycle = begin; cycle < end; cycle++) { + reward += computeReward(cycle, votes); + } + return reward; } } diff --git a/chainbase/src/main/java/org/tron/core/service/RewardViCalService.java b/chainbase/src/main/java/org/tron/core/service/RewardViCalService.java new file mode 100644 index 00000000000..f88fd02c539 --- /dev/null +++ b/chainbase/src/main/java/org/tron/core/service/RewardViCalService.java @@ -0,0 +1,287 @@ +package org.tron.core.service; + +import static org.tron.core.store.DelegationStore.DECIMAL_OF_VI_REWARD; +import static org.tron.core.store.DelegationStore.REMARK; + +import com.google.common.collect.Streams; +import com.google.common.primitives.Bytes; +import com.google.protobuf.ByteString; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; +import java.util.stream.LongStream; +import javax.annotation.PreDestroy; +import lombok.extern.slf4j.Slf4j; +import org.bouncycastle.util.encoders.Hex; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.tron.common.error.TronDBException; +import org.tron.common.es.ExecutorServiceManager; +import org.tron.common.parameter.CommonParameter; +import org.tron.common.utils.ByteArray; +import org.tron.common.utils.MerkleRoot; +import org.tron.common.utils.Pair; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.db.common.iterator.DBIterator; +import org.tron.core.db2.common.DB; +import org.tron.core.exception.TronError; +import org.tron.core.store.DelegationStore; +import org.tron.core.store.DynamicPropertiesStore; +import org.tron.core.store.RewardViStore; +import org.tron.core.store.WitnessStore; + +@Component +@Slf4j(topic = "rewardViCalService") +public class RewardViCalService { + + private final DB propertiesStore; + private final DB delegationStore; + private final DB witnessStore; + + @Autowired + private RewardViStore rewardViStore; + + private static final byte[] IS_DONE_KEY = new byte[]{0x00}; + private static final byte[] IS_DONE_VALUE = new byte[]{0x01}; + + private long newRewardCalStartCycle = Long.MAX_VALUE; + + private volatile long lastBlockNumber = -1; + + private static final String MAIN_NET_ROOT_HEX = + "9debcb9924055500aaae98cdee10501c5c39d4daa75800a996f4bdda73dbccd8"; + + private final Sha256Hash rewardViRoot = CommonParameter.getInstance().getStorage().getDbRoot( + "reward-vi", Sha256Hash.wrap(ByteString.fromHex(MAIN_NET_ROOT_HEX))); + + private final CountDownLatch lock = new CountDownLatch(1); + + private final ScheduledExecutorService es = ExecutorServiceManager + .newSingleThreadScheduledExecutor("rewardViCalService"); + + + @Autowired + public RewardViCalService(@Autowired DynamicPropertiesStore propertiesStore, + @Autowired DelegationStore delegationStore, @Autowired WitnessStore witnessStore) { + this.propertiesStore = propertiesStore.getDb(); + this.delegationStore = delegationStore.getDb(); + this.witnessStore = witnessStore.getDb(); + } + + public void init() { + // after init, we can get the latest block header number from db + this.newRewardCalStartCycle = this.getNewRewardAlgorithmEffectiveCycle(); + boolean ret = this.newRewardCalStartCycle != Long.MAX_VALUE; + if (ret) { + // checkpoint is flushed to db, we can start rewardViCalService immediately + lastBlockNumber = Long.MAX_VALUE; + } + ExecutorServiceManager.scheduleWithFixedDelay(es, this::maybeRun, 0, 3, TimeUnit.SECONDS); + } + + private boolean enableNewRewardAlgorithm() { + this.newRewardCalStartCycle = this.getNewRewardAlgorithmEffectiveCycle(); + boolean ret = this.newRewardCalStartCycle != Long.MAX_VALUE; + if (ret && lastBlockNumber == -1) { + lastBlockNumber = this.getLatestBlockHeaderNumber(); + } + return ret; + } + + private boolean isDone() { + return rewardViStore.has(IS_DONE_KEY); + } + + private void maybeRun() { + try { + if (enableNewRewardAlgorithm()) { + if (this.newRewardCalStartCycle > 1) { + if (isDone()) { + this.clearUp(true); + logger.info("rewardViCalService is already done"); + } else { + if (lastBlockNumber == Long.MAX_VALUE // start rewardViCalService immediately + || this.getLatestBlockHeaderNumber() > lastBlockNumber) { + // checkpoint is flushed to db, so we can start rewardViCalService + startRewardCal(); + clearUp(true); + } else { + logger.info("startRewardCal will run after checkpoint is flushed to db"); + } + } + } else { + clearUp(false); + logger.info("rewardViCalService is no need to run"); + } + } + } catch (Exception e) { + logger.error(" Find fatal error, program will be exited soon.", e); + throw new TronError(e, TronError.ErrCode.REWARD_VI_CALCULATOR); + } + } + + private void clearUp(boolean isDone) { + lock.countDown(); + if (isDone) { + calcMerkleRoot(); + } + es.shutdown(); + } + + @PreDestroy + private void destroy() { + es.shutdownNow(); + } + + + public long getNewRewardAlgorithmReward(long beginCycle, long endCycle, + List> votes) { + if (!isDone()) { + logger.warn("rewardViCalService is not done, wait for it"); + try { + lock.await(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new TronDBException(e); + } + } + + long reward = 0; + if (beginCycle < endCycle) { + for (Pair vote : votes) { + byte[] srAddress = vote.getKey(); + BigInteger beginVi = getWitnessVi(beginCycle - 1, srAddress); + BigInteger endVi = getWitnessVi(endCycle - 1, srAddress); + BigInteger deltaVi = endVi.subtract(beginVi); + if (deltaVi.signum() <= 0) { + continue; + } + long userVote = vote.getValue(); + reward += deltaVi.multiply(BigInteger.valueOf(userVote)) + .divide(DelegationStore.DECIMAL_OF_VI_REWARD).longValue(); + } + } + return reward; + + } + + private void calcMerkleRoot() { + logger.info("calcMerkleRoot start"); + DBIterator iterator = rewardViStore.iterator(); + iterator.seekToFirst(); + ArrayList ids = Streams.stream(iterator) + .map(this::getHash) + .collect(Collectors.toCollection(ArrayList::new)); + + Sha256Hash rewardViRootLocal = MerkleRoot.root(ids); + if (!Objects.equals(rewardViRoot, rewardViRootLocal)) { + logger.warn("Merkle root mismatch, expect: {}, actual: {}." + + " If you are quite sure that there is no miscalculation (not on the main network)" + + ", please configure 'storage.merkleRoot.reward-vi = {}'" + + "(for a specific network such as Nile, etc.) in config.conf to fix the hints", + rewardViRoot, rewardViRootLocal, rewardViRootLocal); + } + logger.info("calcMerkleRoot: {}", rewardViRootLocal); + } + + private Sha256Hash getHash(Map.Entry entry) { + return Sha256Hash.of(CommonParameter.getInstance().isECKeyCryptoEngine(), + Bytes.concat(entry.getKey(), entry.getValue())); + } + + private void startRewardCal() { + logger.info("rewardViCalService start"); + rewardViStore.reset(); + DBIterator iterator = (DBIterator) witnessStore.iterator(); + iterator.seekToFirst(); + iterator.forEachRemaining(e -> accumulateWitnessReward(e.getKey())); + rewardViStore.put(IS_DONE_KEY, IS_DONE_VALUE); + logger.info("rewardViCalService is done"); + + } + + private void accumulateWitnessReward(byte[] witness) { + long startCycle = 1; + LongStream.range(startCycle, newRewardCalStartCycle) + .forEach(cycle -> accumulateWitnessVi(cycle, witness)); + } + + private void accumulateWitnessVi(long cycle, byte[] address) { + BigInteger preVi = getWitnessVi(cycle - 1, address); + long voteCount = getWitnessVote(cycle, address); + long reward = getReward(cycle, address); + if (reward == 0 || voteCount == 0) { // Just forward pre vi + if (!BigInteger.ZERO.equals(preVi)) { // Zero vi will not be record + setWitnessVi(cycle, address, preVi); + } + } else { // Accumulate delta vi + BigInteger deltaVi = BigInteger.valueOf(reward) + .multiply(DECIMAL_OF_VI_REWARD) + .divide(BigInteger.valueOf(voteCount)); + setWitnessVi(cycle, address, preVi.add(deltaVi)); + } + } + + private void setWitnessVi(long cycle, byte[] address, BigInteger value) { + byte[] k = buildViKey(cycle, address); + byte[] v = value.toByteArray(); + rewardViStore.put(k, v); + } + + private BigInteger getWitnessVi(long cycle, byte[] address) { + + byte[] v = rewardViStore.get(buildViKey(cycle, address)); + if (v == null) { + return BigInteger.ZERO; + } else { + return new BigInteger(v); + } + } + + private byte[] buildViKey(long cycle, byte[] address) { + return generateKey(cycle, address, "vi"); + } + + private long getReward(long cycle, byte[] address) { + byte[] value = this.delegationStore.get(generateKey(cycle, address, "reward")); + return value == null ? 0 : ByteArray.toLong(value); + } + + private long getWitnessVote(long cycle, byte[] address) { + byte[] value = this.delegationStore.get(generateKey(cycle, address, "vote")); + return value == null ? REMARK : ByteArray.toLong(value); + } + + private byte[] generateKey(long cycle, byte[] address, String suffix) { + return generateKey(cycle + "", address, suffix); + } + + private byte[] generateKey(String prefix, byte[] address, String suffix) { + StringBuilder sb = new StringBuilder(); + if (prefix != null) { + sb.append(prefix).append("-"); + } + sb.append(Hex.toHexString(address)); + if (suffix != null) { + sb.append("-").append(suffix); + } + return sb.toString().getBytes(); + } + + private long getNewRewardAlgorithmEffectiveCycle() { + byte[] value = this.propertiesStore.get("NEW_REWARD_ALGORITHM_EFFECTIVE_CYCLE".getBytes()); + return value == null ? Long.MAX_VALUE : ByteArray.toLong(value); + } + + private long getLatestBlockHeaderNumber() { + byte[] value = this.propertiesStore.get("latest_block_header_number".getBytes()); + return value == null ? 1 : ByteArray.toLong(value); + } +} + diff --git a/chainbase/src/main/java/org/tron/core/store/AssetIssueStore.java b/chainbase/src/main/java/org/tron/core/store/AssetIssueStore.java index d38a5f0677e..4f69a6c3c66 100644 --- a/chainbase/src/main/java/org/tron/core/store/AssetIssueStore.java +++ b/chainbase/src/main/java/org/tron/core/store/AssetIssueStore.java @@ -43,13 +43,6 @@ private List getAssetIssuesPaginated(List return null; } -// return Streams.stream(iterator()) -// .map(Entry::getValue) -// .sorted(Comparator.comparing(a -> a.getName().toStringUtf8(), String::compareTo)) -// .skip(offset) -// .limit(Math.min(limit, ASSET_ISSUE_COUNT_LIMIT_MAX)) -// .collect(Collectors.toList()); - if (assetIssueList.size() <= offset) { return null; } diff --git a/chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java b/chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java index f3059d31558..91b0cff68a0 100644 --- a/chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java +++ b/chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java @@ -1,5 +1,6 @@ package org.tron.core.store; +import static org.tron.common.math.Maths.max; import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCED_INTERVAL; import static org.tron.core.config.Parameter.ChainConstant.DELEGATE_PERIOD; @@ -217,6 +218,20 @@ public class DynamicPropertiesStore extends TronStoreWithRevoking private static final byte[] MAX_DELEGATE_LOCK_PERIOD = "MAX_DELEGATE_LOCK_PERIOD".getBytes(); + private static final byte[] ALLOW_OLD_REWARD_OPT = "ALLOW_OLD_REWARD_OPT".getBytes(); + + private static final byte[] ALLOW_ENERGY_ADJUSTMENT = "ALLOW_ENERGY_ADJUSTMENT".getBytes(); + + private static final byte[] MAX_CREATE_ACCOUNT_TX_SIZE = "MAX_CREATE_ACCOUNT_TX_SIZE".getBytes(); + private static final byte[] ALLOW_STRICT_MATH = "ALLOW_STRICT_MATH".getBytes(); + + private static final byte[] CONSENSUS_LOGIC_OPTIMIZATION + = "CONSENSUS_LOGIC_OPTIMIZATION".getBytes(); + + private static final byte[] ALLOW_TVM_CANCUN = "ALLOW_TVM_CANCUN".getBytes(); + + private static final byte[] ALLOW_TVM_BLOB = "ALLOW_TVM_BLOB".getBytes(); + @Autowired private DynamicPropertiesStore(@Value("properties") String dbName) { super(dbName); @@ -2233,7 +2248,7 @@ public void addTotalNetWeight(long amount) { long totalNetWeight = getTotalNetWeight(); totalNetWeight += amount; if (allowNewReward()) { - totalNetWeight = Math.max(0, totalNetWeight); + totalNetWeight = max(0, totalNetWeight, disableJavaLangMath()); } saveTotalNetWeight(totalNetWeight); } @@ -2246,7 +2261,7 @@ public void addTotalEnergyWeight(long amount) { long totalEnergyWeight = getTotalEnergyWeight(); totalEnergyWeight += amount; if (allowNewReward()) { - totalEnergyWeight = Math.max(0, totalEnergyWeight); + totalEnergyWeight = max(0, totalEnergyWeight, disableJavaLangMath()); } saveTotalEnergyWeight(totalEnergyWeight); } @@ -2259,7 +2274,7 @@ public void addTotalTronPowerWeight(long amount) { long totalWeight = getTotalTronPowerWeight(); totalWeight += amount; if (allowNewReward()) { - totalWeight = Math.max(0, totalWeight); + totalWeight = max(0, totalWeight, disableJavaLangMath()); } saveTotalTronPowerWeight(totalWeight); } @@ -2833,6 +2848,104 @@ public boolean supportMaxDelegateLockPeriod() { getUnfreezeDelayDays() > 0; } + public void saveAllowOldRewardOpt(long allowOldRewardOpt) { + this.put(ALLOW_OLD_REWARD_OPT, new BytesCapsule(ByteArray.fromLong(allowOldRewardOpt))); + } + + public boolean allowOldRewardOpt() { + return getAllowOldRewardOpt() == 1L; + } + + public long getAllowOldRewardOpt() { + return Optional.ofNullable(getUnchecked(ALLOW_OLD_REWARD_OPT)) + .map(BytesCapsule::getData) + .map(ByteArray::toLong) + .orElse(CommonParameter.getInstance().getAllowOldRewardOpt()); + } + + public void saveAllowEnergyAdjustment(long allowEnergyAdjustment) { + this.put(ALLOW_ENERGY_ADJUSTMENT, new BytesCapsule(ByteArray.fromLong(allowEnergyAdjustment))); + } + + public long getAllowEnergyAdjustment() { + return Optional.ofNullable(getUnchecked(ALLOW_ENERGY_ADJUSTMENT)) + .map(BytesCapsule::getData) + .map(ByteArray::toLong) + .orElse(CommonParameter.getInstance().getAllowEnergyAdjustment()); + } + + public void saveMaxCreateAccountTxSize(long maxCreateAccountTxSize) { + this.put(MAX_CREATE_ACCOUNT_TX_SIZE, + new BytesCapsule(ByteArray.fromLong(maxCreateAccountTxSize))); + } + + public long getMaxCreateAccountTxSize() { + return Optional.ofNullable(getUnchecked(MAX_CREATE_ACCOUNT_TX_SIZE)) + .map(BytesCapsule::getData) + .map(ByteArray::toLong) + .orElse(CommonParameter.getInstance().getMaxCreateAccountTxSize()); + } + public long getAllowStrictMath() { + return Optional.ofNullable(getUnchecked(ALLOW_STRICT_MATH)) + .map(BytesCapsule::getData) + .map(ByteArray::toLong) + .orElse(CommonParameter.getInstance().getAllowStrictMath()); + } + public void saveAllowStrictMath(long allowStrictMath) { + this.put(ALLOW_STRICT_MATH, new BytesCapsule(ByteArray.fromLong(allowStrictMath))); + } + + public boolean allowStrictMath() { + return getAllowStrictMath() == 1L; + } + + public boolean disableJavaLangMath() { + return this.allowConsensusLogicOptimization(); + } + + public void saveConsensusLogicOptimization(long value) { + this.put(CONSENSUS_LOGIC_OPTIMIZATION, + new BytesCapsule(ByteArray.fromLong(value))); + } + + public long getConsensusLogicOptimization() { + return Optional.ofNullable(getUnchecked(CONSENSUS_LOGIC_OPTIMIZATION)) + .map(BytesCapsule::getData) + .map(ByteArray::toLong) + .orElse(CommonParameter.getInstance().getConsensusLogicOptimization()); + } + + public boolean allowConsensusLogicOptimization() { + return getConsensusLogicOptimization() == 1L; + } + + public boolean allowWitnessSortOptimization() { + return this.allowConsensusLogicOptimization(); + } + + public void saveAllowTvmCancun(long allowTvmCancun) { + this.put(ALLOW_TVM_CANCUN, + new BytesCapsule(ByteArray.fromLong(allowTvmCancun))); + } + + public long getAllowTvmCancun() { + return Optional.ofNullable(getUnchecked(ALLOW_TVM_CANCUN)) + .map(BytesCapsule::getData) + .map(ByteArray::toLong) + .orElse(CommonParameter.getInstance().getAllowTvmCancun()); + } + + public void saveAllowTvmBlob(long allowTvmBlob) { + this.put(ALLOW_TVM_BLOB, new BytesCapsule(ByteArray.fromLong(allowTvmBlob))); + } + + public long getAllowTvmBlob() { + return Optional.ofNullable(getUnchecked(ALLOW_TVM_BLOB)) + .map(BytesCapsule::getData) + .map(ByteArray::toLong) + .orElse(CommonParameter.getInstance().getAllowTvmBlob()); + } + private static class DynamicResourceProperties { private static final byte[] ONE_DAY_NET_LIMIT = "ONE_DAY_NET_LIMIT".getBytes(); diff --git a/chainbase/src/main/java/org/tron/core/store/RewardViStore.java b/chainbase/src/main/java/org/tron/core/store/RewardViStore.java new file mode 100755 index 00000000000..f173cecc00f --- /dev/null +++ b/chainbase/src/main/java/org/tron/core/store/RewardViStore.java @@ -0,0 +1,43 @@ +package org.tron.core.store; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.tron.core.db.TronDatabase; +import org.tron.core.db.common.iterator.DBIterator; + +@Slf4j(topic = "DB") +@Component +public class RewardViStore extends TronDatabase { + + @Autowired + private RewardViStore(@Value("reward-vi") String dbName) { + super(dbName); + } + + @Override + public byte[] get(byte[] key) { + return dbSource.getData(key); + } + + @Override + public void put(byte[] key, byte[] item) { + dbSource.putData(key, item); + } + + @Override + public void delete(byte[] key) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean has(byte[] key) { + return dbSource.getData(key) != null; + } + + @Override + public DBIterator iterator() { + return ((DBIterator) dbSource.iterator()); + } +} diff --git a/chainbase/src/main/java/org/tron/core/store/WitnessStore.java b/chainbase/src/main/java/org/tron/core/store/WitnessStore.java index e01680cfc74..9f444d3333d 100644 --- a/chainbase/src/main/java/org/tron/core/store/WitnessStore.java +++ b/chainbase/src/main/java/org/tron/core/store/WitnessStore.java @@ -1,6 +1,7 @@ package org.tron.core.store; import com.google.common.collect.Streams; +import com.google.protobuf.ByteString; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -11,10 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import org.tron.common.cache.CacheManager; -import org.tron.common.cache.CacheStrategies; -import org.tron.common.cache.CacheType; -import org.tron.common.cache.TronCache; +import org.tron.common.utils.ByteArray; import org.tron.core.capsule.WitnessCapsule; import org.tron.core.config.Parameter; import org.tron.core.db.TronStoreWithRevoking; @@ -22,14 +20,10 @@ @Slf4j(topic = "DB") @Component public class WitnessStore extends TronStoreWithRevoking { - // cache for 127 SR - private final TronCache> witnessStandbyCache; @Autowired protected WitnessStore(@Value("witness") String dbName) { super(dbName); - String strategy = String.format(CacheStrategies.PATTERNS, 1, 1, "30s", 1); - witnessStandbyCache = CacheManager.allocate(CacheType.witnessStandby, strategy); } /** @@ -47,23 +41,10 @@ public WitnessCapsule get(byte[] key) { return ArrayUtils.isEmpty(value) ? null : new WitnessCapsule(value); } - public List getWitnessStandby() { - List list = - witnessStandbyCache.getIfPresent(Parameter.ChainConstant.WITNESS_STANDBY_LENGTH); - if (list != null) { - return list; - } - return updateWitnessStandby(null); - } - - public List updateWitnessStandby(List all) { + public List getWitnessStandby(boolean isSortOpt) { List ret; - if (all == null) { - all = getAllWitnesses(); - } - all.sort(Comparator.comparingLong(WitnessCapsule::getVoteCount) - .reversed().thenComparing(Comparator.comparingInt( - (WitnessCapsule w) -> w.getAddress().hashCode()).reversed())); + List all = getAllWitnesses(); + sortWitnesses(all, isSortOpt); if (all.size() > Parameter.ChainConstant.WITNESS_STANDBY_LENGTH) { ret = new ArrayList<>(all.subList(0, Parameter.ChainConstant.WITNESS_STANDBY_LENGTH)); } else { @@ -71,8 +52,21 @@ public List updateWitnessStandby(List all) { } // trim voteCount = 0 ret.removeIf(w -> w.getVoteCount() < 1); - witnessStandbyCache.put(Parameter.ChainConstant.WITNESS_STANDBY_LENGTH, ret); return ret; } + public void sortWitnesses(List witnesses, boolean isSortOpt) { + witnesses.sort(Comparator.comparingLong(WitnessCapsule::getVoteCount).reversed() + .thenComparing(isSortOpt + ? Comparator.comparing(WitnessCapsule::createReadableString).reversed() + : Comparator.comparingInt((WitnessCapsule w) -> w.getAddress().hashCode()).reversed())); + } + + public void sortWitness(List list, boolean isSortOpt) { + list.sort(Comparator.comparingLong((ByteString b) -> get(b.toByteArray()).getVoteCount()) + .reversed().thenComparing(isSortOpt + ? Comparator.comparing( + (ByteString b) -> ByteArray.toHexString(b.toByteArray())).reversed() + : Comparator.comparingInt(ByteString::hashCode).reversed())); + } } diff --git a/common/build.gradle b/common/build.gradle index 0431316c009..c6ce8cf44f9 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -8,7 +8,6 @@ sourceCompatibility = 1.8 // Dependency versions // --------------------------------------- - def leveldbVersion = "1.8" // -------------------------------------- @@ -30,37 +29,39 @@ if (isWindows()) { } } -repositories { - mavenCentral() -} - dependencies { - testCompile group: 'junit', name: 'junit', version: '4.13.2' - compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69' - compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.4.1' - compile "com.cedarsoftware:java-util:1.8.0" - compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.1' - compile group: 'commons-codec', name: 'commons-codec', version: '1.11' - compile group: 'com.beust', name: 'jcommander', version: '1.72' - compile group: 'com.typesafe', name: 'config', version: '1.3.2' - compile group: leveldbGroup, name: leveldbName, version: leveldbVersion - compile group: 'org.rocksdb', name: 'rocksdbjni', version: '5.15.10' - // https://mvnrepository.com/artifact/org.quartz-scheduler/quartz - compile group: 'org.quartz-scheduler', name: 'quartz', version: '2.3.2' - compile group: 'io.prometheus', name: 'simpleclient', version: '0.15.0' - compile group: 'io.prometheus', name: 'simpleclient_httpserver', version: '0.15.0' - compile group: 'io.prometheus', name: 'simpleclient_hotspot', version: '0.15.0' - compile 'org.aspectj:aspectjrt:1.8.13' - compile 'org.aspectj:aspectjweaver:1.8.13' - compile 'org.aspectj:aspectjtools:1.8.13' - compile group: 'io.github.tronprotocol', name: 'libp2p', version: '2.1.0',{ + api group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.4.2' // https://github.com/FasterXML/jackson-databind/issues/3627 + api "com.cedarsoftware:java-util:1.8.0" + api group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.1' + api group: 'commons-codec', name: 'commons-codec', version: '1.11' + api group: 'com.beust', name: 'jcommander', version: '1.78' + api group: 'com.typesafe', name: 'config', version: '1.3.2' + api group: leveldbGroup, name: leveldbName, version: leveldbVersion + api group: 'org.rocksdb', name: 'rocksdbjni', version: '5.15.10' + api group: 'io.prometheus', name: 'simpleclient', version: '0.15.0' + api group: 'io.prometheus', name: 'simpleclient_httpserver', version: '0.15.0' + api group: 'io.prometheus', name: 'simpleclient_hotspot', version: '0.15.0' + api 'org.aspectj:aspectjrt:1.8.13' + api 'org.aspectj:aspectjweaver:1.8.13' + api 'org.aspectj:aspectjtools:1.8.13' + api group: 'io.github.tronprotocol', name: 'libp2p', version: '2.2.5',{ exclude group: 'io.grpc', module: 'grpc-context' exclude group: 'io.grpc', module: 'grpc-core' exclude group: 'io.grpc', module: 'grpc-netty' exclude group: 'com.google.protobuf', module: 'protobuf-java' exclude group: 'com.google.protobuf', module: 'protobuf-java-util' + // https://github.com/dom4j/dom4j/pull/116 + // https://github.com/gradle/gradle/issues/13656 + // https://github.com/dom4j/dom4j/issues/99 + exclude group: 'jaxen', module: 'jaxen' + exclude group: 'javax.xml.stream', module: 'stax-api' + exclude group: 'net.java.dev.msv', module: 'xsdlib' + exclude group: 'pull-parser', module: 'pull-parser' + exclude group: 'xpp3', module: 'xpp3' + exclude group: 'org.bouncycastle', module: 'bcprov-jdk18on' + exclude group: 'org.bouncycastle', module: 'bcutil-jdk18on' } - compile project(":protocol") + api project(":protocol") } jacocoTestReport { diff --git a/common/src/main/java/org/tron/common/cron/CronExpression.java b/common/src/main/java/org/tron/common/cron/CronExpression.java new file mode 100644 index 00000000000..0445ec2ce5b --- /dev/null +++ b/common/src/main/java/org/tron/common/cron/CronExpression.java @@ -0,0 +1,1411 @@ +/* + * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. + * Copyright IBM Corp. 2024, 2025 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + */ + +package org.tron.common.cron; + +import java.io.Serializable; +import java.text.ParseException; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; +import java.util.SortedSet; +import java.util.StringTokenizer; +import java.util.TimeZone; +import java.util.TreeSet; + +/** + * Provides a parser and evaluator for unix-like cron expressions. Cron + * expressions provide the ability to specify complex time combinations such as + * "At 8:00am every Monday through Friday" or "At 1:30am every + * last Friday of the month". + *

+ * Cron expressions are comprised of 6 required fields and one optional field + * separated by white space. The fields respectively are described as follows: + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Examples of cron expressions and their meanings.
Field Name Allowed Values Allowed Special Characters
Seconds 0-59 , - * /
Minutes 0-59 , - * /
Hours 0-23 , - * /
Day-of-month 1-31 , - * ? / L W
Month 0-11 or JAN-DEC , - * /
Day-of-Week 1-7 or SUN-SAT , - * ? / L #
Year (Optional) empty, 1970-2199 , - * /
+ *

+ * The '*' character is used to specify all values. For example, "*" + * in the minute field means "every minute". + *

+ *

+ * The '?' character is allowed for the day-of-month and day-of-week fields. It + * is used to specify 'no specific value'. This is useful when you need to + * specify something in one of the two fields, but not the other. + *

+ * The '-' character is used to specify ranges For example "10-12" in + * the hour field means "the hours 10, 11 and 12". + *

+ * The ',' character is used to specify additional values. For example + * "MON,WED,FRI" in the day-of-week field means "the days Monday, + * Wednesday, and Friday". + *

+ *

+ * The '/' character is used to specify increments. For example "0/15" + * in the seconds field means "the seconds 0, 15, 30, and 45". And + * "5/15" in the seconds field means "the seconds 5, 20, 35, and + * 50". Specifying '*' before the '/' is equivalent to specifying 0 is + * the value to start with. Essentially, for each field in the expression, there + * is a set of numbers that can be turned on or off. For seconds and minutes, + * the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to + * 31, and for months 0 to 11 (JAN to DEC). The "/" character simply helps you turn + * on every "nth" value in the given set. Thus "7/6" in the + * month field only turns on month "7", it does NOT mean every 6th + * month, please note that subtlety. + *

+ *

+ * The 'L' character is allowed for the day-of-month and day-of-week fields. + * This character is short-hand for "last", but it has different + * meaning in each of the two fields. For example, the value "L" in + * the day-of-month field means "the last day of the month" - day 31 + * for January, day 28 for February on non-leap years. If used in the + * day-of-week field by itself, it simply means "7" or + * "SAT". But if used in the day-of-week field after another value, it + * means "the last xxx day of the month" - for example "6L" + * means "the last friday of the month". You can also specify an offset + * from the last day of the month, such as "L-3" which would mean the third-to-last + * day of the calendar month. When using the 'L' option, it is important not to + * specify lists, or ranges of values, as you'll get confusing/unexpected results. + *

+ *

+ * The 'W' character is allowed for the day-of-month field. This character + * is used to specify the weekday (Monday-Friday) nearest the given day. As an + * example, if you were to specify "15W" as the value for the + * day-of-month field, the meaning is: "the nearest weekday to the 15th of + * the month". So if the 15th is a Saturday, the trigger will fire on + * Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the + * 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. + * However if you specify "1W" as the value for day-of-month, and the + * 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not + * 'jump' over the boundary of a month's days. The 'W' character can only be + * specified when the day-of-month is a single day, not a range or list of days. + *

+ *

+ * The 'L' and 'W' characters can also be combined for the day-of-month + * expression to yield 'LW', which translates to "last weekday of the + * month". + *

+ *

+ * The '#' character is allowed for the day-of-week field. This character is + * used to specify "the nth" XXX day of the month. For example, the + * value of "6#3" in the day-of-week field means the third Friday of + * the month (day 6 = Friday and "#3" = the 3rd one in the month). + * Other examples: "2#1" = the first Monday of the month and + * "4#5" = the fifth Wednesday of the month. Note that if you specify + * "#5" and there is not 5 of the given day-of-week in the month, then + * no firing will occur that month. If the '#' character is used, there can + * only be one expression in the day-of-week field ("3#1,6#3" is + * not valid, since there are two expressions). + *

+ * + *

+ * The legal characters and the names of months and days of the week are not + * case sensitive. + * + *

+ * NOTES: + *

+ *
    + *
  • Support for specifying both a day-of-week and a day-of-month value is + * not complete (you'll need to use the '?' character in one of these fields). + *
  • + *
  • Overflowing ranges is supported - that is, having a larger number on + * the left hand side than the right. You might do 22-2 to catch 10 o'clock + * at night until 2 o'clock in the morning, or you might have NOV-FEB. It is + * very important to note that overuse of overflowing ranges creates ranges + * that don't make sense and no effort has been made to determine which + * interpretation CronExpression chooses. An example would be + * "0 0 14-6 ? * FRI-MON".
  • + *
+ * + * @author Sharada Jambula, James House + * @author Contributions from Mads Henderson + * @author Refactoring from CronTrigger to CronExpression by Aaron Craven + */ +public final class CronExpression implements Serializable { + + public static final int MAX_YEAR = Calendar.getInstance().get(Calendar.YEAR) + 100; + private static final int SECOND = 0; + private static final int MINUTE = 1; + private static final int HOUR = 2; + private static final int DAY_OF_MONTH = 3; + private static final int MONTH = 4; + private static final int DAY_OF_WEEK = 5; + private static final int YEAR = 6; + private static final int ALL_SPEC_INT = 99; // '*' + private static final int NO_SPEC_INT = 98; // '?' + private static final int MAX_LAST_DAY_OFFSET = 30; + private static final int LAST_DAY_OFFSET_START = 32; // "L-30" + private static final int LAST_DAY_OFFSET_END = LAST_DAY_OFFSET_START + MAX_LAST_DAY_OFFSET; // 'L' + private static final Integer ALL_SPEC = ALL_SPEC_INT; + private static final Integer NO_SPEC = NO_SPEC_INT; + private static final Map monthMap = new HashMap<>(20); + private static final Map dayMap = new HashMap<>(60); + private static final long serialVersionUID = 12423409423L; + + static { + monthMap.put("JAN", 0); + monthMap.put("FEB", 1); + monthMap.put("MAR", 2); + monthMap.put("APR", 3); + monthMap.put("MAY", 4); + monthMap.put("JUN", 5); + monthMap.put("JUL", 6); + monthMap.put("AUG", 7); + monthMap.put("SEP", 8); + monthMap.put("OCT", 9); + monthMap.put("NOV", 10); + monthMap.put("DEC", 11); + + dayMap.put("SUN", 1); + dayMap.put("MON", 2); + dayMap.put("TUE", 3); + dayMap.put("WED", 4); + dayMap.put("THU", 5); + dayMap.put("FRI", 6); + dayMap.put("SAT", 7); + } + + private final String cronExpression; + private TimeZone timeZone = null; + private transient TreeSet seconds; + private transient TreeSet minutes; + private transient TreeSet hours; + private transient TreeSet daysOfMonth; + private transient TreeSet nearestWeekdays; + private transient TreeSet months; + private transient TreeSet daysOfWeek; + private transient TreeSet years; + private transient boolean lastDayOfWeek = false; + private transient int nthDayOfWeek = 0; + + /** + * Constructs a new CronExpression based on the specified + * parameter. + * + * @param cronExpression String representation of the cron expression the + * new object should represent + * @throws java.text.ParseException if the string expression cannot be parsed into a valid + * CronExpression + */ + public CronExpression(String cronExpression) throws ParseException { + if (cronExpression == null) { + throw new IllegalArgumentException("cronExpression cannot be null"); + } + + this.cronExpression = cronExpression.toUpperCase(Locale.US); + + buildExpression(this.cronExpression); + } + + /** + * Indicates whether the specified cron expression can be parsed into a + * valid cron expression + * + * @param cronExpression the expression to evaluate + * @return a boolean indicating whether the given expression is a valid cron + * expression + */ + public static boolean isValidExpression(String cronExpression) { + try { + validateExpression(cronExpression); + } catch (ParseException pe) { + return false; + } + return true; + } + + public static void validateExpression(String cronExpression) throws ParseException { + new CronExpression(cronExpression); + } + + /** + * Indicates whether the given date satisfies the cron expression. Note that + * milliseconds are ignored, so two Dates falling on different milliseconds + * of the same second will always have the same result here. + * + * @param date the date to evaluate + * @return a boolean indicating whether the given date satisfies the cron + * expression + */ + public boolean isSatisfiedBy(Date date) { + Calendar testDateCal = Calendar.getInstance(getTimeZone()); + testDateCal.setTime(date); + testDateCal.set(Calendar.MILLISECOND, 0); + Date originalDate = testDateCal.getTime(); + + testDateCal.add(Calendar.SECOND, -1); + + Date timeAfter = getTimeAfter(testDateCal.getTime()); + + return ((timeAfter != null) && (timeAfter.equals(originalDate))); + } + + /** + * Returns the next date/time after the given date/time which + * satisfies the cron expression. + * + * @param date the date/time at which to begin the search for the next valid + * date/time + * @return the next valid date/time + */ + public Date getNextValidTimeAfter(Date date) { + return getTimeAfter(date); + } + + /** + * Returns the time zone for which this CronExpression + * will be resolved. + */ + public TimeZone getTimeZone() { + if (timeZone == null) { + timeZone = TimeZone.getDefault(); + } + + return timeZone; + } + + /** + * Sets the time zone for which this CronExpression + * will be resolved. + */ + public void setTimeZone(TimeZone timeZone) { + this.timeZone = timeZone; + } + + /** + * Returns the string representation of the CronExpression + * + * @return a string representation of the CronExpression + */ + @Override + public String toString() { + return cronExpression; + } + + private void buildExpression(String expression) throws ParseException { + try { + + if (seconds == null) { + seconds = new TreeSet<>(); + } + if (minutes == null) { + minutes = new TreeSet<>(); + } + if (hours == null) { + hours = new TreeSet<>(); + } + if (daysOfMonth == null) { + daysOfMonth = new TreeSet<>(); + } + if (nearestWeekdays == null) { + nearestWeekdays = new TreeSet<>(); + } + if (months == null) { + months = new TreeSet<>(); + } + if (daysOfWeek == null) { + daysOfWeek = new TreeSet<>(); + } + if (years == null) { + years = new TreeSet<>(); + } + + int exprOn = SECOND; + + StringTokenizer exprsTok = new StringTokenizer(expression, " \t", + false); + + if(exprsTok.countTokens() > 7) { + throw new ParseException("Invalid expression has too many terms: " + expression, -1); + } + + while (exprsTok.hasMoreTokens() && exprOn <= YEAR) { + String expr = exprsTok.nextToken().trim(); + + // throw an exception if L is used with other days of the week + if (exprOn == DAY_OF_WEEK && expr.indexOf('L') != -1 && expr.length() > 1 + && expr.contains(",")) { + throw new ParseException("Support for specifying 'L' " + + "with other days of the week is not implemented", -1); + } + if (exprOn == DAY_OF_WEEK && expr.indexOf('#') != -1 + && expr.indexOf('#', expr.indexOf('#') +1) != -1) { + throw new ParseException( + "Support for specifying multiple \"nth\" days is not implemented.", -1); + } + + StringTokenizer vTok = new StringTokenizer(expr, ","); + while (vTok.hasMoreTokens()) { + String v = vTok.nextToken(); + storeExpressionVals(0, v, exprOn); + } + + exprOn++; + } + + if (exprOn <= DAY_OF_WEEK) { + throw new ParseException("Unexpected end of expression.", expression.length()); + } + + if (exprOn <= YEAR) { + storeExpressionVals(0, "*", YEAR); + } + + TreeSet dow = getSet(DAY_OF_WEEK); + TreeSet dom = getSet(DAY_OF_MONTH); + + // Copying the logic from the UnsupportedOperationException below + boolean dayOfMSpec = !dom.contains(NO_SPEC); + boolean dayOfWSpec = !dow.contains(NO_SPEC); + + if ((!dayOfMSpec || dayOfWSpec) && (!dayOfWSpec || dayOfMSpec)) { + throw new ParseException( + "Support for specifying both a day-of-week AND a day-of-month" + + " parameter is not implemented.", 0); + } + } catch (ParseException pe) { + throw pe; + } catch (Exception e) { + throw new ParseException("Illegal cron expression format (" + e + ")", 0); + } + } + + private int storeExpressionVals(int pos, String s, int type) + throws ParseException { + + int incr = 0; + int i = skipWhiteSpace(pos, s); + if (i >= s.length()) { + return i; + } + char c = s.charAt(i); + if ((c >= 'A') && (c <= 'Z') && (!"L".equals(s)) && (!"LW".equals(s)) + && (!s.matches("^L-[0-9]*[W]?"))) { + String sub = s.substring(i, i + 3); + int sval; + int eval = -1; + if (type == MONTH) { + sval = getMonthNumber(sub) + 1; + if (sval <= 0) { + throw new ParseException("Invalid Month value: '" + sub + "'", i); + } + if (s.length() > i + 3) { + c = s.charAt(i + 3); + if (c == '-') { + i += 4; + sub = s.substring(i, i + 3); + eval = getMonthNumber(sub) + 1; + if (eval <= 0) { + throw new ParseException("Invalid Month value: '" + sub + "'", i); + } + } + } + } else if (type == DAY_OF_WEEK) { + sval = getDayOfWeekNumber(sub); + if (sval < 0) { + throw new ParseException("Invalid Day-of-Week value: '" + sub + "'", i); + } + if (s.length() > i + 3) { + c = s.charAt(i + 3); + if (c == '-') { + i += 4; + sub = s.substring(i, i + 3); + eval = getDayOfWeekNumber(sub); + if (eval < 0) { + throw new ParseException("Invalid Day-of-Week value: '" + sub + "'", i); + } + } else if (c == '#') { + try { + i += 4; + nthDayOfWeek = Integer.parseInt(s.substring(i)); + if (nthDayOfWeek < 1 || nthDayOfWeek > 5) { + throw new Exception(); + } + } catch (Exception e) { + throw new ParseException( + "A numeric value between 1 and 5 must follow the '#' option", i); + } + } else if (c == 'L') { + lastDayOfWeek = true; + i++; + } + } + + } else { + throw new ParseException("Illegal characters for this position: '" + sub + "'", i); + } + if (eval != -1) { + incr = 1; + } + addToSet(sval, eval, incr, type); + return (i + 3); + } + + if (c == '?') { + i++; + if ((i + 1) < s.length() + && (s.charAt(i) != ' ' && s.charAt(i + 1) != '\t')) { + throw new ParseException("Illegal character after '?': " + s.charAt(i), i); + } + if (type != DAY_OF_WEEK && type != DAY_OF_MONTH) { + throw new ParseException( + "'?' can only be specified for Day-of-Month or Day-of-Week.", i); + } + if ((type == DAY_OF_WEEK) && (!daysOfMonth.isEmpty() && daysOfMonth.last() == NO_SPEC_INT)) { + throw new ParseException("'?' can only be specified for Day-of-Month -OR- Day-of-Week.", i); + } + + addToSet(NO_SPEC_INT, -1, 0, type); + return i; + } + + if (c == '*' || c == '/') { + if (c == '*' && (i + 1) >= s.length()) { + addToSet(ALL_SPEC_INT, -1, incr, type); + return i + 1; + } else if (c == '/' + && ((i + 1) >= s.length() || s.charAt(i + 1) == ' ' || s + .charAt(i + 1) == '\t')) { + throw new ParseException("'/' must be followed by an integer.", i); + } else if (c == '*') { + i++; + } + c = s.charAt(i); + if (c == '/') { // is an increment specified? + i++; + if (i >= s.length()) { + throw new ParseException("Unexpected end of string.", i); + } + + incr = getNumericValue(s, i); + + i++; + if (incr > 10) { + i++; + } + checkIncrementRange(incr, type, i); + } else { + incr = 1; + } + + addToSet(ALL_SPEC_INT, -1, incr, type); + return i; + } else if (c == 'L') { + i++; + if (type == DAY_OF_WEEK) { + addToSet(7, 7, 0, type); + } + if (type == DAY_OF_MONTH) { + int dom = LAST_DAY_OFFSET_END; + boolean nearestWeekday = false; + if (s.length() > i) { + c = s.charAt(i); + if (c == '-') { + ValueSet vs = getValue(0, s, i + 1); + int offset = vs.value; + if (offset > MAX_LAST_DAY_OFFSET) { + throw new ParseException( + "Offset from last day must be <= " + MAX_LAST_DAY_OFFSET, i + 1); + } + dom -= offset; + i = vs.pos; + } + if (s.length() > i) { + c = s.charAt(i); + if (c == 'W') { + nearestWeekday = true; + i++; + } + } + } + if (nearestWeekday) { + nearestWeekdays.add(dom); + } else { + daysOfMonth.add(dom); + } + } + return i; + } else if (c >= '0' && c <= '9') { + int val = Integer.parseInt(String.valueOf(c)); + i++; + if (i >= s.length()) { + addToSet(val, -1, -1, type); + } else { + c = s.charAt(i); + if (c >= '0' && c <= '9') { + ValueSet vs = getValue(val, s, i); + val = vs.value; + i = vs.pos; + } + i = checkNext(i, s, val, type); + return i; + } + } else { + throw new ParseException("Unexpected character: " + c, i); + } + + return i; + } + + private void checkIncrementRange(int incr, int type, int idxPos) throws ParseException { + if (incr > 59 && (type == SECOND || type == MINUTE)) { + throw new ParseException("Increment > 60 : " + incr, idxPos); + } else if (incr > 23 && (type == HOUR)) { + throw new ParseException("Increment > 24 : " + incr, idxPos); + } else if (incr > 31 && (type == DAY_OF_MONTH)) { + throw new ParseException("Increment > 31 : " + incr, idxPos); + } else if (incr > 7 && (type == DAY_OF_WEEK)) { + throw new ParseException("Increment > 7 : " + incr, idxPos); + } else if (incr > 12 && (type == MONTH)) { + throw new ParseException("Increment > 12 : " + incr, idxPos); + } + } + + private int checkNext(int pos, String s, int val, int type) + throws ParseException { + + int end = -1; + int i = pos; + + if (i >= s.length()) { + addToSet(val, end, -1, type); + return i; + } + + char c = s.charAt(pos); + + if (c == 'L') { + if (type == DAY_OF_WEEK) { + if(val < 1 || val > 7) + throw new ParseException("Day-of-Week values must be between 1 and 7", -1); + lastDayOfWeek = true; + } else { + throw new ParseException("'L' option is not valid here. (pos=" + i + ")", i); + } + TreeSet set = getSet(type); + set.add(val); + i++; + return i; + } + + if (c == 'W') { + if (type != DAY_OF_MONTH) { + throw new ParseException("'W' option is not valid here. (pos=" + i + ")", i); + } + if (val > 31) { + throw new ParseException("The 'W' option does not make sense with values larger than" + + " 31 (max number of days in a month)", i); + } + + nearestWeekdays.add(val); + i++; + return i; + } + + if (c == '#') { + if (type != DAY_OF_WEEK) { + throw new ParseException("'#' option is not valid here. (pos=" + i + ")", i); + } + i++; + try { + nthDayOfWeek = Integer.parseInt(s.substring(i)); + if (nthDayOfWeek < 1 || nthDayOfWeek > 5) { + throw new Exception(); + } + } catch (Exception e) { + throw new ParseException( + "A numeric value between 1 and 5 must follow the '#' option", + i); + } + + TreeSet set = getSet(type); + set.add(val); + i++; + return i; + } + + if (c == '-') { + i++; + c = s.charAt(i); + int v = Integer.parseInt(String.valueOf(c)); + end = v; + i++; + if (i >= s.length()) { + addToSet(val, end, 1, type); + return i; + } + c = s.charAt(i); + if (c >= '0' && c <= '9') { + ValueSet vs = getValue(v, s, i); + end = vs.value; + i = vs.pos; + } + if (i < s.length() && (s.charAt(i) == '/')) { + i++; + c = s.charAt(i); + int v2 = Integer.parseInt(String.valueOf(c)); + i++; + if (i >= s.length()) { + addToSet(val, end, v2, type); + return i; + } + c = s.charAt(i); + if (c >= '0' && c <= '9') { + ValueSet vs = getValue(v2, s, i); + int v3 = vs.value; + addToSet(val, end, v3, type); + i = vs.pos; + return i; + } else { + addToSet(val, end, v2, type); + return i; + } + } else { + addToSet(val, end, 1, type); + return i; + } + } + + if (c == '/') { + if ((i + 1) >= s.length() || s.charAt(i + 1) == ' ' || s.charAt(i + 1) == '\t') { + throw new ParseException("'/' must be followed by an integer.", i); + } + + i++; + c = s.charAt(i); + int v2 = Integer.parseInt(String.valueOf(c)); + i++; + if (i >= s.length()) { + checkIncrementRange(v2, type, i); + addToSet(val, end, v2, type); + return i; + } + c = s.charAt(i); + if (c >= '0' && c <= '9') { + ValueSet vs = getValue(v2, s, i); + int v3 = vs.value; + checkIncrementRange(v3, type, i); + addToSet(val, end, v3, type); + i = vs.pos; + return i; + } else { + throw new ParseException("Unexpected character '" + c + "' after '/'", i); + } + } + + addToSet(val, end, 0, type); + i++; + return i; + } + + public String getCronExpression() { + return cronExpression; + } + + private int skipWhiteSpace(int i, String s) { + for (; i < s.length() && (s.charAt(i) == ' ' || s.charAt(i) == '\t'); i++) { + } + + return i; + } + + private int findNextWhiteSpace(int i, String s) { + for (; i < s.length() && (s.charAt(i) != ' ' || s.charAt(i) != '\t'); i++) { + } + + return i; + } + + private void addToSet(int val, int end, int incr, int type) + throws ParseException { + + TreeSet set = getSet(type); + + if (type == SECOND || type == MINUTE) { + if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) { + throw new ParseException("Minute and Second values must be between 0 and 59", -1); + } + } else if (type == HOUR) { + if ((val < 0 || val > 23 || end > 23) && (val != ALL_SPEC_INT)) { + throw new ParseException("Hour values must be between 0 and 23", -1); + } + } else if (type == DAY_OF_MONTH) { + if ((val < 1 || val > 31 || end > 31) && (val != ALL_SPEC_INT) + && (val != NO_SPEC_INT)) { + throw new ParseException("Day of month values must be between 1 and 31", -1); + } + } else if (type == MONTH) { + if ((val < 1 || val > 12 || end > 12) && (val != ALL_SPEC_INT)) { + throw new ParseException("Month values must be between 1 and 12", -1); + } + } else if (type == DAY_OF_WEEK && ((val == 0 || val > 7 || end > 7) && (val != ALL_SPEC_INT) + && (val != NO_SPEC_INT))) { + throw new ParseException("Day-of-Week values must be between 1 and 7", -1); + } + + if ((incr == 0 || incr == -1) && val != ALL_SPEC_INT) { + if (val != -1) { + set.add(val); + } else { + set.add(NO_SPEC); + } + + return; + } + + int startAt = val; + int stopAt = end; + + if (val == ALL_SPEC_INT && incr <= 0) { + incr = 1; + set.add(ALL_SPEC); // put in a marker, but also fill values + } + + if (type == SECOND || type == MINUTE) { + if (stopAt == -1) { + stopAt = 59; + } + if (startAt == -1 || startAt == ALL_SPEC_INT) { + startAt = 0; + } + } else if (type == HOUR) { + if (stopAt == -1) { + stopAt = 23; + } + if (startAt == -1 || startAt == ALL_SPEC_INT) { + startAt = 0; + } + } else if (type == DAY_OF_MONTH) { + if (stopAt == -1) { + stopAt = 31; + } + if (startAt == -1 || startAt == ALL_SPEC_INT) { + startAt = 1; + } + } else if (type == MONTH) { + if (stopAt == -1) { + stopAt = 12; + } + if (startAt == -1 || startAt == ALL_SPEC_INT) { + startAt = 1; + } + } else if (type == DAY_OF_WEEK) { + if (stopAt == -1) { + stopAt = 7; + } + if (startAt == -1 || startAt == ALL_SPEC_INT) { + startAt = 1; + } + } else if (type == YEAR) { + if (stopAt == -1) { + stopAt = MAX_YEAR; + } + if (startAt == -1 || startAt == ALL_SPEC_INT) { + startAt = 1970; + } + } + + // if the end of the range is before the start, then we need to overflow into + // the next day, month etc. This is done by adding the maximum amount for that + // type, and using modulus max to determine the value being added. + int max = -1; + if (stopAt < startAt) { + switch (type) { + case SECOND: + case MINUTE: + max = 60; + break; + case HOUR: + max = 24; + break; + case MONTH: + max = 12; + break; + case DAY_OF_WEEK: + max = 7; + break; + case DAY_OF_MONTH: + max = 31; + break; + case YEAR: + throw new IllegalArgumentException("Start year must be less than stop year"); + default: + throw new IllegalArgumentException("Unexpected type encountered"); + } + stopAt += max; + } + + for (int i = startAt; i <= stopAt; i += incr) { + if (max == -1) { + // ie: there's no max to overflow over + set.add(i); + } else { + // take the modulus to get the real value + int i2 = i % max; + + // 1-indexed ranges should not include 0, and should include their max + if (i2 == 0 && (type == MONTH || type == DAY_OF_WEEK || type == DAY_OF_MONTH)) { + i2 = max; + } + + set.add(i2); + } + } + } + + TreeSet getSet(int type) { + switch (type) { + case SECOND: + return seconds; + case MINUTE: + return minutes; + case HOUR: + return hours; + case DAY_OF_MONTH: + return daysOfMonth; + case MONTH: + return months; + case DAY_OF_WEEK: + return daysOfWeek; + case YEAR: + return years; + default: + throw new IllegalArgumentException("Invalid type encountered: " + type); + } + } + + private ValueSet getValue(int v, String s, int i) { + char c = s.charAt(i); + StringBuilder s1 = new StringBuilder(String.valueOf(v)); + while (c >= '0' && c <= '9') { + s1.append(c); + i++; + if (i >= s.length()) { + break; + } + c = s.charAt(i); + } + ValueSet val = new ValueSet(); + + val.pos = (i < s.length()) ? i : i + 1; + val.value = Integer.parseInt(s1.toString()); + return val; + } + + private int getNumericValue(String s, int i) { + int endOfVal = findNextWhiteSpace(i, s); + String val = s.substring(i, endOfVal); + return Integer.parseInt(val); + } + + private int getMonthNumber(String s) { + Integer integer = monthMap.get(s); + + if (integer == null) { + return -1; + } + + return integer; + } + + private int getDayOfWeekNumber(String s) { + Integer integer = dayMap.get(s); + + if (integer == null) { + return -1; + } + + return integer; + } + + + public Date getTimeAfter(Date afterTime) { + + // Computation is based on Gregorian year only. + Calendar cl = new java.util.GregorianCalendar(getTimeZone()); + + // move ahead one second, since we're computing the time *after* the + // given time + afterTime = new Date(afterTime.getTime() + 1000); + // CronTrigger does not deal with milliseconds + cl.setTime(afterTime); + cl.set(Calendar.MILLISECOND, 0); + + boolean gotOne = false; + // loop until we've computed the next time, or we've past the endTime + while (!gotOne) { + + + if(cl.get(Calendar.YEAR) > 2999) { // prevent endless loop... + return null; + } + + + int sec = cl.get(Calendar.SECOND); + int min = cl.get(Calendar.MINUTE); + + // get second................................................. + SortedSet st = seconds.tailSet(sec); + if (!st.isEmpty()) { + sec = st.first(); + } else { + sec = seconds.first(); + min++; + cl.set(Calendar.MINUTE, min); + } + cl.set(Calendar.SECOND, sec); + + min = cl.get(Calendar.MINUTE); + int hr = cl.get(Calendar.HOUR_OF_DAY); + int t = -1; + + // get minute................................................. + st = minutes.tailSet(min); + if (!st.isEmpty()) { + t = min; + min = st.first(); + } else { + min = minutes.first(); + hr++; + } + if (min != t) { + cl.set(Calendar.SECOND, 0); + cl.set(Calendar.MINUTE, min); + setCalendarHour(cl, hr); + continue; + } + cl.set(Calendar.MINUTE, min); + + hr = cl.get(Calendar.HOUR_OF_DAY); + int day = cl.get(Calendar.DAY_OF_MONTH); + t = -1; + + // get hour................................................... + st = hours.tailSet(hr); + if (!st.isEmpty()) { + t = hr; + hr = st.first(); + } else { + hr = hours.first(); + day++; + } + if (hr != t) { + cl.set(Calendar.SECOND, 0); + cl.set(Calendar.MINUTE, 0); + cl.set(Calendar.DAY_OF_MONTH, day); + setCalendarHour(cl, hr); + continue; + } + cl.set(Calendar.HOUR_OF_DAY, hr); + + day = cl.get(Calendar.DAY_OF_MONTH); + int mon = cl.get(Calendar.MONTH) + 1; + // '+ 1' because calendar is 0-based for this field, and we are + // 1-based + int tmon = mon; + + // get day................................................... + boolean dayOfMSpec = !daysOfMonth.contains(NO_SPEC); + boolean dayOfWSpec = !daysOfWeek.contains(NO_SPEC); + if (dayOfMSpec && !dayOfWSpec) { // get day by day of month rule + final Optional smallestDay = findSmallestDay(day, mon, cl.get(Calendar.YEAR), + daysOfMonth); + Optional smallestDayForWeekday = findSmallestDay(day, mon, cl.get(Calendar.YEAR), + nearestWeekdays); + t = day; + day = -1; + if (smallestDayForWeekday.isPresent()) { + day = smallestDayForWeekday.get(); + + java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone()); + tcal.set(Calendar.SECOND, 0); + tcal.set(Calendar.MINUTE, 0); + tcal.set(Calendar.HOUR_OF_DAY, 0); + tcal.set(Calendar.DAY_OF_MONTH, day); + tcal.set(Calendar.MONTH, mon - 1); + tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR)); + + int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR)); + int dow = tcal.get(Calendar.DAY_OF_WEEK); + + if (dow == Calendar.SATURDAY && day == 1) { + day += 2; + } else if (dow == Calendar.SATURDAY) { + day -= 1; + } else if (dow == Calendar.SUNDAY && day == ldom) { + day -= 2; + } else if (dow == Calendar.SUNDAY) { + day += 1; + } + + + tcal.set(Calendar.SECOND, sec); + tcal.set(Calendar.MINUTE, min); + tcal.set(Calendar.HOUR_OF_DAY, hr); + tcal.set(Calendar.DAY_OF_MONTH, day); + tcal.set(Calendar.MONTH, mon - 1); + Date nTime = tcal.getTime(); + if (nTime.before(afterTime)) { + day = -1; + } + } + if (smallestDay.isPresent()) { + if (day == -1 || smallestDay.get() < day) { + day = smallestDay.get(); + } + } else if (day == -1) { + day = 1; + mon++; + } + if (day != t || mon != tmon) { + cl.set(Calendar.SECOND, 0); + cl.set(Calendar.MINUTE, 0); + cl.set(Calendar.HOUR_OF_DAY, 0); + cl.set(Calendar.DAY_OF_MONTH, day); + cl.set(Calendar.MONTH, mon - 1); + // '- 1' because calendar is 0-based for this field, and we + // are 1-based + continue; + } + } else if (dayOfWSpec && !dayOfMSpec) { // get day by day of week rule + if (lastDayOfWeek) { // are we looking for the last XXX day of + // the month? + int dow = daysOfWeek.first(); // desired + // d-o-w + int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w + int daysToAdd = 0; + if (cDow < dow) { + daysToAdd = dow - cDow; + } + if (cDow > dow) { + daysToAdd = dow + (7 - cDow); + } + + int lDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR)); + + if (day + daysToAdd > lDay) { // did we already miss the + // last one? + cl.set(Calendar.SECOND, 0); + cl.set(Calendar.MINUTE, 0); + cl.set(Calendar.HOUR_OF_DAY, 0); + cl.set(Calendar.DAY_OF_MONTH, 1); + cl.set(Calendar.MONTH, mon); + // no '- 1' here because we are promoting the month + continue; + } + + // find date of last occurrence of this day in this month... + while ((day + daysToAdd + 7) <= lDay) { + daysToAdd += 7; + } + + day += daysToAdd; + + if (daysToAdd > 0) { + cl.set(Calendar.SECOND, 0); + cl.set(Calendar.MINUTE, 0); + cl.set(Calendar.HOUR_OF_DAY, 0); + cl.set(Calendar.DAY_OF_MONTH, day); + cl.set(Calendar.MONTH, mon - 1); + // '- 1' here because we are not promoting the month + continue; + } + + } else if (nthDayOfWeek != 0) { + // are we looking for the Nth XXX day in the month? + int dow = daysOfWeek.first(); // desired + // d-o-w + int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w + int daysToAdd = 0; + if (cDow < dow) { + daysToAdd = dow - cDow; + } else if (cDow > dow) { + daysToAdd = dow + (7 - cDow); + } + + final boolean dayShifted = daysToAdd > 0; + + day += daysToAdd; + int weekOfMonth = day / 7; + if (day % 7 > 0) { + weekOfMonth++; + } + + daysToAdd = (nthDayOfWeek - weekOfMonth) * 7; + day += daysToAdd; + if (daysToAdd < 0 + || day > getLastDayOfMonth(mon, cl + .get(Calendar.YEAR))) { + cl.set(Calendar.SECOND, 0); + cl.set(Calendar.MINUTE, 0); + cl.set(Calendar.HOUR_OF_DAY, 0); + cl.set(Calendar.DAY_OF_MONTH, 1); + cl.set(Calendar.MONTH, mon); + // no '- 1' here because we are promoting the month + continue; + } else if (daysToAdd > 0 || dayShifted) { + cl.set(Calendar.SECOND, 0); + cl.set(Calendar.MINUTE, 0); + cl.set(Calendar.HOUR_OF_DAY, 0); + cl.set(Calendar.DAY_OF_MONTH, day); + cl.set(Calendar.MONTH, mon - 1); + // '- 1' here because we are NOT promoting the month + continue; + } + } else { + int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w + int dow = daysOfWeek.first(); // desired + // d-o-w + st = daysOfWeek.tailSet(cDow); + if (!st.isEmpty()) { + dow = st.first(); + } + + int daysToAdd = 0; + if (cDow < dow) { + daysToAdd = dow - cDow; + } + if (cDow > dow) { + daysToAdd = dow + (7 - cDow); + } + + int lDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR)); + + if (day + daysToAdd > lDay) { // will we pass the end of + // the month? + cl.set(Calendar.SECOND, 0); + cl.set(Calendar.MINUTE, 0); + cl.set(Calendar.HOUR_OF_DAY, 0); + cl.set(Calendar.DAY_OF_MONTH, 1); + cl.set(Calendar.MONTH, mon); + // no '- 1' here because we are promoting the month + continue; + } else if (daysToAdd > 0) { // are we switching days? + cl.set(Calendar.SECOND, 0); + cl.set(Calendar.MINUTE, 0); + cl.set(Calendar.HOUR_OF_DAY, 0); + cl.set(Calendar.DAY_OF_MONTH, day + daysToAdd); + cl.set(Calendar.MONTH, mon - 1); + // '- 1' because calendar is 0-based for this field, + // and we are 1-based + continue; + } + } + } else { // dayOfWSpec && !dayOfMSpec + throw new UnsupportedOperationException( + "Support for specifying both a day-of-week" + + " AND a day-of-month parameter is not implemented."); + } + cl.set(Calendar.DAY_OF_MONTH, day); + + mon = cl.get(Calendar.MONTH) + 1; + // '+ 1' because calendar is 0-based for this field, and we are + // 1-based + int year = cl.get(Calendar.YEAR); + t = -1; + + // test for expressions that never generate a valid fire date, + // but keep looping... + if (year > MAX_YEAR) { + return null; + } + + // get month................................................... + st = months.tailSet(mon); + if (!st.isEmpty()) { + t = mon; + mon = st.first(); + } else { + mon = months.first(); + year++; + } + if (mon != t) { + cl.set(Calendar.SECOND, 0); + cl.set(Calendar.MINUTE, 0); + cl.set(Calendar.HOUR_OF_DAY, 0); + cl.set(Calendar.DAY_OF_MONTH, 1); + cl.set(Calendar.MONTH, mon - 1); + // '- 1' because calendar is 0-based for this field, and we are + // 1-based + cl.set(Calendar.YEAR, year); + continue; + } + cl.set(Calendar.MONTH, mon - 1); + // '- 1' because calendar is 0-based for this field, and we are + // 1-based + + year = cl.get(Calendar.YEAR); + + // get year................................................... + st = years.tailSet(year); + if (!st.isEmpty()) { + t = year; + year = st.first(); + } else { + return null; // ran out of years... + } + + if (year != t) { + cl.set(Calendar.SECOND, 0); + cl.set(Calendar.MINUTE, 0); + cl.set(Calendar.HOUR_OF_DAY, 0); + cl.set(Calendar.DAY_OF_MONTH, 1); + cl.set(Calendar.MONTH, 0); + // '- 1' because calendar is 0-based for this field, and we are + // 1-based + cl.set(Calendar.YEAR, year); + continue; + } + cl.set(Calendar.YEAR, year); + + gotOne = true; + } + + return cl.getTime(); + } + + /** + * Advance the calendar to the particular hour paying particular attention + * to daylight saving problems. + * + * @param cal the calendar to operate on + * @param hour the hour to set + */ + private void setCalendarHour(Calendar cal, int hour) { + cal.set(java.util.Calendar.HOUR_OF_DAY, hour); + if (cal.get(java.util.Calendar.HOUR_OF_DAY) != hour && hour != 24) { + cal.set(java.util.Calendar.HOUR_OF_DAY, hour + 1); + } + } + + private boolean isLeapYear(int year) { + return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)); + } + + private int getLastDayOfMonth(int monthNum, int year) { + switch (monthNum) { + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: + return 31; + case 2: + return (isLeapYear(year)) ? 29 : 28; + case 4: + case 6: + case 9: + case 11: + return 30; + default: + throw new IllegalArgumentException("Illegal month number: " + + monthNum); + } + } + + + private Optional findSmallestDay(int day, int mon, int year, TreeSet set) { + if (set.isEmpty()) { + return Optional.empty(); + } + + final int lastDay = getLastDayOfMonth(mon, year); + // For "L", "L-1", etc. + int smallestDay = Optional.ofNullable(set.ceiling(LAST_DAY_OFFSET_END - (lastDay - day))) + .map(d -> d - LAST_DAY_OFFSET_START + 1) + .orElse(Integer.MAX_VALUE); + + // For "1", "2", etc. + SortedSet st = set.subSet(day, LAST_DAY_OFFSET_START); + // make sure we don't over-run a short month, such as february + if (!st.isEmpty() && st.first() < smallestDay && st.first() <= lastDay) { + smallestDay = st.first(); + } + + return smallestDay == Integer.MAX_VALUE ? Optional.empty() : Optional.of(smallestDay); + } + } diff --git a/common/src/main/java/org/tron/common/cron/ValueSet.java b/common/src/main/java/org/tron/common/cron/ValueSet.java new file mode 100644 index 00000000000..e8ffa73b1e2 --- /dev/null +++ b/common/src/main/java/org/tron/common/cron/ValueSet.java @@ -0,0 +1,7 @@ +package org.tron.common.cron; + +class ValueSet { + protected int value; + + protected int pos; +} diff --git a/common/src/main/java/org/tron/common/es/ExecutorServiceManager.java b/common/src/main/java/org/tron/common/es/ExecutorServiceManager.java index 196d44ba722..779a8edf75d 100644 --- a/common/src/main/java/org/tron/common/es/ExecutorServiceManager.java +++ b/common/src/main/java/org/tron/common/es/ExecutorServiceManager.java @@ -4,10 +4,13 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import lombok.extern.slf4j.Slf4j; +import org.tron.common.exit.ExitManager; @Slf4j(topic = "common-executor") public class ExecutorServiceManager { @@ -80,4 +83,30 @@ public static void shutdownAndAwaitTermination(ExecutorService pool, String name } logger.info("Pool {} shutdown done", name); } + + public static Future submit(ExecutorService es, Runnable task) { + return es.submit(() -> { + try { + task.run(); + } catch (Throwable e) { + ExitManager.findTronError(e).ifPresent(ExitManager::logAndExit); + throw e; + } + }); + } + + public static ScheduledFuture scheduleWithFixedDelay(ScheduledExecutorService es, + Runnable command, + long initialDelay, + long delay, + TimeUnit unit) { + return es.scheduleWithFixedDelay(() -> { + try { + command.run(); + } catch (Throwable e) { + ExitManager.findTronError(e).ifPresent(ExitManager::logAndExit); + throw e; + } + }, initialDelay, delay, unit); + } } diff --git a/common/src/main/java/org/tron/common/exit/ExitManager.java b/common/src/main/java/org/tron/common/exit/ExitManager.java new file mode 100644 index 00000000000..d80b7838c08 --- /dev/null +++ b/common/src/main/java/org/tron/common/exit/ExitManager.java @@ -0,0 +1,53 @@ +package org.tron.common.exit; + +import java.util.HashSet; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ThreadFactory; +import lombok.extern.slf4j.Slf4j; +import org.tron.core.exception.TronError; + +@Slf4j(topic = "Exit") +public class ExitManager { + + private static final ThreadFactory exitThreadFactory = r -> { + Thread thread = new Thread(r, "System-Exit-Thread"); + thread.setDaemon(true); + return thread; + }; + + private ExitManager() { + + } + + public static void initExceptionHandler() { + Thread.setDefaultUncaughtExceptionHandler((t, e) -> { + findTronError(e).ifPresent(ExitManager::logAndExit); + logger.error("Uncaught exception", e); + }); + } + + public static Optional findTronError(Throwable e) { + if (e == null) { + return Optional.empty(); + } + + Set seen = new HashSet<>(); + + while (e != null && !seen.contains(e)) { + if (e instanceof TronError) { + return Optional.of((TronError) e); + } + seen.add(e); + e = e.getCause(); + } + return Optional.empty(); + } + + public static void logAndExit(TronError exit) { + final int code = exit.getErrCode().getCode(); + logger.error("Shutting down with code: {}.", exit.getErrCode(), exit); + Thread exitThread = exitThreadFactory.newThread(() -> System.exit(code)); + exitThread.start(); + } +} \ No newline at end of file diff --git a/common/src/main/java/org/tron/common/log/LogService.java b/common/src/main/java/org/tron/common/log/LogService.java new file mode 100644 index 00000000000..801e13f54f7 --- /dev/null +++ b/common/src/main/java/org/tron/common/log/LogService.java @@ -0,0 +1,26 @@ +package org.tron.common.log; + +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.joran.JoranConfigurator; +import java.io.File; +import org.slf4j.LoggerFactory; +import org.tron.core.exception.TronError; + +public class LogService { + + public static void load(String path) { + try { + File file = new File(path); + if (!file.exists() || !file.isFile() || !file.canRead()) { + return; + } + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + JoranConfigurator configurator = new JoranConfigurator(); + configurator.setContext(lc); + lc.reset(); + configurator.doConfigure(file); + } catch (Exception e) { + throw new TronError(e, TronError.ErrCode.LOG_LOAD); + } + } +} diff --git a/common/src/main/java/org/tron/common/log/layout/DesensitizedConverter.java b/common/src/main/java/org/tron/common/log/layout/DesensitizedConverter.java new file mode 100644 index 00000000000..2777d6ba283 --- /dev/null +++ b/common/src/main/java/org/tron/common/log/layout/DesensitizedConverter.java @@ -0,0 +1,49 @@ +package org.tron.common.log.layout; + +import ch.qos.logback.classic.pattern.ClassicConverter; +import ch.qos.logback.classic.spi.ILoggingEvent; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import lombok.extern.slf4j.Slf4j; +import org.tron.common.parameter.CommonParameter; + +@Slf4j(topic = "Parser") +public class DesensitizedConverter extends ClassicConverter { + + private static final int SENSITIVE_WORD_SIZE = 1_000; + + private static final Pattern pattern = Pattern.compile( + "(((25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(25[0-5]|2[0-4]\\d|((1\\d{2})|" + + "([1-9]?\\d))))"); + + private static final Cache sensitiveCache = CacheBuilder.newBuilder() + .maximumSize(SENSITIVE_WORD_SIZE) + .recordStats().build(); + + public static void addSensitive(String key, String value) { + sensitiveCache.put(key, value); + } + + private String desensitization(String content) { + Matcher matcher = pattern.matcher(content); + while (matcher.find()) { + String key = matcher.group(); + String value = sensitiveCache.getIfPresent(key); + if (value != null) { + content = content.replaceAll(key, value); + } else { + content = content.replaceAll(key, "IP"); + } + } + + return content; + } + + @Override + public String convert(ILoggingEvent iLoggingEvent) { + String source = iLoggingEvent.getFormattedMessage(); + return CommonParameter.getInstance().isFastForward() ? desensitization(source) : source; + } +} diff --git a/common/src/main/java/org/tron/common/logsfilter/EventPluginConfig.java b/common/src/main/java/org/tron/common/logsfilter/EventPluginConfig.java index 050499b6123..e2aa0950d72 100644 --- a/common/src/main/java/org/tron/common/logsfilter/EventPluginConfig.java +++ b/common/src/main/java/org/tron/common/logsfilter/EventPluginConfig.java @@ -15,6 +15,14 @@ public class EventPluginConfig { public static final String SOLIDITY_EVENT_NAME = "solidityevent"; public static final String SOLIDITY_LOG_NAME = "soliditylog"; + @Getter + @Setter + private int version; + + @Getter + @Setter + private long startSyncBlockNum; + @Getter @Setter private String pluginPath; diff --git a/common/src/main/java/org/tron/common/logsfilter/trigger/BlockLogTrigger.java b/common/src/main/java/org/tron/common/logsfilter/trigger/BlockLogTrigger.java index 5e64c5a1050..b878597045d 100644 --- a/common/src/main/java/org/tron/common/logsfilter/trigger/BlockLogTrigger.java +++ b/common/src/main/java/org/tron/common/logsfilter/trigger/BlockLogTrigger.java @@ -34,7 +34,7 @@ public BlockLogTrigger() { @Override public String toString() { return new StringBuilder().append("triggerName: ").append(getTriggerName()) - .append("timestamp: ") + .append(", timestamp: ") .append(timeStamp) .append(", blockNumber: ") .append(blockNumber) diff --git a/common/src/main/java/org/tron/common/logsfilter/trigger/SolidityTrigger.java b/common/src/main/java/org/tron/common/logsfilter/trigger/SolidityTrigger.java index d9745f4724a..230544a91ff 100644 --- a/common/src/main/java/org/tron/common/logsfilter/trigger/SolidityTrigger.java +++ b/common/src/main/java/org/tron/common/logsfilter/trigger/SolidityTrigger.java @@ -16,7 +16,7 @@ public SolidityTrigger() { @Override public String toString() { return new StringBuilder().append("triggerName: ").append(getTriggerName()) - .append("timestamp: ") + .append(", timestamp: ") .append(timeStamp) .append(", latestSolidifiedBlockNumber: ") .append(latestSolidifiedBlockNumber).toString(); diff --git a/common/src/main/java/org/tron/common/math/MathWrapper.java b/common/src/main/java/org/tron/common/math/MathWrapper.java new file mode 100644 index 00000000000..758a0f18370 --- /dev/null +++ b/common/src/main/java/org/tron/common/math/MathWrapper.java @@ -0,0 +1,78 @@ +package org.tron.common.math; + +/** + * This class is deprecated and should not be used in new code, + * for cross-platform consistency, please use {@link StrictMathWrapper} instead, + * especially for floating-point calculations. + */ +@Deprecated +public class MathWrapper { + + public static double pow(double a, double b) { + return Math.pow(a, b); + } + + public static long addExact(long x, long y) { + return Math.addExact(x, y); + } + + public static int addExact(int x, int y) { + return Math.addExact(x, y); + } + + public static long floorDiv(long x, long y) { + return Math.floorDiv(x, y); + } + + public static int multiplyExact(int x, int y) { + return Math.multiplyExact(x, y); + } + + public static long multiplyExact(long x, long y) { + return Math.multiplyExact(x, y); + } + + public static long subtractExact(long x, long y) { + return Math.subtractExact(x, y); + } + + public static int min(int a, int b) { + return Math.min(a, b); + } + + public static long min(long a, long b) { + return Math.min(a, b); + } + + public static int max(int a, int b) { + return Math.max(a, b); + } + + public static long max(long a, long b) { + return Math.max(a, b); + } + + public static int round(float a) { + return Math.round(a); + } + + public static long round(double a) { + return Math.round(a); + } + + public static double ceil(double a) { + return Math.ceil(a); + } + + public static double signum(double a) { + return Math.signum(a); + } + + public static double random() { + return Math.random(); + } + + public static long abs(long a) { + return Math.abs(a); + } +} diff --git a/common/src/main/java/org/tron/common/math/Maths.java b/common/src/main/java/org/tron/common/math/Maths.java new file mode 100644 index 00000000000..f0503cee2e4 --- /dev/null +++ b/common/src/main/java/org/tron/common/math/Maths.java @@ -0,0 +1,92 @@ +package org.tron.common.math; + +/** + * This class is deprecated and should not be used in new code, + * for cross-platform consistency, please use {@link StrictMathWrapper} instead, + * especially for floating-point calculations. + */ +@Deprecated +public class Maths { + + /** + * Returns the value of the first argument raised to the power of the second argument. + * @param a the base. + * @param b the exponent. + * @return the value {@code a}{@code b}. + */ + public static double pow(double a, double b, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.pow(a, b) : MathWrapper.pow(a, b); + } + + /** + * Adds two integers together, checking for overflow. + * @param x the first value. + * @param y the second value. + * @return the sum of {@code x} and {@code y}. + * @throws ArithmeticException if the result overflows an int. + */ + public static long addExact(long x, long y, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.addExact(x, y) : MathWrapper.addExact(x, y); + } + + public static int addExact(int x, int y, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.addExact(x, y) : MathWrapper.addExact(x, y); + } + + public static long floorDiv(long x, long y, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.floorDiv(x, y) : MathWrapper.floorDiv(x, y); + } + + public static int multiplyExact(int x, int y, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.multiplyExact(x, y) : MathWrapper.multiplyExact(x, y); + } + + public static long multiplyExact(long x, long y, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.multiplyExact(x, y) : MathWrapper.multiplyExact(x, y); + } + + public static long subtractExact(long x, long y, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.subtractExact(x, y) : MathWrapper.subtractExact(x, y); + } + + public static int min(int a, int b, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.min(a, b) : MathWrapper.min(a, b); + } + + public static long min(long a, long b, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.min(a, b) : MathWrapper.min(a, b); + } + + public static int max(int a, int b, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.max(a, b) : MathWrapper.max(a, b); + } + + public static long max(long a, long b, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.max(a, b) : MathWrapper.max(a, b); + } + + public static int round(float a, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.round(a) : MathWrapper.round(a); + } + + public static long round(double a, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.round(a) : MathWrapper.round(a); + } + + public static double ceil(double a, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.ceil(a) : MathWrapper.ceil(a); + } + + public static double signum(double a, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.signum(a) : MathWrapper.signum(a); + } + + public static double random(boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.random() : MathWrapper.random(); + } + + public static long abs(long a, boolean useStrictMath) { + return useStrictMath ? StrictMathWrapper.abs(a) : MathWrapper.abs(a); + } + +} diff --git a/common/src/main/java/org/tron/common/math/StrictMathWrapper.java b/common/src/main/java/org/tron/common/math/StrictMathWrapper.java new file mode 100644 index 00000000000..6a4d9c4e1a6 --- /dev/null +++ b/common/src/main/java/org/tron/common/math/StrictMathWrapper.java @@ -0,0 +1,144 @@ +package org.tron.common.math; + +public class StrictMathWrapper { + + public static double pow(double a, double b) { + return StrictMath.pow(a, b); + } + + /** + * *** methods are same as {@link java.lang.Math} methods, guaranteed by the call start *** + */ + + /** + * finally calls {@link java.lang.Math#addExact(long, long)} + */ + + public static long addExact(long x, long y) { + return StrictMath.addExact(x, y); + } + + /** + * finally calls {@link java.lang.Math#addExact(int, int)} + */ + + public static int addExact(int x, int y) { + return StrictMath.addExact(x, y); + } + + /** + * finally calls {@link java.lang.Math#subtractExact(long, long)} + */ + + public static long subtractExact(long x, long y) { + return StrictMath.subtractExact(x, y); + } + + /** + * finally calls {@link java.lang.Math#floorMod(long, long)} + */ + public static long multiplyExact(long x, long y) { + return StrictMath.multiplyExact(x, y); + } + + public static long multiplyExact(long x, int y) { + return multiplyExact(x, (long) y); + } + + public static int multiplyExact(int x, int y) { + return StrictMath.multiplyExact(x, y); + } + + /** + * finally calls {@link java.lang.Math#floorDiv(long, long)} + */ + public static long floorDiv(long x, long y) { + return StrictMath.floorDiv(x, y); + } + + public static long floorDiv(long x, int y) { + return floorDiv(x, (long) y); + } + + /** + * finally calls {@link java.lang.Math#min(int, int)} + */ + public static int min(int a, int b) { + return StrictMath.min(a, b); + } + + /** + * finally calls {@link java.lang.Math#min(long, long)} + */ + public static long min(long a, long b) { + return StrictMath.min(a, b); + } + + /** + * finally calls {@link java.lang.Math#max(int, int)} + */ + public static int max(int a, int b) { + return StrictMath.max(a, b); + } + + /** + * finally calls {@link java.lang.Math#max(long, long)} + */ + public static long max(long a, long b) { + return StrictMath.max(a, b); + } + + /** + * finally calls {@link java.lang.Math#round(float)} + */ + public static int round(float a) { + return StrictMath.round(a); + } + + /** + * finally calls {@link java.lang.Math#round(double)} + */ + public static long round(double a) { + return StrictMath.round(a); + } + + /** + * finally calls {@link java.lang.Math#signum(double)} + */ + public static double signum(double d) { + return StrictMath.signum(d); + } + + /** + * finally calls {@link java.lang.Math#signum(float)} + */ + public static long abs(long a) { + return StrictMath.abs(a); + } + + /** + * *** methods are same as {@link java.lang.Math} methods, guaranteed by the call end *** + */ + + /** + * *** methods are same as {@link java.lang.Math} methods by mathematical algorithms*** + * / + + + /** + * mathematical integer: ceil(i) = floor(i) = i + * @return the smallest (closest to negative infinity) double value that is greater + * than or equal to the argument and is equal to a mathematical integer. + */ + public static double ceil(double a) { + return StrictMath.ceil(a); + } + + /** + * *** methods are no matters *** + */ + public static double random() { + return StrictMath.random(); + } + +} diff --git a/common/src/main/java/org/tron/common/parameter/CommonParameter.java b/common/src/main/java/org/tron/common/parameter/CommonParameter.java index f8f6e6c5edb..45893970fb0 100644 --- a/common/src/main/java/org/tron/common/parameter/CommonParameter.java +++ b/common/src/main/java/org/tron/common/parameter/CommonParameter.java @@ -8,9 +8,9 @@ import java.util.Set; import lombok.Getter; import lombok.Setter; -import org.quartz.CronExpression; import org.tron.common.args.GenesisBlock; import org.tron.common.config.DbBackupConfig; +import org.tron.common.cron.CronExpression; import org.tron.common.logsfilter.EventPluginConfig; import org.tron.common.logsfilter.FilterQuery; import org.tron.common.setting.RocksDbSettings; @@ -68,12 +68,12 @@ public class CommonParameter { @Getter @Setter @Parameter(names = {"--min-time-ratio"}, description = "Maximum CPU tolerance when executing " - + "non-timeout transactions while synchronizing blocks. (default: 5.0)") + + "timeout transactions while synchronizing blocks. (default: 0.0)") public double minTimeRatio = 0.0; @Getter @Setter @Parameter(names = {"--max-time-ratio"}, description = "Maximum CPU tolerance when executing " - + "timeout transactions while synchronizing blocks. (default: 0.0)") + + "non-timeout transactions while synchronizing blocks. (default: 5.0)") public double maxTimeRatio = calcMaxTimeRatio(); @Getter @Setter @@ -88,6 +88,12 @@ public class CommonParameter { public boolean saveFeaturedInternalTx; @Getter @Setter + @Parameter(names = {"--save-cancel-all-unfreeze-v2-details"}, description = "Record the details of the internal " + + "transactions generated by the CANCELALLUNFREEZEV2 opcode, such as bandwidth/energy/tronpower cancel amount. " + + "(default: false)") + public boolean saveCancelAllUnfreezeV2Details; + @Getter + @Setter @Parameter(names = {"--long-running-time"}) public int longRunningTime = 10; @Getter @@ -176,7 +182,7 @@ public class CommonParameter { public int nodeListenPort; @Getter @Setter - public String nodeDiscoveryBindIp; + public String nodeLanIp; @Getter @Setter public String nodeExternalIp; @@ -255,6 +261,9 @@ public class CommonParameter { public int maxHeaderListSize; @Getter @Setter + public boolean isRpcReflectionServiceEnable; + @Getter + @Setter @Parameter(names = {"--validate-sign-thread"}, description = "Num of validate thread") public int validateSignThreadNum; @Getter @@ -330,6 +339,9 @@ public class CommonParameter { public boolean isOpenFullTcpDisconnect; @Getter @Setter + public int inactiveThreshold; + @Getter + @Setter public boolean nodeDetectEnable; @Getter @Setter @@ -450,12 +462,30 @@ public class CommonParameter { @Getter @Setter public String cryptoEngine = Constant.ECKey_ENGINE; + + @Getter + @Setter + public boolean rpcEnable = true; + + @Getter + @Setter + public boolean rpcSolidityEnable = true; + + @Getter + @Setter + public boolean rpcPBFTEnable = true; + @Getter @Setter public boolean fullNodeHttpEnable = true; @Getter @Setter public boolean solidityNodeHttpEnable = true; + + @Getter + @Setter + public boolean pBFTHttpEnable = true; + @Getter @Setter public boolean jsonRpcHttpFullNodeEnable = false; @@ -465,6 +495,13 @@ public class CommonParameter { @Getter @Setter public boolean jsonRpcHttpPBFTNodeEnable = false; + @Getter + @Setter + public int jsonRpcMaxBlockRange = 5000; + @Getter + @Setter + public int jsonRpcMaxSubTopics = 1000; + @Getter @Setter public int maxTransactionPendingSize; @@ -651,6 +688,42 @@ public class CommonParameter { @Setter public long allowCancelAllUnfreezeV2; + @Getter + @Setter + public boolean unsolidifiedBlockCheck; + + @Getter + @Setter + public int maxUnsolidifiedBlocks; + + @Getter + @Setter + public long allowOldRewardOpt; + + @Getter + @Setter + public long allowEnergyAdjustment; + + @Getter + @Setter + public long maxCreateAccountTxSize = 1000L; + + @Getter + @Setter + public long allowStrictMath; + + @Getter + @Setter + public long consensusLogicOptimization; + + @Getter + @Setter + public long allowTvmCancun; + + @Getter + @Setter + public long allowTvmBlob; + private static double calcMaxTimeRatio() { //return max(2.0, min(5.0, 5 * 4.0 / max(Runtime.getRuntime().availableProcessors(), 1))); return 5.0; diff --git a/common/src/main/java/org/tron/common/prometheus/Metrics.java b/common/src/main/java/org/tron/common/prometheus/Metrics.java index 3f37cf331aa..6774dd7c315 100644 --- a/common/src/main/java/org/tron/common/prometheus/Metrics.java +++ b/common/src/main/java/org/tron/common/prometheus/Metrics.java @@ -5,9 +5,9 @@ import io.prometheus.client.Histogram; import io.prometheus.client.exporter.HTTPServer; import io.prometheus.client.hotspot.DefaultExports; -import java.io.IOException; import lombok.extern.slf4j.Slf4j; import org.tron.common.parameter.CommonParameter; +import org.tron.core.exception.TronError; @Slf4j(topic = "metrics") public class Metrics { @@ -32,9 +32,8 @@ public static synchronized void init() { new HTTPServer.Builder().withPort(port).build(); logger.info("prometheus exposed on port : {}", port); initialized = true; - } catch (IOException e) { - CommonParameter.getInstance().setMetricsPrometheusEnable(false); - logger.error("{}", e.getMessage()); + } catch (Exception e) { + throw new TronError(e, TronError.ErrCode.PROMETHEUS_INIT); } } } diff --git a/common/src/main/java/org/tron/common/runtime/vm/DataWord.java b/common/src/main/java/org/tron/common/runtime/vm/DataWord.java index 0eb0487a534..faeae45782e 100644 --- a/common/src/main/java/org/tron/common/runtime/vm/DataWord.java +++ b/common/src/main/java/org/tron/common/runtime/vm/DataWord.java @@ -17,6 +17,9 @@ */ package org.tron.common.runtime.vm; +import static org.tron.common.math.Maths.min; +import static org.tron.common.math.Maths.signum; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import java.math.BigInteger; @@ -28,6 +31,7 @@ import org.tron.common.utils.DecodeUtil; import org.tron.common.utils.FastByteComparisons; import org.tron.core.db.ByteArrayWrapper; +import org.tron.core.vm.config.VMConfig; /** * DataWord is the 32-byte array representation of a 256-bit number Calculations can be done on this @@ -165,7 +169,7 @@ public byte[] getClonedData() { byte[] ret = ByteUtil.EMPTY_BYTE_ARRAY; if (data != null) { ret = new byte[WORD_SIZE]; - int dataSize = Math.min(data.length, WORD_SIZE); + int dataSize = min(data.length, WORD_SIZE, VMConfig.disableJavaLangMath()); System.arraycopy(data, 0, ret, 0, dataSize); } return ret; @@ -484,7 +488,7 @@ public int compareTo(DataWord o) { data, 0, data.length, o.getData(), 0, o.getData().length); // Convert result into -1, 0 or 1 as is the convention - return (int) Math.signum(result); + return (int) signum(result, VMConfig.disableJavaLangMath()); } public void signExtend(byte k) { diff --git a/common/src/main/java/org/tron/common/utils/ByteUtil.java b/common/src/main/java/org/tron/common/utils/ByteUtil.java index 54d637d3f01..a7f7abd8fa8 100644 --- a/common/src/main/java/org/tron/common/utils/ByteUtil.java +++ b/common/src/main/java/org/tron/common/utils/ByteUtil.java @@ -18,6 +18,8 @@ package org.tron.common.utils; +import static org.tron.common.math.Maths.min; + import com.google.common.base.Preconditions; import com.google.common.primitives.UnsignedBytes; import java.io.ByteArrayOutputStream; @@ -70,7 +72,7 @@ public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; - int length = Math.min(biBytes.length, numBytes); + int length = min(biBytes.length, numBytes, true); System.arraycopy(biBytes, start, bytes, numBytes - length, length); return bytes; } @@ -346,7 +348,7 @@ public static byte[] parseBytes(byte[] input, int offset, int len) { } byte[] bytes = new byte[len]; - System.arraycopy(input, offset, bytes, 0, Math.min(input.length - offset, len)); + System.arraycopy(input, offset, bytes, 0, min(input.length - offset, len, true)); return bytes; } @@ -477,40 +479,41 @@ public static byte[] setBit(byte[] data, int pos, int val) { public static byte[] compress(byte[] data) throws EventBloomException { Deflater deflater = new Deflater(); - deflater.setInput(data); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length); + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length)) { + deflater.setInput(data); + deflater.finish(); + byte[] buffer = new byte[1024]; - deflater.finish(); - byte[] buffer = new byte[1024]; - while (!deflater.finished()) { - int count = deflater.deflate(buffer); // returns the generated code... index - outputStream.write(buffer, 0, count); - } - try { - outputStream.close(); + while (!deflater.finished()) { + int count = deflater.deflate(buffer); // returns the generated code... index + outputStream.write(buffer, 0, count); + } + + return outputStream.toByteArray(); } catch (IOException e) { throw new EventBloomException("compress data failed"); + } finally { + deflater.end(); } - byte[] output = outputStream.toByteArray(); - - return output; } public static byte[] decompress(byte[] data) throws IOException, DataFormatException { Inflater inflater = new Inflater(); - inflater.setInput(data); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length); - byte[] buffer = new byte[1024]; - while (!inflater.finished()) { - int count = inflater.inflate(buffer); - outputStream.write(buffer, 0, count); - } - outputStream.close(); - byte[] output = outputStream.toByteArray(); + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length)) { + inflater.setInput(data); + byte[] buffer = new byte[1024]; + + while (!inflater.finished()) { + int count = inflater.inflate(buffer); + outputStream.write(buffer, 0, count); + } - return output; + return outputStream.toByteArray(); + } finally { + inflater.end(); + } } } diff --git a/common/src/main/java/org/tron/common/utils/MerkleRoot.java b/common/src/main/java/org/tron/common/utils/MerkleRoot.java new file mode 100644 index 00000000000..ccd8905b6c5 --- /dev/null +++ b/common/src/main/java/org/tron/common/utils/MerkleRoot.java @@ -0,0 +1,68 @@ +package org.tron.common.utils; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import lombok.Getter; + +public class MerkleRoot { + + private MerkleRoot() { + + } + + public static Sha256Hash root(List hashList) { + List leaves = createLeaves(hashList); + while (leaves.size() > 1) { + leaves = createParentLeaves(leaves); + } + return leaves.isEmpty() ? Sha256Hash.ZERO_HASH : leaves.get(0).hash; + } + + private static List createParentLeaves(List leaves) { + int step = 2; + int len = leaves.size(); + return IntStream.iterate(0, i -> i + step) + .limit(len) + .filter(i -> i < len) + .mapToObj(i -> { + Leaf right = i + 1 < len ? leaves.get(i + 1) : null; + return createLeaf(leaves.get(i), right); + }).collect(Collectors.toList()); + } + + private static List createLeaves(List hashList) { + int step = 2; + int len = hashList.size(); + return IntStream.iterate(0, i -> i + step) + .limit(len) + .filter(i -> i < len) + .mapToObj(i -> { + Leaf right = i + 1 < len ? createLeaf(hashList.get(i + 1)) : null; + return createLeaf(createLeaf(hashList.get(i)), right); + }).collect(Collectors.toList()); + } + + private static Leaf createLeaf(Leaf left, Leaf right) { + Leaf leaf = new Leaf(); + leaf.hash = right == null ? left.hash : computeHash(left.hash, right.hash); + return leaf; + } + + private static Leaf createLeaf(Sha256Hash hash) { + Leaf leaf = new Leaf(); + leaf.hash = hash; + return leaf; + } + + private static Sha256Hash computeHash(Sha256Hash leftHash, Sha256Hash rightHash) { + return Sha256Hash.of(true, + leftHash.getByteString().concat(rightHash.getByteString()).toByteArray()); + } + + @Getter + private static class Leaf { + + private Sha256Hash hash; + } +} diff --git a/common/src/main/java/org/tron/core/Constant.java b/common/src/main/java/org/tron/core/Constant.java index ba867793b41..c5a8a02fb4e 100644 --- a/common/src/main/java/org/tron/core/Constant.java +++ b/common/src/main/java/org/tron/core/Constant.java @@ -18,12 +18,16 @@ public class Constant { public static final String ADD_PRE_FIX_STRING_MAINNET = "41"; public static final byte ADD_PRE_FIX_BYTE_TESTNET = (byte) 0xa0; //a0 + address public static final String ADD_PRE_FIX_STRING_TESTNET = "a0"; + public static final int STANDARD_ADDRESS_SIZE = 20; + public static final int TRON_ADDRESS_SIZE = 21; public static final int NODE_TYPE_FULL_NODE = 0; public static final int NODE_TYPE_LIGHT_NODE = 1; // config for transaction public static final long TRANSACTION_MAX_BYTE_SIZE = 500 * 1_024L; + public static final int CREATE_ACCOUNT_TRANSACTION_MIN_BYTE_SIZE = 500; + public static final int CREATE_ACCOUNT_TRANSACTION_MAX_BYTE_SIZE = 10000; public static final long MAXIMUM_TIME_UNTIL_EXPIRATION = 24 * 60 * 60 * 1_000L; //one day public static final long TRANSACTION_DEFAULT_EXPIRATION_TIME = 60 * 1_000L; //60 seconds public static final long TRANSACTION_FEE_POOL_PERIOD = 1; //1 blocks @@ -31,6 +35,8 @@ public class Constant { public static final long SUN_PER_ENERGY = 100; // 1 us = 100 SUN = 100 * 10^-6 TRX public static final long ENERGY_LIMIT_IN_CONSTANT_TX = 3_000_000L; // ref: 1 us = 1 energy public static final long MAX_RESULT_SIZE_IN_TX = 64; // max 8 * 8 items in result + public static final long PER_SIGN_LENGTH = 65L; + public static final long MAX_CONTRACT_RESULT_SIZE = 2L; public static final long PB_DEFAULT_ENERGY_LIMIT = 0L; public static final long CREATOR_DEFAULT_ENERGY_LIMIT = 1000 * 10_000L; @@ -118,21 +124,29 @@ public class Constant { public static final String NODE_DNS_AWS_REGION = "node.dns.awsRegion"; public static final String NODE_DNS_AWS_HOST_ZONE_ID = "node.dns.awsHostZoneId"; + // config for rpc public static final String NODE_RPC_PORT = "node.rpc.port"; public static final String NODE_RPC_SOLIDITY_PORT = "node.rpc.solidityPort"; public static final String NODE_RPC_PBFT_PORT = "node.rpc.PBFTPort"; + public static final String NODE_RPC_ENABLE = "node.rpc.enable"; + public static final String NODE_RPC_SOLIDITY_ENABLE = "node.rpc.solidityEnable"; + public static final String NODE_RPC_PBFT_ENABLE = "node.rpc.PBFTEnable"; + // config for http public static final String NODE_HTTP_FULLNODE_PORT = "node.http.fullNodePort"; public static final String NODE_HTTP_SOLIDITY_PORT = "node.http.solidityPort"; public static final String NODE_HTTP_FULLNODE_ENABLE = "node.http.fullNodeEnable"; public static final String NODE_HTTP_SOLIDITY_ENABLE = "node.http.solidityEnable"; + public static final String NODE_HTTP_PBFT_ENABLE = "node.http.PBFTEnable"; public static final String NODE_HTTP_PBFT_PORT = "node.http.PBFTPort"; - + // config for jsonrpc public static final String NODE_JSONRPC_HTTP_FULLNODE_ENABLE = "node.jsonrpc.httpFullNodeEnable"; public static final String NODE_JSONRPC_HTTP_FULLNODE_PORT = "node.jsonrpc.httpFullNodePort"; public static final String NODE_JSONRPC_HTTP_SOLIDITY_ENABLE = "node.jsonrpc.httpSolidityEnable"; public static final String NODE_JSONRPC_HTTP_SOLIDITY_PORT = "node.jsonrpc.httpSolidityPort"; public static final String NODE_JSONRPC_HTTP_PBFT_ENABLE = "node.jsonrpc.httpPBFTEnable"; public static final String NODE_JSONRPC_HTTP_PBFT_PORT = "node.jsonrpc.httpPBFTPort"; + public static final String NODE_JSONRPC_MAX_BLOCK_RANGE = "node.jsonrpc.maxBlockRange"; + public static final String NODE_JSONRPC_MAX_SUB_TOPICS = "node.jsonrpc.maxSubTopics"; public static final String NODE_DISABLED_API_LIST = "node.disabledApi"; @@ -151,6 +165,8 @@ public class Constant { public static final String NODE_RPC_MAX_HEADER_LIST_SIZE = "node.rpc.maxHeaderListSize"; + public static final String NODE_RPC_REFLECTION_SERVICE = "node.rpc.reflectionService"; + public static final String NODE_OPEN_HISTORY_QUERY_WHEN_LITEFN = "node.openHistoryQueryWhenLiteFN"; public static final String BLOCK_MAINTENANCE_TIME_INTERVAL = "block.maintenanceTimeInterval"; @@ -190,6 +206,8 @@ public class Constant { public static final String NODE_IS_OPEN_FULL_TCP_DISCONNECT = "node.isOpenFullTcpDisconnect"; + public static final String NODE_INACTIVE_THRESHOLD = "node.inactiveThreshold"; + public static final String NODE_DETECT_ENABLE = "node.nodeDetectEnable"; public static final String NODE_MAX_TRANSACTION_PENDING_SIZE = "node.maxTransactionPendingSize"; @@ -213,6 +231,7 @@ public class Constant { public static final String VM_SAVE_INTERNAL_TX = "vm.saveInternalTx"; public static final String VM_SAVE_FEATURED_INTERNAL_TX = "vm.saveFeaturedInternalTx"; + public static final String VM_SAVE_CANCEL_ALL_UNFREEZE_V2_DETAILS = "vm.saveCancelAllUnfreezeV2Details"; // public static final String COMMITTEE_ALLOW_SHIELDED_TRANSACTION = "committee.allowShieldedTransaction"; @@ -270,6 +289,8 @@ public class Constant { public static final String NATIVE_QUEUE_SEND_LENGTH = "event.subscribe.native.sendqueuelength"; + public static final String EVENT_SUBSCRIBE_VERSION = "event.subscribe.version"; + public static final String EVENT_SUBSCRIBE_START_SYNC_BLOCK_NUM = "event.subscribe.startSyncBlockNum"; public static final String EVENT_SUBSCRIBE_PATH = "event.subscribe.path"; public static final String EVENT_SUBSCRIBE_SERVER = "event.subscribe.server"; public static final String EVENT_SUBSCRIBE_DB_CONFIG = "event.subscribe.dbconfig"; @@ -279,8 +300,6 @@ public class Constant { public static final String EVENT_SUBSCRIBE_CONTRACT_ADDRESS = "event.subscribe.filter.contractAddress"; public static final String EVENT_SUBSCRIBE_CONTRACT_TOPIC = "event.subscribe.filter.contractTopic"; - public static final String NODE_DISCOVERY_BIND_IP = "node.discovery.bind.ip"; - public static final String NODE_DISCOVERY_EXTERNAL_IP = "node.discovery.external.ip"; public static final String NODE_BACKUP_PRIORITY = "node.backup.priority"; @@ -371,4 +390,19 @@ public class Constant { public static final String DYNAMIC_CONFIG_CHECK_INTERVAL = "node.dynamicConfig.checkInterval"; public static final String COMMITTEE_ALLOW_TVM_SHANGHAI = "committee.allowTvmShangHai"; + + public static final String UNSOLIDIFIED_BLOCK_CHECK = "node.unsolidifiedBlockCheck"; + + public static final String MAX_UNSOLIDIFIED_BLOCKS = "node.maxUnsolidifiedBlocks"; + public static final String COMMITTEE_ALLOW_OLD_REWARD_OPT = "committee.allowOldRewardOpt"; + + public static final String COMMITTEE_ALLOW_ENERGY_ADJUSTMENT = "committee.allowEnergyAdjustment"; + public static final String COMMITTEE_ALLOW_STRICT_MATH = "committee.allowStrictMath"; + + public static final String COMMITTEE_CONSENSUS_LOGIC_OPTIMIZATION + = "committee.consensusLogicOptimization"; + + public static final String COMMITTEE_ALLOW_TVM_CANCUN = "committee.allowTvmCancun"; + + public static final String COMMITTEE_ALLOW_TVM_BLOB = "committee.allowTvmBlob"; } diff --git a/common/src/main/java/org/tron/core/config/Parameter.java b/common/src/main/java/org/tron/core/config/Parameter.java index b1a948e9fdf..a71dc58e8bd 100644 --- a/common/src/main/java/org/tron/core/config/Parameter.java +++ b/common/src/main/java/org/tron/core/config/Parameter.java @@ -22,7 +22,11 @@ public enum ForkBlockVersionEnum { VERSION_4_6(25, 1596780000000L, 80), VERSION_4_7(26, 1596780000000L, 80), VERSION_4_7_1(27, 1596780000000L, 80), - VERSION_4_7_2(28, 1596780000000L, 80); + VERSION_4_7_2(28, 1596780000000L, 80), + VERSION_4_7_4(29, 1596780000000L, 80), + VERSION_4_7_5(30, 1596780000000L, 80), + VERSION_4_7_7(31, 1596780000000L, 80), + VERSION_4_8_0(32, 1596780000000L, 80); // if add a version, modify BLOCK_VERSION simultaneously @Getter @@ -71,7 +75,7 @@ public class ChainConstant { public static final int SINGLE_REPEAT = 1; public static final int BLOCK_FILLED_SLOTS_NUMBER = 128; public static final int MAX_FROZEN_NUMBER = 1; - public static final int BLOCK_VERSION = 28; + public static final int BLOCK_VERSION = 32; public static final long FROZEN_PERIOD = 86_400_000L; public static final long DELEGATE_PERIOD = 3 * 86_400_000L; public static final long TRX_PRECISION = 1000_000L; diff --git a/common/src/main/java/org/tron/core/config/args/Storage.java b/common/src/main/java/org/tron/core/config/args/Storage.java index 22dc239c167..9cf6eb6bab1 100644 --- a/common/src/main/java/org/tron/core/config/args/Storage.java +++ b/common/src/main/java/org/tron/core/config/args/Storage.java @@ -16,6 +16,7 @@ package org.tron.core.config.args; import com.google.common.collect.Maps; +import com.google.protobuf.ByteString; import com.typesafe.config.Config; import com.typesafe.config.ConfigObject; import java.io.File; @@ -32,6 +33,7 @@ import org.tron.common.utils.DbOptionalsUtils; import org.tron.common.utils.FileUtil; import org.tron.common.utils.Property; +import org.tron.common.utils.Sha256Hash; /** * Custom storage configurations @@ -79,6 +81,8 @@ public class Storage { private static final String CACHE_STRATEGIES = "storage.cache.strategies"; public static final String TX_CACHE_INIT_OPTIMIZATION = "storage.txCache.initOptimization"; + private static final String MERKLE_ROOT = "storage.merkleRoot"; + /** * Default values of directory */ @@ -163,6 +167,9 @@ public class Storage { @Getter private Map propertyMap; + // db root + private final Map dbRoots = Maps.newConcurrentMap(); + public static String getDbEngineFromConfig(final Config config) { return config.hasPath(DB_ENGINE_CONFIG_KEY) ? config.getString(DB_ENGINE_CONFIG_KEY) : DEFAULT_DB_ENGINE; @@ -258,6 +265,18 @@ public String getCacheStrategy(CacheType dbName) { return this.cacheStrategies.getOrDefault(dbName, CacheStrategies.getCacheStrategy(dbName)); } + public Sha256Hash getDbRoot(String dbName, Sha256Hash defaultV) { + return this.dbRoots.getOrDefault(dbName, defaultV); + } + + public void setDbRoots(Config config) { + if (config.hasPath(MERKLE_ROOT)) { + config.getConfig(MERKLE_ROOT).resolve().entrySet().forEach(c -> + this.dbRoots.put(c.getKey(), Sha256Hash.wrap( + ByteString.fromHex(c.getValue().unwrapped().toString())))); + } + } + private Property createProperty(final ConfigObject conf) { Property property = new Property(); diff --git a/common/src/main/java/org/tron/core/exception/TronError.java b/common/src/main/java/org/tron/core/exception/TronError.java new file mode 100644 index 00000000000..9d11d249476 --- /dev/null +++ b/common/src/main/java/org/tron/core/exception/TronError.java @@ -0,0 +1,63 @@ +package org.tron.core.exception; + +import lombok.Getter; + +/** + * If a {@link TronError} is thrown, the service will trigger {@link System#exit(int)} by + * {@link Thread#setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler)}. + * NOTE: Do not attempt to catch {@link TronError}. + */ +@Getter +public class TronError extends Error { + + private final ErrCode errCode; + + public TronError(String message, ErrCode exitCode) { + super(message); + this.errCode = exitCode; + } + + public TronError(String message, Throwable cause, ErrCode exitCode) { + super(message, cause); + this.errCode = exitCode; + } + + public TronError(Throwable cause, ErrCode exitCode) { + super(cause); + this.errCode = exitCode; + } + + @Getter + public enum ErrCode { + WITNESS_KEYSTORE_LOAD(-1), + CHECKPOINT_VERSION(-1), + LEVELDB_INIT(1), + ROCKSDB_INIT(1), + DB_FLUSH(1), + REWARD_VI_CALCULATOR(1), + KHAOS_DB_INIT(1), + GENESIS_BLOCK_INIT(1), + EVENT_SUBSCRIBE_ERROR(1), + AUTO_STOP_PARAMS(1), + API_SERVER_INIT(1), + EVENT_SUBSCRIBE_INIT(1), + PROMETHEUS_INIT(1), + TRON_NET_SERVICE_INIT(1), + ZCASH_INIT(1), + LOG_LOAD(1), + WITNESS_INIT(1), + RATE_LIMITER_INIT(1), + SOLID_NODE_INIT(0); + + private final int code; + + ErrCode(int code) { + this.code = code; + } + + @Override + public String toString() { + return name() + "(" + code + ")"; + } + } +} diff --git a/actuator/src/main/java/org/tron/core/vm/config/VMConfig.java b/common/src/main/java/org/tron/core/vm/config/VMConfig.java similarity index 81% rename from actuator/src/main/java/org/tron/core/vm/config/VMConfig.java rename to common/src/main/java/org/tron/core/vm/config/VMConfig.java index 97202432598..2bdbeb78b92 100644 --- a/actuator/src/main/java/org/tron/core/vm/config/VMConfig.java +++ b/common/src/main/java/org/tron/core/vm/config/VMConfig.java @@ -49,6 +49,16 @@ public class VMConfig { private static boolean ALLOW_TVM_SHANGHAI = false; + private static boolean ALLOW_ENERGY_ADJUSTMENT = false; + + private static boolean ALLOW_STRICT_MATH = false; + + private static boolean ALLOW_TVM_CANCUN = false; + + private static Boolean DISABLE_JAVA_LANG_MATH = false; + + private static boolean ALLOW_TVM_BLOB = false; + private VMConfig() { } @@ -136,6 +146,26 @@ public static void initAllowTvmShangHai(long allow) { ALLOW_TVM_SHANGHAI = allow == 1; } + public static void initAllowEnergyAdjustment(long allow) { + ALLOW_ENERGY_ADJUSTMENT = allow == 1; + } + + public static void initAllowStrictMath(long allow) { + ALLOW_STRICT_MATH = allow == 1; + } + + public static void initAllowTvmCancun(long allow) { + ALLOW_TVM_CANCUN = allow == 1; + } + + public static void initDisableJavaLangMath(long allow) { + DISABLE_JAVA_LANG_MATH = allow == 1; + } + + public static void initAllowTvmBlob(long allow) { + ALLOW_TVM_BLOB = allow == 1; + } + public static boolean getEnergyLimitHardFork() { return CommonParameter.ENERGY_LIMIT_HARD_FORK; } @@ -211,4 +241,24 @@ public static long getDynamicEnergyMaxFactor() { public static boolean allowTvmShanghai() { return ALLOW_TVM_SHANGHAI; } + + public static boolean allowEnergyAdjustment() { + return ALLOW_ENERGY_ADJUSTMENT; + } + + public static boolean allowStrictMath() { + return ALLOW_STRICT_MATH; + } + + public static boolean allowTvmCancun() { + return ALLOW_TVM_CANCUN; + } + + public static boolean disableJavaLangMath() { + return DISABLE_JAVA_LANG_MATH; + } + + public static boolean allowTvmBlob() { + return ALLOW_TVM_BLOB; + } } diff --git a/config/checkstyle/checkStyle.xml b/config/checkstyle/checkStyle.xml index 16fda0fdc4f..9d09ca11bee 100644 --- a/config/checkstyle/checkStyle.xml +++ b/config/checkstyle/checkStyle.xml @@ -1,7 +1,7 @@ + "https://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd"> + diff --git a/framework/src/test/java/org/tron/common/BaseTest.java b/framework/src/test/java/org/tron/common/BaseTest.java index 959a746a141..552808b842c 100644 --- a/framework/src/test/java/org/tron/common/BaseTest.java +++ b/framework/src/test/java/org/tron/common/BaseTest.java @@ -16,6 +16,7 @@ import org.tron.common.application.Application; import org.tron.common.crypto.ECKey; import org.tron.common.parameter.CommonParameter; +import org.tron.common.utils.Commons; import org.tron.common.utils.Sha256Hash; import org.tron.consensus.base.Param; import org.tron.core.ChainBaseManager; @@ -23,6 +24,8 @@ import org.tron.core.config.DefaultConfig; import org.tron.core.config.args.Args; import org.tron.core.db.Manager; +import org.tron.core.exception.BalanceInsufficientException; +import org.tron.core.store.AccountStore; import org.tron.protos.Protocol; @Slf4j @@ -102,4 +105,10 @@ public Protocol.Block getSignedBlock(ByteString witness, long time, byte[] priva return block.toBuilder().setBlockHeader(blockHeader).build(); } + + public void adjustBalance(AccountStore accountStore, byte[] accountAddress, long amount) + throws BalanceInsufficientException { + Commons.adjustBalance(accountStore, accountAddress, amount, + chainBaseManager.getDynamicPropertiesStore().disableJavaLangMath()); + } } diff --git a/framework/src/test/java/org/tron/common/EntityTest.java b/framework/src/test/java/org/tron/common/EntityTest.java new file mode 100644 index 00000000000..483475a453b --- /dev/null +++ b/framework/src/test/java/org/tron/common/EntityTest.java @@ -0,0 +1,67 @@ +package org.tron.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import com.google.common.collect.Lists; +import java.util.HashMap; +import org.apache.commons.collections4.CollectionUtils; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.entity.NodeInfo; +import org.tron.common.entity.NodeInfo.MachineInfo; +import org.tron.common.entity.NodeInfo.MachineInfo.DeadLockThreadInfo; + +public class EntityTest { + + private final MachineInfo machineInfo = new MachineInfo(); + private final DeadLockThreadInfo deadLockThreadInfo = new DeadLockThreadInfo(); + + @Before + public void setup() { + deadLockThreadInfo.setName("name"); + deadLockThreadInfo.setLockName("lockName"); + deadLockThreadInfo.setLockOwner("lockOwner"); + deadLockThreadInfo.setState("state"); + deadLockThreadInfo.setStackTrace("stackTrace"); + deadLockThreadInfo.setWaitTime(0L); + deadLockThreadInfo.setBlockTime(0L); + machineInfo.setDeadLockThreadInfoList(Lists.newArrayList(deadLockThreadInfo)); + machineInfo.setJavaVersion("1.8"); + machineInfo.setOsName("linux"); + } + + @Test + public void testMachineInfo() { + machineInfo.setDeadLockThreadCount(3); + assertTrue(CollectionUtils.isNotEmpty(machineInfo.getDeadLockThreadInfoList())); + assertEquals(3, machineInfo.getDeadLockThreadCount()); + + } + + @Test + public void testDeadLockThreadInfo() { + assertEquals("name", deadLockThreadInfo.getName()); + assertEquals("lockName", deadLockThreadInfo.getLockName()); + assertEquals("lockOwner", deadLockThreadInfo.getLockOwner()); + assertEquals("state", deadLockThreadInfo.getState()); + assertEquals("stackTrace", deadLockThreadInfo.getStackTrace()); + assertEquals(0, deadLockThreadInfo.getBlockTime()); + assertEquals(0, deadLockThreadInfo.getWaitTime()); + + } + + @Test + public void testNodeInfo() { + NodeInfo nodeInfo = new NodeInfo(); + nodeInfo.setTotalFlow(1L); + nodeInfo.setCheatWitnessInfoMap(new HashMap<>()); + assertEquals(1, nodeInfo.getTotalFlow()); + assertNotNull(nodeInfo.getCheatWitnessInfoMap()); + nodeInfo.setMachineInfo(machineInfo); + nodeInfo.setBlock("block"); + nodeInfo.setSolidityBlock("solidityBlock"); + nodeInfo.transferToProtoEntity(); + } +} diff --git a/framework/src/test/java/org/tron/common/MultiLayoutPatternTest.java b/framework/src/test/java/org/tron/common/MultiLayoutPatternTest.java new file mode 100644 index 00000000000..87223757e8e --- /dev/null +++ b/framework/src/test/java/org/tron/common/MultiLayoutPatternTest.java @@ -0,0 +1,72 @@ +package org.tron.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.classic.spi.LoggingEvent; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.LoggerFactory; +import org.tron.common.log.layout.MultiLayoutPattern; + +public class MultiLayoutPatternTest { + + private MultiLayoutPattern multiLayoutPattern; + private LoggerContext context; + + @Before + public void setUp() { + context = new LoggerContext(); + multiLayoutPattern = new MultiLayoutPattern(); + multiLayoutPattern.setContext(context); + + MultiLayoutPattern.Rule rule1 = new MultiLayoutPattern.Rule(); + rule1.setLogger("com.example.app1"); + assertNotNull(rule1.getLogger()); + rule1.setPattern("%date [%thread] %-5level %logger{36} - %msg%n"); + assertNotNull(rule1.getPattern()); + rule1.setOutputPatternAsHeader(true); + assertTrue(rule1.isOutputPatternAsHeader()); + multiLayoutPattern.addRule(rule1); + + MultiLayoutPattern.Rule rule2 = new MultiLayoutPattern.Rule(); + rule2.setLogger("com.example.app2"); + rule2.setPattern("%msg%n"); + multiLayoutPattern.addRule(rule2); + + multiLayoutPattern.start(); + } + + @Test + public void testEncodeForSpecificLogger() { + ILoggingEvent event1 = createLoggingEvent("com.example.app1", "Test message 1"); + byte[] encoded1 = multiLayoutPattern.encode(event1); + String result1 = new String(encoded1); + assertTrue(result1.contains("Test message 1")); + + ILoggingEvent event2 = createLoggingEvent("com.example.app2", "Test message 2"); + byte[] encoded2 = multiLayoutPattern.encode(event2); + String result2 = new String(encoded2); + assertEquals("Test message 2\n", result2); + } + + @Test + public void testEncodeForRootLogger() { + ILoggingEvent event = createLoggingEvent(Logger.ROOT_LOGGER_NAME, "Root logger message"); + byte[] encoded = multiLayoutPattern.encode(event); + String result = new String(encoded); + assertFalse(result.contains("Root logger message")); + } + + private ILoggingEvent createLoggingEvent(String loggerName, String message) { + Logger logger = (Logger) LoggerFactory.getLogger(loggerName); + return new LoggingEvent(loggerName, logger, Level.INFO, message, null, null); + } + +} diff --git a/framework/src/test/java/org/tron/common/ParameterTest.java b/framework/src/test/java/org/tron/common/ParameterTest.java new file mode 100644 index 00000000000..b16be405f61 --- /dev/null +++ b/framework/src/test/java/org/tron/common/ParameterTest.java @@ -0,0 +1,320 @@ +package org.tron.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.tron.common.parameter.RateLimiterInitialization.createHttpItem; +import static org.tron.common.parameter.RateLimiterInitialization.createRpcItem; +import static org.tron.core.Constant.ECKey_ENGINE; + +import com.google.common.collect.Lists; +import com.typesafe.config.ConfigFactory; +import com.typesafe.config.ConfigObject; +import java.util.ArrayList; +import java.util.HashSet; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; +import org.tron.common.parameter.CommonParameter; +import org.tron.common.parameter.RateLimiterInitialization; +import org.tron.common.parameter.RateLimiterInitialization.HttpRateLimiterItem; +import org.tron.common.parameter.RateLimiterInitialization.RpcRateLimiterItem; +import org.tron.p2p.dns.update.PublishConfig; + +public class ParameterTest { + @Test + public void testConstructor_ValidConfig() { + String configStr = "{\"component\":\"testComponent\",\"strategy\":\"testStrategy\"," + + "\"paramString\":\"testParams\"}"; + ConfigObject config = ConfigFactory.parseString(configStr).root().toConfig().root(); + RpcRateLimiterItem item = new RpcRateLimiterItem(config); + HttpRateLimiterItem item1 = new HttpRateLimiterItem(config); + + assertEquals("testComponent", item.getComponent()); + assertEquals("testComponent", item1.getComponent()); + assertEquals("testStrategy", item.getStrategy()); + assertEquals("testParams", item.getParams()); + assertNull(createRpcItem(null)); + assertNull(createHttpItem(null)); + assertNotNull(createRpcItem(config)); + RateLimiterInitialization rateLimiterInitialization = new RateLimiterInitialization(); + rateLimiterInitialization.setRpcMap(Lists.newArrayList(item)); + assertFalse(rateLimiterInitialization.isHttpFlag()); + assertTrue(rateLimiterInitialization.isRpcFlag()); + } + + @Test + public void testCommonParameter() { + CommonParameter parameter = new CommonParameter(); + parameter.setWitness(false); + parameter.setSupportConstant(false); + parameter.setMaxEnergyLimitForConstant(1000000L); + parameter.setLruCacheSize(5); + parameter.setMinTimeRatio(0); + parameter.setMaxTimeRatio(20); + parameter.setSaveInternalTx(false); + parameter.setSaveFeaturedInternalTx(false); + parameter.setLongRunningTime(60); + parameter.setMaxHttpConnectNumber(5); + + assertEquals(StringUtils.EMPTY, parameter.getLogbackPath()); + assertEquals(1000000L, parameter.getMaxEnergyLimitForConstant()); + assertEquals(5, parameter.getLruCacheSize()); + assertEquals(60, parameter.getLongRunningTime()); + assertFalse(parameter.isHelp()); + assertFalse(parameter.isSaveFeaturedInternalTx()); + assertFalse(parameter.isSaveInternalTx()); + CollectionUtils.isEmpty(parameter.getSeedNodes()); + parameter.setChainId("123"); + assertEquals("123", parameter.getChainId()); + parameter.setNeedSyncCheck(false); + assertFalse(parameter.isNeedSyncCheck()); + parameter.setNodeDiscoveryEnable(false); + assertFalse(parameter.isNodeDiscoveryEnable()); + parameter.setNodeDiscoveryPersist(false); + assertFalse(parameter.isNodeDiscoveryPersist()); + parameter.setNodeEffectiveCheckEnable(false); + assertFalse(parameter.isNodeEffectiveCheckEnable()); + parameter.setNodeConnectionTimeout(500); + assertEquals(500, parameter.getNodeConnectionTimeout()); + parameter.setFetchBlockTimeout(500); + assertEquals(500, parameter.getFetchBlockTimeout()); + parameter.setNodeChannelReadTimeout(500); + assertEquals(500, parameter.getNodeChannelReadTimeout()); + parameter.setMaxConnections(500); + assertEquals(500, parameter.getMaxConnections()); + parameter.setMinConnections(500); + assertEquals(500, parameter.getMinConnections()); + parameter.setMinActiveConnections(500); + assertEquals(500, parameter.getMinActiveConnections()); + parameter.setMaxConnectionsWithSameIp(500); + assertEquals(500, parameter.getMaxConnectionsWithSameIp()); + parameter.setMaxTps(500); + assertEquals(500, parameter.getMaxTps()); + parameter.setMinParticipationRate(500); + assertEquals(500, parameter.getMinParticipationRate()); + parameter.setMaxConnectionsWithSameIp(500); + assertEquals(500, parameter.getMaxConnectionsWithSameIp()); + assertNull(parameter.getP2pConfig()); + parameter.setNodeLanIp("500"); + assertEquals("500", parameter.getNodeLanIp()); + parameter.setNodeP2pVersion(5); + assertEquals(5, parameter.getNodeP2pVersion()); + parameter.setNodeEnableIpv6(false); + assertFalse(parameter.isNodeEnableIpv6()); + parameter.setDnsTreeUrls(new ArrayList<>()); + assertTrue(CollectionUtils.isEmpty(parameter.getDnsTreeUrls())); + parameter.setDnsPublishConfig(new PublishConfig()); + parameter.setSyncFetchBatchNum(500); + assertEquals(500, parameter.getSyncFetchBatchNum()); + parameter.setDebug(false); + assertFalse(parameter.isDebug()); + parameter.setFullNodeHttpPort(80); + assertEquals(80, parameter.getFullNodeHttpPort()); + parameter.setSolidityHttpPort(80); + assertEquals(80, parameter.getSolidityHttpPort()); + parameter.setJsonRpcHttpFullNodePort(80); + assertEquals(80, parameter.getJsonRpcHttpFullNodePort()); + parameter.setJsonRpcHttpSolidityPort(80); + assertEquals(80, parameter.getJsonRpcHttpSolidityPort()); + parameter.setJsonRpcHttpPBFTPort(80); + assertEquals(80, parameter.getJsonRpcHttpPBFTPort()); + parameter.setRpcThreadNum(10); + assertEquals(10, parameter.getRpcThreadNum()); + parameter.setSolidityThreads(5); + assertEquals(5, parameter.getSolidityThreads()); + parameter.setMaxConcurrentCallsPerConnection(10); + assertEquals(10, parameter.getMaxConcurrentCallsPerConnection()); + parameter.setFlowControlWindow(20); + assertEquals(20, parameter.getFlowControlWindow()); + parameter.setMaxConnectionIdleInMillis(1000); + assertEquals(1000, parameter.getMaxConnectionIdleInMillis()); + parameter.setBlockProducedTimeOut(500); + assertEquals(500, parameter.getBlockProducedTimeOut()); + parameter.setNetMaxTrxPerSecond(15); + assertEquals(15, parameter.getNetMaxTrxPerSecond()); + parameter.setMaxConnectionAgeInMillis(1500); + assertEquals(1500, parameter.getMaxConnectionAgeInMillis()); + parameter.setMaxMessageSize(200); + assertEquals(200, parameter.getMaxMessageSize()); + parameter.setMaxHeaderListSize(100); + assertEquals(100, parameter.getMaxHeaderListSize()); + parameter.setRpcReflectionServiceEnable(false); + assertFalse(parameter.isRpcReflectionServiceEnable); + parameter.setValidateSignThreadNum(5); + assertEquals(5, parameter.getValidateSignThreadNum()); + parameter.setMaintenanceTimeInterval(200); + assertEquals(200, parameter.getMaintenanceTimeInterval()); + parameter.setProposalExpireTime(1000); + assertEquals(1000, parameter.getProposalExpireTime()); + parameter.setAllowCreationOfContracts(1); + assertEquals(1, parameter.getAllowCreationOfContracts()); + parameter.setAllowAdaptiveEnergy(1); + assertEquals(1, parameter.getAllowAdaptiveEnergy()); + parameter.setAllowDelegateResource(1); + assertEquals(1, parameter.getAllowDelegateResource()); + parameter.setAllowSameTokenName(1); + assertEquals(1, parameter.getAllowSameTokenName()); + parameter.setAllowTvmTransferTrc10(1); + assertEquals(1, parameter.getAllowTvmTransferTrc10()); + parameter.setAllowTvmConstantinople(1); + assertEquals(1, parameter.getAllowTvmConstantinople()); + parameter.setAllowTvmSolidity059(1); + assertEquals(1, parameter.getAllowTvmSolidity059()); + parameter.setForbidTransferToContract(1); + assertEquals(1, parameter.getForbidTransferToContract()); + parameter.setTcpNettyWorkThreadNum(5); + assertEquals(5, parameter.getTcpNettyWorkThreadNum()); + parameter.setUdpNettyWorkThreadNum(5); + assertEquals(5, parameter.getUdpNettyWorkThreadNum()); + parameter.setTrustNodeAddr("address"); + assertEquals("address", parameter.getTrustNodeAddr()); + parameter.setWalletExtensionApi(false); + assertFalse(parameter.isWalletExtensionApi()); + parameter.setEstimateEnergy(false); + assertFalse(parameter.isEstimateEnergy()); + parameter.setEstimateEnergyMaxRetry(2); + assertEquals(2, parameter.getEstimateEnergyMaxRetry()); + parameter.setKeepAliveInterval(1000); + assertEquals(1000, parameter.getKeepAliveInterval()); + parameter.setReceiveTcpMinDataLength(10); + assertEquals(10, parameter.getReceiveTcpMinDataLength()); + parameter.setOpenFullTcpDisconnect(false); + assertFalse(parameter.isOpenFullTcpDisconnect()); + parameter.setNodeDetectEnable(false); + assertFalse(parameter.isNodeDetectEnable()); + parameter.setAllowMultiSign(1); + assertEquals(1, parameter.getAllowMultiSign()); + parameter.setVmTrace(false); + assertFalse(parameter.isVmTrace()); + parameter.setNeedToUpdateAsset(false); + assertFalse(parameter.isNeedToUpdateAsset()); + parameter.setTrxReferenceBlock("test"); + assertEquals("test", parameter.getTrxReferenceBlock()); + parameter.setTrxCacheEnable(false); + assertFalse(parameter.isTrxCacheEnable()); + parameter.setAllowMarketTransaction(1); + assertEquals(1, parameter.getAllowMarketTransaction()); + parameter.setAllowTransactionFeePool(1); + assertEquals(1, parameter.getAllowTransactionFeePool()); + parameter.setAllowBlackHoleOptimization(1); + assertEquals(1, parameter.getAllowBlackHoleOptimization()); + parameter.setAllowNewResourceModel(1); + assertEquals(1, parameter.getAllowNewResourceModel()); + parameter.setEventSubscribe(false); + assertFalse(parameter.isEventSubscribe()); + parameter.setTrxExpirationTimeInMilliseconds(100); + assertEquals(100, parameter.getTrxExpirationTimeInMilliseconds()); + parameter.setAllowProtoFilterNum(10); + assertEquals(10, parameter.getAllowProtoFilterNum()); + parameter.setShieldedTransInPendingMaxCounts(1); + assertEquals(1, parameter.getShieldedTransInPendingMaxCounts()); + parameter.setChangedDelegation(1); + assertEquals(1, parameter.getChangedDelegation()); + parameter.setActuatorSet(new HashSet<>()); + assertTrue(CollectionUtils.isEmpty(parameter.getActuatorSet())); + parameter.setRateLimiterInitialization(new RateLimiterInitialization()); + assertNotNull(parameter.getRateLimiterInitialization()); + parameter.setRateLimiterGlobalQps(1000); + assertEquals(1000, parameter.getRateLimiterGlobalQps()); + parameter.setRateLimiterGlobalIpQps(100); + assertEquals(100, parameter.getRateLimiterGlobalIpQps()); + assertNull(parameter.getOverlay()); + assertNull(parameter.getEventPluginConfig()); + assertNull(parameter.getEventFilter()); + parameter.setCryptoEngine(ECKey_ENGINE); + assertEquals(ECKey_ENGINE, parameter.getCryptoEngine()); + parameter.setFullNodeHttpEnable(false); + assertFalse(parameter.isFullNodeHttpEnable()); + parameter.setSolidityNodeHttpEnable(false); + assertFalse(parameter.isSolidityNodeHttpEnable()); + parameter.setMaxTransactionPendingSize(500); + assertEquals(500, parameter.getMaxTransactionPendingSize()); + parameter.setPendingTransactionTimeout(500); + assertEquals(500, parameter.getPendingTransactionTimeout()); + parameter.setNodeMetricsEnable(false); + assertFalse(parameter.isNodeMetricsEnable()); + parameter.setMetricsStorageEnable(false); + assertFalse(parameter.isMetricsStorageEnable()); + parameter.setInfluxDbIp("127.0.0.1"); + assertEquals("127.0.0.1", parameter.getInfluxDbIp()); + parameter.setInfluxDbPort(90); + assertEquals(90, parameter.getInfluxDbPort()); + parameter.setInfluxDbDatabase("InfluxDb"); + assertEquals("InfluxDb", parameter.getInfluxDbDatabase()); + parameter.setMetricsReportInterval(100); + assertEquals(100, parameter.getMetricsReportInterval()); + parameter.setMetricsPrometheusPort(3000); + assertEquals(3000, parameter.getMetricsPrometheusPort()); + parameter.setAgreeNodeCount(10); + assertEquals(10, parameter.getAgreeNodeCount()); + parameter.setAllowPBFT(1); + assertEquals(1, parameter.getAllowPBFT()); + parameter.setPBFTHttpPort(70); + assertEquals(70, parameter.getPBFTHttpPort()); + parameter.setPBFTExpireNum(100); + assertEquals(100, parameter.getPBFTExpireNum()); + parameter.setAllowShieldedTRC20Transaction(10); + assertEquals(10, parameter.getAllowShieldedTRC20Transaction()); + parameter.setAllowTvmIstanbul(1); + assertEquals(1, parameter.getAllowTvmIstanbul()); + parameter.setAllowTvmVote(1); + assertEquals(1, parameter.getAllowTvmVote()); + parameter.setAllowTvmLondon(1); + assertEquals(1, parameter.getAllowTvmLondon()); + parameter.setAllowTvmCompatibleEvm(1); + assertEquals(1, parameter.getAllowTvmCompatibleEvm()); + parameter.setAllowHigherLimitForMaxCpuTimeOfOneTx(1); + assertEquals(1, parameter.getAllowHigherLimitForMaxCpuTimeOfOneTx()); + parameter.setHistoryBalanceLookup(false); + assertFalse(parameter.isHistoryBalanceLookup()); + parameter.setOpenPrintLog(false); + assertFalse(parameter.isOpenPrintLog()); + parameter.setOpenTransactionSort(false); + assertFalse(parameter.isOpenTransactionSort()); + parameter.setAllowAssetOptimization(1); + assertEquals(1, parameter.getAllowAssetOptimization()); + parameter.setAllowAccountAssetOptimization(1); + assertEquals(1, parameter.getAllowAccountAssetOptimization()); + parameter.setBlockCacheTimeout(60); + assertEquals(60, parameter.getBlockCacheTimeout()); + parameter.setAllowNewReward(1); + assertEquals(1, parameter.getAllowNewReward()); + parameter.setAllowNewRewardAlgorithm(1); + assertEquals(1, parameter.getAllowNewRewardAlgorithm()); + parameter.setMemoFee(100); + assertEquals(100, parameter.getMemoFee()); + parameter.setAllowDelegateOptimization(1); + assertEquals(1, parameter.getAllowDelegateOptimization()); + parameter.setUnfreezeDelayDays(10); + assertEquals(10, parameter.getUnfreezeDelayDays()); + parameter.setAllowOptimizedReturnValueOfChainId(1); + assertEquals(1, parameter.getAllowOptimizedReturnValueOfChainId()); + parameter.setAllowDynamicEnergy(1); + assertEquals(1, parameter.getAllowDynamicEnergy()); + parameter.setDynamicEnergyThreshold(1); + assertEquals(1, parameter.getDynamicEnergyThreshold()); + parameter.setDynamicEnergyIncreaseFactor(1); + assertEquals(1, parameter.getDynamicEnergyIncreaseFactor()); + parameter.setDynamicEnergyMaxFactor(1); + assertEquals(1, parameter.getDynamicEnergyMaxFactor()); + parameter.setDynamicConfigEnable(false); + assertFalse(parameter.isDynamicConfigEnable()); + parameter.setDynamicConfigCheckInterval(10); + assertEquals(10, parameter.getDynamicConfigCheckInterval()); + parameter.setAllowTvmShangHai(1); + assertEquals(1, parameter.getAllowTvmShangHai()); + parameter.setAllowCancelAllUnfreezeV2(1); + assertEquals(1, parameter.getAllowCancelAllUnfreezeV2()); + parameter.setMaxUnsolidifiedBlocks(100); + assertEquals(100, parameter.getMaxUnsolidifiedBlocks()); + parameter.setAllowOldRewardOpt(1); + assertEquals(1, parameter.getAllowOldRewardOpt()); + parameter.setAllowEnergyAdjustment(1); + assertEquals(1, parameter.getAllowEnergyAdjustment()); + parameter.setMaxCreateAccountTxSize(1000); + assertEquals(1000, parameter.getMaxCreateAccountTxSize()); + } +} diff --git a/framework/src/test/java/org/tron/common/backup/BackupManagerTest.java b/framework/src/test/java/org/tron/common/backup/BackupManagerTest.java index 8a5ff4f4bc2..9ace8f5b601 100644 --- a/framework/src/test/java/org/tron/common/backup/BackupManagerTest.java +++ b/framework/src/test/java/org/tron/common/backup/BackupManagerTest.java @@ -4,41 +4,62 @@ import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService; +import org.junit.After; import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.tron.common.backup.BackupManager.BackupStatusEnum; import org.tron.common.backup.message.KeepAliveMessage; +import org.tron.common.backup.socket.BackupServer; import org.tron.common.backup.socket.UdpEvent; import org.tron.common.parameter.CommonParameter; +import org.tron.common.utils.PublicMethod; import org.tron.core.Constant; import org.tron.core.config.args.Args; public class BackupManagerTest { + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(); + private BackupManager manager; + private BackupServer backupServer; + + @Before + public void setUp() throws Exception { + Args.setParam(new String[] {"-d", temporaryFolder.newFolder().toString()}, Constant.TEST_CONF); + CommonParameter.getInstance().setBackupPort(PublicMethod.chooseRandomPort()); + manager = new BackupManager(); + backupServer = new BackupServer(manager); + } + + @After + public void tearDown() { + Args.clearParam(); + } + @Test public void test() throws Exception { - String[] a = new String[0]; - Args.setParam(a, Constant.TESTNET_CONF); - CommonParameter parameter = CommonParameter.getInstance(); - parameter.setBackupPriority(8); + CommonParameter.getInstance().setBackupPriority(8); List members = new ArrayList<>(); members.add("127.0.0.2"); - parameter.setBackupMembers(members); + CommonParameter.getInstance().setBackupMembers(members); - BackupManager manager = new BackupManager(); - - Field field = manager.getClass().getDeclaredField("localIp"); + Field field = manager.getClass().getDeclaredField("localIp"); field.setAccessible(true); field.set(manager, "127.0.0.1"); - Assert.assertEquals(manager.getStatus(), BackupManager.BackupStatusEnum.MASTER); + Assert.assertEquals(BackupManager.BackupStatusEnum.MASTER, manager.getStatus()); - field = manager.getClass().getDeclaredField("executorService"); + field = manager.getClass().getDeclaredField("executorService"); field.setAccessible(true); ScheduledExecutorService executorService = (ScheduledExecutorService) field.get(manager); manager.init(); executorService.shutdown(); - Assert.assertEquals(manager.getStatus(), BackupManager.BackupStatusEnum.INIT); + Assert.assertEquals(BackupManager.BackupStatusEnum.INIT, manager.getStatus()); /* ip not in the members */ manager.setStatus(BackupManager.BackupStatusEnum.INIT); @@ -46,45 +67,76 @@ public void test() throws Exception { InetSocketAddress address = new InetSocketAddress("127.0.0.3", 1000); UdpEvent event = new UdpEvent(message, address); manager.handleEvent(event); - Assert.assertEquals(manager.getStatus(), BackupManager.BackupStatusEnum.INIT); + Assert.assertEquals(BackupManager.BackupStatusEnum.INIT, manager.getStatus()); /* ip not the member */ address = new InetSocketAddress("127.0.0.3", 1000); message = new KeepAliveMessage(false, 6); event = new UdpEvent(message, address); manager.handleEvent(event); - Assert.assertEquals(manager.getStatus(), BackupManager.BackupStatusEnum.INIT); + Assert.assertEquals(BackupManager.BackupStatusEnum.INIT, manager.getStatus()); /* keepAliveMessage.getFlag() || peerPriority > priority */ address = new InetSocketAddress("127.0.0.2", 1000); message = new KeepAliveMessage(false, 6); event = new UdpEvent(message, address); manager.handleEvent(event); - Assert.assertEquals(manager.getStatus(), BackupManager.BackupStatusEnum.INIT); + Assert.assertEquals(BackupStatusEnum.SLAVER, manager.getStatus()); /* keepAliveMessage.getFlag() || peerPriority > priority */ message = new KeepAliveMessage(false, 10); event = new UdpEvent(message, address); manager.handleEvent(event); - Assert.assertEquals(manager.getStatus(), BackupManager.BackupStatusEnum.SLAVER); + Assert.assertEquals(BackupManager.BackupStatusEnum.SLAVER, manager.getStatus()); /* keepAliveMessage.getFlag() || peerPriority > priority */ manager.setStatus(BackupManager.BackupStatusEnum.INIT); message = new KeepAliveMessage(true, 6); event = new UdpEvent(message, address); manager.handleEvent(event); - Assert.assertEquals(manager.getStatus(), BackupManager.BackupStatusEnum.SLAVER); + Assert.assertEquals(BackupManager.BackupStatusEnum.SLAVER, manager.getStatus()); manager.setStatus(BackupManager.BackupStatusEnum.MASTER); message = new KeepAliveMessage(false, 10); event = new UdpEvent(message, address); manager.handleEvent(event); - Assert.assertEquals(manager.getStatus(), BackupManager.BackupStatusEnum.MASTER); + Assert.assertEquals(BackupManager.BackupStatusEnum.MASTER, manager.getStatus()); message = new KeepAliveMessage(true, 10); event = new UdpEvent(message, address); manager.handleEvent(event); - Assert.assertEquals(manager.getStatus(), BackupManager.BackupStatusEnum.SLAVER); + Assert.assertEquals(BackupManager.BackupStatusEnum.SLAVER, manager.getStatus()); + + } + + @Test + public void testSendKeepAliveMessage() throws Exception { + CommonParameter parameter = CommonParameter.getInstance(); + parameter.setBackupPriority(8); + List members = new ArrayList<>(); + members.add("127.0.0.2"); + parameter.setBackupMembers(members); + + Field field = manager.getClass().getDeclaredField("localIp"); + field.setAccessible(true); + field.set(manager, "127.0.0.1"); + + Assert.assertEquals(manager.getStatus(), BackupManager.BackupStatusEnum.MASTER); + backupServer.initServer(); + manager.init(); + + Thread.sleep(parameter.getKeepAliveInterval() + 1000);//test send KeepAliveMessage + + field = manager.getClass().getDeclaredField("executorService"); + field.setAccessible(true); + ScheduledExecutorService executorService = (ScheduledExecutorService) field.get(manager); + executorService.shutdown(); + + Field field2 = backupServer.getClass().getDeclaredField("executor"); + field2.setAccessible(true); + ExecutorService executorService2 = (ExecutorService) field2.get(backupServer); + executorService2.shutdown(); + Assert.assertEquals(BackupManager.BackupStatusEnum.INIT, manager.getStatus()); } } diff --git a/framework/src/test/java/org/tron/common/backup/BackupServerTest.java b/framework/src/test/java/org/tron/common/backup/BackupServerTest.java index 34b17ec186f..c40aca7e17a 100644 --- a/framework/src/test/java/org/tron/common/backup/BackupServerTest.java +++ b/framework/src/test/java/org/tron/common/backup/BackupServerTest.java @@ -7,6 +7,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.junit.rules.Timeout; import org.tron.common.backup.socket.BackupServer; import org.tron.common.parameter.CommonParameter; import org.tron.core.Constant; @@ -17,6 +18,9 @@ public class BackupServerTest { @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @Rule + public Timeout globalTimeout = Timeout.seconds(60); private BackupServer backupServer; @Before @@ -37,8 +41,10 @@ public void tearDown() { Args.clearParam(); } - @Test + @Test(timeout = 60_000) public void test() throws InterruptedException { backupServer.initServer(); + // wait for the server to start + Thread.sleep(1000); } } diff --git a/framework/src/test/java/org/tron/common/cache/TronCacheTest.java b/framework/src/test/java/org/tron/common/cache/TronCacheTest.java new file mode 100644 index 00000000000..422bd1de881 --- /dev/null +++ b/framework/src/test/java/org/tron/common/cache/TronCacheTest.java @@ -0,0 +1,100 @@ +package org.tron.common.cache; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.tron.common.cache.CacheManager.allocate; +import static org.tron.common.cache.CacheStrategies.CACHE_STRATEGY_DEFAULT; +import static org.tron.common.cache.CacheType.findByType; +import static org.tron.common.cache.CacheType.witness; +import static org.tron.common.cache.CacheType.witnessStandby; + +import com.google.common.cache.CacheLoader; +import java.util.concurrent.ExecutionException; +import javax.annotation.ParametersAreNonnullByDefault; +import lombok.extern.slf4j.Slf4j; +import org.junit.Before; +import org.junit.Test; + +@Slf4j +public class TronCacheTest { + + private TronCache cacheWithLoader; + private TronCache cacheWithoutLoader; + CacheLoader loader = new CacheLoader() { + @Override + @ParametersAreNonnullByDefault + public String load(String key) { + return "Loaded: " + key; + } + }; + + @Before + public void setUp() { + + cacheWithLoader = new TronCache<>(witness, CACHE_STRATEGY_DEFAULT, loader); + + cacheWithoutLoader = new TronCache<>(witnessStandby, CACHE_STRATEGY_DEFAULT); + } + + @Test + public void testGetIfPresent() { + cacheWithoutLoader.put("key1", "value1"); + assertEquals("value1", cacheWithoutLoader.getIfPresent("key1")); + assertNull(cacheWithoutLoader.getIfPresent("key2")); + } + + @Test + public void testGetWithLoader() throws ExecutionException { + String value = cacheWithLoader.get("key1", () -> "Fallback value"); + assertEquals("Fallback value", value); + } + + @Test + public void testPutAndGet() { + cacheWithoutLoader.put("key2", "value2"); + assertEquals("value2", cacheWithoutLoader.getIfPresent("key2")); + assertEquals(witnessStandby, cacheWithoutLoader.getName()); + logger.info("hash code: {}", cacheWithoutLoader.hashCode()); + } + + @Test + public void testStats() { + cacheWithoutLoader.put("key3", "value3"); + assertNotNull(cacheWithoutLoader.stats()); + assertEquals(0, cacheWithoutLoader.stats().hitCount()); + cacheWithoutLoader.getIfPresent("key3"); + assertTrue(cacheWithoutLoader.stats().hitCount() > 0); + } + + @Test + public void testInvalidateAll() { + cacheWithoutLoader.put("key4", "value4"); + assertEquals("value4", cacheWithoutLoader.getIfPresent("key4")); + cacheWithoutLoader.invalidateAll(); + assertNull(cacheWithoutLoader.getIfPresent("key4")); + } + + @Test + public void testEquals() { + TronCache tmpCache = cacheWithoutLoader; + assertEquals(cacheWithoutLoader, tmpCache); + assertNotEquals(cacheWithoutLoader, new Object()); + assertNotEquals(cacheWithoutLoader, cacheWithLoader); + tmpCache = new TronCache<>(witnessStandby, CACHE_STRATEGY_DEFAULT); + assertEquals(cacheWithoutLoader, tmpCache); + } + + @Test + public void testCacheManager() { + TronCache allocate = allocate(witness, CACHE_STRATEGY_DEFAULT); + TronCache allocate1 = allocate(witness, CACHE_STRATEGY_DEFAULT, loader); + assertNotNull(allocate); + assertNotNull(allocate1); + assertThrows(IllegalArgumentException.class, () -> findByType("test")); + } + +} diff --git a/framework/src/test/java/org/tron/common/config/args/ArgsTest.java b/framework/src/test/java/org/tron/common/config/args/ArgsTest.java index b95d47bfa39..01a49f6df40 100644 --- a/framework/src/test/java/org/tron/common/config/args/ArgsTest.java +++ b/framework/src/test/java/org/tron/common/config/args/ArgsTest.java @@ -36,7 +36,7 @@ public void testConfig() { Args.logConfig(); Assert.assertEquals(Args.getInstance().getMaxTransactionPendingSize(), 2000); Assert.assertEquals(Args.getInstance().getPendingTransactionTimeout(), 60_000); - Assert.assertEquals(Args.getInstance().getMaxFastForwardNum(), 3); + Assert.assertEquals(Args.getInstance().getMaxFastForwardNum(), 4); Assert.assertEquals(Args.getInstance().getBlockCacheTimeout(), 60); Assert.assertEquals(Args.getInstance().isNodeDetectEnable(), false); Assert.assertFalse(Args.getInstance().isNodeEffectiveCheckEnable()); @@ -48,6 +48,7 @@ public void testConfig() { RateLimiterInitialization rateLimiter = Args.getInstance().getRateLimiterInitialization(); Assert.assertEquals(rateLimiter.getHttpMap().size(), 1); Assert.assertEquals(rateLimiter.getRpcMap().size(), 0); + Assert.assertTrue(Args.getInstance().isRpcReflectionServiceEnable()); } @Test diff --git a/framework/src/test/java/org/tron/common/cron/CronExpressionTest.java b/framework/src/test/java/org/tron/common/cron/CronExpressionTest.java new file mode 100644 index 00000000000..5e41670763c --- /dev/null +++ b/framework/src/test/java/org/tron/common/cron/CronExpressionTest.java @@ -0,0 +1,450 @@ +/* + * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. + * Copyright IBM Corp. 2024, 2025 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.tron.common.cron; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.text.ParseException; +import java.util.Calendar; +import java.util.Date; +import org.junit.Test; + +public class CronExpressionTest { + + private static void assertTrue(boolean condition, String message) { + if (!condition) { + fail(message); + } + } + + private static void assertTrue(boolean condition) { + if (!condition) { + fail(); + } + } + + @Test + public void testTooManyTokens() { + try { + new CronExpression("0 15 10 * * ? 2005 *"); // too many tokens/terms in expression + fail("Expected ParseException did not occur for invalid expression"); + } catch (ParseException pe) { + assertTrue(pe.getMessage().contains("too many"), + "Incorrect ParseException thrown"); + } + + } + + @Test + public void testIsSatisfiedBy() throws Exception { + CronExpression cronExpression = new CronExpression("0 15 10 * * ? 2005"); + + Calendar cal = Calendar.getInstance(); + + cal.set(2005, Calendar.JUNE, 1, 10, 15, 0); + assertTrue(cronExpression.isSatisfiedBy(cal.getTime())); + + cal.set(Calendar.YEAR, 2006); + assertFalse(cronExpression.isSatisfiedBy(cal.getTime())); + + cal = Calendar.getInstance(); + cal.set(2005, Calendar.JUNE, 1, 10, 16, 0); + assertFalse(cronExpression.isSatisfiedBy(cal.getTime())); + + cal = Calendar.getInstance(); + cal.set(2005, Calendar.JUNE, 1, 10, 14, 0); + assertFalse(cronExpression.isSatisfiedBy(cal.getTime())); + } + + @Test + public void testIsValidExpression() { + assertTrue(CronExpression.isValidExpression("0 0 0 L-2 * ? *")); + assertTrue(CronExpression.isValidExpression("0 0 0 LW * ? *")); + assertFalse(CronExpression.isValidExpression("0 0 0 Foo * ? *")); + assertFalse(CronExpression.isValidExpression("61 15 10 L-2 * ? 2010")); + assertFalse(CronExpression.isValidExpression("0 61 10 L-2 * ? 2010")); + assertFalse(CronExpression.isValidExpression("0 15 25 L-2 * ? 2010")); + assertTrue(CronExpression.isValidExpression("0/5 * * * * ?")); + assertTrue(CronExpression.isValidExpression("0 0 2 * * ?")); + assertTrue(CronExpression.isValidExpression("0 15 8 ? * MON-FRI")); + assertTrue(CronExpression.isValidExpression("0 45 15 1,15 * ? 2005")); + assertTrue(CronExpression.isValidExpression("0 10 * * * ?")); + assertTrue(CronExpression.isValidExpression("0 0 12 L 3,6,9,12 ?")); + assertTrue(CronExpression.isValidExpression("0 0 6 ? DEC,JAN SUN,SAT")); + assertTrue(CronExpression.isValidExpression("0 0 12 1/5 * ?")); + assertTrue(CronExpression.isValidExpression("0 0 8-18 ? * MON,WED,FRI")); + assertTrue(CronExpression.isValidExpression("0 10,44 14 ? 3 WED 2022/2")); + assertTrue(CronExpression.isValidExpression("0 0/30 9-17 * * ? 2022-2025")); + assertTrue(CronExpression.isValidExpression("0 15 10 ? * 6#3 2022,2023")); + assertTrue(CronExpression.isValidExpression("0 10,44 14 ? 3 WED 2022/2")); + assertTrue(CronExpression.isValidExpression("0 0/5 14,18 * * ?")); + assertTrue(CronExpression.isValidExpression("0 15 10 ? * 6#3")); + assertFalse(CronExpression.isValidExpression(" 0 15 10 ? * 6#3 2014-2012")); + assertTrue(CronExpression.isValidExpression("0 0 20-18 ? * MON,WED,FRI")); + assertTrue(CronExpression.isValidExpression("0 0/30 17-9 * 10-9 ? 2022")); + + } + + @Test + public void testLastDayOffset() throws Exception { + CronExpression cronExpression = new CronExpression("0 15 10 L-2 * ? 2010"); + cronExpression.setTimeZone(Calendar.getInstance().getTimeZone()); + + Calendar cal = Calendar.getInstance(); + // last day - 2 + cal.set(2010, Calendar.OCTOBER, 29, 10, 15, 0); + assertTrue(cronExpression.isSatisfiedBy(cal.getTime())); + + cal.set(2010, Calendar.OCTOBER, 28, 10, 15, 0); + assertFalse(cronExpression.isSatisfiedBy(cal.getTime())); + + cronExpression = new CronExpression("0 15 10 L-5W * ? 2010"); + // last day - 5 + cal.set(2010, Calendar.OCTOBER, 26, 10, 15, 0); + assertTrue(cronExpression.isSatisfiedBy(cal.getTime())); + + cronExpression = new CronExpression("0 15 10 L-1 * ? 2010"); + // last day - 1 + cal.set(2010, Calendar.OCTOBER, 30, 10, 15, 0); + assertTrue(cronExpression.isSatisfiedBy(cal.getTime())); + + cronExpression = new CronExpression("0 15 10 L-1W * ? 2010"); + // nearest weekday to last day - 1 (29th is a friday in 2010) + cal.set(2010, Calendar.OCTOBER, 29, 10, 15, 0); + assertTrue(cronExpression.isSatisfiedBy(cal.getTime())); + + cronExpression = new CronExpression("0 15 10 1,L * ? 2010"); + + cal.set(2010, Calendar.OCTOBER, 1, 10, 15, 0); + assertTrue(cronExpression.isSatisfiedBy(cal.getTime())); + + cal.set(2010, Calendar.OCTOBER, 31, 10, 15, 0); + assertTrue(cronExpression.isSatisfiedBy(cal.getTime())); + + cal.set(2010, Calendar.OCTOBER, 30, 10, 15, 0); + assertFalse(cronExpression.isSatisfiedBy(cal.getTime())); + + cronExpression = new CronExpression("0 15 10 L-1W,L-1 * ? 2010"); + // nearest weekday to last day - 1 (29th is a friday in 2010) + cal.set(2010, Calendar.OCTOBER, 29, 10, 15, 0); + assertTrue(cronExpression.isSatisfiedBy(cal.getTime())); + // last day - 1 + cal.set(2010, Calendar.OCTOBER, 30, 10, 15, 0); + + cronExpression = new CronExpression("0 15 10 2W,16 * ? 2010"); + // nearest weekday to the 2nd of the month (1st is a friday in 2010) + cal.set(2010, Calendar.OCTOBER, 1, 10, 15, 0); + assertTrue(cronExpression.isSatisfiedBy(cal.getTime())); + + cal.set(2010, Calendar.OCTOBER, 2, 10, 15, 0); + assertFalse(cronExpression.isSatisfiedBy(cal.getTime())); + + cal.set(2010, Calendar.OCTOBER, 16, 10, 15, 0); + assertTrue(cronExpression.isSatisfiedBy(cal.getTime())); + + } + + @Test + public void testQuartz() throws Exception { + CronExpression cronExpression = new CronExpression("19 15 10 4 Apr ? "); + assertEquals("19 15 10 4 Apr ? ".toUpperCase(), cronExpression.getCronExpression()); + assertEquals("19 15 10 4 Apr ? ".toUpperCase(), cronExpression.toString()); + + // if broken, this will throw an exception + cronExpression.getNextValidTimeAfter(new Date()); + + try { + new CronExpression(null); + fail("Expected ParseException did not fire for null "); + } catch (IllegalArgumentException e) { + assertTrue(e.getMessage().equals("cronExpression cannot be null"), + "Incorrect ParseException thrown"); + } + + try { + new CronExpression("* * * * Foo ? "); + fail("Expected ParseException did not fire for nonexistent month"); + } catch (ParseException pe) { + assertTrue(pe.getMessage().startsWith("Invalid Month value:"), + "Incorrect ParseException thrown"); + } + + try { + new CronExpression("* * * * Jan-Foo ? "); + fail("Expected ParseException did not fire for nonexistent month"); + } catch (ParseException pe) { + assertTrue(pe.getMessage().startsWith("Invalid Month value:"), + "Incorrect ParseException thrown"); + } + + try { + new CronExpression("0 0 * * * *"); + fail("Expected ParseException did not fire for wildcard day-of-month and day-of-week"); + } catch (ParseException pe) { + assertTrue(pe.getMessage().startsWith( + "Support for specifying both a day-of-week AND" + + " a day-of-month parameter is not implemented."), + "Incorrect ParseException thrown"); + } + try { + new CronExpression("0 0 * 4 * *"); + fail("Expected ParseException did not fire for specified day-of-month and" + + " wildcard day-of-week"); + } catch (ParseException pe) { + assertTrue(pe.getMessage().startsWith( + "Support for specifying both a day-of-week AND a day-of-month" + + " parameter is not implemented."), "Incorrect ParseException thrown"); + } + try { + new CronExpression("0 0 * * * 4"); + fail("Expected ParseException did not fire for wildcard day-of-month" + + " and specified day-of-week"); + } catch (ParseException pe) { + assertTrue(pe.getMessage().startsWith( + "Support for specifying both a day-of-week AND a day-of-month" + + " parameter is not implemented."), "Incorrect ParseException thrown"); + } + + try { + new CronExpression("0 43 9 ? * SAT,SUN,L"); + fail("Expected ParseException did not fire for L combined with other days of the week"); + } catch (ParseException pe) { + assertTrue(pe.getMessage().startsWith( + "Support for specifying 'L' with other days of the week is not implemented"), + "Incorrect ParseException thrown"); + } + try { + new CronExpression("0 43 9 ? * 6,7,L"); + fail("Expected ParseException did not fire for L combined with other days of the week"); + } catch (ParseException pe) { + assertTrue(pe.getMessage().startsWith( + "Support for specifying 'L' with other days of the week is not implemented"), + "Incorrect ParseException thrown"); + } + try { + new CronExpression("0 43 9 ? * 5L"); + } catch (ParseException pe) { + fail("Unexpected ParseException thrown for supported '5L' expression."); + } + } + + @Test + public void testQtz96() throws ParseException { + try { + new CronExpression("0/5 * * 32W 1 ?"); + fail("Expected ParseException did not fire for W with value larger than 31"); + } catch (ParseException pe) { + assertTrue(pe.getMessage().startsWith( + "The 'W' option does not make sense with values larger than"), + "Incorrect ParseException thrown"); + } + + // Test case 1 + try { + new CronExpression("/120 0 8-18 ? * 2-6"); + fail("Cron did not validate bad range interval in '_blank/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 60 : 120", e.getMessage()); + } + + // Test case 2 + try { + new CronExpression("0/120 0 8-18 ? * 2-6"); + fail("Cron did not validate bad range interval in in '0/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 60 : 120", e.getMessage()); + } + + // Test case 3 + try { + new CronExpression("/ 0 8-18 ? * 2-6"); + fail("Cron did not validate bad range interval in '_blank/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + + // Test case 4 + try { + new CronExpression("0/ 0 8-18 ? * 2-6"); + fail("Cron did not validate bad range interval in '0/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + + // Test case 1 + try { + new CronExpression("0 /120 8-18 ? * 2-6"); + fail("Cron did not validate bad range interval in '_blank/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 60 : 120", e.getMessage()); + } + + // Test case 2 + try { + new CronExpression("0 0/120 8-18 ? * 2-6"); + fail("Cron did not validate bad range interval in in '0/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 60 : 120", e.getMessage()); + } + + // Test case 3 + try { + new CronExpression("0 / 8-18 ? * 2-6"); + fail("Cron did not validate bad range interval in '_blank/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + + // Test case 4 + try { + new CronExpression("0 0/ 8-18 ? * 2-6"); + fail("Cron did not validate bad range interval in '0/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + + // Test case 1 + try { + new CronExpression("0 0 /120 ? * 2-6"); + fail("Cron did not validate bad range interval in '_blank/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 24 : 120", e.getMessage()); + } + + // Test case 2 + try { + new CronExpression("0 0 0/120 ? * 2-6"); + fail("Cron did not validate bad range interval in in '0/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 24 : 120", e.getMessage()); + } + + // Test case 3 + try { + new CronExpression("0 0 / ? * 2-6"); + fail("Cron did not validate bad range interval in '_blank/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + + // Test case 4 + try { + new CronExpression("0 0 0/ ? * 2-6"); + fail("Cron did not validate bad range interval in '0/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + + // Test case 1 + try { + new CronExpression("0 0 0 /120 * 2-6"); + fail("Cron did not validate bad range interval in '_blank/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 31 : 120", e.getMessage()); + } + + // Test case 2 + try { + new CronExpression("0 0 0 0/120 * 2-6"); + fail("Cron did not validate bad range interval in in '0/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 31 : 120", e.getMessage()); + } + + // Test case 3 + try { + new CronExpression("0 0 0 / * 2-6"); + fail("Cron did not validate bad range interval in '_blank/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + + // Test case 4 + try { + new CronExpression("0 0 0 0/ * 2-6"); + fail("Cron did not validate bad range interval in '0/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + // Test case 1 + try { + new CronExpression("0 0 0 ? /120 2-6"); + fail("Cron did not validate bad range interval in '_blank/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 12 : 120", e.getMessage()); + } + + // Test case 2 + try { + new CronExpression("0 0 0 ? 0/120 2-6"); + fail("Cron did not validate bad range interval in in '0/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 12 : 120", e.getMessage()); + } + + // Test case 3 + try { + new CronExpression("0 0 0 ? / 2-6"); + fail("Cron did not validate bad range interval in '_blank/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + + // Test case 4 + try { + new CronExpression("0 0 0 ? 0/ 2-6"); + fail("Cron did not validate bad range interval in '0/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + // Test case 1 + try { + new CronExpression("0 0 0 ? * /120"); + fail("Cron did not validate bad range interval in '_blank/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 7 : 120", e.getMessage()); + } + + // Test case 2 + try { + new CronExpression("0 0 0 ? * 0/120"); + fail("Cron did not validate bad range interval in in '0/xxx' form"); + } catch (ParseException e) { + assertEquals("Increment > 7 : 120", e.getMessage()); + } + + // Test case 3 + try { + new CronExpression("0 0 0 ? * /"); + fail("Cron did not validate bad range interval in '_blank/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + + // Test case 4 + try { + new CronExpression("0 0 0 ? * 0/"); + fail("Cron did not validate bad range interval in '0/_blank'"); + } catch (ParseException e) { + assertEquals("'/' must be followed by an integer.", e.getMessage()); + } + } + +} diff --git a/framework/src/test/java/org/tron/common/crypto/BouncyCastleTest.java b/framework/src/test/java/org/tron/common/crypto/BouncyCastleTest.java index 880a6623a38..ab6b2832c12 100644 --- a/framework/src/test/java/org/tron/common/crypto/BouncyCastleTest.java +++ b/framework/src/test/java/org/tron/common/crypto/BouncyCastleTest.java @@ -2,6 +2,7 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.tron.common.utils.client.utils.AbiUtil.generateOccupationConstantPrivateKey; import java.math.BigInteger; import java.security.SignatureException; @@ -20,12 +21,13 @@ */ public class BouncyCastleTest { - private String privString = "c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4"; - private BigInteger privateKey = new BigInteger(privString, 16); + // For safety reasons, test with a placeholder private key + private final String privString = generateOccupationConstantPrivateKey(); + private final BigInteger privateKey = new BigInteger(privString, 16); @Test public void testHex() { - String spongyAddress = "cd2a3d9f938e13cd947ec05abc7fe734df8dd826"; + String spongyAddress = "2e988a386a799f506693793c6a5af6b54dfaabfb"; ECKey key = ECKey.fromPrivate(privateKey); byte[] address = key.getAddress(); assertEquals(spongyAddress, @@ -55,10 +57,9 @@ public void testSha3Hash() { @Test public void testECKeyAddress() { - String spongyPubkey = - "040947751e3022ecf3016be03ec77ab0ce3c2662b4843898cb068d74f698ccc8ad75" - + "aa17564ae80a20bb044ee7a6d903e8e8df624b089c95d66a0570f051e5a05b"; - String spongyAddress = "cd2a3d9f938e13cd947ec05abc7fe734df8dd826"; + String spongyPubkey = "04e90c7d3640a1568839c31b70a893ab6714ef8415b9de90cedfc1c8f353a6983e625529" + + "392df7fa514bdd65a2003f6619567d79bee89830e63e932dbd42362d34"; + String spongyAddress = "2e988a386a799f506693793c6a5af6b54dfaabfb"; ECKey key = ECKey.fromPrivate(privateKey); byte[] pubkey = key.getPubKey(); assertEquals(spongyPubkey, Hex.toHexString(pubkey)); @@ -71,7 +72,7 @@ public void testECKeyAddress() { public void testECKeySignature() throws SignatureException { SignInterface sign = SignUtils.fromPrivate(Hex.decode(privString), true); String msg = "transaction raw data"; - String spongyAddress = "cd2a3d9f938e13cd947ec05abc7fe734df8dd826"; + String spongyAddress = "2e988a386a799f506693793c6a5af6b54dfaabfb"; byte[] hash = Sha256Hash.hash(true, msg.getBytes()); String sig = sign.signHash(hash); byte[] address = SignUtils.signatureToAddress(hash, sig, true); @@ -102,9 +103,9 @@ public void testSM3Hash() { @Test public void testSM2Address() { - String spongyPublickey = "04f9539070c135be6183cbff4539f8298755df5981022769cd16cfdcb917fa7e32" - + "4e83b50f0bdbb34acd6ccbb78d45a8a383403f26bbd03805a178c43407dfdeae"; - String spongyAddress = "7dc44d739a5226c0d3037bb7919f653eb2f938b9"; + String spongyPublickey = "04dc3547dbbc4c90a9cde599848e26cb145e805b3d11daaf9daae0680d9c6824058ac" + + "35ddecb12f3a8bbc3104a2b91a2b7d04851d773d9b4ab8d5e0359243c8628"; + String spongyAddress = "6cb22f88564bdd61eb4cdb36215add53bc702ff1"; SM2 key = SM2.fromPrivate(privateKey); assertEquals(spongyPublickey, Hex.toHexString(key.getPubKey())); byte[] address = key.getAddress(); @@ -115,7 +116,7 @@ public void testSM2Address() { public void testSM2Signature() throws SignatureException { SignInterface sign = SignUtils.fromPrivate(Hex.decode(privString), false); String msg = "transaction raw data"; - String spongyAddress = "7dc44d739a5226c0d3037bb7919f653eb2f938b9"; + String spongyAddress = "6cb22f88564bdd61eb4cdb36215add53bc702ff1"; byte[] hash = Sha256Hash.hash(false, msg.getBytes()); String sig = sign.signHash(hash); byte[] address = SignUtils.signatureToAddress(hash, sig, false); diff --git a/framework/src/test/java/org/tron/common/crypto/ECKeyTest.java b/framework/src/test/java/org/tron/common/crypto/ECKeyTest.java index bf268f14320..4e7d45ee8d7 100644 --- a/framework/src/test/java/org/tron/common/crypto/ECKeyTest.java +++ b/framework/src/test/java/org/tron/common/crypto/ECKeyTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.tron.common.utils.client.utils.AbiUtil.generateOccupationConstantPrivateKey; import java.math.BigInteger; import java.security.KeyPairGenerator; @@ -27,16 +28,17 @@ @Slf4j public class ECKeyTest { - private String privString = "c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4"; + // For safety reasons, test with a placeholder private key + private String privString = generateOccupationConstantPrivateKey(); private BigInteger privateKey = new BigInteger(privString, 16); - private String pubString = "040947751e3022ecf3016be03ec77ab0ce3c2662b4843898cb068d74f698ccc" - + "8ad75aa17564ae80a20bb044ee7a6d903e8e8df624b089c95d66a0570f051e5a05b"; + private String pubString = "04e90c7d3640a1568839c31b70a893ab6714ef8415b9de90cedfc1c8f353a6983e62" + + "5529392df7fa514bdd65a2003f6619567d79bee89830e63e932dbd42362d34"; private String compressedPubString = - "030947751e3022ecf3016be03ec77ab0ce3c2662b4843898cb068d74f6" + "98ccc8ad"; + "02e90c7d3640a1568839c31b70a893ab6714ef8415b9de90cedfc1c8f353a6983e"; private byte[] pubKey = Hex.decode(pubString); private byte[] compressedPubKey = Hex.decode(compressedPubString); - private String address = "cd2a3d9f938e13cd947ec05abc7fe734df8dd826"; + private String address = "2e988a386a799f506693793c6a5af6b54dfaabfb"; String eventSign = "eventBytesL(address,bytes,bytes32,uint256,string)"; @Test @@ -46,7 +48,7 @@ public void testSha3() { @Test public void testHashCode() { - assertEquals(-351262686, ECKey.fromPrivate(privateKey).hashCode()); + assertEquals(-827927068, ECKey.fromPrivate(privateKey).hashCode()); } @Test diff --git a/framework/src/test/java/org/tron/common/crypto/SM2KeyTest.java b/framework/src/test/java/org/tron/common/crypto/SM2KeyTest.java index 62e800679c1..b84026d2085 100644 --- a/framework/src/test/java/org/tron/common/crypto/SM2KeyTest.java +++ b/framework/src/test/java/org/tron/common/crypto/SM2KeyTest.java @@ -6,6 +6,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.tron.common.utils.client.utils.AbiUtil.generateOccupationConstantPrivateKey; import java.math.BigInteger; import java.security.KeyPairGenerator; @@ -30,19 +31,20 @@ public class SM2KeyTest { //private String IDa = "ALICE123@YAHOO.COM"; private static BigInteger SM2_N = new BigInteger("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6" + "B21C6052B53BBF40939D54123", 16); - private String privString = "128B2FA8BD433C6C068C8D803DFF79792A519A55171B1B650C23661D15897263"; + // For safety reasons, test with a placeholder private key + private String privString = generateOccupationConstantPrivateKey(); private BigInteger privateKey = new BigInteger(privString, 16); - private String pubString = "04d5548c7825cbb56150a3506cd57464af8a1ae0519dfaf3c58221dc810caf28d" - + "d921073768fe3d59ce54e79a49445cf73fed23086537027264d168946d479533e"; + private String pubString = "04dc3547dbbc4c90a9cde599848e26cb145e805b3d11daaf9daae0680d9c6824058ac" + + "35ddecb12f3a8bbc3104a2b91a2b7d04851d773d9b4ab8d5e0359243c8628"; private String compressedPubString = - "02d5548c7825cbb56150a3506cd57464af8a1ae0519dfaf3c58221dc810caf28dd"; + "02dc3547dbbc4c90a9cde599848e26cb145e805b3d11daaf9daae0680d9c682405"; private byte[] pubKey = Hex.decode(pubString); private byte[] compressedPubKey = Hex.decode(compressedPubString); - private String address = "62e49e4c2f4e3c0653a02f8859c1e6991b759e87"; + private String address = "6cb22f88564bdd61eb4cdb36215add53bc702ff1"; @Test public void testHashCode() { - assertEquals(1126288006, SM2.fromPrivate(privateKey).hashCode()); + assertEquals(578690511, SM2.fromPrivate(privateKey).hashCode()); } @Test @@ -114,7 +116,7 @@ public void testSM3Hash() { SM2Signer signer = key.getSM2SignerForHash(); String message = "message digest"; byte[] hash = signer.generateSM3Hash(message.getBytes()); - assertEquals("299C7DDB0D8DD2A85381BACBB92F738F390210A493A144C78E18C67B430DA882", + assertEquals("2A723761EAE35429DF643648FD69FB7787E7FC32F321BFAF7E294390F529BAF4", Hex.toHexString(hash).toUpperCase()); } diff --git a/framework/src/test/java/org/tron/common/jetty/JettyServerTest.java b/framework/src/test/java/org/tron/common/jetty/JettyServerTest.java new file mode 100644 index 00000000000..fbb2721f502 --- /dev/null +++ b/framework/src/test/java/org/tron/common/jetty/JettyServerTest.java @@ -0,0 +1,64 @@ +package org.tron.common.jetty; + +import java.net.URI; +import lombok.extern.slf4j.Slf4j; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.DefaultHttpClient; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.servlet.DefaultServlet; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.tron.common.utils.PublicMethod; + +@Slf4j +public class JettyServerTest { + private static Server server; + private static URI serverUri; + + @BeforeClass + public static void startJetty() throws Exception { + server = new Server(); + ServerConnector connector = new ServerConnector(server); + connector.setPort(PublicMethod.chooseRandomPort()); + server.addConnector(connector); + + ServletContextHandler context = new ServletContextHandler(); + ServletHolder defaultServ = new ServletHolder("default", DefaultServlet.class); + context.addServlet(defaultServ, "/"); + server.setHandler(context); + server.start(); + String host = connector.getHost(); + if (host == null) { + host = "localhost"; + } + int port = connector.getLocalPort(); + serverUri = new URI(String.format("http://%s:%d/", host, port)); + } + + @AfterClass + public static void stopJetty() { + try { + server.stop(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Test + public void testGet() throws Exception { + HttpClient client = new DefaultHttpClient(); + HttpGet request = new HttpGet(serverUri.resolve("/")); + request.setHeader("Content-Length", "+450"); + HttpResponse mockResponse = client.execute(request); + Assert.assertTrue(mockResponse.getStatusLine().toString().contains( + "400 Invalid Content-Length Value")); + } + +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/DesensitizedConverterTest.java b/framework/src/test/java/org/tron/common/logsfilter/DesensitizedConverterTest.java new file mode 100644 index 00000000000..abdc0eccdfd --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/DesensitizedConverterTest.java @@ -0,0 +1,32 @@ +package org.tron.common.logsfilter; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.junit.Assert; +import org.junit.Test; +import org.tron.common.log.layout.DesensitizedConverter; + +public class DesensitizedConverterTest { + + @Test + public void testReplace() + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + DesensitizedConverter converter = new DesensitizedConverter(); + DesensitizedConverter.addSensitive("192.168.1.10", "address1"); + DesensitizedConverter.addSensitive("197.168.1.10", "address2"); + + Method method = converter.getClass().getDeclaredMethod( + "desensitization", String.class); + method.setAccessible(true); + + String logStr1 = "This is test log /192.168.1.10:100, /197.168.1.10:200, /197.168.1.10:100"; + String result1 = (String) method.invoke(converter, logStr1); + Assert.assertEquals("This is test log /address1:100, /address2:200, /address2:100", + result1); + + String logStr2 = "This is test log /192.168.1.100:100, /197.168.1.10:200, /197.168.1.10:100"; + String result2 = (String) method.invoke(converter, logStr2); + Assert.assertEquals("This is test log /IP:100, /address2:200, /address2:100", + result2); + } +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java b/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java index 8ff8167f52e..1e5268ddeb6 100644 --- a/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java +++ b/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java @@ -1,5 +1,9 @@ package org.tron.common.logsfilter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.List; import org.junit.Assert; @@ -15,18 +19,31 @@ public void launchNativeQueue() { config.setSendQueueLength(1000); config.setBindPort(5555); config.setUseNativeQueue(true); + config.setPluginPath("pluginPath"); + config.setServerAddress("serverAddress"); + config.setDbConfig("dbConfig"); + assertEquals("pluginPath", config.getPluginPath()); + assertEquals("serverAddress", config.getServerAddress()); + assertEquals("dbConfig", config.getDbConfig()); List triggerConfigList = new ArrayList<>(); - TriggerConfig blockTriggerConfig = new TriggerConfig(); - blockTriggerConfig.setTriggerName("block"); - blockTriggerConfig.setEnabled(true); - blockTriggerConfig.setTopic("block"); - triggerConfigList.add(blockTriggerConfig); + TriggerConfig triggerConfig = new TriggerConfig(); + triggerConfig.setTriggerName("block"); + triggerConfig.setEnabled(true); + triggerConfig.setTopic("topic"); + triggerConfig.setRedundancy(false); + triggerConfig.setEthCompatible(false); + triggerConfig.setSolidified(false); + assertFalse(triggerConfig.isRedundancy()); + assertFalse(triggerConfig.isEthCompatible()); + assertFalse(triggerConfig.isSolidified()); + assertEquals("topic", triggerConfig.getTopic()); + triggerConfigList.add(triggerConfig); config.setTriggerConfigList(triggerConfigList); - Assert.assertTrue(EventPluginLoader.getInstance().start(config)); + assertTrue(EventPluginLoader.getInstance().start(config)); EventPluginLoader.getInstance().stopPlugin(); } diff --git a/framework/src/test/java/org/tron/common/logsfilter/FilterQueryTest.java b/framework/src/test/java/org/tron/common/logsfilter/FilterQueryTest.java index 601cf72b294..5ee32d98ee6 100644 --- a/framework/src/test/java/org/tron/common/logsfilter/FilterQueryTest.java +++ b/framework/src/test/java/org/tron/common/logsfilter/FilterQueryTest.java @@ -1,6 +1,13 @@ package org.tron.common.logsfilter; +import static org.apache.commons.lang3.StringUtils.EMPTY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; import static org.tron.common.logsfilter.EventPluginLoader.matchFilter; +import static org.tron.common.logsfilter.FilterQuery.EARLIEST_BLOCK_NUM; +import static org.tron.common.logsfilter.FilterQuery.LATEST_BLOCK_NUM; import static org.tron.common.logsfilter.FilterQuery.parseFromBlockNumber; import static org.tron.common.logsfilter.FilterQuery.parseToBlockNumber; @@ -9,54 +16,57 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import lombok.extern.slf4j.Slf4j; import org.junit.Assert; import org.junit.Test; import org.tron.common.logsfilter.capsule.ContractEventTriggerCapsule; +import org.tron.common.logsfilter.capsule.FilterTriggerCapsule; +import org.tron.common.logsfilter.capsule.TriggerCapsule; import org.tron.common.runtime.LogEventWrapper; import org.tron.protos.contract.SmartContractOuterClass.SmartContract.ABI.Entry; +@Slf4j public class FilterQueryTest { @Test public synchronized void testParseFilterQueryBlockNumber() { - { - String blockNum = ""; - Assert.assertEquals(FilterQuery.LATEST_BLOCK_NUM, parseToBlockNumber(blockNum)); - } + assertEquals(LATEST_BLOCK_NUM, parseToBlockNumber(EMPTY)); + assertEquals(13245, parseToBlockNumber("13245")); - { - String blockNum = "earliest"; - Assert.assertEquals(FilterQuery.EARLIEST_BLOCK_NUM, parseFromBlockNumber(blockNum)); - } + assertEquals(EARLIEST_BLOCK_NUM, parseFromBlockNumber("earliest")); + assertEquals(13245, parseFromBlockNumber("13245")); + assertThrows(Exception.class, () -> parseFromBlockNumber("test")); + assertThrows(Exception.class, () -> parseToBlockNumber("test")); - { - String blockNum = "13245"; - Assert.assertEquals(13245, parseToBlockNumber(blockNum)); - } } @Test public synchronized void testMatchFilter() { - String[] addrList = {"address1", "address2"}; + String[] adrList = {"address1", "address2"}; String[] topList = {"top1", "top2"}; - Map topMap = new HashMap(); + Map topMap = new HashMap<>(); List addressList = new ArrayList<>(); - addressList.add(addrList[0].getBytes()); - addressList.add(addrList[1].getBytes()); + addressList.add(adrList[0].getBytes()); + addressList.add(adrList[1].getBytes()); topMap.put("1", topList[0]); topMap.put("2", topList[1]); LogEventWrapper event = new LogEventWrapper(); - ((LogEventWrapper) event).setTopicList(addressList); - ((LogEventWrapper) event).setData(new byte[]{}); - ((LogEventWrapper) event).setEventSignature(""); - ((LogEventWrapper) event).setAbiEntry(Entry.newBuilder().setName("testABI").build()); - event.setBlockNumber(new Long(123)); + event.setTopicList(addressList); + event.setData(new byte[]{}); + event.setEventSignature(""); + event.setAbiEntry(Entry.newBuilder().setName("testABI").build()); + event.setBlockNumber(123L); ContractEventTriggerCapsule capsule = new ContractEventTriggerCapsule(event); + capsule.setContractEventTrigger(capsule.getContractEventTrigger()); capsule.getContractEventTrigger().setContractAddress("address1"); + capsule.setLatestSolidifiedBlockNumber(0L); + capsule.setData(capsule.getData()); + capsule.setTopicList(capsule.getTopicList()); + capsule.setAbiEntry(capsule.getAbiEntry()); capsule.getContractEventTrigger().setTopicMap(topMap); { - Assert.assertEquals(true, matchFilter(capsule.getContractEventTrigger())); + Assert.assertTrue(matchFilter(capsule.getContractEventTrigger())); } { @@ -64,7 +74,7 @@ public synchronized void testMatchFilter() { filterQuery.setFromBlock(1); filterQuery.setToBlock(100); EventPluginLoader.getInstance().setFilterQuery(filterQuery); - Assert.assertEquals(false, matchFilter(capsule.getContractEventTrigger())); + Assert.assertFalse(matchFilter(capsule.getContractEventTrigger())); } { @@ -72,17 +82,33 @@ public synchronized void testMatchFilter() { filterQuery.setFromBlock(133); filterQuery.setToBlock(190); EventPluginLoader.getInstance().setFilterQuery(filterQuery); - Assert.assertEquals(false, matchFilter(capsule.getContractEventTrigger())); + Assert.assertFalse(matchFilter(capsule.getContractEventTrigger())); } { FilterQuery filterQuery = new FilterQuery(); filterQuery.setFromBlock(100); filterQuery.setToBlock(190); - filterQuery.setContractAddressList(Arrays.asList(addrList)); + filterQuery.setContractAddressList(Arrays.asList(adrList)); filterQuery.setContractTopicList(Arrays.asList(topList)); EventPluginLoader.getInstance().setFilterQuery(filterQuery); - Assert.assertEquals(true, matchFilter(capsule.getContractEventTrigger())); + Assert.assertTrue(matchFilter(capsule.getContractEventTrigger())); + capsule.processTrigger(); + assertNotNull(filterQuery.toString()); + } + + FilterTriggerCapsule filterTriggerCapsule = new FilterTriggerCapsule(); + try { + filterTriggerCapsule.processFilterTrigger(); + } catch (Exception e) { + logger.info(e.getMessage()); + } + + TriggerCapsule triggerCapsule = new TriggerCapsule(); + try { + triggerCapsule.processTrigger(); + } catch (Exception e) { + assertTrue(e instanceof UnsupportedOperationException); } } } diff --git a/framework/src/test/java/org/tron/common/logsfilter/TransactionLogTriggerCapsuleMockTest.java b/framework/src/test/java/org/tron/common/logsfilter/TransactionLogTriggerCapsuleMockTest.java new file mode 100644 index 00000000000..975d41a9051 --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/TransactionLogTriggerCapsuleMockTest.java @@ -0,0 +1,128 @@ +package org.tron.common.logsfilter; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import com.google.protobuf.ByteString; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.logsfilter.capsule.TransactionLogTriggerCapsule; +import org.tron.common.logsfilter.trigger.InternalTransactionPojo; +import org.tron.common.runtime.InternalTransaction; +import org.tron.common.runtime.ProgramResult; +import org.tron.common.runtime.RuntimeImpl; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.capsule.ReceiptCapsule; +import org.tron.core.capsule.TransactionCapsule; +import org.tron.core.db.TransactionTrace; +import org.tron.p2p.utils.ByteArray; +import org.tron.protos.Protocol; +import org.tron.protos.contract.BalanceContract; + + + + +public class TransactionLogTriggerCapsuleMockTest { + + private static final String OWNER_ADDRESS = "41548794500882809695a8a687866e76d4271a1abc"; + private static final String RECEIVER_ADDRESS = "41abd4b9367799eaa3197fecb144eb71de1e049150"; + private static final String CONTRACT_ADDRESS = "A0B4750E2CD76E19DCA331BF5D089B71C3C2798548"; + + private TransactionCapsule transactionCapsule; + private BlockCapsule blockCapsule; + + @Before + public void setup() { + blockCapsule = new BlockCapsule(1, + Sha256Hash.ZERO_HASH, + System.currentTimeMillis(), + Sha256Hash.ZERO_HASH.getByteString() + ); + } + + @After + public void clearMocks() { + + } + + + @Test + public void testConstructorWithTransactionTrace() { + BalanceContract.TransferContract.Builder builder2 = + BalanceContract.TransferContract.newBuilder() + .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))) + .setToAddress(ByteString.copyFrom(ByteArray.fromHexString(RECEIVER_ADDRESS))); + transactionCapsule = spy(new TransactionCapsule(builder2.build(), + Protocol.Transaction.Contract.ContractType.TransferContract)); + + TransactionTrace trace = mock(TransactionTrace.class); + ReceiptCapsule receiptCapsule = new ReceiptCapsule(Sha256Hash.ZERO_HASH); + RuntimeImpl runtime = mock(RuntimeImpl.class); + List logs = new ArrayList<>(); + logs.add(Protocol.TransactionInfo.Log.newBuilder() + .setAddress(ByteString.copyFrom("address".getBytes())) + .setData(ByteString.copyFrom("data".getBytes())) + .addTopics(ByteString.copyFrom("topic".getBytes())) + .build()); + + Protocol.TransactionInfo.Builder builder = Protocol.TransactionInfo.newBuilder() + .addAllLog(logs); + + ProgramResult programResult = ProgramResult.createEmpty(); + programResult.setHReturn("hreturn".getBytes()); + programResult.setContractAddress(CONTRACT_ADDRESS.getBytes()); + + when(transactionCapsule.getTrxTrace()).thenReturn(trace); + when(trace.getReceipt()).thenReturn(receiptCapsule); + when(trace.getRuntime()).thenReturn(runtime); + when(runtime.getResult()).thenReturn(programResult); + + transactionCapsule.setTrxTrace(trace); + + TransactionLogTriggerCapsule triggerCapsule = new TransactionLogTriggerCapsule( + transactionCapsule, blockCapsule,0,0,0, + builder.build(),0); + + Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger()); + } + + @Test + public void testGetInternalTransactionList() throws Exception { + BalanceContract.TransferContract.Builder builder2 = + BalanceContract.TransferContract.newBuilder() + .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))) + .setToAddress(ByteString.copyFrom(ByteArray.fromHexString(RECEIVER_ADDRESS))); + transactionCapsule = new TransactionCapsule(builder2.build(), + Protocol.Transaction.Contract.ContractType.TransferContract); + InternalTransaction internalTransaction = new InternalTransaction( + "parentHash".getBytes(), 10, 0, + "sendAddress".getBytes(), + "transferToAddress".getBytes(), + 100L, "data".getBytes(), "note", + 0L, new HashMap<>() + ); + List internalTransactionList = new ArrayList<>(); + internalTransactionList.add(internalTransaction); + TransactionLogTriggerCapsule triggerCapsule = + new TransactionLogTriggerCapsule(transactionCapsule, blockCapsule); + + Method privateMethod = TransactionLogTriggerCapsule.class.getDeclaredMethod( + "getInternalTransactionList", List.class); + privateMethod.setAccessible(true); + List pojoList = (List) + privateMethod.invoke(triggerCapsule, internalTransactionList); + + Assert.assertNotNull(pojoList); + } + +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/common/logsfilter/TransactionLogTriggerCapsuleTest.java b/framework/src/test/java/org/tron/common/logsfilter/TransactionLogTriggerCapsuleTest.java index 76dd6e99158..ce0f63ef7a4 100644 --- a/framework/src/test/java/org/tron/common/logsfilter/TransactionLogTriggerCapsuleTest.java +++ b/framework/src/test/java/org/tron/common/logsfilter/TransactionLogTriggerCapsuleTest.java @@ -4,22 +4,27 @@ import static org.tron.protos.contract.Common.ResourceCode.BANDWIDTH; import com.google.protobuf.ByteString; +import org.bouncycastle.util.encoders.Hex; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.tron.common.logsfilter.capsule.TransactionLogTriggerCapsule; import org.tron.common.utils.Sha256Hash; +import org.tron.common.utils.StringUtil; import org.tron.core.capsule.BlockCapsule; import org.tron.core.capsule.TransactionCapsule; import org.tron.p2p.utils.ByteArray; import org.tron.protos.Protocol; +import org.tron.protos.contract.AssetIssueContractOuterClass; import org.tron.protos.contract.BalanceContract; import org.tron.protos.contract.Common; +import org.tron.protos.contract.SmartContractOuterClass; public class TransactionLogTriggerCapsuleTest { private static final String OWNER_ADDRESS = "41548794500882809695a8a687866e76d4271a1abc"; private static final String RECEIVER_ADDRESS = "41abd4b9367799eaa3197fecb144eb71de1e049150"; + private static final String CONTRACT_ADDRESS = "A0B4750E2CD76E19DCA331BF5D089B71C3C2798548"; public TransactionCapsule transactionCapsule; public BlockCapsule blockCapsule; @@ -175,4 +180,110 @@ public void testConstructorWithCancelAllUnfreezeTrxCapsule() { triggerCapsule.getTransactionLogTrigger().getExtMap().get(BANDWIDTH.name()).longValue()); } + + @Test + public void testConstructorWithTransferCapsule() { + BalanceContract.TransferContract.Builder builder2 = + BalanceContract.TransferContract.newBuilder() + .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))) + .setToAddress(ByteString.copyFrom(ByteArray.fromHexString(RECEIVER_ADDRESS))); + transactionCapsule = new TransactionCapsule(builder2.build(), + Protocol.Transaction.Contract.ContractType.TransferContract); + + TransactionLogTriggerCapsule triggerCapsule = + new TransactionLogTriggerCapsule(transactionCapsule, blockCapsule); + + Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getFromAddress()); + Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getToAddress()); + } + + @Test + public void testConstructorWithTransferAssetCapsule() { + AssetIssueContractOuterClass.TransferAssetContract.Builder builder2 = + AssetIssueContractOuterClass.TransferAssetContract.newBuilder() + .setAssetName(ByteString.copyFrom("AssetName".getBytes())) + .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))) + .setToAddress(ByteString.copyFrom(ByteArray.fromHexString(RECEIVER_ADDRESS))); + transactionCapsule = new TransactionCapsule(builder2.build(), + Protocol.Transaction.Contract.ContractType.TransferAssetContract); + + TransactionLogTriggerCapsule triggerCapsule = + new TransactionLogTriggerCapsule(transactionCapsule, blockCapsule); + + Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getFromAddress()); + Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getToAddress()); + } + + @Test + public void testConstructorWithTriggerSmartContract() { + SmartContractOuterClass.TriggerSmartContract.Builder builder2 = + SmartContractOuterClass.TriggerSmartContract.newBuilder() + .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))) + .setContractAddress(ByteString.copyFrom(ByteArray.fromHexString(CONTRACT_ADDRESS))); + transactionCapsule = new TransactionCapsule(builder2.build(), + Protocol.Transaction.Contract.ContractType.TriggerSmartContract); + + TransactionLogTriggerCapsule triggerCapsule = + new TransactionLogTriggerCapsule(transactionCapsule, blockCapsule); + + Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getFromAddress()); + Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getToAddress()); + } + + @Test + public void testConstructorWithCreateSmartContract() { + SmartContractOuterClass.CreateSmartContract.Builder builder2 = + SmartContractOuterClass.CreateSmartContract.newBuilder() + .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))); + transactionCapsule = new TransactionCapsule(builder2.build(), + Protocol.Transaction.Contract.ContractType.CreateSmartContract); + + TransactionLogTriggerCapsule triggerCapsule = + new TransactionLogTriggerCapsule(transactionCapsule, blockCapsule); + + Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getFromAddress()); + } + + @Test + public void testConstructorWithCreateTransactionInfo() { + Protocol.TransactionInfo.Builder infoBuild = Protocol.TransactionInfo.newBuilder(); + + Protocol.ResourceReceipt.Builder resourceBuild = Protocol.ResourceReceipt.newBuilder(); + resourceBuild.setEnergyFee(1); + resourceBuild.setEnergyUsageTotal(2); + resourceBuild.setEnergyUsage(3); + resourceBuild.setOriginEnergyUsage(4); + resourceBuild.setNetFee(5); + resourceBuild.setNetUsage(6); + + infoBuild + .setContractAddress(ByteString.copyFrom(ByteArray.fromHexString(CONTRACT_ADDRESS))) + .addContractResult(ByteString.copyFrom(ByteArray.fromHexString("112233"))) + .setReceipt(resourceBuild.build()); + + SmartContractOuterClass.CreateSmartContract.Builder builder2 = + SmartContractOuterClass.CreateSmartContract.newBuilder() + .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))); + TransactionCapsule tc = new TransactionCapsule(builder2.build(), + Protocol.Transaction.Contract.ContractType.CreateSmartContract); + + BlockCapsule bc = new BlockCapsule(1, Sha256Hash.ZERO_HASH, + System.currentTimeMillis(), Sha256Hash.ZERO_HASH.getByteString()); + + + TransactionLogTriggerCapsule trigger = + new TransactionLogTriggerCapsule(tc, bc, infoBuild.build()); + + Assert.assertEquals(1, trigger.getTransactionLogTrigger().getEnergyFee()); + Assert.assertEquals(2, trigger.getTransactionLogTrigger().getEnergyUsageTotal()); + Assert.assertEquals(3, trigger.getTransactionLogTrigger().getEnergyUsage()); + Assert.assertEquals(4, trigger.getTransactionLogTrigger().getOriginEnergyUsage()); + Assert.assertEquals(5, trigger.getTransactionLogTrigger().getNetFee()); + Assert.assertEquals(6, trigger.getTransactionLogTrigger().getNetUsage()); + + Assert.assertEquals(StringUtil.encode58Check(Hex.decode(CONTRACT_ADDRESS)), + trigger.getTransactionLogTrigger().getContractAddress()); + Assert.assertEquals("112233", trigger.getTransactionLogTrigger().getContractResult()); + } + } \ No newline at end of file diff --git a/framework/src/test/java/org/tron/common/logsfilter/capsule/BlockFilterCapsuleTest.java b/framework/src/test/java/org/tron/common/logsfilter/capsule/BlockFilterCapsuleTest.java new file mode 100644 index 00000000000..5381c6ab2de --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/capsule/BlockFilterCapsuleTest.java @@ -0,0 +1,38 @@ +package org.tron.common.logsfilter.capsule; + +import com.google.protobuf.ByteString; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.capsule.BlockCapsule; + +public class BlockFilterCapsuleTest { + + private BlockFilterCapsule blockFilterCapsule; + + @Before + public void setUp() { + BlockCapsule blockCapsule = new BlockCapsule(1, Sha256Hash.ZERO_HASH, + System.currentTimeMillis(), ByteString.EMPTY); + blockFilterCapsule = new BlockFilterCapsule(blockCapsule, false); + } + + @Test + public void testSetAndGetBlockHash() { + blockFilterCapsule + .setBlockHash("e58f33f9baf9305dc6f82b9f1934ea8f0ade2defb951258d50167028c780351f"); + System.out.println(blockFilterCapsule); + Assert.assertEquals("e58f33f9baf9305dc6f82b9f1934ea8f0ade2defb951258d50167028c780351f", + blockFilterCapsule.getBlockHash()); + } + + @Test + public void testSetAndIsSolidified() { + blockFilterCapsule = new BlockFilterCapsule( + "e58f33f9baf9305dc6f82b9f1934ea8f0ade2defb951258d50167028c780351f", false); + blockFilterCapsule.setSolidified(true); + blockFilterCapsule.processFilterTrigger(); + Assert.assertTrue(blockFilterCapsule.isSolidified()); + } +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/capsule/BlockLogTriggerCapsuleTest.java b/framework/src/test/java/org/tron/common/logsfilter/capsule/BlockLogTriggerCapsuleTest.java new file mode 100644 index 00000000000..f77869b8650 --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/capsule/BlockLogTriggerCapsuleTest.java @@ -0,0 +1,35 @@ +package org.tron.common.logsfilter.capsule; + +import com.google.protobuf.ByteString; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.capsule.BlockCapsule; + +public class BlockLogTriggerCapsuleTest { + + private BlockLogTriggerCapsule blockLogTriggerCapsule; + + @Before + public void setUp() { + BlockCapsule blockCapsule = new BlockCapsule(1, Sha256Hash.ZERO_HASH, + System.currentTimeMillis(), ByteString.EMPTY); + blockLogTriggerCapsule = new BlockLogTriggerCapsule(blockCapsule); + } + + @Test + public void testSetAndGetBlockLogTrigger() { + blockLogTriggerCapsule + .setBlockLogTrigger(blockLogTriggerCapsule.getBlockLogTrigger()); + Assert.assertEquals(1, + blockLogTriggerCapsule.getBlockLogTrigger().getBlockNumber()); + } + + @Test + public void testSetLatestSolidifiedBlockNumber() { + blockLogTriggerCapsule.setLatestSolidifiedBlockNumber(100); + Assert.assertEquals(100, + blockLogTriggerCapsule.getBlockLogTrigger().getLatestSolidifiedBlockNumber()); + } +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/capsule/ContractLogTriggerCapsuleTest.java b/framework/src/test/java/org/tron/common/logsfilter/capsule/ContractLogTriggerCapsuleTest.java new file mode 100644 index 00000000000..3d45eb026ea --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/capsule/ContractLogTriggerCapsuleTest.java @@ -0,0 +1,36 @@ +package org.tron.common.logsfilter.capsule; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.tron.common.logsfilter.trigger.Trigger.CONTRACTLOG_TRIGGER_NAME; + +import lombok.extern.slf4j.Slf4j; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.logsfilter.trigger.ContractLogTrigger; + +@Slf4j +public class ContractLogTriggerCapsuleTest { + + private ContractLogTriggerCapsule capsule; + + @Before + public void setUp() { + ContractLogTrigger contractLogTrigger = new ContractLogTrigger(); + contractLogTrigger.setBlockNumber(0L); + capsule = new ContractLogTriggerCapsule(contractLogTrigger); + capsule.setLatestSolidifiedBlockNumber(0); + } + + @Test + public void testSetAndGetContractLogTrigger() { + capsule.setContractLogTrigger(capsule.getContractLogTrigger()); + assertEquals(CONTRACTLOG_TRIGGER_NAME, capsule.getContractLogTrigger().getTriggerName()); + try { + capsule.processTrigger(); + } catch (Exception e) { + assertTrue(e instanceof NullPointerException); + } + } + +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/capsule/ContractTriggerCapsuleTest.java b/framework/src/test/java/org/tron/common/logsfilter/capsule/ContractTriggerCapsuleTest.java new file mode 100644 index 00000000000..898447b3a75 --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/capsule/ContractTriggerCapsuleTest.java @@ -0,0 +1,70 @@ +package org.tron.common.logsfilter.capsule; + +import static com.google.common.collect.Lists.newArrayList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.beust.jcommander.internal.Lists; +import java.util.ArrayList; +import java.util.Arrays; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.logsfilter.trigger.ContractTrigger; +import org.tron.common.runtime.vm.DataWord; +import org.tron.common.runtime.vm.LogInfo; + +@Slf4j +public class ContractTriggerCapsuleTest { + + private ContractTriggerCapsule capsule; + + private LogInfo logInfo; + + @Before + public void setUp() { + ContractTrigger contractTrigger = new ContractTrigger(); + contractTrigger.setBlockNumber(0L); + contractTrigger.setRemoved(false); + logInfo = new LogInfo(bytesToAddress(new byte[] {0x11}), + newArrayList(new DataWord()), new byte[0]); + contractTrigger.setLogInfo(logInfo); + contractTrigger.setRawData(new RawData(null, null, null)); + contractTrigger.setAbi(contractTrigger.getAbi()); + capsule = new ContractTriggerCapsule(contractTrigger); + + } + + private byte[] bytesToAddress(byte[] address) { + byte[] data = new byte[20]; + System.arraycopy(address, 0, data, 20 - address.length, address.length); + return data; + } + + @Test + public void testSetAndGetContractTrigger() { + capsule.setContractTrigger(capsule.getContractTrigger()); + capsule.setBlockHash("e58f33f9baf9305dc6f82b9f1934ea8f0ade2defb951258d50167028c780351f"); + capsule.setLatestSolidifiedBlockNumber(0); + assertEquals(0, capsule.getContractTrigger().getLatestSolidifiedBlockNumber()); + assertEquals("e58f33f9baf9305dc6f82b9f1934ea8f0ade2defb951258d50167028c780351f", + capsule.getContractTrigger().getBlockHash()); + try { + capsule.processTrigger(); + } catch (Exception e) { + assertTrue(e instanceof NullPointerException); + } + } + + @Test + public void testLogInfo() { + logger.info("log info to string: {}, ", logInfo.toString()); + logger.info("log clone data: {}, ", logInfo.getClonedData()); + CollectionUtils.isNotEmpty(logInfo.getClonedTopics()); + CollectionUtils.isNotEmpty(logInfo.getHexTopics()); + new LogInfo(null, null, null); + } + +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/capsule/LogsFilterCapsuleTest.java b/framework/src/test/java/org/tron/common/logsfilter/capsule/LogsFilterCapsuleTest.java new file mode 100644 index 00000000000..691a3106b49 --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/capsule/LogsFilterCapsuleTest.java @@ -0,0 +1,33 @@ +package org.tron.common.logsfilter.capsule; + +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.bloom.Bloom; + +public class LogsFilterCapsuleTest { + + private LogsFilterCapsule capsule; + + @Before + public void setUp() { + capsule = new LogsFilterCapsule(0, + "e58f33f9baf9305dc6f82b9f1934ea8f0ade2defb951258d50167028c780351f", + new Bloom(), new ArrayList<>(), true, false); + } + + @Test + public void testSetAndGetLogsFilterCapsule() { + capsule.setBlockNumber(capsule.getBlockNumber()); + capsule.setBlockHash(capsule.getBlockHash()); + capsule.setSolidified(capsule.isSolidified()); + capsule.setBloom(capsule.getBloom()); + capsule.setRemoved(capsule.isRemoved()); + capsule.setTxInfoList(capsule.getTxInfoList()); + assertNotNull(capsule.toString()); + capsule.processFilterTrigger(); + } + +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/capsule/RawDataTest.java b/framework/src/test/java/org/tron/common/logsfilter/capsule/RawDataTest.java new file mode 100644 index 00000000000..c14afcd903b --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/capsule/RawDataTest.java @@ -0,0 +1,33 @@ +package org.tron.common.logsfilter.capsule; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; +import org.junit.Test; +import org.tron.common.runtime.vm.DataWord; + +public class RawDataTest { + @Test + public void testRawDataConstructor() { + byte[] addressBytes = {0x01, 0x02, 0x03, 0x04}; + byte[] dataBytes = {0x10, 0x20, 0x30, 0x40}; + List topics = Arrays.asList( + new DataWord("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), + new DataWord("0000000000000000000000000000000000000000000000000000000000000001")); + + RawData rawData = new RawData(addressBytes, topics, dataBytes); + + assertEquals("01020304", rawData.getAddress()); + assertEquals(topics, rawData.getTopics()); + assertEquals("10203040", rawData.getData()); + + rawData = new RawData(null, null, null); + assertEquals("", rawData.getAddress()); + assertTrue(rawData.getTopics().isEmpty()); + assertEquals("", rawData.getData()); + assertNotNull(rawData.toString()); + } +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/capsule/SolidityEventCapsuleTest.java b/framework/src/test/java/org/tron/common/logsfilter/capsule/SolidityEventCapsuleTest.java new file mode 100644 index 00000000000..9259ca3ea97 --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/capsule/SolidityEventCapsuleTest.java @@ -0,0 +1,32 @@ +package org.tron.common.logsfilter.capsule; + +import static org.junit.Assert.assertTrue; + +import lombok.extern.slf4j.Slf4j; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.logsfilter.trigger.ContractEventTrigger; + +@Slf4j +public class SolidityEventCapsuleTest { + + private SolidityEventCapsule capsule; + + @Before + public void setUp() { + ContractEventTrigger contractEventTrigger = new ContractEventTrigger(); + capsule = new SolidityEventCapsule(contractEventTrigger); + } + + @Test + public void testSetAndGetSolidityEventCapsule() { + capsule.setSolidityEventTrigger(capsule.getSolidityEventTrigger()); + try { + capsule.processTrigger(); + } catch (Exception e) { + assertTrue(e instanceof NullPointerException); + } + } + +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/capsule/SolidityLogCapsuleTest.java b/framework/src/test/java/org/tron/common/logsfilter/capsule/SolidityLogCapsuleTest.java new file mode 100644 index 00000000000..4e663930530 --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/capsule/SolidityLogCapsuleTest.java @@ -0,0 +1,31 @@ +package org.tron.common.logsfilter.capsule; + +import static org.junit.Assert.assertTrue; + +import lombok.extern.slf4j.Slf4j; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.logsfilter.trigger.ContractLogTrigger; + +@Slf4j +public class SolidityLogCapsuleTest { + + private SolidityLogCapsule capsule; + + @Before + public void setUp() { + ContractLogTrigger trigger = new ContractLogTrigger(); + capsule = new SolidityLogCapsule(trigger); + } + + @Test + public void testSetAndGetSolidityLogCapsule() { + capsule.setSolidityLogTrigger(capsule.getSolidityLogTrigger()); + try { + capsule.processTrigger(); + } catch (Exception e) { + assertTrue(e instanceof NullPointerException); + } + } + +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/capsule/SolidityTriggerCapsuleTest.java b/framework/src/test/java/org/tron/common/logsfilter/capsule/SolidityTriggerCapsuleTest.java new file mode 100644 index 00000000000..849803c1f04 --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/capsule/SolidityTriggerCapsuleTest.java @@ -0,0 +1,37 @@ +package org.tron.common.logsfilter.capsule; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import lombok.extern.slf4j.Slf4j; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.logsfilter.trigger.SolidityTrigger; + +@Slf4j +public class SolidityTriggerCapsuleTest { + + private SolidityTriggerCapsule capsule; + + @Before + public void setUp() { + capsule = new SolidityTriggerCapsule(0); + SolidityTrigger trigger = new SolidityTrigger(); + assertNotNull(trigger.toString()); + capsule.setSolidityTrigger(trigger); + capsule.setTimeStamp(System.currentTimeMillis()); + } + + @Test + public void testSetAndGetSolidityLogCapsule() { + capsule.setSolidityTrigger(capsule.getSolidityTrigger()); + capsule.setTimeStamp(capsule.getSolidityTrigger().getTimeStamp()); + try { + capsule.processTrigger(); + } catch (Exception e) { + assertTrue(e instanceof NullPointerException); + } + } + +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/trigger/ContractLogTriggerTest.java b/framework/src/test/java/org/tron/common/logsfilter/trigger/ContractLogTriggerTest.java new file mode 100644 index 00000000000..8d6e044c134 --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/trigger/ContractLogTriggerTest.java @@ -0,0 +1,82 @@ +package org.tron.common.logsfilter.trigger; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Arrays; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.logsfilter.capsule.RawData; +import org.tron.common.runtime.vm.DataWord; + +public class ContractLogTriggerTest { + private ContractEventTrigger mockEventTrigger; + + @Before + public void setUp() { + mockEventTrigger = new ContractEventTrigger(); + byte[] addressBytes = {0x01, 0x02, 0x03, 0x04}; + byte[] dataBytes = {0x10, 0x20, 0x30, 0x40}; + List topics = Arrays.asList( + new DataWord("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), + new DataWord("0000000000000000000000000000000000000000000000000000000000000001")); + + RawData rawData = new RawData(addressBytes, topics, dataBytes); + mockEventTrigger.setRawData(rawData); + mockEventTrigger.setLatestSolidifiedBlockNumber(12345L); + mockEventTrigger.setRemoved(false); + mockEventTrigger.setUniqueId("unique-id"); + mockEventTrigger.setTransactionId("tx-id"); + mockEventTrigger.setContractAddress("contract-addr"); + mockEventTrigger.setOriginAddress("origin-addr"); + mockEventTrigger.setCreatorAddress("creator-addr"); + mockEventTrigger.setBlockNumber(67890L); + mockEventTrigger.setTimeStamp(1622547200L); + mockEventTrigger.setBlockHash("block-hash"); + } + + @Test + public void testDefaultConstructor() { + ContractLogTrigger trigger = new ContractLogTrigger(); + assertEquals(Trigger.CONTRACTLOG_TRIGGER_NAME, trigger.getTriggerName()); + assertNull(trigger.getTopicList()); + assertNull(trigger.getData()); + } + + @Test + public void testConstructorWithEventTrigger() { + ContractLogTrigger trigger = new ContractLogTrigger(mockEventTrigger); + assertEquals(Trigger.CONTRACTLOG_TRIGGER_NAME, trigger.getTriggerName()); + assertEquals(mockEventTrigger.getRawData(), trigger.getRawData()); + assertEquals(mockEventTrigger.getLatestSolidifiedBlockNumber(), + trigger.getLatestSolidifiedBlockNumber()); + assertEquals(mockEventTrigger.isRemoved(), trigger.isRemoved()); + assertEquals(mockEventTrigger.getUniqueId(), trigger.getUniqueId()); + assertEquals(mockEventTrigger.getTransactionId(), trigger.getTransactionId()); + assertEquals(mockEventTrigger.getContractAddress(), trigger.getContractAddress()); + assertEquals(mockEventTrigger.getOriginAddress(), trigger.getOriginAddress()); + assertEquals("", trigger.getCallerAddress()); // Explicitly set to empty string + assertEquals(mockEventTrigger.getCreatorAddress(), trigger.getCreatorAddress()); + assertEquals(mockEventTrigger.getBlockNumber(), trigger.getBlockNumber()); + assertEquals(mockEventTrigger.getTimeStamp(), trigger.getTimeStamp()); + assertEquals(mockEventTrigger.getBlockHash(), trigger.getBlockHash()); + } + + @Test + public void testSetAndGetTopicList() { + ContractLogTrigger trigger = new ContractLogTrigger(); + List topics = Arrays.asList("topic1", "topic2"); + trigger.setTopicList(topics); + assertEquals(topics, trigger.getTopicList()); + } + + @Test + public void testSetAndGetData() { + ContractLogTrigger trigger = new ContractLogTrigger(); + String testData = "log data"; + trigger.setData(testData); + assertEquals(testData, trigger.getData()); + } + +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/trigger/InternalTransactionPojoTest.java b/framework/src/test/java/org/tron/common/logsfilter/trigger/InternalTransactionPojoTest.java new file mode 100644 index 00000000000..9948c5535af --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/trigger/InternalTransactionPojoTest.java @@ -0,0 +1,87 @@ +package org.tron.common.logsfilter.trigger; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; +import org.junit.Before; +import org.junit.Test; + +public class InternalTransactionPojoTest { + private InternalTransactionPojo internalTransactionPojo; + + @Before + public void setUp() { + internalTransactionPojo = new InternalTransactionPojo(); + } + + @Test + public void testHash() { + String testHash = "0x123456789abcdef0123456789abcdef0"; + internalTransactionPojo.setHash(testHash); + assertEquals(testHash, internalTransactionPojo.getHash()); + } + + @Test + public void testCallValue() { + long testCallValue = 123456789L; + internalTransactionPojo.setCallValue(testCallValue); + assertEquals(testCallValue, internalTransactionPojo.getCallValue()); + } + + @Test + public void testTokenInfo() { + Map testTokenInfo = new HashMap<>(); + testTokenInfo.put("token1", 100L); + testTokenInfo.put("token2", 200L); + internalTransactionPojo.setTokenInfo(testTokenInfo); + assertEquals(testTokenInfo, internalTransactionPojo.getTokenInfo()); + } + + @Test + public void testTransferToAddress() { + String testAddress = "0x0000000000000000000000000000000000000001"; + internalTransactionPojo.setTransferTo_address(testAddress); + assertEquals(testAddress, internalTransactionPojo.getTransferTo_address()); + } + + @Test + public void testData() { + String testData = "0x6060604052341561000f57600080fd5b5b6040516020806101158339810160405280805" + + "19060200190929190505050"; + internalTransactionPojo.setData(testData); + assertEquals(testData, internalTransactionPojo.getData()); + } + + @Test + public void testCallerAddress() { + String testCallerAddress = "0x0000000000000000000000000000000000000002"; + internalTransactionPojo.setCaller_address(testCallerAddress); + assertEquals(testCallerAddress, internalTransactionPojo.getCaller_address()); + } + + @Test + public void testRejected() { + internalTransactionPojo.setRejected(true); + assertTrue(internalTransactionPojo.isRejected()); + + internalTransactionPojo.setRejected(false); + assertFalse(internalTransactionPojo.isRejected()); + } + + @Test + public void testNote() { + String testNote = "This is a test note"; + internalTransactionPojo.setNote(testNote); + assertEquals(testNote, internalTransactionPojo.getNote()); + } + + @Test + public void testExtra() { + String testExtra = "extra_data_for_vote_witness"; + internalTransactionPojo.setExtra(testExtra); + assertEquals(testExtra, internalTransactionPojo.getExtra()); + } +} diff --git a/framework/src/test/java/org/tron/common/logsfilter/trigger/LogPojoTest.java b/framework/src/test/java/org/tron/common/logsfilter/trigger/LogPojoTest.java new file mode 100644 index 00000000000..7c94ec4f7ad --- /dev/null +++ b/framework/src/test/java/org/tron/common/logsfilter/trigger/LogPojoTest.java @@ -0,0 +1,74 @@ +package org.tron.common.logsfilter.trigger; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.List; +import org.junit.Before; +import org.junit.Test; + +public class LogPojoTest { + + private LogPojo logPojo; + + @Before + public void setUp() { + logPojo = new LogPojo(); + } + + @Test + public void testAddress() { + String testAddress = "123 Test Address"; + logPojo.setAddress(testAddress); + assertEquals(testAddress, logPojo.getAddress()); + } + + @Test + public void testBlockHash() { + String testBlockHash = "abcdef1234567890abcdef1234567890abcdef12"; + logPojo.setBlockHash(testBlockHash); + assertEquals(testBlockHash, logPojo.getBlockHash()); + } + + @Test + public void testBlockNumber() { + long testBlockNumber = 1234567L; + logPojo.setBlockNumber(testBlockNumber); + assertEquals(testBlockNumber, logPojo.getBlockNumber()); + } + + @Test + public void testData() { + String testData = "Some data here"; + logPojo.setData(testData); + assertEquals(testData, logPojo.getData()); + } + + @Test + public void testLogIndex() { + long testLogIndex = 5L; + logPojo.setLogIndex(testLogIndex); + assertEquals(testLogIndex, logPojo.getLogIndex()); + } + + @Test + public void testTopicList() { + List testTopicList = Arrays.asList("topic1", "topic2", "topic3"); + logPojo.setTopicList(testTopicList); + assertEquals(testTopicList, logPojo.getTopicList()); + } + + @Test + public void testTransactionHash() { + String testTransactionHash = "abcdef1234567890abcdef1234567890abcdef12"; + logPojo.setTransactionHash(testTransactionHash); + assertEquals(testTransactionHash, logPojo.getTransactionHash()); + } + + @Test + public void testTransactionIndex() { + long testTransactionIndex = 3L; + logPojo.setTransactionIndex(testTransactionIndex); + assertEquals(testTransactionIndex, logPojo.getTransactionIndex()); + } +} diff --git a/framework/src/test/java/org/tron/common/runtime/RuntimeImplMockTest.java b/framework/src/test/java/org/tron/common/runtime/RuntimeImplMockTest.java new file mode 100644 index 00000000000..e694f1c194f --- /dev/null +++ b/framework/src/test/java/org/tron/common/runtime/RuntimeImplMockTest.java @@ -0,0 +1,53 @@ +package org.tron.common.runtime; + +import java.lang.reflect.Method; + +import lombok.extern.slf4j.Slf4j; +import org.junit.After; +import org.junit.Test; +import org.tron.core.vm.program.Program; + + + +@Slf4j +public class RuntimeImplMockTest { + @After + public void clearMocks() { + + } + + @Test + public void testSetResultCode1() throws Exception { + RuntimeImpl runtime = new RuntimeImpl(); + ProgramResult programResult = new ProgramResult(); + Method privateMethod = RuntimeImpl.class.getDeclaredMethod( + "setResultCode", ProgramResult.class); + privateMethod.setAccessible(true); + + Program.BadJumpDestinationException badJumpDestinationException + = new Program.BadJumpDestinationException("Operation with pc isn't 'JUMPDEST': PC[%d];", 0); + programResult.setException(badJumpDestinationException); + privateMethod.invoke(runtime, programResult); + + Program.OutOfTimeException outOfTimeException + = new Program.OutOfTimeException("CPU timeout for 0x0a executing"); + programResult.setException(outOfTimeException); + privateMethod.invoke(runtime, programResult); + + Program.PrecompiledContractException precompiledContractException + = new Program.PrecompiledContractException("precompiled contract exception"); + programResult.setException(precompiledContractException); + privateMethod.invoke(runtime, programResult); + + Program.StackTooSmallException stackTooSmallException + = new Program.StackTooSmallException("Expected stack size %d but actual %d;", 100, 10); + programResult.setException(stackTooSmallException); + privateMethod.invoke(runtime, programResult); + + Program.JVMStackOverFlowException jvmStackOverFlowException + = new Program.JVMStackOverFlowException(); + programResult.setException(jvmStackOverFlowException); + privateMethod.invoke(runtime, programResult); + } + +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java index afac8cd7d22..582f5157b27 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java @@ -33,6 +33,7 @@ import org.tron.core.exception.AccountResourceInsufficientException; import org.tron.core.exception.ContractExeException; import org.tron.core.exception.ContractValidateException; +import org.tron.core.exception.TooBigTransactionException; import org.tron.core.exception.TooBigTransactionResultException; import org.tron.core.exception.TronException; import org.tron.core.exception.VMIllegalException; @@ -72,7 +73,6 @@ public class BandWidthRuntimeOutOfTimeTest extends BaseTest { "--output-directory", dbPath(), "--storage-db-directory", dbDirectory, "--storage-index-directory", indexDirectory, - "-w", "--debug" }, "config-test-mainnet.conf" @@ -154,7 +154,8 @@ public void testSuccess() { private byte[] createContract() throws ContractValidateException, AccountResourceInsufficientException, - TooBigTransactionResultException, ContractExeException, VMIllegalException { + TooBigTransactionResultException, ContractExeException, VMIllegalException, + TooBigTransactionException { AccountCapsule owner = dbManager.getAccountStore() .get(Commons.decodeFromBase58Check(OwnerAddress)); long energy = owner.getEnergyUsage(); diff --git a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java index 7203388f815..7e75f2b31d1 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java @@ -34,6 +34,7 @@ import org.tron.core.exception.ContractExeException; import org.tron.core.exception.ContractValidateException; import org.tron.core.exception.ReceiptCheckErrException; +import org.tron.core.exception.TooBigTransactionException; import org.tron.core.exception.TooBigTransactionResultException; import org.tron.core.exception.TronException; import org.tron.core.exception.VMIllegalException; @@ -73,7 +74,6 @@ public class BandWidthRuntimeOutOfTimeWithCheckTest extends BaseTest { "--output-directory", dbPath(), "--storage-db-directory", dbDirectory, "--storage-index-directory", indexDirectory, - "-w", "--debug" }, "config-test-mainnet.conf" @@ -156,7 +156,8 @@ public void testSuccess() { private byte[] createContract() throws ContractValidateException, AccountResourceInsufficientException, - TooBigTransactionResultException, ContractExeException, VMIllegalException { + TooBigTransactionResultException, ContractExeException, VMIllegalException, + TooBigTransactionException { AccountCapsule owner = dbManager.getAccountStore() .get(Commons.decodeFromBase58Check(OwnerAddress)); long energy = owner.getEnergyUsage(); diff --git a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java index 40c5908c2dd..40a4003f625 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java @@ -15,6 +15,8 @@ package org.tron.common.runtime.vm; +import static org.tron.common.math.Maths.max; + import com.google.protobuf.Any; import com.google.protobuf.ByteString; import org.junit.Assert; @@ -35,6 +37,7 @@ import org.tron.core.exception.AccountResourceInsufficientException; import org.tron.core.exception.ContractExeException; import org.tron.core.exception.ContractValidateException; +import org.tron.core.exception.TooBigTransactionException; import org.tron.core.exception.TooBigTransactionResultException; import org.tron.core.exception.TronException; import org.tron.core.exception.VMIllegalException; @@ -43,6 +46,8 @@ import org.tron.protos.Protocol.Transaction; import org.tron.protos.Protocol.Transaction.Contract; import org.tron.protos.Protocol.Transaction.Contract.ContractType; +import org.tron.protos.Protocol.Transaction.Result; +import org.tron.protos.Protocol.Transaction.Result.contractResult; import org.tron.protos.Protocol.Transaction.raw; import org.tron.protos.contract.SmartContractOuterClass.CreateSmartContract; import org.tron.protos.contract.SmartContractOuterClass.TriggerSmartContract; @@ -64,7 +69,6 @@ public static void init() { "--output-directory", dbPath(), "--storage-db-directory", dbDirectory, "--storage-index-directory", indexDirectory, - "-w" }, "config-test-mainnet.conf" ); @@ -186,7 +190,8 @@ public void testSuccessNoBandd() { private byte[] createContract() throws ContractValidateException, AccountResourceInsufficientException, - TooBigTransactionResultException, ContractExeException, VMIllegalException { + TooBigTransactionResultException, ContractExeException, VMIllegalException, + TooBigTransactionException { AccountCapsule owner = dbManager.getAccountStore() .get(Commons.decodeFromBase58Check(OwnerAddress)); long energy = owner.getEnergyUsage(); @@ -235,4 +240,18 @@ private byte[] createContract() Assert.assertNull(trace.getRuntimeError()); return trace.getRuntimeResult().getContractAddress(); } + + @Test + public void testMaxContractResultSize() { + int maxSize = 0; + for (contractResult cr : contractResult.values()) { + if (cr.name().equals("UNRECOGNIZED")) { + continue; + } + Result result = Result.newBuilder().setContractRet(cr).build(); + maxSize = max(maxSize, result.getSerializedSize(), + dbManager.getDynamicPropertiesStore().disableJavaLangMath()); + } + Assert.assertEquals(2, maxSize); + } } \ No newline at end of file diff --git a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java index e359e7eab1a..aae8cb5702d 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java @@ -34,6 +34,7 @@ import org.tron.core.exception.ContractExeException; import org.tron.core.exception.ContractValidateException; import org.tron.core.exception.ReceiptCheckErrException; +import org.tron.core.exception.TooBigTransactionException; import org.tron.core.exception.TooBigTransactionResultException; import org.tron.core.exception.TronException; import org.tron.core.exception.VMIllegalException; @@ -75,7 +76,6 @@ public class BandWidthRuntimeWithCheckTest extends BaseTest { "--output-directory", dbPath(), "--storage-db-directory", dbDirectory, "--storage-index-directory", indexDirectory, - "-w" }, "config-test-mainnet.conf" ); @@ -198,7 +198,7 @@ public void testSuccessNoBandWidth() { private byte[] createContract() throws ContractValidateException, AccountResourceInsufficientException, TooBigTransactionResultException, ContractExeException, ReceiptCheckErrException, - VMIllegalException { + VMIllegalException, TooBigTransactionException { AccountCapsule owner = dbManager.getAccountStore() .get(Commons.decodeFromBase58Check(OwnerAddress)); long energy = owner.getEnergyUsage(); diff --git a/framework/src/test/java/org/tron/common/runtime/vm/BatchSendTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BatchSendTest.java index 5ada5612fce..cf67ae4b087 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/BatchSendTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/BatchSendTest.java @@ -93,6 +93,7 @@ public void TransferTokenTest() ECKey ecKey3 = new ECKey(Utils.getRandom()); List params = new ArrayList<>(); + logger.info("show db key: {}", StringUtil.createDbKey(ByteString.copyFrom("test".getBytes()))); params.add(StringUtil.encode58Check(ecKey1.getAddress())); params.add(StringUtil.encode58Check(ecKey2.getAddress())); params.add(StringUtil.encode58Check(ecKey3.getAddress())); diff --git a/framework/src/test/java/org/tron/common/runtime/vm/BatchValidateSignContractTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BatchValidateSignContractTest.java index d094f1a3d05..fc60d8c0648 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/BatchValidateSignContractTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/BatchValidateSignContractTest.java @@ -79,7 +79,6 @@ public void staticCallTest() { @Test public void correctionTest() { - contract.setConstantCall(false); List signatures = new ArrayList<>(); List addresses = new ArrayList<>(); byte[] hash = Hash.sha3(longData); @@ -128,7 +127,8 @@ Pair validateMultiSign(byte[] hash, List signatures, List parameters = Arrays.asList("0x" + Hex.toHexString(hash), signatures, addresses); byte[] input = Hex.decode(AbiUtil.parseParameters(METHOD_SIGN, parameters)); contract.getEnergyForData(input); - contract.setVmShouldEndInUs(System.nanoTime() / 1000 + 500 * 1000); + long maxExecutionTime = 2000; // ms + contract.setVmShouldEndInUs(System.nanoTime() / 1000 + maxExecutionTime * 1000); Pair ret = contract.execute(input); logger.info("BytesArray:{},HexString:{}", Arrays.toString(ret.getValue()), Hex.toHexString(ret.getValue())); diff --git a/framework/src/test/java/org/tron/common/runtime/vm/Create2Test.java b/framework/src/test/java/org/tron/common/runtime/vm/Create2Test.java index 79ed1c7e1f8..f400b3215ee 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/Create2Test.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/Create2Test.java @@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; import org.bouncycastle.util.encoders.Hex; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.tron.common.runtime.TVMTestResult; import org.tron.common.runtime.TvmTestUtils; @@ -23,6 +24,7 @@ import org.tron.core.exception.VMIllegalException; import org.tron.core.services.NodeInfoService; import org.tron.core.services.jsonrpc.TronJsonRpcImpl; +import org.tron.core.vm.config.ConfigLoader; import org.tron.protos.Protocol.Transaction; @@ -103,6 +105,11 @@ triggercontract Txxxxxxxxxxx deploy(bytes,uint256) bytes,uint256 false 100000000 */ + @Before + public void before() { + ConfigLoader.disable = false; + } + @Test public void testCreate2() throws ContractExeException, ReceiptCheckErrException, @@ -160,9 +167,16 @@ public void testCreate2() // Trigger contract method: deploy(bytes,uint) long salt = 100L; String hexInput = AbiUtil.parseMethod(methodSign, Arrays.asList(testCode, salt)); + + long preTime = manager.getDynamicPropertiesStore().getMaxCpuTimeOfOneTx(); + // set max cpu time to 500 + manager.getDynamicPropertiesStore().saveMaxCpuTimeOfOneTx(500L); TVMTestResult result = TvmTestUtils .triggerContractAndReturnTvmTestResult(Hex.decode(OWNER_ADDRESS), factoryAddress, Hex.decode(hexInput), 0, fee, manager, null); + // restore max cpu time + manager.getDynamicPropertiesStore().saveMaxCpuTimeOfOneTx(preTime); + Assert.assertNull(result.getRuntime().getRuntimeError()); byte[] returnValue = result.getRuntime().getResult().getHReturn(); diff --git a/framework/src/test/java/org/tron/common/runtime/vm/DataWordTest.java b/framework/src/test/java/org/tron/common/runtime/vm/DataWordTest.java index 8da6e4c96ea..172e3f17f1b 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/DataWordTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/DataWordTest.java @@ -18,14 +18,22 @@ package org.tron.common.runtime.vm; +import static org.apache.commons.lang3.ArrayUtils.isNotEmpty; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; +import static org.tron.common.runtime.vm.DataWord.isZero; import java.math.BigInteger; import java.util.Arrays; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ArrayUtils; import org.bouncycastle.util.encoders.Hex; +import org.eclipse.jetty.util.ArrayUtil; import org.junit.Test; +import org.tron.core.db.ByteArrayWrapper; @Slf4j public class DataWordTest { @@ -70,16 +78,16 @@ public void testAddPerformance() { DataWord x = new DataWord(one); x.add(x); } - System.out.println("Add1: " + (System.currentTimeMillis() - now1) + "ms"); + logger.info("Add1: " + (System.currentTimeMillis() - now1) + "ms"); long now2 = System.currentTimeMillis(); for (int i = 0; i < ITERATIONS; i++) { DataWord x = new DataWord(one); x.add2(x); } - System.out.println("Add2: " + (System.currentTimeMillis() - now2) + "ms"); + logger.info("Add2: " + (System.currentTimeMillis() - now2) + "ms"); } else { - System.out.println("ADD performance test is disabled."); + logger.info("ADD performance test is disabled."); } } @@ -90,11 +98,11 @@ public void testAdd2() { DataWord x = new DataWord(two); x.add(new DataWord(two)); - System.out.println(Hex.toHexString(x.getData())); + logger.info(Hex.toHexString(x.getData())); DataWord y = new DataWord(two); y.add2(new DataWord(two)); - System.out.println(Hex.toHexString(y.getData())); + logger.info(Hex.toHexString(y.getData())); } @Test @@ -107,12 +115,12 @@ public void testAdd3() { DataWord x = new DataWord(three); x.add(new DataWord(three)); assertEquals(32, x.getData().length); - System.out.println(Hex.toHexString(x.getData())); + logger.info(Hex.toHexString(x.getData())); // FAIL // DataWord y = new DataWord(three); // y.add2(new DataWord(three)); - // System.out.println(Hex.toHexString(y.getData())); + // logger.info(Hex.toHexString(y.getData())); } @Test @@ -128,8 +136,8 @@ public void testMod() { } two[31] = 0x56; // 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff56 - DataWord x = new DataWord(one);// System.out.println(x.value()); - DataWord y = new DataWord(two);// System.out.println(y.value()); + DataWord x = new DataWord(one);// logger.info(x.value()); + DataWord y = new DataWord(two);// logger.info(y.value()); y.mod(x); assertEquals(32, y.getData().length); assertEquals(expected, Hex.toHexString(y.getData())); @@ -143,8 +151,8 @@ public void testMul() { byte[] two = new byte[32]; two[11] = 0x1; // 0x0000000000000000000000010000000000000000000000000000000000000000 - DataWord x = new DataWord(one);// System.out.println(x.value()); - DataWord y = new DataWord(two);// System.out.println(y.value()); + DataWord x = new DataWord(one);// logger.info(x.value()); + DataWord y = new DataWord(two);// logger.info(y.value()); x.mul(y); assertEquals(32, y.getData().length); assertEquals("0000000000000000000000010000000000000000000000000000000000000000", @@ -160,8 +168,8 @@ public void testMulOverflow() { byte[] two = new byte[32]; two[0] = 0x1; // 0x1000000000000000000000000000000000000000000000000000000000000000 - DataWord x = new DataWord(one);// System.out.println(x.value()); - DataWord y = new DataWord(two);// System.out.println(y.value()); + DataWord x = new DataWord(one);// logger.info(x.value()); + DataWord y = new DataWord(two);// logger.info(y.value()); x.mul(y); assertEquals(32, y.getData().length); assertEquals("0100000000000000000000000000000000000000000000000000000000000000", @@ -226,8 +234,8 @@ public void testPow() { BigInteger result1 = x.modPow(x, y); BigInteger result2 = pow(x, y); - System.out.println(result1); - System.out.println(result2); + logger.info(result1.toString()); + logger.info(result2.toString()); } @Test @@ -238,7 +246,7 @@ public void testSignExtend1() { String expected = "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2"; x.signExtend(k); - System.out.println(x.toString()); + logger.info(x.toString()); assertEquals(expected, x.toString()); } @@ -249,7 +257,7 @@ public void testSignExtend2() { String expected = "00000000000000000000000000000000000000000000000000000000000000f2"; x.signExtend(k); - System.out.println(x.toString()); + logger.info(x.toString()); assertEquals(expected, x.toString()); } @@ -261,7 +269,7 @@ public void testSignExtend3() { String expected = "00000000000000000000000000000000000000000000000000000000000000ab"; x.signExtend(k); - System.out.println(x.toString()); + logger.info(x.toString()); assertEquals(expected, x.toString()); } @@ -273,7 +281,7 @@ public void testSignExtend4() { String expected = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; x.signExtend(k); - System.out.println(x.toString()); + logger.info(x.toString()); assertEquals(expected, x.toString()); } @@ -285,7 +293,7 @@ public void testSignExtend5() { String expected = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; x.signExtend(k); - System.out.println(x.toString()); + logger.info(x.toString()); assertEquals(expected, x.toString()); } @@ -297,7 +305,7 @@ public void testSignExtend6() { String expected = "0000000000000000000000000000000000000000000000000000000002345678"; x.signExtend(k); - System.out.println(x.toString()); + logger.info(x.toString()); assertEquals(expected, x.toString()); } @@ -309,7 +317,7 @@ public void testSignExtend7() { String expected = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff82345678"; x.signExtend(k); - System.out.println(x.toString()); + logger.info(x.toString()); assertEquals(expected, x.toString()); } @@ -322,7 +330,7 @@ public void testSignExtend8() { String expected = "0034567882345678823456788234567882345678823456788234567882345678"; x.signExtend(k); - System.out.println(x.toString()); + logger.info(x.toString()); assertEquals(expected, x.toString()); } @@ -576,9 +584,39 @@ private void testShiftRightSigned(String[][] cases) { DataWord arg = new DataWord(c[1]); DataWord expected = new DataWord(c[2]); DataWord actual = value.shiftRightSigned(arg); - assertEquals(i + " " + Arrays.asList(c).toString(), expected, actual); + assertEquals(i + " " + Arrays.asList(c), expected, actual); } } + @Test + public void testIsZero() { + DataWord dataWord = new DataWord(new byte[0]); + DataWord d = new DataWord(new ByteArrayWrapper(new byte[0])); + assertTrue(d.isZero()); + d.negate(); + assertThrows(IllegalArgumentException.class, () -> new ByteArrayWrapper(null)); + assertTrue(dataWord.isZero()); + assertTrue(isZero(new byte[0])); + assertFalse(isZero(new byte[]{1})); + DataWord dataWord1 = new DataWord(new byte[]{0, 1}); + assertFalse(dataWord1.isZero()); + assertTrue(isNotEmpty(new DataWord((byte[]) null).getClonedData())); + assertTrue(isNotEmpty(dataWord1.getClonedData())); + logger.info(dataWord.toPrefixString()); + logger.info(dataWord1.toPrefixString()); + logger.info(new DataWord((new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8})).toPrefixString()); + logger.info(dataWord.shortHex()); + logger.info(DataWord.shortHex(new byte[0])); + logger.info(DataWord.bigIntValue(new byte[]{1})); + logger.info(dataWord.bigIntValue()); + logger.info("dataWord is Hex: {}", dataWord.isHex("test")); + logger.info(dataWord.asString()); + logger.info(Arrays.toString(dataWord.getNoEndZeroesData())); + DataWord tmp = dataWord; + assertEquals(dataWord, tmp); + assertNotEquals(dataWord, null); + assertEquals(-1, dataWord.compareTo(null)); + } + } diff --git a/framework/src/test/java/org/tron/common/runtime/vm/FreezeV2Test.java b/framework/src/test/java/org/tron/common/runtime/vm/FreezeV2Test.java index 9558c701109..907398f163b 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/FreezeV2Test.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/FreezeV2Test.java @@ -1,5 +1,6 @@ package org.tron.common.runtime.vm; +import static org.tron.common.math.Maths.min; import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCED_INTERVAL; import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION; import static org.tron.core.config.Parameter.ChainConstant.WINDOW_SIZE_MS; @@ -22,6 +23,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.tron.common.application.TronApplicationContext; +import org.tron.common.parameter.CommonParameter; import org.tron.common.runtime.Runtime; import org.tron.common.runtime.RuntimeImpl; import org.tron.common.runtime.TVMTestResult; @@ -274,6 +276,7 @@ private TVMTestResult triggerWithdrawExpireUnfreeze( private TVMTestResult triggerCancelAllUnfreezeV2( byte[] callerAddr, byte[] contractAddr, contractResult expectedResult, Consumer check) throws Exception { + CommonParameter.getInstance().saveCancelAllUnfreezeV2Details = true; return triggerContract( callerAddr, contractAddr, fee, expectedResult, check, "cancelAllUnfreezeBalanceV2()"); } @@ -856,7 +859,8 @@ private TVMTestResult unDelegateResource( transferUsage = (long) (oldReceiver.getEnergyUsage() * ((double) (amount) / oldReceiver.getAllFrozenBalanceForEnergy())); } - transferUsage = Math.min(unDelegateMaxUsage, transferUsage); + transferUsage = min(unDelegateMaxUsage, transferUsage, + manager.getDynamicPropertiesStore().disableJavaLangMath()); } DelegatedResourceStore delegatedResourceStore = manager.getDelegatedResourceStore(); diff --git a/framework/src/test/java/org/tron/common/runtime/vm/MemoryTest.java b/framework/src/test/java/org/tron/common/runtime/vm/MemoryTest.java index b6e9cfe109c..dbbf6921567 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/MemoryTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/MemoryTest.java @@ -18,9 +18,9 @@ package org.tron.common.runtime.vm; -import static java.lang.Math.ceil; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; +import static org.tron.common.math.Maths.ceil; import java.util.Arrays; import lombok.extern.slf4j.Slf4j; @@ -43,7 +43,7 @@ private static void checkMemoryExtend(int dataSize) { } private static int calcSize(int dataSize, int chunkSize) { - return (int) ceil((double) dataSize / chunkSize) * chunkSize; + return (int) ceil((double) dataSize / chunkSize, true) * chunkSize; } @Test diff --git a/framework/src/test/java/org/tron/common/runtime/vm/OperationsTest.java b/framework/src/test/java/org/tron/common/runtime/vm/OperationsTest.java index be031d7c00b..3315005b7d2 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/OperationsTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/OperationsTest.java @@ -3,6 +3,8 @@ import static org.junit.Assert.assertEquals; import java.util.List; +import java.util.Random; + import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.bouncycastle.util.encoders.Hex; @@ -15,6 +17,7 @@ import org.tron.common.BaseTest; import org.tron.common.parameter.CommonParameter; import org.tron.common.runtime.InternalTransaction; +import org.tron.common.utils.DecodeUtil; import org.tron.core.Constant; import org.tron.core.config.args.Args; import org.tron.core.exception.ContractValidateException; @@ -864,6 +867,186 @@ public void testPush0() throws ContractValidateException { VMConfig.initAllowTvmShangHai(0); } + @Test + public void testSuicideCost() throws ContractValidateException { + invoke = new ProgramInvokeMockImpl(StoreFactory.getInstance(), new byte[0], new byte[21]); + program = new Program(null, null, invoke, + new InternalTransaction( + Protocol.Transaction.getDefaultInstance(), + InternalTransaction.TrxType.TRX_UNKNOWN_TYPE)); + + byte[] receiver1 = generateRandomAddress(); + program.stackPush(new DataWord(receiver1)); + Assert.assertEquals(0, EnergyCost.getSuicideCost(program)); + invoke.getDeposit().createAccount(receiver1, Protocol.AccountType.Normal); + Assert.assertEquals(0, EnergyCost.getSuicideCost(program)); + + byte[] receiver2 = generateRandomAddress(); + program.stackPush(new DataWord(receiver2)); + Assert.assertEquals(25000, EnergyCost.getSuicideCost2(program)); + invoke.getDeposit().createAccount(receiver2, Protocol.AccountType.Normal); + Assert.assertEquals(0, EnergyCost.getSuicideCost2(program)); + } + + @Test + public void testSuicideAction() throws ContractValidateException { + invoke = new ProgramInvokeMockImpl( + StoreFactory.getInstance(), + new byte[0], + Hex.decode("41471fd3ad3e9eeadeec4608b92d16ce6b500704cc")); + + program = new Program(null, null, invoke, + new InternalTransaction( + Protocol.Transaction.getDefaultInstance(), + InternalTransaction.TrxType.TRX_UNKNOWN_TYPE)); + + VMConfig.initAllowEnergyAdjustment(1); + byte prePrefixByte = DecodeUtil.addressPreFixByte; + DecodeUtil.addressPreFixByte = Constant.ADD_PRE_FIX_BYTE_MAINNET; + + program.suicide(new DataWord( + dbManager.getAccountStore().getBlackhole().getAddress().toByteArray())); + + DecodeUtil.addressPreFixByte = prePrefixByte; + VMConfig.initAllowEnergyAdjustment(0); + } + + @Test + public void testVoteWitnessCost() throws ContractValidateException { + // Build stack environment, the stack from top to bottom is 0x00, 0x80, 0x00, 0x80 + program = new Program(null, null, new ProgramInvokeMockImpl(), + new InternalTransaction( + Protocol.Transaction.getDefaultInstance(), + InternalTransaction.TrxType.TRX_UNKNOWN_TYPE)); + program.stackPush(DataWord.of((byte) 0x80)); + program.stackPush(DataWord.of((byte) 0x00)); + program.stackPush(DataWord.of((byte) 0x80)); + program.stackPush(DataWord.of((byte) 0x00)); + + // Test VoteWitness before EnergyAdjustment, should not have memory expand energy + Assert.assertEquals(30000, EnergyCost.getVoteWitnessCost(program)); + + // Test VoteWitness after EnergyAdjustment, should have memory expand energy + VMConfig.initAllowEnergyAdjustment(1); + + long memWords = (0x80 + 32) / 32; + long memoryExpandEnergy = 3 * memWords + memWords * memWords / 512; + Assert.assertEquals(30000 + memoryExpandEnergy, EnergyCost.getVoteWitnessCost2(program)); + } + + @Test + public void testTransientStorageOperations() throws ContractValidateException { + VMConfig.initAllowTvmCancun(1); + + invoke = new ProgramInvokeMockImpl(); + invoke.setEnergyLimit(20000); + Protocol.Transaction trx = Protocol.Transaction.getDefaultInstance(); + InternalTransaction interTrx = + new InternalTransaction(trx, InternalTransaction.TrxType.TRX_UNKNOWN_TYPE); + + // TLOAD = 0x5c; + byte[] op = new byte[] {0x60, 0x01, 0x5c}; + program = new Program(op, op, invoke, interTrx); + testOperations(program); + Assert.assertEquals(103, program.getResult().getEnergyUsed()); + Assert.assertEquals(new DataWord(0x00), program.getStack().pop()); + + // TSTORE = 0x5d; + op = new byte[] {0x60, 0x01, 0x60, 0x01, 0x5d}; + + invoke.setStaticCall(true); + program = new Program(op, op, invoke, interTrx); + testOperations(program); + Assert.assertEquals(20000, program.getResult().getEnergyUsed()); + Assert.assertTrue(program.getResult().getException() + instanceof Program.StaticCallModificationException); + + invoke.setStaticCall(false); + program = new Program(op, op, invoke, interTrx); + testOperations(program); + Assert.assertEquals(106, program.getResult().getEnergyUsed()); + Assert.assertArrayEquals(new DataWord(0x01).getData(), + program.getContractState().getTransientStorageValue( + program.getContractAddress().getData(), new DataWord(0x01).getData())); + + op = new byte[] {0x60, 0x02, 0x60, 0x01, 0x5c, 0x16}; + program = new Program(op, op, invoke, interTrx); + testOperations(program); + + // TLOAD = 0x5c; + op = new byte[] {0x60, 0x01, 0x5c}; + program = new Program(op, op, invoke, interTrx); + testOperations(program); + Assert.assertEquals(103, program.getResult().getEnergyUsed()); + Assert.assertEquals(new DataWord(0x01), program.getStack().pop()); + + VMConfig.initAllowTvmCancun(0); + } + + @Test + public void testMCOPY() throws ContractValidateException { + VMConfig.initAllowTvmCancun(1); + + invoke = new ProgramInvokeMockImpl(); + Protocol.Transaction trx = Protocol.Transaction.getDefaultInstance(); + InternalTransaction interTrx = + new InternalTransaction(trx, InternalTransaction.TrxType.TRX_UNKNOWN_TYPE); + + // MCOPY = 0x5e + byte[] op = new byte[] {0x60, 0x20, 0x60, 0x01, 0x60, 0x20, 0x5e}; + program = new Program(op, op, invoke, interTrx); + testOperations(program); + Assert.assertEquals(21, program.getResult().getEnergyUsed()); + Assert.assertEquals(64, program.getMemSize()); + + op = + new byte[] { + 0x60, 0x01, 0x60, 0x01, 0x52, 0x60, 0x20, 0x60, 0x01, 0x60, 0x20, 0x5e, 0x60, 0x20, 0x51}; + program = new Program(op, op, invoke, interTrx); + testOperations(program); + Assert.assertEquals(new DataWord(0x01), program.getStack().pop()); + + VMConfig.initAllowTvmCancun(0); + } + + @Test + public void testBlobHash() throws ContractValidateException { + VMConfig.initAllowTvmBlob(1); + + invoke = new ProgramInvokeMockImpl(); + Protocol.Transaction trx = Protocol.Transaction.getDefaultInstance(); + InternalTransaction interTrx = + new InternalTransaction(trx, InternalTransaction.TrxType.TRX_UNKNOWN_TYPE); + + // BLOBAHASH = 0x49 + byte[] op = new byte[] {0x60, 0x20, 0x49}; + program = new Program(op, op, invoke, interTrx); + testOperations(program); + Assert.assertEquals(6, program.getResult().getEnergyUsed()); + Assert.assertEquals(DataWord.ZERO(), program.getStack().pop()); + + VMConfig.initAllowTvmBlob(0); + } + + @Test + public void testBlobBaseFee() throws ContractValidateException { + VMConfig.initAllowTvmBlob(1); + + invoke = new ProgramInvokeMockImpl(); + Protocol.Transaction trx = Protocol.Transaction.getDefaultInstance(); + InternalTransaction interTrx = + new InternalTransaction(trx, InternalTransaction.TrxType.TRX_UNKNOWN_TYPE); + + // BLOBBASEFEE = 0x4a + byte[] op = new byte[] {0x60, 0x20, 0x4a}; + program = new Program(op, op, invoke, interTrx); + testOperations(program); + Assert.assertEquals(5, program.getResult().getEnergyUsed()); + Assert.assertEquals(DataWord.ZERO(), program.getStack().pop()); + + VMConfig.initAllowTvmBlob(0); + } + private void testOperations(Program program) { try { while (!program.isStopped()) { @@ -954,4 +1137,10 @@ private byte[] compile(String code) { return new BytecodeCompiler().compile(code); } + private byte[] generateRandomAddress() { + byte[] address = new byte[21]; + new Random().nextBytes(address); + address[0] = DecodeUtil.addressPreFixByte; + return address; + } } diff --git a/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsVerifyProofTest.java b/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsVerifyProofTest.java index 833ed6b0ac3..27e7891e6d8 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsVerifyProofTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsVerifyProofTest.java @@ -1,6 +1,8 @@ package org.tron.common.runtime.vm; import static org.junit.Assert.assertNotNull; +import static org.tron.common.math.Maths.random; +import static org.tron.common.math.Maths.round; import com.google.protobuf.ByteString; import java.math.BigInteger; @@ -4504,7 +4506,7 @@ private byte[] longTo32Bytes(long value) { } private long randomLong() { - return Math.round(Math.random() * Long.MAX_VALUE / 2); + return round(random(true) * Long.MAX_VALUE / 2, true); } } diff --git a/framework/src/test/java/org/tron/common/runtime/vm/VoteTest.java b/framework/src/test/java/org/tron/common/runtime/vm/VoteTest.java index 1d85e9a7eab..d6493ed8018 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/VoteTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/VoteTest.java @@ -1,10 +1,10 @@ package org.tron.common.runtime.vm; +import static org.tron.common.math.Maths.max; import static org.tron.protos.Protocol.Transaction.Result.contractResult; import static org.tron.protos.Protocol.Transaction.Result.contractResult.REVERT; import static org.tron.protos.Protocol.Transaction.Result.contractResult.SUCCESS; -import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -29,7 +29,6 @@ import org.tron.common.runtime.TVMTestResult; import org.tron.common.runtime.TvmTestUtils; import org.tron.common.utils.Commons; -import org.tron.common.utils.FileUtil; import org.tron.common.utils.StringUtil; import org.tron.common.utils.WalletUtil; import org.tron.common.utils.client.utils.AbiUtil; @@ -863,7 +862,8 @@ private void checkRewardAndWithdraw(byte[] contract, boolean isZero) throws Exce long rewardBySystem = mortgageService.queryReward(contract); long beginCycle = manager.getDelegationStore().getBeginCycle(contract); long currentCycle = manager.getDynamicPropertiesStore().getCurrentCycleNumber(); - long passedCycle = Math.max(0, currentCycle - beginCycle); + long passedCycle = max(0, currentCycle - beginCycle, + manager.getDynamicPropertiesStore().disableJavaLangMath()); Assert.assertTrue(isZero ? rewardBySystem == 0 : rewardBySystem > 0); triggerContract(contract, SUCCESS, getConsumer(">=", rewardBySystem) diff --git a/framework/src/test/java/org/tron/common/storage/leveldb/LevelDbDataSourceImplTest.java b/framework/src/test/java/org/tron/common/storage/leveldb/LevelDbDataSourceImplTest.java index 50a55d24a0f..bf18b988f19 100644 --- a/framework/src/test/java/org/tron/common/storage/leveldb/LevelDbDataSourceImplTest.java +++ b/framework/src/test/java/org/tron/common/storage/leveldb/LevelDbDataSourceImplTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -41,9 +42,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.ClassRule; -import org.junit.Rule; import org.junit.Test; -import org.junit.contrib.java.lang.system.ExpectedSystemExit; import org.junit.rules.TemporaryFolder; import org.tron.common.utils.ByteArray; import org.tron.common.utils.FileUtil; @@ -51,6 +50,7 @@ import org.tron.core.Constant; import org.tron.core.config.args.Args; import org.tron.core.db2.common.WrappedByteArray; +import org.tron.core.exception.TronError; @Slf4j public class LevelDbDataSourceImplTest { @@ -73,9 +73,6 @@ public class LevelDbDataSourceImplTest { private byte[] key5 = "00000005aa".getBytes(); private byte[] key6 = "00000006aa".getBytes(); - @Rule - public final ExpectedSystemExit exit = ExpectedSystemExit.none(); - /** * Release resources. */ @@ -350,12 +347,11 @@ public void prefixQueryTest() { @Test public void initDbTest() { - exit.expectSystemExitWithStatus(1); makeExceptionDb("test_initDb"); LevelDbDataSourceImpl dataSource = new LevelDbDataSourceImpl( Args.getInstance().getOutputDirectory(), "test_initDb"); - dataSource.initDB(); - dataSource.closeDB(); + TronError thrown = assertThrows(TronError.class, dataSource::initDB); + assertEquals(TronError.ErrCode.LEVELDB_INIT, thrown.getErrCode()); } private void makeExceptionDb(String dbName) { diff --git a/framework/src/test/java/org/tron/common/storage/leveldb/RocksDbDataSourceImplTest.java b/framework/src/test/java/org/tron/common/storage/leveldb/RocksDbDataSourceImplTest.java index ed37c1e4bcd..c6fce30e3af 100644 --- a/framework/src/test/java/org/tron/common/storage/leveldb/RocksDbDataSourceImplTest.java +++ b/framework/src/test/java/org/tron/common/storage/leveldb/RocksDbDataSourceImplTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -23,9 +24,7 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.ClassRule; -import org.junit.Rule; import org.junit.Test; -import org.junit.contrib.java.lang.system.ExpectedSystemExit; import org.junit.rules.TemporaryFolder; import org.tron.common.storage.rocksdb.RocksDbDataSourceImpl; import org.tron.common.utils.ByteArray; @@ -34,6 +33,7 @@ import org.tron.common.utils.PublicMethod; import org.tron.core.config.args.Args; import org.tron.core.db2.common.WrappedByteArray; +import org.tron.core.exception.TronError; @Slf4j public class RocksDbDataSourceImplTest { @@ -55,9 +55,6 @@ public class RocksDbDataSourceImplTest { private byte[] key5 = "00000005aa".getBytes(); private byte[] key6 = "00000006aa".getBytes(); - @Rule - public final ExpectedSystemExit exit = ExpectedSystemExit.none(); - /** * Release resources. */ @@ -392,12 +389,11 @@ public void prefixQueryTest() { @Test public void initDbTest() { - exit.expectSystemExitWithStatus(1); makeExceptionDb("test_initDb"); RocksDbDataSourceImpl dataSource = new RocksDbDataSourceImpl( Args.getInstance().getOutputDirectory(), "test_initDb"); - dataSource.initDB(); - dataSource.closeDB(); + TronError thrown = assertThrows(TronError.class, dataSource::initDB); + assertEquals(TronError.ErrCode.ROCKSDB_INIT, thrown.getErrCode()); } private void makeExceptionDb(String dbName) { diff --git a/framework/src/test/java/org/tron/common/utils/ALockTest.java b/framework/src/test/java/org/tron/common/utils/ALockTest.java new file mode 100644 index 00000000000..d4501756daa --- /dev/null +++ b/framework/src/test/java/org/tron/common/utils/ALockTest.java @@ -0,0 +1,27 @@ +package org.tron.common.utils; + +import static org.junit.Assert.assertNotNull; + +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import org.junit.Before; +import org.junit.Test; + +public class ALockTest { + private ALock aLock; + private Lock mockLock; + + @Before + public void setUp() { + mockLock = new ReentrantLock(); + aLock = new ALock(mockLock); + } + + @Test + public void testLockAndUnlock() { + aLock.lock(); + assertNotNull(aLock); + aLock.close(); + } + +} diff --git a/framework/src/test/java/org/tron/common/utils/BIUtilTest.java b/framework/src/test/java/org/tron/common/utils/BIUtilTest.java new file mode 100644 index 00000000000..d126eb2a6b1 --- /dev/null +++ b/framework/src/test/java/org/tron/common/utils/BIUtilTest.java @@ -0,0 +1,155 @@ +package org.tron.common.utils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.math.BigInteger; +import org.junit.Test; + +public class BIUtilTest { + + @Test + public void testIsLessThan() { + BigInteger valueA = BigInteger.valueOf(1); + BigInteger valueB = BigInteger.valueOf(2); + assertTrue(BIUtil.isLessThan(valueA, valueB)); + + valueA = BigInteger.valueOf(3); + valueB = BigInteger.valueOf(3); + assertFalse(BIUtil.isLessThan(valueA, valueB)); + + valueA = BigInteger.valueOf(4); + valueB = BigInteger.valueOf(2); + assertFalse(BIUtil.isLessThan(valueA, valueB)); + } + + @Test + public void testIsZero() { + BigInteger value = BigInteger.ZERO; + assertTrue(BIUtil.isZero(value)); + + value = BigInteger.valueOf(1); + assertFalse(BIUtil.isZero(value)); + + value = BigInteger.valueOf(-1); + assertFalse(BIUtil.isZero(value)); + } + + @Test + public void testIsEqual() { + BigInteger valueA = BigInteger.valueOf(1); + BigInteger valueB = BigInteger.valueOf(1); + assertTrue(BIUtil.isEqual(valueA, valueB)); + + valueA = BigInteger.valueOf(2); + valueB = BigInteger.valueOf(3); + assertFalse(BIUtil.isEqual(valueA, valueB)); + } + + @Test + public void testIsNotEqual() { + BigInteger valueA = BigInteger.valueOf(1); + BigInteger valueB = BigInteger.valueOf(2); + assertTrue(BIUtil.isNotEqual(valueA, valueB)); + + valueA = BigInteger.valueOf(3); + valueB = BigInteger.valueOf(3); + assertFalse(BIUtil.isNotEqual(valueA, valueB)); + } + + @Test + public void testIsMoreThan() { + BigInteger valueA = BigInteger.valueOf(3); + BigInteger valueB = BigInteger.valueOf(2); + assertTrue(BIUtil.isMoreThan(valueA, valueB)); + + valueA = BigInteger.valueOf(1); + valueB = BigInteger.valueOf(2); + assertFalse(BIUtil.isMoreThan(valueA, valueB)); + + valueA = BigInteger.valueOf(2); + valueB = BigInteger.valueOf(2); + assertFalse(BIUtil.isMoreThan(valueA, valueB)); + } + + @Test + public void testSum() { + BigInteger valueA = BigInteger.valueOf(5); + BigInteger valueB = BigInteger.valueOf(7); + BigInteger expected = BigInteger.valueOf(12); + assertEquals(expected, BIUtil.sum(valueA, valueB)); + } + + @Test + public void testToBI_byteArray() { + byte[] data = {1, 0, 0, 0, 0, 0, 0, 1}; // BigInteger(128) + BigInteger expected = new BigInteger(1, data); + assertEquals(expected, BIUtil.toBI(data)); + } + + @Test + public void testToBI_long() { + long data = 123456789L; + BigInteger expected = BigInteger.valueOf(data); + assertEquals(expected, BIUtil.toBI(data)); + } + + @Test + public void testIsPositive() { + BigInteger value = BigInteger.valueOf(1); + assertTrue(BIUtil.isPositive(value)); + + value = BigInteger.ZERO; + assertFalse(BIUtil.isPositive(value)); + + value = BigInteger.valueOf(-1); + assertFalse(BIUtil.isPositive(value)); + } + + @Test + public void testIsNotCovers() { + BigInteger covers = BigInteger.valueOf(5); + BigInteger value = BigInteger.valueOf(10); + assertTrue(BIUtil.isNotCovers(covers, value)); + + covers = BigInteger.valueOf(10); + value = BigInteger.valueOf(5); + assertFalse(BIUtil.isNotCovers(covers, value)); + + covers = BigInteger.valueOf(10); + value = BigInteger.valueOf(10); + assertFalse(BIUtil.isNotCovers(covers, value)); + } + + @Test + public void testMax() { + BigInteger first = BigInteger.valueOf(5); + BigInteger second = BigInteger.valueOf(10); + assertEquals(second, BIUtil.max(first, second)); + + first = BigInteger.valueOf(15); + second = BigInteger.valueOf(10); + assertEquals(first, BIUtil.max(first, second)); + + first = BigInteger.valueOf(10); + second = BigInteger.valueOf(10); + assertEquals(first, BIUtil.max(first, second)); + } + + @Test + public void testAddSafely() { + int a = Integer.MAX_VALUE; + int b = 1; + int expected = Integer.MAX_VALUE; + assertEquals(expected, BIUtil.addSafely(a, b)); + + a = Integer.MAX_VALUE - 1; + b = 2; + assertEquals(expected, BIUtil.addSafely(a, b)); + + a = 1; + expected = 3; + assertEquals(expected, BIUtil.addSafely(a, b)); + } +} diff --git a/framework/src/test/java/org/tron/common/utils/ByteArrayMapTest.java b/framework/src/test/java/org/tron/common/utils/ByteArrayMapTest.java new file mode 100644 index 00000000000..b367ade7e4f --- /dev/null +++ b/framework/src/test/java/org/tron/common/utils/ByteArrayMapTest.java @@ -0,0 +1,173 @@ +package org.tron.common.utils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import lombok.Getter; +import org.junit.Before; +import org.junit.Test; + +public class ByteArrayMapTest { + + private ByteArrayMap byteArrayMap; + + @Before + public void setUp() { + byteArrayMap = new ByteArrayMap<>(); + } + + @Test + public void testPutAndGet() { + byte[] key = "key1".getBytes(); + String value = "value1"; + byteArrayMap.put(key, value); + assertEquals("Should return the correct value", value, byteArrayMap.get(key)); + } + + @Test + public void testSize() { + byte[] key1 = "key1".getBytes(); + byte[] key2 = "key2".getBytes(); + byteArrayMap.put(key1, "value1"); + byteArrayMap.put(key2, "value2"); + assertEquals("Should return the correct size", 2, byteArrayMap.size()); + } + + @Test + public void testRemove() { + byte[] key = "key".getBytes(); + String value = "value"; + byteArrayMap.put(key, value); + byteArrayMap.remove(key); + assertNull("Should return null after removal", byteArrayMap.get(key)); + } + + @Test + public void testContainsKey() { + byte[] key = "key".getBytes(); + byteArrayMap.put(key, "value"); + assertTrue("Should contain the key", byteArrayMap.containsKey(key)); + } + + @Test + public void testPutAll() { + Map mapToPut = createTestMap(); + byteArrayMap.putAll(mapToPut); + assertEquals("Should contain all entries after putAll", 2, byteArrayMap.size()); + assertEquals("Should return the correct value for key1", + "value1", byteArrayMap.get("key1".getBytes())); + assertEquals("Should return the correct value for key2", + "value2", byteArrayMap.get("key2".getBytes())); + + } + + @Test + public void testClear() { + byte[] key1 = "key1".getBytes(); + byte[] key2 = "key2".getBytes(); + byteArrayMap.put(key1, "value1"); + byteArrayMap.put(key2, "value2"); + assertFalse(byteArrayMap.isEmpty()); + byteArrayMap.clear(); + } + + @Test + public void testKeySet() { + byte[] key1 = "key1".getBytes(); + byte[] key2 = "key2".getBytes(); + byteArrayMap.put(key1, "value1"); + byteArrayMap.put(key2, "value2"); + Set set = byteArrayMap.keySet(); + assertTrue("Key set should contain key1", set.contains(key1)); + assertTrue("Key set should contain key2", set.contains(key2)); + } + + @Test + public void testValues() { + byte[] key1 = "key1".getBytes(); + byte[] key2 = "key2".getBytes(); + byteArrayMap.put(key1, "value1"); + byteArrayMap.put(key2, "value2"); + Collection values = byteArrayMap.values(); + assertTrue("Values should contain value1", values.contains("value1")); + assertTrue("Values should contain value1", byteArrayMap.containsValue("value1")); + assertTrue("Values should contain value2", values.contains("value2")); + } + + @Test + public void testEntrySet() { + byte[] key1 = "key1".getBytes(); + byte[] key2 = "key2".getBytes(); + byteArrayMap.put(key1, "value1"); + byteArrayMap.put(key2, "value2"); + Set> entrySet = byteArrayMap.entrySet(); + assertFalse(entrySet.isEmpty()); + assertEquals("Entry set size should be 2", 2, entrySet.size()); + assertThrows(Exception.class, () -> entrySet.contains(new Object())); + assertThrows(Exception.class, entrySet::toArray); + assertThrows(Exception.class, () -> entrySet.toArray(new Map.Entry[0])); + assertThrows(Exception.class, () -> entrySet.add(new MapEntry(key1, "value1"))); + assertThrows(Exception.class, () -> entrySet.remove(new MapEntry(key1, "value1"))); + assertThrows(Exception.class, () -> entrySet.containsAll(new HashSet<>())); + assertThrows(Exception.class, () -> entrySet.removeAll(new HashSet<>())); + assertThrows(Exception.class, () -> entrySet.addAll(new HashSet<>())); + assertThrows(Exception.class, () -> entrySet.retainAll(new HashSet<>())); + assertThrows(Exception.class, entrySet::clear); + } + + // Helper method to create a map for testing putAll + private Map createTestMap() { + Map map = new ByteArrayMap<>(); + map.put("key1".getBytes(), "value1"); + map.put("key2".getBytes(), "value2"); + return map; + } + + + @Test + public void test() { + Map map = new ByteArrayMap<>(); + Map testMap = createTestMap(); + assertNotEquals(map, testMap); + assertTrue(testMap.hashCode() <= 0); + assertNotNull(testMap.toString()); + } + + + @Getter + static class MapEntry implements Map.Entry { + K key; + V value; + + public MapEntry(K key, V value) { + this.key = key; + this.value = value; + } + + public V setValue(V o) { + throw new UnsupportedOperationException(); + } + + public boolean equals(Object o) { + if (o instanceof Map.Entry) { + Map.Entry other = (Map.Entry) o; + return Objects.equals(key, other.getKey()) && Objects.equals(value, other.getValue()); + } + return false; + } + + public int hashCode() { + return Objects.hashCode(key) ^ Objects.hashCode(value); + } + } +} diff --git a/framework/src/test/java/org/tron/common/utils/ByteArraySetTest.java b/framework/src/test/java/org/tron/common/utils/ByteArraySetTest.java new file mode 100644 index 00000000000..22695f713a7 --- /dev/null +++ b/framework/src/test/java/org/tron/common/utils/ByteArraySetTest.java @@ -0,0 +1,143 @@ +package org.tron.common.utils; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import org.junit.Before; +import org.junit.Test; + +public class ByteArraySetTest { + + private ByteArraySet byteArraySet; + + @Before + public void setUp() { + byteArraySet = new ByteArraySet(); + } + + @Test + public void testSizeIsEmptyInitially() { + assertEquals(0, byteArraySet.size()); + } + + @Test + public void testIsEmptyInitially() { + assertTrue(byteArraySet.isEmpty()); + } + + @Test + public void testAddAndGetSize() { + byte[] bytes1 = {1, 2, 3}; + byte[] bytes2 = {4, 5, 6}; + + byteArraySet.add(bytes1); + assertEquals(1, byteArraySet.size()); + + byteArraySet.add(bytes2); + assertEquals(2, byteArraySet.size()); + } + + @Test + public void testContains() { + byte[] bytes1 = {1, 2, 3}; + byte[] bytes2 = {4, 5, 6}; + + byteArraySet.add(bytes1); + assertTrue(byteArraySet.contains(bytes1)); + assertFalse(byteArraySet.contains(bytes2)); + + byteArraySet.add(bytes2); + assertTrue(byteArraySet.contains(bytes2)); + + assertThrows(Exception.class, () -> byteArraySet.containsAll(new HashSet<>())); + assertThrows(Exception.class, () -> byteArraySet.retainAll(new HashSet<>())); + assertThrows(Exception.class, () -> byteArraySet.removeAll(new HashSet<>())); + assertThrows(Exception.class, () -> byteArraySet.equals(new ByteArraySet())); + assertThrows(Exception.class, () -> byteArraySet.hashCode()); + } + + @Test + public void testIterator() { + byte[] bytes1 = {1, 2, 3}; + byte[] bytes2 = {4, 5, 6}; + + byteArraySet.add(bytes1); + byteArraySet.add(bytes2); + + Iterator iterator = byteArraySet.iterator(); + + assertTrue(iterator.hasNext()); + assertArrayEquals(bytes1, iterator.next()); + + assertTrue(iterator.hasNext()); + assertArrayEquals(bytes2, iterator.next()); + + assertFalse(iterator.hasNext()); + } + + @Test + public void testToArray() { + byte[] bytes1 = {1, 2, 3}; + byte[] bytes2 = {4, 5, 6}; + + byteArraySet.add(bytes1); + byteArraySet.add(bytes2); + + byte[][] array = byteArraySet.toArray(new byte[0][]); + + assertEquals(2, array.length); + assertArrayEquals(bytes1, array[0]); + assertArrayEquals(bytes2, array[1]); + } + + @Test + public void testAddAll() { + List list = Arrays.asList( + new byte[]{1, 2, 3}, + new byte[]{4, 5, 6} + ); + + boolean result = byteArraySet.addAll(list); + + assertTrue(result); + assertEquals(2, byteArraySet.size()); + assertTrue(byteArraySet.contains(new byte[]{1, 2, 3})); + assertTrue(byteArraySet.contains(new byte[]{4, 5, 6})); + } + + @Test + public void testRemove() { + byte[] bytes1 = {1, 2, 3}; + byte[] bytes2 = {4, 5, 6}; + + byteArraySet.add(bytes1); + byteArraySet.add(bytes2); + + boolean result = byteArraySet.remove(bytes1); + + assertTrue(result); + assertEquals(1, byteArraySet.size()); + assertFalse(byteArraySet.contains(bytes1)); + assertTrue(byteArraySet.contains(bytes2)); + } + + @Test + public void testClear() { + byte[] bytes1 = {1, 2, 3}; + byte[] bytes2 = {4, 5, 6}; + + byteArraySet.add(bytes1); + byteArraySet.add(bytes2); + assertTrue(byteArraySet.size() > 0); + + byteArraySet.clear(); + } +} diff --git a/framework/src/test/java/org/tron/common/utils/ByteArrayTest.java b/framework/src/test/java/org/tron/common/utils/ByteArrayTest.java index 226b00b8cb1..c0db8c4b418 100644 --- a/framework/src/test/java/org/tron/common/utils/ByteArrayTest.java +++ b/framework/src/test/java/org/tron/common/utils/ByteArrayTest.java @@ -17,6 +17,12 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.tron.common.utils.ByteArray.fromHex; +import static org.tron.common.utils.ByteArray.jsonHexToInt; import lombok.extern.slf4j.Slf4j; import org.bouncycastle.util.encoders.Hex; @@ -80,4 +86,33 @@ public void test2ToHexString() { assertEquals("ByteArray.toHexString is not equals Hex.toHexString", ByteArray.toHexString(bss), Hex.toHexString(bss)); } + + @Test + public void testFromObject_SerializableObject() { + String testString = "Hello, World!"; + byte[] result = ByteArray.fromObject(testString); + assertNotNull(result); + assertTrue(result.length > 0); + } + + @Test + public void testJsonHexToInt_ValidHex() { + try { + int result = jsonHexToInt("0x1A"); + assertEquals(26, result); + } catch (Exception e) { + fail("Exception should not have been thrown for valid hex string."); + } + assertThrows(Exception.class, () -> ByteArray.jsonHexToInt("1A")); + } + + @Test + public void testFromHexWithPrefix() { + String input = "0x1A3F"; + String expected = "1A3F"; + String result = fromHex(input); + assertEquals(expected, result); + String input1 = "1A3"; + assertEquals("01A3", fromHex(input1)); + } } diff --git a/framework/src/test/java/org/tron/common/utils/CollectionUtilsTest.java b/framework/src/test/java/org/tron/common/utils/CollectionUtilsTest.java new file mode 100644 index 00000000000..8b8ef35fb4b --- /dev/null +++ b/framework/src/test/java/org/tron/common/utils/CollectionUtilsTest.java @@ -0,0 +1,81 @@ +package org.tron.common.utils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; +import org.junit.Test; + +public class CollectionUtilsTest { + + @Test + public void testCollectList() { + List numbers = Arrays.asList("1", "2", "3"); + Function toInt = Integer::parseInt; + List integers = CollectionUtils.collectList(numbers, toInt); + assertEquals(Arrays.asList(1, 2, 3), integers); + } + + @Test + public void testCollectSet() { + List numbers = Arrays.asList("1", "2", "2", "3"); + Function toInt = Integer::parseInt; + Set integers = CollectionUtils.collectSet(numbers, toInt); + assertEquals(new HashSet<>(Arrays.asList(1, 2, 3)), integers); + } + + @Test + public void testTruncate() { + List numbers = Arrays.asList(1, 2, 3, 4, 5); + List truncated = CollectionUtils.truncate(numbers, 3); + assertEquals(Arrays.asList(1, 2, 3), truncated); + } + + @Test + public void testTruncateNoLimit() { + List numbers = Arrays.asList(1, 2, 3, 4, 5); + List truncated = CollectionUtils.truncate(numbers, 10); + assertEquals(numbers, truncated); + } + + @Test + public void testTruncateRandom() { + List numbers = Arrays.asList(1, 2, 3, 4, 5); + List numbers1 = Arrays.asList(1, 2); + List truncated = CollectionUtils.truncateRandom(numbers, 3, 2); + List truncated1 = CollectionUtils.truncateRandom(numbers1, 3, 2); + assertEquals(2, truncated1.size()); + assertEquals(3, truncated.size()); + assertTrue(truncated.containsAll(Arrays.asList(1, 2, 3, 4, 5).subList(0, 2))); + // Last element could be 3, 4, or 5, so we just check that it's one of them + assertTrue(truncated.contains(3) || truncated.contains(4) || truncated.contains(5)); + } + + @Test + public void testTruncateRandomConfirmEqualLimit() { + List numbers = Arrays.asList(1, 2, 3, 4, 5); + List truncated = CollectionUtils.truncateRandom(numbers, 5, 5); + assertEquals(numbers, truncated); + } + + @Test + public void testSelectList() { + List numbers = Arrays.asList(1, 2, 3, 4, 5); + Predicate isEven = n -> n % 2 == 0; + List selected = CollectionUtils.selectList(numbers, isEven); + assertEquals(Arrays.asList(2, 4), selected); + } + + @Test + public void testSelectSet() { + List numbers = Arrays.asList(1, 2, 2, 3, 4, 4, 5); + Predicate isEven = n -> n % 2 == 0; + Set selected = CollectionUtils.selectSet(numbers, isEven); + assertEquals(new HashSet<>(Arrays.asList(2, 4)), selected); + } +} diff --git a/framework/src/test/java/org/tron/common/utils/FileUtilTest.java b/framework/src/test/java/org/tron/common/utils/FileUtilTest.java index 9aff1566ef3..126e0918520 100644 --- a/framework/src/test/java/org/tron/common/utils/FileUtilTest.java +++ b/framework/src/test/java/org/tron/common/utils/FileUtilTest.java @@ -1,11 +1,88 @@ package org.tron.common.utils; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.tron.common.utils.FileUtil.readData; + import java.io.File; +import java.io.FileWriter; import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.FileVisitor; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; public class FileUtilTest { + private Path tempDir; + + @Before + public void setUp() throws IOException { + tempDir = Files.createTempDirectory("testDir"); + + Files.createFile(tempDir.resolve("file1.txt")); + Files.createFile(tempDir.resolve("file2.txt")); + + Path subDir = Files.createDirectory(tempDir.resolve("subdir")); + Files.createFile(subDir.resolve("file3.txt")); + } + + @After + public void tearDown() throws IOException { + Files.walk(tempDir) + .sorted(Comparator.reverseOrder()) + .forEach(path -> { + try { + Files.delete(path); + } catch (IOException e) { + e.printStackTrace(); + } + }); + } + + @Test + public void testRecursiveList() throws IOException { + List files = FileUtil.recursiveList(tempDir.toString()); + + assertTrue(files.contains(tempDir.resolve("file1.txt").toString())); + assertTrue(files.contains(tempDir.resolve("file2.txt").toString())); + assertTrue(files.contains(tempDir.resolve("subdir").resolve("file3.txt").toString())); + + assertEquals(3, files.size()); + } + + @Test + public void testReadData_NormalFile() throws IOException { + Path tempFile = Files.createTempFile("testfile", ".txt"); + try (FileWriter writer = new FileWriter(tempFile.toFile())) { + writer.write("Hello, World!"); + } + + char[] buffer = new char[1024]; + int len = readData(tempFile.toString(), buffer); + + assertEquals(13, len); + assertArrayEquals("Hello, World!".toCharArray(), Arrays.copyOf(buffer, 13)); + } + + @Test + public void testReadData_IOException() { + char[] buffer = new char[1024]; + File dir = new File(System.getProperty("java.io.tmpdir")); + int len = readData(dir.getAbsolutePath(), buffer); + assertEquals(0, len); + } + @Test public void testCreateFileIfNotExists() { @@ -16,15 +93,15 @@ public void testCreateFileIfNotExists() { } catch (IOException e) { System.out.println("ignore this exception."); } - Assert.assertTrue(file1.exists()); - Assert.assertTrue(FileUtil.createDirIfNotExists(existFile)); - Assert.assertTrue(file1.exists()); + assertTrue(file1.exists()); + assertTrue(FileUtil.createDirIfNotExists(existFile)); + assertTrue(file1.exists()); String notExistFile = "notexistsfile.txt"; File file2 = new File(notExistFile); - Assert.assertTrue(!file2.exists()); - Assert.assertTrue(FileUtil.createDirIfNotExists(notExistFile)); - Assert.assertTrue(file2.exists()); + assertTrue(!file2.exists()); + assertTrue(FileUtil.createDirIfNotExists(notExistFile)); + assertTrue(file2.exists()); file1.delete(); file2.delete(); } @@ -34,16 +111,18 @@ public void testCreateDirIfNotExists() { String existDir = "existsdir"; File fileDir1 = new File(existDir); fileDir1.mkdir(); - Assert.assertTrue(fileDir1.exists()); - Assert.assertTrue(FileUtil.createDirIfNotExists(existDir)); - Assert.assertTrue(fileDir1.exists()); + assertTrue(fileDir1.exists()); + assertTrue(FileUtil.createDirIfNotExists(existDir)); + assertTrue(fileDir1.exists()); String notExistDir = "notexistsdir"; File fileDir2 = new File(notExistDir); - Assert.assertTrue(!fileDir2.exists()); - Assert.assertTrue(FileUtil.createDirIfNotExists(notExistDir)); - Assert.assertTrue(fileDir2.exists()); + assertTrue(!fileDir2.exists()); + assertTrue(FileUtil.createDirIfNotExists(notExistDir)); + assertTrue(fileDir2.exists()); fileDir1.delete(); fileDir2.delete(); } + + } \ No newline at end of file diff --git a/framework/src/test/java/org/tron/common/utils/JsonUtilTest.java b/framework/src/test/java/org/tron/common/utils/JsonUtilTest.java index 9a4efb722e3..8681ff58270 100644 --- a/framework/src/test/java/org/tron/common/utils/JsonUtilTest.java +++ b/framework/src/test/java/org/tron/common/utils/JsonUtilTest.java @@ -1,7 +1,13 @@ package org.tron.common.utils; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.tron.common.utils.JsonUtil.json2Obj; +import static org.tron.common.utils.JsonUtil.obj2Json; + import lombok.Data; -import org.junit.Assert; import org.junit.Test; public class JsonUtilTest { @@ -25,11 +31,50 @@ public void test() { a1.setKey("abc"); a1.setValue(100); - String jsonString = JsonUtil.obj2Json(a1); + String jsonString = obj2Json(a1); A a2 = JsonUtil.json2Obj(jsonString, A.class); - Assert.assertEquals(a2.getKey(), "abc"); - Assert.assertEquals(a2.getValue(), 100); + assert a2 != null; + assertEquals("abc", a2.getKey()); + assertEquals(100, a2.getValue()); + assertNull(obj2Json(null)); + assertNull(json2Obj(null, null)); + + + } + + @Test + public void testObj2JsonWithCircularReference() { + Node node1 = new Node("Node1"); + Node node2 = new Node("Node2"); + node1.setNext(node2); + node2.setNext(node1); + + try { + obj2Json(node1); + fail("Expected a RuntimeException to be thrown"); + } catch (RuntimeException e) { + assertTrue(e.getCause() instanceof com.fasterxml.jackson.databind.JsonMappingException); + } + } + + @Test(expected = RuntimeException.class) + public void testInvalidJson() { + String invalidJson = "{invalid: json}"; + json2Obj(invalidJson, String.class); + } + + class Node { + private String name; + private org.tron.common.utils.JsonUtilTest.Node next; + + public Node(String name) { + this.name = name; + } + + public void setNext(org.tron.common.utils.JsonUtilTest.Node next) { + this.next = next; + } } } diff --git a/framework/src/test/java/org/tron/common/utils/RandomGeneratorTest.java b/framework/src/test/java/org/tron/common/utils/RandomGeneratorTest.java index 7bc922661cb..4de441d940d 100644 --- a/framework/src/test/java/org/tron/common/utils/RandomGeneratorTest.java +++ b/framework/src/test/java/org/tron/common/utils/RandomGeneratorTest.java @@ -1,19 +1,42 @@ package org.tron.common.utils; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import com.beust.jcommander.internal.Lists; import com.google.protobuf.ByteString; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import org.joda.time.DateTime; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.tron.core.capsule.WitnessCapsule; @Slf4j -@Ignore public class RandomGeneratorTest { + private RandomGenerator randomGenerator; + + @Before + public void setUp() { + randomGenerator = new RandomGenerator<>(); + } + + @Test + public void testShufflePreservesElements() { + List list = Arrays.asList(1, 2, 3, 4, 5); + List shuffledList = randomGenerator.shuffle(list, System.currentTimeMillis()); + + assertEquals(list.size(), shuffledList.size()); + for (Integer num : list) { + assertTrue(shuffledList.contains(num)); + } + } + + @Ignore @Test public void shuffle() { final List witnessCapsuleListBefore = this.getWitnessList(); diff --git a/framework/src/test/java/org/tron/common/utils/SetAdapterTest.java b/framework/src/test/java/org/tron/common/utils/SetAdapterTest.java new file mode 100644 index 00000000000..1d53ea3dd1a --- /dev/null +++ b/framework/src/test/java/org/tron/common/utils/SetAdapterTest.java @@ -0,0 +1,114 @@ +package org.tron.common.utils; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.junit.Before; +import org.junit.Test; + +public class SetAdapterTest { + + private Map delegate; + private SetAdapter setAdapter; + + @Before + public void setUp() { + delegate = new HashMap<>(); + setAdapter = new SetAdapter<>(delegate); + } + + @Test + public void testSizeInitiallyEmpty() { + assertEquals(0, setAdapter.size()); + } + + @Test + public void testIsEmptyInitially() { + assertTrue(setAdapter.isEmpty()); + } + + @Test + public void testContainsWhenEmpty() { + assertFalse(setAdapter.contains("test")); + } + + @Test + public void testAddAndGetSize() { + setAdapter.add("one"); + assertEquals(1, setAdapter.size()); + } + + @Test + public void testAddAndCheckContains() { + setAdapter.add("two"); + assertTrue(setAdapter.contains("two")); + } + + @Test + public void testRemoveAndCheckContains() { + setAdapter.add("three"); + assertTrue(setAdapter.contains("three")); + setAdapter.remove("three"); + assertFalse(setAdapter.contains("three")); + } + + @Test + public void testIterator() { + setAdapter.add("four"); + setAdapter.add("five"); + Set expected = new HashSet<>(Arrays.asList("four", "five")); + Set actual = new HashSet<>(setAdapter); // Convert to HashSet to ignore order + assertEquals(expected, actual); + } + + @Test + public void testToArray() { + setAdapter.add("six"); + setAdapter.add("seven"); + Object[] array = setAdapter.toArray(); + Arrays.sort(array); // Sorting to ignore order + assertArrayEquals(new String[]{"seven", "six"}, array); + } + + @Test + public void testToArrayWithGivenType() { + setAdapter.add("eight"); + String[] array = setAdapter.toArray(new String[0]); + Arrays.sort(array); // Sorting to ignore order + assertArrayEquals(new String[]{"eight"}, array); + } + + @Test + public void testAddAll() { + setAdapter.addAll(Arrays.asList("nine", "ten")); + assertTrue(setAdapter.containsAll(Arrays.asList("nine", "ten"))); + } + + @Test + public void testRemoveAll() { + setAdapter.addAll(Arrays.asList("eleven", "twelve")); + setAdapter.removeAll(Collections.singletonList("eleven")); + assertFalse(setAdapter.contains("eleven")); + assertTrue(setAdapter.contains("twelve")); + } + + @Test + public void testClear() { + setAdapter.addAll(Arrays.asList("thirteen", "fourteen")); + setAdapter.clear(); + assertTrue(setAdapter.isEmpty()); + } + + @Test(expected = RuntimeException.class) + public void testRetainAllThrowsException() { + setAdapter.retainAll(Collections.emptyList()); + } +} diff --git a/framework/src/test/java/org/tron/common/utils/Sha256HashTest.java b/framework/src/test/java/org/tron/common/utils/Sha256HashTest.java index 51745e96e92..0df72cc125d 100644 --- a/framework/src/test/java/org/tron/common/utils/Sha256HashTest.java +++ b/framework/src/test/java/org/tron/common/utils/Sha256HashTest.java @@ -1,8 +1,19 @@ package org.tron.common.utils; +import static java.nio.file.Files.createTempFile; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import ch.qos.logback.core.util.FileUtil; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.Arrays; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.IntStream; +import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.Test; import org.tron.common.parameter.CommonParameter; @@ -10,18 +21,37 @@ public class Sha256HashTest { @Test - public void testHash() { + public void testHash() throws IOException { //Example from https://github.com/tronprotocol/tips/blob/master/TWP-001.md byte[] input = ByteArray.fromHexString("A0E11973395042BA3C0B52B4CDF4E15EA77818F275"); byte[] hash0 = Sha256Hash.hash(CommonParameter .getInstance().isECKeyCryptoEngine(), input); byte[] hash1 = Sha256Hash.hash(CommonParameter .getInstance().isECKeyCryptoEngine(), hash0); - Assert.assertEquals(Arrays.toString(hash0), Arrays.toString(ByteArray + assertEquals(Arrays.toString(hash0), Arrays.toString(ByteArray .fromHexString("CD5D4A7E8BE869C00E17F8F7712F41DBE2DDBD4D8EC36A7280CD578863717084"))); - Assert.assertEquals(Arrays.toString(hash1), Arrays.toString(ByteArray + assertEquals(Arrays.toString(hash1), Arrays.toString(ByteArray .fromHexString("10AE21E887E8FE30C591A22A5F8BB20EB32B2A739486DC5F3810E00BBDB58C5C"))); + Sha256Hash sha256Hash = new Sha256Hash(1, new byte[32]); + assertNotNull(sha256Hash.toBigInteger()); + + Sha256Hash.create(true, ("byte1-1").getBytes(StandardCharsets.UTF_8)); + File testfile = createTempFile("testfile", ".txt").toFile(); + Sha256Hash.of(true, testfile); + Sha256Hash.createDouble(true, new byte[0]); + Sha256Hash.twiceOf(true, new byte[0]); + Sha256Hash.hashTwice(true, new byte[0]); + Sha256Hash.hashTwice(false, new byte[0]); + Sha256Hash.hashTwice(true, new byte[0], 0, 0); + Sha256Hash.hashTwice(false, new byte[0], 0, 0); + Sha256Hash.hash(false, new byte[0], 0, 0); + Sha256Hash.hashTwice(true, new byte[0], 0, 0, new byte[0], 0, 0); + Sha256Hash.hashTwice(false, new byte[0], 0, 0, new byte[0], 0, 0); + assertTrue(testfile.delete()); + + + } @Test @@ -51,7 +81,7 @@ public void testMultiThreadingHash() { e.printStackTrace(); } }); - Assert.assertEquals(70000, countAll.get()); - Assert.assertEquals(0, countFailed.get()); + assertEquals(70000, countAll.get()); + assertEquals(0, countFailed.get()); } } \ No newline at end of file diff --git a/framework/src/test/java/org/tron/common/utils/SlidingWindowCounterTest.java b/framework/src/test/java/org/tron/common/utils/SlidingWindowCounterTest.java new file mode 100644 index 00000000000..016b7ac611b --- /dev/null +++ b/framework/src/test/java/org/tron/common/utils/SlidingWindowCounterTest.java @@ -0,0 +1,63 @@ +package org.tron.common.utils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class SlidingWindowCounterTest { + + private SlidingWindowCounter counter; + + @Before + public void setUp() { + counter = new SlidingWindowCounter(3); + } + + @Test + public void testIncrease() { + counter.increase(); + counter.increase(); + counter.increase(); + assertEquals(3, counter.totalCount()); + counter.resizeWindow(5); + assertNotNull(counter.toString()); + } + + @Test + public void testTotalAndAdvance() { + counter.increase(); + counter.increase(); + counter.advance(); + counter.increase(); + int total = counter.totalAndAdvance(); + assertEquals(3, total); + assertEquals(3, counter.totalCount()); + } + + @Test + public void testTotalCount() { + counter.increase(); + counter.increase(); + counter.advance(); + assertEquals(2, counter.totalCount()); + } + + @Test + public void testCircularWindow() { + for (int i = 0; i < 3; i++) { + counter.increase(); + } + counter.increase(); + counter.advance(); + assertEquals(4, counter.totalCount()); + + counter.increase(); + counter.increase(); + counter.increase(); + int total = counter.totalAndAdvance(); + assertEquals(7, total); + assertEquals(7, counter.totalCount()); + } +} diff --git a/framework/src/test/java/org/tron/common/utils/TypeConversionTest.java b/framework/src/test/java/org/tron/common/utils/TypeConversionTest.java index b9188e96060..c98115af3f0 100644 --- a/framework/src/test/java/org/tron/common/utils/TypeConversionTest.java +++ b/framework/src/test/java/org/tron/common/utils/TypeConversionTest.java @@ -17,9 +17,13 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; import static org.tron.common.utils.TypeConversion.bytesToHexString; import static org.tron.common.utils.TypeConversion.bytesToLong; import static org.tron.common.utils.TypeConversion.hexStringToBytes; +import static org.tron.common.utils.TypeConversion.increment; import static org.tron.common.utils.TypeConversion.longToBytes; import lombok.extern.slf4j.Slf4j; @@ -58,6 +62,14 @@ public void testHexStringToBytes() { //logger.info("hex string 7f to bytes is: {}", result); byte[] expected = new byte[]{127}; assertArrayEquals(expected, result); + assertNull(hexStringToBytes("test")); + } + @Test + public void testIncrementNormalCase() { + byte[] bytes = {1, 2, 3}; + boolean result = increment(bytes); + assertTrue(result); + assertArrayEquals(new byte[]{1, 2, 4}, bytes); } } diff --git a/framework/src/test/java/org/tron/common/utils/UtilsTest.java b/framework/src/test/java/org/tron/common/utils/UtilsTest.java new file mode 100644 index 00000000000..6a593a7684f --- /dev/null +++ b/framework/src/test/java/org/tron/common/utils/UtilsTest.java @@ -0,0 +1,74 @@ +package org.tron.common.utils; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.nio.charset.Charset; +import java.security.SecureRandom; +import org.junit.Test; + +public class UtilsTest { + + @Test + public void testGetRandom() { + SecureRandom random = Utils.getRandom(); + assertNotNull("SecureRandom should not be null", random); + } + + @Test + public void testGetBytes() { + char[] chars = "hello".toCharArray(); + byte[] bytes = Utils.getBytes(chars); + + // Convert back to String to check if it's the same + String result = new String(bytes, Charset.forName("UTF-8")); + assertEquals("Converted bytes should match the original string", "hello", result); + } + + @Test + public void testGetIdShort() { + String longId = "12345678901234567890"; + String shortId = Utils.getIdShort(longId); + assertEquals("Short ID should be the first 8 characters of the long ID", "12345678", shortId); + + String nullId = Utils.getIdShort(null); + assertEquals("ID should be '' for null input", "", nullId); + } + + @Test + public void testClone() { + byte[] original = {1, 2, 3, 4, 5}; + byte[] clone = Utils.clone(original); + + assertArrayEquals("Clone should be equal to the original", original, clone); + + // Modify the clone to ensure it's a new array + clone[0] = 99; + assertNotEquals("Modifying the clone should not affect the original", original[0], clone[0]); + } + + @Test + public void testAlignLeft() { + String result = Utils.align("abc", '-', 10, false); + String result1 = Utils.align("abc", '-', 2, false); + assertEquals("abc-------", result); + assertEquals("abc", result1); + } + + @Test + public void testAlignRight() { + String result = Utils.align("abc", '-', 10, true); + assertEquals("-------abc", result); + } + + @Test + public void testRepeat() { + String result = Utils.repeat("a", 5); + assertEquals("aaaaa", result); + + result = Utils.repeat("abc", 3); + assertEquals("abcabcabc", result); + } +} diff --git a/framework/src/test/java/org/tron/common/utils/ValueTest.java b/framework/src/test/java/org/tron/common/utils/ValueTest.java new file mode 100644 index 00000000000..f7e4f415f5f --- /dev/null +++ b/framework/src/test/java/org/tron/common/utils/ValueTest.java @@ -0,0 +1,198 @@ +package org.tron.common.utils; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.tron.common.utils.ByteUtil.EMPTY_BYTE_ARRAY; + +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import org.bouncycastle.util.encoders.Hex; +import org.junit.Before; +import org.junit.Test; + +public class ValueTest { + + private Value value; + + @Before + public void setUp() { + value = new Value(); + value.init(new byte[100]); + } + + @Test + public void testAsObj() { + Object obj = new Object(); + value = new Value(obj); + assertEquals("asObj should return the encapsulated object", obj, value.asObj()); + } + + @Test + public void testAsList() { + Object[] array = { "element1", "element2" }; + value = new Value(array); + List list = value.asList(); + assertEquals(2, list.size()); + assertEquals("element1", list.get(0)); + } + + @Test + public void testAsInt() { + value = new Value(123); + assertEquals(123, value.asInt()); + assertEquals(0, new Value(new byte[0]).asInt()); + assertEquals(0, new Value("test").asInt()); + } + + @Test + public void testAsLong() { + value = new Value(123456789L); + assertEquals(123456789L, value.asLong()); + assertEquals(0L, new Value(new byte[0]).asLong()); + assertEquals(0L, new Value("TEST").asLong()); + } + + @Test + public void testAsBigInt() { + BigInteger bigInteger = new BigInteger("12345678901234567890"); + value = new Value(bigInteger); + assertEquals(bigInteger, value.asBigInt()); + } + + @Test + public void testAsString() { + value = new Value("test string"); + assertEquals("test string", value.asString()); + assertNotNull(new Value(new byte[0]).asString()); + assertEquals("", new Value(100).asString()); + assertNotNull(value.get(0)); + + } + + @Test + public void testAsBytes() { + byte[] bytes = { 0x01, 0x02, 0x03 }; + value = new Value(bytes); + assertArrayEquals("asBytes should return the correct byte array", bytes, value.asBytes()); + assertEquals(EMPTY_BYTE_ARRAY, new Value(100).asBytes()); + } + + @Test + public void testGet() { + List list = Arrays.asList("element1", "element2"); + value = new Value(list.toArray()); + Value element = value.get(0); + assertEquals("element1", element.asString()); + assertNotNull(value.get(2)); + } + + @Test(expected = Exception.class) + public void testGetNegativeIndex() { + value = new Value(new Object[] { "element1", "element2" }); + value.get(-1); + } + + @Test + public void testCmp() { + Value value1 = new Value("test"); + Value value2 = new Value("test"); + assertTrue("cmp should return true for equal values", value1.cmp(value2)); + } + + @Test + public void testIsList() { + value = new Value(new Object[] { "element1", "element2" }); + assertTrue("isList should return true for an array", value.isList()); + assertNotNull(value.toString()); + } + + @Test + public void testIsString() { + value = new Value("test string"); + assertTrue("isString should return true for a string", value.isString()); + } + + @Test + public void testIsInt() { + value = new Value(123); + assertTrue("isInt should return true for an integer", value.isInt()); + } + + @Test + public void testIsLong() { + value = new Value(123456789L); + assertTrue("isLong should return true for a long", value.isLong()); + } + + @Test + public void testIsBigInt() { + value = new Value(new BigInteger("12345678901234567890")); + assertTrue("isBigInt should return true for a BigInteger", value.isBigInt()); + } + + @Test + public void testIsBytes() { + byte[] bytes = { 0x01, 0x02, 0x03 }; + value = new Value(bytes); + assertTrue("isBytes should return true for a byte array", value.isBytes()); + } + + @Test + public void testIsReadableString() { + byte[] readableBytes = "Hello World".getBytes(); + value = new Value(readableBytes); + assertTrue(value.isReadableString()); + } + + @Test + public void testIsHexString() { + byte[] hexBytes = Hex.decode("48656c6c6f20576f726c64"); + value = new Value(hexBytes); + assertFalse("isHexString should return true for hex byte array", value.isHexString()); + } + + @Test + public void testIsHashCode() { + byte[] hashBytes = new byte[32]; + value = new Value(hashBytes); + assertTrue("isHashCode should return true for a 32 byte array", value.isHashCode()); + } + + @Test + public void testIsNull() { + value = new Value(null); + assertTrue("isNull should return true for null", value.isNull()); + } + + @Test + public void testIsEmpty() { + value = new Value(""); + assertTrue("isEmpty should return true for an empty string", value.isEmpty()); + } + + @Test + public void testLength() { + value = new Value("test string"); + assertEquals(11, value.length()); + } + + @Test + public void testToString() { + value = new Value("test string"); + assertEquals("test string", value.toString()); + } + + @Test + public void testCountBranchNodes() { + Object[] array = { new Value("element1"), new Value("element2") }; + value = new Value(array); + assertEquals(0, value.countBranchNodes()); + value = new Value(new byte[0]); + assertEquals(0, value.countBranchNodes()); + + } +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/common/utils/client/WalletClient.java b/framework/src/test/java/org/tron/common/utils/client/WalletClient.java index 37b67ffaa46..9d9a68da49d 100644 --- a/framework/src/test/java/org/tron/common/utils/client/WalletClient.java +++ b/framework/src/test/java/org/tron/common/utils/client/WalletClient.java @@ -96,65 +96,6 @@ public WalletClient(final ECKey ecKey) { this.ecKey = ecKey; } - /** - * constructor. - */ - - public static boolean init(int itype) { - Config config = Configuration.getByPath("testng.conf"); - dbPath = config.getString("CityDb.DbPath"); - txtPath = System.getProperty("user.dir") + '/' + config.getString("CityDb.TxtPath"); - - String fullNodepathname = ""; - - if (1000 == itype) { - fullNodepathname = "checkfullnode.ip.list"; - } else { - fullNodepathname = "fullnode.ip.list"; - } - String fullNode = ""; - String solidityNode = ""; - if (config.hasPath("soliditynode.ip.list")) { - solidityNode = config.getStringList("soliditynode.ip.list").get(0); - } - if (config.hasPath(fullNodepathname)) { - fullNode = config.getStringList(fullNodepathname).get(itype); - } - if (config.hasPath("net.type") && "mainnet".equalsIgnoreCase(config.getString("net.type"))) { - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } else { - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_TESTNET); - } - rpcCli = new GrpcClient(fullNode, solidityNode); - return true; - } - - /** - * constructor. - */ - - public static GrpcClient init() { - //Config config = org.tron.core.config.Configuration.getByPath("config.conf"); - Config config = Configuration.getByPath("testng.conf"); - dbPath = config.getString("CityDb.DbPath"); - txtPath = System.getProperty("user.dir") + "/" + config.getString("CityDb.TxtPath"); - - String fullNode = ""; - String solidityNode = ""; - if (config.hasPath("soliditynode.ip.list")) { - solidityNode = config.getStringList("soliditynode.ip.list").get(0); - } - if (config.hasPath("fullnode.ip.list")) { - fullNode = config.getStringList("fullnode.ip.list").get(0); - } - if (config.hasPath("net.type") && "mainnet".equalsIgnoreCase(config.getString("net.type"))) { - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } else { - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_TESTNET); - } - return new GrpcClient(fullNode, solidityNode); - } - public static byte getAddressPreFixByte() { return addressPreFixByte; } diff --git a/framework/src/test/java/org/tron/common/utils/client/utils/AbiUtil.java b/framework/src/test/java/org/tron/common/utils/client/utils/AbiUtil.java index 976490b8c80..1d780bfacd4 100644 --- a/framework/src/test/java/org/tron/common/utils/client/utils/AbiUtil.java +++ b/framework/src/test/java/org/tron/common/utils/client/utils/AbiUtil.java @@ -1,5 +1,7 @@ package org.tron.common.utils.client.utils; +import static org.tron.common.math.Maths.abs; + import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.util.ArrayList; @@ -238,6 +240,16 @@ public static byte[] encodeInput(String methodSign, String input) { return pack(coders, items); } + public static String generateOccupationConstantPrivateKey() { + StringBuilder privateKey = new StringBuilder(); + String baseKey = "1234567890"; + for (int i = 0; i < 6; i++) { + privateKey.append(baseKey); + } + privateKey.append("1234"); + return privateKey.toString(); + } + public static void main(String[] args) { String method = "test(string,int2,string)"; String params = "asdf,3123,adf"; @@ -340,7 +352,7 @@ static class CoderNumber extends Coder { @Override byte[] encode(String value) { long n = Long.valueOf(value); - DataWord word = new DataWord(Math.abs(n)); + DataWord word = new DataWord(abs(n, true)); if (n < 0) { word.negate(); } diff --git a/framework/src/test/java/org/tron/common/utils/client/utils/DataWord.java b/framework/src/test/java/org/tron/common/utils/client/utils/DataWord.java index 6c36f4d636a..f676ef6c8e4 100644 --- a/framework/src/test/java/org/tron/common/utils/client/utils/DataWord.java +++ b/framework/src/test/java/org/tron/common/utils/client/utils/DataWord.java @@ -18,6 +18,8 @@ * along with the ethereumJ library. If not, see . */ +import static org.tron.common.math.Maths.signum; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import java.math.BigInteger; @@ -466,7 +468,7 @@ public int compareTo(DataWord o) { data, 0, data.length, o.getData(), 0, o.getData().length); // Convert result into -1, 0 or 1 as is the convention - return (int) Math.signum(result); + return (int) signum(result, true); } /** diff --git a/framework/src/test/java/org/tron/common/utils/client/utils/HttpMethed.java b/framework/src/test/java/org/tron/common/utils/client/utils/HttpMethed.java index ee872be6330..a68bb616f11 100644 --- a/framework/src/test/java/org/tron/common/utils/client/utils/HttpMethed.java +++ b/framework/src/test/java/org/tron/common/utils/client/utils/HttpMethed.java @@ -36,10 +36,8 @@ public class HttpMethed { static HttpClient httpClient; static HttpPost httppost; static HttpResponse response; - static Integer connectionTimeout = - Configuration.getByPath("testng.conf").getInt("defaultParameter.httpConnectionTimeout"); - static Integer soTimeout = - Configuration.getByPath("testng.conf").getInt("defaultParameter.httpSoTimeout"); + static Integer connectionTimeout = 19000; + static Integer soTimeout = 18000; static String transactionString; static String transactionSignString; static JSONObject responseContent; @@ -48,8 +46,7 @@ public class HttpMethed { public static volatile Integer witnessNum; /** constructor. */ - private static volatile String httpnode = - Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list").get(1); + private static volatile String httpnode = "127.0.0.1:50052"; /** constructor. */ public static Integer getWitnessNum() { @@ -1171,7 +1168,7 @@ public static String gettransactionsign( String httpNode, String transactionString, String privateKey) { try { transactionSignString = TransactionUtils.getTransactionSign(transactionString, privateKey, - false); + false); } catch (Exception e) { e.printStackTrace(); httppost.releaseConnection(); @@ -3446,7 +3443,7 @@ public static Boolean getSpendResult( String jsonString = responseContent.toJSONString(); if (jsonString.contains("result") && (responseContent.getString("result").equals("true") - && responseContent.getString("message").equals("Input note has been spent"))) { + && responseContent.getString("message").equals("Input note has been spent"))) { return Boolean.TRUE; } else { return Boolean.FALSE; @@ -3501,7 +3498,7 @@ public static Boolean getSpendResultFromSolidity( String jsonString = responseContent.toJSONString(); if (jsonString.contains("result") && (responseContent.getString("result").equals("true") - && responseContent.getString("message").equals("Input note has been spent"))) { + && responseContent.getString("message").equals("Input note has been spent"))) { return Boolean.TRUE; } else { return Boolean.FALSE; @@ -3552,7 +3549,7 @@ public static Boolean getSpendResultFromPbft( String jsonString = responseContent.toJSONString(); if (jsonString.contains("result") && (responseContent.getString("result").equals("true") - && responseContent.getString("message").equals("Input note has been spent"))) { + && responseContent.getString("message").equals("Input note has been spent"))) { return Boolean.TRUE; } else { return Boolean.FALSE; @@ -4234,10 +4231,8 @@ public static HttpResponse sendShieldCoinWithoutAsk( public static void freedResource( String httpNode, byte[] fromAddress, byte[] toAddress, String fromKey) { long balance = HttpMethed.getBalance(httpNode, fromAddress); - // System.out.println("剩余资源:" + balance); sendCoin(httpNode, fromAddress, toAddress, balance - 50000, fromKey); balance = HttpMethed.getBalance(httpNode, fromAddress); - // System.out.println("之后资源:" + balance); } /** constructor. */ diff --git a/framework/src/test/java/org/tron/common/zksnark/ZksnarkClientTest.java b/framework/src/test/java/org/tron/common/zksnark/ZksnarkClientTest.java new file mode 100644 index 00000000000..21275d548a0 --- /dev/null +++ b/framework/src/test/java/org/tron/common/zksnark/ZksnarkClientTest.java @@ -0,0 +1,43 @@ +package org.tron.common.zksnark; + +import static org.junit.Assert.assertThrows; + +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import io.grpc.StatusRuntimeException; +import java.nio.charset.StandardCharsets; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.utils.ByteArray; +import org.tron.protos.Protocol.Transaction; +import org.tron.protos.contract.BalanceContract; + +public class ZksnarkClientTest { + + public ZksnarkClient zksnarkClient; + + @Before + public void setUp() { + zksnarkClient = ZksnarkClient.getInstance(); + } + + @Test + public void testCheckZksnarkProof() { + BalanceContract.TransferContract transferContract = + BalanceContract.TransferContract.newBuilder() + .setAmount(10) + .setOwnerAddress(ByteString.copyFromUtf8("aaa")) + .setToAddress(ByteString.copyFromUtf8("bbb")) + .build(); + Transaction transaction = Transaction.newBuilder().setRawData(Transaction.raw.newBuilder() + .setData(ByteString.copyFrom("transfer".getBytes(StandardCharsets.UTF_8))) + .addContract(Transaction.Contract.newBuilder().setParameter(Any.pack(transferContract)) + .setType(Transaction.Contract.ContractType.TransferContract))) + .addRet(Transaction.Result.newBuilder().setAssetIssueID("1234567").build()).build(); + byte[] b = ByteArray + .fromHexString("ded9c2181fd7ea468a7a7b1475defe90bb0fc0ca8d0f2096b0617465cea6568c"); + assertThrows(StatusRuntimeException.class, () -> zksnarkClient.checkZksnarkProof(transaction, b, + 10000L)); + } + +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/BandwidthProcessorTest.java b/framework/src/test/java/org/tron/core/BandwidthProcessorTest.java index 300c202e11a..1faa70d59ee 100755 --- a/framework/src/test/java/org/tron/core/BandwidthProcessorTest.java +++ b/framework/src/test/java/org/tron/core/BandwidthProcessorTest.java @@ -1,7 +1,10 @@ package org.tron.core; +import static org.junit.Assert.assertThrows; + import com.google.protobuf.Any; import com.google.protobuf.ByteString; +import java.nio.charset.StandardCharsets; import lombok.extern.slf4j.Slf4j; import org.joda.time.DateTime; import org.junit.Assert; @@ -19,10 +22,16 @@ import org.tron.core.db.TransactionTrace; import org.tron.core.exception.AccountResourceInsufficientException; import org.tron.core.exception.ContractValidateException; +import org.tron.core.exception.TooBigTransactionException; import org.tron.core.exception.TooBigTransactionResultException; import org.tron.core.store.StoreFactory; import org.tron.protos.Protocol; import org.tron.protos.Protocol.AccountType; +import org.tron.protos.Protocol.Transaction; +import org.tron.protos.Protocol.Transaction.Contract; +import org.tron.protos.Protocol.Transaction.Contract.ContractType; +import org.tron.protos.Protocol.Transaction.Result; +import org.tron.protos.Protocol.Transaction.raw; import org.tron.protos.contract.AssetIssueContractOuterClass.AssetIssueContract; import org.tron.protos.contract.AssetIssueContractOuterClass.TransferAssetContract; import org.tron.protos.contract.BalanceContract.TransferContract; @@ -539,6 +548,32 @@ public void testUsingFee() throws Exception { dbManager.consumeBandwidth(trx, trace); } + @Test + public void testConsumeBandwidthTooBigTransactionResultException() { + TransferContract transferContract = + TransferContract.newBuilder() + .setAmount(10) + .setOwnerAddress(ByteString.copyFromUtf8("aaa")) + .setToAddress(ByteString.copyFromUtf8("bbb")) + .build(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 6666; i++) { + sb.append("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + } + Transaction transaction = Transaction.newBuilder().setRawData(raw.newBuilder() + .setData(ByteString.copyFrom(sb.toString().getBytes(StandardCharsets.UTF_8))) + .addContract(Contract.newBuilder().setParameter(Any.pack(transferContract)) + .setType(ContractType.TransferContract))) + .addRet(Result.newBuilder().setAssetIssueID(sb.toString()).build()).build(); + TransactionCapsule trx = new TransactionCapsule(transaction); + trx.setInBlock(false); + TransactionTrace trace = new TransactionTrace(trx, StoreFactory + .getInstance(), new RuntimeImpl()); + assertThrows( + "Too big transaction result, TxId %s, the result size is %d bytes, maxResultSize %d", + TooBigTransactionResultException.class, () -> dbManager.consumeBandwidth(trx, trace)); + } + /** * sameTokenName close, consume success assetIssueCapsule.getOwnerAddress() != * fromAccount.getAddress()) contract.getType() = TransferAssetContract @@ -646,6 +681,8 @@ public void sameTokenNameCloseConsumeSuccess() { Assert.assertFalse(e instanceof TooBigTransactionResultException); } catch (AccountResourceInsufficientException e) { Assert.assertFalse(e instanceof AccountResourceInsufficientException); + } catch (TooBigTransactionException e) { + Assert.fail(); } finally { chainBaseManager.getAccountStore().delete(ByteArray.fromHexString(OWNER_ADDRESS)); chainBaseManager.getAccountStore().delete(ByteArray.fromHexString(TO_ADDRESS)); @@ -752,6 +789,8 @@ public void sameTokenNameOpenConsumeSuccess() { Assert.assertFalse(e instanceof TooBigTransactionResultException); } catch (AccountResourceInsufficientException e) { Assert.assertFalse(e instanceof AccountResourceInsufficientException); + } catch (TooBigTransactionException e) { + Assert.fail(); } finally { chainBaseManager.getAccountStore().delete(ByteArray.fromHexString(OWNER_ADDRESS)); chainBaseManager.getAccountStore().delete(ByteArray.fromHexString(TO_ADDRESS)); @@ -821,6 +860,8 @@ public void sameTokenNameCloseTransferToAccountNotExist() { Assert.assertFalse(e instanceof TooBigTransactionResultException); } catch (AccountResourceInsufficientException e) { Assert.assertFalse(e instanceof AccountResourceInsufficientException); + } catch (TooBigTransactionException e) { + Assert.fail(); } finally { chainBaseManager.getAccountStore().delete(ByteArray.fromHexString(OWNER_ADDRESS)); chainBaseManager.getAccountStore().delete(ByteArray.fromHexString(TO_ADDRESS)); diff --git a/framework/src/test/java/org/tron/core/CoreExceptionTest.java b/framework/src/test/java/org/tron/core/CoreExceptionTest.java new file mode 100644 index 00000000000..89feaba338c --- /dev/null +++ b/framework/src/test/java/org/tron/core/CoreExceptionTest.java @@ -0,0 +1,1161 @@ +package org.tron.core; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.tron.core.exception.BadBlockException.TypeEnum.CALC_MERKLE_ROOT_FAILED; +import static org.tron.core.exception.BadBlockException.TypeEnum.DEFAULT; +import static org.tron.core.exception.P2pException.TypeEnum.NO_SUCH_MESSAGE; +import static org.tron.core.exception.P2pException.TypeEnum.PARSE_MESSAGE_FAILED; +import static org.tron.core.exception.P2pException.TypeEnum.SYNC_FAILED; + +import org.junit.Test; +import org.tron.common.error.TronDBException; +import org.tron.core.exception.AccountResourceInsufficientException; +import org.tron.core.exception.BadBlockException; +import org.tron.core.exception.BadItemException; +import org.tron.core.exception.BadNumberBlockException; +import org.tron.core.exception.BadTransactionException; +import org.tron.core.exception.BalanceInsufficientException; +import org.tron.core.exception.CancelException; +import org.tron.core.exception.CipherException; +import org.tron.core.exception.ContractExeException; +import org.tron.core.exception.ContractSizeNotEqualToOneException; +import org.tron.core.exception.ContractValidateException; +import org.tron.core.exception.DupTransactionException; +import org.tron.core.exception.EventBloomException; +import org.tron.core.exception.HeaderNotFound; +import org.tron.core.exception.HighFreqException; +import org.tron.core.exception.ItemNotFoundException; +import org.tron.core.exception.JsonRpcInternalException; +import org.tron.core.exception.JsonRpcInvalidParamsException; +import org.tron.core.exception.JsonRpcInvalidRequestException; +import org.tron.core.exception.JsonRpcMethodNotFoundException; +import org.tron.core.exception.JsonRpcTooManyResultException; +import org.tron.core.exception.NonCommonBlockException; +import org.tron.core.exception.NonUniqueObjectException; +import org.tron.core.exception.P2pException; +import org.tron.core.exception.PermissionException; +import org.tron.core.exception.ReceiptCheckErrException; +import org.tron.core.exception.RevokingStoreIllegalStateException; +import org.tron.core.exception.SignatureFormatException; +import org.tron.core.exception.StoreException; +import org.tron.core.exception.TaposException; +import org.tron.core.exception.TooBigTransactionException; +import org.tron.core.exception.TooBigTransactionResultException; +import org.tron.core.exception.TraitorPeerException; +import org.tron.core.exception.TransactionExpirationException; +import org.tron.core.exception.TronRuntimeException; +import org.tron.core.exception.TypeMismatchNamingException; +import org.tron.core.exception.UnLinkedBlockException; +import org.tron.core.exception.UnReachBlockException; +import org.tron.core.exception.VMIllegalException; +import org.tron.core.exception.ValidateScheduleException; +import org.tron.core.exception.ValidateSignatureException; +import org.tron.core.exception.ZkProofValidateException; +import org.tron.core.exception.ZksnarkException; + +public class CoreExceptionTest { + + @Test + public void testAccountResourceInsufficientExceptionMessage() { + String expectedMessage = "Account resources are insufficient"; + AccountResourceInsufficientException exception = + new AccountResourceInsufficientException(expectedMessage); + + assertEquals(expectedMessage, exception.getMessage()); + } + + @Test + public void testBadBlockExceptionWithNoMessageAndDefaultType() { + BadBlockException exception = new BadBlockException(); + + assertNull(exception.getMessage()); + + assertEquals(DEFAULT, exception.getType()); + } + + @Test + public void testBadBlockExceptionWithMessageAndDefaultType() { + String testMessage = "Block is bad due to some reason"; + + BadBlockException exception = new BadBlockException(testMessage); + + assertEquals(testMessage, exception.getMessage()); + + assertEquals(DEFAULT, exception.getType()); + } + + @Test + public void testBadBlockExceptionWithSpecificTypeAndMessage() { + String testMessage = "Failed to calculate Merkle root"; + + BadBlockException exception = new BadBlockException(CALC_MERKLE_ROOT_FAILED, testMessage); + + assertEquals(testMessage, exception.getMessage()); + + assertEquals(CALC_MERKLE_ROOT_FAILED, exception.getType()); + } + + @Test + public void testTypeEnumValues() { + assertEquals(Integer.valueOf(1), CALC_MERKLE_ROOT_FAILED.getValue()); + + assertEquals(Integer.valueOf(100), DEFAULT.getValue()); + } + + @Test + public void testBadItemExceptionDefaultConstructor() { + BadItemException exception = new BadItemException(); + assertNotNull(exception); + } + + @Test + public void testBadItemExceptionMessageConstructor() { + String expectedMessage = "This item is bad!"; + BadItemException exception = new BadItemException(expectedMessage); + assertEquals(expectedMessage, exception.getMessage()); + assertNull(exception.getCause()); + assertNotNull(exception); + } + + @Test + public void testBadItemExceptionMessageAndCauseConstructor() { + String expectedMessage = "This item is really bad!"; + Throwable expectedCause = new Throwable("Some underlying cause"); + BadItemException exception = new BadItemException(expectedMessage, expectedCause); + assertEquals(expectedMessage, exception.getMessage()); + assertEquals(expectedCause, exception.getCause()); + assertNotNull(exception); + } + + @Test + public void testBadNumberBlockExceptionDefaultConstructor() { + BadNumberBlockException exception = new BadNumberBlockException(); + assertNull(exception.getMessage()); + assertNotNull(exception); + } + + @Test + public void testBadNumberBlockExceptionMessageConstructor() { + String expectedMessage = "Number block is bad!"; + BadNumberBlockException exception = new BadNumberBlockException(expectedMessage); + assertEquals(expectedMessage, exception.getMessage()); + assertNotNull(exception); + } + + @Test + public void testBadTransactionExceptionDefaultConstructor() { + BadTransactionException exception = new BadTransactionException(); + assertNull(exception.getMessage()); + assertNull(exception.getCause()); + assertNotNull(exception); + } + + @Test + public void testBadTransactionExceptionMessageConstructor() { + String expectedMessage = "Transaction is bad!"; + BadTransactionException exception = new BadTransactionException(expectedMessage); + + assertEquals(expectedMessage, exception.getMessage()); + + assertNull(exception.getCause()); + + assertNotNull(exception); + } + + @Test + public void testBadTransactionExceptionMessageAndCauseConstructor() { + String expectedMessage = "Transaction failed due to an error"; + Throwable cause = new IllegalArgumentException("Invalid transaction data"); + + BadTransactionException exception = new BadTransactionException(expectedMessage, cause); + + assertEquals(expectedMessage, exception.getMessage()); + + assertEquals(cause, exception.getCause()); + + assertNotNull(exception); + } + + @Test + public void testBalanceInsufficientExceptionWithNoMessage() { + BalanceInsufficientException exception = new BalanceInsufficientException(); + assertNull(exception.getMessage()); + } + + @Test + public void testBalanceInsufficientExceptionWithMessage() { + String testMessage = "Balance is insufficient for this transaction"; + BalanceInsufficientException exception = new BalanceInsufficientException(testMessage); + assertEquals(testMessage, exception.getMessage()); + } + + @Test + public void testCancelExceptionWithNoMessage() { + CancelException exception = new CancelException(); + + assertNull(exception.getMessage()); + } + + @Test + public void testCancelExceptionWithMessage() { + String testMessage = "Operation canceled by user"; + + CancelException exception = new CancelException(testMessage); + + assertEquals(testMessage, exception.getMessage()); + } + + @Test + public void testCipherExceptionWithMessage() { + String testMessage = "Cipher operation failed"; + + CipherException exception = new CipherException(testMessage); + + assertEquals(testMessage, exception.getMessage()); + + assertNull(exception.getCause()); + } + + @Test + public void testCipherExceptionWithCause() { + Throwable testCause = new Throwable("Underlying error"); + + CipherException exception = new CipherException(testCause); + + assertSame(testCause, exception.getCause()); + + } + + @Test + public void testCipherExceptionWithMessageAndCause() { + String testMessage = "Cipher operation failed due to error"; + + Throwable testCause = new Throwable("Underlying error"); + CipherException exception = new CipherException(testMessage, testCause); + + assertEquals(testMessage, exception.getMessage()); + + assertSame(testCause, exception.getCause()); + } + + @Test + public void testContractExeExceptionWithNoMessage() { + ContractExeException exception = new ContractExeException(); + + assertNull(exception.getMessage()); + } + + @Test + public void testContractExeExceptionWithMessage() { + String testMessage = "Contract execution failed"; + + ContractExeException exception = new ContractExeException(testMessage); + + assertEquals(testMessage, exception.getMessage()); + } + + @Test + public void testContractSizeNotEqualToOneExceptionWithNoMessage() { + ContractSizeNotEqualToOneException exception = new ContractSizeNotEqualToOneException(); + + assertNull(exception.getMessage()); + } + + @Test + public void testContractSizeNotEqualToOneExceptionWithMessage() { + String testMessage = "Contract size is not equal to one"; + + ContractSizeNotEqualToOneException exception = + new ContractSizeNotEqualToOneException(testMessage); + + assertEquals(testMessage, exception.getMessage()); + } + + @Test + public void testContractValidateExceptionWithNoMessageOrThrowable() { + ContractValidateException exception = new ContractValidateException(); + + assertNull(exception.getMessage()); + + assertNull(exception.getCause()); + } + + @Test + public void testContractValidateExceptionWithMessage() { + String testMessage = "Contract validation failed"; + + ContractValidateException exception = new ContractValidateException(testMessage); + + assertEquals(testMessage, exception.getMessage()); + + assertNull(exception.getCause()); + } + + @Test + public void testContractValidateExceptionWithMessageAndThrowable() { + String testMessage = "Contract validation failed due to internal error"; + + Throwable cause = new RuntimeException("Internal error"); + + ContractValidateException exception = new ContractValidateException(testMessage, cause); + + assertEquals(testMessage, exception.getMessage()); + + assertSame(cause, exception.getCause()); + } + + @Test + public void testDupTransactionExceptionDefaultConstructor() { + DupTransactionException exception = new DupTransactionException(); + + assertNotNull(exception); + + } + + @Test + public void testDupTransactionExceptionMessageConstructor() { + String testMessage = "Duplicate Transaction Exception"; + DupTransactionException exception = new DupTransactionException(testMessage); + + assertNotNull(exception); + + assertEquals(testMessage, exception.getMessage()); + } + + @Test + public void testEventBloomExceptionDefaultConstructor() { + EventBloomException exception = new EventBloomException(); + + assertNotNull(exception); + + assertNull(exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testEventBloomExceptionMessageConstructor() { + String testMessage = "Event Bloom Exception occurred"; + EventBloomException exception = new EventBloomException(testMessage); + + assertNotNull(exception); + + assertEquals(testMessage, exception.getMessage()); + + assertNull(exception.getCause()); + } + + @Test + public void testEventBloomExceptionMessageAndCauseConstructor() { + String testMessage = "Event Bloom Exception with cause"; + Throwable testCause = new Throwable("Root cause"); + EventBloomException exception = new EventBloomException(testMessage, testCause); + + assertNotNull(exception); + + assertEquals(testMessage, exception.getMessage()); + + assertEquals(testCause, exception.getCause()); + } + + @Test + public void testHeaderNotFoundDefaultConstructor() { + HeaderNotFound exception = new HeaderNotFound(); + + assertNotNull(exception); + + assertNull(exception.getMessage()); + } + + @Test + public void testHeaderNotFoundMessageConstructor() { + String testMessage = "Header not found"; + HeaderNotFound exception = new HeaderNotFound(testMessage); + + assertNotNull(exception); + + assertEquals(testMessage, exception.getMessage()); + } + + @Test + public void testHighFreqExceptionDefaultConstructor() { + HighFreqException exception = new HighFreqException(); + + assertNotNull("Exception object should not be null", exception); + + assertNull("Exception message should be null", exception.getMessage()); + } + + @Test + public void testHighFreqExceptionMessageConstructor() { + String testMessage = "High frequency error occurred"; + HighFreqException exception = new HighFreqException(testMessage); + + assertNotNull("Exception object should not be null", exception); + + assertEquals("Exception message should match the provided message", + testMessage, exception.getMessage()); + } + + @Test + public void testItemNotFoundExceptionWithMessage() { + String testMessage = "Item not found"; + ItemNotFoundException exception = new ItemNotFoundException(testMessage); + + assertNotNull("Exception object should not be null", exception); + assertEquals("Exception message should match the provided message", testMessage, + exception.getMessage()); + assertNull("Cause should be null when not provided", exception.getCause()); + } + + @Test + public void testItemNotFoundExceptionDefaultConstructor() { + ItemNotFoundException exception = new ItemNotFoundException(); + + assertNotNull("Exception object should not be null", exception); + assertNull("Exception message should be null when no message is provided", + exception.getMessage()); + assertNull("Cause should be null when not provided", exception.getCause()); + } + + @Test + public void testItemNotFoundExceptionWithMessageAndCause() { + String testMessage = "Item not found in database"; + Throwable testCause = new Throwable("Database error"); + ItemNotFoundException exception = new ItemNotFoundException(testMessage, testCause); + + assertNotNull("Exception object should not be null", exception); + assertEquals("Exception message should match the provided message", + testMessage, exception.getMessage()); + assertEquals("Cause should match the provided Throwable", testCause, exception.getCause()); + } + + @Test + public void testJsonRpcInternalExceptionDefaultConstructor() { + JsonRpcInternalException exception = new JsonRpcInternalException(); + + assertNotNull("Exception object should not be null", exception); + assertNull("Exception message should be null when no message is provided", + exception.getMessage()); + assertNull("Cause should be null when not provided", exception.getCause()); + } + + @Test + public void testJsonRpcInternalExceptionWithMessage() { + String testMessage = "Internal JSON-RPC error occurred"; + JsonRpcInternalException exception = new JsonRpcInternalException(testMessage); + + assertNotNull("Exception object should not be null", exception); + assertEquals("Exception message should match the provided message", testMessage, + exception.getMessage()); + assertNull("Cause should be null when not provided", exception.getCause()); + } + + @Test + public void testJsonRpcInternalExceptionWithMessageAndCause() { + String testMessage = "Internal JSON-RPC processing failed"; + Throwable testCause = new Throwable("Underlying system error"); + JsonRpcInternalException exception = new JsonRpcInternalException(testMessage, testCause); + + assertNotNull("Exception object should not be null", exception); + assertEquals("Exception message should match the provided message", + testMessage, exception.getMessage()); + assertEquals("Cause should match the provided Throwable", testCause, exception.getCause()); + } + + @Test + public void testJsonRpcInvalidParamsExceptionDefaultConstructor() { + JsonRpcInvalidParamsException exception = new JsonRpcInvalidParamsException(); + + assertNotNull("Exception object should not be null", exception); + assertNull("Exception message should be null when no message is provided", + exception.getMessage()); + assertNull("Cause should be null when not provided", exception.getCause()); + } + + @Test + public void testJsonRpcInvalidParamsExceptionWithMessage() { + String testMessage = "Invalid parameters provided"; + JsonRpcInvalidParamsException exception = new JsonRpcInvalidParamsException(testMessage); + + assertNotNull("Exception object should not be null", exception); + assertEquals("Exception message should match the provided message", + testMessage, exception.getMessage()); + assertNull("Cause should be null when not provided", exception.getCause()); + } + + @Test + public void testJsonRpcInvalidParamsExceptionWithMessageAndCause() { + String testMessage = "Parameter validation failed"; + Throwable testCause = new Throwable("Underlying validation error"); + JsonRpcInvalidParamsException e = new JsonRpcInvalidParamsException(testMessage, testCause); + + assertNotNull("Exception object should not be null", e); + assertEquals("Exception message should match the provided message", testMessage, + e.getMessage()); + assertEquals("Cause should match the provided Throwable", testCause, e.getCause()); + } + + @Test + public void testJsonRpcInvalidRequestExceptionDefaultConstructor() { + JsonRpcInvalidRequestException exception = new JsonRpcInvalidRequestException(); + assertNotNull(exception); + assertNull(exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testJsonRpcInvalidRequestExceptionConstructorWithMessage() { + String testMessage = "Invalid JSON-RPC request"; + JsonRpcInvalidRequestException exception = new JsonRpcInvalidRequestException(testMessage); + assertNotNull(exception); + assertEquals(testMessage, exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testJsonRpcInvalidRequestExceptionConstructorWithMessageAndCause() { + String testMessage = "Invalid JSON-RPC request with cause"; + Throwable testCause = new Throwable("Root cause"); + JsonRpcInvalidRequestException e = new JsonRpcInvalidRequestException(testMessage, testCause); + assertNotNull(e); + assertEquals(testMessage, e.getMessage()); + assertEquals(testCause, e.getCause()); + } + + @Test + public void testJsonRpcMethodNotFoundExceptionDefaultConstructor() { + JsonRpcMethodNotFoundException exception = new JsonRpcMethodNotFoundException(); + assertNotNull(exception); + assertNull(exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testJsonRpcMethodNotFoundExceptionConstructorWithMessage() { + String testMessage = "JSON-RPC method not found"; + JsonRpcMethodNotFoundException exception = new JsonRpcMethodNotFoundException(testMessage); + assertNotNull(exception); + assertEquals(testMessage, exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testJsonRpcMethodNotFoundExceptionConstructorWithMessageAndCause() { + String testMessage = "JSON-RPC method not found with cause"; + Throwable testCause = new Throwable("Root cause"); + JsonRpcMethodNotFoundException e = new JsonRpcMethodNotFoundException(testMessage, testCause); + assertNotNull(e); + assertEquals(testMessage, e.getMessage()); + assertEquals(testCause, e.getCause()); + } + + @Test + public void testJsonRpcTooManyResultExceptionDefaultConstructor() { + JsonRpcTooManyResultException exception = new JsonRpcTooManyResultException(); + assertNotNull("Exception object should not be null", exception); + assertNull(exception.getMessage()); + assertNull("Cause should be null for default constructor", exception.getCause()); + } + + @Test + public void testJsonRpcTooManyResultExceptionWithMessage() { + String testMessage = "Too many results returned by JSON-RPC method"; + JsonRpcTooManyResultException exception = new JsonRpcTooManyResultException(testMessage); + assertNotNull("Exception object should not be null", exception); + assertEquals("Message should match the provided message", testMessage, exception.getMessage()); + assertNull("Cause should be null when only message is provided", exception.getCause()); + } + + @Test + public void testJsonRpcTooManyResultExceptionWithMessageAndCause() { + String testMessage = "Too many results returned with cause"; + Throwable testCause = new Throwable("Root cause"); + JsonRpcTooManyResultException e = new JsonRpcTooManyResultException(testMessage, testCause); + assertNotNull("Exception object should not be null", e); + assertEquals("Message should match the provided message", testMessage, e.getMessage()); + assertEquals("Cause should match the provided cause", testCause, e.getCause()); + } + + @Test + public void testNonCommonBlockExceptionDefaultConstructor() { + NonCommonBlockException exception = new NonCommonBlockException(); + assertNotNull("Exception object should not be null", exception); + assertNull("Message should be null for default constructor", exception.getMessage()); + assertNull("Cause should be null for default constructor", exception.getCause()); + } + + @Test + public void testNonCommonBlockExceptionWithMessage() { + String testMessage = "Block is not common"; + NonCommonBlockException exception = new NonCommonBlockException(testMessage); + assertNotNull("Exception object should not be null", exception); + assertEquals("Message should match the provided message", testMessage, exception.getMessage()); + assertNull("Cause should be null when only message is provided", exception.getCause()); + } + + @Test + public void testNonCommonBlockExceptionWithMessageAndCause() { + String testMessage = "Block is not common due to some error"; + Throwable testCause = new Throwable("Root cause of the error"); + NonCommonBlockException exception = new NonCommonBlockException(testMessage, testCause); + assertNotNull("Exception object should not be null", exception); + assertEquals("Message should match the provided message", testMessage, exception.getMessage()); + assertEquals("Cause should match the provided cause", testCause, exception.getCause()); + } + + @Test + public void testDefaultConstructor() { + NonUniqueObjectException exception = new NonUniqueObjectException(); + assertNotNull("Exception object should not be null", exception); + assertNull("Message should be null for default constructor", exception.getMessage()); + assertNull("Cause should be null for default constructor", exception.getCause()); + } + + @Test + public void testConstructorWithMessage() { + String testMessage = "Object is not unique"; + NonUniqueObjectException exception = new NonUniqueObjectException(testMessage); + assertNotNull("Exception object should not be null", exception); + assertEquals("Message should match the provided message", testMessage, exception.getMessage()); + assertNull("Cause should be null when only message is provided", exception.getCause()); + } + + @Test + public void testConstructorWithMessageAndCause() { + String testMessage = "Object is not unique due to a conflict"; + Throwable testCause = new Throwable("Conflict error"); + NonUniqueObjectException exception = new NonUniqueObjectException(testMessage, testCause); + assertNotNull("Exception object should not be null", exception); + assertEquals("Message should match the provided message", testMessage, exception.getMessage()); + assertEquals("Cause should match the provided cause", testCause, exception.getCause()); + } + + @Test + public void testConstructorWithCauseOnly() { + Throwable testCause = new Throwable("Root cause of non-uniqueness"); + NonUniqueObjectException exception = new NonUniqueObjectException(testCause); + assertNotNull("Exception object should not be null", exception); + assertEquals("Message should be empty string when only cause is provided", "", + exception.getMessage()); + assertEquals("Cause should match the provided cause", testCause, exception.getCause()); + } + + @Test + public void testConstructorWithTypeEnumAndErrMsg() { + P2pException exception = new P2pException(NO_SUCH_MESSAGE, "Test error message"); + assertNotNull("Exception should not be null", exception); + assertEquals("Error message should match", "Test error message", exception.getMessage()); + assertEquals("Exception type should be NO_SUCH_MESSAGE", NO_SUCH_MESSAGE, exception.getType()); + } + + @Test + public void testConstructorWithTypeEnumAndThrowable() { + Throwable cause = new Throwable("Cause of the error"); + P2pException exception = new P2pException(PARSE_MESSAGE_FAILED, cause); + assertNotNull("Exception should not be null", exception); + assertEquals("Cause should match", cause, exception.getCause()); + } + + @Test + public void testConstructorWithTypeEnumErrMsgAndThrowable() { + Throwable cause = new Throwable("Cause of the error"); + P2pException exception = new P2pException(SYNC_FAILED, "Test error message", cause); + assertNotNull("Exception should not be null", exception); + assertEquals("Error message should match", + "Test error message", exception.getMessage()); + assertEquals("Cause should match", cause, exception.getCause()); + assertEquals("Exception type should be SYNC_FAILED", SYNC_FAILED, exception.getType()); + } + + @Test + public void testP2pExceptionTypeEnumValues() { + assertNotNull(NO_SUCH_MESSAGE.toString()); + assertEquals("NO_SUCH_MESSAGE value should be 1", + Integer.valueOf(1), NO_SUCH_MESSAGE.getValue()); + assertEquals("NO_SUCH_MESSAGE desc should be 'no such message'", + "no such message", NO_SUCH_MESSAGE.getDesc()); + + assertEquals("DEFAULT value should be 100", Integer.valueOf(100), + P2pException.TypeEnum.DEFAULT.getValue()); + assertEquals("DEFAULT desc should be 'default exception'", + "default exception", P2pException.TypeEnum.DEFAULT.getDesc()); + } + + @Test + public void testPermissionExceptionDefaultConstructor() { + PermissionException exception = new PermissionException(); + assertNotNull(exception); + } + + @Test + public void testPermissionExceptionWithMessage() { + String errorMessage = "You do not have sufficient permissions to perform this operation"; + PermissionException exception = new PermissionException(errorMessage); + assertNotNull(exception); + assertEquals(errorMessage, exception.getMessage()); + } + + @Test + public void testReceiptCheckErrExceptionDefaultConstructor() { + ReceiptCheckErrException exception = new ReceiptCheckErrException(); + assertNotNull("Exception object should not be null", exception); + assertNull("Message should be null for default constructor", exception.getMessage()); + assertNull("Cause should be null for default constructor", exception.getCause()); + } + + @Test + public void testReceiptCheckErrExceptionConstructorWithMessage() { + String errorMessage = "Receipt check failed due to invalid data"; + ReceiptCheckErrException exception = new ReceiptCheckErrException(errorMessage); + assertNotNull("Exception object should not be null", exception); + assertEquals("Message should match the input message", errorMessage, exception.getMessage()); + assertNull("Cause should be null when only message is provided", exception.getCause()); + } + + @Test + public void testReceiptCheckErrExceptionConstructorWithMessageAndCause() { + String errorMessage = "Receipt check error"; + Throwable cause = new Throwable("Underlying database error"); + ReceiptCheckErrException exception = new ReceiptCheckErrException(errorMessage, cause); + assertNotNull("Exception object should not be null", exception); + assertEquals("Message should match the input message", errorMessage, exception.getMessage()); + assertEquals("Cause should match the input cause", cause, exception.getCause()); + } + + @Test + public void testRevokingStoreIllegalStateExceptionDefaultConstructor() { + RevokingStoreIllegalStateException exception = new RevokingStoreIllegalStateException(); + assertNotNull("Exception should not be null", exception); + assertNull("Message should be null", exception.getMessage()); + assertNull("Cause should be null", exception.getCause()); + } + + @Test + public void testRevokingStoreIllegalStateExceptionConstructorWithMessage() { + String errorMessage = "Invalid state for revoking store"; + RevokingStoreIllegalStateException e = new RevokingStoreIllegalStateException(errorMessage); + assertNotNull("Exception should not be null", e); + assertEquals("Message should match the input message", errorMessage, e.getMessage()); + assertNull("Cause should be null", e.getCause()); + } + + @Test + public void testRevokingStoreIllegalStateExceptionConstructorWithMessageAndCause() { + String errorMessage = "Error occurred during revocation"; + Throwable cause = new Throwable("Database connection failed"); + RevokingStoreIllegalStateException e = + new RevokingStoreIllegalStateException(errorMessage, cause); + assertNotNull("Exception should not be null", e); + assertEquals("Message should match the input message", errorMessage, e.getMessage()); + assertEquals("Cause should match the input cause", cause, e.getCause()); + } + + @Test + public void testRevokingStoreIllegalStateExceptionConstructorWithCauseOnly() { + Throwable cause = new Throwable("Unknown error"); + RevokingStoreIllegalStateException exception = new RevokingStoreIllegalStateException(cause); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should be empty string", "", exception.getMessage()); + assertEquals("Cause should match the input cause", cause, exception.getCause()); + } + + @Test + public void testRevokingStoreIllegalStateExceptionConstructorWithActiveSession() { + int activeSession = 0; + RevokingStoreIllegalStateException e = new RevokingStoreIllegalStateException(activeSession); + assertNotNull("Exception should not be null", e); + assertEquals("Message should indicate activeSession is not greater than 0", + "activeSession 0 has to be greater than 0", e.getMessage()); + } + + @Test + public void testSignatureFormatExceptionDefaultConstructor() { + SignatureFormatException exception = new SignatureFormatException(); + assertNotNull("Exception should not be null", exception); + assertNull("Message should be null", exception.getMessage()); + } + + @Test + public void testSignatureFormatExceptionWithMessage() { + String errorMessage = "Invalid signature format"; + SignatureFormatException exception = new SignatureFormatException(errorMessage); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match the provided error message", + errorMessage, exception.getMessage()); + } + + @Test + public void testStoreExceptionDefaultConstructor() { + StoreException exception = new StoreException(); + assertNotNull("Exception should not be null", exception); + assertNull("Message should be null", exception.getMessage()); + assertNull("Cause should be null", exception.getCause()); + } + + @Test + public void testStoreExceptionWithMessage() { + String errorMessage = "Store error occurred"; + StoreException exception = new StoreException(errorMessage); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match the provided error message", + errorMessage, exception.getMessage()); + assertNull("Cause should be null", exception.getCause()); + } + + @Test + public void testStoreExceptionWithMessageAndCause() { + String errorMessage = "Store error occurred"; + Throwable cause = new Throwable("Root cause"); + StoreException exception = new StoreException(errorMessage, cause); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match the provided error message", + errorMessage, exception.getMessage()); + assertEquals("Cause should match the provided cause", cause, exception.getCause()); + } + + @Test + public void testStoreExceptionWithCause() { + Throwable cause = new Throwable("Root cause"); + StoreException exception = new StoreException(cause); + assertNotNull("Exception should not be null", exception); + } + + + @Test + public void testTaposExceptionDefaultConstructor() { + TaposException exception = new TaposException(); + assertNotNull(exception); + assertNull(exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testTaposExceptionWithMessage() { + String errorMessage = "Tapos error occurred"; + TaposException exception = new TaposException(errorMessage); + assertNotNull(exception); + assertEquals(errorMessage, exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testTaposExceptionWithMessageAndCause() { + String errorMessage = "Tapos error occurred"; + Throwable cause = new Throwable("Root cause"); + TaposException exception = new TaposException(errorMessage, cause); + assertNotNull(exception); + assertEquals(errorMessage, exception.getMessage()); + assertEquals(cause, exception.getCause()); + } + + @Test + public void testTooBigTransactionExceptionDefaultConstructor() { + TooBigTransactionException exception = new TooBigTransactionException(); + assertNotNull(exception); + assertNull(exception.getMessage()); + } + + @Test + public void testTooBigTransactionExceptionWithMessage() { + String errorMessage = "Transaction is too big"; + TooBigTransactionException exception = new TooBigTransactionException(errorMessage); + assertNotNull(exception); + assertEquals(errorMessage, exception.getMessage()); + } + + @Test + public void testTooBigTransactionResultExceptionDefaultConstructor() { + TooBigTransactionResultException exception = new TooBigTransactionResultException(); + assertNotNull(exception); + assertEquals("too big transaction result", + exception.getMessage()); + } + + @Test + public void testTooBigTransactionResultExceptionWithMessage() { + String customMessage = "Custom error message for too big transaction result"; + TooBigTransactionResultException e = new TooBigTransactionResultException(customMessage); + assertNotNull(e); + assertEquals(customMessage, e.getMessage()); + } + + @Test + public void testTraitorPeerExceptionDefaultConstructor() { + TraitorPeerException exception = new TraitorPeerException(); + assertNotNull(exception); + assertNull(exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testTraitorPeerExceptionWithMessage() { + String errorMessage = "Peer is a traitor"; + TraitorPeerException exception = new TraitorPeerException(errorMessage); + assertNotNull(exception); + assertEquals(errorMessage, exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testTraitorPeerExceptionWithMessageAndCause() { + String errorMessage = "Peer is a traitor and caused an error"; + Throwable cause = new Throwable("Underlying cause"); + TraitorPeerException exception = new TraitorPeerException(errorMessage, cause); + assertNotNull(exception); + assertEquals(errorMessage, exception.getMessage()); + assertEquals(cause, exception.getCause()); + } + + @Test + public void testTransactionExpirationExceptionDefaultConstructor() { + TransactionExpirationException exception = new TransactionExpirationException(); + assertNotNull(exception); + assertNull(exception.getMessage()); + } + + @Test + public void testTransactionExpirationExceptionWithMessage() { + String errorMessage = "Transaction has expired"; + TransactionExpirationException exception = new TransactionExpirationException(errorMessage); + assertNotNull(exception); + assertEquals(errorMessage, exception.getMessage()); + } + + @Test + public void testTronRuntimeExceptionDefaultConstructor() { + TronRuntimeException exception = new TronRuntimeException(); + assertNotNull(exception); + assertNull(exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testTronRuntimeExceptionWithMessage() { + String errorMessage = "An error occurred"; + TronRuntimeException exception = new TronRuntimeException(errorMessage); + assertNotNull(exception); + assertEquals(errorMessage, exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testTronRuntimeExceptionWithMessageAndCause() { + String errorMessage = "An error occurred due to a cause"; + Throwable cause = new Throwable("Underlying cause"); + TronRuntimeException exception = new TronRuntimeException(errorMessage, cause); + assertNotNull(exception); + assertEquals(errorMessage, exception.getMessage()); + assertEquals(cause, exception.getCause()); + } + + @Test + public void testTronRuntimeExceptionWithCause() { + Throwable cause = new Throwable("Underlying cause without message"); + TronRuntimeException exception = new TronRuntimeException(cause); + assertEquals(cause, exception.getCause()); + } + + @Test + public void testTypeMismatchNamingException_WithRequiredAndActualTypes() { + try { + throw new TypeMismatchNamingException("someName", String.class, Integer.class); + } catch (TypeMismatchNamingException e) { + assertEquals("Object of type [class java.lang.Integer] available at store location " + + "[someName] is not assignable to [java.lang.String]", e.getMessage()); + assertEquals(String.class, e.getRequiredType()); + assertEquals(Integer.class, e.getActualType()); + } + } + + @Test + public void testTypeMismatchNamingException_WithExplanation() { + try { + throw new TypeMismatchNamingException("Custom explanation"); + } catch (TypeMismatchNamingException e) { + assertEquals("Custom explanation", e.getMessage()); + assertNull(e.getRequiredType()); + assertNull(e.getActualType()); + } + } + + @Test + public void testUnLinkedBlockExceptionDefaultConstructor() { + UnLinkedBlockException exception = new UnLinkedBlockException(); + assertNotNull("Exception should not be null", exception); + assertNull(exception.getMessage()); + assertNull("Cause should be null", exception.getCause()); + } + + @Test + public void testUnLinkedBlockExceptionWithMessage() { + String testMessage = "This block is not linked"; + UnLinkedBlockException exception = new UnLinkedBlockException(testMessage); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match", testMessage, exception.getMessage()); + assertNull("Cause should be null", exception.getCause()); + } + + @Test + public void testUnLinkedBlockExceptionWithMessageAndCause() { + String testMessage = "This block is not linked due to an error"; + Throwable testCause = new Throwable("Cause of the error"); + UnLinkedBlockException exception = new UnLinkedBlockException(testMessage, testCause); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match", testMessage, exception.getMessage()); + assertEquals("Cause should match", testCause, exception.getCause()); + } + + @Test + public void testUnReachBlockExceptionDefaultConstructor() { + UnReachBlockException exception = new UnReachBlockException(); + assertNotNull(exception); + assertNull(exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testUnReachBlockExceptionWithMessage() { + String testMessage = "Block is unreachable"; + UnReachBlockException exception = new UnReachBlockException(testMessage); + assertNotNull(exception); + assertEquals(testMessage, exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + public void testUnReachBlockExceptionWithMessageAndCause() { + String testMessage = "Block is unreachable due to an error"; + Throwable testCause = new Throwable("Cause of the error"); + UnReachBlockException exception = new UnReachBlockException(testMessage, testCause); + assertNotNull(exception); + assertEquals(testCause, exception.getCause()); + } + + @Test + public void testValidateScheduleExceptionDefaultConstructor() { + ValidateScheduleException exception = new ValidateScheduleException(); + + assertNotNull(exception); + + assertNull(exception.getMessage()); + } + + @Test + public void testValidateScheduleExceptionConstructorWithMessage() { + String testMessage = "Schedule validation failed"; + + ValidateScheduleException exception = new ValidateScheduleException(testMessage); + + assertNotNull(exception); + + assertEquals(testMessage, exception.getMessage()); + } + + @Test + public void testValidateSignatureExceptionDefaultConstructor() { + ValidateSignatureException exception = new ValidateSignatureException(); + assertNotNull("Exception should not be null", exception); + assertNull(exception.getMessage()); + } + + @Test + public void testValidateSignatureExceptionConstructorWithMessage() { + String testMessage = "Signature validation failed"; + ValidateSignatureException exception = new ValidateSignatureException(testMessage); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match", testMessage, exception.getMessage()); + } + + @Test + public void testVMIllegalExceptionDefaultConstructor() { + VMIllegalException exception = new VMIllegalException(); + assertNotNull("Exception should not be null", exception); + assertNull(exception.getMessage()); + } + + @Test + public void testVMIllegalExceptionConstructorWithMessage() { + String testMessage = "VM operation is illegal"; + VMIllegalException exception = new VMIllegalException(testMessage); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match", testMessage, exception.getMessage()); + } + + @Test + public void testZkProofValidateExceptionWithFirstValidatedTrue() { + String testMessage = "Zero-knowledge proof validation failed, but first part was validated"; + boolean firstValidated = true; + + ZkProofValidateException exception = new ZkProofValidateException(testMessage, firstValidated); + + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match", testMessage, exception.getMessage()); + assertTrue("firstValidated should be true", exception.isFirstValidated()); + } + + @Test + public void testZkProofValidateExceptionWithFirstValidatedFalse() { + String testMessage = "Zero-knowledge proof validation failed, first part not validated"; + boolean firstValidated = false; + + ZkProofValidateException exception = new ZkProofValidateException(testMessage, firstValidated); + exception.setFirstValidated(true); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match", testMessage, exception.getMessage()); + assertTrue("firstValidated should be true", exception.isFirstValidated()); + } + + @Test + public void testZksnarkExceptionNoMessage() { + ZksnarkException exception = new ZksnarkException(); + assertNotNull("Exception should not be null", exception); + assertNull(exception.getMessage()); + } + + @Test + public void testZksnarkExceptionWithMessage() { + String testMessage = "Zksnark validation failed"; + ZksnarkException exception = new ZksnarkException(testMessage); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match", testMessage, exception.getMessage()); + } + + @Test + public void testTronDBExceptionNoArgs() { + TronDBException exception = new TronDBException(); + assertNotNull("Exception should not be null", exception); + assertNull("Message should be null", exception.getMessage()); + assertNull("Cause should be null", exception.getCause()); + } + + @Test + public void testTronDBExceptionWithMessage() { + String testMessage = "Database error occurred"; + TronDBException exception = new TronDBException(testMessage); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match", testMessage, exception.getMessage()); + assertNull("Cause should be null", exception.getCause()); + } + + @Test + public void testTronDBExceptionWithMessageAndThrowable() { + String testMessage = "Database error with specific cause"; + Throwable testCause = new Throwable("Root cause"); + TronDBException exception = new TronDBException(testMessage, testCause); + assertNotNull("Exception should not be null", exception); + assertEquals("Message should match", testMessage, exception.getMessage()); + assertEquals("Cause should match", testCause, exception.getCause()); + } + + @Test + public void testTronDBExceptionWithThrowable() { + Throwable testCause = new Throwable("Root cause without message"); + TronDBException exception = new TronDBException(testCause); + assertNotNull("Exception should not be null", exception); + assertEquals("Cause should match", testCause, exception.getCause()); + } +} diff --git a/framework/src/test/java/org/tron/core/ForkControllerTest.java b/framework/src/test/java/org/tron/core/ForkControllerTest.java index 74e651b3c1d..0b43db3e534 100644 --- a/framework/src/test/java/org/tron/core/ForkControllerTest.java +++ b/framework/src/test/java/org/tron/core/ForkControllerTest.java @@ -31,7 +31,7 @@ public class ForkControllerTest { @Before public void init() throws IOException { Args.setParam(new String[]{"-d", - temporaryFolder.newFolder().toString(), "-w"}, Constant.TEST_CONF); + temporaryFolder.newFolder().toString()}, Constant.TEST_CONF); context = new TronApplicationContext(DefaultConfig.class); dynamicPropertiesStore = context.getBean(DynamicPropertiesStore.class); chainBaseManager = context.getBean(ChainBaseManager.class); diff --git a/framework/src/test/java/org/tron/core/ShieldWalletTest.java b/framework/src/test/java/org/tron/core/ShieldWalletTest.java index 5bc2a31c9d0..f8d5db1a44c 100644 --- a/framework/src/test/java/org/tron/core/ShieldWalletTest.java +++ b/framework/src/test/java/org/tron/core/ShieldWalletTest.java @@ -19,6 +19,7 @@ import org.tron.core.capsule.TransactionCapsule; import org.tron.core.config.args.Args; import org.tron.core.exception.ContractExeException; +import org.tron.core.exception.ContractValidateException; import org.tron.core.services.http.JsonFormat; import org.tron.core.services.http.JsonFormat.ParseException; @@ -337,6 +338,82 @@ public void testCreateShieldedContractParameters() throws ContractExeException { } } + @Test + public void testCreateShieldedContractParameters2() throws ContractExeException { + librustzcashInitZksnarkParams(); + Args.getInstance().setFullNodeAllowShieldedTransactionArgs(true); + Wallet wallet1 = spy(new Wallet()); + + doReturn(BigInteger.valueOf(1).toByteArray()) + .when(wallet1).getShieldedContractScalingFactor( + ByteArray.fromHexString("4144007979359ECAC395BBD3CEF8060D3DF2DC3F01")); + String parameter = new String(ByteArray.fromHexString( + "7b0a202020202261736b223a2263323531336539653330383439343933326264383265306365353336" + + "363264313734323164393062373261383437316130613132623835353261333336653032222c0a202" + + "02020226e736b223a2234633662663364643461303634336432306236323866376534353938306335" + + "653138376630376135316436663365383661616631616239313663303765623064222c0a202020202" + + "26f766b223a2231376135386439613530353864613665343263613132636432383964306136616131" + + "363962393236633138653139626361353138623864366638363734653433222c0a202020202266726" + + "f6d5f616d6f756e74223a22313030222c0a2020202022736869656c6465645f726563656976657322" + + "3a5b0a20202020202020207b0a202020202020202020202020226e6f7465223a7b0a2020202020202" + + "02020202020202020202276616c7565223a3130302c0a202020202020202020202020202020202270" + + "61796d656e745f61646472657373223a22222c0a202020202020202020202020202020202272636d2" + + "23a223136623666356534303434346162376565616231316165363631336332376633353131373937" + + "3165666138376237313536306235383133383239633933393064220a2020202020202020202020207" + + "d0a20202020202020207d0a202020205d2c0a2020202022736869656c6465645f54524332305f636f" + + "6e74726163745f61646472657373223a2234313434303037393739333539454341433339354242443" + + "3434546383036304433444632444333463031220a7d")); + + PrivateShieldedTRC20Parameters.Builder builder = PrivateShieldedTRC20Parameters.newBuilder(); + try { + JsonFormat.merge(parameter, builder, false); + } catch (ParseException e) { + Assert.fail(); + } + + try { + wallet1.createShieldedContractParameters(builder.build()); + Assert.fail(); + } catch (Exception e) { + Assert.assertTrue(e instanceof ContractValidateException); + Assert.assertEquals("PaymentAddress in ReceiveNote should not be empty", + e.getMessage()); + } + + String parameter2 = new String(ByteArray.fromHexString( + "7b0a202020202261736b223a2263323531336539653330383439343933326264383265306365353336" + + "363264313734323164393062373261383437316130613132623835353261333336653032222c0a202" + + "02020226e736b223a2234633662663364643461303634336432306236323866376534353938306335" + + "653138376630376135316436663365383661616631616239313663303765623064222c0a202020202" + + "26f766b223a2231376135386439613530353864613665343263613132636432383964306136616131" + + "363962393236633138653139626361353138623864366638363734653433222c0a202020202266726" + + "f6d5f616d6f756e74223a22313030222c0a2020202022736869656c6465645f7370656e6473223a5b" + + "0a20202020202020207b0a202020202020202020202020226e6f7465223a7b0a20202020202020202" + + "0202020202020202276616c7565223a3130302c0a2020202020202020202020202020202022706179" + + "6d656e745f61646472657373223a22222c0a202020202020202020202020202020202272636d223a2" + + "231366236663565343034343461623765656162313161653636313363323766333531313739373165" + + "666138376237313536306235383133383239633933393064220a2020202020202020202020207d0a2" + + "0202020202020207d0a202020205d2c0a2020202022736869656c6465645f54524332305f636f6e74" + + "726163745f61646472657373223a22343134343030373937393335394543414333393542424433434" + + "546383036304433444632444333463031220a7d")); + + builder = PrivateShieldedTRC20Parameters.newBuilder(); + try { + JsonFormat.merge(parameter2, builder, false); + } catch (ParseException e) { + Assert.fail(); + } + + try { + wallet1.createShieldedContractParameters(builder.build()); + Assert.fail(); + } catch (Exception e) { + Assert.assertTrue(e instanceof ContractValidateException); + Assert.assertEquals("PaymentAddress in SpendNote should not be empty", + e.getMessage()); + } + } + @Test public void testCreateShieldedContractParametersWithoutAsk() throws ContractExeException { librustzcashInitZksnarkParams(); diff --git a/framework/src/test/java/org/tron/core/ShieldedTRC20BuilderTest.java b/framework/src/test/java/org/tron/core/ShieldedTRC20BuilderTest.java index ff30537ee7a..2c97473b6c3 100644 --- a/framework/src/test/java/org/tron/core/ShieldedTRC20BuilderTest.java +++ b/framework/src/test/java/org/tron/core/ShieldedTRC20BuilderTest.java @@ -2269,7 +2269,7 @@ public void testscanShieldedTRC20NotesByOvk() throws Exception { } } - @Test(expected = IllegalArgumentException.class) + @Test(expected = ZksnarkException.class) public void isShieldedTRC20ContractNoteSpent() throws Exception { int statNum = 9200; int endNum = 9240; diff --git a/framework/src/test/java/org/tron/core/StorageMarketTest.java b/framework/src/test/java/org/tron/core/StorageMarketTest.java deleted file mode 100644 index 8b6e90e1c67..00000000000 --- a/framework/src/test/java/org/tron/core/StorageMarketTest.java +++ /dev/null @@ -1,256 +0,0 @@ -package org.tron.core; - -import static org.tron.core.config.Parameter.ChainConstant.TRANSFER_FEE; - -import com.google.protobuf.Any; -import com.google.protobuf.ByteString; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.tron.common.BaseTest; -import org.tron.common.utils.ByteArray; -import org.tron.core.capsule.AccountCapsule; -import org.tron.core.config.args.Args; -import org.tron.core.db.StorageMarket; -import org.tron.protos.Protocol.AccountType; -import org.tron.protos.contract.StorageContract.BuyStorageContract; - -@Slf4j -public class StorageMarketTest extends BaseTest { - - private static final String OWNER_ADDRESS; - private static final long initBalance = 10_000_000_000_000_000L; - private static StorageMarket storageMarket; - - static { - Args.setParam(new String[]{"--output-directory", dbPath()}, Constant.TEST_CONF); - OWNER_ADDRESS = Wallet.getAddressPreFixString() + "548794500882809695a8a687866e76d4271a1abc"; - } - - /** - * create temp Capsule test need. - */ - @Before - public void createAccountCapsule() { - storageMarket = new StorageMarket(dbManager.getAccountStore(), - dbManager.getDynamicPropertiesStore()); - - AccountCapsule ownerCapsule = - new AccountCapsule( - ByteString.copyFromUtf8("owner"), - ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)), - AccountType.Normal, - initBalance); - dbManager.getAccountStore().put(ownerCapsule.getAddress().toByteArray(), ownerCapsule); - - dbManager.getDynamicPropertiesStore().saveTotalStorageReserved( - 128L * 1024 * 1024 * 1024); - dbManager.getDynamicPropertiesStore().saveTotalStoragePool(100_000_000_000000L); - dbManager.getDynamicPropertiesStore().saveTotalStorageTax(0); - - dbManager.getDynamicPropertiesStore().saveLatestBlockHeaderTimestamp(0); - } - - private Any getContract(String ownerAddress, long quant) { - return Any.pack( - BuyStorageContract.newBuilder() - .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(ownerAddress))) - .setQuant(quant) - .build()); - } - - @Test - public void testBuyStorage() { - long currentPool = dbManager.getDynamicPropertiesStore().getTotalStoragePool(); - long currentReserved = dbManager.getDynamicPropertiesStore().getTotalStorageReserved(); - Assert.assertEquals(currentPool, 100_000_000_000000L); - Assert.assertEquals(currentReserved, 128L * 1024 * 1024 * 1024); - - AccountCapsule owner = - dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS)); - - long quant = 2_000_000_000_000L; // 2 million trx - storageMarket.buyStorage(owner, quant); - - Assert.assertEquals(owner.getBalance(), initBalance - quant - - TRANSFER_FEE); - Assert.assertEquals(2694881440L, owner.getStorageLimit()); - Assert.assertEquals(currentReserved - 2694881440L, - dbManager.getDynamicPropertiesStore().getTotalStorageReserved()); - Assert.assertEquals(currentPool + quant, - dbManager.getDynamicPropertiesStore().getTotalStoragePool()); - - } - - @Test - public void testBuyStorage2() { - long currentPool = dbManager.getDynamicPropertiesStore().getTotalStoragePool(); - long currentReserved = dbManager.getDynamicPropertiesStore().getTotalStorageReserved(); - Assert.assertEquals(currentPool, 100_000_000_000000L); - Assert.assertEquals(currentReserved, 128L * 1024 * 1024 * 1024); - - AccountCapsule owner = - dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS)); - - long quant = 1_000_000_000_000L; // 1 million trx - - storageMarket.buyStorage(owner, quant); - - Assert.assertEquals(owner.getBalance(), initBalance - quant - - TRANSFER_FEE); - Assert.assertEquals(1360781717L, owner.getStorageLimit()); - Assert.assertEquals(currentReserved - 1360781717L, - dbManager.getDynamicPropertiesStore().getTotalStorageReserved()); - Assert.assertEquals(currentPool + quant, - dbManager.getDynamicPropertiesStore().getTotalStoragePool()); - - storageMarket.buyStorage(owner, quant); - - Assert.assertEquals(owner.getBalance(), initBalance - 2 * quant - - TRANSFER_FEE); - Assert.assertEquals(2694881439L, owner.getStorageLimit()); - Assert.assertEquals(currentReserved - 2694881439L, - dbManager.getDynamicPropertiesStore().getTotalStorageReserved()); - Assert.assertEquals(currentPool + 2 * quant, - dbManager.getDynamicPropertiesStore().getTotalStoragePool()); - - } - - - @Test - public void testBuyStorageBytes() { - long currentPool = dbManager.getDynamicPropertiesStore().getTotalStoragePool(); - long currentReserved = dbManager.getDynamicPropertiesStore().getTotalStorageReserved(); - Assert.assertEquals(currentPool, 100_000_000_000000L); - Assert.assertEquals(currentReserved, 128L * 1024 * 1024 * 1024); - - AccountCapsule owner = - dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS)); - - long bytes = 2694881440L; // 2 million trx - storageMarket.buyStorageBytes(owner, bytes); - - Assert.assertEquals(owner.getBalance(), initBalance - 2_000_000_000_000L - - TRANSFER_FEE); - Assert.assertEquals(bytes, owner.getStorageLimit()); - Assert.assertEquals(currentReserved - bytes, - dbManager.getDynamicPropertiesStore().getTotalStorageReserved()); - Assert.assertEquals(currentPool + 2_000_000_000_000L, - dbManager.getDynamicPropertiesStore().getTotalStoragePool()); - - } - - @Test - public void testBuyStorageBytes2() { - long currentPool = dbManager.getDynamicPropertiesStore().getTotalStoragePool(); - long currentReserved = dbManager.getDynamicPropertiesStore().getTotalStorageReserved(); - Assert.assertEquals(currentPool, 100_000_000_000000L); - Assert.assertEquals(currentReserved, 128L * 1024 * 1024 * 1024); - - AccountCapsule owner = - dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS)); - - long bytes1 = 1360781717L; - - storageMarket.buyStorageBytes(owner, bytes1); - - Assert.assertEquals(owner.getBalance(), initBalance - 1_000_000_000_000L - - TRANSFER_FEE); - Assert.assertEquals(bytes1, owner.getStorageLimit()); - Assert.assertEquals(currentReserved - bytes1, - dbManager.getDynamicPropertiesStore().getTotalStorageReserved()); - Assert.assertEquals(currentPool + 1_000_000_000_000L, - dbManager.getDynamicPropertiesStore().getTotalStoragePool()); - - long bytes2 = 1334099723L; - storageMarket.buyStorageBytes(owner, bytes2); - Assert.assertEquals(owner.getBalance(), initBalance - 2 * 1_000_000_000_000L - - TRANSFER_FEE); - Assert.assertEquals(bytes1 + bytes2, owner.getStorageLimit()); - Assert.assertEquals(currentReserved - (bytes1 + bytes2), - dbManager.getDynamicPropertiesStore().getTotalStorageReserved()); - Assert.assertEquals(currentPool + 2 * 1_000_000_000_000L, - dbManager.getDynamicPropertiesStore().getTotalStoragePool()); - - } - - @Test - public void testSellStorage() { - long currentPool = dbManager.getDynamicPropertiesStore().getTotalStoragePool(); - long currentReserved = dbManager.getDynamicPropertiesStore().getTotalStorageReserved(); - Assert.assertEquals(currentPool, 100_000_000_000000L); - Assert.assertEquals(currentReserved, 128L * 1024 * 1024 * 1024); - - AccountCapsule owner = - dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS)); - - long quant = 2_000_000_000_000L; // 2 million trx - storageMarket.buyStorage(owner, quant); - - Assert.assertEquals(owner.getBalance(), initBalance - quant - - TRANSFER_FEE); - Assert.assertEquals(2694881440L, owner.getStorageLimit()); - Assert.assertEquals(currentReserved - 2694881440L, - dbManager.getDynamicPropertiesStore().getTotalStorageReserved()); - Assert.assertEquals(currentPool + quant, - dbManager.getDynamicPropertiesStore().getTotalStoragePool()); - - long bytes = 2694881440L; - storageMarket.sellStorage(owner, bytes); - - Assert.assertEquals(owner.getBalance(), initBalance); - Assert.assertEquals(0, owner.getStorageLimit()); - Assert.assertEquals(currentReserved, - dbManager.getDynamicPropertiesStore().getTotalStorageReserved()); - Assert.assertEquals(100_000_000_000_000L, - dbManager.getDynamicPropertiesStore().getTotalStoragePool()); - - } - - @Test - public void testSellStorage2() { - long currentPool = dbManager.getDynamicPropertiesStore().getTotalStoragePool(); - long currentReserved = dbManager.getDynamicPropertiesStore().getTotalStorageReserved(); - Assert.assertEquals(currentPool, 100_000_000_000000L); - Assert.assertEquals(currentReserved, 128L * 1024 * 1024 * 1024); - - AccountCapsule owner = - dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS)); - - long quant = 2_000_000_000_000L; // 2 million trx - storageMarket.buyStorage(owner, quant); - - Assert.assertEquals(owner.getBalance(), initBalance - quant - - TRANSFER_FEE); - Assert.assertEquals(2694881440L, owner.getStorageLimit()); - Assert.assertEquals(currentReserved - 2694881440L, - dbManager.getDynamicPropertiesStore().getTotalStorageReserved()); - Assert.assertEquals(currentPool + quant, - dbManager.getDynamicPropertiesStore().getTotalStoragePool()); - - long bytes1 = 2694881440L - 1360781717L; // 1 million trx - long bytes2 = 1360781717L; // 1 million trx - - storageMarket.sellStorage(owner, bytes1); - - Assert.assertEquals(owner.getBalance(), initBalance - 1_000_000_000_000L); - Assert.assertEquals(1360781717L, owner.getStorageLimit()); - Assert.assertEquals(currentReserved - 1360781717L, - dbManager.getDynamicPropertiesStore().getTotalStorageReserved()); - Assert.assertEquals(currentPool + 1_000_000_000_000L, - dbManager.getDynamicPropertiesStore().getTotalStoragePool()); - - storageMarket.sellStorage(owner, bytes2); - - Assert.assertEquals(owner.getBalance(), initBalance); - Assert.assertEquals(0, owner.getStorageLimit()); - Assert.assertEquals(currentReserved, - dbManager.getDynamicPropertiesStore().getTotalStorageReserved()); - Assert.assertEquals(currentPool, - dbManager.getDynamicPropertiesStore().getTotalStoragePool()); - - } - - -} diff --git a/framework/src/test/java/org/tron/core/WalletMockTest.java b/framework/src/test/java/org/tron/core/WalletMockTest.java new file mode 100644 index 00000000000..098ba9aee61 --- /dev/null +++ b/framework/src/test/java/org/tron/core/WalletMockTest.java @@ -0,0 +1,1322 @@ +package org.tron.core; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockConstruction; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.when; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.LazyStringArrayList; +import com.google.protobuf.ProtocolStringList; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockedConstruction; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.tron.api.GrpcAPI; +import org.tron.common.parameter.CommonParameter; +import org.tron.common.utils.ByteUtil; +import org.tron.common.utils.Sha256Hash; +import org.tron.common.utils.client.WalletClient; +import org.tron.core.capsule.AccountCapsule; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.capsule.ContractCapsule; +import org.tron.core.capsule.ContractStateCapsule; +import org.tron.core.capsule.TransactionCapsule; +import org.tron.core.config.args.Args; +import org.tron.core.db.Manager; +import org.tron.core.db.TransactionStore; +import org.tron.core.exception.AccountResourceInsufficientException; +import org.tron.core.exception.BadItemException; +import org.tron.core.exception.ContractExeException; +import org.tron.core.exception.ContractValidateException; +import org.tron.core.exception.DupTransactionException; +import org.tron.core.exception.HeaderNotFound; +import org.tron.core.exception.ItemNotFoundException; +import org.tron.core.exception.TaposException; +import org.tron.core.exception.TooBigTransactionException; +import org.tron.core.exception.TronException; +import org.tron.core.exception.VMIllegalException; +import org.tron.core.exception.ValidateSignatureException; +import org.tron.core.exception.ZksnarkException; +import org.tron.core.net.TronNetDelegate; +import org.tron.core.net.message.adv.TransactionMessage; +import org.tron.core.net.peer.PeerConnection; +import org.tron.core.store.AbiStore; +import org.tron.core.store.AccountStore; +import org.tron.core.store.CodeStore; +import org.tron.core.store.ContractStateStore; +import org.tron.core.store.ContractStore; +import org.tron.core.store.DynamicPropertiesStore; +import org.tron.core.store.TransactionHistoryStore; +import org.tron.core.store.TransactionRetStore; +import org.tron.core.zen.ShieldedTRC20ParametersBuilder; +import org.tron.core.zen.address.DiversifierT; +import org.tron.core.zen.address.ExpandedSpendingKey; +import org.tron.core.zen.address.KeyIo; +import org.tron.core.zen.address.PaymentAddress; +import org.tron.protos.Protocol; +import org.tron.protos.contract.BalanceContract; +import org.tron.protos.contract.ShieldContract; +import org.tron.protos.contract.SmartContractOuterClass; + + +public class WalletMockTest { + + @Before + public void init() { + CommonParameter.PARAMETER.setMinEffectiveConnection(0); + } + + @After + public void clearMocks() { + Mockito.clearAllCaches(); + } + + @Test + public void testSetTransactionNullException() throws Exception { + Wallet wallet = new Wallet(); + TransactionCapsule transactionCapsuleMock + = mock(TransactionCapsule.class); + + Method privateMethod = Wallet.class.getDeclaredMethod( + "setTransaction", TransactionCapsule.class); + privateMethod.setAccessible(true); + privateMethod.invoke(wallet, transactionCapsuleMock); + } + + @Test + public void testCreateTransactionCapsuleWithoutValidateWithTimeoutNullException() + throws Exception { + Wallet wallet = new Wallet(); + com.google.protobuf.Message message = + mock(com.google.protobuf.Message.class); + Protocol.Transaction.Contract.ContractType contractType = + mock(Protocol.Transaction.Contract.ContractType.class); + long timeout = 100L; + + try (MockedConstruction mocked = mockConstruction(TransactionCapsule.class, + (mock, context) -> { + when(mock.getInstance()).thenReturn(Protocol.Transaction.newBuilder().build()); + })) { + Method privateMethod = Wallet.class.getDeclaredMethod( + "createTransactionCapsuleWithoutValidateWithTimeout", + com.google.protobuf.Message.class, + Protocol.Transaction.Contract.ContractType.class, + long.class); + privateMethod.setAccessible(true); + privateMethod.invoke(wallet, message, contractType, timeout); + } + } + + @Test + public void testCreateTransactionCapsuleWithoutValidateWithTimeout() + throws Exception { + Wallet wallet = new Wallet(); + com.google.protobuf.Message message = + mock(com.google.protobuf.Message.class); + Protocol.Transaction.Contract.ContractType contractType = + mock(Protocol.Transaction.Contract.ContractType.class); + long timeout = 100L; + BlockCapsule.BlockId blockId = new BlockCapsule.BlockId(); + + try (MockedConstruction mocked = mockConstruction(TransactionCapsule.class, + (mock, context) -> { + when(mock.getInstance()).thenReturn(Protocol.Transaction.newBuilder().build()); + })) { + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + + when(chainBaseManagerMock.getHeadBlockId()).thenReturn(blockId); + + Method privateMethod = Wallet.class.getDeclaredMethod( + "createTransactionCapsuleWithoutValidateWithTimeout", + com.google.protobuf.Message.class, + Protocol.Transaction.Contract.ContractType.class, + long.class); + privateMethod.setAccessible(true); + privateMethod.invoke(wallet, message, contractType, timeout); + } + } + + + @Test + public void testBroadcastTransactionBlockUnsolidified() throws Exception { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + + TronNetDelegate tronNetDelegateMock = mock(TronNetDelegate.class); + when(tronNetDelegateMock.isBlockUnsolidified()).thenReturn(true); + + Field field = wallet.getClass().getDeclaredField("tronNetDelegate"); + field.setAccessible(true); + field.set(wallet, tronNetDelegateMock); + + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + + assertEquals(GrpcAPI.Return.response_code.BLOCK_UNSOLIDIFIED, ret.getCode()); + } + + @Test + public void testBroadcastTransactionNoConnection() throws Exception { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + List peerConnections = new ArrayList<>(); + + TronNetDelegate tronNetDelegateMock = mock(TronNetDelegate.class); + when(tronNetDelegateMock.isBlockUnsolidified()).thenReturn(false); + + Field field = wallet.getClass().getDeclaredField("tronNetDelegate"); + field.setAccessible(true); + field.set(wallet, tronNetDelegateMock); + + Field field2 = wallet.getClass().getDeclaredField("minEffectiveConnection"); + field2.setAccessible(true); + field2.set(wallet, 10); + + when(tronNetDelegateMock.getActivePeer()).thenReturn(peerConnections); + + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + + assertEquals(GrpcAPI.Return.response_code.NO_CONNECTION, ret.getCode()); + } + + @Test + public void testBroadcastTransactionConnectionNotEnough() throws Exception { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + List peerConnections = new ArrayList<>(); + PeerConnection p1 = new PeerConnection(); + PeerConnection p2 = new PeerConnection(); + peerConnections.add(p1); + peerConnections.add(p2); + + TronNetDelegate tronNetDelegateMock = mock(TronNetDelegate.class); + when(tronNetDelegateMock.isBlockUnsolidified()).thenReturn(false); + + Field field = wallet.getClass().getDeclaredField("tronNetDelegate"); + field.setAccessible(true); + field.set(wallet, tronNetDelegateMock); + + Field field2 = wallet.getClass().getDeclaredField("minEffectiveConnection"); + field2.setAccessible(true); + field2.set(wallet, 10); + when(tronNetDelegateMock.getActivePeer()).thenReturn(peerConnections); + + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + + assertEquals(GrpcAPI.Return.response_code.NOT_ENOUGH_EFFECTIVE_CONNECTION, + ret.getCode()); + } + + @Test + public void testBroadcastTransactionTooManyPending() throws Exception { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + + TronNetDelegate tronNetDelegateMock = mock(TronNetDelegate.class); + Manager managerMock = mock(Manager.class); + when(tronNetDelegateMock.isBlockUnsolidified()).thenReturn(false); + when(managerMock.isTooManyPending()).thenReturn(true); + + Field field = wallet.getClass().getDeclaredField("tronNetDelegate"); + field.setAccessible(true); + field.set(wallet, tronNetDelegateMock); + + Field field2 = wallet.getClass().getDeclaredField("dbManager"); + field2.setAccessible(true); + field2.set(wallet, managerMock); + + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + + assertEquals(GrpcAPI.Return.response_code.SERVER_BUSY, ret.getCode()); + } + + @Test + public void testBroadcastTransactionAlreadyExists() throws Exception { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + TransactionCapsule trx = new TransactionCapsule(transaction); + trx.setTime(System.currentTimeMillis()); + Sha256Hash txID = trx.getTransactionId(); + + Cache transactionIdCache = CacheBuilder + .newBuilder().maximumSize(10) + .expireAfterWrite(1, TimeUnit.HOURS).recordStats().build(); + transactionIdCache.put(txID, true); + + TronNetDelegate tronNetDelegateMock = mock(TronNetDelegate.class); + Manager managerMock = mock(Manager.class); + when(tronNetDelegateMock.isBlockUnsolidified()).thenReturn(false); + when(managerMock.isTooManyPending()).thenReturn(false); + when(managerMock.getTransactionIdCache()).thenReturn(transactionIdCache); + + Field field = wallet.getClass().getDeclaredField("tronNetDelegate"); + field.setAccessible(true); + field.set(wallet, tronNetDelegateMock); + + Field field2 = wallet.getClass().getDeclaredField("dbManager"); + field2.setAccessible(true); + field2.set(wallet, managerMock); + + Field field3 = wallet.getClass().getDeclaredField("trxCacheEnable"); + field3.setAccessible(true); + field3.set(wallet, true); + + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + + assertEquals(GrpcAPI.Return.response_code.DUP_TRANSACTION_ERROR, + ret.getCode()); + } + + + @Test + public void testBroadcastTransactionNoContract() throws Exception { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + + TronNetDelegate tronNetDelegateMock = mock(TronNetDelegate.class); + Manager managerMock = mock(Manager.class); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + DynamicPropertiesStore dynamicPropertiesStoreMock + = mock(DynamicPropertiesStore.class); + when(tronNetDelegateMock.isBlockUnsolidified()).thenReturn(false); + when(managerMock.isTooManyPending()).thenReturn(false); + when(chainBaseManagerMock.getDynamicPropertiesStore()) + .thenReturn(dynamicPropertiesStoreMock); + when(dynamicPropertiesStoreMock.supportVM()).thenReturn(false); + + Field field = wallet.getClass().getDeclaredField("tronNetDelegate"); + field.setAccessible(true); + field.set(wallet, tronNetDelegateMock); + + Field field2 = wallet.getClass().getDeclaredField("dbManager"); + field2.setAccessible(true); + field2.set(wallet, managerMock); + + Field field4 = wallet.getClass().getDeclaredField("chainBaseManager"); + field4.setAccessible(true); + field4.set(wallet, chainBaseManagerMock); + + Field field3 = wallet.getClass().getDeclaredField("trxCacheEnable"); + field3.setAccessible(true); + field3.set(wallet, false); + + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + + assertEquals(GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR, + ret.getCode()); + } + + @Test + public void testBroadcastTransactionOtherException() throws Exception { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = getExampleTrans(); + + TronNetDelegate tronNetDelegateMock = mock(TronNetDelegate.class); + Manager managerMock = mock(Manager.class); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + DynamicPropertiesStore dynamicPropertiesStoreMock + = mock(DynamicPropertiesStore.class); + when(tronNetDelegateMock.isBlockUnsolidified()).thenReturn(false); + when(managerMock.isTooManyPending()).thenReturn(false); + when(chainBaseManagerMock.getDynamicPropertiesStore()) + .thenReturn(dynamicPropertiesStoreMock); + when(dynamicPropertiesStoreMock.supportVM()).thenReturn(false); + + Field field = wallet.getClass().getDeclaredField("tronNetDelegate"); + field.setAccessible(true); + field.set(wallet, tronNetDelegateMock); + + Field field2 = wallet.getClass().getDeclaredField("dbManager"); + field2.setAccessible(true); + field2.set(wallet, managerMock); + + Field field4 = wallet.getClass().getDeclaredField("chainBaseManager"); + field4.setAccessible(true); + field4.set(wallet, chainBaseManagerMock); + + Field field3 = wallet.getClass().getDeclaredField("trxCacheEnable"); + field3.setAccessible(true); + field3.set(wallet, false); + + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + + assertEquals(GrpcAPI.Return.response_code.OTHER_ERROR, ret.getCode()); + } + + private Protocol.Transaction getExampleTrans() { + BalanceContract.TransferContract transferContract = + BalanceContract.TransferContract.newBuilder() + .setAmount(10) + .setOwnerAddress(ByteString.copyFromUtf8("aaa")) + .setToAddress(ByteString.copyFromUtf8("bbb")) + .build(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 6666; i++) { + sb.append("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + } + return Protocol.Transaction.newBuilder().setRawData( + Protocol.Transaction.raw.newBuilder() + .setData(ByteString.copyFrom(sb.toString().getBytes(StandardCharsets.UTF_8))) + .addContract( + Protocol.Transaction.Contract.newBuilder() + .setParameter(Any.pack(transferContract)) + .setType(Protocol.Transaction.Contract.ContractType.TransferContract))) + .build(); + } + + private void mockEnv(Wallet wallet, TronException tronException) throws Exception { + TronNetDelegate tronNetDelegateMock = mock(TronNetDelegate.class); + Manager managerMock = mock(Manager.class); + ChainBaseManager chainBaseManagerMock + = mock(ChainBaseManager.class); + DynamicPropertiesStore dynamicPropertiesStoreMock + = mock(DynamicPropertiesStore.class); + + when(tronNetDelegateMock.isBlockUnsolidified()).thenReturn(false); + when(managerMock.isTooManyPending()).thenReturn(false); + when(chainBaseManagerMock.getDynamicPropertiesStore()) + .thenReturn(dynamicPropertiesStoreMock); + when(dynamicPropertiesStoreMock.supportVM()).thenReturn(false); + + doThrow(tronException).when(managerMock).pushTransaction(any()); + + Field field = wallet.getClass().getDeclaredField("tronNetDelegate"); + field.setAccessible(true); + field.set(wallet, tronNetDelegateMock); + + Field field2 = wallet.getClass().getDeclaredField("dbManager"); + field2.setAccessible(true); + field2.set(wallet, managerMock); + + Field field4 = wallet.getClass().getDeclaredField("chainBaseManager"); + field4.setAccessible(true); + field4.set(wallet, chainBaseManagerMock); + + Field field3 = wallet.getClass().getDeclaredField("trxCacheEnable"); + field3.setAccessible(true); + field3.set(wallet, false); + } + + @Test + public void testBroadcastTransactionValidateSignatureException() throws Exception { + try (MockedConstruction mocked = mockConstruction(TransactionMessage.class, + (mock, context) -> { + + })) { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = getExampleTrans(); + mockEnv(wallet, new ValidateSignatureException()); + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + assertEquals(GrpcAPI.Return.response_code.SIGERROR, ret.getCode()); + } + + } + + @Test + public void testBroadcastTransactionValidateContractExeException() throws Exception { + try (MockedConstruction mocked = mockConstruction(TransactionMessage.class, + (mock, context) -> { + + })) { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = getExampleTrans(); + mockEnv(wallet, new ContractExeException()); + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + assertEquals(GrpcAPI.Return.response_code.CONTRACT_EXE_ERROR, ret.getCode()); + } + + } + + @Test + public void testBroadcastTransactionValidateAccountResourceInsufficientException() + throws Exception { + try (MockedConstruction mocked = mockConstruction(TransactionMessage.class, + (mock, context) -> { + + })) { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = getExampleTrans(); + mockEnv(wallet, new AccountResourceInsufficientException("")); + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + assertEquals(GrpcAPI.Return.response_code.BANDWITH_ERROR, ret.getCode()); + } + + } + + @Test + public void testBroadcastTransactionValidateDupTransactionException() + throws Exception { + try (MockedConstruction mocked = mockConstruction(TransactionMessage.class, + (mock, context) -> { + + })) { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = getExampleTrans(); + mockEnv(wallet, new DupTransactionException("")); + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + assertEquals(GrpcAPI.Return.response_code.DUP_TRANSACTION_ERROR, ret.getCode()); + } + + } + + @Test + public void testBroadcastTransactionValidateTaposException() throws Exception { + try (MockedConstruction mocked = mockConstruction(TransactionMessage.class, + (mock, context) -> { + + })) { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = getExampleTrans(); + mockEnv(wallet, new TaposException("")); + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + assertEquals(GrpcAPI.Return.response_code.TAPOS_ERROR, ret.getCode()); + } + + } + + @Test + public void testBroadcastTransactionValidateTooBigTransactionException() + throws Exception { + try (MockedConstruction mocked = mockConstruction(TransactionMessage.class, + (mock, context) -> { + + })) { + Wallet wallet = new Wallet(); + Protocol.Transaction transaction = getExampleTrans(); + mockEnv(wallet, new TooBigTransactionException("")); + + GrpcAPI.Return ret = wallet.broadcastTransaction(transaction); + assertEquals(GrpcAPI.Return.response_code.TOO_BIG_TRANSACTION_ERROR, ret.getCode()); + } + + } + + @Test + public void testGetBlockByNum() throws Exception { + Wallet wallet = new Wallet(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + + doThrow(new ItemNotFoundException()).when(chainBaseManagerMock).getBlockByNum(anyLong()); + + Protocol.Block block = wallet.getBlockByNum(0L); + assertNull(block); + } + + @Test + public void testGetBlockCapsuleByNum() throws Exception { + Wallet wallet = new Wallet(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + doThrow(new ItemNotFoundException()).when(chainBaseManagerMock).getBlockByNum(anyLong()); + + BlockCapsule blockCapsule = wallet.getBlockCapsuleByNum(0L); + assertNull(blockCapsule); + } + + @Test + public void testGetTransactionCountByBlockNum() throws Exception { + Wallet wallet = new Wallet(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + doThrow(new ItemNotFoundException()).when(chainBaseManagerMock).getBlockByNum(anyLong()); + + long count = wallet.getTransactionCountByBlockNum(0L); + assertEquals(count, 0L); + } + + @Test + public void testGetTransactionById() throws Exception { + Wallet wallet = new Wallet(); + ByteString transactionId = null; + Protocol.Transaction transaction = wallet.getTransactionById(transactionId); + assertNull(transaction); + } + + @Test + public void testGetTransactionById2() throws Exception { + Wallet wallet = new Wallet(); + ByteString transactionId = ByteString.empty(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + TransactionStore transactionStoreMock = mock(TransactionStore.class); + + when(chainBaseManagerMock.getTransactionStore()).thenReturn(transactionStoreMock); + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + doThrow(new BadItemException()).when(transactionStoreMock).get(any()); + + Protocol.Transaction transaction = wallet.getTransactionById(transactionId); + assertNull(transaction); + } + + @Test + public void testGetTransactionById3() throws Exception { + Wallet wallet = new Wallet(); + ByteString transactionId = ByteString.empty(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + TransactionStore transactionStoreMock = mock(TransactionStore.class); + TransactionCapsule transactionCapsuleMock = mock(TransactionCapsule.class); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + + when(chainBaseManagerMock.getTransactionStore()).thenReturn(transactionStoreMock); + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + when(transactionStoreMock.get(any())).thenReturn(transactionCapsuleMock); + when(transactionCapsuleMock.getInstance()).thenReturn(transaction); + + Protocol.Transaction transactionRet = wallet.getTransactionById(transactionId); + assertEquals(transaction, transactionRet); + } + + @Test + public void testGetTransactionCapsuleById() throws Exception { + Wallet wallet = new Wallet(); + ByteString transactionId = null; + TransactionCapsule transactionCapsule = wallet.getTransactionCapsuleById(transactionId); + assertNull(transactionCapsule); + } + + @Test + public void testGetTransactionCapsuleById1() throws Exception { + Wallet wallet = new Wallet(); + ByteString transactionId = ByteString.empty(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + TransactionStore transactionStoreMock = mock(TransactionStore.class); + + when(chainBaseManagerMock.getTransactionStore()).thenReturn(transactionStoreMock); + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + doThrow(new BadItemException()).when(transactionStoreMock).get(any()); + + TransactionCapsule transactionCapsule = wallet.getTransactionCapsuleById(transactionId); + assertNull(transactionCapsule); + } + + @Test + public void testGetTransactionInfoById() throws Exception { + Wallet wallet = new Wallet(); + ByteString transactionId = null; + Protocol.TransactionInfo transactionInfo = wallet.getTransactionInfoById(transactionId); + assertNull(transactionInfo); + } + + @Test + public void testGetTransactionInfoById1() throws Exception { + Wallet wallet = new Wallet(); + ByteString transactionId = ByteString.empty(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + TransactionRetStore transactionRetStoreMock = mock(TransactionRetStore.class); + + when(chainBaseManagerMock.getTransactionRetStore()).thenReturn(transactionRetStoreMock); + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + doThrow(new BadItemException()).when(transactionRetStoreMock).getTransactionInfo(any()); + + Protocol.TransactionInfo transactionInfo = wallet.getTransactionInfoById(transactionId); + assertNull(transactionInfo); + } + + @Test + public void testGetTransactionInfoById2() throws Exception { + Wallet wallet = new Wallet(); + ByteString transactionId = ByteString.empty(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + TransactionRetStore transactionRetStoreMock = mock(TransactionRetStore.class); + TransactionHistoryStore transactionHistoryStoreMock = + mock(TransactionHistoryStore.class); + + when(chainBaseManagerMock.getTransactionRetStore()) + .thenReturn(transactionRetStoreMock); + when(chainBaseManagerMock.getTransactionHistoryStore()) + .thenReturn(transactionHistoryStoreMock); + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + when(transactionRetStoreMock.getTransactionInfo(any())).thenReturn(null); + doThrow(new BadItemException()).when(transactionHistoryStoreMock).get(any()); + + Protocol.TransactionInfo transactionInfo = wallet.getTransactionInfoById(transactionId); + assertNull(transactionInfo); + } + + @Test + public void testGetProposalById() throws Exception { + Wallet wallet = new Wallet(); + ByteString proposalId = null; + Protocol.Proposal proposal = wallet.getProposalById(proposalId); + assertNull(proposal); + } + + @Test + public void testGetMemoFeePrices() throws Exception { + Wallet wallet = new Wallet(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + DynamicPropertiesStore dynamicPropertiesStoreMock = + mock(DynamicPropertiesStore.class); + + when(chainBaseManagerMock.getDynamicPropertiesStore()).thenReturn(dynamicPropertiesStoreMock); + doThrow(new IllegalArgumentException("not found MEMO_FEE_HISTORY")) + .when(dynamicPropertiesStoreMock).getMemoFeeHistory(); + + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + + GrpcAPI.PricesResponseMessage responseMessage = wallet.getMemoFeePrices(); + assertNull(responseMessage); + } + + @Test + public void testGetEnergyFeeByTime() throws Exception { + Wallet wallet = new Wallet(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + DynamicPropertiesStore dynamicPropertiesStoreMock = + mock(DynamicPropertiesStore.class); + long now = System.currentTimeMillis(); + + when(chainBaseManagerMock.getDynamicPropertiesStore()).thenReturn(dynamicPropertiesStoreMock); + doThrow(new IllegalArgumentException("not found ENERGY_PRICE_HISTORY")) + .when(dynamicPropertiesStoreMock).getEnergyPriceHistory(); + when(dynamicPropertiesStoreMock.getEnergyFee()).thenReturn(10L); + + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + + long energyFee = wallet.getEnergyFee(now); + assertEquals(energyFee, 10L); + } + + @Test + public void testGetEnergyPrices() throws Exception { + Wallet wallet = new Wallet(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + DynamicPropertiesStore dynamicPropertiesStoreMock = + mock(DynamicPropertiesStore.class); + + when(chainBaseManagerMock.getDynamicPropertiesStore()).thenReturn(dynamicPropertiesStoreMock); + doThrow(new IllegalArgumentException("not found ENERGY_PRICE_HISTORY")) + .when(dynamicPropertiesStoreMock).getEnergyPriceHistory(); + + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + + GrpcAPI.PricesResponseMessage pricesResponseMessage = wallet.getEnergyPrices(); + assertNull(pricesResponseMessage); + } + + @Test + public void testGetBandwidthPrices() throws Exception { + Wallet wallet = new Wallet(); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + DynamicPropertiesStore dynamicPropertiesStoreMock = + mock(DynamicPropertiesStore.class); + + when(chainBaseManagerMock.getDynamicPropertiesStore()).thenReturn(dynamicPropertiesStoreMock); + doThrow(new IllegalArgumentException("not found BANDWIDTH_PRICE_HISTORY")) + .when(dynamicPropertiesStoreMock).getBandwidthPriceHistory(); + + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + + GrpcAPI.PricesResponseMessage pricesResponseMessage = wallet.getBandwidthPrices(); + assertNull(pricesResponseMessage); + } + + @Test + public void testCheckBlockIdentifier() { + Wallet wallet = new Wallet(); + BalanceContract.BlockBalanceTrace.BlockIdentifier blockIdentifier = + BalanceContract.BlockBalanceTrace.BlockIdentifier.newBuilder() + .build(); + blockIdentifier = blockIdentifier.getDefaultInstanceForType(); + + BalanceContract.BlockBalanceTrace.BlockIdentifier blockIdentifier1 = + blockIdentifier; + + assertThrows(IllegalArgumentException.class, () -> { + wallet.checkBlockIdentifier(blockIdentifier1); + }); + + BalanceContract.BlockBalanceTrace.BlockIdentifier blockIdentifier2 = + BalanceContract.BlockBalanceTrace.BlockIdentifier.newBuilder() + .setNumber(-1L) + .build(); + + assertThrows(IllegalArgumentException.class, () -> { + wallet.checkBlockIdentifier(blockIdentifier2); + }); + + BalanceContract.BlockBalanceTrace.BlockIdentifier blockIdentifier3 = + BalanceContract.BlockBalanceTrace.BlockIdentifier.newBuilder() + .setHash(ByteString.copyFrom("".getBytes(StandardCharsets.UTF_8))) + .build(); + + assertThrows(IllegalArgumentException.class, () -> { + wallet.checkBlockIdentifier(blockIdentifier3); + }); + } + + @Test + public void testCheckAccountIdentifier() { + Wallet wallet = new Wallet(); + BalanceContract.AccountIdentifier accountIdentifier = + BalanceContract.AccountIdentifier.newBuilder().build(); + accountIdentifier = accountIdentifier.getDefaultInstanceForType(); + + BalanceContract.AccountIdentifier accountIdentifier2 = accountIdentifier; + + assertThrows(IllegalArgumentException.class, () -> { + wallet.checkAccountIdentifier(accountIdentifier2); + }); + + BalanceContract.AccountIdentifier accountIdentifier1 + = BalanceContract.AccountIdentifier.newBuilder().build(); + + assertThrows(IllegalArgumentException.class, () -> { + wallet.checkAccountIdentifier(accountIdentifier1); + }); + } + + @Test + public void testGetTriggerInputForShieldedTRC20Contract() { + Wallet wallet = new Wallet(); + GrpcAPI.ShieldedTRC20TriggerContractParameters.Builder triggerParam = + GrpcAPI.ShieldedTRC20TriggerContractParameters + .newBuilder(); + GrpcAPI.ShieldedTRC20Parameters shieldedTRC20Parameters = + GrpcAPI.ShieldedTRC20Parameters.newBuilder().build(); + GrpcAPI.BytesMessage bytesMessage = + GrpcAPI.BytesMessage.newBuilder().build(); + + triggerParam.setShieldedTRC20Parameters(shieldedTRC20Parameters); + triggerParam.addSpendAuthoritySignature(bytesMessage); + + CommonParameter commonParameterMock = mock(Args.class); + try (MockedStatic mockedStatic = mockStatic(CommonParameter.class)) { + when(CommonParameter.getInstance()).thenReturn(commonParameterMock); + when(commonParameterMock.isFullNodeAllowShieldedTransactionArgs()).thenReturn(true); + + assertThrows(ZksnarkException.class, () -> { + wallet.getTriggerInputForShieldedTRC20Contract(triggerParam.build()); + }); + } + } + + @Test + public void testGetTriggerInputForShieldedTRC20Contract1() + throws ZksnarkException, ContractValidateException { + Wallet wallet = new Wallet(); + ShieldContract.SpendDescription spendDescription = + ShieldContract.SpendDescription.newBuilder().build(); + GrpcAPI.ShieldedTRC20TriggerContractParameters.Builder triggerParam = + GrpcAPI.ShieldedTRC20TriggerContractParameters + .newBuilder(); + GrpcAPI.ShieldedTRC20Parameters shieldedTRC20Parameters = + GrpcAPI.ShieldedTRC20Parameters.newBuilder() + .addSpendDescription(spendDescription) + .setParameterType("transfer") + .build(); + GrpcAPI.BytesMessage bytesMessage = + GrpcAPI.BytesMessage.newBuilder().build(); + + triggerParam.setShieldedTRC20Parameters(shieldedTRC20Parameters); + triggerParam.addSpendAuthoritySignature(bytesMessage); + + CommonParameter commonParameterMock = mock(Args.class); + try (MockedStatic mockedStatic = mockStatic(CommonParameter.class)) { + when(CommonParameter.getInstance()).thenReturn(commonParameterMock); + when(commonParameterMock.isFullNodeAllowShieldedTransactionArgs()).thenReturn(true); + + GrpcAPI.BytesMessage reponse = + wallet.getTriggerInputForShieldedTRC20Contract(triggerParam.build()); + assertNotNull(reponse); + } + + } + + @Test + public void testGetShieldedContractScalingFactorException() throws Exception { + Wallet walletMock = mock(Wallet.class); + byte[] contractAddress = "".getBytes(StandardCharsets.UTF_8); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + when(walletMock.createTransactionCapsule(any(), any())) + .thenReturn(new TransactionCapsule(transaction)); + + try { + when(walletMock.getShieldedContractScalingFactor(contractAddress)).thenCallRealMethod(); + } catch (Exception e) { + assertNotNull(e); + } + } + + @Test + public void testGetShieldedContractScalingFactorRuntimeException() + throws VMIllegalException, HeaderNotFound, ContractValidateException, ContractExeException { + Wallet walletMock = mock(Wallet.class); + byte[] contractAddress = "".getBytes(StandardCharsets.UTF_8); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + when(walletMock.triggerConstantContract(any(),any(),any(),any())).thenReturn(transaction); + when(walletMock.getShieldedContractScalingFactor(any())).thenCallRealMethod(); + + assertThrows(ContractExeException.class, () -> { + walletMock.getShieldedContractScalingFactor(contractAddress); + }); + } + + @Test + public void testGetShieldedContractScalingFactorSuccess() + throws Exception { + Wallet walletMock = mock(Wallet.class); + byte[] contractAddress = "".getBytes(StandardCharsets.UTF_8); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + when(walletMock.triggerConstantContract(any(),any(),any(),any())) + .thenReturn(transaction); + when(walletMock.createTransactionCapsule(any(), any())) + .thenReturn(new TransactionCapsule(transaction)); + when(walletMock.getShieldedContractScalingFactor(any())).thenCallRealMethod(); + try { + byte[] listBytes = walletMock.getShieldedContractScalingFactor(contractAddress); + assertNotNull(listBytes); + } catch (Exception e) { + assertNull(e); + } + } + + @Test + public void testGetShieldedContractScalingFactorContractExeException() + throws Exception { + Wallet walletMock = mock(Wallet.class); + byte[] contractAddress = "".getBytes(StandardCharsets.UTF_8); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + doThrow(new ContractExeException("")) + .when(walletMock).triggerConstantContract(any(),any(),any(),any()); + when(walletMock.createTransactionCapsule(any(), any())) + .thenReturn(new TransactionCapsule(transaction)); + when(walletMock.getShieldedContractScalingFactor(any())).thenCallRealMethod(); + + assertThrows(ContractExeException.class, () -> { + walletMock.getShieldedContractScalingFactor(contractAddress); + }); + } + + @Test + public void testCheckBigIntegerRange() { + Wallet wallet = new Wallet(); + + assertThrows( + Exception.class, + () -> { + Method privateMethod = Wallet.class.getDeclaredMethod( + "checkBigIntegerRange", BigInteger.class); + privateMethod.setAccessible(true); + privateMethod.invoke(wallet, new BigInteger("-1")); + } + ); + } + + @Test + public void testCheckPublicAmount() throws ContractExeException { + Wallet walletMock = mock(Wallet.class); + + byte[] address = "".getBytes(StandardCharsets.UTF_8); + BigInteger fromAmount = new BigInteger("10"); + BigInteger toAmount = new BigInteger("10"); + doThrow(new ContractExeException("")).when(walletMock).getShieldedContractScalingFactor(any()); + + Throwable thrown = assertThrows(InvocationTargetException.class, () -> { + Method privateMethod = Wallet.class.getDeclaredMethod( + "checkPublicAmount", + byte[].class, BigInteger.class, BigInteger.class); + privateMethod.setAccessible(true); + privateMethod.invoke(walletMock, address, fromAmount, toAmount); + }); + Throwable cause = thrown.getCause(); + assertTrue(cause instanceof ContractExeException); + } + + @Test + public void testCheckPublicAmount1() throws ContractExeException { + Wallet walletMock = mock(Wallet.class); + + byte[] address = "".getBytes(StandardCharsets.UTF_8); + BigInteger fromAmount = new BigInteger("300"); + BigInteger toAmount = new BigInteger("255"); + + byte[] scalingFactorBytes = ByteUtil.bigIntegerToBytes(new BigInteger("-1")); + + when(walletMock.getShieldedContractScalingFactor(any())).thenReturn(scalingFactorBytes); + + Throwable thrown = assertThrows(InvocationTargetException.class, () -> { + Method privateMethod = Wallet.class.getDeclaredMethod( + "checkPublicAmount", + byte[].class, BigInteger.class, BigInteger.class); + privateMethod.setAccessible(true); + privateMethod.invoke(walletMock, address, fromAmount, toAmount); + }); + Throwable cause = thrown.getCause(); + assertTrue(cause instanceof ContractValidateException); + } + + @Test + public void testCheckPublicAmount2() throws ContractExeException { + Wallet walletMock = mock(Wallet.class); + + byte[] address = "".getBytes(StandardCharsets.UTF_8); + BigInteger fromAmount = new BigInteger("300"); + BigInteger toAmount = new BigInteger("255"); + + byte[] scalingFactorBytes = ByteUtil.bigIntegerToBytes(new BigInteger("-1")); + try (MockedStatic mockedStatic = mockStatic(ByteUtil.class)) { + when(ByteUtil.bytesToBigInteger(any())).thenReturn(new BigInteger("-1")); + when(walletMock.getShieldedContractScalingFactor(any())).thenReturn(scalingFactorBytes); + + Throwable thrown = assertThrows(InvocationTargetException.class, () -> { + Method privateMethod = Wallet.class.getDeclaredMethod( + "checkPublicAmount", + byte[].class, BigInteger.class, BigInteger.class); + privateMethod.setAccessible(true); + privateMethod.invoke(walletMock, address, fromAmount, toAmount); + }); + Throwable cause = thrown.getCause(); + assertTrue(cause instanceof ContractValidateException); + } + + } + + @Test + public void testGetShieldedTRC20Nullifier() { + Wallet wallet = new Wallet(); + GrpcAPI.Note note = GrpcAPI.Note.newBuilder() + .setValue(100) + .setPaymentAddress("address") + .setRcm(ByteString.copyFrom("rcm".getBytes(StandardCharsets.UTF_8))) + .setMemo(ByteString.copyFrom("memo".getBytes(StandardCharsets.UTF_8))) + .build(); + long pos = 100L; + byte[] ak = "ak".getBytes(StandardCharsets.UTF_8); + byte[] nk = "nk".getBytes(StandardCharsets.UTF_8); + try (MockedStatic keyIoMockedStatic = mockStatic(KeyIo.class)) { + when(KeyIo.decodePaymentAddress(any())).thenReturn(null); + + Throwable thrown = assertThrows(InvocationTargetException.class, () -> { + Method privateMethod = Wallet.class.getDeclaredMethod( + "getShieldedTRC20Nullifier", + GrpcAPI.Note.class, long.class, byte[].class, + byte[].class); + privateMethod.setAccessible(true); + privateMethod.invoke(wallet, + note, pos, ak, nk); + }); + Throwable cause = thrown.getCause(); + assertTrue(cause instanceof ZksnarkException); + } + } + + @Test + public void testGetShieldedTRC20LogType() { + Wallet wallet = new Wallet(); + Protocol.TransactionInfo.Log log = Protocol.TransactionInfo.Log.newBuilder().build(); + byte[] contractAddress = "contractAddress".getBytes(StandardCharsets.UTF_8); + LazyStringArrayList topicsList = new LazyStringArrayList(); + + Throwable thrown = assertThrows(InvocationTargetException.class, () -> { + Method privateMethod = Wallet.class.getDeclaredMethod( + "getShieldedTRC20LogType", + Protocol.TransactionInfo.Log.class, + byte[].class, + ProtocolStringList.class); + privateMethod.setAccessible(true); + privateMethod.invoke(wallet, + log, + contractAddress, + topicsList); + }); + Throwable cause = thrown.getCause(); + assertTrue(cause instanceof ZksnarkException); + } + + @Test + public void testGetShieldedTRC20LogType1() { + Wallet wallet = new Wallet(); + final String SHIELDED_CONTRACT_ADDRESS_STR = "TGAmX5AqVUoXCf8MoHxbuhQPmhGfWTnEgA"; + byte[] contractAddress = WalletClient.decodeFromBase58Check(SHIELDED_CONTRACT_ADDRESS_STR); + + byte[] addressWithoutPrefix = new byte[20]; + System.arraycopy(contractAddress, 1, addressWithoutPrefix, 0, 20); + Protocol.TransactionInfo.Log log = Protocol.TransactionInfo.Log.newBuilder() + .setAddress(ByteString.copyFrom(addressWithoutPrefix)) + .build(); + + LazyStringArrayList topicsList = new LazyStringArrayList(); + try { + Method privateMethod = Wallet.class.getDeclaredMethod( + "getShieldedTRC20LogType", + Protocol.TransactionInfo.Log.class, + byte[].class, + ProtocolStringList.class); + privateMethod.setAccessible(true); + privateMethod.invoke(wallet, + log, + contractAddress, + topicsList); + } catch (Exception e) { + assertTrue(false); + } + } + + + @Test + public void testGetShieldedTRC20LogType2() { + Wallet wallet = new Wallet(); + final String SHIELDED_CONTRACT_ADDRESS_STR = "TGAmX5AqVUoXCf8MoHxbuhQPmhGfWTnEgA"; + byte[] contractAddress = WalletClient.decodeFromBase58Check(SHIELDED_CONTRACT_ADDRESS_STR); + + byte[] addressWithoutPrefix = new byte[20]; + System.arraycopy(contractAddress, 1, addressWithoutPrefix, 0, 20); + Protocol.TransactionInfo.Log log = Protocol.TransactionInfo.Log.newBuilder() + .setAddress(ByteString.copyFrom(addressWithoutPrefix)) + .addTopics(ByteString.copyFrom("topic".getBytes())) + .build(); + + LazyStringArrayList topicsList = new LazyStringArrayList(); + topicsList.add("topic"); + try { + Method privateMethod = Wallet.class.getDeclaredMethod( + "getShieldedTRC20LogType", + Protocol.TransactionInfo.Log.class, + byte[].class, + ProtocolStringList.class); + privateMethod.setAccessible(true); + privateMethod.invoke(wallet, + log, + contractAddress, + topicsList); + } catch (Exception e) { + assertTrue(false); + } + } + + @Test + public void testBuildShieldedTRC20InputWithAK() throws ZksnarkException { + Wallet wallet = new Wallet(); + ShieldedTRC20ParametersBuilder builder = new ShieldedTRC20ParametersBuilder("transfer"); + GrpcAPI.Note note = GrpcAPI.Note.newBuilder() + .setValue(100) + .setPaymentAddress("address") + .setRcm(ByteString.copyFrom("rcm".getBytes(StandardCharsets.UTF_8))) + .setMemo(ByteString.copyFrom("memo".getBytes(StandardCharsets.UTF_8))) + .build(); + GrpcAPI.SpendNoteTRC20 spendNote = GrpcAPI.SpendNoteTRC20.newBuilder() + .setNote(note) + .setAlpha(ByteString.copyFrom("alpha".getBytes())) + .setRoot(ByteString.copyFrom("root".getBytes())) + .setPath(ByteString.copyFrom("path".getBytes())) + .setPos(0L) + .build(); + byte[] ak = "ak".getBytes(StandardCharsets.UTF_8); + byte[] nk = "nk".getBytes(StandardCharsets.UTF_8); + + try (MockedStatic keyIoMockedStatic = mockStatic(KeyIo.class)) { + when(KeyIo.decodePaymentAddress(any())).thenReturn(null); + + Throwable thrown = assertThrows(InvocationTargetException.class, () -> { + Method privateMethod = Wallet.class.getDeclaredMethod( + "buildShieldedTRC20InputWithAK", + ShieldedTRC20ParametersBuilder.class, + GrpcAPI.SpendNoteTRC20.class, + byte[].class, byte[].class); + privateMethod.setAccessible(true); + privateMethod.invoke(wallet, + builder, + spendNote, + ak, nk); + }); + Throwable cause = thrown.getCause(); + assertTrue(cause instanceof ZksnarkException); + } + + } + + @Test + public void testBuildShieldedTRC20InputWithAK1() throws Exception { + Wallet wallet = new Wallet(); + ShieldedTRC20ParametersBuilder builder = new ShieldedTRC20ParametersBuilder("transfer"); + GrpcAPI.Note note = GrpcAPI.Note.newBuilder() + .setValue(100) + .setPaymentAddress("address") + .setRcm(ByteString.copyFrom("rcm".getBytes(StandardCharsets.UTF_8))) + .setMemo(ByteString.copyFrom("memo".getBytes(StandardCharsets.UTF_8))) + .build(); + GrpcAPI.SpendNoteTRC20 spendNote = GrpcAPI.SpendNoteTRC20.newBuilder() + .setNote(note) + .setAlpha(ByteString.copyFrom("alpha".getBytes())) + .setRoot(ByteString.copyFrom("root".getBytes())) + .setPath(ByteString.copyFrom("path".getBytes())) + .setPos(0L) + .build(); + byte[] ak = "ak".getBytes(StandardCharsets.UTF_8); + byte[] nk = "nk".getBytes(StandardCharsets.UTF_8); + PaymentAddress paymentAddress = mock(PaymentAddress.class); + DiversifierT diversifierT = mock(DiversifierT.class); + + try (MockedStatic keyIoMockedStatic = mockStatic(KeyIo.class)) { + when(KeyIo.decodePaymentAddress(any())).thenReturn(paymentAddress); + when(paymentAddress.getD()).thenReturn(diversifierT); + when(paymentAddress.getPkD()).thenReturn("pkd".getBytes()); + + Method privateMethod = Wallet.class.getDeclaredMethod( + "buildShieldedTRC20InputWithAK", + ShieldedTRC20ParametersBuilder.class, + GrpcAPI.SpendNoteTRC20.class, + byte[].class, byte[].class); + privateMethod.setAccessible(true); + privateMethod.invoke(wallet, + builder, + spendNote, + ak, nk); + } + + } + + @Test + public void testBuildShieldedTRC20Input() throws Exception { + Wallet wallet = new Wallet(); + ShieldedTRC20ParametersBuilder builder = new ShieldedTRC20ParametersBuilder("transfer"); + GrpcAPI.Note note = GrpcAPI.Note.newBuilder() + .setValue(100) + .setPaymentAddress("address") + .setRcm(ByteString.copyFrom("rcm".getBytes(StandardCharsets.UTF_8))) + .setMemo(ByteString.copyFrom("memo".getBytes(StandardCharsets.UTF_8))) + .build(); + GrpcAPI.SpendNoteTRC20 spendNote = GrpcAPI.SpendNoteTRC20.newBuilder() + .setNote(note) + .setAlpha(ByteString.copyFrom("alpha".getBytes())) + .setRoot(ByteString.copyFrom("root".getBytes())) + .setPath(ByteString.copyFrom("path".getBytes())) + .setPos(0L) + .build(); + ExpandedSpendingKey expandedSpendingKey = mock(ExpandedSpendingKey.class); + PaymentAddress paymentAddress = mock(PaymentAddress.class); + DiversifierT diversifierT = mock(DiversifierT.class); + + try (MockedStatic keyIoMockedStatic = mockStatic(KeyIo.class)) { + when(KeyIo.decodePaymentAddress(any())).thenReturn(paymentAddress); + when(paymentAddress.getD()).thenReturn(diversifierT); + when(paymentAddress.getPkD()).thenReturn("pkd".getBytes()); + Method privateMethod = Wallet.class.getDeclaredMethod( + "buildShieldedTRC20Input", + ShieldedTRC20ParametersBuilder.class, + GrpcAPI.SpendNoteTRC20.class, + ExpandedSpendingKey.class); + privateMethod.setAccessible(true); + privateMethod.invoke(wallet, + builder, + spendNote, + expandedSpendingKey); + } + } + + @Test + public void testGetContractInfo() throws Exception { + Wallet wallet = new Wallet(); + GrpcAPI.BytesMessage bytesMessage = GrpcAPI.BytesMessage.newBuilder() + .setValue(ByteString.copyFrom("test".getBytes())) + .build(); + + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + AccountStore accountStore = mock(AccountStore.class); + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + when(chainBaseManagerMock.getAccountStore()).thenReturn(accountStore); + when(accountStore.get(any())).thenReturn(null); + + SmartContractOuterClass.SmartContractDataWrapper smartContractDataWrapper = + wallet.getContractInfo(bytesMessage); + assertNull(smartContractDataWrapper); + } + + @Test + public void testGetContractInfo1() throws Exception { + Wallet wallet = new Wallet(); + GrpcAPI.BytesMessage bytesMessage = GrpcAPI.BytesMessage.newBuilder() + .setValue(ByteString.copyFrom("test".getBytes())) + .build(); + + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + AccountStore accountStore = mock(AccountStore.class); + ContractStore contractStore = mock(ContractStore.class); + AbiStore abiStore = mock(AbiStore.class); + CodeStore codeStore = mock(CodeStore.class); + ContractStateStore contractStateStore = mock(ContractStateStore.class); + DynamicPropertiesStore dynamicPropertiesStore = mock(DynamicPropertiesStore.class); + + AccountCapsule accountCapsule = mock(AccountCapsule.class); + ContractCapsule contractCapsule = mock(ContractCapsule.class); + ContractStateCapsule contractStateCapsule = new ContractStateCapsule(10L); + + Field field = wallet.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(wallet, chainBaseManagerMock); + when(chainBaseManagerMock.getAccountStore()).thenReturn(accountStore); + when(chainBaseManagerMock.getContractStore()).thenReturn(contractStore); + when(chainBaseManagerMock.getAbiStore()).thenReturn(abiStore); + when(chainBaseManagerMock.getCodeStore()).thenReturn(codeStore); + when(chainBaseManagerMock.getContractStateStore()).thenReturn(contractStateStore); + when(chainBaseManagerMock.getDynamicPropertiesStore()).thenReturn(dynamicPropertiesStore); + + when(accountStore.get(any())).thenReturn(accountCapsule); + when(contractStore.get(any())).thenReturn(contractCapsule); + when(contractCapsule.generateWrapper()) + .thenReturn(SmartContractOuterClass.SmartContractDataWrapper.newBuilder().build()); + when(abiStore.get(any())).thenReturn(null); + when(codeStore.get(any())).thenReturn(null); + when(contractStateStore.get(any())).thenReturn(contractStateCapsule); + when(dynamicPropertiesStore.getCurrentCycleNumber()).thenReturn(100L); + + SmartContractOuterClass.SmartContractDataWrapper smartContractDataWrapper = + wallet.getContractInfo(bytesMessage); + assertNotNull(smartContractDataWrapper); + } +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/WalletTest.java b/framework/src/test/java/org/tron/core/WalletTest.java index 357a2d2ca08..831490fdca1 100644 --- a/framework/src/test/java/org/tron/core/WalletTest.java +++ b/framework/src/test/java/org/tron/core/WalletTest.java @@ -48,6 +48,7 @@ import org.tron.api.GrpcAPI.ProposalList; import org.tron.common.BaseTest; import org.tron.common.crypto.ECKey; +import org.tron.common.parameter.CommonParameter; import org.tron.common.utils.ByteArray; import org.tron.common.utils.Utils; import org.tron.core.actuator.DelegateResourceActuator; @@ -72,6 +73,8 @@ import org.tron.core.store.DynamicPropertiesStore; import org.tron.core.utils.ProposalUtil.ProposalType; import org.tron.core.utils.TransactionUtil; +import org.tron.core.vm.config.ConfigLoader; +import org.tron.core.vm.config.VMConfig; import org.tron.core.vm.program.Program; import org.tron.protos.Protocol; import org.tron.protos.Protocol.Block; @@ -139,7 +142,7 @@ public class WalletTest extends BaseTest { private static boolean init; static { - Args.setParam(new String[]{"-d", dbPath()}, Constant.TEST_CONF); + Args.setParam(new String[] {"-d", dbPath()}, Constant.TEST_CONF); OWNER_ADDRESS = Wallet.getAddressPreFixString() + "548794500882809695a8a687866e76d4271a1abc"; RECEIVER_ADDRESS = Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049150"; } @@ -152,7 +155,8 @@ public void before() { } initTransaction(); initBlock(); - chainBaseManager.getDynamicPropertiesStore().saveLatestBlockHeaderNumber(5); + chainBaseManager.getDynamicPropertiesStore().saveLatestBlockHeaderNumber(BLOCK_NUM_FIVE); + chainBaseManager.getDynamicPropertiesStore().saveLatestSolidifiedBlockNum(BLOCK_NUM_TWO); chainBaseManager.getDelegatedResourceStore().reset(); init = true; } @@ -166,6 +170,7 @@ private void initTransaction() { TRANSACTION_TIMESTAMP_ONE, BLOCK_NUM_ONE); addTransactionToStore(transaction1); + // solidified transaction2 = getBuildTransaction( getBuildTransferContract(ACCOUNT_ADDRESS_TWO, ACCOUNT_ADDRESS_THREE), TRANSACTION_TIMESTAMP_TWO, BLOCK_NUM_TWO); @@ -284,6 +289,7 @@ private void initBlock() { private void addBlockToStore(Block block) { BlockCapsule blockCapsule = new BlockCapsule(block); + chainBaseManager.getBlockIndexStore().put(blockCapsule.getBlockId()); chainBaseManager.getBlockStore().put(blockCapsule.getBlockId().getBytes(), blockCapsule); } @@ -1043,6 +1049,79 @@ public void testGetAssetIssueByName() { chainBaseManager.getDynamicPropertiesStore().saveAllowSameTokenName(0); } + @Test + @SneakyThrows + public void testTriggerConstant() { + boolean preDebug = CommonParameter.getInstance().debug; + CommonParameter.getInstance().debug = true; + ConfigLoader.disable = true; + VMConfig.initAllowTvmTransferTrc10(1); + VMConfig.initAllowTvmConstantinople(1); + VMConfig.initAllowTvmShangHai(1); + + String contractAddress = + Wallet.getAddressPreFixString() + "1A622D84ed49f01045f5f1a5AfcEb9c57e9cC3cc"; + + AccountCapsule accountCap = new AccountCapsule( + ByteString.copyFrom(ByteArray.fromHexString(contractAddress)), + Protocol.AccountType.Normal); + dbManager.getAccountStore().put(accountCap.createDbKey(), accountCap); + + SmartContractOuterClass.SmartContract smartContract = + SmartContractOuterClass.SmartContract.newBuilder().build(); + ContractCapsule contractCap = new ContractCapsule(smartContract); + dbManager.getContractStore().put(ByteArray.fromHexString(contractAddress), contractCap); + + String codeString = "608060405234801561000f575f80fd5b50d3801561001b575f80fd5b50d280156100" + + "27575f80fd5b506004361061004c575f3560e01c80638da5cb5b14610050578063f8a8fd6d1461006e57" + + "5b5f80fd5b61005861008c565b6040516100659190610269565b60405180910390f35b6100766100af565b" + + "6040516100839190610269565b60405180910390f35b5f8054906101000a900473ffffffffffffffffffff" + + "ffffffffffffffffffff1681565b5f60017fbe0166938e2ea2f3f3e0746fdaf46e25c4d8de37ce56d70400" + + "cf284c80d47bbe601b7f10afab946e2be82aa3e4280cf24e2cab294911c3beb06ca9dd7ead06081265d07f" + + "1e1855bcdc3ed57c6f3c3874cde035782427d1236e2d819bd16c75676ecc003a6040515f81526020016040" + + "52604051610133949392919061038f565b6020604051602081039080840390855afa158015610153573d5f" + + "803e3d5ffd5b505050602060405103515f806101000a81548173ffffffffffffffffffffffffffffffffff" + + "ffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550734c95a52686a9b3" + + "ff9cf787b94b8549a988334c5773ffffffffffffffffffffffffffffffffffffffff165f8054906101000a" + + "900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffff" + + "ffff1614610205575f80fd5b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff" + + "16905090565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6102538261" + + "022a565b9050919050565b61026381610249565b82525050565b5f60208201905061027c5f83018461025a" + + "565b92915050565b5f819050919050565b5f819050919050565b5f815f1b9050919050565b5f6102b96102" + + "b46102af84610282565b610294565b61028b565b9050919050565b6102c98161029f565b82525050565b5f" + + "819050919050565b5f60ff82169050919050565b5f819050919050565b5f6103076103026102fd846102cf" + + "565b6102e4565b6102d8565b9050919050565b610317816102ed565b82525050565b5f819050919050565b" + + "5f61034061033b6103368461031d565b610294565b61028b565b9050919050565b61035081610326565b82" + + "525050565b5f819050919050565b5f61037961037461036f84610356565b610294565b61028b565b905091" + + "9050565b6103898161035f565b82525050565b5f6080820190506103a25f8301876102c0565b6103af6020" + + "83018661030e565b6103bc6040830185610347565b6103c96060830184610380565b9594505050505056fe" + + "a26474726f6e58221220e967690f9c06386434cbe4d8dd6dce394130f190d17621cbd4ae4cabdef4ad7964" + + "736f6c63430008140033"; + CodeCapsule codeCap = new CodeCapsule(ByteArray.fromHexString(codeString)); + dbManager.getCodeStore().put(ByteArray.fromHexString(contractAddress), codeCap); + + SmartContractOuterClass.TriggerSmartContract contract = + SmartContractOuterClass.TriggerSmartContract.newBuilder() + .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(contractAddress))) + .setContractAddress(ByteString.copyFrom(ByteArray.fromHexString(contractAddress))) + .setData(ByteString.copyFrom(ByteArray.fromHexString("f8a8fd6d"))) + .build(); + TransactionCapsule trxCap = wallet.createTransactionCapsule(contract, + ContractType.TriggerSmartContract); + + GrpcAPI.TransactionExtention.Builder trxExtBuilder = GrpcAPI.TransactionExtention.newBuilder(); + GrpcAPI.Return.Builder retBuilder = GrpcAPI.Return.newBuilder(); + + Transaction tx = wallet.triggerConstantContract(contract, trxCap, trxExtBuilder, retBuilder); + Assert.assertEquals(Transaction.Result.code.SUCESS, tx.getRet(0).getRet()); + + VMConfig.initAllowTvmTransferTrc10(0); + VMConfig.initAllowTvmConstantinople(0); + VMConfig.initAllowTvmShangHai(0); + ConfigLoader.disable = false; + CommonParameter.getInstance().debug = preDebug; + } + @Test @SneakyThrows public void testEstimateEnergy() { @@ -1169,19 +1248,19 @@ public void testListNodes() { * delegate_balance = 1000_000L; => 277 * delegate_balance = 1000_000_000L; => 279 * delegate_balance = 1000_000_000_000L => 280 - * + *

* We initialize account information as follows * account balance = 1000_000_000_000L * account frozen_balance = 1000_000_000L - * + *

* then estimateConsumeBandWidthSize cost 279 - * + *

* so we have following result: * TransactionUtil.estimateConsumeBandWidthSize( * dynamicStore,ownerCapsule.getBalance()) ===> false * TransactionUtil.estimateConsumeBandWidthSize( * dynamicStore,ownerCapsule.getFrozenV2BalanceForBandwidth()) ===> true - * + *

* This test case is used to verify the above conclusions */ @Test @@ -1206,5 +1285,13 @@ public void testGetCanDelegatedMaxSizeBandWidth123() { chainBaseManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(DELEGATE_PERIOD / 3000); } + @Test + public void testGetSolidBlock() { + long blkNum = wallet.getSolidBlockNum(); + Assert.assertEquals(BLOCK_NUM_TWO, blkNum); + + Block block = wallet.getSolidBlock(); + assertEquals(block2, block); + } } diff --git a/framework/src/test/java/org/tron/core/actuator/ActuatorFactoryTest.java b/framework/src/test/java/org/tron/core/actuator/ActuatorFactoryTest.java new file mode 100644 index 00000000000..8258fbf9a3e --- /dev/null +++ b/framework/src/test/java/org/tron/core/actuator/ActuatorFactoryTest.java @@ -0,0 +1,71 @@ +package org.tron.core.actuator; + +import com.google.protobuf.ByteString; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.tron.common.BaseTest; +import org.tron.common.utils.ByteArray; +import org.tron.core.Constant; +import org.tron.core.Wallet; +import org.tron.core.capsule.AccountCapsule; +import org.tron.core.capsule.TransactionCapsule; +import org.tron.core.config.args.Args; +import org.tron.protos.Protocol.AccountType; +import org.tron.protos.contract.BalanceContract.TransferContract; + +public class ActuatorFactoryTest extends BaseTest { + + private static final String OWNER_ADDRESS = Wallet.getAddressPreFixString() + + "548794500882809695a8a687866e76d4271a1abc"; + private static final String TO_ADDRESS = Wallet.getAddressPreFixString() + + "abd4b9367799eaa3197fecb144eb71de1e049abc"; + + static { + Args.setParam( + new String[] { + "--output-directory", dbPath() + }, + Constant.TEST_CONF + ); + } + + private TransferContract getContract(long count, String owneraddress, String toaddress) { + return TransferContract.newBuilder() + .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(owneraddress))) + .setToAddress(ByteString.copyFrom(ByteArray.fromHexString(toaddress))) + .setAmount(count) + .build(); + } + + @Before + public void createCapsule() { + AccountCapsule ownerCapsule = + new AccountCapsule( + ByteString.copyFromUtf8("owner"), + ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)), + AccountType.Normal, + 10000L); + AccountCapsule toAccountCapsule = + new AccountCapsule( + ByteString.copyFromUtf8("toAccount"), + ByteString.copyFrom(ByteArray.fromHexString(TO_ADDRESS)), + AccountType.Normal, + 10L); + dbManager.getAccountStore().put(ownerCapsule.getAddress().toByteArray(), ownerCapsule); + dbManager.getAccountStore().put(toAccountCapsule.getAddress().toByteArray(), toAccountCapsule); + } + + + @Test + public void testCreateActuator() { + TransferContract contract = getContract(10L, OWNER_ADDRESS, TO_ADDRESS); + TransactionCapsule trx = new TransactionCapsule(contract, + chainBaseManager.getAccountStore()); + List actList = ActuatorFactory.createActuator(trx, chainBaseManager); + + Assert.assertEquals(1, actList.size()); + } + +} diff --git a/framework/src/test/java/org/tron/core/actuator/ExchangeCreateActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ExchangeCreateActuatorTest.java index 807d0e1be02..179ba56e7ed 100644 --- a/framework/src/test/java/org/tron/core/actuator/ExchangeCreateActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/ExchangeCreateActuatorTest.java @@ -125,8 +125,8 @@ public void sameTokenNameCloseSuccessExchangeCreate() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -216,7 +216,7 @@ public void sameTokenNameCloseSuccessExchangeCreate2() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); accountCapsule.setBalance(200_000_000_000000L); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L, true); dbManager.getAccountStore().put(ownerAddress, accountCapsule); ExchangeCreateActuator actuator = new ExchangeCreateActuator(); @@ -710,8 +710,8 @@ public void sameTokenNameCloseNoEnoughBalance() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance, true); accountCapsule.setBalance(1000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -748,8 +748,8 @@ public void sameTokenNameOpenNoEnoughBalance() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance, true); accountCapsule.setBalance(1000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -785,8 +785,8 @@ public void sameTokenNameCloseSameTokens() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -822,8 +822,8 @@ public void sameTokenNameOpenSameTokens() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -859,8 +859,8 @@ public void sameTokenNameCloseLessToken() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), 1000); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), 1000); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), 1000, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), 1000, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -897,8 +897,8 @@ public void sameTokenNameOpenLessToken() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), 1000); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), 1000); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), 1000, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), 1000, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -934,8 +934,8 @@ public void sameTokenNameCloseMoreThanBalanceLimit() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -972,8 +972,8 @@ public void sameTokenNameOpenMoreThanBalanceLimit() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenBalance, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1010,7 +1010,7 @@ public void sameTokenNameCloseBalanceNotEnough() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); accountCapsule.setBalance(firstTokenBalance + 1000L); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L, false); dbManager.getAccountStore().put(ownerAddress, accountCapsule); ExchangeCreateActuator actuator = new ExchangeCreateActuator(); @@ -1047,7 +1047,7 @@ public void sameTokenNameOpenBalanceNotEnough() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); accountCapsule.setBalance(firstTokenBalance + 1000L); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L, false); dbManager.getAccountStore().put(ownerAddress, accountCapsule); ExchangeCreateActuator actuator = new ExchangeCreateActuator(); @@ -1082,8 +1082,8 @@ public void sameTokenNameCloseFirstTokenBalanceNotEnough() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance - 1000L); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance - 1000L, false); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1120,8 +1120,8 @@ public void sameTokenNameOpenFirstTokenBalanceNotEnough() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance - 1000L); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance - 1000L, false); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1158,7 +1158,7 @@ public void sameTokenNameCloseBalanceNotEnough2() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); accountCapsule.setBalance(secondTokenBalance + 1000L); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), 200_000_000L); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), 200_000_000L, false); dbManager.getAccountStore().put(ownerAddress, accountCapsule); ExchangeCreateActuator actuator = new ExchangeCreateActuator(); @@ -1195,7 +1195,7 @@ public void sameTokenNameOpenBalanceNotEnough2() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); accountCapsule.setBalance(secondTokenBalance + 1000L); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), 200_000_000L); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), 200_000_000L, false); dbManager.getAccountStore().put(ownerAddress, accountCapsule); ExchangeCreateActuator actuator = new ExchangeCreateActuator(); @@ -1230,8 +1230,8 @@ public void sameTokenNameCloseSecondTokenBalanceNotEnough() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), 90_000_000L); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance, false); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), 90_000_000L, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1268,8 +1268,8 @@ public void sameTokenNameOpenSecondTokenBalanceNotEnough() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), 90_000_000L); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), 90_000_000L, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1305,7 +1305,7 @@ public void sameTokenNameCloseSecondTokenNotExist() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1342,7 +1342,7 @@ public void sameTokenNameOpenSecondTokenNotExist() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenBalance, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1388,7 +1388,7 @@ public void commonErrorCheck() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); accountCapsule.setBalance(200_000_000_000000L); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), 200_000_000L, true); dbManager.getAccountStore().put(ownerAddress, accountCapsule); actuatorTest.setContract(getContract( diff --git a/framework/src/test/java/org/tron/core/actuator/ExchangeInjectActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ExchangeInjectActuatorTest.java index 6268c226c7e..7aef11ed793 100644 --- a/framework/src/test/java/org/tron/core/actuator/ExchangeInjectActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/ExchangeInjectActuatorTest.java @@ -190,8 +190,8 @@ public void SameTokenNameCloseSuccessExchangeInject() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, false); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -451,7 +451,7 @@ public void SameTokenNameCloseSuccessExchangeInject2() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, false); accountCapsule.setBalance(firstTokenQuant); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -731,8 +731,8 @@ public void SameTokenNameCloseExchangeNotExist() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -819,8 +819,8 @@ public void SameTokenNameCloseAccountIsNotCreator() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -910,7 +910,7 @@ public void SameTokenNameCloseTokenIsNotInExchange() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, false); accountCapsule.setBalance(firstTokenQuant); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -995,8 +995,8 @@ public void SameTokenNameCloseTokenBalanceZero() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant, false); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, false); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1099,8 +1099,8 @@ public void SameTokenNameCloseTokenQuantLessThanZero() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), 1000L); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), 1000L, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1187,7 +1187,7 @@ public void SameTokenNameCloseCalculatedTokenQuantLessThanZero() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(firstTokenQuant); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1273,7 +1273,7 @@ public void SameTokenNameCloseTokenBalanceGreaterThanBalanceLimit() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(firstTokenQuant); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1358,7 +1358,7 @@ public void SameTokenNameCloseBalanceNotEnough() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(firstTokenQuant - 1); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1445,8 +1445,8 @@ public void SameTokenNameCloseTokenBalanceNotEnough() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant - 1); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant - 1, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1533,7 +1533,7 @@ public void SameTokenNameCloseBalanceNotEnough2() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(399_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1618,8 +1618,8 @@ public void SameTokenNameCloseAnotherTokenBalanceNotEnough() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant - 1); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant - 1, false); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, false); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1785,8 +1785,8 @@ public void sameTokennullTransationResult() { TransactionResultCapsule ret = null; byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); diff --git a/framework/src/test/java/org/tron/core/actuator/ExchangeTransactionActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ExchangeTransactionActuatorTest.java index 02107427cad..d39706e0699 100644 --- a/framework/src/test/java/org/tron/core/actuator/ExchangeTransactionActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/ExchangeTransactionActuatorTest.java @@ -430,7 +430,7 @@ public void SameTokenNameCloseSuccessExchangeTransaction2() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), 10000); + accountCapsule.addAssetAmount(tokenId.getBytes(), 10000, true); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -588,7 +588,7 @@ public void SameTokenNameCloseInvalidAddress() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), 10000); + accountCapsule.addAssetAmount(tokenId.getBytes(), 10000, false); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -679,7 +679,7 @@ public void SameTokenNameCloseNoEnoughBalance() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), 10000); + accountCapsule.addAssetAmount(tokenId.getBytes(), 10000, false); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -729,7 +729,7 @@ public void SameTokenNameOpenNoEnoughBalance() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), 10000); + accountCapsule.addAssetAmount(tokenId.getBytes(), 10000, true); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -779,7 +779,7 @@ public void SameTokenNameCloseNoAccount() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), 10000); + accountCapsule.addAssetAmount(tokenId.getBytes(), 10000, true); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -870,7 +870,7 @@ public void SameTokenNameCloseExchangeNotExist() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), 10000); + accountCapsule.addAssetAmount(tokenId.getBytes(), 10000, true); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -959,7 +959,7 @@ public void SameTokenNameCloseTokenIsNotInExchange() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), 10000); + accountCapsule.addAssetAmount(tokenId.getBytes(), 10000, true); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -1049,7 +1049,7 @@ public void SameTokenNameCloseTokenBalanceZero() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), 10000); + accountCapsule.addAssetAmount(tokenId.getBytes(), 10000, true); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -1155,7 +1155,7 @@ public void SameTokenNameCloseTokenQuantLessThanZero() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), 10000); + accountCapsule.addAssetAmount(tokenId.getBytes(), 10000, true); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -1245,7 +1245,7 @@ public void SameTokenNameCloseTokenBalanceGreaterThanBalanceLimit() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), 10000); + accountCapsule.addAssetAmount(tokenId.getBytes(), 10000, true); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -1421,7 +1421,7 @@ public void SameTokenNameCloseTokenBalanceNotEnough() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), quant - 1); + accountCapsule.addAssetAmount(tokenId.getBytes(), quant - 1, true); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -1502,6 +1502,7 @@ public void SameTokenNameOpenTokenBalanceNotEnough() { @Test public void SameTokenNameCloseTokenRequiredNotEnough() { dbManager.getDynamicPropertiesStore().saveAllowSameTokenName(0); + final boolean useStrictMath = dbManager.getDynamicPropertiesStore().allowStrictMath(); InitExchangeBeforeSameTokenNameActive(); long exchangeId = 2; String tokenId = "abc"; @@ -1510,7 +1511,7 @@ public void SameTokenNameCloseTokenRequiredNotEnough() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(tokenId.getBytes(), quant); + accountCapsule.addAssetAmount(tokenId.getBytes(), quant, true); Map assetMap = accountCapsule.getAssetMapForTest(); Assert.assertEquals(20000_000000L, accountCapsule.getBalance()); Assert.assertEquals(null, assetMap.get(buyTokenId)); @@ -1520,7 +1521,7 @@ public void SameTokenNameCloseTokenRequiredNotEnough() { try { ExchangeCapsule exchangeCapsule = dbManager.getExchangeStore() .get(ByteArray.fromLong(exchangeId)); - expected = exchangeCapsule.transaction(tokenId.getBytes(), quant); + expected = exchangeCapsule.transaction(tokenId.getBytes(), quant, useStrictMath); } catch (ItemNotFoundException e) { fail(); } @@ -1555,6 +1556,7 @@ public void SameTokenNameCloseTokenRequiredNotEnough() { @Test public void SameTokenNameOpenTokenRequiredNotEnough() { dbManager.getDynamicPropertiesStore().saveAllowSameTokenName(1); + final boolean useStrictMath = dbManager.getDynamicPropertiesStore().allowStrictMath(); InitExchangeSameTokenNameActive(); long exchangeId = 2; String tokenId = "123"; @@ -1575,7 +1577,7 @@ public void SameTokenNameOpenTokenRequiredNotEnough() { try { ExchangeCapsule exchangeCapsuleV2 = dbManager.getExchangeV2Store() .get(ByteArray.fromLong(exchangeId)); - expected = exchangeCapsuleV2.transaction(tokenId.getBytes(), quant); + expected = exchangeCapsuleV2.transaction(tokenId.getBytes(), quant, useStrictMath); } catch (ItemNotFoundException e) { fail(); } diff --git a/framework/src/test/java/org/tron/core/actuator/ExchangeWithdrawActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ExchangeWithdrawActuatorTest.java index 6844925288e..5c5536f873c 100644 --- a/framework/src/test/java/org/tron/core/actuator/ExchangeWithdrawActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/ExchangeWithdrawActuatorTest.java @@ -851,8 +851,8 @@ public void SameTokenNameCloseAccountIsNotCreator() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_SECOND); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -943,7 +943,7 @@ public void SameTokenNameCloseTokenIsNotInExchange() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(firstTokenQuant); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1030,8 +1030,8 @@ public void SameTokenNameCloseTokenBalanceZero() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), firstTokenQuant, false); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, false); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1136,8 +1136,8 @@ public void SameTokenNameCloseTokenQuantLessThanZero() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), 1000L); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), 1000L, true); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, true); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); @@ -1227,8 +1227,8 @@ public void SameTokenNameCloseTnotherTokenQuantLessThanZero() { byte[] ownerAddress = ByteArray.fromHexString(OWNER_ADDRESS_FIRST); AccountCapsule accountCapsule = dbManager.getAccountStore().get(ownerAddress); - accountCapsule.addAssetAmount(firstTokenId.getBytes(), 1000L); - accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant); + accountCapsule.addAssetAmount(firstTokenId.getBytes(), 1000L, false); + accountCapsule.addAssetAmount(secondTokenId.getBytes(), secondTokenQuant, false); accountCapsule.setBalance(10000_000000L); dbManager.getAccountStore().put(ownerAddress, accountCapsule); diff --git a/framework/src/test/java/org/tron/core/actuator/ParticipateAssetIssueActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ParticipateAssetIssueActuatorTest.java index 52e5f554374..88db0791b0a 100755 --- a/framework/src/test/java/org/tron/core/actuator/ParticipateAssetIssueActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/ParticipateAssetIssueActuatorTest.java @@ -1230,7 +1230,7 @@ public void sameTokenNameCloseNotEnoughAssetTest() { AccountCapsule toAccount = chainBaseManager.getAccountStore().get(ByteArray.fromHexString(TO_ADDRESS)); toAccount.reduceAssetAmount(ByteString.copyFromUtf8(ASSET_NAME).toByteArray(), - TOTAL_SUPPLY - 10000); + TOTAL_SUPPLY - 10000, true); chainBaseManager.getAccountStore().put(toAccount.getAddress().toByteArray(), toAccount); ParticipateAssetIssueActuator actuator = new ParticipateAssetIssueActuator(); actuator.setChainBaseManager(chainBaseManager).setAny(getContract(1)); diff --git a/framework/src/test/java/org/tron/core/actuator/ProposalCreateActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ProposalCreateActuatorTest.java index a42a4ffbe5a..7210fe8d074 100644 --- a/framework/src/test/java/org/tron/core/actuator/ProposalCreateActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/ProposalCreateActuatorTest.java @@ -1,6 +1,10 @@ package org.tron.core.actuator; import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertThrows; +import static org.tron.core.Constant.CREATE_ACCOUNT_TRANSACTION_MAX_BYTE_SIZE; +import static org.tron.core.Constant.CREATE_ACCOUNT_TRANSACTION_MIN_BYTE_SIZE; +import static org.tron.core.config.Parameter.ChainConstant.ONE_YEAR_BLOCK_NUMBERS; import com.google.protobuf.Any; import com.google.protobuf.ByteString; @@ -9,8 +13,10 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import org.tron.common.BaseTest; import org.tron.common.utils.ByteArray; +import org.tron.common.utils.ForkController; import org.tron.core.Constant; import org.tron.core.Wallet; import org.tron.core.capsule.AccountCapsule; @@ -279,6 +285,50 @@ public void invalidPara() { Assert.assertEquals("This value[REMOVE_THE_POWER_OF_THE_GR] is only allowed to be 1", e.getMessage()); } + // verify Proposal No. 78 + paras = new HashMap<>(); + paras.put(78L, 10L); + actuator = new ProposalCreateActuator(); + actuator.setChainBaseManager(dbManager.getChainBaseManager()) + .setForkUtils(dbManager.getChainBaseManager().getForkController()) + .setAny(getContract(OWNER_ADDRESS_FIRST, paras)); + assertThrows( + "Bad chain parameter id [MAX_DELEGATE_LOCK_PERIOD]", + ContractValidateException.class, actuator::validate); + + actuator = new ProposalCreateActuator(); + ForkController forkController = Mockito.mock(ForkController.class); + Mockito.when(forkController.pass(Mockito.any())).thenReturn(true); + actuator.setChainBaseManager(dbManager.getChainBaseManager()) + .setForkUtils(forkController) + .setAny(getContract(OWNER_ADDRESS_FIRST, paras)); + dbManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(86400L); + long maxDelegateLockPeriod = dbManager.getDynamicPropertiesStore().getMaxDelegateLockPeriod(); + assertThrows( + "This value[MAX_DELEGATE_LOCK_PERIOD] is only allowed to be greater than " + + maxDelegateLockPeriod + " and less than or equal to " + ONE_YEAR_BLOCK_NUMBERS + "!", + ContractValidateException.class, actuator::validate); + + // verify Proposal No. 82 + paras = new HashMap<>(); + paras.put(82L, 0L); + actuator = new ProposalCreateActuator(); + actuator.setChainBaseManager(dbManager.getChainBaseManager()) + .setForkUtils(dbManager.getChainBaseManager().getForkController()) + .setAny(getContract(OWNER_ADDRESS_FIRST, paras)); + assertThrows( + "Bad chain parameter id [ALLOW_ENERGY_ADJUSTMENT]", + ContractValidateException.class, actuator::validate); + + actuator = new ProposalCreateActuator(); + actuator.setChainBaseManager(dbManager.getChainBaseManager()) + .setForkUtils(forkController) + .setAny(getContract(OWNER_ADDRESS_FIRST, paras)); + assertThrows( + "This value[MAX_CREATE_ACCOUNT_TX_SIZE] is only allowed to be greater than or equal " + + "to " + CREATE_ACCOUNT_TRANSACTION_MIN_BYTE_SIZE + " and less than or equal to " + + CREATE_ACCOUNT_TRANSACTION_MAX_BYTE_SIZE + "!", + ContractValidateException.class, actuator::validate); } /** diff --git a/framework/src/test/java/org/tron/core/actuator/UpdateSettingContractActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/UpdateSettingContractActuatorTest.java index 508cee731f0..213bbd6cb85 100644 --- a/framework/src/test/java/org/tron/core/actuator/UpdateSettingContractActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/UpdateSettingContractActuatorTest.java @@ -108,8 +108,8 @@ public void successUpdateSettingContract() { Assert.assertEquals(ret.getInstance().getRet(), Protocol.Transaction.Result.code.SUCESS); Assert.assertEquals( dbManager.getContractStore().get(ByteArray.fromHexString(CONTRACT_ADDRESS)) - .getConsumeUserResourcePercent(), - TARGET_PERCENT); + .getConsumeUserResourcePercent( + dbManager.getDynamicPropertiesStore().disableJavaLangMath()), TARGET_PERCENT); } catch (ContractValidateException e) { Assert.assertFalse(e instanceof ContractValidateException); } catch (ContractExeException e) { @@ -245,8 +245,8 @@ public void twiceUpdateSettingContract() { Assert.assertEquals(ret.getInstance().getRet(), Protocol.Transaction.Result.code.SUCESS); Assert.assertEquals( dbManager.getContractStore().get(ByteArray.fromHexString(CONTRACT_ADDRESS)) - .getConsumeUserResourcePercent(), - TARGET_PERCENT); + .getConsumeUserResourcePercent( + dbManager.getDynamicPropertiesStore().disableJavaLangMath()), TARGET_PERCENT); // second secondActuator.validate(); @@ -255,8 +255,8 @@ public void twiceUpdateSettingContract() { Assert.assertEquals(ret.getInstance().getRet(), Protocol.Transaction.Result.code.SUCESS); Assert.assertEquals( dbManager.getContractStore().get(ByteArray.fromHexString(CONTRACT_ADDRESS)) - .getConsumeUserResourcePercent(), - 90L); + .getConsumeUserResourcePercent( + dbManager.getDynamicPropertiesStore().disableJavaLangMath()), 90L); } catch (ContractValidateException e) { Assert.assertFalse(e instanceof ContractValidateException); diff --git a/framework/src/test/java/org/tron/core/actuator/VoteWitnessActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/VoteWitnessActuatorTest.java index 1a152555931..d7fef2ab2f5 100644 --- a/framework/src/test/java/org/tron/core/actuator/VoteWitnessActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/VoteWitnessActuatorTest.java @@ -52,6 +52,7 @@ public class VoteWitnessActuatorTest extends BaseTest { static { Args.setParam(new String[]{"--output-directory", dbPath()}, Constant.TEST_CONF); + Args.getInstance().setConsensusLogicOptimization(1); OWNER_ADDRESS = Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049abc"; WITNESS_ADDRESS = Wallet.getAddressPreFixString() + "548794500882809695a8a687866e76d4271a1abc"; WITNESS_ADDRESS_NOACCOUNT = diff --git a/framework/src/test/java/org/tron/core/actuator/utils/ProposalUtilTest.java b/framework/src/test/java/org/tron/core/actuator/utils/ProposalUtilTest.java index 6f4df3cba8f..e8a1e862f54 100644 --- a/framework/src/test/java/org/tron/core/actuator/utils/ProposalUtilTest.java +++ b/framework/src/test/java/org/tron/core/actuator/utils/ProposalUtilTest.java @@ -3,7 +3,10 @@ import com.google.protobuf.ByteString; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; import org.junit.BeforeClass; @@ -12,13 +15,17 @@ import org.tron.common.utils.ByteArray; import org.tron.common.utils.ForkController; import org.tron.core.Constant; +import org.tron.core.capsule.BytesCapsule; +import org.tron.core.capsule.ProposalCapsule; import org.tron.core.config.Parameter; import org.tron.core.config.Parameter.ForkBlockVersionEnum; import org.tron.core.config.args.Args; +import org.tron.core.consensus.ProposalService; import org.tron.core.exception.ContractValidateException; import org.tron.core.store.DynamicPropertiesStore; import org.tron.core.utils.ProposalUtil; import org.tron.core.utils.ProposalUtil.ProposalType; +import org.tron.protos.Protocol; @Slf4j(topic = "actuator") public class ProposalUtilTest extends BaseTest { @@ -27,6 +34,11 @@ public class ProposalUtilTest extends BaseTest { private static final String LONG_VALUE_ERROR = "Bad chain parameter value, valid range is [0," + LONG_VALUE + "]"; + @Resource + private DynamicPropertiesStore dynamicPropertiesStore; + + ForkController forkUtils = ForkController.instance(); + /** * Init . */ @@ -60,8 +72,6 @@ public void validProposalTypeCheck() throws ContractValidateException { @Test public void validateCheck() { - DynamicPropertiesStore dynamicPropertiesStore = null; - ForkController forkUtils = ForkController.instance(); long invalidValue = -1; try { @@ -328,11 +338,327 @@ public void validateCheck() { e.getMessage()); } + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_OLD_REWARD_OPT.getCode(), 2); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "Bad chain parameter id [ALLOW_OLD_REWARD_OPT]", + e.getMessage()); + } + hardForkTime = + ((ForkBlockVersionEnum.VERSION_4_7_4.getHardForkTime() - 1) / maintenanceTimeInterval + 1) + * maintenanceTimeInterval; + forkUtils.getManager().getDynamicPropertiesStore() + .saveLatestBlockHeaderTimestamp(hardForkTime + 1); + forkUtils.getManager().getDynamicPropertiesStore() + .statsByVersion(ForkBlockVersionEnum.VERSION_4_7_4.getValue(), stats); + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_OLD_REWARD_OPT.getCode(), 2); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "This value[ALLOW_OLD_REWARD_OPT] is only allowed to be 1", + e.getMessage()); + } + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_OLD_REWARD_OPT.getCode(), 1); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "[ALLOW_NEW_REWARD] or [ALLOW_TVM_VOTE] proposal must be approved " + + "before [ALLOW_OLD_REWARD_OPT] can be proposed", + e.getMessage()); + } + dynamicPropertiesStore.put("NEW_REWARD_ALGORITHM_EFFECTIVE_CYCLE".getBytes(), + new BytesCapsule(ByteArray.fromLong(4000))); + dynamicPropertiesStore.saveAllowOldRewardOpt(1); + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_OLD_REWARD_OPT.getCode(), 1); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "[ALLOW_OLD_REWARD_OPT] has been valid, no need to propose again", + e.getMessage()); + } + + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_STRICT_MATH.getCode(), 2); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "Bad chain parameter id [ALLOW_STRICT_MATH]", + e.getMessage()); + } + hardForkTime = + ((ForkBlockVersionEnum.VERSION_4_7_7.getHardForkTime() - 1) / maintenanceTimeInterval + 1) + * maintenanceTimeInterval; + forkUtils.getManager().getDynamicPropertiesStore() + .saveLatestBlockHeaderTimestamp(hardForkTime + 1); + forkUtils.getManager().getDynamicPropertiesStore() + .statsByVersion(ForkBlockVersionEnum.VERSION_4_7_7.getValue(), stats); + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_STRICT_MATH.getCode(), 2); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "This value[ALLOW_STRICT_MATH] is only allowed to be 1", + e.getMessage()); + } + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_STRICT_MATH.getCode(), 1); + } catch (ContractValidateException e) { + Assert.fail(e.getMessage()); + } + Protocol.Proposal proposal = Protocol.Proposal.newBuilder().putParameters( + ProposalType.ALLOW_STRICT_MATH.getCode(), 1).build(); + ProposalCapsule proposalCapsule = new ProposalCapsule(proposal); + ProposalService.process(dbManager, proposalCapsule); + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_STRICT_MATH.getCode(), 1); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "[ALLOW_STRICT_MATH] has been valid, no need to propose again", + e.getMessage()); + } + + testEnergyAdjustmentProposal(); + + testConsensusLogicOptimizationProposal(); + + testAllowTvmCancunProposal(); + + testAllowTvmBlobProposal(); + forkUtils.getManager().getDynamicPropertiesStore() .statsByVersion(ForkBlockVersionEnum.ENERGY_LIMIT.getValue(), stats); forkUtils.reset(); } + private void testEnergyAdjustmentProposal() { + // Should fail because cannot pass the fork controller check + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_ENERGY_ADJUSTMENT.getCode(), 1); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "Bad chain parameter id [ALLOW_ENERGY_ADJUSTMENT]", + e.getMessage()); + } + + long maintenanceTimeInterval = forkUtils.getManager().getDynamicPropertiesStore() + .getMaintenanceTimeInterval(); + + long hardForkTime = + ((ForkBlockVersionEnum.VERSION_4_7_5.getHardForkTime() - 1) / maintenanceTimeInterval + 1) + * maintenanceTimeInterval; + forkUtils.getManager().getDynamicPropertiesStore() + .saveLatestBlockHeaderTimestamp(hardForkTime + 1); + + byte[] stats = new byte[27]; + Arrays.fill(stats, (byte) 1); + forkUtils.getManager().getDynamicPropertiesStore() + .statsByVersion(ForkBlockVersionEnum.VERSION_4_7_5.getValue(), stats); + + // Should fail because the proposal value is invalid + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_ENERGY_ADJUSTMENT.getCode(), 2); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "This value[ALLOW_ENERGY_ADJUSTMENT] is only allowed to be 1", + e.getMessage()); + } + + // Should succeed + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_ENERGY_ADJUSTMENT.getCode(), 1); + } catch (Throwable t) { + Assert.fail(); + } + + ProposalCapsule proposalCapsule = new ProposalCapsule(ByteString.empty(), 0); + Map parameter = new HashMap<>(); + parameter.put(81L, 1L); + proposalCapsule.setParameters(parameter); + ProposalService.process(dbManager, proposalCapsule); + + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_ENERGY_ADJUSTMENT.getCode(), 1); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "[ALLOW_ENERGY_ADJUSTMENT] has been valid, no need to propose again", + e.getMessage()); + } + } + + private void testConsensusLogicOptimizationProposal() { + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.CONSENSUS_LOGIC_OPTIMIZATION.getCode(), 1); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "Bad chain parameter id [CONSENSUS_LOGIC_OPTIMIZATION]", + e.getMessage()); + } + + long maintenanceTimeInterval = forkUtils.getManager().getDynamicPropertiesStore() + .getMaintenanceTimeInterval(); + + long hardForkTime = + ((ForkBlockVersionEnum.VERSION_4_8_0.getHardForkTime() - 1) / maintenanceTimeInterval + 1) + * maintenanceTimeInterval; + forkUtils.getManager().getDynamicPropertiesStore() + .saveLatestBlockHeaderTimestamp(hardForkTime + 1); + + byte[] stats = new byte[27]; + Arrays.fill(stats, (byte) 1); + forkUtils.getManager().getDynamicPropertiesStore() + .statsByVersion(ForkBlockVersionEnum.VERSION_4_8_0.getValue(), stats); + + // Should fail because the proposal value is invalid + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.CONSENSUS_LOGIC_OPTIMIZATION.getCode(), 2); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "This value[CONSENSUS_LOGIC_OPTIMIZATION] is only allowed to be 1", + e.getMessage()); + } + + dynamicPropertiesStore.saveConsensusLogicOptimization(1); + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.CONSENSUS_LOGIC_OPTIMIZATION.getCode(), 1); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "[CONSENSUS_LOGIC_OPTIMIZATION] has been valid, no need to propose again", + e.getMessage()); + } + + } + + private void testAllowTvmCancunProposal() { + byte[] stats = new byte[27]; + forkUtils.getManager().getDynamicPropertiesStore() + .statsByVersion(ForkBlockVersionEnum.VERSION_4_8_0.getValue(), stats); + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_TVM_CANCUN.getCode(), 1); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "Bad chain parameter id [ALLOW_TVM_CANCUN]", + e.getMessage()); + } + + long maintenanceTimeInterval = forkUtils.getManager().getDynamicPropertiesStore() + .getMaintenanceTimeInterval(); + + long hardForkTime = + ((ForkBlockVersionEnum.VERSION_4_8_0.getHardForkTime() - 1) / maintenanceTimeInterval + 1) + * maintenanceTimeInterval; + forkUtils.getManager().getDynamicPropertiesStore() + .saveLatestBlockHeaderTimestamp(hardForkTime + 1); + + stats = new byte[27]; + Arrays.fill(stats, (byte) 1); + forkUtils.getManager().getDynamicPropertiesStore() + .statsByVersion(ForkBlockVersionEnum.VERSION_4_8_0.getValue(), stats); + + // Should fail because the proposal value is invalid + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_TVM_CANCUN.getCode(), 2); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "This value[ALLOW_TVM_CANCUN] is only allowed to be 1", + e.getMessage()); + } + + dynamicPropertiesStore.saveAllowTvmCancun(1); + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_TVM_CANCUN.getCode(), 1); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "[ALLOW_TVM_CANCUN] has been valid, no need to propose again", + e.getMessage()); + } + + } + + private void testAllowTvmBlobProposal() { + byte[] stats = new byte[27]; + forkUtils.getManager().getDynamicPropertiesStore() + .statsByVersion(ForkBlockVersionEnum.VERSION_4_8_0.getValue(), stats); + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_TVM_BLOB.getCode(), 1); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "Bad chain parameter id [ALLOW_TVM_BLOB]", + e.getMessage()); + } + + long maintenanceTimeInterval = forkUtils.getManager().getDynamicPropertiesStore() + .getMaintenanceTimeInterval(); + + long hardForkTime = + ((ForkBlockVersionEnum.VERSION_4_8_0.getHardForkTime() - 1) / maintenanceTimeInterval + 1) + * maintenanceTimeInterval; + forkUtils.getManager().getDynamicPropertiesStore() + .saveLatestBlockHeaderTimestamp(hardForkTime + 1); + + stats = new byte[27]; + Arrays.fill(stats, (byte) 1); + forkUtils.getManager().getDynamicPropertiesStore() + .statsByVersion(ForkBlockVersionEnum.VERSION_4_8_0.getValue(), stats); + + // Should fail because the proposal value is invalid + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_TVM_BLOB.getCode(), 2); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "This value[ALLOW_TVM_BLOB] is only allowed to be 1", + e.getMessage()); + } + + dynamicPropertiesStore.saveAllowTvmBlob(1); + try { + ProposalUtil.validator(dynamicPropertiesStore, forkUtils, + ProposalType.ALLOW_TVM_BLOB.getCode(), 1); + Assert.fail(); + } catch (ContractValidateException e) { + Assert.assertEquals( + "[ALLOW_TVM_BLOB] has been valid, no need to propose again", + e.getMessage()); + } + + } + @Test public void blockVersionCheck() { for (ForkBlockVersionEnum forkVersion : ForkBlockVersionEnum.values()) { diff --git a/framework/src/test/java/org/tron/core/actuator/utils/TransactionUtilTest.java b/framework/src/test/java/org/tron/core/actuator/utils/TransactionUtilTest.java index 9d56876a4da..0eb69f8fd66 100644 --- a/framework/src/test/java/org/tron/core/actuator/utils/TransactionUtilTest.java +++ b/framework/src/test/java/org/tron/core/actuator/utils/TransactionUtilTest.java @@ -3,6 +3,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.tron.common.math.Maths.max; import static org.tron.core.capsule.utils.TransactionUtil.isNumber; import static org.tron.core.config.Parameter.ChainConstant.DELEGATE_COST_BASE_SIZE; import static org.tron.core.config.Parameter.ChainConstant.DELEGATE_PERIOD; @@ -14,6 +15,7 @@ import com.google.protobuf.ByteString; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.List; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; @@ -113,7 +115,7 @@ public static long estimateConsumeBandWidthSize(final AccountCapsule ownerCapsul TransactionCapsule fakeTransactionCapsule2 = new TransactionCapsule(builder2.build(), ContractType.DelegateResourceContract); long size2 = consumeBandWidthSize(fakeTransactionCapsule2, chainBaseManager); - long addSize = Math.max(size1 - size2, 0L); + long addSize = max(size1 - size2, 0L, true); return DELEGATE_COST_BASE_SIZE + addSize; } @@ -134,7 +136,7 @@ public static long estimateConsumeBandWidthSizeOld( TransactionCapsule fakeTransactionCapsule2 = new TransactionCapsule(builder2.build(), ContractType.DelegateResourceContract); long size2 = consumeBandWidthSize(fakeTransactionCapsule2, chainBaseManager); - long addSize = Math.max(size1 - size2, 0L); + long addSize = max(size1 - size2, 0L, true); return DELEGATE_COST_BASE_SIZE + addSize; } @@ -372,8 +374,8 @@ public void estimateConsumeBandWidthSizePositive() { DelegateResourceContract.newBuilder() .setBalance(TRX_PRECISION); - long expected = DELEGATE_COST_BASE_SIZE + Math.max( - builder.build().getSerializedSize() - builder2.build().getSerializedSize(), 0L); + long expected = DELEGATE_COST_BASE_SIZE + max( + builder.build().getSerializedSize() - builder2.build().getSerializedSize(), 0L, true); long actual = TransactionUtil.estimateConsumeBandWidthSize(dps, balance); Assert.assertEquals(expected, actual); } @@ -390,8 +392,8 @@ public void estimateConsumeBandWidthSizeBoundary() { DelegateResourceContract.newBuilder() .setBalance(TRX_PRECISION); - long expected = DELEGATE_COST_BASE_SIZE + Math.max( - builder.build().getSerializedSize() - builder2.build().getSerializedSize(), 0L); + long expected = DELEGATE_COST_BASE_SIZE + max( + builder.build().getSerializedSize() - builder2.build().getSerializedSize(), 0L, true); long actual = TransactionUtil.estimateConsumeBandWidthSize(dps, balance); Assert.assertEquals(expected, actual); } @@ -408,8 +410,8 @@ public void estimateConsumeBandWidthSizeEdge() { DelegateResourceContract.newBuilder() .setBalance(TRX_PRECISION); - long expected = DELEGATE_COST_BASE_SIZE + Math.max( - builder.build().getSerializedSize() - builder2.build().getSerializedSize(), 0L); + long expected = DELEGATE_COST_BASE_SIZE + max( + builder.build().getSerializedSize() - builder2.build().getSerializedSize(), 0L, true); long actual = TransactionUtil.estimateConsumeBandWidthSize(dps, balance); Assert.assertEquals(expected, actual); } @@ -426,9 +428,27 @@ public void estimateConsumeBandWidthSizeCorner() { DelegateResourceContract.newBuilder() .setBalance(TRX_PRECISION); - long expected = DELEGATE_COST_BASE_SIZE + Math.max( - builder.build().getSerializedSize() - builder2.build().getSerializedSize(), 0L); + long expected = DELEGATE_COST_BASE_SIZE + max( + builder.build().getSerializedSize() - builder2.build().getSerializedSize(), 0L, true); long actual = TransactionUtil.estimateConsumeBandWidthSize(dps, balance); Assert.assertEquals(expected, actual); } + + @Test + public void testConcurrentToString() throws InterruptedException { + Transaction.Builder builder = Transaction.newBuilder(); + TransactionCapsule trx = new TransactionCapsule(builder.build()); + List threadList = new ArrayList<>(); + int n = 10; + for (int i = 0; i < n; i++) { + threadList.add(new Thread(() -> trx.toString())); + } + for (int i = 0; i < n; i++) { + threadList.get(i).start(); + } + for (int i = 0; i < n; i++) { + threadList.get(i).join(); + } + Assert.assertTrue(true); + } } diff --git a/framework/src/test/java/org/tron/core/capsule/AccountCapsuleTest.java b/framework/src/test/java/org/tron/core/capsule/AccountCapsuleTest.java index de72b4be276..7a217dfd787 100644 --- a/framework/src/test/java/org/tron/core/capsule/AccountCapsuleTest.java +++ b/framework/src/test/java/org/tron/core/capsule/AccountCapsuleTest.java @@ -36,7 +36,7 @@ public class AccountCapsuleTest extends BaseTest { static AccountCapsule accountCapsule; static { - Args.setParam(new String[]{"-d", dbPath(), "-w"}, Constant.TEST_CONF); + Args.setParam(new String[]{"-d", dbPath()}, Constant.TEST_CONF); OWNER_ADDRESS = Wallet.getAddressPreFixString() + "a06a17a49648a8ad32055c06f60fa14ae46df91234"; } @@ -90,7 +90,7 @@ public void AssetAmountTest() { String nameAdd = "TokenX"; long amountAdd = 222L; boolean addBoolean = accountCapsuleTest - .addAssetAmount(nameAdd.getBytes(), amountAdd); + .addAssetAmount(nameAdd.getBytes(), amountAdd, true); Assert.assertTrue(addBoolean); @@ -102,7 +102,7 @@ public void AssetAmountTest() { long amountReduce = 22L; boolean reduceBoolean = accountCapsuleTest - .reduceAssetAmount(ByteArray.fromString("TokenX"), amountReduce); + .reduceAssetAmount(ByteArray.fromString("TokenX"), amountReduce, false); Assert.assertTrue(reduceBoolean); Map assetMapAfter = accountCapsuleTest.getAssetMapForTest(); diff --git a/framework/src/test/java/org/tron/core/capsule/BlockCapsuleTest.java b/framework/src/test/java/org/tron/core/capsule/BlockCapsuleTest.java index 0dd078dedb0..3c86d893895 100644 --- a/framework/src/test/java/org/tron/core/capsule/BlockCapsuleTest.java +++ b/framework/src/test/java/org/tron/core/capsule/BlockCapsuleTest.java @@ -2,7 +2,9 @@ import com.google.protobuf.ByteString; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import lombok.extern.slf4j.Slf4j; import org.junit.AfterClass; import org.junit.Assert; @@ -146,4 +148,20 @@ public void testGetTimeStamp() { Assert.assertEquals(1234L, blockCapsule0.getTimeStamp()); } + @Test + public void testConcurrentToString() throws InterruptedException { + List threadList = new ArrayList<>(); + int n = 10; + for (int i = 0; i < n; i++) { + threadList.add(new Thread(() -> blockCapsule0.toString())); + } + for (int i = 0; i < n; i++) { + threadList.get(i).start(); + } + for (int i = 0; i < n; i++) { + threadList.get(i).join(); + } + Assert.assertTrue(true); + } + } diff --git a/framework/src/test/java/org/tron/core/capsule/ContractStateCapsuleTest.java b/framework/src/test/java/org/tron/core/capsule/ContractStateCapsuleTest.java index 90f74074a9b..c90ad89abb3 100644 --- a/framework/src/test/java/org/tron/core/capsule/ContractStateCapsuleTest.java +++ b/framework/src/test/java/org/tron/core/capsule/ContractStateCapsuleTest.java @@ -1,7 +1,12 @@ package org.tron.core.capsule; +import org.junit.After; import org.junit.Assert; import org.junit.Test; +import org.mockito.Mockito; +import org.tron.core.config.args.Args; +import org.tron.core.store.DynamicPropertiesStore; +import org.tron.core.vm.config.VMConfig; import org.tron.protos.contract.SmartContractOuterClass; public class ContractStateCapsuleTest { @@ -15,12 +20,12 @@ public void testCatchUpCycle() { .setUpdateCycle(1000L) .build()); - Assert.assertFalse(capsule.catchUpToCycle(1000L, 2_000_000L, 2000L, 10_00L)); + Assert.assertFalse(capsule.catchUpToCycle(1000L, 2_000_000L, 2000L, 10_00L, false, false)); Assert.assertEquals(1000L, capsule.getUpdateCycle()); Assert.assertEquals(1_000_000L, capsule.getEnergyUsage()); Assert.assertEquals(5000L, capsule.getEnergyFactor()); - Assert.assertTrue(capsule.catchUpToCycle(1010L, 900_000L, 1000L, 10_000L)); + Assert.assertTrue(capsule.catchUpToCycle(1010L, 900_000L, 1000L, 10_000L, false, false)); Assert.assertEquals(1010L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(3137L, capsule.getEnergyFactor()); @@ -32,7 +37,7 @@ public void testCatchUpCycle() { .setUpdateCycle(1000L) .build()); - Assert.assertTrue(capsule.catchUpToCycle(1001L, 2_000_000L, 2000L, 10_000L)); + Assert.assertTrue(capsule.catchUpToCycle(1001L, 2_000_000L, 2000L, 10_000L, false, false)); Assert.assertEquals(1001L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(4250L, capsule.getEnergyFactor()); @@ -44,7 +49,7 @@ public void testCatchUpCycle() { .setUpdateCycle(1000L) .build()); - Assert.assertTrue(capsule.catchUpToCycle(1001L, 1_000_000L, 2000L, 10_000L)); + Assert.assertTrue(capsule.catchUpToCycle(1001L, 1_000_000L, 2000L, 10_000L, false, false)); Assert.assertEquals(1001L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(4250L, capsule.getEnergyFactor()); @@ -56,7 +61,7 @@ public void testCatchUpCycle() { .setUpdateCycle(1000L) .build()); - Assert.assertTrue(capsule.catchUpToCycle(1001L, 900_000L, 2000L, 10_000L)); + Assert.assertTrue(capsule.catchUpToCycle(1001L, 900_000L, 2000L, 10_000L, false, false)); Assert.assertEquals(1001L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(8000L, capsule.getEnergyFactor()); @@ -68,7 +73,7 @@ public void testCatchUpCycle() { .setUpdateCycle(1000L) .build()); - Assert.assertTrue(capsule.catchUpToCycle(1001L, 900_000L, 5000L, 10_000L)); + Assert.assertTrue(capsule.catchUpToCycle(1001L, 900_000L, 5000L, 10_000L, false, false)); Assert.assertEquals(1001L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(10_000L, capsule.getEnergyFactor()); @@ -80,7 +85,7 @@ public void testCatchUpCycle() { .setUpdateCycle(1000L) .build()); - Assert.assertTrue(capsule.catchUpToCycle(1002L, 900_000L, 5000L, 10_000L)); + Assert.assertTrue(capsule.catchUpToCycle(1002L, 900_000L, 5000L, 10_000L, false, false)); Assert.assertEquals(1002L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(7500L, capsule.getEnergyFactor()); @@ -92,7 +97,7 @@ public void testCatchUpCycle() { .setUpdateCycle(1000L) .build()); - Assert.assertTrue(capsule.catchUpToCycle(1003L, 900_000L, 5000L, 10_000L)); + Assert.assertTrue(capsule.catchUpToCycle(1003L, 900_000L, 5000L, 10_000L, false, false)); Assert.assertEquals(1003L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(5312L, capsule.getEnergyFactor()); @@ -104,7 +109,7 @@ public void testCatchUpCycle() { .setUpdateCycle(1000L) .build()); - Assert.assertTrue(capsule.catchUpToCycle(1004L, 900_000L, 5000L, 10_000L)); + Assert.assertTrue(capsule.catchUpToCycle(1004L, 900_000L, 5000L, 10_000L, false, false)); Assert.assertEquals(1004L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(3398L, capsule.getEnergyFactor()); @@ -116,7 +121,7 @@ public void testCatchUpCycle() { .setUpdateCycle(1000L) .build()); - Assert.assertTrue(capsule.catchUpToCycle(1005L, 900_000L, 5000L, 10_000L)); + Assert.assertTrue(capsule.catchUpToCycle(1005L, 900_000L, 5000L, 10_000L, true, true)); Assert.assertEquals(1005L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(1723L, capsule.getEnergyFactor()); @@ -128,7 +133,7 @@ public void testCatchUpCycle() { .setUpdateCycle(1000L) .build()); - Assert.assertTrue(capsule.catchUpToCycle(1005L, 900_000L, 5000L, 10_000L)); + Assert.assertTrue(capsule.catchUpToCycle(1005L, 900_000L, 5000L, 10_000L, true, true)); Assert.assertEquals(1005L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(1723L, capsule.getEnergyFactor()); @@ -140,7 +145,7 @@ public void testCatchUpCycle() { .setUpdateCycle(1000L) .build()); - Assert.assertTrue(capsule.catchUpToCycle(1006L, 900_000L, 5000L, 10_000L)); + Assert.assertTrue(capsule.catchUpToCycle(1006L, 900_000L, 5000L, 10_000L, true, true)); Assert.assertEquals(1006L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(258L, capsule.getEnergyFactor()); @@ -151,12 +156,25 @@ public void testCatchUpCycle() { .setEnergyFactor(5000L) .setUpdateCycle(1000L) .build()); - - Assert.assertTrue(capsule.catchUpToCycle(1007L, 900_000L, 5000L, 10_000L)); + Args.getInstance().setAllowStrictMath(1); + VMConfig.initAllowStrictMath(Args.getInstance().getAllowStrictMath()); + DynamicPropertiesStore dps = Mockito.mock(DynamicPropertiesStore.class); + Mockito.when(dps.getCurrentCycleNumber()).thenReturn(1007L); + Mockito.when(dps.getDynamicEnergyThreshold()).thenReturn(900_000L); + Mockito.when(dps.getDynamicEnergyIncreaseFactor()).thenReturn(5000L); + Mockito.when(dps.getDynamicEnergyMaxFactor()).thenReturn(10_000L); + Mockito.when(dps.allowStrictMath()).thenReturn(VMConfig.allowStrictMath()); + Assert.assertTrue(capsule.catchUpToCycle(dps)); Assert.assertEquals(1007L, capsule.getUpdateCycle()); Assert.assertEquals(0L, capsule.getEnergyUsage()); Assert.assertEquals(0L, capsule.getEnergyFactor()); } + @After + public void reset() { + Args.clearParam(); + + } + } diff --git a/framework/src/test/java/org/tron/core/capsule/ExchangeCapsuleTest.java b/framework/src/test/java/org/tron/core/capsule/ExchangeCapsuleTest.java index 791767a952f..5fcd259d738 100644 --- a/framework/src/test/java/org/tron/core/capsule/ExchangeCapsuleTest.java +++ b/framework/src/test/java/org/tron/core/capsule/ExchangeCapsuleTest.java @@ -52,8 +52,8 @@ public void testExchange() { long sellQuant = 1_000_000L; byte[] sellID = "abc".getBytes(); - - long result = exchangeCapsule.transaction(sellID, sellQuant); + boolean useStrictMath = chainBaseManager.getDynamicPropertiesStore().allowStrictMath(); + long result = exchangeCapsule.transaction(sellID, sellQuant, useStrictMath); Assert.assertEquals(990_099L, result); sellBalance += sellQuant; Assert.assertEquals(sellBalance, exchangeCapsule.getFirstTokenBalance()); @@ -61,7 +61,7 @@ public void testExchange() { Assert.assertEquals(buyBalance, exchangeCapsule.getSecondTokenBalance()); sellQuant = 9_000_000L; - long result2 = exchangeCapsule.transaction(sellID, sellQuant); + long result2 = exchangeCapsule.transaction(sellID, sellQuant, useStrictMath); Assert.assertEquals(9090909L, result + result2); sellBalance += sellQuant; Assert.assertEquals(sellBalance, exchangeCapsule.getFirstTokenBalance()); diff --git a/framework/src/test/java/org/tron/core/capsule/TransactionCapsuleTest.java b/framework/src/test/java/org/tron/core/capsule/TransactionCapsuleTest.java index fcb2a4fbfd5..7065608f188 100644 --- a/framework/src/test/java/org/tron/core/capsule/TransactionCapsuleTest.java +++ b/framework/src/test/java/org/tron/core/capsule/TransactionCapsuleTest.java @@ -1,5 +1,9 @@ package org.tron.core.capsule; +import static org.tron.protos.Protocol.Transaction.Result.contractResult.BAD_JUMP_DESTINATION; +import static org.tron.protos.Protocol.Transaction.Result.contractResult.PRECOMPILED_CONTRACT; +import static org.tron.protos.Protocol.Transaction.Result.contractResult.SUCCESS; + import com.google.protobuf.ByteString; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; @@ -13,55 +17,20 @@ import org.tron.core.config.args.Args; import org.tron.protos.Protocol.AccountType; import org.tron.protos.Protocol.Transaction; +import org.tron.protos.Protocol.Transaction.Contract.ContractType; import org.tron.protos.Protocol.Transaction.Result; import org.tron.protos.Protocol.Transaction.Result.contractResult; +import org.tron.protos.Protocol.Transaction.raw; @Slf4j public class TransactionCapsuleTest extends BaseTest { private static String OWNER_ADDRESS; - /*private static String OWNER_KEY = - "bfa67cb3dc6609b3a0c98e717d66f38ed1a159b5b3421678dfab85961c40de2f"; - private static String TO_ADDRESS; - private static String OWNER_ACCOUNT_NOT_Exist; - private static String KEY_11 = "1111111111111111111111111111111111111111111111111111111111111111"; - private static String KEY_12 = "1212121212121212121212121212121212121212121212121212121212121212"; - private static String KEY_13 = "1313131313131313131313131313131313131313131313131313131313131313"; - private static String KEY_21 = "2121212121212121212121212121212121212121212121212121212121212121"; - private static String KEY_22 = "2222222222222222222222222222222222222222222222222222222222222222"; - private static String KEY_23 = "2323232323232323232323232323232323232323232323232323232323232323"; - private static String KEY_31 = "3131313131313131313131313131313131313131313131313131313131313131"; - private static String KEY_32 = "3232323232323232323232323232323232323232323232323232323232323232"; - private static String KEY_33 = "3333333333333333333333333333333333333333333333333333333333333333"; - - private static String KEY_ADDRESS_11; - private static String KEY_ADDRESS_12; - private static String KEY_ADDRESS_13; - private static String KEY_ADDRESS_21; - private static String KEY_ADDRESS_22; - private static String KEY_ADDRESS_23; - private static String KEY_ADDRESS_31; - private static String KEY_ADDRESS_32; - private static String KEY_ADDRESS_33;*/ @BeforeClass public static void init() { Args.setParam(new String[]{"-d", dbPath()}, Constant.TEST_CONF); OWNER_ADDRESS = Wallet.getAddressPreFixString() + "03702350064AD5C1A8AA6B4D74B051199CFF8EA7"; - /*TO_ADDRESS = Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049abc"; - OWNER_ACCOUNT_NOT_Exist = - Wallet.getAddressPreFixString() + "548794500882809695a8a687866e76d4271a3456"; - KEY_ADDRESS_11 = Wallet.getAddressPreFixString() + "19E7E376E7C213B7E7E7E46CC70A5DD086DAFF2A"; - KEY_ADDRESS_12 = Wallet.getAddressPreFixString() + "1C5A77D9FA7EF466951B2F01F724BCA3A5820B63"; - KEY_ADDRESS_13 = Wallet.getAddressPreFixString() + "03A1BBA60B5AA37094CF16123ADD674C01589488"; - - KEY_ADDRESS_21 = Wallet.getAddressPreFixString() + "2BD0C9FE079C8FCA0E3352EB3D02839C371E5C41"; - KEY_ADDRESS_22 = Wallet.getAddressPreFixString() + "1563915E194D8CFBA1943570603F7606A3115508"; - KEY_ADDRESS_23 = Wallet.getAddressPreFixString() + "D3E442496EB66A4748912EC4A3B7A111D0B855D6"; - - KEY_ADDRESS_31 = Wallet.getAddressPreFixString() + "77952CE83CA3CAD9F7ADCFABEDA85BD2F1F52008"; - KEY_ADDRESS_32 = Wallet.getAddressPreFixString() + "94622CC2A5B64A58C25A129D48A2BEEC4B65B779"; - KEY_ADDRESS_33 = Wallet.getAddressPreFixString() + "5CBDD86A2FA8DC4BDDD8A8F69DBA48572EEC07FB";*/ } /** @@ -74,984 +43,6 @@ public void createAccountCapsule() { dbManager.getAccountStore().put(ownerCapsule.createDbKey(), ownerCapsule); } - /*@Test - public void getDefaultPermission() { - String[] names = {"active", "owner", "other"}; - ByteString address = ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)); - for (String name : names) { - Permission permission = TransactionCapsule - .getDefaultPermission(address, name); - Assert.assertEquals(permission.getName(), name); - Assert.assertEquals(permission.getThreshold(), 1); - if ("owner".equalsIgnoreCase(name)) { - Assert.assertEquals(permission.getParent(), ""); - } else { - Assert.assertEquals(permission.getParent(), "owner"); - } - Assert.assertEquals(permission.getKeysCount(), 1); - Key key = permission.getKeys(0); - Assert.assertEquals(key.getAddress(), address); - Assert.assertEquals(key.getWeight(), 1); - } - } - - public TransferContract createTransferContract(byte[] to, byte[] owner, long amount) { - TransferContract.Builder builder = TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - return builder.build(); - } - - public PermissionAddKeyContract createPermissionAddKeyContract(byte[] owner, String name, - byte[] address, int weight) { - PermissionAddKeyContract.Builder contractBuilder = PermissionAddKeyContract.newBuilder(); - contractBuilder.setOwnerAddress(ByteString.copyFrom(owner)); - contractBuilder.setPermissionName(name); - Key.Builder keyBuilder = Key.newBuilder(); - keyBuilder.setAddress(ByteString.copyFrom(address)); - keyBuilder.setWeight(weight); - contractBuilder.setKey(keyBuilder.build()); - return contractBuilder.build(); - } - - public void updatePermission(List permissions, byte[] address) { - Account account = dbManager.getAccountStore().get(address).getInstance(); - Account.Builder builder = account.toBuilder(); - for (Permission permission : permissions) { - builder.addPermissions(permission); - } - dbManager.getAccountStore().put(address, new AccountCapsule(builder.build())); - } - - public List buildPermissions() { - Permission.Builder builder1 = Permission.newBuilder(); - Key.Builder key11 = Key.newBuilder(); - Key.Builder key12 = Key.newBuilder(); - Key.Builder key13 = Key.newBuilder(); - key11.setAddress(ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_11))).setWeight(1); - key12.setAddress(ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_12))).setWeight(1); - key13.setAddress(ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_13))).setWeight(1); - builder1.setName("owner").setThreshold(2).setParent("").addKeys(key11).addKeys(key12) - .addKeys(key13); - Permission.Builder builder2 = Permission.newBuilder(); - Key.Builder key21 = Key.newBuilder(); - Key.Builder key22 = Key.newBuilder(); - Key.Builder key23 = Key.newBuilder(); - key21.setAddress(ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_21))).setWeight(1); - key22.setAddress(ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_22))).setWeight(1); - key23.setAddress(ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_23))).setWeight(1); - builder2.setName("active").setThreshold(2).setParent("").addKeys(key21).addKeys(key22) - .addKeys(key23); - Permission.Builder builder3 = Permission.newBuilder(); - Key.Builder key31 = Key.newBuilder(); - Key.Builder key32 = Key.newBuilder(); - Key.Builder key33 = Key.newBuilder(); - key31.setAddress(ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_31))).setWeight(1); - key32.setAddress(ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_32))).setWeight(1); - key33.setAddress(ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_33))).setWeight(1); - builder3.setName("other").setThreshold(2).setParent("").addKeys(key31).addKeys(key32) - .addKeys(key33); - List list = new ArrayList<>(); - list.add(builder1.build()); - list.add(builder2.build()); - list.add(builder3.build()); - return list; - } - - @Test - public void getPermission() { - //Default "active" permission - byte[] owner = ByteArray.fromHexString(OWNER_ADDRESS); - Account account = dbManager.getAccountStore().get(owner).getInstance(); - try { - Permission permission = TransactionCapsule.getPermission(account, "active"); - Permission permission1 = TransactionCapsule - .getDefaultPermission(ByteString.copyFrom(owner), "active"); - Assert.assertEquals(permission, permission1); - } catch (PermissionException e) { - Assert.assertFalse(true); - } - //Default "owner" permission - try { - Permission permission = TransactionCapsule.getPermission(account, "owner"); - Permission permission1 = TransactionCapsule - .getDefaultPermission(ByteString.copyFrom(owner), "owner"); - Assert.assertEquals(permission, permission1); - } catch (PermissionException e) { - Assert.assertFalse(true); - } - //Add 3 permission : owner active other - List permissions = buildPermissions(); - updatePermission(permissions, owner); - Permission permission1 = permissions.get(0); - Permission permission2 = permissions.get(1); - account = dbManager.getAccountStore().get(owner).getInstance(); - try { - Permission permission = TransactionCapsule.getPermission(account, "owner"); - Assert.assertEquals(permission, permission1); - } catch (PermissionException e) { - Assert.assertFalse(true); - } - - try { - Permission permission = TransactionCapsule.getPermission(account, "active"); - Assert.assertEquals(permission, permission2); - } catch (PermissionException e) { - Assert.assertFalse(true); - } - } - - @Test - public void getWeight() { - List permissions = buildPermissions(); - Permission permission1 = permissions.get(0); - Permission permission2 = permissions.get(1); - Permission permission3 = permissions.get(2); - Assert.assertEquals(1, - TransactionCapsule.getWeight(permission1, ByteArray.fromHexString(KEY_ADDRESS_11))); - Assert.assertEquals(1, - TransactionCapsule.getWeight(permission1, ByteArray.fromHexString(KEY_ADDRESS_12))); - Assert.assertEquals(1, - TransactionCapsule.getWeight(permission1, ByteArray.fromHexString(KEY_ADDRESS_13))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission1, ByteArray.fromHexString(KEY_ADDRESS_21))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission1, ByteArray.fromHexString(KEY_ADDRESS_22))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission1, ByteArray.fromHexString(KEY_ADDRESS_23))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission1, ByteArray.fromHexString(KEY_ADDRESS_31))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission1, ByteArray.fromHexString(KEY_ADDRESS_32))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission1, ByteArray.fromHexString(KEY_ADDRESS_33))); - - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission2, ByteArray.fromHexString(KEY_ADDRESS_11))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission2, ByteArray.fromHexString(KEY_ADDRESS_12))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission2, ByteArray.fromHexString(KEY_ADDRESS_13))); - Assert.assertEquals(1, - TransactionCapsule.getWeight(permission2, ByteArray.fromHexString(KEY_ADDRESS_21))); - Assert.assertEquals(1, - TransactionCapsule.getWeight(permission2, ByteArray.fromHexString(KEY_ADDRESS_22))); - Assert.assertEquals(1, - TransactionCapsule.getWeight(permission2, ByteArray.fromHexString(KEY_ADDRESS_23))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission2, ByteArray.fromHexString(KEY_ADDRESS_31))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission2, ByteArray.fromHexString(KEY_ADDRESS_32))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission2, ByteArray.fromHexString(KEY_ADDRESS_33))); - - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission3, ByteArray.fromHexString(KEY_ADDRESS_11))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission3, ByteArray.fromHexString(KEY_ADDRESS_12))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission3, ByteArray.fromHexString(KEY_ADDRESS_13))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission3, ByteArray.fromHexString(KEY_ADDRESS_21))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission3, ByteArray.fromHexString(KEY_ADDRESS_22))); - Assert.assertEquals(0, - TransactionCapsule.getWeight(permission3, ByteArray.fromHexString(KEY_ADDRESS_23))); - Assert.assertEquals(1, - TransactionCapsule.getWeight(permission3, ByteArray.fromHexString(KEY_ADDRESS_31))); - Assert.assertEquals(1, - TransactionCapsule.getWeight(permission3, ByteArray.fromHexString(KEY_ADDRESS_32))); - Assert.assertEquals(1, - TransactionCapsule.getWeight(permission3, ByteArray.fromHexString(KEY_ADDRESS_33))); - } - - public ArrayList sign(List priKeys, byte[] hash) { - ArrayList list = new ArrayList<>(); - for (byte[] priKey : priKeys) { - ECKey ecKey = ECKey.fromPrivate(priKey); - ECDSASignature signature = ecKey.sign(hash); - ByteString result = ByteString.copyFrom(signature.toByteArray()); - list.add(result); - } - return list; - } - - @Test - public void checkWeight() { - List permissions = buildPermissions(); - Permission permission = permissions.get(0); - byte[] hash = Sha256Hash.hash("test".getBytes()); - - //SignatureFormatException - ArrayList list = new ArrayList<>(); - ByteString test = ByteString.copyFromUtf8("test"); - list.add(test); - try { - TransactionCapsule.checkWeight(permission, list, hash, null); - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertEquals(e.getMessage(), "Signature size is " + test.size()); - } - //SignatureException: Header byte out of range: - //Ignore more exception case. - byte[] rand = new byte[65]; - new Random().nextBytes(rand); - rand[64] = 8; // v = 8 < 27 v += 35 > 35 - try { - ArrayList list1 = new ArrayList<>(); - list1.add(ByteString.copyFrom(rand)); - TransactionCapsule.checkWeight(permission, list1, hash, null); - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertEquals(e.getMessage(), "Header byte out of range: 35"); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - //Permission does not contain KEY - List prikeys = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_11)); - prikeys.add(ByteArray.fromHexString(KEY_21)); - ArrayList sign11_21 = sign(prikeys, hash); - try { - TransactionCapsule.checkWeight(permission, sign11_21, hash, null); - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - ByteString sign21 = sign11_21.get(1); - Assert.assertEquals(e.getMessage(), - ByteArray.toHexString(sign21.toByteArray()) + " is signed by " + Wallet - .encode58Check(ByteArray.fromHexString(KEY_ADDRESS_21)) - + " but it is not contained of permission."); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - //Too many signature - prikeys.add(ByteArray.fromHexString(KEY_12)); - prikeys.add(ByteArray.fromHexString(KEY_13)); - ArrayList sign11_21_12_13 = sign(prikeys, hash); - try { - TransactionCapsule.checkWeight(permission, sign11_21_12_13, hash, null); - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertEquals(e.getMessage(), - "Signature count is " + prikeys.size() + " more than key counts of permission : " - + permission.getKeysCount()); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - - //Sign twice by same key - prikeys = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_11)); - prikeys.add(ByteArray.fromHexString(KEY_12)); - prikeys.add(ByteArray.fromHexString(KEY_11)); - ArrayList sign11_12_11 = sign(prikeys, hash); - try { - TransactionCapsule.checkWeight(permission, sign11_12_11, hash, null); - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertEquals(e.getMessage(), - WalletUtil.encode58Check(ByteArray.fromHexString(KEY_ADDRESS_11)) + " has signed twice!"); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - - // - prikeys = new ArrayList<>(); - List approveList = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_11)); - ArrayList sign11 = sign(prikeys, hash); - try { - long weight = TransactionCapsule.checkWeight(permission, sign11, hash, approveList); - Assert.assertEquals(weight, 1); - Assert.assertEquals(approveList.size(), 1); - Assert.assertEquals(approveList.get(0), - ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_11))); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - - approveList = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_12)); - ArrayList sign11_12 = sign(prikeys, hash); - try { - long weight = TransactionCapsule.checkWeight(permission, sign11_12, hash, approveList); - Assert.assertEquals(weight, 2); - Assert.assertEquals(approveList.size(), 2); - Assert.assertEquals(approveList.get(0), - ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_11))); - Assert.assertEquals(approveList.get(1), - ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_12))); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - - approveList = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_13)); - ArrayList sign11_12_13 = sign(prikeys, hash); - try { - long weight = TransactionCapsule.checkWeight(permission, sign11_12_13, hash, approveList); - Assert.assertEquals(weight, 3); - Assert.assertEquals(approveList.size(), 3); - Assert.assertEquals(approveList.get(0), - ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_11))); - Assert.assertEquals(approveList.get(1), - ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_12))); - Assert.assertEquals(approveList.get(2), - ByteString.copyFrom(ByteArray.fromHexString(KEY_ADDRESS_13))); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - } - - @Test - public void addSign() { - - byte[] to = ByteArray.fromHexString(TO_ADDRESS); - byte[] owner_not_exist = ByteArray.fromHexString(OWNER_ACCOUNT_NOT_Exist); - TransferContract transferContract = createTransferContract(to, owner_not_exist, 1); - Transaction.Builder trxBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = Transaction.raw.newBuilder(); - Contract.Builder contractBuilder = Contract.newBuilder(); - contractBuilder.setType(ContractType.TransferContract).setParameter(Any.pack(transferContract)) - .build(); - rawBuilder.addContract(contractBuilder); - trxBuilder.setRawData(rawBuilder); - AccountStore accountStore = dbManager.getAccountStore(); - TransactionCapsule transactionCapsule = new TransactionCapsule(trxBuilder.build()); - //Accout not exist - try { - transactionCapsule.addSign(ByteArray.fromHexString(KEY_11), accountStore); - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertEquals(e.getMessage(), "Account is not exist!"); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - - byte[] owner = ByteArray.fromHexString(OWNER_ADDRESS); - transferContract = createTransferContract(to, owner, 1); - transactionCapsule = new TransactionCapsule(transferContract, accountStore); - //Defalut permission - try { - transactionCapsule.addSign(ByteArray.fromHexString(KEY_11), accountStore); - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertEquals(e.getMessage(), - KEY_11 + "'s address is " + WalletUtil - .encode58Check(ByteArray.fromHexString(KEY_ADDRESS_11)) - + " but it is not contained of permission."); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - - try { - transactionCapsule.addSign(ByteArray.fromHexString(OWNER_KEY), accountStore); - Assert.assertEquals(transactionCapsule.getInstance().getSignatureCount(), 1); - ByteString signature = transactionCapsule.getInstance().getSignature(0); - Assert.assertEquals(signature.size(), 65); - byte[] sign = signature.toByteArray(); - byte[] r = ByteArray.subArray(sign, 0, 32); - byte[] s = ByteArray.subArray(sign, 32, 64); - byte v = sign[64]; - ECDSASignature ecdsaSignature = ECDSASignature.fromComponents(r, s, (byte) (v + 27)); - byte[] address = ECKey - .signatureToAddress(transactionCapsule.getTransactionId().getBytes(), ecdsaSignature); - Assert.assertTrue(Arrays.equals(address, ByteArray.fromHexString(OWNER_ADDRESS))); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - // Sign twice - try { - transactionCapsule.addSign(ByteArray.fromHexString(OWNER_KEY), accountStore); - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertEquals(e.getMessage(), - WalletUtil.encode58Check(ByteArray.fromHexString(OWNER_ADDRESS)) + " had signed!"); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - //Update permission, can signed by key21 key22 key23 - List permissions = buildPermissions(); - Account account = accountStore.get(ByteArray.fromHexString(OWNER_ADDRESS)).getInstance(); - Account.Builder builder = account.toBuilder(); - builder.addPermissions(permissions.get(0)); - builder.addPermissions(permissions.get(1)); - builder.addPermissions(permissions.get(2)); - accountStore.put(ByteArray.fromHexString(OWNER_ADDRESS), new AccountCapsule(builder.build())); - - transactionCapsule = new TransactionCapsule(transferContract, accountStore); - try { - transactionCapsule.addSign(ByteArray.fromHexString(OWNER_KEY), accountStore); - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertEquals(e.getMessage(), - OWNER_KEY + "'s address is " + Wallet - .encode58Check(ByteArray.fromHexString(OWNER_ADDRESS)) - + " but it is not contained of permission."); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - //Sign KEY_21 - try { - transactionCapsule.addSign(ByteArray.fromHexString(KEY_21), accountStore); - Assert.assertEquals(transactionCapsule.getInstance().getSignatureCount(), 1); - ByteString signature = transactionCapsule.getInstance().getSignature(0); - Assert.assertEquals(signature.size(), 65); - byte[] sign = signature.toByteArray(); - byte[] r = ByteArray.subArray(sign, 0, 32); - byte[] s = ByteArray.subArray(sign, 32, 64); - byte v = sign[64]; - ECDSASignature ecdsaSignature = ECDSASignature.fromComponents(r, s, (byte) (v + 27)); - byte[] address = ECKey - .signatureToAddress(transactionCapsule.getTransactionId().getBytes(), ecdsaSignature); - Assert.assertTrue(Arrays.equals(address, ByteArray.fromHexString(KEY_ADDRESS_21))); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - //Sign KEY_12 - try { - transactionCapsule.addSign(ByteArray.fromHexString(KEY_22), accountStore); - Assert.assertEquals(transactionCapsule.getInstance().getSignatureCount(), 2); - ByteString signature = transactionCapsule.getInstance().getSignature(0); - Assert.assertEquals(signature.size(), 65); - byte[] sign = signature.toByteArray(); - byte[] r21 = ByteArray.subArray(sign, 0, 32); - byte[] s21 = ByteArray.subArray(sign, 32, 64); - byte v21 = sign[64]; - ECDSASignature ecdsaSignature11 = ECDSASignature.fromComponents(r21, s21, (byte) (v21 + 27)); - byte[] address21 = ECKey - .signatureToAddress(transactionCapsule.getTransactionId().getBytes(), ecdsaSignature11); - Assert.assertTrue(Arrays.equals(address21, ByteArray.fromHexString(KEY_ADDRESS_21))); - - ByteString signature1 = transactionCapsule.getInstance().getSignature(1); - - byte[] r22 = ByteArray.subArray(signature1.toByteArray(), 0, 32); - byte[] s22 = ByteArray.subArray(signature1.toByteArray(), 32, 64); - byte v22 = signature1.toByteArray()[64]; - ECDSASignature ecdsaSignature12 = ECDSASignature.fromComponents(r22, s22, (byte) (v22 + 27)); - byte[] address22 = ECKey - .signatureToAddress(transactionCapsule.getTransactionId().getBytes(), ecdsaSignature12); - Assert.assertTrue(Arrays.equals(address22, ByteArray.fromHexString(KEY_ADDRESS_22))); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - //Sign KEY_23 - try { - transactionCapsule.addSign(ByteArray.fromHexString(KEY_23), accountStore); - Assert.assertEquals(transactionCapsule.getInstance().getSignatureCount(), 3); - ByteString signature = transactionCapsule.getInstance().getSignature(0); - Assert.assertEquals(signature.size(), 65); - byte[] sign = signature.toByteArray(); - byte[] r21 = ByteArray.subArray(sign, 0, 32); - byte[] s21 = ByteArray.subArray(sign, 32, 64); - byte v21 = sign[64]; - ECDSASignature ecdsaSignature21 = ECDSASignature.fromComponents(r21, s21, (byte) (v21 + 27)); - byte[] address21 = ECKey - .signatureToAddress(transactionCapsule.getTransactionId().getBytes(), ecdsaSignature21); - Assert.assertTrue(Arrays.equals(address21, ByteArray.fromHexString(KEY_ADDRESS_21))); - - ByteString signature1 = transactionCapsule.getInstance().getSignature(1); - Assert.assertEquals(signature1.size(), 65); - byte[] sign1 = signature1.toByteArray(); - byte[] r22 = ByteArray.subArray(sign1, 0, 32); - byte[] s22 = ByteArray.subArray(sign1, 32, 64); - byte v22 = sign1[64]; - ECDSASignature ecdsaSignature22 = ECDSASignature.fromComponents(r22, s22, (byte) (v22 + 27)); - byte[] address22 = ECKey - .signatureToAddress(transactionCapsule.getTransactionId().getBytes(), ecdsaSignature22); - Assert.assertTrue(Arrays.equals(address22, ByteArray.fromHexString(KEY_ADDRESS_22))); - - ByteString signature2 = transactionCapsule.getInstance().getSignature(2); - Assert.assertEquals(signature2.size(), 65); - byte[] sign2 = signature2.toByteArray(); - byte[] r23 = ByteArray.subArray(sign2, 0, 32); - byte[] s23 = ByteArray.subArray(sign2, 32, 64); - byte v23 = sign2[64]; - ECDSASignature ecdsaSignature23 = ECDSASignature.fromComponents(r23, s23, (byte) (v23 + 27)); - byte[] address23 = ECKey - .signatureToAddress(transactionCapsule.getTransactionId().getBytes(), ecdsaSignature23); - Assert.assertTrue(Arrays.equals(address23, ByteArray.fromHexString(KEY_ADDRESS_23))); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - //Sign KEY_11, throw exception - try { - transactionCapsule.addSign(ByteArray.fromHexString(KEY_11), accountStore); - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertEquals(e.getMessage(), - KEY_11 + "'s address is " + Wallet - .encode58Check(ByteArray.fromHexString(KEY_ADDRESS_11)) - + " but it is not contained of permission."); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - //invalidate signature - transactionCapsule = new TransactionCapsule(transferContract, accountStore); - Transaction.Builder builder1 = transactionCapsule.getInstance().toBuilder(); - builder1.addSignature(ByteString.copyFromUtf8("test")); - transactionCapsule = new TransactionCapsule(builder1.build()); - //Sign KEY_21, throw exception - try { - transactionCapsule.addSign(ByteArray.fromHexString(KEY_11), accountStore); - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertEquals(e.getMessage(), "Signature size is " + "test".length()); - } - - //invalidate signature - transactionCapsule = new TransactionCapsule(transferContract, accountStore); - builder1 = transactionCapsule.getInstance().toBuilder(); - builder1.addSignature(ByteString.copyFromUtf8("test")); - transactionCapsule = new TransactionCapsule(builder1.build()); - //Sign KEY_21, throw exception - try { - transactionCapsule.addSign(ByteArray.fromHexString(KEY_11), accountStore); - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertEquals(e.getMessage(), "Signature size is " + "test".length()); - } - //transaction already have a signature signed by a invalidate key - //that the key is not in the permission. - transactionCapsule = new TransactionCapsule(transferContract, accountStore); - List prikeys = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_11)); - ArrayList sign11 = sign(prikeys, transactionCapsule.getTransactionId().getBytes()); - builder1 = transactionCapsule.getInstance().toBuilder(); - builder1.addAllSignature(sign11); - transactionCapsule = new TransactionCapsule(builder1.build()); - - try { - transactionCapsule.addSign(ByteArray.fromHexString(KEY_21), accountStore); - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertEquals(e.getMessage(), - ByteArray.toHexString(sign11.get(0).toByteArray()) + " is signed by " + Wallet - .encode58Check(ByteArray.fromHexString(KEY_ADDRESS_11)) - + " but it is not contained of permission."); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - } - - @Test - // test public static boolean validateSignature(Transaction.Contract contract, - ByteString sigs, byte[] hash, AccountStore accountStore) - public void validateSignature0() { - //Update permission, can signed by key21 key22 key23 - AccountStore accountStore = dbManager.getAccountStore(); - List permissions = buildPermissions(); - - byte[] to = ByteArray.fromHexString(TO_ADDRESS); - byte[] owner_not_exist = ByteArray.fromHexString(OWNER_ACCOUNT_NOT_Exist); - TransferContract transferContract = createTransferContract(to, owner_not_exist, 1); - Transaction.Builder trxBuilder = Transaction - .newBuilder(); - Transaction.raw.Builder rawBuilder = Transaction.raw.newBuilder(); - Contract.Builder contractBuilder = Contract.newBuilder(); - contractBuilder.setType(ContractType.TransferContract).setParameter(Any.pack(transferContract)); - rawBuilder.addContract(contractBuilder.build()); - trxBuilder.setRawData(rawBuilder.build()); - List prikeys = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_21)); - ArrayList sign = sign(prikeys, Sha256Hash.hash(rawBuilder.build().toByteArray())); - trxBuilder.addAllSignature(sign); - - Account account = accountStore.get(ByteArray.fromHexString(OWNER_ADDRESS)).getInstance(); - Account.Builder builder = account.toBuilder(); - builder.clearPermissions(); - builder.addPermissions(permissions.get(0)); - builder.addPermissions(permissions.get(1)); - builder.addPermissions(permissions.get(2)); - accountStore.put(ByteArray.fromHexString(OWNER_ADDRESS), new AccountCapsule(builder.build())); - byte[] hash = Sha256Hash.hash("test".getBytes()); - - byte[] owner = ByteArray.fromHexString(OWNER_ADDRESS); - transferContract = createTransferContract(to, owner, 1); - contractBuilder = Contract.newBuilder(); - contractBuilder.setParameter(Any.pack(transferContract)).setType(ContractType.TransferContract); - rawBuilder.clearContract().addContract(contractBuilder.build()); - trxBuilder.setRawData(rawBuilder.build()); - - //SignatureFormatException - ByteString test = ByteString.copyFromUtf8("test"); - trxBuilder.clearSignature().addSignature(test); - try { - TransactionCapsule.validateSignature(trxBuilder.build(), hash, accountStore); - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertEquals(e.getMessage(), "Signature size is " + test.size()); - } - //SignatureException: Header byte out of range: - //Ignore more exception case. - byte[] rand = new byte[65]; - new Random().nextBytes(rand); - rand[64] = 8; // v = 8 < 27 v += 35 > 35 - trxBuilder.clearSignature().addSignature(ByteString.copyFrom(rand)); - try { - TransactionCapsule.validateSignature(trxBuilder.build(), hash, - accountStore); - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertEquals(e.getMessage(), "Header byte out of range: 35"); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - //Permission is not contain KEY - prikeys = new ArrayList<>(); - prikeys.clear(); - prikeys.add(ByteArray.fromHexString(KEY_21)); - prikeys.add(ByteArray.fromHexString(KEY_11)); - ArrayList sign21_11 = sign(prikeys, hash); - trxBuilder.clearSignature().addAllSignature(sign21_11); - try { - TransactionCapsule.validateSignature(trxBuilder.build(), hash, accountStore); - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - ByteString sign21 = sign21_11.get(1); - Assert.assertEquals(e.getMessage(), - ByteArray.toHexString(sign21.toByteArray()) + " is signed by " + Wallet - .encode58Check(ByteArray.fromHexString(KEY_ADDRESS_11)) - + " but it is not contained of permission."); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - //Too many signature - prikeys.add(ByteArray.fromHexString(KEY_22)); - prikeys.add(ByteArray.fromHexString(KEY_23)); - ArrayList sign21_11_22_23 = sign(prikeys, hash); - trxBuilder.clearSignature().addAllSignature(sign21_11_22_23); - try { - TransactionCapsule - .validateSignature(trxBuilder.build(), hash, accountStore); - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertEquals(e.getMessage(), - "Signature count is " + prikeys.size() + " more than key counts of permission : " - + permissions.get(1).getKeysCount()); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - - //Sign twices by same key - prikeys = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_21)); - prikeys.add(ByteArray.fromHexString(KEY_22)); - prikeys.add(ByteArray.fromHexString(KEY_21)); - ArrayList sign21_22_21 = sign(prikeys, hash); - trxBuilder.clearSignature().addAllSignature(sign21_22_21); - try { - TransactionCapsule - .validateSignature(trxBuilder.build(), hash, accountStore); - Assert.assertFalse(true); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertEquals(e.getMessage(), - WalletUtil.encode58Check(ByteArray.fromHexString(KEY_ADDRESS_21)) + " has signed twice!"); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - - // - prikeys = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_21)); - ArrayList sign21 = sign(prikeys, hash); - trxBuilder.clearSignature().addAllSignature(sign21); - try { - boolean result = TransactionCapsule - .validateSignature(trxBuilder.build(), hash, accountStore); - Assert.assertFalse(result); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - - prikeys.add(ByteArray.fromHexString(KEY_22)); - ArrayList sign21_22 = sign(prikeys, hash); - trxBuilder.clearSignature().addAllSignature(sign21_22); - try { - boolean result = TransactionCapsule - .validateSignature(trxBuilder.build(), hash, accountStore); - Assert.assertTrue(result); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - - prikeys.add(ByteArray.fromHexString(KEY_23)); - ArrayList sign21_22_23 = sign(prikeys, hash); - trxBuilder.clearSignature().addAllSignature(sign21_22_23); - try { - boolean result = TransactionCapsule - .validateSignature(trxBuilder.build(), hash, accountStore); - Assert.assertTrue(result); - } catch (SignatureException e) { - Assert.assertFalse(true); - } catch (PermissionException e) { - Assert.assertFalse(true); - } catch (SignatureFormatException e) { - Assert.assertFalse(true); - } - } - - @Test - // test public boolean validateSignature(AccountStore accountStore) - public void validateSignature1() { - //Update permission, can signed by key21 key22 key23 - List permissions = buildPermissions(); - Account account = dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS)) - .getInstance(); - Account.Builder builder = account.toBuilder(); - builder.clearPermissions(); - builder.addPermissions(permissions.get(0)); - builder.addPermissions(permissions.get(1)); - builder.addPermissions(permissions.get(2)); - dbManager.getAccountStore() - .put(ByteArray.fromHexString(OWNER_ADDRESS), new AccountCapsule(builder.build())); - - byte[] to = ByteArray.fromHexString(TO_ADDRESS); - byte[] owner_not_exist = ByteArray.fromHexString(OWNER_ACCOUNT_NOT_Exist); - TransferContract transferContract = createTransferContract(to, owner_not_exist, 1); - Transaction.Builder trxBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = Transaction.raw.newBuilder(); - Contract.Builder contractBuilder = Contract.newBuilder(); - contractBuilder.setType(ContractType.TransferContract).setParameter(Any.pack(transferContract)) - .build(); - rawBuilder.addContract(contractBuilder); - trxBuilder.setRawData(rawBuilder); - TransactionCapsule transactionCapsule = new TransactionCapsule(trxBuilder.build()); - List prikeys = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_21)); - ArrayList sign = sign(prikeys, Sha256Hash.hash(rawBuilder.build().toByteArray())); - trxBuilder.addAllSignature(sign); - transactionCapsule = new TransactionCapsule(trxBuilder.build()); - - // no contract - prikeys.clear(); - prikeys.add(ByteArray.fromHexString(KEY_21)); - trxBuilder = Transaction.newBuilder(); - rawBuilder = Transaction.raw.newBuilder(); - rawBuilder.setTimestamp(System.currentTimeMillis()); - trxBuilder.setRawData(rawBuilder); - sign = sign(prikeys, Sha256Hash.hash(rawBuilder.build().toByteArray())); - trxBuilder.addAllSignature(sign); - transactionCapsule = new TransactionCapsule(trxBuilder.build()); - try { - transactionCapsule.validateSignature(dbManager); - Assert.assertFalse(true); - } catch (ValidateSignatureException e) { - Assert.assertEquals(e.getMessage(), "miss sig or contract"); - } - // no sign - byte[] owner = ByteArray.fromHexString(OWNER_ADDRESS); - transferContract = createTransferContract(to, owner, 1); - transactionCapsule = new TransactionCapsule(transferContract, dbManager.getAccountStore()); - try { - transactionCapsule.validateSignature(dbManager); - Assert.assertFalse(true); - } catch (ValidateSignatureException e) { - Assert.assertEquals(e.getMessage(), "miss sig or contract"); - } - - transactionCapsule = new TransactionCapsule(transferContract, dbManager.getAccountStore()); - byte[] hash = transactionCapsule.getTransactionId().getBytes(); - trxBuilder = transactionCapsule.getInstance().toBuilder(); - //SignatureFormatException - ByteString test = ByteString.copyFromUtf8("test"); - trxBuilder.clearSignature(); - trxBuilder.addSignature(test); - transactionCapsule = new TransactionCapsule(trxBuilder.build()); - try { - transactionCapsule.validateSignature(dbManager); - Assert.assertFalse(true); - } catch (ValidateSignatureException e) { - Assert.assertEquals(e.getMessage(), "Signature size is " + test.size()); - } - //SignatureException: Header byte out of range: - //Ignore more exception case. - byte[] rand = new byte[65]; - new Random().nextBytes(rand); - rand[64] = 8; // v = 8 < 27 v += 35 > 35 - trxBuilder.clearSignature(); - trxBuilder.addSignature(ByteString.copyFrom(rand)); - transactionCapsule = new TransactionCapsule(trxBuilder.build()); - try { - transactionCapsule.validateSignature(dbManager); - Assert.assertFalse(true); - } catch (ValidateSignatureException e) { - Assert.assertEquals(e.getMessage(), "Header byte out of range: 35"); - } - //Permission is not contain KEY - prikeys.clear(); - prikeys.add(ByteArray.fromHexString(KEY_21)); - prikeys.add(ByteArray.fromHexString(KEY_11)); - ArrayList sign21_11 = sign(prikeys, hash); - trxBuilder.clearSignature(); - trxBuilder.addAllSignature(sign21_11); - transactionCapsule = new TransactionCapsule(trxBuilder.build()); - try { - transactionCapsule.validateSignature(dbManager); - Assert.assertFalse(true); - } catch (ValidateSignatureException e) { - ByteString sign21 = sign21_11.get(1); - Assert.assertEquals(e.getMessage(), - ByteArray.toHexString(sign21.toByteArray()) + " is signed by " + Wallet - .encode58Check(ByteArray.fromHexString(KEY_ADDRESS_11)) - + " but it is not contained of permission."); - } - //Too many signature - prikeys.add(ByteArray.fromHexString(KEY_22)); - prikeys.add(ByteArray.fromHexString(KEY_23)); - ArrayList sign21_11_22_23 = sign(prikeys, hash); - trxBuilder.clearSignature(); - trxBuilder.addAllSignature(sign21_11_22_23); - transactionCapsule = new TransactionCapsule(trxBuilder.build()); - try { - transactionCapsule.validateSignature(dbManager); - Assert.assertFalse(true); - } catch (ValidateSignatureException e) { - Assert.assertEquals(e.getMessage(), - "Signature count is " + prikeys.size() + " more than key counts of permission : " - + permissions.get(1).getKeysCount()); - } - - //Sign twices by same key - prikeys = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_21)); - prikeys.add(ByteArray.fromHexString(KEY_22)); - prikeys.add(ByteArray.fromHexString(KEY_21)); - ArrayList sign21_22_21 = sign(prikeys, hash); - trxBuilder.clearSignature(); - trxBuilder.addAllSignature(sign21_22_21); - transactionCapsule = new TransactionCapsule(trxBuilder.build()); - try { - transactionCapsule.validateSignature(dbManager); - Assert.assertFalse(true); - } catch (ValidateSignatureException e) { - Assert.assertEquals(e.getMessage(), - WalletUtil.encode58Check(ByteArray.fromHexString(KEY_ADDRESS_21)) + " has signed twice!"); - } - - // - prikeys = new ArrayList<>(); - prikeys.add(ByteArray.fromHexString(KEY_21)); - ArrayList sign21 = sign(prikeys, hash); - trxBuilder.clearSignature(); - trxBuilder.addAllSignature(sign21); - transactionCapsule = new TransactionCapsule(trxBuilder.build()); - try { - transactionCapsule.validateSignature(dbManager); - Assert.assertFalse(true); - } catch (ValidateSignatureException e) { - Assert.assertEquals(e.getMessage(), "sig error"); - } - - prikeys.add(ByteArray.fromHexString(KEY_22)); - ArrayList sign21_22 = sign(prikeys, hash); - trxBuilder.clearSignature(); - trxBuilder.addAllSignature(sign21_22); - transactionCapsule = new TransactionCapsule(trxBuilder.build()); - try { - boolean result = transactionCapsule.validateSignature(dbManager); - Assert.assertTrue(result); - } catch (ValidateSignatureException e) { - Assert.assertFalse(true); - } - - prikeys.add(ByteArray.fromHexString(KEY_23)); - ArrayList sign21_22_23 = sign(prikeys, hash); - trxBuilder.clearSignature(); - trxBuilder.addAllSignature(sign21_22_23); - transactionCapsule = new TransactionCapsule(trxBuilder.build()); - try { - boolean result = transactionCapsule.validateSignature(dbManager); - Assert.assertTrue(result); - } catch (ValidateSignatureException e) { - Assert.assertFalse(true); - } - }*/ - @Test public void trxCapsuleClearTest() { Transaction tx = Transaction.newBuilder() @@ -1064,4 +55,18 @@ public void trxCapsuleClearTest() { Assert.assertEquals(trxCap.getInstance() .getRet(0).getContractRet(), Result.contractResult.OUT_OF_TIME); } + + @Test + public void testRemoveRedundantRet() { + Transaction.Builder transaction = Transaction.newBuilder().setRawData(raw.newBuilder() + .addContract(Transaction.Contract.newBuilder().setType(ContractType.TriggerSmartContract)) + .setFeeLimit(1000000000)).build().toBuilder(); + transaction.addRet(Result.newBuilder().setContractRet(SUCCESS).build()); + transaction.addRet(Result.newBuilder().setContractRet(PRECOMPILED_CONTRACT).build()); + transaction.addRet(Result.newBuilder().setContractRet(BAD_JUMP_DESTINATION).build()); + TransactionCapsule transactionCapsule = new TransactionCapsule(transaction.build()); + transactionCapsule.removeRedundantRet(); + Assert.assertEquals(1, transactionCapsule.getInstance().getRetCount()); + Assert.assertEquals(SUCCESS, transactionCapsule.getInstance().getRet(0).getContractRet()); + } } \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/capsule/utils/AssetUtilTest.java b/framework/src/test/java/org/tron/core/capsule/utils/AssetUtilTest.java index 2b07d7d7952..b966b26a299 100644 --- a/framework/src/test/java/org/tron/core/capsule/utils/AssetUtilTest.java +++ b/framework/src/test/java/org/tron/core/capsule/utils/AssetUtilTest.java @@ -24,7 +24,7 @@ public class AssetUtilTest extends BaseTest { static { - Args.setParam(new String[] {"-d", dbPath(), "-w"}, Constant.TEST_CONF); + Args.setParam(new String[] {"-d", dbPath()}, Constant.TEST_CONF); } public static byte[] randomBytes(int length) { diff --git a/framework/src/test/java/org/tron/core/capsule/utils/ExchangeProcessorTest.java b/framework/src/test/java/org/tron/core/capsule/utils/ExchangeProcessorTest.java index 3437eb0ea42..717c62b01a8 100644 --- a/framework/src/test/java/org/tron/core/capsule/utils/ExchangeProcessorTest.java +++ b/framework/src/test/java/org/tron/core/capsule/utils/ExchangeProcessorTest.java @@ -24,7 +24,7 @@ public class ExchangeProcessorTest extends BaseTest { @BeforeClass public static void init() { long supply = 1_000_000_000_000_000_000L; - processor = new ExchangeProcessor(supply); + processor = new ExchangeProcessor(supply, false); } @Test @@ -135,5 +135,15 @@ public void testWithdraw() { } + @Test + public void testStrictMath() { + long supply = 1_000_000_000_000_000_000L; + ExchangeProcessor processor = new ExchangeProcessor(supply, false); + long anotherTokenQuant = processor.exchange(4732214, 2202692725330L, 29218); + processor = new ExchangeProcessor(supply, true); + long result = processor.exchange(4732214, 2202692725330L, 29218); + Assert.assertNotEquals(anotherTokenQuant, result); + } + } diff --git a/framework/src/test/java/org/tron/core/capsule/utils/MerkleTreeTest.java b/framework/src/test/java/org/tron/core/capsule/utils/MerkleTreeTest.java index 4e3273203c8..df84433726e 100644 --- a/framework/src/test/java/org/tron/core/capsule/utils/MerkleTreeTest.java +++ b/framework/src/test/java/org/tron/core/capsule/utils/MerkleTreeTest.java @@ -1,18 +1,31 @@ package org.tron.core.capsule.utils; +import static org.tron.common.math.Maths.pow; + +import com.google.protobuf.ByteString; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.tron.common.parameter.CommonParameter; import org.tron.common.utils.ByteArray; +import org.tron.common.utils.MerkleRoot; import org.tron.common.utils.Sha256Hash; import org.tron.core.capsule.utils.MerkleTree.Leaf; @Slf4j public class MerkleTreeTest { + @Rule + public ExpectedException exception = ExpectedException.none(); + private static List getHash(int hashNum) { List hashList = new ArrayList(); for (int i = 0; i < hashNum; i++) { @@ -75,7 +88,7 @@ private static int getRank(int num) { num = num >> 1; rank++; } - if (temp == Math.pow(2, rank - 1)) { + if (temp == pow(2, rank - 1, true)) { rank -= 1; } return rank; @@ -173,4 +186,28 @@ public void testAnyHashNum() { pareTree(root, hashList, maxRank, 0, 0); } } -} \ No newline at end of file + + @Test + @Ignore + public void testConcurrent() { + Sha256Hash root1 = Sha256Hash.wrap( + ByteString.fromHex("6cb38b4f493db8bacf26123cd4253bbfc530c708b97b3747e782f64097c3c482")); + Sha256Hash root2 = Sha256Hash.wrap( + ByteString.fromHex("4bfc60ea3de4f5d1476f839874df0aba38eec4e524d6fa63f5b19c4bf527eaf3")); + List list1 = IntStream.range(0, 10000).mapToObj(i -> + Sha256Hash.of(true, ("byte1-" + i).getBytes(StandardCharsets.UTF_8))) + .collect(Collectors.toList()); + List list2 = IntStream.range(0, 10000).mapToObj(i -> + Sha256Hash.of(true, ("byte2-" + i).getBytes(StandardCharsets.UTF_8))) + .collect(Collectors.toList()); + Assert.assertEquals(root1, MerkleTree.getInstance().createTree(list1).getRoot().getHash()); + Assert.assertEquals(root2, MerkleTree.getInstance().createTree(list2).getRoot().getHash()); + Assert.assertEquals(root1, MerkleRoot.root(list1)); + Assert.assertEquals(root2, MerkleRoot.root(list2)); + exception.expect(ArrayIndexOutOfBoundsException.class); + IntStream.range(0, 1000).parallel().forEach(i -> Assert.assertEquals( + MerkleTree.getInstance().createTree(i % 2 == 0 ? list1 : list2).getRoot().getHash(), + MerkleRoot.root(i % 2 == 0 ? list1 : list2)) + ); + } +} diff --git a/framework/src/test/java/org/tron/core/capsule/utils/RLPListTest.java b/framework/src/test/java/org/tron/core/capsule/utils/RLPListTest.java index 7d903591966..500e7454dbe 100644 --- a/framework/src/test/java/org/tron/core/capsule/utils/RLPListTest.java +++ b/framework/src/test/java/org/tron/core/capsule/utils/RLPListTest.java @@ -1,19 +1,29 @@ package org.tron.core.capsule.utils; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.math.BigInteger; +import java.util.Random; +import org.bouncycastle.util.BigIntegers; import org.junit.Assert; import org.junit.Test; +import org.tron.common.utils.Value; public class RLPListTest { @Test public void testRecursivePrint() { RLPItem element = new RLPItem("rlpItem".getBytes()); - Assert.assertEquals(new String(element.getRLPData()), "rlpItem"); + Assert.assertEquals("rlpItem", new String(element.getRLPData())); RLPList.recursivePrint(element); RLPList rlpList = new RLPList(); rlpList.add(new RLPItem("rlpItem0".getBytes())); RLPList.recursivePrint(rlpList); Assert.assertThrows(RuntimeException.class, () -> RLPList.recursivePrint(null)); + + RLPItem rlpItem = new RLPItem(new byte[0]); + Assert.assertNull(rlpItem.getRLPData()); + } @Test @@ -23,4 +33,53 @@ public void testGetRLPData() { Assert.assertEquals(new String(rlpList.getRLPData()), "rlpData"); } + @Test + public void testToBytes() + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Method method = RLP.class.getDeclaredMethod("toBytes", Object.class); + method.setAccessible(true); + + byte[] aBytes = new byte[10]; + byte[] bBytes = (byte[]) method.invoke(RLP.class, aBytes); + Assert.assertArrayEquals(aBytes, bBytes); + + int i = new Random().nextInt(); + byte[] cBytes = BigIntegers.asUnsignedByteArray(BigInteger.valueOf(i)); + byte[] dBytes = (byte[]) method.invoke(RLP.class, i); + Assert.assertArrayEquals(cBytes, dBytes); + + long j = new Random().nextInt(); + byte[] eBytes = BigIntegers.asUnsignedByteArray(BigInteger.valueOf(j)); + byte[] fBytes = (byte[]) method.invoke(RLP.class, j); + Assert.assertArrayEquals(eBytes, fBytes); + + String test = "testA"; + byte[] gBytes = test.getBytes(); + byte[] hBytes = (byte[]) method.invoke(RLP.class, test); + Assert.assertArrayEquals(gBytes, hBytes); + + BigInteger bigInteger = BigInteger.valueOf(100); + byte[] iBytes = BigIntegers.asUnsignedByteArray(bigInteger); + byte[] jBytes = (byte[]) method.invoke(RLP.class, bigInteger); + Assert.assertArrayEquals(iBytes, jBytes); + + Value v = new Value(new byte[0]); + byte[] kBytes = v.asBytes(); + byte[] lBytes = (byte[]) method.invoke(RLP.class, v); + Assert.assertArrayEquals(kBytes, lBytes); + + char c = 'a'; + try { + method.invoke(RLP.class, c); + Assert.fail(); + } catch (Exception e) { + Assert.assertTrue(true); + } + } + + @Test + public void testEncode() { + byte[] aBytes = RLP.encode(new byte[1]); + Assert.assertEquals(1, aBytes.length); + } } diff --git a/framework/src/test/java/org/tron/core/config/ConfigurationTest.java b/framework/src/test/java/org/tron/core/config/ConfigurationTest.java index 24a34dbcd0e..f3ca2da5312 100644 --- a/framework/src/test/java/org/tron/core/config/ConfigurationTest.java +++ b/framework/src/test/java/org/tron/core/config/ConfigurationTest.java @@ -17,7 +17,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.tron.common.utils.PublicMethod.getRandomPrivateKey; +import static org.tron.common.utils.client.utils.AbiUtil.generateOccupationConstantPrivateKey; +import static org.tron.core.Constant.ADD_PRE_FIX_STRING_MAINNET; import com.typesafe.config.Config; import java.lang.reflect.Field; @@ -46,13 +50,10 @@ public void resetSingleton() @Test public void testGetEcKey() { - ECKey key = ECKey.fromPrivate( - Hex.decode("1cd5a70741c6e583d2dd3c5f17231e608eb1e52437210d948c5085e141c2d830")); - - //log.debug("address = {}", ByteArray.toHexString(key.getOwnerAddress())); - - assertEquals(Wallet.getAddressPreFixString() + "125b6c87b3d67114b3873977888c34582f27bbb0", - ByteArray.toHexString(key.getAddress())); + ECKey key = ECKey.fromPrivate(Hex.decode(generateOccupationConstantPrivateKey())); + assertNotNull(key); + assertEquals("2e988a386a799f506693793c6a5af6b54dfaabfb", + ByteArray.toHexString(key.getAddress()).substring(2)); } @Test(expected = IllegalArgumentException.class) diff --git a/framework/src/test/java/org/tron/core/config/args/ArgsTest.java b/framework/src/test/java/org/tron/core/config/args/ArgsTest.java index 13e272d1e13..4bb8e7e4909 100644 --- a/framework/src/test/java/org/tron/core/config/args/ArgsTest.java +++ b/framework/src/test/java/org/tron/core/config/args/ArgsTest.java @@ -17,29 +17,28 @@ import com.google.common.collect.Lists; import com.typesafe.config.Config; -import com.typesafe.config.ConfigMergeable; -import com.typesafe.config.ConfigOrigin; -import com.typesafe.config.ConfigRenderOptions; -import com.typesafe.config.ConfigValue; -import com.typesafe.config.ConfigValueType; +import com.typesafe.config.ConfigFactory; import io.grpc.internal.GrpcUtil; import io.grpc.netty.NettyServerBuilder; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; import lombok.extern.slf4j.Slf4j; import org.junit.After; import org.junit.Assert; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.tron.common.args.GenesisBlock; import org.tron.common.parameter.CommonParameter; import org.tron.common.utils.ByteArray; +import org.tron.common.utils.DecodeUtil; import org.tron.common.utils.LocalWitnesses; import org.tron.common.utils.PublicMethod; -import org.tron.common.utils.ReflectUtils; import org.tron.core.Constant; import org.tron.core.config.Configuration; -import org.tron.core.net.peer.PeerManager; @Slf4j public class ArgsTest { @@ -48,6 +47,9 @@ public class ArgsTest { private String address; private LocalWitnesses localWitnesses; + @Rule + public ExpectedException thrown = ExpectedException.none(); + @After public void destroy() { Args.clearParam(); @@ -55,7 +57,7 @@ public void destroy() { @Test public void get() { - Args.setParam(new String[] {"-w"}, Constant.TEST_CONF); + Args.setParam(new String[] {"-c", Constant.TEST_CONF}, Constant.TESTNET_CONF); CommonParameter parameter = Args.getInstance(); @@ -67,7 +69,7 @@ public void get() { Args.setLocalWitnesses(localWitnesses); address = ByteArray.toHexString(Args.getLocalWitnesses() .getWitnessAccountAddress(CommonParameter.getInstance().isECKeyCryptoEngine())); - + Assert.assertEquals(Constant.ADD_PRE_FIX_STRING_TESTNET, DecodeUtil.addressPreFixString); Assert.assertEquals(0, parameter.getBackupPriority()); Assert.assertEquals(3000, parameter.getKeepAliveInterval()); @@ -95,13 +97,15 @@ public void get() { Assert.assertTrue(parameter.isNodeDiscoveryEnable()); Assert.assertTrue(parameter.isNodeDiscoveryPersist()); - Assert.assertEquals("127.0.0.1", parameter.getNodeDiscoveryBindIp()); Assert.assertEquals("46.168.1.1", parameter.getNodeExternalIp()); Assert.assertEquals(18888, parameter.getNodeListenPort()); Assert.assertEquals(2000, parameter.getNodeConnectionTimeout()); Assert.assertEquals(0, parameter.getActiveNodes().size()); Assert.assertEquals(30, parameter.getMaxConnections()); Assert.assertEquals(43, parameter.getNodeP2pVersion()); + Assert.assertEquals(54, parameter.getMaxUnsolidifiedBlocks()); + Assert.assertEquals(false, parameter.isUnsolidifiedBlockCheck()); + Assert.assertEquals(1000, parameter.getMaxCreateAccountTxSize()); //Assert.assertEquals(30, args.getSyncNodeCount()); // gRPC network configs checking @@ -115,6 +119,7 @@ public void get() { Assert.assertEquals(GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE, parameter.getMaxMessageSize()); Assert.assertEquals(GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE, parameter.getMaxHeaderListSize()); Assert.assertEquals(1L, parameter.getAllowCreationOfContracts()); + Assert.assertEquals(0, parameter.getConsensusLogicOptimization()); Assert.assertEquals(privateKey, Args.getLocalWitnesses().getPrivateKey()); @@ -127,31 +132,150 @@ public void get() { @Test public void testIpFromLibP2p() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Args.setParam(new String[] {"-w"}, Constant.TEST_CONF); + Args.setParam(new String[] {}, Constant.TEST_CONF); CommonParameter parameter = Args.getInstance(); - String configuredBindIp = parameter.getNodeDiscoveryBindIp(); String configuredExternalIp = parameter.getNodeExternalIp(); - Assert.assertEquals("127.0.0.1", configuredBindIp); Assert.assertEquals("46.168.1.1", configuredExternalIp); Config config = Configuration.getByFileName(null, Constant.TEST_CONF); - Config config2 = config.withoutPath(Constant.NODE_DISCOVERY_BIND_IP); - Config config3 = config2.withoutPath(Constant.NODE_DISCOVERY_EXTERNAL_IP); + Config config3 = config.withoutPath(Constant.NODE_DISCOVERY_EXTERNAL_IP); - CommonParameter.getInstance().setNodeDiscoveryBindIp(null); CommonParameter.getInstance().setNodeExternalIp(null); - Method method1 = Args.class.getDeclaredMethod("bindIp", Config.class); - method1.setAccessible(true); - method1.invoke(Args.class, config3); - Method method2 = Args.class.getDeclaredMethod("externalIp", Config.class); method2.setAccessible(true); method2.invoke(Args.class, config3); - Assert.assertNotEquals(configuredBindIp, parameter.getNodeDiscoveryBindIp()); Assert.assertNotEquals(configuredExternalIp, parameter.getNodeExternalIp()); } + + @Test + public void testOldRewardOpt() { + thrown.expect(IllegalArgumentException.class); + Args.setParam(new String[] {"-c", "args-test.conf"}, Constant.TESTNET_CONF); + } + + @Test + public void testInitService() { + Map storage = new HashMap<>(); + // avoid the exception for the missing storage + storage.put("storage.db.directory", "database"); + Config config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage)); + // test default value + Args.setParam(config); + Assert.assertTrue(Args.getInstance().isRpcEnable()); + Assert.assertTrue(Args.getInstance().isRpcSolidityEnable()); + Assert.assertTrue(Args.getInstance().isRpcPBFTEnable()); + Assert.assertTrue(Args.getInstance().isFullNodeHttpEnable()); + Assert.assertTrue(Args.getInstance().isSolidityNodeHttpEnable()); + Assert.assertTrue(Args.getInstance().isPBFTHttpEnable()); + Assert.assertFalse(Args.getInstance().isJsonRpcHttpFullNodeEnable()); + Assert.assertFalse(Args.getInstance().isJsonRpcHttpSolidityNodeEnable()); + Assert.assertFalse(Args.getInstance().isJsonRpcHttpPBFTNodeEnable()); + Assert.assertEquals(5000, Args.getInstance().getJsonRpcMaxBlockRange()); + Assert.assertEquals(1000, Args.getInstance().getJsonRpcMaxSubTopics()); + Args.clearParam(); + // test set all true value + storage.put("node.rpc.enable", "true"); + storage.put("node.rpc.solidityEnable", "true"); + storage.put("node.rpc.PBFTEnable", "true"); + storage.put("node.http.fullNodeEnable", "true"); + storage.put("node.http.solidityEnable", "true"); + storage.put("node.http.PBFTEnable", "true"); + storage.put("node.jsonrpc.httpFullNodeEnable", "true"); + storage.put("node.jsonrpc.httpSolidityEnable", "true"); + storage.put("node.jsonrpc.httpPBFTEnable", "true"); + storage.put("node.jsonrpc.maxBlockRange", "10"); + storage.put("node.jsonrpc.maxSubTopics", "20"); + config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage)); + // test value + Args.setParam(config); + Assert.assertTrue(Args.getInstance().isRpcEnable()); + Assert.assertTrue(Args.getInstance().isRpcSolidityEnable()); + Assert.assertTrue(Args.getInstance().isRpcPBFTEnable()); + Assert.assertTrue(Args.getInstance().isFullNodeHttpEnable()); + Assert.assertTrue(Args.getInstance().isSolidityNodeHttpEnable()); + Assert.assertTrue(Args.getInstance().isPBFTHttpEnable()); + Assert.assertTrue(Args.getInstance().isJsonRpcHttpFullNodeEnable()); + Assert.assertTrue(Args.getInstance().isJsonRpcHttpSolidityNodeEnable()); + Assert.assertTrue(Args.getInstance().isJsonRpcHttpPBFTNodeEnable()); + Assert.assertEquals(10, Args.getInstance().getJsonRpcMaxBlockRange()); + Assert.assertEquals(20, Args.getInstance().getJsonRpcMaxSubTopics()); + Args.clearParam(); + // test set all false value + storage.put("node.rpc.enable", "false"); + storage.put("node.rpc.solidityEnable", "false"); + storage.put("node.rpc.PBFTEnable", "false"); + storage.put("node.http.fullNodeEnable", "false"); + storage.put("node.http.solidityEnable", "false"); + storage.put("node.http.PBFTEnable", "false"); + storage.put("node.jsonrpc.httpFullNodeEnable", "false"); + storage.put("node.jsonrpc.httpSolidityEnable", "false"); + storage.put("node.jsonrpc.httpPBFTEnable", "false"); + storage.put("node.jsonrpc.maxBlockRange", "5000"); + storage.put("node.jsonrpc.maxSubTopics", "1000"); + config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage)); + // test value + Args.setParam(config); + Assert.assertFalse(Args.getInstance().isRpcEnable()); + Assert.assertFalse(Args.getInstance().isRpcSolidityEnable()); + Assert.assertFalse(Args.getInstance().isRpcPBFTEnable()); + Assert.assertFalse(Args.getInstance().isFullNodeHttpEnable()); + Assert.assertFalse(Args.getInstance().isSolidityNodeHttpEnable()); + Assert.assertFalse(Args.getInstance().isPBFTHttpEnable()); + Assert.assertFalse(Args.getInstance().isJsonRpcHttpFullNodeEnable()); + Assert.assertFalse(Args.getInstance().isJsonRpcHttpSolidityNodeEnable()); + Assert.assertFalse(Args.getInstance().isJsonRpcHttpPBFTNodeEnable()); + Assert.assertEquals(5000, Args.getInstance().getJsonRpcMaxBlockRange()); + Assert.assertEquals(1000, Args.getInstance().getJsonRpcMaxSubTopics()); + Args.clearParam(); + // test set random value + storage.put("node.rpc.enable", "false"); + storage.put("node.rpc.solidityEnable", "false"); + storage.put("node.rpc.PBFTEnable", "true"); + storage.put("node.http.fullNodeEnable", "false"); + storage.put("node.http.solidityEnable", "true"); + storage.put("node.http.PBFTEnable", "false"); + storage.put("node.jsonrpc.httpFullNodeEnable", "true"); + storage.put("node.jsonrpc.httpSolidityEnable", "false"); + storage.put("node.jsonrpc.httpPBFTEnable", "true"); + storage.put("node.jsonrpc.maxBlockRange", "30"); + storage.put("node.jsonrpc.maxSubTopics", "40"); + config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage)); + // test value + Args.setParam(config); + Assert.assertFalse(Args.getInstance().isRpcEnable()); + Assert.assertFalse(Args.getInstance().isRpcSolidityEnable()); + Assert.assertTrue(Args.getInstance().isRpcPBFTEnable()); + Assert.assertFalse(Args.getInstance().isFullNodeHttpEnable()); + Assert.assertTrue(Args.getInstance().isSolidityNodeHttpEnable()); + Assert.assertFalse(Args.getInstance().isPBFTHttpEnable()); + Assert.assertTrue(Args.getInstance().isJsonRpcHttpFullNodeEnable()); + Assert.assertFalse(Args.getInstance().isJsonRpcHttpSolidityNodeEnable()); + Assert.assertTrue(Args.getInstance().isJsonRpcHttpPBFTNodeEnable()); + Assert.assertEquals(30, Args.getInstance().getJsonRpcMaxBlockRange()); + Assert.assertEquals(40, Args.getInstance().getJsonRpcMaxSubTopics()); + + // test set invalid value + storage.put("node.jsonrpc.maxBlockRange", "0"); + storage.put("node.jsonrpc.maxSubTopics", "0"); + config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage)); + // check value + Args.setParam(config); + Assert.assertEquals(0, Args.getInstance().getJsonRpcMaxBlockRange()); + Assert.assertEquals(0, Args.getInstance().getJsonRpcMaxSubTopics()); + + // test set invalid value + storage.put("node.jsonrpc.maxBlockRange", "-2"); + storage.put("node.jsonrpc.maxSubTopics", "-4"); + config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage)); + // check value + Args.setParam(config); + Assert.assertEquals(-2, Args.getInstance().getJsonRpcMaxBlockRange()); + Assert.assertEquals(-4, Args.getInstance().getJsonRpcMaxSubTopics()); + + Args.clearParam(); + } } diff --git a/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java b/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java index d0222254c7d..27d5effd6b1 100644 --- a/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java +++ b/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java @@ -24,8 +24,8 @@ public class LocalWitnessTest { - private LocalWitnesses localWitness = new LocalWitnesses(); - private static String PRIVATE_KEY = PublicMethod.getRandomPrivateKey(); + private final LocalWitnesses localWitness = new LocalWitnesses(); + private static final String PRIVATE_KEY = PublicMethod.getRandomPrivateKey(); @Before public void setLocalWitness() { @@ -38,11 +38,15 @@ public void setLocalWitness() { @Test public void whenSetNullPrivateKey() { localWitness.setPrivateKeys(null); + Assert.assertNotNull(localWitness.getPrivateKey()); + Assert.assertNotNull(localWitness.getPublicKey()); } @Test public void whenSetEmptyPrivateKey() { localWitness.setPrivateKeys(Lists.newArrayList("")); + Assert.assertNotNull(localWitness.getPrivateKey()); + Assert.assertNotNull(localWitness.getPublicKey()); } @Test(expected = IllegalArgumentException.class) @@ -58,6 +62,7 @@ public void whenSetPrefixPrivateKey() { localWitness .setPrivateKeys(Lists .newArrayList("0X" + PRIVATE_KEY)); + Assert.assertNotNull(localWitness.getPrivateKey()); } @Test @@ -66,4 +71,20 @@ public void getPrivateKey() { .newArrayList(PRIVATE_KEY), localWitness.getPrivateKeys()); } + + @Test + public void testConstructor() { + LocalWitnesses localWitnesses = new LocalWitnesses(PublicMethod.getRandomPrivateKey()); + LocalWitnesses localWitnesses1 = + new LocalWitnesses(Lists.newArrayList(PublicMethod.getRandomPrivateKey())); + localWitnesses.setWitnessAccountAddress(new byte[0]); + Assert.assertNotNull(localWitnesses1.getPublicKey()); + + LocalWitnesses localWitnesses2 = new LocalWitnesses(); + Assert.assertNull(localWitnesses2.getPrivateKey()); + Assert.assertNull(localWitnesses2.getPublicKey()); + localWitnesses2.initWitnessAccountAddress(true); + LocalWitnesses localWitnesses3 = new LocalWitnesses(); + Assert.assertNotNull(localWitnesses3.getWitnessAccountAddress(true)); + } } diff --git a/framework/src/test/java/org/tron/core/consensus/DposServiceTest.java b/framework/src/test/java/org/tron/core/consensus/DposServiceTest.java new file mode 100644 index 00000000000..dc6802d71d5 --- /dev/null +++ b/framework/src/test/java/org/tron/core/consensus/DposServiceTest.java @@ -0,0 +1,117 @@ +package org.tron.core.consensus; + +import static org.mockito.Mockito.mock; + +import com.google.protobuf.ByteString; +import java.lang.reflect.Field; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.tron.common.parameter.CommonParameter; +import org.tron.consensus.ConsensusDelegate; +import org.tron.consensus.dpos.DposService; +import org.tron.consensus.dpos.DposSlot; +import org.tron.core.Constant; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.config.args.Args; +import org.tron.core.store.DynamicPropertiesStore; +import org.tron.p2p.utils.NetUtil; +import org.tron.protos.Protocol; + +public class DposServiceTest { + DposService service = new DposService(); + + + @AfterClass + public static void destroy() { + Args.clearParam(); + } + + @Test + public void testValidBlockTime() throws Exception { + long headTime = 1724036757000L; + + ConsensusDelegate consensusDelegate = mock(ConsensusDelegate.class); + Field field = service.getClass().getDeclaredField("consensusDelegate"); + field.setAccessible(true); + field.set(service, consensusDelegate); + + DynamicPropertiesStore store = mock(DynamicPropertiesStore.class); + Mockito.when(consensusDelegate.getDynamicPropertiesStore()).thenReturn(store); + + Mockito.when(consensusDelegate.getLatestBlockHeaderNumber()).thenReturn(0L); + boolean f = service.validBlock(null); + Assert.assertTrue(f); + + Protocol.BlockHeader.raw raw = Protocol.BlockHeader.raw.newBuilder() + .setTimestamp(headTime + 3001).build(); + Protocol.BlockHeader header = Protocol.BlockHeader.newBuilder().setRawData(raw).build(); + Protocol.Block block = Protocol.Block.newBuilder().setBlockHeader(header).build(); + + Mockito.when(consensusDelegate.getLatestBlockHeaderNumber()).thenReturn(100L); + Mockito.when(store.allowConsensusLogicOptimization()).thenReturn(true); + + Mockito.when(consensusDelegate.getLatestBlockHeaderTimestamp()).thenReturn(headTime + 3000); + f = service.validBlock(new BlockCapsule(block)); + Assert.assertTrue(!f); + + } + + @Test + public void testValidSlot() throws Exception { + Args.setParam(new String[] {}, Constant.TEST_CONF); + long headTime = 1724036757000L; + ByteString witness = ByteString.copyFrom(NetUtil.getNodeId()); + ByteString witness2 = ByteString.copyFrom(NetUtil.getNodeId()); + + ConsensusDelegate consensusDelegate = mock(ConsensusDelegate.class); + Field field = service.getClass().getDeclaredField("consensusDelegate"); + field.setAccessible(true); + field.set(service, consensusDelegate); + + DposSlot dposSlot = mock(DposSlot.class); + field = service.getClass().getDeclaredField("dposSlot"); + field.setAccessible(true); + field.set(service, dposSlot); + + Mockito.when(dposSlot.getAbSlot(headTime)).thenReturn(headTime / 3000); + Mockito.when(dposSlot.getAbSlot(headTime + 3000)).thenReturn((headTime + 3000) / 3000); + + DynamicPropertiesStore store = mock(DynamicPropertiesStore.class); + Mockito.when(consensusDelegate.getDynamicPropertiesStore()).thenReturn(store); + + Mockito.when(consensusDelegate.getLatestBlockHeaderNumber()).thenReturn(0L); + boolean f = service.validBlock(null); + Assert.assertTrue(f); + + Mockito.when(consensusDelegate.getLatestBlockHeaderNumber()).thenReturn(100L); + + Protocol.BlockHeader.raw raw = Protocol.BlockHeader.raw.newBuilder() + .setTimestamp(headTime + 3000) + .setWitnessAddress(witness).build(); + Protocol.BlockHeader header = Protocol.BlockHeader.newBuilder().setRawData(raw).build(); + Protocol.Block block = Protocol.Block.newBuilder().setBlockHeader(header).build(); + + Mockito.when(consensusDelegate.getLatestBlockHeaderTimestamp()).thenReturn(headTime + 3000); + f = service.validBlock(new BlockCapsule(block)); + Assert.assertTrue(!f); + + Mockito.when(consensusDelegate.getLatestBlockHeaderTimestamp()).thenReturn(headTime); + + Mockito.when(dposSlot.getSlot(headTime + 3000)).thenReturn(0L); + + Mockito.when(dposSlot.getScheduledWitness(0L)).thenReturn(witness2); + f = service.validBlock(new BlockCapsule(block)); + Assert.assertTrue(!f); + + Mockito.when(dposSlot.getScheduledWitness(0L)).thenReturn(witness); + f = service.validBlock(new BlockCapsule(block)); + Assert.assertTrue(f); + + Mockito.when(store.allowConsensusLogicOptimization()).thenReturn(true); + f = service.validBlock(new BlockCapsule(block)); + Assert.assertTrue(!f); + } + +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/consensus/DposTaskTest.java b/framework/src/test/java/org/tron/core/consensus/DposTaskTest.java new file mode 100644 index 00000000000..89d887d5fe9 --- /dev/null +++ b/framework/src/test/java/org/tron/core/consensus/DposTaskTest.java @@ -0,0 +1,64 @@ +package org.tron.core.consensus; + +import static org.mockito.Mockito.mock; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.tron.consensus.base.BlockHandle; +import org.tron.consensus.base.State; +import org.tron.consensus.dpos.DposService; +import org.tron.consensus.dpos.DposSlot; +import org.tron.consensus.dpos.DposTask; +import org.tron.consensus.dpos.StateManager; + +public class DposTaskTest { + private DposTask dposTask = new DposTask(); + + @Test + public void tet() throws Exception { + StateManager stateManager = mock(StateManager.class); + Mockito.when(stateManager.getState()).thenReturn(State.BACKUP_IS_NOT_MASTER); + + Field field = dposTask.getClass().getDeclaredField("stateManager"); + field.setAccessible(true); + field.set(dposTask, stateManager); + + Method method = dposTask.getClass().getDeclaredMethod("produceBlock"); + method.setAccessible(true); + State state = (State) method.invoke(dposTask); + + Assert.assertEquals(State.BACKUP_IS_NOT_MASTER, state); + + + Mockito.when(stateManager.getState()).thenReturn(State.OK); + + DposSlot dposSlot = mock(DposSlot.class); + Mockito.when(dposSlot.getTime(1)).thenReturn(Long.MAX_VALUE); + + field = dposTask.getClass().getDeclaredField("dposSlot"); + field.setAccessible(true); + field.set(dposTask, dposSlot); + + + Mockito.when(stateManager.getState()).thenReturn(State.OK); + + BlockHandle blockHandle = mock(BlockHandle.class); + Mockito.when(blockHandle.getLock()).thenReturn(new Object()); + + + DposService dposService = mock(DposService.class); + Mockito.when(dposService.getBlockHandle()).thenReturn(blockHandle); + + field = dposTask.getClass().getDeclaredField("dposService"); + field.setAccessible(true); + field.set(dposTask, dposService); + + state = (State) method.invoke(dposTask); + + Assert.assertEquals(State.NOT_TIME_YET, state); + } + +} diff --git a/framework/src/test/java/org/tron/core/db/AccountTraceStoreTest.java b/framework/src/test/java/org/tron/core/db/AccountTraceStoreTest.java index aa87f903ad3..5a6d44a8c7c 100644 --- a/framework/src/test/java/org/tron/core/db/AccountTraceStoreTest.java +++ b/framework/src/test/java/org/tron/core/db/AccountTraceStoreTest.java @@ -12,6 +12,7 @@ import org.tron.common.utils.ByteArray; import org.tron.core.Constant; import org.tron.core.capsule.AccountCapsule; +import org.tron.core.capsule.AccountTraceCapsule; import org.tron.core.config.args.Args; import org.tron.core.exception.BadItemException; import org.tron.core.exception.ItemNotFoundException; @@ -54,4 +55,16 @@ public void testGetPrevBalance() { Assert.assertEquals((long)pair2.getKey(),3L); Assert.assertEquals((long)pair2.getValue(), 99L); } + + @Test + public void testPut() { + long number = 2 ^ Long.MAX_VALUE; + long balance = 9999; + byte[] key = Bytes.concat(address, Longs.toByteArray(number)); + accountTraceStore.put(key, new AccountTraceCapsule(balance)); + Pair pair = accountTraceStore.getPrevBalance(address,2); + Assert.assertEquals((long)pair.getKey(),2L); + Assert.assertEquals((long)pair.getValue(), 0L); + } + } \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/db/BlockIndexStoreTest.java b/framework/src/test/java/org/tron/core/db/BlockIndexStoreTest.java new file mode 100644 index 00000000000..a5600b34b26 --- /dev/null +++ b/framework/src/test/java/org/tron/core/db/BlockIndexStoreTest.java @@ -0,0 +1,64 @@ +package org.tron.core.db; + +import com.google.protobuf.ByteString; +import javax.annotation.Resource; +import org.junit.Assert; +import org.junit.Test; +import org.tron.common.BaseTest; +import org.tron.common.utils.ByteArray; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.Constant; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.capsule.BytesCapsule; +import org.tron.core.config.args.Args; +import org.tron.core.exception.ItemNotFoundException; + +public class BlockIndexStoreTest extends BaseTest { + + @Resource + private BlockIndexStore blockIndexStore; + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath() + }, + Constant.TEST_CONF + ); + } + + private BlockCapsule getBlockCapsule(long number) { + return new BlockCapsule(number, Sha256Hash.ZERO_HASH, + System.currentTimeMillis(), ByteString.EMPTY); + } + + @Test + public void testPut() { + BlockCapsule blockCapsule = getBlockCapsule(1); + blockIndexStore.put(blockCapsule.getBlockId()); + byte[] key = ByteArray.fromLong(blockCapsule.getBlockId().getNum()); + Assert.assertTrue(blockIndexStore.has(key)); + } + + @Test + public void testGet() throws ItemNotFoundException { + BlockCapsule blockCapsule = getBlockCapsule(1); + blockIndexStore.put(blockCapsule.getBlockId()); + byte[] key = ByteArray.fromLong(blockCapsule.getBlockId().getNum()); + BytesCapsule bytesCapsule = blockIndexStore.get(key); + Assert.assertNotNull(bytesCapsule); + } + + @Test + public void testDelete() throws ItemNotFoundException { + BlockCapsule blockCapsule = getBlockCapsule(1); + blockIndexStore.put(blockCapsule.getBlockId()); + byte[] key = ByteArray.fromLong(blockCapsule.getBlockId().getNum()); + BytesCapsule bytesCapsule = blockIndexStore.get(key); + Assert.assertNotNull(bytesCapsule); + + blockIndexStore.delete(key); + BytesCapsule capsule = blockIndexStore.getUnchecked(key); + Assert.assertNull(capsule.getData()); + } +} diff --git a/framework/src/test/java/org/tron/core/db/BlockStoreTest.java b/framework/src/test/java/org/tron/core/db/BlockStoreTest.java index 4f706a97dcf..937a102193f 100644 --- a/framework/src/test/java/org/tron/core/db/BlockStoreTest.java +++ b/framework/src/test/java/org/tron/core/db/BlockStoreTest.java @@ -1,21 +1,90 @@ package org.tron.core.db; +import com.google.protobuf.ByteString; +import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; +import org.junit.Assert; import org.junit.Test; import org.tron.common.BaseTest; +import org.tron.common.utils.Sha256Hash; import org.tron.core.Constant; +import org.tron.core.capsule.BlockCapsule; import org.tron.core.config.args.Args; +import org.tron.core.exception.BadItemException; +import org.tron.core.exception.ItemNotFoundException; + @Slf4j public class BlockStoreTest extends BaseTest { + @Resource + private BlockStore blockStore; static { Args.setParam(new String[]{"--output-directory", dbPath()}, Constant.TEST_CONF); } + private BlockCapsule getBlockCapsule(long number) { + return new BlockCapsule(number, Sha256Hash.ZERO_HASH, + System.currentTimeMillis(), ByteString.EMPTY); + } + @Test public void testCreateBlockStore() { } + + @Test + public void testPut() { + long number = 1; + BlockCapsule blockCapsule = getBlockCapsule(number); + + byte[] blockId = blockCapsule.getBlockId().getBytes(); + blockStore.put(blockId, blockCapsule); + try { + BlockCapsule blockCapsule1 = blockStore.get(blockId); + Assert.assertNotNull(blockCapsule1); + Assert.assertEquals(number, blockCapsule1.getNum()); + } catch (ItemNotFoundException | BadItemException e) { + e.printStackTrace(); + } + } + + @Test + public void testGet() { + long number = 2; + BlockCapsule blockCapsule = getBlockCapsule(number); + byte[] blockId = blockCapsule.getBlockId().getBytes(); + blockStore.put(blockId, blockCapsule); + try { + boolean has = blockStore.has(blockId); + Assert.assertTrue(has); + BlockCapsule blockCapsule1 = blockStore.get(blockId); + + Assert.assertEquals(number, blockCapsule1.getNum()); + } catch (ItemNotFoundException | BadItemException e) { + e.printStackTrace(); + } + } + + @Test + public void testDelete() { + long number = 1; + BlockCapsule blockCapsule = getBlockCapsule(number); + + byte[] blockId = blockCapsule.getBlockId().getBytes(); + blockStore.put(blockId, blockCapsule); + try { + BlockCapsule blockCapsule1 = blockStore.get(blockId); + Assert.assertNotNull(blockCapsule1); + Assert.assertEquals(number, blockCapsule1.getNum()); + + blockStore.delete(blockId); + BlockCapsule blockCapsule2 = blockStore.getUnchecked(blockId); + Assert.assertNull(blockCapsule2); + } catch (ItemNotFoundException | BadItemException e) { + e.printStackTrace(); + } + } + } diff --git a/framework/src/test/java/org/tron/core/db/DBIteratorTest.java b/framework/src/test/java/org/tron/core/db/DBIteratorTest.java index a55d1b04d4d..b4f7ca424c0 100644 --- a/framework/src/test/java/org/tron/core/db/DBIteratorTest.java +++ b/framework/src/test/java/org/tron/core/db/DBIteratorTest.java @@ -5,86 +5,122 @@ import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.nio.file.Paths; import java.util.NoSuchElementException; import org.iq80.leveldb.DB; import org.iq80.leveldb.Options; -import org.junit.AfterClass; import org.junit.Assert; -import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; import org.rocksdb.RocksDB; import org.rocksdb.RocksDBException; -import org.tron.common.utils.FileUtil; import org.tron.core.db.common.iterator.RockStoreIterator; import org.tron.core.db.common.iterator.StoreIterator; public class DBIteratorTest { - @BeforeClass - public static void init() { - File file = Paths.get("database-iterator").toFile(); - if (!file.exists()) { - file.mkdirs(); - } - } + @ClassRule + public static final TemporaryFolder temporaryFolder = new TemporaryFolder(); - @AfterClass - public static void clear() { - File file = Paths.get("database-iterator").toFile(); - if (file.exists()) { - FileUtil.deleteDir(Paths.get("database-iterator").toFile()); - } - } + @Rule + public final ExpectedException thrown = ExpectedException.none(); @Test public void testLevelDb() throws IOException { - File file = new File("database-iterator/testLevelDb"); - try { - DB db = factory.open(file, new Options().createIfMissing(true)); + File file = temporaryFolder.newFolder(); + try (DB db = factory.open(file, new Options().createIfMissing(true))) { db.put("1".getBytes(StandardCharsets.UTF_8), "1".getBytes(StandardCharsets.UTF_8)); db.put("2".getBytes(StandardCharsets.UTF_8), "2".getBytes(StandardCharsets.UTF_8)); - StoreIterator iterator = new StoreIterator(db.iterator()); + StoreIterator iterator = new StoreIterator(db.iterator()); + iterator.seekToFirst(); + Assert.assertArrayEquals("1".getBytes(StandardCharsets.UTF_8), iterator.getKey()); + Assert.assertArrayEquals("1".getBytes(StandardCharsets.UTF_8), iterator.next().getValue()); + Assert.assertTrue(iterator.hasNext()); + + Assert.assertArrayEquals("2".getBytes(StandardCharsets.UTF_8), iterator.getValue()); + Assert.assertArrayEquals("2".getBytes(StandardCharsets.UTF_8), iterator.next().getKey()); + Assert.assertFalse(iterator.hasNext()); + + try { + iterator.seekToLast(); + } catch (Exception e) { + Assert.assertTrue(e instanceof IllegalStateException); + } + + iterator = new StoreIterator(db.iterator()); + iterator.seekToLast(); + Assert.assertArrayEquals("2".getBytes(StandardCharsets.UTF_8), iterator.getKey()); + Assert.assertArrayEquals("2".getBytes(StandardCharsets.UTF_8), iterator.getValue()); + iterator.seekToFirst(); while (iterator.hasNext()) { iterator.next(); } Assert.assertFalse(iterator.hasNext()); try { - iterator.next(); + iterator.getKey(); } catch (Exception e) { - Assert.assertTrue(e instanceof NoSuchElementException); + Assert.assertTrue(e instanceof IllegalStateException); } - db.close(); - } finally { - factory.destroy(file, new Options()); + try { + iterator.getValue(); + } catch (Exception e) { + Assert.assertTrue(e instanceof IllegalStateException); + } + thrown.expect(NoSuchElementException.class); + iterator.next(); } } @Test - public void testRocksDb() throws RocksDBException { - File file = new File("database-iterator/testRocksDb"); - try (org.rocksdb.Options options = new org.rocksdb.Options().setCreateIfMissing(true)) { - RocksDB db = RocksDB.open(options, file.toString()); + public void testRocksDb() throws RocksDBException, IOException { + File file = temporaryFolder.newFolder(); + try (org.rocksdb.Options options = new org.rocksdb.Options().setCreateIfMissing(true); + RocksDB db = RocksDB.open(options, file.toString())) { db.put("1".getBytes(StandardCharsets.UTF_8), "1".getBytes(StandardCharsets.UTF_8)); db.put("2".getBytes(StandardCharsets.UTF_8), "2".getBytes(StandardCharsets.UTF_8)); RockStoreIterator iterator = new RockStoreIterator(db.newIterator()); + iterator.seekToFirst(); + Assert.assertArrayEquals("1".getBytes(StandardCharsets.UTF_8), iterator.getKey()); + Assert.assertArrayEquals("1".getBytes(StandardCharsets.UTF_8), iterator.next().getValue()); + Assert.assertTrue(iterator.hasNext()); + + Assert.assertArrayEquals("2".getBytes(StandardCharsets.UTF_8), iterator.getValue()); + Assert.assertArrayEquals("2".getBytes(StandardCharsets.UTF_8), iterator.next().getKey()); + Assert.assertFalse(iterator.hasNext()); + + try { + iterator.seekToLast(); + } catch (Exception e) { + Assert.assertTrue(e instanceof IllegalStateException); + } + + iterator = new RockStoreIterator(db.newIterator()); + iterator.seekToLast(); + Assert.assertArrayEquals("2".getBytes(StandardCharsets.UTF_8), iterator.getKey()); + Assert.assertArrayEquals("2".getBytes(StandardCharsets.UTF_8), iterator.getValue()); + iterator.seekToFirst(); while (iterator.hasNext()) { iterator.next(); } Assert.assertFalse(iterator.hasNext()); try { - iterator.next(); + iterator.getKey(); + } catch (Exception e) { + Assert.assertTrue(e instanceof IllegalStateException); + } + try { + iterator.getValue(); } catch (Exception e) { - Assert.assertTrue(e instanceof NoSuchElementException); + Assert.assertTrue(e instanceof IllegalStateException); } - db.close(); - } finally { - RocksDB.destroyDB(file.toString(), new org.rocksdb.Options()); + thrown.expect(NoSuchElementException.class); + iterator.next(); } - } } diff --git a/framework/src/test/java/org/tron/core/db/DelegatedResourceStoreTest.java b/framework/src/test/java/org/tron/core/db/DelegatedResourceStoreTest.java index 8878ff0dcf3..905ef0384f1 100644 --- a/framework/src/test/java/org/tron/core/db/DelegatedResourceStoreTest.java +++ b/framework/src/test/java/org/tron/core/db/DelegatedResourceStoreTest.java @@ -57,6 +57,21 @@ public void testPut() { Assert.assertEquals(BALANCE, delegatedResourceCapsule1.getFrozenBalanceForEnergy()); } + @Test + public void testDelete() { + DelegatedResourceCapsule delegatedResourceCapsule = create("444444444"); + byte[] key = delegatedResourceCapsule.createDbKey(); + delegatedResourceStore.put(key, delegatedResourceCapsule); + DelegatedResourceCapsule delegatedResourceCapsule1 = delegatedResourceStore.get(key); + Assert.assertNotNull(delegatedResourceCapsule1); + Assert.assertEquals(BALANCE, delegatedResourceCapsule1.getFrozenBalanceForEnergy()); + + delegatedResourceStore.delete(key); + DelegatedResourceCapsule delegatedResourceCapsule2 = delegatedResourceStore.get(key); + Assert.assertNull(delegatedResourceCapsule2); + + } + public DelegatedResourceCapsule create(String address) { byte[] ownerAddress = ByteArray.fromHexString(address); byte[] receiverAddress = ByteArray.fromHexString(RECEIVER_ADDRESS); diff --git a/framework/src/test/java/org/tron/core/db/DelegationStoreTest.java b/framework/src/test/java/org/tron/core/db/DelegationStoreTest.java index d63015ae064..10e70a0a83b 100644 --- a/framework/src/test/java/org/tron/core/db/DelegationStoreTest.java +++ b/framework/src/test/java/org/tron/core/db/DelegationStoreTest.java @@ -68,4 +68,21 @@ public void testPut() { Assert.assertEquals(value, actualValue); } + @Test + public void testDelete() { + long value = 20_000_000; + byte[] key = buildRewardKey(CYCLE, ByteArray.fromHexString("33333333")); + delegationStore.put(key, new BytesCapsule(ByteArray + .fromLong(20_000_000))); + + BytesCapsule bytesCapsule = delegationStore.get(key); + Assert.assertNotNull(bytesCapsule); + long actualValue = ByteArray.toLong(bytesCapsule.getData()); + Assert.assertEquals(value, actualValue); + + delegationStore.delete(key); + BytesCapsule bytesCapsule1 = delegationStore.getUnchecked(key); + Assert.assertNull(bytesCapsule1.getData()); + } + } diff --git a/framework/src/test/java/org/tron/core/db/ExchangeStoreTest.java b/framework/src/test/java/org/tron/core/db/ExchangeStoreTest.java index f48ac11301d..685c137422c 100644 --- a/framework/src/test/java/org/tron/core/db/ExchangeStoreTest.java +++ b/framework/src/test/java/org/tron/core/db/ExchangeStoreTest.java @@ -10,6 +10,7 @@ import org.tron.core.Constant; import org.tron.core.capsule.ExchangeCapsule; import org.tron.core.config.args.Args; +import org.tron.core.exception.ItemNotFoundException; import org.tron.core.store.ExchangeStore; import org.tron.protos.Protocol; @@ -50,6 +51,30 @@ public void testGet() throws Exception { Assert.assertEquals(result.getID(), 1); } + @Test + public void testPut() throws ItemNotFoundException { + Protocol.Exchange.Builder builder = Protocol.Exchange.newBuilder(); + builder.setExchangeId(1L).setCreatorAddress(ByteString.copyFromUtf8("Address1")); + ExchangeCapsule exchangeCapsule = new ExchangeCapsule(builder.build()); + exchangeKey1 = exchangeCapsule.createDbKey(); + chainBaseManager.getExchangeStore().put(exchangeKey1, exchangeCapsule); + + final ExchangeCapsule result = exchangeStore.get(exchangeKey1); + Assert.assertNotNull(result); + Assert.assertEquals(result.getID(), 1); + } + + @Test + public void testDelete() throws Exception { + final ExchangeCapsule result = exchangeStore.get(exchangeKey1); + Assert.assertNotNull(result); + Assert.assertEquals(result.getID(), 1); + + exchangeStore.delete(exchangeKey1); + ExchangeCapsule exchangeCapsule = exchangeStore.getUnchecked(exchangeKey1); + Assert.assertNull(exchangeCapsule); + } + @Test public void testGetAllExchanges() { List exchangeCapsuleList = exchangeStore.getAllExchanges(); diff --git a/framework/src/test/java/org/tron/core/db/ExchangeV2StoreTest.java b/framework/src/test/java/org/tron/core/db/ExchangeV2StoreTest.java index 2b1e2ea31ea..97c5f599b6e 100644 --- a/framework/src/test/java/org/tron/core/db/ExchangeV2StoreTest.java +++ b/framework/src/test/java/org/tron/core/db/ExchangeV2StoreTest.java @@ -8,6 +8,7 @@ import org.tron.core.Constant; import org.tron.core.capsule.ExchangeCapsule; import org.tron.core.config.args.Args; +import org.tron.core.exception.ItemNotFoundException; import org.tron.core.store.ExchangeV2Store; import org.tron.protos.Protocol; @@ -33,6 +34,31 @@ public void testGet() throws Exception { Assert.assertEquals(result.getID(), 1); } + @Test + public void testPut() throws ItemNotFoundException { + Protocol.Exchange.Builder builder = Protocol.Exchange.newBuilder().setExchangeId(1L) + .setCreatorAddress(ByteString.copyFromUtf8("Address2")); + ExchangeCapsule exchangeCapsule = new ExchangeCapsule(builder.build()); + byte[] exchangeKey1 = exchangeCapsule.createDbKey(); + exchangeV2Store.put(exchangeKey1, exchangeCapsule); + + final ExchangeCapsule result = exchangeV2Store.get(exchangeKey1); + Assert.assertNotNull(result); + Assert.assertEquals(result.getID(), 1); + } + + @Test + public void testDelete() throws ItemNotFoundException { + Protocol.Exchange.Builder builder = Protocol.Exchange.newBuilder().setExchangeId(1L) + .setCreatorAddress(ByteString.copyFromUtf8("Address3")); + ExchangeCapsule exchangeCapsule = new ExchangeCapsule(builder.build()); + byte[] exchangeKey1 = exchangeCapsule.createDbKey(); + exchangeV2Store.put(exchangeKey1, exchangeCapsule); + exchangeV2Store.delete(exchangeKey1); + ExchangeCapsule result = exchangeV2Store.getUnchecked(exchangeKey1); + Assert.assertNull(result); + } + private byte[] putToExchangeV2() { Protocol.Exchange.Builder builder = Protocol.Exchange.newBuilder().setExchangeId(1L) .setCreatorAddress(ByteString.copyFromUtf8("Address1")); diff --git a/framework/src/test/java/org/tron/core/db/ManagerMockTest.java b/framework/src/test/java/org/tron/core/db/ManagerMockTest.java new file mode 100644 index 00000000000..364b86c82b4 --- /dev/null +++ b/framework/src/test/java/org/tron/core/db/ManagerMockTest.java @@ -0,0 +1,441 @@ +package org.tron.core.db; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockConstruction; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.nio.charset.StandardCharsets; + +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.junit.After; +import org.junit.Test; +import org.mockito.MockedConstruction; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +import org.tron.common.cron.CronExpression; +import org.tron.common.parameter.CommonParameter; +import org.tron.common.runtime.ProgramResult; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.ChainBaseManager; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.capsule.TransactionCapsule; +import org.tron.core.capsule.TransactionInfoCapsule; +import org.tron.core.capsule.utils.TransactionUtil; +import org.tron.core.config.args.Args; +import org.tron.core.exception.ContractSizeNotEqualToOneException; +import org.tron.core.exception.DupTransactionException; +import org.tron.core.exception.ItemNotFoundException; +import org.tron.core.exception.ReceiptCheckErrException; +import org.tron.core.exception.TaposException; +import org.tron.core.exception.TooBigTransactionException; +import org.tron.core.exception.TooBigTransactionResultException; +import org.tron.core.exception.TransactionExpirationException; +import org.tron.core.exception.ValidateSignatureException; +import org.tron.core.store.AccountStore; +import org.tron.core.store.BalanceTraceStore; +import org.tron.core.store.DynamicPropertiesStore; +import org.tron.protos.Protocol; +import org.tron.protos.contract.BalanceContract; + +@Slf4j +public class ManagerMockTest { + @After + public void clearMocks() { + Mockito.framework().clearInlineMocks(); + } + + @Test + public void processTransactionCostTimeMoreThan100() throws Exception { + TransactionTrace traceMock = mock(TransactionTrace.class); + BandwidthProcessor bandwidthProcessorMock = mock(BandwidthProcessor.class); + try (MockedConstruction mockedConstruction2 + = mockConstruction(TransactionTrace.class,(mock, context) -> { + when(mock).thenReturn(traceMock); }); + MockedConstruction mockedConstruction3 + = mockConstruction(BandwidthProcessor.class,(mock, context) -> { + when(mock).thenReturn(bandwidthProcessorMock); + }); + MockedStatic mockedStatic = mockStatic(TransactionUtil.class)) { + Manager dbManager = mock(Manager.class); + BalanceContract.TransferContract transferContract = + BalanceContract.TransferContract.newBuilder() + .setAmount(10) + .setOwnerAddress(ByteString.copyFromUtf8("aaa")) + .setToAddress(ByteString.copyFromUtf8("bbb")) + .build(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 6666; i++) { + sb.append("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + } + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().setRawData( + Protocol.Transaction.raw.newBuilder() + .setData(ByteString.copyFrom(sb.toString().getBytes(StandardCharsets.UTF_8))) + .addContract( + Protocol.Transaction.Contract.newBuilder() + .setParameter(Any.pack(transferContract)) + .setType(Protocol.Transaction.Contract.ContractType.TransferContract))) + .build(); + TransactionCapsule trxCap = new TransactionCapsule(transaction); + ProgramResult result = new ProgramResult(); + result.setResultCode(Protocol.Transaction.Result.contractResult.SUCCESS); + + Sha256Hash transactionId = trxCap.getTransactionId(); + TransactionCapsule trxCapMock = mock(TransactionCapsule.class); + + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + BalanceTraceStore balanceTraceStoreMock = mock(BalanceTraceStore.class); + TransactionStore transactionStoreMock = mock(TransactionStore.class); + TransactionInfoCapsule transactionInfoCapsuleMock = mock(TransactionInfoCapsule.class); + Protocol.TransactionInfo transactionInfo = Protocol.TransactionInfo.newBuilder().build(); + + Field field = dbManager.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(dbManager, chainBaseManagerMock); + + BlockCapsule blockCapMock = Mockito.mock(BlockCapsule.class); + + when(TransactionUtil + .buildTransactionInfoInstance(trxCapMock, blockCapMock, traceMock)) + .thenReturn(transactionInfoCapsuleMock); + + // this make cost > 100 cond is true + when(blockCapMock.isMerkleRootEmpty()).thenAnswer(new Answer() { + @Override + public Boolean answer(InvocationOnMock invocation) throws Throwable { + Thread.sleep(100); + return true; + } + }); + + when(chainBaseManagerMock.getBalanceTraceStore()).thenReturn(balanceTraceStoreMock); + when(chainBaseManagerMock.getAccountStore()).thenReturn(mock(AccountStore.class)); + when(chainBaseManagerMock.getDynamicPropertiesStore()) + .thenReturn(mock(DynamicPropertiesStore.class)); + when(chainBaseManagerMock.getTransactionStore()).thenReturn(transactionStoreMock); + when(trxCapMock.getTransactionId()).thenReturn(transactionId); + when(traceMock.getRuntimeResult()).thenReturn(result); + when(transactionInfoCapsuleMock.getId()).thenReturn(transactionId.getBytes()); + when(transactionInfoCapsuleMock.getInstance()).thenReturn(transactionInfo); + when(trxCapMock.getInstance()).thenReturn(trxCap.getInstance()); + when(trxCapMock.validatePubSignature( + Mockito.any(AccountStore.class), + Mockito.any(DynamicPropertiesStore.class))).thenReturn(true); + when(trxCapMock.validateSignature( + Mockito.any(AccountStore.class), + Mockito.any(DynamicPropertiesStore.class))).thenReturn(true); + + doNothing().when(dbManager).validateTapos(trxCapMock); + doNothing().when(dbManager).validateCommon(trxCapMock); + doNothing().when(dbManager).validateDup(trxCapMock); + + + doNothing().when(transactionStoreMock).put(transactionId.getBytes(), trxCapMock); + doNothing().when(bandwidthProcessorMock).consume(trxCapMock, traceMock); + doNothing().when(dbManager).consumeBandwidth(trxCapMock, traceMock); + doNothing().when(balanceTraceStoreMock).initCurrentTransactionBalanceTrace(trxCapMock); + doNothing().when(balanceTraceStoreMock).updateCurrentTransactionStatus(anyString()); + doNothing().when(balanceTraceStoreMock).resetCurrentTransactionTrace(); + + + assertNotNull( + when(dbManager.processTransaction(trxCapMock, blockCapMock)).thenCallRealMethod() + ); + } + } + + private void initMockEnv(Manager dbManager, long headNum, long headTime, + long exitHeight, long exitCount, String blockTime) + throws Exception { + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + Args argsMock = mock(Args.class); + + when(Args.getInstance()).thenReturn(argsMock); + + when(chainBaseManagerMock.getHeadBlockNum()).thenReturn(headNum); + when(chainBaseManagerMock.getHeadBlockTimeStamp()).thenReturn(headTime); + + when(argsMock.getShutdownBlockHeight()).thenReturn(exitHeight); + when(argsMock.getShutdownBlockCount()).thenReturn(exitCount); + when(argsMock.isP2pDisable()).thenReturn(false); + when(argsMock.getShutdownBlockTime()) + .thenReturn(new CronExpression(blockTime)); //"0 0 12 * * ?" + + Field field = dbManager.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(dbManager, chainBaseManagerMock); + } + + @Test + public void testInitAutoStop() throws Exception { + Manager dbManager = spy(new Manager()); + try (MockedStatic methodTestMockedStatic + = mockStatic(CommonParameter.class)) { + initMockEnv(dbManager, 100L, 12345L, + 10L, 0L, "0 0 12 * * ?"); + + assertThrows( + "shutDownBlockHeight 10 is less than headNum 100", + Exception.class, + () -> { + Method privateMethod = Manager.class.getDeclaredMethod( + "initAutoStop"); + privateMethod.setAccessible(true); + privateMethod.invoke(dbManager); + } + ); + } + + } + + @Test + public void testInitAutoStop1() throws Exception { + Manager dbManager = spy(new Manager()); + try (MockedStatic methodTestMockedStatic + = mockStatic(CommonParameter.class)) { + initMockEnv(dbManager,10L, 12345L, + 100L, 0L, "0 0 12 * * ?"); + + assertThrows( + "shutDownBlockCount 0 is less than 1", + Exception.class, + () -> { + Method privateMethod = Manager.class.getDeclaredMethod( + "initAutoStop"); + privateMethod.setAccessible(true); + privateMethod.invoke(dbManager); + } + ); + } + } + + @Test + public void testInitAutoStop2() throws Exception { + Manager dbManager = spy(new Manager()); + try (MockedStatic methodTestMockedStatic + = mockStatic(CommonParameter.class)) { + initMockEnv(dbManager,10L, 99726143865000L, + 100L, 1L, "0 0 12 * * ?"); + + assertThrows( + "shutDownBlockTime 0 0 12 * * ? is illegal", + Exception.class, + () -> { + Method privateMethod = Manager.class.getDeclaredMethod( + "initAutoStop"); + privateMethod.setAccessible(true); + privateMethod.invoke(dbManager); + } + ); + } + + } + + @Test + public void testInitAutoStop3() throws Exception { + Manager dbManager = spy(new Manager()); + try (MockedStatic methodTestMockedStatic + = mockStatic(CommonParameter.class)) { + initMockEnv(dbManager,10L, 12345L, + 100L, 1L, "0 0 12 * * ?"); + + assertThrows( + "shutDownBlockHeight 100 and shutDownBlockCount 1 set both", + Exception.class, + () -> { + Method privateMethod = Manager.class.getDeclaredMethod( + "initAutoStop"); + privateMethod.setAccessible(true); + privateMethod.invoke(dbManager); + } + ); + } + + } + + @Test + public void testInitAutoStop4() throws Exception { + Manager dbManager = spy(new Manager()); + try (MockedStatic methodTestMockedStatic + = mockStatic(CommonParameter.class)) { + initMockEnv(dbManager, 10L, 12345L, + 100L, -1L, "0 0 12 * * ?"); + + assertThrows( + "shutDownBlockHeight 100 and shutDownBlockTime 0 0 12 * * ? set both", + Exception.class, + () -> { + Method privateMethod = Manager.class.getDeclaredMethod( + "initAutoStop"); + privateMethod.setAccessible(true); + privateMethod.invoke(dbManager); + } + ); + } + + } + + @Test + public void testInitAutoStop5() throws Exception { + Manager dbManager = spy(new Manager()); + try (MockedStatic methodTestMockedStatic + = mockStatic(CommonParameter.class)) { + initMockEnv(dbManager,10L, 12345L, + 0L, 1L, "0 0 12 * * ?"); + + assertThrows( + "shutDownBlockCount 1 and shutDownBlockTime 0 0 12 * * ? set both", + Exception.class, + () -> { + Method privateMethod = Manager.class.getDeclaredMethod( + "initAutoStop"); + privateMethod.setAccessible(true); + privateMethod.invoke(dbManager); + } + ); + } + + } + + @Test + public void testProcessTransaction() throws Exception { + Manager dbManager = spy(new Manager()); + TransactionCapsule transactionCapsuleMock = null; + BlockCapsule blockCapsuleMock = mock(BlockCapsule.class); + + Method privateMethod = Manager.class.getDeclaredMethod( + "processTransaction", + TransactionCapsule.class, BlockCapsule.class); + privateMethod.setAccessible(true); + privateMethod.invoke(dbManager, transactionCapsuleMock, blockCapsuleMock); + } + + @Test + public void testProcessTransaction1() { + Manager dbManager = spy(new Manager()); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().setRawData( + Protocol.Transaction.raw.newBuilder() + .setData(ByteString.copyFrom("sb.toString()".getBytes(StandardCharsets.UTF_8)))) + .build(); + TransactionCapsule trxCap = new TransactionCapsule(transaction); + + BlockCapsule blockCapsuleMock = mock(BlockCapsule.class); + + Throwable thrown = assertThrows(InvocationTargetException.class, () -> { + Method privateMethod = Manager.class.getDeclaredMethod( + "processTransaction", + TransactionCapsule.class, BlockCapsule.class); + privateMethod.setAccessible(true); + privateMethod.invoke(dbManager, trxCap, blockCapsuleMock); + }); + Throwable cause = thrown.getCause(); + assertTrue(cause instanceof ContractSizeNotEqualToOneException); + } + + @SneakyThrows + @Test + public void testRePush() { + Manager dbManager = spy(new Manager()); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + TransactionCapsule trx = new TransactionCapsule(transaction); + TransactionStore transactionStoreMock = mock(TransactionStore.class); + + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + Field field = dbManager.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(dbManager, chainBaseManagerMock); + when(chainBaseManagerMock.getTransactionStore()).thenReturn(transactionStoreMock); + when(transactionStoreMock.has(any())).thenReturn(true); + + dbManager.rePush(trx); + } + + @SneakyThrows + @Test + public void testRePush1() { + Manager dbManager = spy(new Manager()); + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().build(); + TransactionCapsule trx = new TransactionCapsule(transaction); + TransactionStore transactionStoreMock = mock(TransactionStore.class); + + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + + Field field = dbManager.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(dbManager, chainBaseManagerMock); + + when(chainBaseManagerMock.getTransactionStore()).thenReturn(transactionStoreMock); + when(transactionStoreMock.has(any())).thenReturn(false); + + doThrow(new ValidateSignatureException()).when(dbManager).pushTransaction(any()); + dbManager.rePush(trx); + + doThrow(new DupTransactionException()).when(dbManager).pushTransaction(any()); + dbManager.rePush(trx); + + doThrow(new TaposException()).when(dbManager).pushTransaction(any()); + dbManager.rePush(trx); + + doThrow(new TooBigTransactionException()).when(dbManager).pushTransaction(any()); + dbManager.rePush(trx); + + doThrow(new TransactionExpirationException()).when(dbManager).pushTransaction(any()); + dbManager.rePush(trx); + + doThrow(new ReceiptCheckErrException()).when(dbManager).pushTransaction(any()); + dbManager.rePush(trx); + + doThrow(new TooBigTransactionResultException()).when(dbManager).pushTransaction(any()); + dbManager.rePush(trx); + } + + @Test + public void testPostSolidityFilter() throws Exception { + Manager dbManager = spy(new Manager()); + + Method privateMethod = Manager.class.getDeclaredMethod( + "postSolidityFilter", long.class, long.class); + privateMethod.setAccessible(true); + privateMethod.invoke(dbManager, 100L, 10L); + } + + @Test + public void testReOrgLogsFilter() throws Exception { + Manager dbManager = spy(new Manager()); + CommonParameter commonParameterMock = mock(Args.class); + mockStatic(CommonParameter.class); + ChainBaseManager chainBaseManagerMock = mock(ChainBaseManager.class); + + when(CommonParameter.getInstance()).thenReturn(commonParameterMock); + when(commonParameterMock.isJsonRpcHttpFullNodeEnable()).thenReturn(true); + when(chainBaseManagerMock.getDynamicPropertiesStore()) + .thenReturn(mock(DynamicPropertiesStore.class)); + Field field = dbManager.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(dbManager, chainBaseManagerMock); + doThrow(new ItemNotFoundException()).when(chainBaseManagerMock).getBlockById(any()); + + Method privateMethod = Manager.class.getDeclaredMethod("reOrgLogsFilter"); + privateMethod.setAccessible(true); + privateMethod.invoke(dbManager); + } + +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/db/ManagerTest.java b/framework/src/test/java/org/tron/core/db/ManagerTest.java index e25faf536f7..db219377b74 100755 --- a/framework/src/test/java/org/tron/core/db/ManagerTest.java +++ b/framework/src/test/java/org/tron/core/db/ManagerTest.java @@ -1,15 +1,23 @@ package org.tron.core.db; +import static org.junit.Assert.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.spy; import static org.tron.common.utils.Commons.adjustAssetBalanceV2; -import static org.tron.common.utils.Commons.adjustBalance; import static org.tron.common.utils.Commons.adjustTotalShieldedPoolValue; import static org.tron.common.utils.Commons.getExchangeStoreFinal; +import static org.tron.common.utils.StringUtil.encode58Check; import static org.tron.core.exception.BadBlockException.TypeEnum.CALC_MERKLE_ROOT_FAILED; +import static org.tron.protos.Protocol.Transaction.Result.contractResult.SUCCESS; +import com.beust.jcommander.internal.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import com.google.protobuf.Any; import com.google.protobuf.ByteString; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -29,6 +37,7 @@ import org.tron.common.crypto.ECKey; import org.tron.common.runtime.RuntimeImpl; import org.tron.common.utils.ByteArray; +import org.tron.common.utils.Commons; import org.tron.common.utils.JsonUtil; import org.tron.common.utils.LocalWitnesses; import org.tron.common.utils.PublicMethod; @@ -69,11 +78,13 @@ import org.tron.core.exception.TooBigTransactionException; import org.tron.core.exception.TooBigTransactionResultException; import org.tron.core.exception.TransactionExpirationException; +import org.tron.core.exception.TronError; import org.tron.core.exception.UnLinkedBlockException; import org.tron.core.exception.VMIllegalException; import org.tron.core.exception.ValidateScheduleException; import org.tron.core.exception.ValidateSignatureException; import org.tron.core.exception.ZksnarkException; +import org.tron.core.store.AccountStore; import org.tron.core.store.CodeStore; import org.tron.core.store.DynamicPropertiesStore; import org.tron.core.store.ExchangeStore; @@ -112,7 +123,7 @@ public class ManagerTest extends BlockGenerate { @Before public void init() throws IOException { Args.setParam(new String[]{"-d", - temporaryFolder.newFolder().toString(), "-w"}, Constant.TEST_CONF); + temporaryFolder.newFolder().toString()}, Constant.TEST_CONF); Args.getInstance().setNodeListenPort(10000 + port.incrementAndGet()); context = new TronApplicationContext(DefaultConfig.class); @@ -357,12 +368,12 @@ public void entityTest() { Assert.assertTrue(trie.isEmpty()); AccountStateEntity entity = new AccountStateEntity(); AccountStateEntity parsedEntity = AccountStateEntity.parse("".getBytes()); - Assert.assertTrue(parsedEntity != null); - Assert.assertTrue(parsedEntity.getAccount() != null); - Assert.assertTrue(org.tron.core.db.api.pojo.Account.of() != null); - Assert.assertTrue(org.tron.core.db.api.pojo.AssetIssue.of() != null); - Assert.assertTrue(org.tron.core.db.api.pojo.Block.of() != null); - Assert.assertTrue(org.tron.core.db.api.pojo.Transaction.of() != null); + Assert.assertNotNull(parsedEntity); + Assert.assertNotNull(parsedEntity.getAccount()); + Assert.assertNotNull(org.tron.core.db.api.pojo.Account.of()); + Assert.assertNotNull(org.tron.core.db.api.pojo.AssetIssue.of()); + Assert.assertNotNull(org.tron.core.db.api.pojo.Block.of()); + Assert.assertNotNull(org.tron.core.db.api.pojo.Transaction.of()); } @@ -470,7 +481,7 @@ public void adjustAssetBalanceV2Test() { } catch (BalanceInsufficientException e) { Assert.assertTrue(e instanceof BalanceInsufficientException); Assert.assertEquals( - "reduceAssetAmount failed! account: " + StringUtil.encode58Check(account.createDbKey()), + "reduceAssetAmount failed! account: " + encode58Check(account.createDbKey()), e.getMessage()); } @@ -580,15 +591,36 @@ public void pushSwitchFork() TaposException, ReceiptCheckErrException, TooBigTransactionException, AccountResourceInsufficientException, EventBloomException { - String key = "f31db24bfbd1a2ef19beddca0a0fa37632eded9ac666a05d3bd925f01dde1f62"; + String key = PublicMethod.getRandomPrivateKey(); + String key2 = PublicMethod.getRandomPrivateKey(); byte[] privateKey = ByteArray.fromHexString(key); final ECKey ecKey = ECKey.fromPrivate(privateKey); byte[] address = ecKey.getAddress(); + ByteString addressByte = ByteString.copyFrom(address); + AccountCapsule accountCapsule = + new AccountCapsule(Protocol.Account.newBuilder() + .setAddress(addressByte).build()); + chainManager.getAccountStore() + .put(addressByte.toByteArray(), accountCapsule); + + WitnessCapsule sr1 = new WitnessCapsule( + ByteString.copyFrom(address), "www.tron.net/first"); + sr1.setVoteCount(1000000000L); + + + byte[] privateKey2 = ByteArray.fromHexString(key2); + final ECKey ecKey2 = ECKey.fromPrivate(privateKey2); + byte[] address2 = ecKey2.getAddress(); + WitnessCapsule sr2 = new WitnessCapsule( + ByteString.copyFrom(address2), "www.tron.net/second"); + sr2.setVoteCount(100000L); + chainManager.getWitnessStore().put(address, sr1); WitnessCapsule witnessCapsule = new WitnessCapsule(ByteString.copyFrom(address)); chainManager.getWitnessScheduleStore().saveActiveWitnesses(new ArrayList<>()); chainManager.addWitness(ByteString.copyFrom(address)); - + List witnessStandby1 = chainManager.getWitnessStore().getWitnessStandby( + chainManager.getDynamicPropertiesStore().allowWitnessSortOptimization()); Block block = getSignedBlock(witnessCapsule.getAddress(), 1533529947843L, privateKey); dbManager.pushBlock(new BlockCapsule(block)); @@ -625,6 +657,10 @@ public void pushSwitchFork() } catch (Exception e) { Assert.assertTrue(e instanceof Exception); } + chainManager.getWitnessStore().put(address, sr2); + List witnessStandby2 = chainManager.getWitnessStore().getWitnessStandby( + chainManager.getDynamicPropertiesStore().allowWitnessSortOptimization()); + Assert.assertNotEquals(witnessStandby1, witnessStandby2); } @@ -687,18 +723,28 @@ public void fork() BadBlockException, TaposException, BadNumberBlockException, NonCommonBlockException, ReceiptCheckErrException, VMIllegalException, TooBigTransactionResultException, ZksnarkException, EventBloomException { - Args.setParam(new String[]{"--witness"}, Constant.TEST_CONF); + Args.setParam(new String[]{}, Constant.TEST_CONF); long size = chainManager.getBlockStore().size(); // System.out.print("block store size:" + size + "\n"); - String key = "f31db24bfbd1a2ef19beddca0a0fa37632eded9ac666a05d3bd925f01dde1f62"; + String key = PublicMethod.getRandomPrivateKey(); byte[] privateKey = ByteArray.fromHexString(key); final ECKey ecKey = ECKey.fromPrivate(privateKey); byte[] address = ecKey.getAddress(); + + ByteString addressByte = ByteString.copyFrom(address); + AccountCapsule accountCapsule = + new AccountCapsule(Protocol.Account.newBuilder() + .setAddress(addressByte).build()); + chainManager.getAccountStore() + .put(addressByte.toByteArray(), accountCapsule); + + WitnessCapsule witnessCapsule = new WitnessCapsule(ByteString.copyFrom(address)); chainManager.getWitnessScheduleStore().saveActiveWitnesses(new ArrayList<>()); chainManager.addWitness(ByteString.copyFrom(address)); + chainManager.getWitnessStore().put(address, witnessCapsule); - Block block = getSignedBlock(witnessCapsule.getAddress(), 1533529947843L, privateKey); + Block block = getSignedBlock(witnessCapsule.getAddress(), 1533529947000L, privateKey); dbManager.pushBlock(new BlockCapsule(block)); @@ -708,7 +754,7 @@ public void fork() long num = chainManager.getDynamicPropertiesStore().getLatestBlockHeaderNumber(); BlockCapsule blockCapsule0 = createTestBlockCapsule( - 1533529947843L + 3000, + 1533529947000L + 3000, num + 1, chainManager.getDynamicPropertiesStore().getLatestBlockHeaderHash() .getByteString(), @@ -716,7 +762,7 @@ public void fork() BlockCapsule blockCapsule1 = createTestBlockCapsule( - 1533529947843L + 3000, + 1533529947000L + 3000, num + 1, chainManager.getDynamicPropertiesStore().getLatestBlockHeaderHash() .getByteString(), @@ -727,7 +773,7 @@ public void fork() BlockCapsule blockCapsule2 = createTestBlockCapsule( - 1533529947843L + 6000, + 1533529947000L + 6000, num + 2, blockCapsule1.getBlockId().getByteString(), addressToProvateKeys); dbManager.pushBlock(blockCapsule2); @@ -754,6 +800,24 @@ public void fork() Assert.assertEquals( chainManager.getHead().getBlockId(), chainManager.getDynamicPropertiesStore().getLatestBlockHeaderHash()); + + dbManager.getDynamicPropertiesStore().saveConsensusLogicOptimization(1); + BlockCapsule blockCapsule3 = + createTestBlockCapsule2(1533529947000L + 9000, + num + 3, blockCapsule2.getBlockId().getByteString(), addressToProvateKeys); + + assertThrows(BadBlockException.class, () -> dbManager.pushBlock(blockCapsule3)); + } + + private Transaction buildTransaction(com.google.protobuf.Message message, + ContractType contractType) { + Transaction.raw.Builder rawBuilder = Transaction.raw.newBuilder().addContract( + Transaction.Contract.newBuilder().setType(contractType).setParameter( + (message instanceof Any ? (Any) message : Any.pack(message))).build()); + Transaction.Builder transactionBuilder = Transaction.newBuilder().setRawData(rawBuilder) + .addRet(Transaction.Result.newBuilder().setContractRet(SUCCESS).build()) + .addRet(Transaction.Result.newBuilder().setContractRet(SUCCESS).build()); + return transactionBuilder.build(); } @Test @@ -806,17 +870,23 @@ public void doNotSwitch() TaposException, BadNumberBlockException, NonCommonBlockException, ReceiptCheckErrException, VMIllegalException, TooBigTransactionResultException, ZksnarkException, EventBloomException { - Args.setParam(new String[]{"--witness"}, Constant.TEST_CONF); + Args.setParam(new String[]{}, Constant.TEST_CONF); long size = chainManager.getBlockStore().size(); System.out.print("block store size:" + size + "\n"); - String key = "f31db24bfbd1a2ef19beddca0a0fa37632eded9ac666a05d3bd925f01dde1f62"; + String key = PublicMethod.getRandomPrivateKey(); byte[] privateKey = ByteArray.fromHexString(key); final ECKey ecKey = ECKey.fromPrivate(privateKey); byte[] address = ecKey.getAddress(); - + ByteString addressByte = ByteString.copyFrom(address); + AccountCapsule accountCapsule = + new AccountCapsule(Protocol.Account.newBuilder() + .setAddress(addressByte).build()); + chainManager.getAccountStore() + .put(addressByte.toByteArray(), accountCapsule); WitnessCapsule witnessCapsule = new WitnessCapsule(ByteString.copyFrom(address)); chainManager.getWitnessScheduleStore().saveActiveWitnesses(new ArrayList<>()); chainManager.addWitness(ByteString.copyFrom(address)); + chainManager.getWitnessStore().put(address, witnessCapsule); Block block = getSignedBlock(witnessCapsule.getAddress(), 1533529947843L, privateKey); dbManager.pushBlock(new BlockCapsule(block)); @@ -912,17 +982,25 @@ public void switchBack() BadBlockException, TaposException, BadNumberBlockException, NonCommonBlockException, ReceiptCheckErrException, VMIllegalException, TooBigTransactionResultException, ZksnarkException, EventBloomException { - Args.setParam(new String[]{"--witness"}, Constant.TEST_CONF); + Args.setParam(new String[]{}, Constant.TEST_CONF); long size = chainManager.getBlockStore().size(); System.out.print("block store size:" + size + "\n"); - String key = "f31db24bfbd1a2ef19beddca0a0fa37632eded9ac666a05d3bd925f01dde1f62"; + String key = PublicMethod.getRandomPrivateKey();; byte[] privateKey = ByteArray.fromHexString(key); final ECKey ecKey = ECKey.fromPrivate(privateKey); byte[] address = ecKey.getAddress(); + + ByteString addressByte = ByteString.copyFrom(address); + AccountCapsule accountCapsule = + new AccountCapsule(Protocol.Account.newBuilder() + .setAddress(addressByte).build()); + chainManager.getAccountStore() + .put(addressByte.toByteArray(), accountCapsule); + WitnessCapsule witnessCapsule = new WitnessCapsule(ByteString.copyFrom(address)); chainManager.getWitnessScheduleStore().saveActiveWitnesses(new ArrayList<>()); chainManager.addWitness(ByteString.copyFrom(address)); - + chainManager.getWitnessStore().put(address, witnessCapsule); Block block = getSignedBlock(witnessCapsule.getAddress(), 1533529947843L, privateKey); dbManager.pushBlock(new BlockCapsule(block)); @@ -1035,6 +1113,36 @@ private BlockCapsule createTestBlockCapsule(long time, return blockCapsule; } + private BlockCapsule createTestBlockCapsule2(long time, long number, ByteString hash, + Map addressToProvateKeys) { + TransferContract c1 = TransferContract.newBuilder() + .setOwnerAddress(ByteString.copyFrom("f1".getBytes())) + .setAmount(1).build(); + ByteString witnessAddress = dposSlot.getScheduledWitness(dposSlot.getSlot(time)); + Protocol.BlockHeader.raw.Builder blockHeaderRawBuild = Protocol.BlockHeader.raw.newBuilder(); + Protocol.BlockHeader.raw blockHeaderRaw = blockHeaderRawBuild + .setTimestamp(time) + .setParentHash(hash) + .setWitnessAddress(witnessAddress) + .setNumber(number) + .build(); + + // block header + Protocol.BlockHeader.Builder blockHeaderBuild = Protocol.BlockHeader.newBuilder(); + Protocol.BlockHeader blockHeader = blockHeaderBuild.setRawData(blockHeaderRaw).build(); + + // block + Block.Builder blockBuild = Block.newBuilder(); + List transactions = Lists.newArrayList(buildTransaction(c1, + ContractType.TransferContract)); + transactions.forEach(blockBuild::addTransactions); + BlockCapsule blockCapsule = new BlockCapsule(blockBuild.setBlockHeader(blockHeader).build()); + blockCapsule.generatedByMyself = true; + blockCapsule.setMerkleRoot(); + blockCapsule.sign(ByteArray.fromHexString(addressToProvateKeys.get(witnessAddress))); + return blockCapsule; + } + private BlockCapsule createTestBlockCapsuleError(long time, long number, ByteString hash, Map addressToProvateKeys) { @@ -1067,4 +1175,76 @@ public void testExpireTransaction() { Assert.fail(); } } + + @Test + public void testTooBigTransaction() { + TransferContract transferContract = + TransferContract.newBuilder() + .setAmount(10) + .setOwnerAddress(ByteString.copyFromUtf8("aaa")) + .setToAddress(ByteString.copyFromUtf8("bbb")) + .build(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 6666; i++) { + sb.append("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + } + Transaction transaction = Transaction.newBuilder().setRawData(Transaction.raw.newBuilder() + .setData(ByteString.copyFrom(sb.toString().getBytes(StandardCharsets.UTF_8))) + .addContract(Transaction.Contract.newBuilder().setParameter(Any.pack(transferContract)) + .setType(ContractType.TransferContract))).build(); + TransactionCapsule trx = new TransactionCapsule(transaction); + trx.setInBlock(false); + assertThrows( + "Too big transaction with result, " + + "TxId 1c05e9fca6a2d0c366ed4430456527eb40198e70c8b20f5ceca4739c68a79af8, " + + "the size is 533483 bytes, maxTxSize 512000", + TooBigTransactionException.class, () -> dbManager.validateCommon(trx)); + + trx.setInBlock(true); + assertThrows( + "Too big transaction, " + + "TxId 1c05e9fca6a2d0c366ed4430456527eb40198e70c8b20f5ceca4739c68a79af8, " + + "the size is 1066643 bytes, maxTxSize 512000", + TooBigTransactionException.class, () -> dbManager.validateCommon(trx)); + + } + + @Test + public void testExpiration() { + dbManager.getDynamicPropertiesStore().saveConsensusLogicOptimization(1); + TransferContract transferContract = + TransferContract.newBuilder() + .setAmount(10) + .setOwnerAddress(ByteString.copyFromUtf8("aaa")) + .setToAddress(ByteString.copyFromUtf8("bbb")) + .build(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 100; i++) { + sb.append("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + } + Transaction transaction = Transaction.newBuilder().setRawData(Transaction.raw.newBuilder() + .setData(ByteString.copyFrom(sb.toString().getBytes(StandardCharsets.UTF_8))) + .addContract(Transaction.Contract.newBuilder().setParameter(Any.pack(transferContract)) + .setType(ContractType.TransferContract))).build(); + TransactionCapsule trx = new TransactionCapsule(transaction); + trx.setInBlock(true); + + assertThrows(TransactionExpirationException.class, () -> dbManager.validateCommon(trx)); + + } + + @Test + public void blockTrigger() { + Manager manager = spy(new Manager()); + doThrow(new RuntimeException("postBlockTrigger mock")).when(manager).postBlockTrigger(any()); + TronError thrown = Assert.assertThrows(TronError.class, () -> + manager.blockTrigger(new BlockCapsule(Block.newBuilder().build()), 1, 1)); + Assert.assertEquals(TronError.ErrCode.EVENT_SUBSCRIBE_ERROR, thrown.getErrCode()); + } + + public void adjustBalance(AccountStore accountStore, byte[] accountAddress, long amount) + throws BalanceInsufficientException { + Commons.adjustBalance(accountStore, accountAddress, amount, + chainManager.getDynamicPropertiesStore().disableJavaLangMath()); + } } diff --git a/framework/src/test/java/org/tron/core/db/MarketAccountStoreTest.java b/framework/src/test/java/org/tron/core/db/MarketAccountStoreTest.java index 51bf1c5d7fc..ed94a64175d 100644 --- a/framework/src/test/java/org/tron/core/db/MarketAccountStoreTest.java +++ b/framework/src/test/java/org/tron/core/db/MarketAccountStoreTest.java @@ -8,6 +8,7 @@ import org.tron.core.Constant; import org.tron.core.capsule.MarketAccountOrderCapsule; import org.tron.core.config.args.Args; +import org.tron.core.exception.ItemNotFoundException; import org.tron.core.store.MarketAccountStore; public class MarketAccountStoreTest extends BaseTest { @@ -27,6 +28,11 @@ public class MarketAccountStoreTest extends BaseTest { @Test public void testGet() throws Exception { String address = "Address1"; + + MarketAccountOrderCapsule marketAccountOrderCapsule = + marketAccountStore.getUnchecked(address.getBytes()); + Assert.assertNull(marketAccountOrderCapsule); + marketAccountStore.put(address.getBytes(), new MarketAccountOrderCapsule(ByteString.copyFrom(address.getBytes()))); final MarketAccountOrderCapsule result = marketAccountStore.get(address.getBytes()); @@ -34,4 +40,14 @@ public void testGet() throws Exception { Assert.assertEquals(result.getOwnerAddress(), ByteString.copyFrom(address.getBytes())); } + @Test + public void testPut() throws ItemNotFoundException { + String address = "Address1"; + marketAccountStore.put(address.getBytes(), + new MarketAccountOrderCapsule(ByteString.copyFrom(address.getBytes()))); + final MarketAccountOrderCapsule result = marketAccountStore.get(address.getBytes()); + Assert.assertNotNull(result); + Assert.assertEquals(result.getOwnerAddress(), ByteString.copyFrom(address.getBytes())); + } + } diff --git a/framework/src/test/java/org/tron/core/db/MarketOrderStoreTest.java b/framework/src/test/java/org/tron/core/db/MarketOrderStoreTest.java index 33126783e9a..1cfdb20da97 100644 --- a/framework/src/test/java/org/tron/core/db/MarketOrderStoreTest.java +++ b/framework/src/test/java/org/tron/core/db/MarketOrderStoreTest.java @@ -8,6 +8,7 @@ import org.tron.core.Constant; import org.tron.core.capsule.MarketOrderCapsule; import org.tron.core.config.args.Args; +import org.tron.core.exception.ItemNotFoundException; import org.tron.core.store.MarketOrderStore; import org.tron.protos.Protocol; @@ -44,4 +45,20 @@ public void testGet() throws Exception { Assert.assertEquals(result.getBuyTokenQuantity(), 100L); } + @Test + public void testDelete() throws ItemNotFoundException { + byte[] orderId = "testDelete".getBytes(); + marketOrderStore.put(orderId, + new MarketOrderCapsule(Protocol.MarketOrder.newBuilder() + .setOrderId(ByteString.copyFrom(orderId)) + .setSellTokenId(ByteString.copyFrom("addr1".getBytes())) + .setSellTokenQuantity(200L) + .setBuyTokenId(ByteString.copyFrom("addr2".getBytes())) + .setBuyTokenQuantity(100L) + .build())); + marketOrderStore.delete(orderId); + final MarketOrderCapsule result = marketOrderStore.getUnchecked(orderId); + Assert.assertNull(result); + } + } diff --git a/framework/src/test/java/org/tron/core/db/MarketPairPriceToOrderStoreTest.java b/framework/src/test/java/org/tron/core/db/MarketPairPriceToOrderStoreTest.java index 1f453cb9b41..d74229fb216 100755 --- a/framework/src/test/java/org/tron/core/db/MarketPairPriceToOrderStoreTest.java +++ b/framework/src/test/java/org/tron/core/db/MarketPairPriceToOrderStoreTest.java @@ -1,5 +1,8 @@ package org.tron.core.db; +import static org.tron.common.math.Maths.random; +import static org.tron.common.math.Maths.round; + import java.util.List; import lombok.extern.slf4j.Slf4j; import org.junit.After; @@ -43,7 +46,7 @@ public void cleanDb() { } private static int randomInt(int minInt, int maxInt) { - return (int) Math.round(Math.random() * (maxInt - minInt) + minInt); + return (int) round(random(true) * (maxInt - minInt) + minInt, true); } @Test diff --git a/framework/src/test/java/org/tron/core/db/RecentBlockStoreTest.java b/framework/src/test/java/org/tron/core/db/RecentBlockStoreTest.java new file mode 100644 index 00000000000..7856fe337a5 --- /dev/null +++ b/framework/src/test/java/org/tron/core/db/RecentBlockStoreTest.java @@ -0,0 +1,81 @@ +package org.tron.core.db; + +import com.google.protobuf.ByteString; +import javax.annotation.Resource; +import org.junit.Assert; +import org.junit.Test; +import org.tron.common.BaseTest; +import org.tron.common.utils.ByteArray; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.Constant; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.capsule.BytesCapsule; +import org.tron.core.config.args.Args; +import org.tron.core.exception.ItemNotFoundException; + +public class RecentBlockStoreTest extends BaseTest { + + @Resource + private RecentBlockStore recentBlockStore; + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath() + }, + Constant.TEST_CONF + ); + } + + private BlockCapsule getBlockCapsule() { + long number = 1; + return new BlockCapsule(number, + Sha256Hash.ZERO_HASH, + System.currentTimeMillis(), + ByteString.EMPTY); + } + + @Test + public void testPut() { + BlockCapsule blockCapsule = getBlockCapsule(); + byte[] key = ByteArray.subArray( + ByteArray.fromLong(blockCapsule.getNum()), 6, 8); + recentBlockStore.put(key, + new BytesCapsule(ByteArray.subArray(blockCapsule + .getBlockId().getBytes(), + 8, + 16))); + + Assert.assertTrue(recentBlockStore.has(key)); + } + + @Test + public void testGet() throws ItemNotFoundException { + BlockCapsule blockCapsule = getBlockCapsule(); + byte[] key = ByteArray.subArray( + ByteArray.fromLong(blockCapsule.getNum()), 6, 8); + BytesCapsule value = new BytesCapsule(ByteArray + .subArray(blockCapsule.getBlockId().getBytes(), + 8, + 16)); + recentBlockStore.put(key, value); + + BytesCapsule bytesCapsule = recentBlockStore.get(key); + Assert.assertNotNull(bytesCapsule); + Assert.assertArrayEquals(value.getData(), bytesCapsule.getData()); + } + + @Test + public void testDelete() { + BlockCapsule blockCapsule = getBlockCapsule(); + byte[] key = ByteArray.subArray( + ByteArray.fromLong(blockCapsule.getNum()), 6, 8); + recentBlockStore.put(key, + new BytesCapsule(ByteArray.subArray(blockCapsule + .getBlockId().getBytes(), + 8, + 16))); + recentBlockStore.delete(key); + Assert.assertFalse(recentBlockStore.has(key)); + } +} diff --git a/framework/src/test/java/org/tron/core/db/RecentTransactionStoreTest.java b/framework/src/test/java/org/tron/core/db/RecentTransactionStoreTest.java new file mode 100644 index 00000000000..20447dfc6a1 --- /dev/null +++ b/framework/src/test/java/org/tron/core/db/RecentTransactionStoreTest.java @@ -0,0 +1,72 @@ +package org.tron.core.db; + +import com.google.protobuf.ByteString; +import javax.annotation.Resource; + +import org.junit.Assert; +import org.junit.Test; +import org.tron.common.BaseTest; +import org.tron.common.utils.ByteArray; +import org.tron.core.Constant; +import org.tron.core.capsule.BytesCapsule; +import org.tron.core.capsule.TransactionCapsule; +import org.tron.core.config.args.Args; +import org.tron.core.exception.ItemNotFoundException; +import org.tron.protos.Protocol; +import org.tron.protos.contract.BalanceContract; + +public class RecentTransactionStoreTest extends BaseTest { + + @Resource + private RecentTransactionStore recentTransactionStore; + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath() + }, + Constant.TEST_CONF + ); + } + + private TransactionCapsule createTransaction() { + BalanceContract.TransferContract tc = + BalanceContract.TransferContract.newBuilder() + .setAmount(10) + .setOwnerAddress(ByteString.copyFromUtf8("aaa")) + .setToAddress(ByteString.copyFromUtf8("bbb")) + .build(); + return new TransactionCapsule(tc, + Protocol.Transaction.Contract.ContractType.TransferContract); + } + + + @Test + public void testPut() { + TransactionCapsule transaction = createTransaction(); + byte[] key = transaction.getTransactionId().getBytes(); + BytesCapsule value = new BytesCapsule(ByteArray.subArray(transaction + .getTransactionId().getBytes(), + 8, + 16)); + recentTransactionStore.put(key, value); + Assert.assertTrue(recentTransactionStore.has(key)); + } + + @Test + public void testGet() throws ItemNotFoundException { + TransactionCapsule transaction = createTransaction(); + byte[] key = transaction.getTransactionId().getBytes(); + BytesCapsule value = new BytesCapsule( + ByteArray.subArray(transaction + .getTransactionId().getBytes(), + 8, + 16)); + recentTransactionStore.put(key, value); + + BytesCapsule bytesCapsule = recentTransactionStore.get(key); + Assert.assertNotNull(bytesCapsule); + Assert.assertArrayEquals(value.getData(), bytesCapsule.getData()); + + } +} diff --git a/framework/src/test/java/org/tron/core/db/TransactionExpireTest.java b/framework/src/test/java/org/tron/core/db/TransactionExpireTest.java index 5243405b7e6..420b54525e4 100644 --- a/framework/src/test/java/org/tron/core/db/TransactionExpireTest.java +++ b/framework/src/test/java/org/tron/core/db/TransactionExpireTest.java @@ -46,23 +46,11 @@ public void init() throws IOException { Args.setParam(new String[] {"--output-directory", temporaryFolder.newFolder().toString()}, Constant.TEST_CONF); CommonParameter.PARAMETER.setMinEffectiveConnection(0); + CommonParameter.getInstance().setP2pDisable(true); context = new TronApplicationContext(DefaultConfig.class); wallet = context.getBean(Wallet.class); dbManager = context.getBean(Manager.class); - - blockCapsule = new BlockCapsule( - 1, - Sha256Hash.wrap(ByteString.copyFrom( - ByteArray.fromHexString( - "0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b81"))), - 1, - ByteString.copyFromUtf8("testAddress")); - dbManager.getDynamicPropertiesStore().saveLatestBlockHeaderNumber(blockCapsule.getNum()); - dbManager.getDynamicPropertiesStore() - .saveLatestBlockHeaderTimestamp(blockCapsule.getTimeStamp()); - dbManager.updateRecentBlock(blockCapsule); - initLocalWitness(); } private void initLocalWitness() { @@ -81,6 +69,19 @@ public void removeDb() { @Test public void testExpireTransaction() { + blockCapsule = new BlockCapsule( + 1, + Sha256Hash.wrap(ByteString.copyFrom( + ByteArray.fromHexString( + "0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b81"))), + 1, + ByteString.copyFromUtf8("testAddress")); + dbManager.getDynamicPropertiesStore().saveLatestBlockHeaderNumber(blockCapsule.getNum()); + dbManager.getDynamicPropertiesStore() + .saveLatestBlockHeaderTimestamp(blockCapsule.getTimeStamp()); + dbManager.updateRecentBlock(blockCapsule); + initLocalWitness(); + TransferContract transferContract = TransferContract.newBuilder() .setAmount(1L) .setOwnerAddress(ByteString.copyFrom(Args.getLocalWitnesses() @@ -101,8 +102,61 @@ public void testExpireTransaction() { Assert.assertEquals(response_code.TRANSACTION_EXPIRATION_ERROR, result.getCode()); } + @Test + public void testExpireTransactionNew() { + blockCapsule = new BlockCapsule( + 1, + Sha256Hash.wrap(ByteString.copyFrom( + ByteArray.fromHexString( + "0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b81"))), + System.currentTimeMillis(), + ByteString.copyFromUtf8("testAddress")); + dbManager.getDynamicPropertiesStore().saveLatestBlockHeaderNumber(blockCapsule.getNum()); + dbManager.getDynamicPropertiesStore() + .saveLatestBlockHeaderTimestamp(blockCapsule.getTimeStamp()); + dbManager.updateRecentBlock(blockCapsule); + initLocalWitness(); + byte[] address = Args.getLocalWitnesses() + .getWitnessAccountAddress(CommonParameter.getInstance().isECKeyCryptoEngine()); + ByteString addressByte = ByteString.copyFrom(address); + AccountCapsule accountCapsule = + new AccountCapsule(Protocol.Account.newBuilder().setAddress(addressByte).build()); + accountCapsule.setBalance(1000_000_000L); + dbManager.getChainBaseManager().getAccountStore() + .put(accountCapsule.createDbKey(), accountCapsule); + + TransferContract transferContract = TransferContract.newBuilder() + .setAmount(1L) + .setOwnerAddress(addressByte) + .setToAddress(ByteString.copyFrom(ByteArray.fromHexString( + (Wallet.getAddressPreFixString() + "A389132D6639FBDA4FBC8B659264E6B7C90DB086")))) + .build(); + TransactionCapsule transactionCapsule = + new TransactionCapsule(transferContract, ContractType.TransferContract); + transactionCapsule.setReference(blockCapsule.getNum(), blockCapsule.getBlockId().getBytes()); + + transactionCapsule.setExpiration(System.currentTimeMillis()); + transactionCapsule.sign(ByteArray.fromHexString(Args.getLocalWitnesses().getPrivateKey())); + + GrpcAPI.Return result = wallet.broadcastTransaction(transactionCapsule.getInstance()); + Assert.assertEquals(response_code.TRANSACTION_EXPIRATION_ERROR, result.getCode()); + } + @Test public void testTransactionApprovedList() { + blockCapsule = new BlockCapsule( + 1, + Sha256Hash.wrap(ByteString.copyFrom( + ByteArray.fromHexString( + "0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b81"))), + 1, + ByteString.copyFromUtf8("testAddress")); + dbManager.getDynamicPropertiesStore().saveLatestBlockHeaderNumber(blockCapsule.getNum()); + dbManager.getDynamicPropertiesStore() + .saveLatestBlockHeaderTimestamp(blockCapsule.getTimeStamp()); + dbManager.updateRecentBlock(blockCapsule); + initLocalWitness(); + byte[] address = Args.getLocalWitnesses() .getWitnessAccountAddress(CommonParameter.getInstance().isECKeyCryptoEngine()); TransferContract transferContract = TransferContract.newBuilder() diff --git a/framework/src/test/java/org/tron/core/db/TransactionHistoryTest.java b/framework/src/test/java/org/tron/core/db/TransactionHistoryTest.java index eef168938b2..c5c249b6f70 100644 --- a/framework/src/test/java/org/tron/core/db/TransactionHistoryTest.java +++ b/framework/src/test/java/org/tron/core/db/TransactionHistoryTest.java @@ -59,4 +59,11 @@ public void get() throws BadItemException { Assert.assertEquals(ByteArray.toHexString(transactionId), ByteArray.toHexString(resultCapsule.getId())); } + + @Test + public void testDelete() throws BadItemException { + transactionHistoryStore.delete(transactionId); + TransactionInfoCapsule transactionInfoCapsule = transactionHistoryStore.get(transactionId); + Assert.assertNull(transactionInfoCapsule); + } } \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/db/TransactionStoreTest.java b/framework/src/test/java/org/tron/core/db/TransactionStoreTest.java index 1edc4aca756..21d34fb7a69 100644 --- a/framework/src/test/java/org/tron/core/db/TransactionStoreTest.java +++ b/framework/src/test/java/org/tron/core/db/TransactionStoreTest.java @@ -50,7 +50,7 @@ public class TransactionStoreTest extends BaseTest { */ @BeforeClass public static void init() { - Args.setParam(new String[]{"--output-directory", dbPath(), "-w"}, Constant.TEST_CONF); + Args.setParam(new String[]{"--output-directory", dbPath()}, Constant.TEST_CONF); } /** @@ -112,7 +112,7 @@ private VoteWitnessContract getVoteWitnessContract(String address, String votead public void getTransactionTest() throws BadItemException, ItemNotFoundException { final BlockStore blockStore = chainBaseManager.getBlockStore(); final TransactionStore trxStore = chainBaseManager.getTransactionStore(); - String key = "f31db24bfbd1a2ef19beddca0a0fa37632eded9ac666a05d3bd925f01dde1f62"; + String key = PublicMethod.getRandomPrivateKey();; BlockCapsule blockCapsule = new BlockCapsule( diff --git a/framework/src/test/java/org/tron/core/db/TransactionTraceTest.java b/framework/src/test/java/org/tron/core/db/TransactionTraceTest.java index 161fbea9569..08848fc9da1 100644 --- a/framework/src/test/java/org/tron/core/db/TransactionTraceTest.java +++ b/framework/src/test/java/org/tron/core/db/TransactionTraceTest.java @@ -65,7 +65,6 @@ public class TransactionTraceTest extends BaseTest { "--output-directory", dbPath(), "--storage-db-directory", dbDirectory, "--storage-index-directory", indexDirectory, - "-w", "--debug" }, "config-test-mainnet.conf" diff --git a/framework/src/test/java/org/tron/core/db/TxCacheDBTest.java b/framework/src/test/java/org/tron/core/db/TxCacheDBTest.java index 55557cf51b5..4d223e726ca 100644 --- a/framework/src/test/java/org/tron/core/db/TxCacheDBTest.java +++ b/framework/src/test/java/org/tron/core/db/TxCacheDBTest.java @@ -20,7 +20,7 @@ public static void init() { String dbDirectory = "db_TransactionCache_test"; String indexDirectory = "index_TransactionCache_test"; Args.setParam(new String[]{"--output-directory", dbPath(), "--storage-db-directory", - dbDirectory, "--storage-index-directory", indexDirectory, "-w"}, Constant.TEST_CONF); + dbDirectory, "--storage-index-directory", indexDirectory}, Constant.TEST_CONF); } @Test diff --git a/framework/src/test/java/org/tron/core/db/WitnessStoreTest.java b/framework/src/test/java/org/tron/core/db/WitnessStoreTest.java index 3190e226689..d141a5fd790 100755 --- a/framework/src/test/java/org/tron/core/db/WitnessStoreTest.java +++ b/framework/src/test/java/org/tron/core/db/WitnessStoreTest.java @@ -1,6 +1,9 @@ package org.tron.core.db; import com.google.protobuf.ByteString; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; @@ -46,5 +49,27 @@ public void putAndGetWitness() { Assert.assertEquals(100L, witnessSource.getVoteCount()); } - + @Test + public void testSortWitness() { + this.witnessStore.reset(); + WitnessCapsule s1 = new WitnessCapsule( + ByteString.copyFrom(new byte[]{1, 2, 3}), 100L, "URL-1"); + this.witnessStore.put(s1.getAddress().toByteArray(), s1); + WitnessCapsule s2 = new WitnessCapsule( + ByteString.copyFrom(new byte[]{1, 1, 34}), 100L, "URL-2"); + this.witnessStore.put(s2.getAddress().toByteArray(), s2); + List allWitnesses = this.witnessStore.getAllWitnesses(); + List witnessAddress = allWitnesses.stream().map(WitnessCapsule::getAddress) + .collect(Collectors.toList()); + this.witnessStore.sortWitness(witnessAddress, false); + this.witnessStore.sortWitnesses(allWitnesses, false); + Assert.assertEquals(witnessAddress, allWitnesses.stream().map(WitnessCapsule::getAddress) + .collect(Collectors.toList())); + List pre = new ArrayList<>(witnessAddress); + this.witnessStore.sortWitness(witnessAddress, true); + this.witnessStore.sortWitnesses(allWitnesses, true); + Assert.assertEquals(witnessAddress, allWitnesses.stream().map(WitnessCapsule::getAddress) + .collect(Collectors.toList())); + Assert.assertNotEquals(pre, witnessAddress); + } } \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/db/ZKProofStoreTest.java b/framework/src/test/java/org/tron/core/db/ZKProofStoreTest.java new file mode 100644 index 00000000000..a8aa07c4342 --- /dev/null +++ b/framework/src/test/java/org/tron/core/db/ZKProofStoreTest.java @@ -0,0 +1,58 @@ +package org.tron.core.db; + +import com.google.protobuf.ByteString; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.tron.common.BaseTest; +import org.tron.core.Constant; +import org.tron.core.capsule.TransactionCapsule; +import org.tron.core.config.args.Args; +import org.tron.core.store.ZKProofStore; +import org.tron.protos.Protocol; +import org.tron.protos.contract.BalanceContract; + +public class ZKProofStoreTest extends BaseTest { + + static { + Args.setParam(new String[]{"--output-directory", dbPath()}, + Constant.TEST_CONF); + } + + @Autowired + private ZKProofStore proofStore; + + private TransactionCapsule getTransactionCapsule() { + BalanceContract.TransferContract transferContract = + BalanceContract.TransferContract.newBuilder() + .setAmount(10) + .setOwnerAddress(ByteString.copyFromUtf8("aaa")) + .setToAddress(ByteString.copyFromUtf8("bbb")) + .build(); + return new TransactionCapsule(transferContract, + Protocol.Transaction.Contract.ContractType.TransferContract); + } + + @Test + public void testPut() { + TransactionCapsule trx = getTransactionCapsule(); + proofStore.put(trx.getTransactionId().getBytes(), + true); + boolean has = proofStore.has(trx.getTransactionId().getBytes()); + Assert.assertTrue(has); + } + + @Test + public void testGet() { + TransactionCapsule trx = getTransactionCapsule(); + proofStore.put(trx.getTransactionId().getBytes(), + true); + Boolean result = proofStore.get(trx.getTransactionId().getBytes()); + Assert.assertEquals(true, result); + + proofStore.put(trx.getTransactionId().getBytes(), + false); + result = proofStore.get(trx.getTransactionId().getBytes()); + Assert.assertEquals(false, result); + } +} diff --git a/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java b/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java index ed18b1be97d..d1edd92c109 100644 --- a/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java +++ b/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java @@ -27,7 +27,7 @@ public class AssetUpdateHelperTest extends BaseTest { private static boolean init; static { - Args.setParam(new String[]{"-d", dbPath(), "-w"}, "config-test-index.conf"); + Args.setParam(new String[]{"-d", dbPath()}, "config-test-index.conf"); Args.getInstance().setSolidityNode(true); } diff --git a/framework/src/test/java/org/tron/core/db/api/pojo/PojoTest.java b/framework/src/test/java/org/tron/core/db/api/pojo/PojoTest.java new file mode 100644 index 00000000000..f4661725a02 --- /dev/null +++ b/framework/src/test/java/org/tron/core/db/api/pojo/PojoTest.java @@ -0,0 +1,80 @@ +package org.tron.core.db.api.pojo; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import com.google.common.collect.Lists; +import org.junit.Test; + +public class PojoTest { + + @Test + public void testAccountCreation() { + Account account = Account.of(); + account.setName("testName"); + account.setAddress("testAddress"); + account.setBalance(1622548800000L); + + assertNotNull(account); + assertEquals("testName", account.getName()); + assertEquals("testAddress", account.getAddress()); + assertEquals(1622548800000L, account.getBalance()); + } + + @Test + public void testAssetIssueCreation() { + AssetIssue assetIssue = AssetIssue.of(); + assetIssue.setName("testName"); + assetIssue.setAddress("testAddress"); + assetIssue.setStart(1622548800000L); + assetIssue.setEnd(1654084800000L); + + assertNotNull(assetIssue); + assertEquals("testName", assetIssue.getName()); + assertEquals("testAddress", assetIssue.getAddress()); + assertEquals(1622548800000L, assetIssue.getStart()); + assertEquals(1654084800000L, assetIssue.getEnd()); + } + + @Test + public void testBlockCreation() { + Block block = Block.of(); + block.setId("7654321"); + block.setNumber(1000L); + block.setTransactionIds(Lists.newArrayList("1234567")); + + assertNotNull(block); + assertEquals("7654321", block.getId()); + assertEquals(1000L, block.getNumber()); + assertEquals("1234567", block.getTransactionIds().get(0)); + } + + @Test + public void testTransactionCreation() { + Transaction transaction = Transaction.of(); + transaction.setId("7654321"); + transaction.setFrom("from"); + transaction.setTo("to"); + + assertNotNull(transaction); + assertEquals("7654321", transaction.getId()); + assertEquals("from", transaction.getFrom()); + assertEquals("to", transaction.getTo()); + } + + @Test + public void testWitnessCreation() { + Witness witness = Witness.of(); + witness.setAddress("testAddress"); + witness.setJobs(true); + witness.setUrl("https://cryptoai.com/"); + witness.setPublicKey("wergfsioejgbrotjsdfdoqwj"); + + assertNotNull(witness); + assertEquals("testAddress", witness.getAddress()); + assertTrue(witness.isJobs()); + assertEquals("https://cryptoai.com/", witness.getUrl()); + assertEquals("wergfsioejgbrotjsdfdoqwj", witness.getPublicKey()); + } +} diff --git a/framework/src/test/java/org/tron/core/db2/SnapshotManagerTest.java b/framework/src/test/java/org/tron/core/db2/SnapshotManagerTest.java index 966e947d828..134dc99e51c 100644 --- a/framework/src/test/java/org/tron/core/db2/SnapshotManagerTest.java +++ b/framework/src/test/java/org/tron/core/db2/SnapshotManagerTest.java @@ -1,11 +1,13 @@ package org.tron.core.db2; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + import com.google.common.collect.Maps; -import com.google.common.primitives.Bytes; import com.google.common.primitives.Longs; import com.google.protobuf.ByteString; import java.io.File; -import java.util.Iterator; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -29,6 +31,7 @@ import org.tron.core.db2.core.SnapshotManager; import org.tron.core.exception.BadItemException; import org.tron.core.exception.ItemNotFoundException; +import org.tron.core.exception.TronError; @Slf4j public class SnapshotManagerTest { @@ -38,6 +41,7 @@ public class SnapshotManagerTest { private Application appT; private TestRevokingTronStore tronDatabase; + @Before public void init() { Args.setParam(new String[]{"-d", "output_SnapshotManager_test"}, @@ -111,4 +115,22 @@ public synchronized void testClose() { tronDatabase.get(protoCapsule.getData())); } + + @Test + public void testCheckError() { + SnapshotManager manager = spy(new SnapshotManager("")); + when(manager.getCheckpointList()).thenReturn(Arrays.asList("check1", "check2")); + TronError thrown = Assert.assertThrows(TronError.class, manager::check); + Assert.assertEquals(TronError.ErrCode.CHECKPOINT_VERSION, thrown.getErrCode()); + } + + @Test + public void testFlushError() { + SnapshotManager manager = spy(new SnapshotManager("")); + manager.setUnChecked(false); + when(manager.getCheckpointList()).thenReturn(Arrays.asList("check1", "check2")); + when(manager.shouldBeRefreshed()).thenReturn(true); + TronError thrown = Assert.assertThrows(TronError.class, manager::flush); + Assert.assertEquals(TronError.ErrCode.DB_FLUSH, thrown.getErrCode()); + } } diff --git a/framework/src/test/java/org/tron/core/event/BlockEventCacheTest.java b/framework/src/test/java/org/tron/core/event/BlockEventCacheTest.java new file mode 100644 index 00000000000..e99433db3c6 --- /dev/null +++ b/framework/src/test/java/org/tron/core/event/BlockEventCacheTest.java @@ -0,0 +1,91 @@ +package org.tron.core.event; + +import java.util.List; +import java.util.Random; +import org.junit.Assert; +import org.junit.Test; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.services.event.BlockEventCache; +import org.tron.core.services.event.bo.BlockEvent; +import org.tron.core.services.event.exception.EventException; + +public class BlockEventCacheTest { + + @Test + public void test() throws Exception { + BlockEvent be1 = new BlockEvent(); + BlockCapsule.BlockId b1 = new BlockCapsule.BlockId(getBlockId(), 1); + be1.setBlockId(b1); + be1.setParentId(b1); + be1.setSolidId(b1); + try { + BlockEventCache.add(be1); + Assert.fail(); + } catch (Exception e) { + Assert.assertTrue(e instanceof EventException); + } + + BlockEventCache.init(new BlockCapsule.BlockId(getBlockId(), 100)); + + try { + BlockEventCache.add(be1); + Assert.fail(); + } catch (Exception e) { + Assert.assertTrue(e instanceof EventException); + } + + BlockEventCache.init(b1); + + BlockEvent be2 = new BlockEvent(); + BlockCapsule.BlockId b2 = new BlockCapsule.BlockId(getBlockId(), 2); + be2.setBlockId(b2); + be2.setParentId(b1); + be2.setSolidId(b1); + BlockEventCache.add(be2); + Assert.assertEquals(be2, BlockEventCache.getHead()); + Assert.assertEquals(be2, BlockEventCache.getBlockEvent(b2)); + + BlockEvent be22 = new BlockEvent(); + BlockCapsule.BlockId b22 = new BlockCapsule.BlockId(getBlockId(), 2); + be22.setBlockId(b22); + be22.setParentId(b1); + be22.setSolidId(b22); + BlockEventCache.add(be22); + Assert.assertEquals(be2, BlockEventCache.getHead()); + Assert.assertEquals(be22, BlockEventCache.getBlockEvent(b22)); + Assert.assertEquals(b22, BlockEventCache.getSolidId()); + + BlockEvent be3 = new BlockEvent(); + BlockCapsule.BlockId b3 = new BlockCapsule.BlockId(getBlockId(), 3); + be3.setBlockId(b3); + be3.setParentId(b22); + be3.setSolidId(b22); + BlockEventCache.add(be3); + Assert.assertEquals(be3, BlockEventCache.getHead()); + + List list = BlockEventCache.getSolidBlockEvents(b2); + Assert.assertEquals(1, list.size()); + list = BlockEventCache.getSolidBlockEvents(b22); + Assert.assertEquals(1, list.size()); + + list = BlockEventCache.getSolidBlockEvents(b3); + Assert.assertEquals(2, list.size()); + + BlockEventCache.remove(b22); + Assert.assertEquals(2, BlockEventCache.getSolidNum()); + + list = BlockEventCache.getSolidBlockEvents(b2); + Assert.assertEquals(0, list.size()); + list = BlockEventCache.getSolidBlockEvents(b22); + Assert.assertEquals(0, list.size()); + + list = BlockEventCache.getSolidBlockEvents(b3); + Assert.assertEquals(1, list.size()); + } + + public static byte[] getBlockId() { + byte[] id = new byte[32]; + new Random().nextBytes(id); + return id; + } +} diff --git a/framework/src/test/java/org/tron/core/event/BlockEventGetTest.java b/framework/src/test/java/org/tron/core/event/BlockEventGetTest.java new file mode 100644 index 00000000000..b6835cfcf82 --- /dev/null +++ b/framework/src/test/java/org/tron/core/event/BlockEventGetTest.java @@ -0,0 +1,291 @@ +package org.tron.core.event; + +import static org.mockito.Mockito.mock; + +import com.google.protobuf.ByteString; +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import lombok.extern.slf4j.Slf4j; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.mockito.Mockito; +import org.tron.common.application.TronApplicationContext; +import org.tron.common.logsfilter.EventPluginConfig; +import org.tron.common.logsfilter.EventPluginLoader; +import org.tron.common.logsfilter.TriggerConfig; +import org.tron.common.logsfilter.capsule.TransactionLogTriggerCapsule; +import org.tron.common.runtime.TvmTestUtils; +import org.tron.common.utils.ByteArray; +import org.tron.common.utils.PublicMethod; +import org.tron.common.utils.ReflectUtils; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.ChainBaseManager; +import org.tron.core.Constant; +import org.tron.core.capsule.AccountCapsule; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.capsule.TransactionRetCapsule; +import org.tron.core.capsule.WitnessCapsule; +import org.tron.core.config.DefaultConfig; +import org.tron.core.config.args.Args; +import org.tron.core.consensus.ConsensusService; +import org.tron.core.db.BlockGenerate; +import org.tron.core.db.Manager; +import org.tron.core.net.TronNetDelegate; +import org.tron.core.services.event.BlockEventGet; +import org.tron.core.services.event.bo.BlockEvent; +import org.tron.core.store.DynamicPropertiesStore; +import org.tron.core.store.TransactionRetStore; +import org.tron.protos.Protocol; + +@Slf4j +public class BlockEventGetTest extends BlockGenerate { + + @ClassRule + public static final TemporaryFolder temporaryFolder = new TemporaryFolder(); + + static ChainBaseManager chainManager; + + private final String key = PublicMethod.getRandomPrivateKey(); + private final byte[] privateKey = ByteArray.fromHexString(key); + private final byte[] address = PublicMethod.getAddressByteByPrivateKey(key); + + private final AtomicInteger port = new AtomicInteger(0); + protected String dbPath; + protected Manager dbManager; + long currentHeader = -1; + private TronNetDelegate tronNetDelegate; + private TronApplicationContext context; + + + static LocalDateTime localDateTime = LocalDateTime.now(); + private long time = ZonedDateTime.of(localDateTime, + ZoneId.systemDefault()).toInstant().toEpochMilli(); + + protected void initDbPath() throws IOException { + dbPath = temporaryFolder.newFolder().toString(); + } + + @Before + public void before() throws IOException { + initDbPath(); + logger.info("Full node running."); + Args.setParam(new String[] {"-d", dbPath}, Constant.TEST_CONF); + Args.getInstance().setNodeListenPort(10000 + port.incrementAndGet()); + + context = new TronApplicationContext(DefaultConfig.class); + + dbManager = context.getBean(Manager.class); + setManager(dbManager); + + context.getBean(ConsensusService.class).start(); + chainManager = dbManager.getChainBaseManager(); + tronNetDelegate = context.getBean(TronNetDelegate.class); + tronNetDelegate.setExit(false); + currentHeader = dbManager.getDynamicPropertiesStore() + .getLatestBlockHeaderNumberFromDB(); + + ByteString addressBS = ByteString.copyFrom(address); + WitnessCapsule witnessCapsule = new WitnessCapsule(addressBS); + chainManager.getWitnessStore().put(address, witnessCapsule); + chainManager.addWitness(addressBS); + + AccountCapsule accountCapsule = new AccountCapsule(Protocol.Account.newBuilder() + .setAddress(addressBS).setBalance((long) 1e10).build()); + chainManager.getAccountStore().put(address, accountCapsule); + + DynamicPropertiesStore dps = dbManager.getDynamicPropertiesStore(); + dps.saveAllowTvmTransferTrc10(1); + dps.saveAllowTvmConstantinople(1); + dps.saveAllowTvmShangHai(1); + } + + @After + public void after() throws IOException { + } + + @Test + public void test() throws Exception { + BlockEventGet blockEventGet = context.getBean(BlockEventGet.class); + Manager manager = context.getBean(Manager.class); + + WitnessCapsule witnessCapsule = new WitnessCapsule(ByteString.copyFrom(address)); + ChainBaseManager.getChainBaseManager() + .getWitnessScheduleStore().saveActiveWitnesses(new ArrayList<>()); + ChainBaseManager.getChainBaseManager().addWitness(ByteString.copyFrom(address)); + + String code = "608060405234801561000f575f80fd5b50d3801561001b575f80fd5b50d28015610027575f" + + "80fd5b503373ffffffffffffffffffffffffffffffffffffffff165f73ffffffffffffffffffffffff" + + "ffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3" + + "ef6402540be40060405161008a91906100e2565b60405180910390a36100fb565b5f81905091905056" + + "5b5f819050919050565b5f819050919050565b5f6100cc6100c76100c284610097565b6100a9565b61" + + "00a0565b9050919050565b6100dc816100b2565b82525050565b5f6020820190506100f55f83018461" + + "00d3565b92915050565b603e806101075f395ff3fe60806040525f80fdfea26474726f6e582212200c" + + "57c973388f044038eff0e6474425b38037e75e66d6b3047647290605449c7764736f6c63430008140033"; + Protocol.Transaction trx = TvmTestUtils.generateDeploySmartContractAndGetTransaction( + "TestTRC20", address, "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\"" + + ":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"}" + + ",{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\"," + + "\"type\":\"event\"}]", code, 0, (long) 1e9, 100, null, 1); + trx = trx.toBuilder().addRet( + Protocol.Transaction.Result.newBuilder() + .setContractRetValue(Protocol.Transaction.Result.contractResult.SUCCESS_VALUE) + .build()).build(); + + Protocol.Block block = getSignedBlock(witnessCapsule.getAddress(), time, privateKey); + BlockCapsule blockCapsule = new BlockCapsule(block.toBuilder().addTransactions(trx).build()); + blockCapsule.generatedByMyself = true; + blockCapsule.getTransactions().forEach(txCap -> { + txCap.setVerified(true); + chainManager.setBlockReference(txCap); + txCap.setExpiration(3000); + }); + manager.pushBlock(blockCapsule); + + // Set energy price history to test boundary cases + manager.getDynamicPropertiesStore().saveEnergyPriceHistory( + manager.getDynamicPropertiesStore().getEnergyPriceHistory() + + "," + time + ":210"); + + EventPluginConfig config = new EventPluginConfig(); + config.setSendQueueLength(1000); + config.setBindPort(5555); + config.setUseNativeQueue(true); + config.setTriggerConfigList(new ArrayList<>()); + + TriggerConfig blockTriggerConfig = new TriggerConfig(); + blockTriggerConfig.setTriggerName("block"); + blockTriggerConfig.setEnabled(true); + config.getTriggerConfigList().add(blockTriggerConfig); + + TriggerConfig txTriggerConfig = new TriggerConfig(); + txTriggerConfig.setTriggerName("transaction"); + txTriggerConfig.setEnabled(true); + txTriggerConfig.setEthCompatible(true); + config.getTriggerConfigList().add(txTriggerConfig); + + TriggerConfig solidityTriggerConfig = new TriggerConfig(); + solidityTriggerConfig.setTriggerName("solidity"); + solidityTriggerConfig.setEnabled(true); + config.getTriggerConfigList().add(solidityTriggerConfig); + + TriggerConfig contracteventTriggerConfig = new TriggerConfig(); + contracteventTriggerConfig.setTriggerName("contractevent"); + contracteventTriggerConfig.setEnabled(true); + config.getTriggerConfigList().add(contracteventTriggerConfig); + + TriggerConfig contractlogTriggerConfig = new TriggerConfig(); + contractlogTriggerConfig.setTriggerName("contractlog"); + contractlogTriggerConfig.setEnabled(true); + contractlogTriggerConfig.setRedundancy(true); + config.getTriggerConfigList().add(contractlogTriggerConfig); + + EventPluginLoader.getInstance().start(config); + try { + BlockEvent blockEvent = blockEventGet.getBlockEvent(1); + Assert.assertNotNull(blockEvent); + Assert.assertEquals(1, blockEvent.getTransactionLogTriggerCapsules().size()); + + // Here energy unit price should be 100 not 210, + // cause block time is equal to 210`s effective time + Assert.assertEquals(100, blockEvent.getTransactionLogTriggerCapsules() + .get(0).getTransactionLogTrigger().getEnergyUnitPrice()); + } catch (Exception e) { + Assert.fail(); + } + } + + @Test + public void getTransactionTriggers() throws Exception { + BlockEventGet blockEventGet = new BlockEventGet(); + BlockCapsule bc = new BlockCapsule(1, Sha256Hash.ZERO_HASH, + 100, Sha256Hash.ZERO_HASH.getByteString()); + + List list = blockEventGet.getTransactionTriggers(bc, 1); + Assert.assertEquals(0, list.size()); + + List transactionList = new ArrayList<>(); + + Protocol.Transaction.raw rw = Protocol.Transaction.raw.newBuilder() + .addContract(Protocol.Transaction.Contract.newBuilder().build()).build(); + + Protocol.Transaction transaction = Protocol.Transaction.newBuilder().setRawData(rw).build(); + + transactionList.add(transaction); + + bc = new BlockCapsule(100, ByteString.empty(), 1, transactionList); + + list = blockEventGet.getTransactionTriggers(bc, 1); + Assert.assertEquals(1, list.size()); + Assert.assertEquals(100, list.get(0).getTransactionLogTrigger().getTimeStamp()); + + Protocol.TransactionInfo.Builder infoBuild = Protocol.TransactionInfo.newBuilder(); + + Protocol.ResourceReceipt.Builder resourceBuild = Protocol.ResourceReceipt.newBuilder(); + resourceBuild.setEnergyFee(1); + resourceBuild.setEnergyUsageTotal(2); + resourceBuild.setEnergyUsage(3); + resourceBuild.setOriginEnergyUsage(4); + resourceBuild.setNetFee(5); + resourceBuild.setNetUsage(6); + + String address = "A0B4750E2CD76E19DCA331BF5D089B71C3C2798548"; + infoBuild + .setContractAddress(ByteString.copyFrom(ByteArray.fromHexString(address))) + .addContractResult(ByteString.copyFrom(ByteArray.fromHexString("112233"))) + .setReceipt(resourceBuild.build()); + + Manager manager = mock(Manager.class); + ReflectUtils.setFieldValue(blockEventGet, "manager", manager); + + ChainBaseManager chainBaseManager = mock(ChainBaseManager.class); + Mockito.when(manager.getChainBaseManager()).thenReturn(chainBaseManager); + + TransactionRetStore transactionRetStore = mock(TransactionRetStore.class); + Mockito.when(chainBaseManager.getTransactionRetStore()).thenReturn(transactionRetStore); + + Protocol.TransactionRet transactionRet = Protocol.TransactionRet.newBuilder() + .addTransactioninfo(infoBuild.build()).build(); + + TransactionRetCapsule result = new TransactionRetCapsule(transactionRet.toByteArray()); + + Mockito.when(transactionRetStore.getTransactionInfoByBlockNum(ByteArray.fromLong(0))) + .thenReturn(result); + + Protocol.Block block = Protocol.Block.newBuilder() + .addTransactions(transaction).build(); + + BlockCapsule blockCapsule = new BlockCapsule(block); + blockCapsule.getTransactions().forEach(t -> t.setBlockNum(blockCapsule.getNum())); + + list = blockEventGet.getTransactionTriggers(blockCapsule, 1); + + Assert.assertEquals(1, list.size()); + Assert.assertEquals(1, + list.get(0).getTransactionLogTrigger().getLatestSolidifiedBlockNumber()); + Assert.assertEquals(0, + list.get(0).getTransactionLogTrigger().getBlockNumber()); + Assert.assertEquals(2, + list.get(0).getTransactionLogTrigger().getEnergyUsageTotal()); + + Mockito.when(transactionRetStore.getTransactionInfoByBlockNum(ByteArray.fromLong(0))) + .thenReturn(null); + list = blockEventGet.getTransactionTriggers(blockCapsule, 1); + Assert.assertEquals(1, list.size()); + Assert.assertEquals(1, + list.get(0).getTransactionLogTrigger().getLatestSolidifiedBlockNumber()); + Assert.assertEquals(0, + list.get(0).getTransactionLogTrigger().getBlockNumber()); + Assert.assertEquals(0, + list.get(0).getTransactionLogTrigger().getEnergyUsageTotal()); + } + +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/event/BlockEventLoadTest.java b/framework/src/test/java/org/tron/core/event/BlockEventLoadTest.java new file mode 100644 index 00000000000..991133fee78 --- /dev/null +++ b/framework/src/test/java/org/tron/core/event/BlockEventLoadTest.java @@ -0,0 +1,124 @@ +package org.tron.core.event; + +import static org.mockito.Mockito.mock; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.concurrent.BlockingQueue; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.tron.common.utils.ReflectUtils; +import org.tron.core.ChainBaseManager; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.db.Manager; +import org.tron.core.services.event.BlockEventCache; +import org.tron.core.services.event.BlockEventGet; +import org.tron.core.services.event.BlockEventLoad; +import org.tron.core.services.event.RealtimeEventService; +import org.tron.core.services.event.bo.BlockEvent; +import org.tron.core.services.event.bo.Event; +import org.tron.core.store.DynamicPropertiesStore; + +public class BlockEventLoadTest { + BlockEventLoad blockEventLoad = new BlockEventLoad(); + + @Test + public void test() throws Exception { + Method method = blockEventLoad.getClass().getDeclaredMethod("load"); + method.setAccessible(true); + + RealtimeEventService realtimeEventService = new RealtimeEventService(); + Field field = realtimeEventService.getClass().getDeclaredField("queue"); + field.setAccessible(true); + BlockingQueue queue = (BlockingQueue)field.get(BlockingQueue.class); + + BlockEventGet blockEventGet = mock(BlockEventGet.class); + Manager manager = mock(Manager.class); + ReflectUtils.setFieldValue(blockEventLoad, "realtimeEventService", realtimeEventService); + ReflectUtils.setFieldValue(blockEventLoad, "blockEventGet", blockEventGet); + ReflectUtils.setFieldValue(blockEventLoad, "manager", manager); + + DynamicPropertiesStore dynamicPropertiesStore = mock(DynamicPropertiesStore.class); + ChainBaseManager chainBaseManager = mock(ChainBaseManager.class); + Mockito.when(manager.getDynamicPropertiesStore()).thenReturn(dynamicPropertiesStore); + Mockito.when(manager.getChainBaseManager()).thenReturn(chainBaseManager); + + BlockCapsule.BlockId b0 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 0); + BlockEventCache.init(b0); + + /********** 1 ***********/ + Mockito.when(dynamicPropertiesStore.getLatestBlockHeaderNumber()).thenReturn(0L); + method.invoke(blockEventLoad); + Assert.assertEquals(0, queue.size()); + + /********** 2 ***********/ + BlockEvent be1 = new BlockEvent(); + BlockCapsule.BlockId b1 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 1); + be1.setBlockId(b1); + be1.setParentId(b0); + be1.setSolidId(b0); + + Mockito.when(dynamicPropertiesStore.getLatestBlockHeaderNumber()).thenReturn(1L); + Mockito.when(blockEventGet.getBlockEvent(1L)).thenReturn(be1); + method.invoke(blockEventLoad); + Assert.assertEquals(1, queue.size()); + Assert.assertEquals(b1, BlockEventCache.getHead().getBlockId()); + + /********** 3 ***********/ + BlockEventCache.init(b0); + queue.clear(); + + BlockEvent be2 = new BlockEvent(); + BlockCapsule.BlockId b2 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 2L); + be2.setBlockId(b2); + be2.setParentId(b1); + be2.setSolidId(b0); + + Mockito.when(dynamicPropertiesStore.getLatestBlockHeaderNumber()).thenReturn(2L); + Mockito.when(blockEventGet.getBlockEvent(2L)).thenReturn(be2); + method.invoke(blockEventLoad); + Assert.assertEquals(2, queue.size()); + Assert.assertEquals(b2, BlockEventCache.getHead().getBlockId()); + + /********** 4 ***********/ + BlockEventCache.init(b0); + queue.clear(); + + Mockito.when(dynamicPropertiesStore.getLatestBlockHeaderNumber()).thenReturn(1L); + method.invoke(blockEventLoad); + Assert.assertEquals(1, queue.size()); + queue.clear(); + + BlockEvent be21 = new BlockEvent(); + BlockCapsule.BlockId b21 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 1L); + be21.setBlockId(b21); + be21.setParentId(b0); + be21.setSolidId(b0); + + BlockEvent be22 = new BlockEvent(); + BlockCapsule.BlockId b22 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 2L); + be22.setBlockId(b22); + be22.setParentId(b21); + be22.setSolidId(b21); + + Mockito.when(dynamicPropertiesStore.getLatestBlockHeaderNumber()).thenReturn(2L); + Mockito.when(blockEventGet.getBlockEvent(1L)).thenReturn(be21); + Mockito.when(blockEventGet.getBlockEvent(2L)).thenReturn(be22); + method.invoke(blockEventLoad); + Assert.assertEquals(3, queue.size()); + Assert.assertEquals(b22, BlockEventCache.getHead().getBlockId()); + + Event event = queue.poll(); + Assert.assertEquals(b1, event.getBlockEvent().getBlockId()); + Assert.assertEquals(true, event.isRemove()); + + event = queue.poll(); + Assert.assertEquals(b21, event.getBlockEvent().getBlockId()); + Assert.assertEquals(false, event.isRemove()); + + event = queue.poll(); + Assert.assertEquals(b22, event.getBlockEvent().getBlockId()); + Assert.assertEquals(false, event.isRemove()); + } +} diff --git a/framework/src/test/java/org/tron/core/event/EventPluginLoaderTest.java b/framework/src/test/java/org/tron/core/event/EventPluginLoaderTest.java new file mode 100644 index 00000000000..658d42f38d9 --- /dev/null +++ b/framework/src/test/java/org/tron/core/event/EventPluginLoaderTest.java @@ -0,0 +1,43 @@ +package org.tron.core.event; + +import static org.mockito.Mockito.mock; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.tron.common.logsfilter.EventPluginLoader; +import org.tron.common.logsfilter.IPluginEventListener; +import org.tron.common.utils.ReflectUtils; + +public class EventPluginLoaderTest { + + @Test + public void testIsBusy() { + + EventPluginLoader eventPluginLoader = EventPluginLoader.getInstance(); + ReflectUtils.setFieldValue(eventPluginLoader, "useNativeQueue", true); + boolean flag = eventPluginLoader.isBusy(); + Assert.assertFalse(flag); + + ReflectUtils.setFieldValue(eventPluginLoader, "useNativeQueue", false); + + IPluginEventListener p1 = mock(IPluginEventListener.class); + List list = new ArrayList<>(); + list.add(p1); + ReflectUtils.setFieldValue(eventPluginLoader, "eventListeners", list); + + Mockito.when(p1.getPendingSize()).thenReturn(100); + flag = eventPluginLoader.isBusy(); + Assert.assertFalse(flag); + + Mockito.when(p1.getPendingSize()).thenReturn(60000); + flag = eventPluginLoader.isBusy(); + Assert.assertTrue(flag); + + Mockito.when(p1.getPendingSize()).thenThrow(new AbstractMethodError()); + flag = eventPluginLoader.isBusy(); + Assert.assertFalse(flag); + } +} diff --git a/framework/src/test/java/org/tron/core/event/EventServiceTest.java b/framework/src/test/java/org/tron/core/event/EventServiceTest.java new file mode 100644 index 00000000000..ff7aafb1d1a --- /dev/null +++ b/framework/src/test/java/org/tron/core/event/EventServiceTest.java @@ -0,0 +1,48 @@ +package org.tron.core.event; + +import static org.mockito.Mockito.mock; + +import org.junit.Test; +import org.mockito.Mockito; +import org.tron.common.logsfilter.EventPluginLoader; +import org.tron.common.utils.ReflectUtils; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.db.Manager; +import org.tron.core.services.event.BlockEventCache; +import org.tron.core.services.event.BlockEventLoad; +import org.tron.core.services.event.EventService; +import org.tron.core.services.event.HistoryEventService; +import org.tron.core.services.event.RealtimeEventService; +import org.tron.core.services.event.SolidEventService; + +public class EventServiceTest { + + @Test + public void test() { + BlockCapsule.BlockId b1 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 1); + BlockEventCache.init(b1); + + EventService eventService = new EventService(); + HistoryEventService historyEventService = new HistoryEventService(); + RealtimeEventService realtimeEventService = new RealtimeEventService(); + SolidEventService solidEventService = new SolidEventService(); + BlockEventLoad blockEventLoad = new BlockEventLoad(); + + ReflectUtils.setFieldValue(eventService, "historyEventService", historyEventService); + ReflectUtils.setFieldValue(eventService, "solidEventService", solidEventService); + ReflectUtils.setFieldValue(eventService, "realtimeEventService", realtimeEventService); + ReflectUtils.setFieldValue(eventService, "blockEventLoad", blockEventLoad); + + Manager manager = mock(Manager.class); + ReflectUtils.setFieldValue(eventService, "manager", manager); + Mockito.when(manager.isEventPluginLoaded()).thenReturn(true); + + eventService.init(); + eventService.close(); + + EventPluginLoader instance = mock(EventPluginLoader.class); + Mockito.when(instance.getVersion()).thenReturn(1); + ReflectUtils.setFieldValue(eventService, "instance", instance); + eventService.close(); + } +} diff --git a/framework/src/test/java/org/tron/core/event/HistoryEventServiceTest.java b/framework/src/test/java/org/tron/core/event/HistoryEventServiceTest.java new file mode 100644 index 00000000000..49f77ccf597 --- /dev/null +++ b/framework/src/test/java/org/tron/core/event/HistoryEventServiceTest.java @@ -0,0 +1,96 @@ +package org.tron.core.event; + +import static org.mockito.Mockito.mock; + +import java.lang.reflect.Method; +import org.junit.Test; +import org.mockito.Mockito; +import org.tron.common.logsfilter.EventPluginLoader; +import org.tron.common.utils.ReflectUtils; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.ChainBaseManager; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.db.Manager; +import org.tron.core.services.event.BlockEventGet; +import org.tron.core.services.event.BlockEventLoad; +import org.tron.core.services.event.HistoryEventService; +import org.tron.core.services.event.RealtimeEventService; +import org.tron.core.services.event.SolidEventService; +import org.tron.core.services.event.bo.BlockEvent; +import org.tron.core.store.DynamicPropertiesStore; + +public class HistoryEventServiceTest { + + HistoryEventService historyEventService = new HistoryEventService(); + + @Test + public void test() throws Exception { + EventPluginLoader instance = mock(EventPluginLoader.class); + Mockito.when(instance.isUseNativeQueue()).thenReturn(true); + Mockito.when(instance.isUseNativeQueue()).thenReturn(false); + + ReflectUtils.setFieldValue(historyEventService, "instance", instance); + + DynamicPropertiesStore dynamicPropertiesStore = mock(DynamicPropertiesStore.class); + ChainBaseManager chainBaseManager = mock(ChainBaseManager.class); + Manager manager = mock(Manager.class); + ReflectUtils.setFieldValue(historyEventService, "manager", manager); + Mockito.when(manager.getChainBaseManager()).thenReturn(chainBaseManager); + Mockito.when(manager.getDynamicPropertiesStore()).thenReturn(dynamicPropertiesStore); + Mockito.when(chainBaseManager.getHeadBlockId()).thenReturn(new BlockCapsule.BlockId()); + + SolidEventService solidEventService = new SolidEventService(); + RealtimeEventService realtimeEventService = new RealtimeEventService(); + BlockEventLoad blockEventLoad = new BlockEventLoad(); + ReflectUtils.setFieldValue(blockEventLoad, "instance", instance); + + ReflectUtils.setFieldValue(historyEventService, "solidEventService", solidEventService); + ReflectUtils.setFieldValue(historyEventService, "realtimeEventService", realtimeEventService); + ReflectUtils.setFieldValue(historyEventService, "blockEventLoad", blockEventLoad); + historyEventService.init(); + historyEventService.close(); + solidEventService.close(); + realtimeEventService.close(); + blockEventLoad.close(); + + solidEventService = mock(SolidEventService.class); + ReflectUtils.setFieldValue(historyEventService, "solidEventService", solidEventService); + realtimeEventService = mock(RealtimeEventService.class); + ReflectUtils.setFieldValue(historyEventService, "realtimeEventService", realtimeEventService); + blockEventLoad = mock(BlockEventLoad.class); + ReflectUtils.setFieldValue(historyEventService, "blockEventLoad", blockEventLoad); + + Mockito.when(instance.getStartSyncBlockNum()).thenReturn(0L); + + Mockito.when(dynamicPropertiesStore.getLatestSolidifiedBlockNum()).thenReturn(0L); + Mockito.when(chainBaseManager.getBlockIdByNum(0L)) + .thenReturn(new BlockCapsule.BlockId(Sha256Hash.ZERO_HASH, 0)); + historyEventService.init(); + + BlockEvent be2 = new BlockEvent(); + BlockCapsule.BlockId b2 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 2); + be2.setBlockId(b2); + + BlockEventGet blockEventGet = mock(BlockEventGet.class); + ReflectUtils.setFieldValue(historyEventService, "blockEventGet", blockEventGet); + Mockito.when(blockEventGet.getBlockEvent(1)).thenReturn(be2); + + Mockito.when(instance.getStartSyncBlockNum()).thenReturn(1L); + Mockito.when(dynamicPropertiesStore.getLatestSolidifiedBlockNum()).thenReturn(1L); + + Mockito.when(chainBaseManager.getBlockIdByNum(1L)) + .thenReturn(new BlockCapsule.BlockId(Sha256Hash.ZERO_HASH, 1)); + + Mockito.when(instance.isUseNativeQueue()).thenReturn(true); + + Method method1 = historyEventService.getClass().getDeclaredMethod("syncEvent"); + method1.setAccessible(true); + method1.invoke(historyEventService); + + Mockito.when(instance.isUseNativeQueue()).thenReturn(false); + Mockito.when(instance.isBusy()).thenReturn(true); + historyEventService.init(); + Thread.sleep(1000); + historyEventService.close(); + } +} diff --git a/framework/src/test/java/org/tron/core/event/RealtimeEventServiceTest.java b/framework/src/test/java/org/tron/core/event/RealtimeEventServiceTest.java new file mode 100644 index 00000000000..91dcea71322 --- /dev/null +++ b/framework/src/test/java/org/tron/core/event/RealtimeEventServiceTest.java @@ -0,0 +1,118 @@ +package org.tron.core.event; + +import static org.mockito.Mockito.mock; + +import com.google.protobuf.ByteString; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.BlockingQueue; +import org.eclipse.jetty.util.BlockingArrayQueue; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.tron.common.logsfilter.EventPluginLoader; +import org.tron.common.logsfilter.capsule.BlockLogTriggerCapsule; +import org.tron.common.logsfilter.capsule.TransactionLogTriggerCapsule; +import org.tron.common.logsfilter.capsule.TriggerCapsule; +import org.tron.common.logsfilter.trigger.ContractEventTrigger; +import org.tron.common.logsfilter.trigger.ContractLogTrigger; +import org.tron.common.utils.ReflectUtils; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.db.Manager; +import org.tron.core.services.event.BlockEventCache; +import org.tron.core.services.event.RealtimeEventService; +import org.tron.core.services.event.bo.BlockEvent; +import org.tron.core.services.event.bo.Event; +import org.tron.core.services.event.bo.SmartContractTrigger; + +public class RealtimeEventServiceTest { + + RealtimeEventService realtimeEventService = new RealtimeEventService(); + + @Test + public void test() throws Exception { + BlockEvent be1 = new BlockEvent(); + BlockCapsule.BlockId b1 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 1); + be1.setBlockId(b1); + be1.setParentId(b1); + be1.setSolidId(b1); + BlockEventCache.init(b1); + + BlockEvent be2 = new BlockEvent(); + BlockCapsule.BlockId b2 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 2); + be2.setBlockId(b2); + be2.setParentId(b1); + be2.setSolidId(b1); + BlockEventCache.add(be2); + Assert.assertEquals(be2, BlockEventCache.getHead()); + Assert.assertEquals(be2, BlockEventCache.getBlockEvent(b2)); + + Event event = new Event(be2, true); + + realtimeEventService.add(event); + realtimeEventService.work(); + + EventPluginLoader instance = mock(EventPluginLoader.class); + ReflectUtils.setFieldValue(realtimeEventService, "instance", instance); + + BlockingQueue queue = new BlockingArrayQueue<>(); + Manager manager = mock(Manager.class); + Mockito.when(manager.getTriggerCapsuleQueue()).thenReturn(queue); + ReflectUtils.setFieldValue(realtimeEventService, "manager", manager); + + BlockCapsule blockCapsule = new BlockCapsule(0L, Sha256Hash.ZERO_HASH, 0L, + ByteString.copyFrom(BlockEventCacheTest.getBlockId())); + be2.setBlockLogTriggerCapsule(new BlockLogTriggerCapsule(blockCapsule)); + Mockito.when(instance.isBlockLogTriggerEnable()).thenReturn(true); + Mockito.when(instance.isBlockLogTriggerSolidified()).thenReturn(false); + + realtimeEventService.add(event); + realtimeEventService.work(); + + Assert.assertEquals(0, queue.size()); + + event = new Event(be2, false); + realtimeEventService.add(event); + realtimeEventService.work(); + + Assert.assertEquals(1, queue.size()); + + be2.setBlockLogTriggerCapsule(null); + queue.poll(); + + List list = new ArrayList<>(); + list.add(mock(TransactionLogTriggerCapsule.class)); + be2.setTransactionLogTriggerCapsules(list); + + Mockito.when(instance.isTransactionLogTriggerEnable()).thenReturn(true); + Mockito.when(instance.isTransactionLogTriggerSolidified()).thenReturn(false); + realtimeEventService.flush(be2, event.isRemove()); + Assert.assertEquals(1, queue.size()); + + be2.setTransactionLogTriggerCapsules(null); + + SmartContractTrigger contractTrigger = new SmartContractTrigger(); + be2.setSmartContractTrigger(contractTrigger); + + contractTrigger.getContractEventTriggers().add(mock(ContractEventTrigger.class)); + Mockito.when(instance.isContractLogTriggerEnable()).thenReturn(true); + try { + realtimeEventService.flush(be2, event.isRemove()); + } catch (Exception e) { + Assert.assertTrue(e instanceof NullPointerException); + } + + contractTrigger.getContractEventTriggers().clear(); + + realtimeEventService.flush(be2, event.isRemove()); + + contractTrigger.getContractLogTriggers().add(mock(ContractLogTrigger.class)); + Mockito.when(instance.isContractEventTriggerEnable()).thenReturn(true); + try { + realtimeEventService.flush(be2, event.isRemove()); + } catch (Exception e) { + Assert.assertTrue(e instanceof NullPointerException); + } + } +} diff --git a/framework/src/test/java/org/tron/core/event/SolidEventServiceTest.java b/framework/src/test/java/org/tron/core/event/SolidEventServiceTest.java new file mode 100644 index 00000000000..de0300e31d7 --- /dev/null +++ b/framework/src/test/java/org/tron/core/event/SolidEventServiceTest.java @@ -0,0 +1,125 @@ +package org.tron.core.event; + +import static org.mockito.Mockito.mock; + +import com.google.protobuf.ByteString; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.BlockingQueue; +import org.eclipse.jetty.util.BlockingArrayQueue; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.tron.common.logsfilter.EventPluginLoader; +import org.tron.common.logsfilter.capsule.BlockLogTriggerCapsule; +import org.tron.common.logsfilter.capsule.SolidityTriggerCapsule; +import org.tron.common.logsfilter.capsule.TransactionLogTriggerCapsule; +import org.tron.common.logsfilter.capsule.TriggerCapsule; +import org.tron.common.logsfilter.trigger.ContractEventTrigger; +import org.tron.common.logsfilter.trigger.ContractLogTrigger; +import org.tron.common.utils.ReflectUtils; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.db.Manager; +import org.tron.core.services.event.BlockEventCache; +import org.tron.core.services.event.SolidEventService; +import org.tron.core.services.event.bo.BlockEvent; +import org.tron.core.services.event.bo.SmartContractTrigger; + +public class SolidEventServiceTest { + + SolidEventService solidEventService = new SolidEventService(); + + @Test + public void test() throws Exception { + BlockEvent be0 = new BlockEvent(); + BlockCapsule.BlockId b0 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 1); + be0.setBlockId(b0); + be0.setParentId(b0); + be0.setSolidId(new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 100)); + BlockEventCache.init(b0); + BlockEventCache.add(be0); + solidEventService.work(); + + BlockEvent be1 = new BlockEvent(); + BlockCapsule.BlockId b1 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 1); + be1.setBlockId(b1); + be1.setParentId(b1); + be1.setSolidId(b1); + BlockEventCache.init(b1); + + BlockEvent be2 = new BlockEvent(); + BlockCapsule.BlockId b2 = new BlockCapsule.BlockId(BlockEventCacheTest.getBlockId(), 2); + be2.setBlockId(b2); + be2.setParentId(b1); + be2.setSolidId(b1); + BlockEventCache.add(be2); + Assert.assertEquals(be2, BlockEventCache.getHead()); + Assert.assertEquals(be2, BlockEventCache.getBlockEvent(b2)); + + solidEventService.flush(be2); + + EventPluginLoader instance = mock(EventPluginLoader.class); + ReflectUtils.setFieldValue(solidEventService, "instance", instance); + + BlockingQueue queue = new BlockingArrayQueue<>(); + Manager manager = mock(Manager.class); + Mockito.when(manager.getTriggerCapsuleQueue()).thenReturn(queue); + ReflectUtils.setFieldValue(solidEventService, "manager", manager); + + BlockCapsule blockCapsule = new BlockCapsule(0L, Sha256Hash.ZERO_HASH, 0L, + ByteString.copyFrom(BlockEventCacheTest.getBlockId())); + be2.setBlockLogTriggerCapsule(new BlockLogTriggerCapsule(blockCapsule)); + Mockito.when(instance.isBlockLogTriggerEnable()).thenReturn(true); + Mockito.when(instance.isBlockLogTriggerSolidified()).thenReturn(true); + + solidEventService.flush(be2); + + Assert.assertEquals(1, queue.size()); + + be2.setBlockLogTriggerCapsule(null); + queue.poll(); + + List list = new ArrayList<>(); + list.add(mock(TransactionLogTriggerCapsule.class)); + be2.setTransactionLogTriggerCapsules(list); + + Mockito.when(instance.isTransactionLogTriggerEnable()).thenReturn(true); + Mockito.when(instance.isTransactionLogTriggerSolidified()).thenReturn(true); + solidEventService.flush(be2); + Assert.assertEquals(1, queue.size()); + + be2.setTransactionLogTriggerCapsules(null); + + SmartContractTrigger contractTrigger = new SmartContractTrigger(); + be2.setSmartContractTrigger(contractTrigger); + + contractTrigger.getContractEventTriggers().add(mock(ContractEventTrigger.class)); + Mockito.when(instance.isSolidityLogTriggerEnable()).thenReturn(true); + try { + solidEventService.flush(be2); + } catch (Exception e) { + Assert.assertTrue(e instanceof NullPointerException); + } + + contractTrigger.getContractEventTriggers().clear(); + + solidEventService.flush(be2); + + contractTrigger.getContractLogTriggers().add(mock(ContractLogTrigger.class)); + Mockito.when(instance.isSolidityEventTriggerEnable()).thenReturn(true); + try { + solidEventService.flush(be2); + } catch (Exception e) { + Assert.assertTrue(e instanceof NullPointerException); + } + + be2.setSmartContractTrigger(null); + + Mockito.when(instance.isSolidityTriggerEnable()).thenReturn(true); + be2.setSolidityTriggerCapsule(new SolidityTriggerCapsule(1)); + queue.clear(); + solidEventService.flush(be2); + Assert.assertEquals(1, queue.size()); + } +} diff --git a/framework/src/test/java/org/tron/core/exception/TronErrorTest.java b/framework/src/test/java/org/tron/core/exception/TronErrorTest.java new file mode 100644 index 00000000000..b4c3dc4b07f --- /dev/null +++ b/framework/src/test/java/org/tron/core/exception/TronErrorTest.java @@ -0,0 +1,117 @@ +package org.tron.core.exception; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mockStatic; + +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; +import com.typesafe.config.ConfigObject; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.junit.After; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.tron.common.log.LogService; +import org.tron.common.parameter.RateLimiterInitialization; +import org.tron.common.utils.ReflectUtils; +import org.tron.common.zksnark.JLibrustzcash; +import org.tron.core.Constant; +import org.tron.core.config.args.Args; +import org.tron.core.services.http.GetBlockServlet; +import org.tron.core.services.http.RateLimiterServlet; +import org.tron.core.zen.ZksnarkInitService; + +@RunWith(MockitoJUnitRunner.class) +public class TronErrorTest { + + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @After + public void clearMocks() { + Mockito.clearAllCaches(); + Args.clearParam(); + } + + @Test + public void testTronError() { + TronError tronError = new TronError("message", TronError.ErrCode.WITNESS_KEYSTORE_LOAD); + Assert.assertEquals(tronError.getErrCode(), TronError.ErrCode.WITNESS_KEYSTORE_LOAD); + Assert.assertEquals(tronError.getErrCode().toString(), "WITNESS_KEYSTORE_LOAD(-1)"); + Assert.assertEquals(tronError.getErrCode().getCode(), -1); + tronError = new TronError("message", new Throwable(), TronError.ErrCode.API_SERVER_INIT); + Assert.assertEquals(tronError.getErrCode(), TronError.ErrCode.API_SERVER_INIT); + tronError = new TronError(new Throwable(), TronError.ErrCode.LEVELDB_INIT); + Assert.assertEquals(tronError.getErrCode(), TronError.ErrCode.LEVELDB_INIT); + } + + @Test + public void ZksnarkInitTest() { + try (MockedStatic mock = mockStatic(JLibrustzcash.class)) { + mock.when(JLibrustzcash::isOpenZen).thenReturn(true); + mock.when(() -> JLibrustzcash.librustzcashInitZksnarkParams(any())) + .thenAnswer(invocation -> { + throw new ZksnarkException("Zksnark init failed"); + }); + TronError thrown = assertThrows(TronError.class, + ZksnarkInitService::librustzcashInitZksnarkParams); + assertEquals(TronError.ErrCode.ZCASH_INIT, thrown.getErrCode()); + } + } + + @Test + public void LogLoadTest() throws IOException { + LogService.load("non-existent.xml"); + Path path = temporaryFolder.newFile("logback.xml").toPath(); + TronError thrown = assertThrows(TronError.class, () -> LogService.load(path.toString())); + assertEquals(TronError.ErrCode.LOG_LOAD, thrown.getErrCode()); + } + + @Test + public void witnessInitTest() { + TronError thrown = assertThrows(TronError.class, () -> { + Args.setParam(new String[]{"--witness"}, Constant.TEST_CONF); + }); + assertEquals(TronError.ErrCode.WITNESS_INIT, thrown.getErrCode()); + } + + @Test + public void rateLimiterServletInitTest() { + Args.setParam(new String[]{}, Constant.TEST_CONF); + RateLimiterInitialization rateLimiter = new RateLimiterInitialization(); + Args.getInstance().setRateLimiterInitialization(rateLimiter); + Map item = new HashMap<>(); + item.put("strategy", "strategy"); + item.put("paramString", "params"); + item.put("component", "GetBlockServlet"); + ConfigObject config = ConfigFactory.parseMap(item).root(); + rateLimiter.setHttpMap( + Collections.singletonList(new RateLimiterInitialization.HttpRateLimiterItem(config))); + RateLimiterServlet servlet = new GetBlockServlet(); + TronError thrown = assertThrows(TronError.class, () -> + ReflectUtils.invokeMethod(servlet, "addRateContainer")); + assertEquals(TronError.ErrCode.RATE_LIMITER_INIT, thrown.getErrCode()); + } + + @Test + public void shutdownBlockTimeInitTest() { + Map params = new HashMap<>(); + params.put(Constant.NODE_SHUTDOWN_BLOCK_TIME, "0"); + params.put("storage.db.directory", "database"); + Config config = ConfigFactory.defaultOverrides().withFallback( + ConfigFactory.parseMap(params)); + TronError thrown = assertThrows(TronError.class, () -> Args.setParam(config)); + assertEquals(TronError.ErrCode.AUTO_STOP_PARAMS, thrown.getErrCode()); + } +} diff --git a/framework/src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java b/framework/src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java new file mode 100644 index 00000000000..570e7ed3498 --- /dev/null +++ b/framework/src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java @@ -0,0 +1,46 @@ +package org.tron.core.jsonrpc; + +import static org.tron.common.utils.Commons.decodeFromBase58Check; +import static org.tron.keystore.Wallet.generateRandomBytes; + +import com.google.protobuf.ByteString; +import org.junit.Assert; +import org.junit.Test; +import org.tron.common.utils.ByteArray; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.services.jsonrpc.JsonRpcApiUtil; +import org.tron.protos.Protocol.Block; +import org.tron.protos.Protocol.BlockHeader; +import org.tron.protos.Protocol.BlockHeader.raw; +import org.tron.protos.contract.SmartContractOuterClass.TriggerSmartContract; + +public class ApiUtilTest { + + @Test + public void testGetBlockID() { + byte[] mockedHash = generateRandomBytes(128); + // common parent block + BlockCapsule blockCapsule = new BlockCapsule(Block.newBuilder().setBlockHeader( + BlockHeader.newBuilder().setRawData( + raw.newBuilder().setParentHash(ByteString.copyFrom(mockedHash)) + .setNumber(0))).build()); + String blockIdStr = JsonRpcApiUtil.getBlockID(blockCapsule.getInstance()); + Assert.assertEquals(2 + 64, blockIdStr.length()); + } + + @Test + public void testTriggerCallContract() { + byte[] address = decodeFromBase58Check("TEPRbQxXQEpHpeEx8tK5xHVs7NWudAAZgu"); + //nile usdt + byte[] contractAddress = decodeFromBase58Check("TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"); + long callValue = 100; + //transfer to address TVjsyZ7fYF3qLF6BQgPmTEZy1xrNNyVAAA with 10*10^6 + byte[] data = ByteArray.fromHexString("a9059cbb000000000000000000000000d8dd39e2dea27a4000" + + "1884901735e3940829bb440000000000000000000000000000000000000000000000000000000000989680"); + long tokenValue = 10; + String tokenId = "1000001"; + TriggerSmartContract triggerSmartContract = JsonRpcApiUtil.triggerCallContract(address, + contractAddress, callValue, data, tokenValue, tokenId); + Assert.assertNotNull(triggerSmartContract); + } +} diff --git a/framework/src/test/java/org/tron/core/jsonrpc/ConcurrentHashMapTest.java b/framework/src/test/java/org/tron/core/jsonrpc/ConcurrentHashMapTest.java index ea0c0354bb0..1de106f68e8 100644 --- a/framework/src/test/java/org/tron/core/jsonrpc/ConcurrentHashMapTest.java +++ b/framework/src/test/java/org/tron/core/jsonrpc/ConcurrentHashMapTest.java @@ -1,5 +1,8 @@ package org.tron.core.jsonrpc; +import static org.tron.common.math.Maths.random; +import static org.tron.common.math.Maths.round; + import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -17,7 +20,7 @@ public class ConcurrentHashMapTest { private static int randomInt(int minInt, int maxInt) { - return (int) Math.round(Math.random() * (maxInt - minInt) + minInt); + return (int) round(random(true) * (maxInt - minInt) + minInt, true); } /** diff --git a/framework/src/test/java/org/tron/core/jsonrpc/JsonRpcTest.java b/framework/src/test/java/org/tron/core/jsonrpc/JsonRpcTest.java index f221d0c95ac..bef0b5a1593 100644 --- a/framework/src/test/java/org/tron/core/jsonrpc/JsonRpcTest.java +++ b/framework/src/test/java/org/tron/core/jsonrpc/JsonRpcTest.java @@ -19,6 +19,7 @@ import org.tron.common.utils.ByteUtil; import org.tron.common.utils.Commons; import org.tron.core.exception.JsonRpcInvalidParamsException; +import org.tron.core.services.jsonrpc.JsonRpcApiUtil; import org.tron.core.services.jsonrpc.TronJsonRpc.FilterRequest; import org.tron.core.services.jsonrpc.filters.LogBlockQuery; import org.tron.core.services.jsonrpc.filters.LogFilter; @@ -190,6 +191,7 @@ public void testLogFilter() { } catch (JsonRpcInvalidParamsException e) { Assert.fail(); } + try { new LogFilter(new FilterRequest(null, null, null, new String[] {"0x0"}, null)); } catch (JsonRpcInvalidParamsException e) { @@ -240,124 +242,20 @@ public void testLogFilter() { } } - /** - * test fromBlock and toBlock parameters - */ - @Test - public void testLogFilterWrapper() { - - // fromBlock and toBlock are both empty - try { - LogFilterWrapper logFilterWrapper = - new LogFilterWrapper(new FilterRequest(null, null, null, null, null), 100, null); - Assert.assertEquals(logFilterWrapper.getFromBlock(), 100); - Assert.assertEquals(logFilterWrapper.getToBlock(), Long.MAX_VALUE); - } catch (JsonRpcInvalidParamsException e) { - Assert.fail(); - } - - // fromBlock is not empty and smaller than currentMaxBlockNum, toBlock is empty - try { - LogFilterWrapper logFilterWrapper = - new LogFilterWrapper(new FilterRequest("0x14", null, null, null, null), 100, null); - Assert.assertEquals(logFilterWrapper.getFromBlock(), 20); - Assert.assertEquals(logFilterWrapper.getToBlock(), Long.MAX_VALUE); - } catch (JsonRpcInvalidParamsException e) { - Assert.fail(); - } - - // fromBlock is not empty and bigger than currentMaxBlockNum, toBlock is empty - try { - LogFilterWrapper logFilterWrapper = - new LogFilterWrapper(new FilterRequest("0x78", null, null, null, null), 100, null); - Assert.assertEquals(logFilterWrapper.getFromBlock(), 120); - Assert.assertEquals(logFilterWrapper.getToBlock(), Long.MAX_VALUE); - } catch (JsonRpcInvalidParamsException e) { - Assert.fail(); - } - - // fromBlock is empty, toBlock is not empty and smaller than currentMaxBlockNum - try { - LogFilterWrapper logFilterWrapper = - new LogFilterWrapper(new FilterRequest(null, "0x14", null, null, null), 100, null); - Assert.assertEquals(logFilterWrapper.getFromBlock(), 20); - Assert.assertEquals(logFilterWrapper.getToBlock(), 20); - } catch (JsonRpcInvalidParamsException e) { - Assert.fail(); - } - - // fromBlock is empty, toBlock is not empty and bigger than currentMaxBlockNum - try { - LogFilterWrapper logFilterWrapper = - new LogFilterWrapper(new FilterRequest(null, "0x78", null, null, null), 100, null); - Assert.assertEquals(logFilterWrapper.getFromBlock(), 100); - Assert.assertEquals(logFilterWrapper.getToBlock(), 120); - } catch (JsonRpcInvalidParamsException e) { - Assert.fail(); - } - - // fromBlock is not empty, toBlock is not empty - try { - LogFilterWrapper logFilterWrapper = - new LogFilterWrapper(new FilterRequest("0x14", "0x78", null, null, null), 100, null); - Assert.assertEquals(logFilterWrapper.getFromBlock(), 20); - Assert.assertEquals(logFilterWrapper.getToBlock(), 120); - } catch (JsonRpcInvalidParamsException e) { - Assert.fail(); - } - try { - LogFilterWrapper logFilterWrapper = - new LogFilterWrapper(new FilterRequest("0x78", "0x14", null, null, null), 100, null); - } catch (JsonRpcInvalidParamsException e) { - Assert.assertEquals("please verify: fromBlock <= toBlock", e.getMessage()); - } - - //fromBlock or toBlock is not hex num - try { - LogFilterWrapper logFilterWrapper = - new LogFilterWrapper(new FilterRequest("earliest", null, null, null, null), 100, null); - Assert.assertEquals(logFilterWrapper.getFromBlock(), 0); - Assert.assertEquals(logFilterWrapper.getToBlock(), Long.MAX_VALUE); - } catch (JsonRpcInvalidParamsException e) { - Assert.fail(); - } - try { - LogFilterWrapper logFilterWrapper = - new LogFilterWrapper(new FilterRequest("latest", null, null, null, null), 100, null); - Assert.assertEquals(logFilterWrapper.getFromBlock(), 100); - Assert.assertEquals(logFilterWrapper.getToBlock(), Long.MAX_VALUE); - } catch (JsonRpcInvalidParamsException e) { - Assert.fail(); - } - try { - LogFilterWrapper logFilterWrapper = - new LogFilterWrapper(new FilterRequest("pending", null, null, null, null), 100, null); - } catch (JsonRpcInvalidParamsException e) { - Assert.assertEquals("TAG pending not supported", e.getMessage()); - } - try { - LogFilterWrapper logFilterWrapper = - new LogFilterWrapper(new FilterRequest("test", null, null, null, null), 100, null); - } catch (JsonRpcInvalidParamsException e) { - Assert.assertEquals("Incorrect hex syntax", e.getMessage()); - } - } - private int[] getBloomIndex(String s) { Bloom bloom = Bloom.create(Hash.sha3(ByteArray.fromHexString(s))); BitSet bs = BitSet.valueOf(bloom.getData()); - int[] bitIndex = new int[3]; //must same as the number of hash function in Bloom - int nonZeroCount = 0; + List bitIndexList = new ArrayList<>(); for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { // operate on index i here if (i == Integer.MAX_VALUE) { break; // or (i+1) would overflow } - bitIndex[nonZeroCount++] = i; + bitIndexList.add(i); } - return bitIndex; + return bitIndexList.stream().mapToInt(Integer::intValue).toArray(); } @Test @@ -386,7 +284,8 @@ public void testGetConditions() { topics, null), 100, - null); + null, + false); LogBlockQuery logBlockQuery = new LogBlockQuery(logFilterWrapper, null, 100, null); int[][][] conditions = logBlockQuery.getConditions(); @@ -416,4 +315,49 @@ public void testGetConditions() { Assert.fail(); } } + + @Test + public void testGetConditionWithHashCollision() { + try { + List addressList = new ArrayList<>(); + addressList.add("0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85"); + addressList.add("0x3038114c1a1e72c5bfa8b003bc3650ad2ba254a0"); + + Object[] topics = new Object[0]; + + LogFilterWrapper logFilterWrapper = + new LogFilterWrapper(new FilterRequest(null, + null, + addressList, + topics, + null), + 100, + null, + false); + + LogBlockQuery logBlockQuery = new LogBlockQuery(logFilterWrapper, null, 100, null); + int[][][] conditions = logBlockQuery.getConditions(); + //level = depth(address) + depth(topics), skip null + Assert.assertEquals(1, conditions.length); + //elements number + Assert.assertEquals(2, conditions[0].length); + + Assert.assertEquals(3, conditions[0][0].length); + //Hash collision, only two nonZero position + Assert.assertEquals(2, conditions[0][1].length); + + Assert.assertArrayEquals(conditions[0][0], + getBloomIndex("0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85")); + Assert.assertArrayEquals(conditions[0][1], + getBloomIndex("0x3038114c1a1e72c5bfa8b003bc3650ad2ba254a0")); + + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + } + + @Test + public void testGenerateFilterId() { + Assert.assertEquals(32, JsonRpcApiUtil.generateFilterId().length()); + } } diff --git a/framework/src/test/java/org/tron/core/jsonrpc/JsonrpcServiceTest.java b/framework/src/test/java/org/tron/core/jsonrpc/JsonrpcServiceTest.java index b3ed26b591f..0f2214c5c9c 100644 --- a/framework/src/test/java/org/tron/core/jsonrpc/JsonrpcServiceTest.java +++ b/framework/src/test/java/org/tron/core/jsonrpc/JsonrpcServiceTest.java @@ -1,10 +1,15 @@ package org.tron.core.jsonrpc; +import static org.tron.core.services.jsonrpc.JsonRpcApiUtil.getByJsonBlockId; + import com.alibaba.fastjson.JSON; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.protobuf.ByteString; import io.prometheus.client.CollectorRegistry; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.apache.http.client.methods.CloseableHttpResponse; @@ -21,18 +26,23 @@ import org.tron.common.parameter.CommonParameter; import org.tron.common.prometheus.Metrics; import org.tron.common.utils.ByteArray; +import org.tron.common.utils.PublicMethod; import org.tron.common.utils.Sha256Hash; import org.tron.core.Constant; import org.tron.core.Wallet; import org.tron.core.capsule.AccountCapsule; import org.tron.core.capsule.BlockCapsule; import org.tron.core.capsule.TransactionCapsule; +import org.tron.core.capsule.utils.BlockUtil; import org.tron.core.config.args.Args; +import org.tron.core.exception.JsonRpcInvalidParamsException; import org.tron.core.services.NodeInfoService; import org.tron.core.services.interfaceJsonRpcOnPBFT.JsonRpcServiceOnPBFT; import org.tron.core.services.interfaceJsonRpcOnSolidity.JsonRpcServiceOnSolidity; import org.tron.core.services.jsonrpc.FullNodeJsonRpcHttpService; +import org.tron.core.services.jsonrpc.TronJsonRpc.FilterRequest; import org.tron.core.services.jsonrpc.TronJsonRpcImpl; +import org.tron.core.services.jsonrpc.filters.LogFilterWrapper; import org.tron.core.services.jsonrpc.types.BlockResult; import org.tron.core.services.jsonrpc.types.TransactionResult; import org.tron.protos.Protocol; @@ -42,14 +52,19 @@ @Slf4j public class JsonrpcServiceTest extends BaseTest { + private static final String OWNER_ADDRESS; private static final String OWNER_ADDRESS_ACCOUNT_NAME = "first"; + private static final long LATEST_BLOCK_NUM = 10_000L; + private static final long LATEST_SOLIDIFIED_BLOCK_NUM = 4L; private static TronJsonRpcImpl tronJsonRpc; @Resource private NodeInfoService nodeInfoService; - private static BlockCapsule blockCapsule; + private static BlockCapsule blockCapsule0; + private static BlockCapsule blockCapsule1; + private static BlockCapsule blockCapsule2; private static TransactionCapsule transactionCapsule1; @Resource private Wallet wallet; @@ -64,65 +79,81 @@ public class JsonrpcServiceTest extends BaseTest { private JsonRpcServiceOnSolidity jsonRpcServiceOnSolidity; static { - Args.setParam(new String[]{"--output-directory", dbPath()}, Constant.TEST_CONF); + Args.setParam(new String[] {"--output-directory", dbPath()}, Constant.TEST_CONF); CommonParameter.getInstance().setJsonRpcHttpFullNodeEnable(true); + CommonParameter.getInstance().setJsonRpcHttpFullNodePort(PublicMethod.chooseRandomPort()); CommonParameter.getInstance().setJsonRpcHttpPBFTNodeEnable(true); + CommonParameter.getInstance().setJsonRpcHttpPBFTPort(PublicMethod.chooseRandomPort()); CommonParameter.getInstance().setJsonRpcHttpSolidityNodeEnable(true); + CommonParameter.getInstance().setJsonRpcHttpSolidityPort(PublicMethod.chooseRandomPort()); CommonParameter.getInstance().setMetricsPrometheusEnable(true); + CommonParameter.getInstance().setMetricsPrometheusPort(PublicMethod.chooseRandomPort()); Metrics.init(); - OWNER_ADDRESS = - Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049abc"; + OWNER_ADDRESS = Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049abc"; } @Before public void init() { AccountCapsule accountCapsule = - new AccountCapsule( - ByteString.copyFromUtf8(OWNER_ADDRESS_ACCOUNT_NAME), + new AccountCapsule(ByteString.copyFromUtf8(OWNER_ADDRESS_ACCOUNT_NAME), ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)), - Protocol.AccountType.Normal, - 10000_000_000L); + Protocol.AccountType.Normal, 10000_000_000L); dbManager.getAccountStore().put(accountCapsule.getAddress().toByteArray(), accountCapsule); - blockCapsule = new BlockCapsule( - 1, - Sha256Hash.wrap(ByteString.copyFrom( - ByteArray.fromHexString( - "0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b81"))), - 1, + blockCapsule0 = BlockUtil.newGenesisBlockCapsule(); + blockCapsule1 = new BlockCapsule(LATEST_BLOCK_NUM, Sha256Hash.wrap(ByteString.copyFrom( + ByteArray.fromHexString( + "0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b81"))), 1, + ByteString.copyFromUtf8("testAddress")); + blockCapsule2 = new BlockCapsule(LATEST_SOLIDIFIED_BLOCK_NUM, Sha256Hash.wrap( + ByteString.copyFrom(ByteArray.fromHexString( + "9938a342238077182498b464ac029222ae169360e540d1fd6aee7c2ae9575a06"))), 1, ByteString.copyFromUtf8("testAddress")); - TransferContract transferContract1 = TransferContract.newBuilder() - .setAmount(1L) - .setOwnerAddress(ByteString.copyFrom("0x0000000000000000000".getBytes())) - .setToAddress(ByteString.copyFrom(ByteArray.fromHexString( - (Wallet.getAddressPreFixString() + "A389132D6639FBDA4FBC8B659264E6B7C90DB086")))) - .build(); - TransferContract transferContract2 = TransferContract.newBuilder() - .setAmount(2L) - .setOwnerAddress(ByteString.copyFrom("0x0000000000000000000".getBytes())) - .setToAddress(ByteString.copyFrom(ByteArray.fromHexString( - (Wallet.getAddressPreFixString() + "ED738B3A0FE390EAA71B768B6D02CDBD18FB207B")))) + TransferContract transferContract1 = TransferContract.newBuilder().setAmount(1L) + .setOwnerAddress(ByteString.copyFrom("0x0000000000000000000".getBytes())).setToAddress( + ByteString.copyFrom(ByteArray.fromHexString( + (Wallet.getAddressPreFixString() + "A389132D6639FBDA4FBC8B659264E6B7C90DB086")))) + .build(); + TransferContract transferContract2 = TransferContract.newBuilder().setAmount(2L) + .setOwnerAddress(ByteString.copyFrom("0x0000000000000000000".getBytes())).setToAddress( + ByteString.copyFrom(ByteArray.fromHexString( + (Wallet.getAddressPreFixString() + "ED738B3A0FE390EAA71B768B6D02CDBD18FB207B")))) + .build(); + TransferContract transferContract3 = TransferContract.newBuilder().setAmount(3L) + .setOwnerAddress(ByteString.copyFrom("0x0000000000000000000".getBytes())).setToAddress( + ByteString.copyFrom(ByteArray.fromHexString( + (Wallet.getAddressPreFixString() + "ED738B3A0FE390EAA71B768B6D02CDBD18FB207B")))) .build(); - transactionCapsule1 = - new TransactionCapsule(transferContract1, ContractType.TransferContract); - transactionCapsule1.setBlockNum(blockCapsule.getNum()); + transactionCapsule1 = new TransactionCapsule(transferContract1, ContractType.TransferContract); + transactionCapsule1.setBlockNum(blockCapsule1.getNum()); TransactionCapsule transactionCapsule2 = new TransactionCapsule(transferContract2, ContractType.TransferContract); - transactionCapsule2.setBlockNum(2L); + transactionCapsule2.setBlockNum(blockCapsule1.getNum()); + TransactionCapsule transactionCapsule3 = new TransactionCapsule(transferContract3, + ContractType.TransferContract); + transactionCapsule3.setBlockNum(blockCapsule2.getNum()); + + blockCapsule1.addTransaction(transactionCapsule1); + blockCapsule1.addTransaction(transactionCapsule2); + blockCapsule2.addTransaction(transactionCapsule3); + + dbManager.getDynamicPropertiesStore().saveLatestBlockHeaderNumber(LATEST_BLOCK_NUM); + dbManager.getBlockIndexStore().put(blockCapsule1.getBlockId()); + dbManager.getBlockStore().put(blockCapsule1.getBlockId().getBytes(), blockCapsule1); - blockCapsule.addTransaction(transactionCapsule1); - blockCapsule.addTransaction(transactionCapsule2); - dbManager.getDynamicPropertiesStore().saveLatestBlockHeaderNumber(1L); - dbManager.getBlockIndexStore().put(blockCapsule.getBlockId()); - dbManager.getBlockStore().put(blockCapsule.getBlockId().getBytes(), blockCapsule); + dbManager.getDynamicPropertiesStore().saveLatestSolidifiedBlockNum(LATEST_SOLIDIFIED_BLOCK_NUM); + dbManager.getBlockIndexStore().put(blockCapsule2.getBlockId()); + dbManager.getBlockStore().put(blockCapsule2.getBlockId().getBytes(), blockCapsule2); dbManager.getTransactionStore() .put(transactionCapsule1.getTransactionId().getBytes(), transactionCapsule1); dbManager.getTransactionStore() .put(transactionCapsule2.getTransactionId().getBytes(), transactionCapsule2); + dbManager.getTransactionStore() + .put(transactionCapsule3.getTransactionId().getBytes(), transactionCapsule3); tronJsonRpc = new TronJsonRpcImpl(nodeInfoService, wallet, dbManager); } @@ -165,11 +196,11 @@ public void testGetBlockTransactionCountByHash() { try { result = tronJsonRpc.ethGetBlockTransactionCountByHash( - Hex.toHexString((blockCapsule.getBlockId().getBytes()))); + Hex.toHexString((blockCapsule1.getBlockId().getBytes()))); } catch (Exception e) { Assert.fail(); } - Assert.assertEquals(ByteArray.toJsonHex(blockCapsule.getTransactions().size()), result); + Assert.assertEquals(ByteArray.toJsonHex(blockCapsule1.getTransactions().size()), result); } @@ -199,15 +230,15 @@ public void testGetBlockTransactionCountByNumber() { } catch (Exception e) { Assert.fail(); } - Assert.assertEquals(ByteArray.toJsonHex(blockCapsule.getTransactions().size()), result); + Assert.assertEquals(ByteArray.toJsonHex(blockCapsule1.getTransactions().size()), result); try { - result = tronJsonRpc - .ethGetBlockTransactionCountByNumber(ByteArray.toJsonHex(blockCapsule.getNum())); + result = tronJsonRpc.ethGetBlockTransactionCountByNumber( + ByteArray.toJsonHex(blockCapsule1.getNum())); } catch (Exception e) { Assert.fail(); } - Assert.assertEquals(ByteArray.toJsonHex(blockCapsule.getTransactions().size()), result); + Assert.assertEquals(ByteArray.toJsonHex(blockCapsule1.getTransactions().size()), result); } @@ -215,32 +246,76 @@ public void testGetBlockTransactionCountByNumber() { public void testGetBlockByHash() { BlockResult blockResult = null; try { - blockResult = tronJsonRpc - .ethGetBlockByHash(Hex.toHexString((blockCapsule.getBlockId().getBytes())), false); + blockResult = + tronJsonRpc.ethGetBlockByHash(Hex.toHexString((blockCapsule1.getBlockId().getBytes())), + false); } catch (Exception e) { Assert.fail(); } - Assert.assertEquals(ByteArray.toJsonHex(blockCapsule.getNum()), blockResult.getNumber()); - Assert - .assertEquals(blockCapsule.getTransactions().size(), blockResult.getTransactions().length); + Assert.assertEquals(ByteArray.toJsonHex(blockCapsule1.getNum()), blockResult.getNumber()); + Assert.assertEquals(blockCapsule1.getTransactions().size(), + blockResult.getTransactions().length); } @Test public void testGetBlockByNumber() { BlockResult blockResult = null; + + // by number try { - blockResult = tronJsonRpc - .ethGetBlockByNumber(ByteArray.toJsonHex(blockCapsule.getNum()), false); + blockResult = + tronJsonRpc.ethGetBlockByNumber(ByteArray.toJsonHex(blockCapsule1.getNum()), false); } catch (Exception e) { Assert.fail(); } - - Assert.assertEquals(ByteArray.toJsonHex(blockCapsule.getNum()), blockResult.getNumber()); - Assert - .assertEquals(blockCapsule.getTransactions().size(), blockResult.getTransactions().length); + Assert.assertEquals(ByteArray.toJsonHex(blockCapsule1.getNum()), blockResult.getNumber()); + Assert.assertEquals(blockCapsule1.getTransactions().size(), + blockResult.getTransactions().length); Assert.assertEquals("0x0000000000000000", blockResult.getNonce()); - } + // earliest + try { + blockResult = tronJsonRpc.ethGetBlockByNumber("earliest", false); + } catch (Exception e) { + Assert.fail(); + } + Assert.assertEquals(ByteArray.toJsonHex(0L), blockResult.getNumber()); + Assert.assertEquals(ByteArray.toJsonHex(blockCapsule0.getNum()), blockResult.getNumber()); + + // latest + try { + blockResult = tronJsonRpc.ethGetBlockByNumber("latest", false); + } catch (Exception e) { + Assert.fail(); + } + Assert.assertEquals(ByteArray.toJsonHex(LATEST_BLOCK_NUM), blockResult.getNumber()); + Assert.assertEquals(ByteArray.toJsonHex(blockCapsule1.getNum()), blockResult.getNumber()); + + // finalized + try { + blockResult = tronJsonRpc.ethGetBlockByNumber("finalized", false); + } catch (Exception e) { + Assert.fail(); + } + Assert.assertEquals(ByteArray.toJsonHex(LATEST_SOLIDIFIED_BLOCK_NUM), blockResult.getNumber()); + Assert.assertEquals(ByteArray.toJsonHex(blockCapsule2.getNum()), blockResult.getNumber()); + + // pending + try { + tronJsonRpc.ethGetBlockByNumber("pending", false); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG pending not supported", e.getMessage()); + } + + // invalid + try { + tronJsonRpc.ethGetBlockByNumber("0x", false); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("invalid block number", e.getMessage()); + } + } @Test public void testGetTransactionByHash() { @@ -265,10 +340,9 @@ public void testGetTransactionByHash() { @Test public void testGetBlockByNumber2() { - fullNodeJsonRpcHttpService.init(Args.getInstance()); fullNodeJsonRpcHttpService.start(); JsonArray params = new JsonArray(); - params.add(ByteArray.toJsonHex(blockCapsule.getNum())); + params.add(ByteArray.toJsonHex(blockCapsule1.getNum())); params.add(false); JsonObject requestBody = new JsonObject(); requestBody.addProperty("jsonrpc", "2.0"); @@ -277,22 +351,21 @@ public void testGetBlockByNumber2() { requestBody.addProperty("id", 1); CloseableHttpResponse response; try (CloseableHttpClient httpClient = HttpClients.createDefault()) { - HttpPost httpPost = new HttpPost("http://127.0.0.1:8545/jsonrpc"); + HttpPost httpPost = new HttpPost("http://127.0.0.1/" + + CommonParameter.getInstance().getJsonRpcHttpFullNodePort() + "/jsonrpc"); httpPost.addHeader("Content-Type", "application/json"); httpPost.setEntity(new StringEntity(requestBody.toString())); response = httpClient.execute(httpPost); String resp = EntityUtils.toString(response.getEntity()); BlockResult blockResult = JSON.parseObject(resp).getObject("result", BlockResult.class); - Assert.assertEquals(ByteArray.toJsonHex(blockCapsule.getNum()), - blockResult.getNumber()); - Assert.assertEquals(blockCapsule.getTransactions().size(), + Assert.assertEquals(ByteArray.toJsonHex(blockCapsule1.getNum()), blockResult.getNumber()); + Assert.assertEquals(blockCapsule1.getTransactions().size(), blockResult.getTransactions().length); - Assert.assertEquals("0x0000000000000000", - blockResult.getNonce()); + Assert.assertEquals("0x0000000000000000", blockResult.getNonce()); response.close(); Assert.assertEquals(1, CollectorRegistry.defaultRegistry.getSampleValue( - "tron:jsonrpc_service_latency_seconds_count", - new String[] {"method"}, new String[] {"eth_getBlockByNumber"}).intValue()); + "tron:jsonrpc_service_latency_seconds_count", new String[] {"method"}, + new String[] {"eth_getBlockByNumber"}).intValue()); } catch (Exception e) { Assert.fail(e.getMessage()); } finally { @@ -303,9 +376,7 @@ public void testGetBlockByNumber2() { @Test public void testServicesInit() { try { - jsonRpcServiceOnPBFT.init(Args.getInstance()); jsonRpcServiceOnPBFT.start(); - jsonRpcServiceOnSolidity.init(Args.getInstance()); jsonRpcServiceOnSolidity.start(); } finally { jsonRpcServiceOnPBFT.stop(); @@ -313,4 +384,588 @@ public void testServicesInit() { } } + @Test + public void testGetByJsonBlockId() { + long blkNum = 0; + + try { + getByJsonBlockId("pending", wallet); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG pending not supported", e.getMessage()); + } + + try { + blkNum = getByJsonBlockId(null, wallet); + } catch (Exception e) { + Assert.fail(); + } + Assert.assertEquals(-1, blkNum); + + try { + blkNum = getByJsonBlockId("latest", wallet); + } catch (Exception e) { + Assert.fail(); + } + Assert.assertEquals(-1, blkNum); + + try { + blkNum = getByJsonBlockId("finalized", wallet); + } catch (Exception e) { + Assert.fail(); + } + Assert.assertEquals(LATEST_SOLIDIFIED_BLOCK_NUM, blkNum); + + try { + blkNum = getByJsonBlockId("0xa", wallet); + } catch (Exception e) { + Assert.fail(); + } + Assert.assertEquals(10L, blkNum); + + try { + getByJsonBlockId("abc", wallet); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("Incorrect hex syntax", e.getMessage()); + } + + try { + getByJsonBlockId("0xxabc", wallet); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("For input string: \"xabc\"", e.getMessage()); + } + } + + @Test + public void testGetTrxBalance() { + String balance = ""; + + try { + tronJsonRpc.getTrxBalance("", "earliest"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + + try { + tronJsonRpc.getTrxBalance("", "pending"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + + try { + tronJsonRpc.getTrxBalance("", "finalized"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + + try { + balance = tronJsonRpc.getTrxBalance("0xabd4b9367799eaa3197fecb144eb71de1e049abc", + "latest"); + } catch (Exception e) { + Assert.fail(); + } + Assert.assertEquals("0x2540be400", balance); + } + + @Test + public void testGetStorageAt() { + try { + tronJsonRpc.getStorageAt("", "", "earliest"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + + try { + tronJsonRpc.getStorageAt("", "", "pending"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + + try { + tronJsonRpc.getStorageAt("", "", "finalized"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + } + + @Test + public void testGetABIOfSmartContract() { + try { + tronJsonRpc.getABIOfSmartContract("", "earliest"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + + try { + tronJsonRpc.getABIOfSmartContract("", "pending"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + + try { + tronJsonRpc.getABIOfSmartContract("", "finalized"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + } + + @Test + public void testGetCall() { + try { + tronJsonRpc.getCall(null, "earliest"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + + try { + tronJsonRpc.getCall(null, "pending"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + + try { + tronJsonRpc.getCall(null, "finalized"); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("TAG [earliest | pending | finalized] not supported", + e.getMessage()); + } + } + + /** + * test fromBlock and toBlock parameters + */ + @Test + public void testLogFilterWrapper() { + + // fromBlock and toBlock are both empty + try { + LogFilterWrapper logFilterWrapper = + new LogFilterWrapper(new FilterRequest(null, null, null, null, null), 100, null, false); + Assert.assertEquals(100, logFilterWrapper.getFromBlock()); + Assert.assertEquals(Long.MAX_VALUE, logFilterWrapper.getToBlock()); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + // fromBlock is not empty and smaller than currentMaxBlockNum, toBlock is empty + try { + LogFilterWrapper logFilterWrapper = + new LogFilterWrapper(new FilterRequest("0x14", null, null, null, null), 100, null, false); + Assert.assertEquals(20, logFilterWrapper.getFromBlock()); + Assert.assertEquals(Long.MAX_VALUE, logFilterWrapper.getToBlock()); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + // fromBlock is not empty and bigger than currentMaxBlockNum, toBlock is empty + try { + LogFilterWrapper logFilterWrapper = + new LogFilterWrapper(new FilterRequest("0x78", null, null, null, null), 100, null, false); + Assert.assertEquals(120, logFilterWrapper.getFromBlock()); + Assert.assertEquals(Long.MAX_VALUE, logFilterWrapper.getToBlock()); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + // fromBlock is empty, toBlock is not empty and smaller than currentMaxBlockNum + try { + LogFilterWrapper logFilterWrapper = + new LogFilterWrapper(new FilterRequest(null, "0x14", null, null, null), 100, null, false); + Assert.assertEquals(20, logFilterWrapper.getFromBlock()); + Assert.assertEquals(20, logFilterWrapper.getToBlock()); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + // fromBlock is empty, toBlock is not empty and bigger than currentMaxBlockNum + try { + LogFilterWrapper logFilterWrapper = + new LogFilterWrapper(new FilterRequest(null, "0x78", null, null, null), 100, null, false); + Assert.assertEquals(100, logFilterWrapper.getFromBlock()); + Assert.assertEquals(120, logFilterWrapper.getToBlock()); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + // fromBlock is not empty, toBlock is not empty + try { + LogFilterWrapper logFilterWrapper = new LogFilterWrapper(new FilterRequest("0x14", "0x78", + null, null, null), 100, null, false); + Assert.assertEquals(20, logFilterWrapper.getFromBlock()); + Assert.assertEquals(120, logFilterWrapper.getToBlock()); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + try { + new LogFilterWrapper(new FilterRequest("0x78", "0x14", + null, null, null), 100, null, false); + Assert.fail("Expected to be thrown"); + } catch (JsonRpcInvalidParamsException e) { + Assert.assertEquals("please verify: fromBlock <= toBlock", e.getMessage()); + } + + //fromBlock or toBlock is not hex num + try { + LogFilterWrapper logFilterWrapper = new LogFilterWrapper(new FilterRequest("earliest", null, + null, null, null), 100, null, false); + Assert.assertEquals(0, logFilterWrapper.getFromBlock()); + Assert.assertEquals(Long.MAX_VALUE, logFilterWrapper.getToBlock()); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + try { + LogFilterWrapper logFilterWrapper = new LogFilterWrapper(new FilterRequest("latest", null, + null, null, null), 100, null, false); + Assert.assertEquals(100, logFilterWrapper.getFromBlock()); + Assert.assertEquals(Long.MAX_VALUE, logFilterWrapper.getToBlock()); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + try { + new LogFilterWrapper(new FilterRequest("pending", null, null, null, null), + 100, null, false); + Assert.fail("Expected to be thrown"); + } catch (JsonRpcInvalidParamsException e) { + Assert.assertEquals("TAG pending not supported", e.getMessage()); + } + try { + LogFilterWrapper logFilterWrapper = new LogFilterWrapper(new FilterRequest("finalized", null, + null, null, null), 100, wallet, false); + Assert.assertEquals(LATEST_SOLIDIFIED_BLOCK_NUM, logFilterWrapper.getFromBlock()); + Assert.assertEquals(Long.MAX_VALUE, logFilterWrapper.getToBlock()); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + try { + new LogFilterWrapper(new FilterRequest("test", null, null, null, null), + 100, null, false); + Assert.fail("Expected to be thrown"); + } catch (JsonRpcInvalidParamsException e) { + Assert.assertEquals("Incorrect hex syntax", e.getMessage()); + } + + // to = 8000 + try { + new LogFilterWrapper(new FilterRequest("0x0", "0x1f40", null, + null, null), LATEST_BLOCK_NUM, null, false); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + try { + new LogFilterWrapper(new FilterRequest("0x0", "0x1f40", null, + null, null), LATEST_BLOCK_NUM, null, true); + Assert.fail("Expected to be thrown"); + } catch (JsonRpcInvalidParamsException e) { + Assert.assertEquals( + "exceed max block range: " + Args.getInstance().jsonRpcMaxBlockRange, + e.getMessage()); + } + + try { + new LogFilterWrapper(new FilterRequest("0x0", "latest", null, + null, null), LATEST_BLOCK_NUM, null, false); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + try { + new LogFilterWrapper(new FilterRequest("0x0", "latest", null, + null, null), LATEST_BLOCK_NUM, null, true); + Assert.fail("Expected to be thrown"); + } catch (JsonRpcInvalidParamsException e) { + Assert.assertEquals( + "exceed max block range: " + Args.getInstance().jsonRpcMaxBlockRange, + e.getMessage()); + } + + // from = 100, current = 5_000, to = Long.MAX_VALUE + try { + new LogFilterWrapper(new FilterRequest("0x64", "latest", null, + null, null), 5_000, null, true); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + try { + new LogFilterWrapper(new FilterRequest("0x64", "latest", null, + null, null), LATEST_BLOCK_NUM, null, false); + } catch (Exception e) { + Assert.fail(); + } + + // from = 100 + try { + new LogFilterWrapper(new FilterRequest("0x64", "latest", null, + null, null), LATEST_BLOCK_NUM, null, true); + Assert.fail("Expected to be thrown"); + } catch (JsonRpcInvalidParamsException e) { + Assert.assertEquals( + "exceed max block range: " + Args.getInstance().jsonRpcMaxBlockRange, + e.getMessage()); + } + try { + new LogFilterWrapper(new FilterRequest("0x64", "latest", null, + null, null), LATEST_BLOCK_NUM, null, false); + } catch (Exception e) { + Assert.fail(); + } + + // from = 9_000 + try { + new LogFilterWrapper(new FilterRequest("0x2328", "latest", null, + null, null), LATEST_BLOCK_NUM, null, true); + } catch (Exception e) { + Assert.fail(); + } + try { + new LogFilterWrapper(new FilterRequest("0x2328", "latest", null, + null, null), LATEST_BLOCK_NUM, null, false); + } catch (Exception e) { + Assert.fail(); + } + + try { + new LogFilterWrapper(new FilterRequest("latest", "latest", null, + null, null), LATEST_BLOCK_NUM, null, true); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + try { + new LogFilterWrapper(new FilterRequest("latest", "latest", null, + null, null), LATEST_BLOCK_NUM, null, false); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + int oldMaxBlockRange = Args.getInstance().getJsonRpcMaxBlockRange(); + Args.getInstance().setJsonRpcMaxBlockRange(10_000); + try { + new LogFilterWrapper(new FilterRequest("0x0", "0x1f40", null, + null, null), LATEST_BLOCK_NUM, null, true); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + try { + new LogFilterWrapper(new FilterRequest("0x0", "0x1f40", null, + null, null), LATEST_BLOCK_NUM, null, false); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + Args.getInstance().setJsonRpcMaxBlockRange(0); + try { + new LogFilterWrapper(new FilterRequest("0x0", "0x1f40", null, + null, null), LATEST_BLOCK_NUM, null, true); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + try { + new LogFilterWrapper(new FilterRequest("0x0", "0x1f40", null, + null, null), LATEST_BLOCK_NUM, null, false); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + Args.getInstance().setJsonRpcMaxBlockRange(-2); + try { + new LogFilterWrapper(new FilterRequest("0x0", "0x1f40", null, + null, null), LATEST_BLOCK_NUM, null, true); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + try { + new LogFilterWrapper(new FilterRequest("0x0", "0x1f40", null, + null, null), LATEST_BLOCK_NUM, null, false); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + // reset + Args.getInstance().setJsonRpcMaxBlockRange(oldMaxBlockRange); + } + + @Test + public void testMaxSubTopics() { + List topics = new ArrayList<>(); + topics.add(new ArrayList<>(Collections.singletonList( + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"))); + topics.add(new ArrayList<>(Collections.EMPTY_LIST)); + List subTopics = new ArrayList<>(); + for (int i = 0; i < Args.getInstance().getJsonRpcMaxSubTopics() + 1; i++) { + subTopics.add("0x0000000000000000000000414de17123a3c706ab197957e131350b2537dd4883"); + } + topics.add(subTopics); + + try { + new LogFilterWrapper(new FilterRequest("0xbb8", "0x1f40", + null, topics.toArray(), null), LATEST_BLOCK_NUM, null, false); + Assert.fail("Expected to be thrown"); + } catch (JsonRpcInvalidParamsException e) { + Assert.assertEquals( + "exceed max topics: " + Args.getInstance().getJsonRpcMaxSubTopics(), + e.getMessage()); + } + + try { + tronJsonRpc.getLogs(new FilterRequest("0xbb8", "0x1f40", + null, topics.toArray(), null)); + Assert.fail("Expected to be thrown"); + } catch (JsonRpcInvalidParamsException e) { + Assert.assertEquals( + "exceed max topics: " + Args.getInstance().getJsonRpcMaxSubTopics(), + e.getMessage()); + } catch (Exception e) { + Assert.fail(); + } + + try { + tronJsonRpc.newFilter(new FilterRequest("0xbb8", "0x1f40", + null, topics.toArray(), null)); + Assert.fail("Expected to be thrown"); + } catch (JsonRpcInvalidParamsException e) { + Assert.assertEquals( + "exceed max topics: " + Args.getInstance().getJsonRpcMaxSubTopics(), + e.getMessage()); + } catch (Exception e) { + Assert.fail(); + } + + int oldMaxSubTopics = Args.getInstance().getJsonRpcMaxSubTopics(); + Args.getInstance().setJsonRpcMaxSubTopics(2_000); + try { + new LogFilterWrapper(new FilterRequest("0xbb8", "0x1f40", + null, topics.toArray(), null), LATEST_BLOCK_NUM, null, false); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + + Args.getInstance().setJsonRpcMaxSubTopics(0); + try { + new LogFilterWrapper(new FilterRequest("0xbb8", "0x1f40", + null, topics.toArray(), null), LATEST_BLOCK_NUM, null, false); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + try { + tronJsonRpc.newFilter(new FilterRequest("0xbb8", "0x1f40", + null, topics.toArray(), null)); + } catch (Exception e) { + Assert.fail(); + } + + Args.getInstance().setJsonRpcMaxSubTopics(-2); + try { + new LogFilterWrapper(new FilterRequest("0xbb8", "0x1f40", + null, topics.toArray(), null), LATEST_BLOCK_NUM, null, false); + } catch (JsonRpcInvalidParamsException e) { + Assert.fail(); + } + try { + tronJsonRpc.newFilter(new FilterRequest("0xbb8", "0x1f40", + null, topics.toArray(), null)); + } catch (Exception e) { + Assert.fail(); + } + + Args.getInstance().setJsonRpcMaxSubTopics(oldMaxSubTopics); + } + + @Test + public void testMethodBlockRange() { + try { + tronJsonRpc.getLogs(new FilterRequest("0x0", "0x1f40", null, + null, null)); + Assert.fail("Expected to be thrown"); + } catch (JsonRpcInvalidParamsException e) { + Assert.assertEquals( + "exceed max block range: " + Args.getInstance().jsonRpcMaxBlockRange, + e.getMessage()); + } catch (Exception e) { + Assert.fail(); + } + + try { + tronJsonRpc.newFilter(new FilterRequest("0x0", "0x1f40", null, + null, null)); + } catch (Exception e) { + Assert.fail(); + } + + try { + tronJsonRpc.getLogs(new FilterRequest("0x0", "0x1", null, + null, null)); + } catch (Exception e) { + Assert.fail(); + } + } + + @Test + public void testNewFilterFinalizedBlock() { + + try { + tronJsonRpc.newFilter(new FilterRequest(null, null, null, null, null)); + } catch (Exception e) { + Assert.fail(); + } + + try { + tronJsonRpc.newFilter(new FilterRequest("finalized", null, null, null, null)); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("invalid block range params", e.getMessage()); + } + + try { + tronJsonRpc.newFilter(new FilterRequest(null, "finalized", null, null, null)); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("invalid block range params", e.getMessage()); + } + + try { + tronJsonRpc.newFilter(new FilterRequest("finalized", "latest", null, null, null)); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("invalid block range params", e.getMessage()); + } + + try { + tronJsonRpc.newFilter(new FilterRequest("0x1", "finalized", null, null, null)); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("invalid block range params", e.getMessage()); + } + + try { + tronJsonRpc.newFilter(new FilterRequest("finalized", "finalized", null, null, null)); + Assert.fail("Expected to be thrown"); + } catch (Exception e) { + Assert.assertEquals("invalid block range params", e.getMessage()); + } + } } diff --git a/framework/src/test/java/org/tron/core/jsonrpc/SectionBloomStoreTest.java b/framework/src/test/java/org/tron/core/jsonrpc/SectionBloomStoreTest.java index 6e350a38999..111370bfffd 100644 --- a/framework/src/test/java/org/tron/core/jsonrpc/SectionBloomStoreTest.java +++ b/framework/src/test/java/org/tron/core/jsonrpc/SectionBloomStoreTest.java @@ -132,7 +132,7 @@ public void testWriteAndQuery() { try { LogFilterWrapper logFilterWrapper = new LogFilterWrapper( new FilterRequest("earliest", "latest", ByteArray.toJsonHex(address1), null, null), - currentMaxBlockNum, null); + currentMaxBlockNum, null, false); LogBlockQuery logBlockQuery = new LogBlockQuery(logFilterWrapper, sectionBloomStore, currentMaxBlockNum, sectionExecutor); @@ -149,7 +149,7 @@ public void testWriteAndQuery() { try { LogFilterWrapper logFilterWrapper = new LogFilterWrapper( new FilterRequest("earliest", "latest", addressList, null, null), - currentMaxBlockNum, null); + currentMaxBlockNum, null, false); LogBlockQuery logBlockQuery = new LogBlockQuery(logFilterWrapper, sectionBloomStore, currentMaxBlockNum, sectionExecutor); @@ -165,7 +165,7 @@ public void testWriteAndQuery() { LogFilterWrapper logFilterWrapper = new LogFilterWrapper( new FilterRequest("earliest", "latest", null, new String[] {ByteArray.toHexString(topic1)}, null), - currentMaxBlockNum, null); + currentMaxBlockNum, null, false); LogBlockQuery logBlockQuery = new LogBlockQuery(logFilterWrapper, sectionBloomStore, currentMaxBlockNum, sectionExecutor); @@ -181,7 +181,7 @@ public void testWriteAndQuery() { LogFilterWrapper logFilterWrapper = new LogFilterWrapper( new FilterRequest("earliest", "latest", null, new String[] {ByteArray.toHexString(topic2)}, null), - currentMaxBlockNum, null); + currentMaxBlockNum, null, false); LogBlockQuery logBlockQuery = new LogBlockQuery(logFilterWrapper, sectionBloomStore, currentMaxBlockNum, sectionExecutor); @@ -199,7 +199,7 @@ public void testWriteAndQuery() { LogFilterWrapper logFilterWrapper = new LogFilterWrapper( new FilterRequest("earliest", "latest", null, new Object[] {topicList}, null), - currentMaxBlockNum, null); + currentMaxBlockNum, null, false); LogBlockQuery logBlockQuery = new LogBlockQuery(logFilterWrapper, sectionBloomStore, currentMaxBlockNum, sectionExecutor); @@ -226,7 +226,7 @@ public void testWriteAndQuery() { LogFilterWrapper logFilterWrapper = new LogFilterWrapper( new FilterRequest("earliest", "latest", null, new Object[] {ByteArray.toJsonHex(topic1), ByteArray.toJsonHex(topic2)}, null), - currentMaxBlockNum, null); + currentMaxBlockNum, null, false); LogBlockQuery logBlockQuery = new LogBlockQuery(logFilterWrapper, sectionBloomStore, currentMaxBlockNum, sectionExecutor); diff --git a/framework/src/test/java/org/tron/core/metrics/MetricsApiServiceTest.java b/framework/src/test/java/org/tron/core/metrics/MetricsApiServiceTest.java index 51a46b09388..e36029c6141 100644 --- a/framework/src/test/java/org/tron/core/metrics/MetricsApiServiceTest.java +++ b/framework/src/test/java/org/tron/core/metrics/MetricsApiServiceTest.java @@ -44,7 +44,7 @@ public void init() throws IOException { "--storage-db-directory", dbDirectory, "--storage-index-directory", indexDirectory }, - "config.conf" + Constant.TEST_CONF ); CommonParameter parameter = Args.getInstance(); parameter.setNodeListenPort(port); @@ -52,9 +52,7 @@ public void init() throws IOException { parameter.setNodeExternalIp("127.0.0.1"); context = new TronApplicationContext(DefaultConfig.class); appT = ApplicationFactory.create(context); - rpcApiService = context.getBean(RpcApiService.class); metricsApiService = context.getBean(MetricsApiService.class); - appT.addService(rpcApiService); appT.startup(); } diff --git a/framework/src/test/java/org/tron/core/metrics/prometheus/PrometheusApiServiceTest.java b/framework/src/test/java/org/tron/core/metrics/prometheus/PrometheusApiServiceTest.java index 1c6e56cbbbe..195e4749209 100644 --- a/framework/src/test/java/org/tron/core/metrics/prometheus/PrometheusApiServiceTest.java +++ b/framework/src/test/java/org/tron/core/metrics/prometheus/PrometheusApiServiceTest.java @@ -55,7 +55,7 @@ public class PrometheusApiServiceTest extends BaseTest { private ChainBaseManager chainManager; static { - Args.setParam(new String[] {"-d", dbPath(), "-w"}, Constant.TEST_CONF); + Args.setParam(new String[] {"-d", dbPath()}, Constant.TEST_CONF); Args.getInstance().setNodeListenPort(10000 + port.incrementAndGet()); initParameter(Args.getInstance()); Metrics.init(); diff --git a/framework/src/test/java/org/tron/core/net/BaseNet.java b/framework/src/test/java/org/tron/core/net/BaseNet.java index 7ae8b355168..65771bae952 100644 --- a/framework/src/test/java/org/tron/core/net/BaseNet.java +++ b/framework/src/test/java/org/tron/core/net/BaseNet.java @@ -30,12 +30,12 @@ import org.tron.common.application.TronApplicationContext; import org.tron.common.parameter.CommonParameter; import org.tron.common.utils.FileUtil; +import org.tron.common.utils.PublicMethod; import org.tron.common.utils.ReflectUtils; import org.tron.core.Constant; import org.tron.core.config.DefaultConfig; import org.tron.core.config.args.Args; import org.tron.core.net.peer.PeerConnection; -import org.tron.core.services.RpcApiService; @Slf4j public class BaseNet { @@ -48,7 +48,6 @@ public class BaseNet { protected static TronApplicationContext context; - private static RpcApiService rpcApiService; private static Application appT; private static TronNetDelegate tronNetDelegate; @@ -98,10 +97,15 @@ public static void init() throws Exception { parameter.setNodeListenPort(port); parameter.getSeedNode().getAddressList().clear(); parameter.setNodeExternalIp(Constant.LOCAL_HOST); + parameter.setRpcEnable(true); + parameter.setRpcPort(PublicMethod.chooseRandomPort()); + parameter.setRpcSolidityEnable(false); + parameter.setRpcPBFTEnable(false); + parameter.setFullNodeHttpEnable(false); + parameter.setSolidityNodeHttpEnable(false); + parameter.setPBFTHttpEnable(false); context = new TronApplicationContext(DefaultConfig.class); appT = ApplicationFactory.create(context); - rpcApiService = context.getBean(RpcApiService.class); - appT.addService(rpcApiService); appT.startup(); try { Thread.sleep(2000); diff --git a/framework/src/test/java/org/tron/core/net/P2pEventHandlerImplTest.java b/framework/src/test/java/org/tron/core/net/P2pEventHandlerImplTest.java index 0008ec315d5..e0c816a537a 100644 --- a/framework/src/test/java/org/tron/core/net/P2pEventHandlerImplTest.java +++ b/framework/src/test/java/org/tron/core/net/P2pEventHandlerImplTest.java @@ -12,10 +12,13 @@ import org.tron.common.utils.Sha256Hash; import org.tron.core.Constant; import org.tron.core.config.args.Args; +import org.tron.core.net.message.TronMessage; +import org.tron.core.net.message.adv.FetchInvDataMessage; import org.tron.core.net.message.adv.InventoryMessage; import org.tron.core.net.peer.PeerConnection; import org.tron.core.net.service.statistics.PeerStatistics; import org.tron.protos.Protocol; +import org.tron.protos.Protocol.Inventory.InventoryType; public class P2pEventHandlerImplTest { @@ -108,4 +111,22 @@ public void testProcessInventoryMessage() throws Exception { Assert.assertEquals(300, count); } + + @Test + public void testUpdateLastInteractiveTime() throws Exception { + String[] a = new String[0]; + Args.setParam(a, Constant.TESTNET_CONF); + + PeerConnection peer = new PeerConnection(); + P2pEventHandlerImpl p2pEventHandler = new P2pEventHandlerImpl(); + + Method method = p2pEventHandler.getClass() + .getDeclaredMethod("updateLastInteractiveTime", PeerConnection.class, TronMessage.class); + method.setAccessible(true); + + long t1 = System.currentTimeMillis(); + FetchInvDataMessage message = new FetchInvDataMessage(new ArrayList<>(), InventoryType.BLOCK); + method.invoke(p2pEventHandler, peer, message); + Assert.assertTrue(peer.getLastInteractiveTime() >= t1); + } } diff --git a/framework/src/test/java/org/tron/core/net/TronNetDelegateTest.java b/framework/src/test/java/org/tron/core/net/TronNetDelegateTest.java new file mode 100644 index 00000000000..6550766d702 --- /dev/null +++ b/framework/src/test/java/org/tron/core/net/TronNetDelegateTest.java @@ -0,0 +1,52 @@ +package org.tron.core.net; + +import static org.mockito.Mockito.mock; + +import java.lang.reflect.Field; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.tron.common.parameter.CommonParameter; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.ChainBaseManager; +import org.tron.core.Constant; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.config.args.Args; + +public class TronNetDelegateTest { + + @Test + public void test() throws Exception { + Args.setParam(new String[] {}, Constant.TEST_CONF); + CommonParameter parameter = Args.getInstance(); + Args.logConfig(); + parameter.setUnsolidifiedBlockCheck(true); + + BlockCapsule.BlockId blockId = new BlockCapsule.BlockId(Sha256Hash.ZERO_HASH, 10000L); + + TronNetDelegate tronNetDelegate = new TronNetDelegate(); + + ChainBaseManager chainBaseManager = mock(ChainBaseManager.class); + Mockito.when(chainBaseManager.getHeadBlockNum()).thenReturn(10000L); + Mockito.when(chainBaseManager.getSolidBlockId()).thenReturn(blockId); + + Field field = tronNetDelegate.getClass().getDeclaredField("chainBaseManager"); + field.setAccessible(true); + field.set(tronNetDelegate, chainBaseManager); + + Assert.assertTrue(!tronNetDelegate.isBlockUnsolidified()); + + blockId = new BlockCapsule.BlockId(Sha256Hash.ZERO_HASH, 1L); + Mockito.when(chainBaseManager.getSolidBlockId()).thenReturn(blockId); + Assert.assertTrue(tronNetDelegate.isBlockUnsolidified()); + + parameter.setUnsolidifiedBlockCheck(false); + tronNetDelegate = new TronNetDelegate(); + + field = tronNetDelegate.getClass().getDeclaredField("unsolidifiedBlockCheck"); + field.setAccessible(true); + field.set(tronNetDelegate, false); + + Assert.assertTrue(!tronNetDelegate.isBlockUnsolidified()); + } +} diff --git a/framework/src/test/java/org/tron/core/net/messagehandler/BlockMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/BlockMsgHandlerTest.java index 8154d01aded..48e7d730520 100644 --- a/framework/src/test/java/org/tron/core/net/messagehandler/BlockMsgHandlerTest.java +++ b/framework/src/test/java/org/tron/core/net/messagehandler/BlockMsgHandlerTest.java @@ -1,26 +1,33 @@ package org.tron.core.net.messagehandler; import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; import com.google.common.collect.ImmutableList; import com.google.protobuf.ByteString; - import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.net.InetSocketAddress; +import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; - import lombok.extern.slf4j.Slf4j; +import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.mockito.Mockito; import org.tron.common.BaseTest; +import org.tron.common.utils.ByteArray; import org.tron.common.utils.Sha256Hash; import org.tron.core.Constant; import org.tron.core.capsule.BlockCapsule; +import org.tron.core.capsule.BlockCapsule.BlockId; import org.tron.core.config.Parameter; import org.tron.core.config.args.Args; import org.tron.core.exception.P2pException; +import org.tron.core.net.TronNetDelegate; import org.tron.core.net.message.adv.BlockMessage; import org.tron.core.net.peer.Item; import org.tron.core.net.peer.PeerConnection; @@ -41,9 +48,8 @@ public class BlockMsgHandlerTest extends BaseTest { */ @BeforeClass public static void init() { - Args.setParam(new String[]{"--output-directory", dbPath(), "--debug"}, + Args.setParam(new String[] {"--output-directory", dbPath(), "--debug"}, Constant.TEST_CONF); - } @Before @@ -123,4 +129,42 @@ public void testProcessMessage() { logger.error("error", e); } } + + @Test + public void testProcessBlock() { + TronNetDelegate tronNetDelegate = Mockito.mock(TronNetDelegate.class); + + try { + Field field = handler.getClass().getDeclaredField("tronNetDelegate"); + field.setAccessible(true); + field.set(handler, tronNetDelegate); + + BlockCapsule blockCapsule0 = new BlockCapsule(1, + Sha256Hash.wrap(ByteString + .copyFrom(ByteArray + .fromHexString( + "9938a342238077182498b464ac0292229938a342238077182498b464ac029222"))), + 1234, + ByteString.copyFrom("1234567".getBytes())); + + peer.getAdvInvReceive() + .put(new Item(blockCapsule0.getBlockId(), InventoryType.BLOCK), + System.currentTimeMillis()); + + Mockito.doReturn(true).when(tronNetDelegate).validBlock(any(BlockCapsule.class)); + Mockito.doReturn(true).when(tronNetDelegate).containBlock(any(BlockId.class)); + Mockito.doReturn(blockCapsule0.getBlockId()).when(tronNetDelegate).getHeadBlockId(); + Mockito.doNothing().when(tronNetDelegate).processBlock(any(BlockCapsule.class), anyBoolean()); + List peers = new ArrayList<>(); + peers.add(peer); + Mockito.doReturn(peers).when(tronNetDelegate).getActivePeer(); + + Method method = handler.getClass() + .getDeclaredMethod("processBlock", PeerConnection.class, BlockCapsule.class); + method.setAccessible(true); + method.invoke(handler, peer, blockCapsule0); + } catch (Exception e) { + Assert.fail(); + } + } } diff --git a/framework/src/test/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandlerTest.java index 95cb9d0597f..dab76cfcb46 100644 --- a/framework/src/test/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandlerTest.java +++ b/framework/src/test/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandlerTest.java @@ -9,6 +9,7 @@ import org.tron.core.capsule.BlockCapsule.BlockId; import org.tron.core.config.Parameter.NetConstants; import org.tron.core.exception.P2pException; +import org.tron.core.net.message.keepalive.PingMessage; import org.tron.core.net.message.sync.ChainInventoryMessage; import org.tron.core.net.peer.PeerConnection; @@ -20,11 +21,11 @@ public class ChainInventoryMsgHandlerTest { private List blockIds = new ArrayList<>(); @Test - public void testProcessMessage() { + public void testProcessMessage() throws Exception { try { handler.processMessage(peer, msg); } catch (P2pException e) { - Assert.assertTrue(e.getMessage().equals("not send syncBlockChainMsg")); + Assert.assertEquals("not send syncBlockChainMsg", e.getMessage()); } peer.setSyncChainRequested(new Pair<>(new LinkedList<>(), System.currentTimeMillis())); @@ -32,7 +33,7 @@ public void testProcessMessage() { try { handler.processMessage(peer, msg); } catch (P2pException e) { - Assert.assertTrue(e.getMessage().equals("blockIds is empty")); + Assert.assertEquals("blockIds is empty", e.getMessage()); } long size = NetConstants.SYNC_FETCH_BATCH_NUM + 2; @@ -44,7 +45,7 @@ public void testProcessMessage() { try { handler.processMessage(peer, msg); } catch (P2pException e) { - Assert.assertTrue(e.getMessage().equals("big blockIds size: " + size)); + Assert.assertEquals(e.getMessage(), "big blockIds size: " + size); } blockIds.clear(); @@ -57,8 +58,10 @@ public void testProcessMessage() { try { handler.processMessage(peer, msg); } catch (P2pException e) { - Assert.assertTrue(e.getMessage().equals("remain: 100, blockIds size: " + size)); + Assert.assertEquals(e.getMessage(), "remain: 100, blockIds size: " + size); } + Assert.assertNotNull(msg.toString()); + Assert.assertNull(msg.getAnswerMessage()); } } diff --git a/framework/src/test/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandlerTest.java index 404d275276a..5fd6d6725ba 100644 --- a/framework/src/test/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandlerTest.java +++ b/framework/src/test/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandlerTest.java @@ -21,8 +21,6 @@ import org.tron.core.net.service.adv.AdvService; import org.tron.protos.Protocol; - - public class FetchInvDataMsgHandlerTest { @Test @@ -62,4 +60,37 @@ public void testProcessMessage() throws Exception { new FetchInvDataMessage(blockIds, Protocol.Inventory.InventoryType.BLOCK)); Assert.assertNotNull(syncBlockIdCache.getIfPresent(blockId)); } + + @Test + public void testSyncFetchCheck() { + BlockCapsule.BlockId blockId = new BlockCapsule.BlockId(Sha256Hash.ZERO_HASH, 10000L); + List blockIds = new LinkedList<>(); + blockIds.add(blockId); + FetchInvDataMessage msg = + new FetchInvDataMessage(blockIds, Protocol.Inventory.InventoryType.BLOCK); + + PeerConnection peer = Mockito.mock(PeerConnection.class); + Mockito.when(peer.isNeedSyncFromUs()).thenReturn(true); + Cache advInvSpread = CacheBuilder.newBuilder().maximumSize(100) + .expireAfterWrite(1, TimeUnit.HOURS).recordStats().build(); + Mockito.when(peer.getAdvInvSpread()).thenReturn(advInvSpread); + + FetchInvDataMsgHandler fetchInvDataMsgHandler = new FetchInvDataMsgHandler(); + + try { + Mockito.when(peer.getLastSyncBlockId()) + .thenReturn(new BlockCapsule.BlockId(Sha256Hash.ZERO_HASH, 1000L)); + fetchInvDataMsgHandler.processMessage(peer, msg); + } catch (Exception e) { + Assert.assertEquals(e.getMessage(), "maxBlockNum: 1000, blockNum: 10000"); + } + + try { + Mockito.when(peer.getLastSyncBlockId()) + .thenReturn(new BlockCapsule.BlockId(Sha256Hash.ZERO_HASH, 20000L)); + fetchInvDataMsgHandler.processMessage(peer, msg); + } catch (Exception e) { + Assert.assertEquals(e.getMessage(), "minBlockNum: 16000, blockNum: 10000"); + } + } } diff --git a/framework/src/test/java/org/tron/core/net/messagehandler/InventoryMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/InventoryMsgHandlerTest.java index 97db6207b2a..0864c872bc3 100644 --- a/framework/src/test/java/org/tron/core/net/messagehandler/InventoryMsgHandlerTest.java +++ b/framework/src/test/java/org/tron/core/net/messagehandler/InventoryMsgHandlerTest.java @@ -1,10 +1,16 @@ package org.tron.core.net.messagehandler; +import static org.mockito.Mockito.mock; + import java.lang.reflect.Field; import java.net.InetAddress; import java.net.InetSocketAddress; import java.util.ArrayList; import org.junit.Test; +import org.mockito.Mockito; +import org.tron.core.Constant; +import org.tron.core.config.args.Args; +import org.tron.core.net.TronNetDelegate; import org.tron.core.net.message.adv.InventoryMessage; import org.tron.core.net.peer.PeerConnection; import org.tron.p2p.connection.Channel; @@ -12,10 +18,12 @@ public class InventoryMsgHandlerTest { - private InventoryMsgHandler handler = new InventoryMsgHandler(); - @Test public void testProcessMessage() throws Exception { + InventoryMsgHandler handler = new InventoryMsgHandler(); + Args.setParam(new String[] {}, Constant.TEST_CONF); + Args.logConfig(); + InventoryMessage msg = new InventoryMessage(new ArrayList<>(), InventoryType.TRX); PeerConnection peer = new PeerConnection(); peer.setChannel(getChannel("1.0.0.3", 1000)); @@ -31,6 +39,16 @@ public void testProcessMessage() throws Exception { peer.setNeedSyncFromUs(true); handler.processMessage(peer, msg); + peer.setNeedSyncFromUs(false); + + TronNetDelegate tronNetDelegate = mock(TronNetDelegate.class); + Mockito.when(tronNetDelegate.isBlockUnsolidified()).thenReturn(true); + + Field field = handler.getClass().getDeclaredField("tronNetDelegate"); + field.setAccessible(true); + field.set(handler, tronNetDelegate); + + handler.processMessage(peer, msg); } private Channel getChannel(String host, int port) throws Exception { diff --git a/framework/src/test/java/org/tron/core/net/messagehandler/PbftDataSyncHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/PbftDataSyncHandlerTest.java index d1fdfaa5d90..e5d242a6c4d 100644 --- a/framework/src/test/java/org/tron/core/net/messagehandler/PbftDataSyncHandlerTest.java +++ b/framework/src/test/java/org/tron/core/net/messagehandler/PbftDataSyncHandlerTest.java @@ -32,9 +32,6 @@ public void testProcessMessage() throws Exception { Protocol.PBFTMessage.Raw raw = rawBuilder.build(); PbftSignCapsule pbftSignCapsule = new PbftSignCapsule(raw.toByteString(), new ArrayList<>()); PbftCommitMessage pbftCommitMessage = new PbftCommitMessage(pbftSignCapsule); - pbftDataSyncHandler.processMessage(null, pbftCommitMessage); - Assert.assertEquals(Protocol.PBFTMessage.Raw.parseFrom( - pbftCommitMessage.getPBFTCommitResult().getData()).getViewN(), 1); DynamicPropertiesStore dynamicPropertiesStore = Mockito.mock(DynamicPropertiesStore.class); PbftSignDataStore pbftSignDataStore = Mockito.mock(PbftSignDataStore.class); @@ -48,6 +45,10 @@ public void testProcessMessage() throws Exception { field.setAccessible(true); field.set(pbftDataSyncHandler, chainBaseManager); + pbftDataSyncHandler.processMessage(null, pbftCommitMessage); + Assert.assertEquals(Protocol.PBFTMessage.Raw.parseFrom( + pbftCommitMessage.getPBFTCommitResult().getData()).getViewN(), 1); + pbftDataSyncHandler.processPBFTCommitData(blockCapsule); Field field1 = PbftDataSyncHandler.class.getDeclaredField("pbftCommitMessageCache"); field1.setAccessible(true); diff --git a/framework/src/test/java/org/tron/core/net/messagehandler/PbftMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/PbftMsgHandlerTest.java index 3fec10fc163..8b9d1969cfc 100644 --- a/framework/src/test/java/org/tron/core/net/messagehandler/PbftMsgHandlerTest.java +++ b/framework/src/test/java/org/tron/core/net/messagehandler/PbftMsgHandlerTest.java @@ -34,6 +34,7 @@ import org.tron.core.net.message.MessageTypes; import org.tron.core.net.peer.PeerConnection; import org.tron.core.net.peer.PeerManager; +import org.tron.core.store.DynamicPropertiesStore; import org.tron.p2p.P2pConfig; import org.tron.p2p.base.Parameter; import org.tron.p2p.connection.Channel; @@ -116,6 +117,14 @@ public void testPbft() throws Exception { Assert.assertEquals(P2pException.TypeEnum.BAD_MESSAGE, e.getType()); } + DynamicPropertiesStore dynamicPropertiesStore = context.getBean(DynamicPropertiesStore.class); + dynamicPropertiesStore.saveAllowPBFT(1); + try { + context.getBean(PbftMsgHandler.class).processMessage(peer, pbftMessage); + } catch (P2pException e) { + Assert.assertEquals(P2pException.TypeEnum.BAD_MESSAGE, e.getType()); + } + Assert.assertEquals(1, PeerManager.getPeers().size()); } } diff --git a/framework/src/test/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandlerTest.java index d4ad32dd34f..e654e1c9cc2 100644 --- a/framework/src/test/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandlerTest.java +++ b/framework/src/test/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandlerTest.java @@ -19,6 +19,7 @@ import org.tron.core.config.DefaultConfig; import org.tron.core.config.args.Args; import org.tron.core.exception.P2pException; +import org.tron.core.net.message.sync.BlockInventoryMessage; import org.tron.core.net.message.sync.SyncBlockChainMessage; import org.tron.core.net.peer.PeerConnection; import org.tron.p2p.connection.Channel; @@ -56,7 +57,7 @@ public void testProcessMessage() throws Exception { try { handler.processMessage(peer, new SyncBlockChainMessage(new ArrayList<>())); } catch (P2pException e) { - Assert.assertTrue(e.getMessage().equals("SyncBlockChain blockIds is empty")); + Assert.assertEquals("SyncBlockChain blockIds is empty", e.getMessage()); } List blockIds = new ArrayList<>(); @@ -66,7 +67,10 @@ public void testProcessMessage() throws Exception { "check", PeerConnection.class, SyncBlockChainMessage.class); method.setAccessible(true); boolean f = (boolean)method.invoke(handler, peer, message); - Assert.assertTrue(!f); + Assert.assertNotNull(message.getAnswerMessage()); + Assert.assertNotNull(message.toString()); + Assert.assertNotNull(((BlockInventoryMessage) message).getAnswerMessage()); + Assert.assertFalse(f); Method method1 = handler.getClass().getDeclaredMethod( "getLostBlockIds", List.class, BlockId.class); @@ -80,7 +84,7 @@ public void testProcessMessage() throws Exception { Method method2 = handler.getClass().getDeclaredMethod( "getBlockIds", Long.class, BlockId.class); method2.setAccessible(true); - List list = (List) method2.invoke(handler, 0L, new BlockCapsule.BlockId()); + List list = (List) method2.invoke(handler, 0L, new BlockCapsule.BlockId()); Assert.assertEquals(1, list.size()); } diff --git a/framework/src/test/java/org/tron/core/net/messagehandler/TransactionsMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/TransactionsMsgHandlerTest.java index 47ffde30ac3..54e5f78d85a 100644 --- a/framework/src/test/java/org/tron/core/net/messagehandler/TransactionsMsgHandlerTest.java +++ b/framework/src/test/java/org/tron/core/net/messagehandler/TransactionsMsgHandlerTest.java @@ -6,13 +6,18 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.concurrent.BlockingQueue; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.LinkedBlockingQueue; + +import lombok.Getter; import org.joda.time.DateTime; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; import org.tron.common.BaseTest; +import org.tron.common.runtime.TvmTestUtils; import org.tron.common.utils.ByteArray; import org.tron.core.Constant; import org.tron.core.config.args.Args; @@ -75,10 +80,71 @@ public void testProcessMessage() { transactionsMsgHandler.processMessage(peer, new TransactionsMessage(transactionList)); Assert.assertNull(advInvRequest.get(item)); //Thread.sleep(10); + transactionsMsgHandler.close(); + BlockingQueue smartContractQueue = + new LinkedBlockingQueue(2); + smartContractQueue.offer(new TrxEvent(null, null)); + smartContractQueue.offer(new TrxEvent(null, null)); + Field field1 = TransactionsMsgHandler.class.getDeclaredField("smartContractQueue"); + field1.setAccessible(true); + field1.set(transactionsMsgHandler, smartContractQueue); + Protocol.Transaction trx1 = TvmTestUtils.generateTriggerSmartContractAndGetTransaction( + ByteArray.fromHexString("121212a9cf"), + ByteArray.fromHexString("121212a9cf"), + ByteArray.fromHexString("123456"), + 100, 100000000, 0, 0); + Map advInvRequest1 = new ConcurrentHashMap<>(); + Item item1 = new Item(new TransactionMessage(trx1).getMessageId(), + Protocol.Inventory.InventoryType.TRX); + advInvRequest1.put(item1, 0L); + Mockito.when(peer.getAdvInvRequest()).thenReturn(advInvRequest1); + List transactionList1 = new ArrayList<>(); + transactionList1.add(trx1); + transactionsMsgHandler.processMessage(peer, new TransactionsMessage(transactionList1)); + Assert.assertNull(advInvRequest.get(item1)); + + // test 0 contract + Protocol.Transaction trx2 = Protocol.Transaction.newBuilder().setRawData( + Protocol.Transaction.raw.newBuilder().setTimestamp(transactionTimestamp) + .setRefBlockNum(1).build()) + .build(); + List transactionList2 = new ArrayList<>(); + transactionList2.add(trx2); + try { + transactionsMsgHandler.processMessage(peer, new TransactionsMessage(transactionList2)); + } catch (Exception ep) { + Assert.assertTrue(true); + } + Map advInvRequest2 = new ConcurrentHashMap<>(); + Item item2 = new Item(new TransactionMessage(trx2).getMessageId(), + Protocol.Inventory.InventoryType.TRX); + advInvRequest2.put(item2, 0L); + Mockito.when(peer.getAdvInvRequest()).thenReturn(advInvRequest2); + try { + transactionsMsgHandler.processMessage(peer, new TransactionsMessage(transactionList2)); + } catch (Exception ep) { + Assert.assertTrue(true); + } } catch (Exception e) { Assert.fail(); } finally { transactionsMsgHandler.close(); } } + + class TrxEvent { + + @Getter + private PeerConnection peer; + @Getter + private TransactionMessage msg; + @Getter + private long time; + + public TrxEvent(PeerConnection peer, TransactionMessage msg) { + this.peer = peer; + this.msg = msg; + this.time = System.currentTimeMillis(); + } + } } diff --git a/framework/src/test/java/org/tron/core/net/peer/PeerConnectionTest.java b/framework/src/test/java/org/tron/core/net/peer/PeerConnectionTest.java index c0d81ca2763..5a67cd8f609 100644 --- a/framework/src/test/java/org/tron/core/net/peer/PeerConnectionTest.java +++ b/framework/src/test/java/org/tron/core/net/peer/PeerConnectionTest.java @@ -60,9 +60,9 @@ public void testOnDisconnect() { peerConnection.onDisconnect(); - //Assert.assertEquals(0, peerConnection.getAdvInvReceive().size()); - //Assert.assertEquals(0, peerConnection.getAdvInvSpread().size()); - //Assert.assertEquals(0, peerConnection.getSyncBlockIdCache().size()); + Assert.assertEquals(0, peerConnection.getAdvInvReceive().size()); + Assert.assertEquals(0, peerConnection.getAdvInvSpread().size()); + Assert.assertEquals(0, peerConnection.getSyncBlockIdCache().size()); Assert.assertEquals(0, peerConnection.getSyncBlockToFetch().size()); Assert.assertEquals(0, peerConnection.getSyncBlockRequested().size()); Assert.assertEquals(0, peerConnection.getSyncBlockInProcess().size()); @@ -98,6 +98,36 @@ public void testIsIdle() { Assert.assertTrue(!f); } + @Test + public void testIsSyncIdle() { + PeerConnection peerConnection = new PeerConnection(); + boolean f = peerConnection.isSyncIdle(); + Assert.assertTrue(f); + + Item item = new Item(Sha256Hash.ZERO_HASH, Protocol.Inventory.InventoryType.TRX); + Long time = System.currentTimeMillis(); + peerConnection.getAdvInvRequest().put(item, time); + f = peerConnection.isSyncIdle(); + Assert.assertTrue(f); + + peerConnection.getAdvInvRequest().clear(); + f = peerConnection.isSyncIdle(); + Assert.assertTrue(f); + + BlockCapsule.BlockId blockId = new BlockCapsule.BlockId(); + peerConnection.getSyncBlockRequested().put(blockId, time); + f = peerConnection.isSyncIdle(); + Assert.assertTrue(!f); + + peerConnection.getSyncBlockRequested().clear(); + f = peerConnection.isSyncIdle(); + Assert.assertTrue(f); + + peerConnection.setSyncChainRequested(new Pair<>(new LinkedList<>(), time)); + f = peerConnection.isSyncIdle(); + Assert.assertTrue(!f); + } + @Test public void testOnConnect() { PeerConnection peerConnection = new PeerConnection(); diff --git a/framework/src/test/java/org/tron/core/net/peer/PeerManagerTest.java b/framework/src/test/java/org/tron/core/net/peer/PeerManagerTest.java index a6151da6d1c..b8c03de1029 100644 --- a/framework/src/test/java/org/tron/core/net/peer/PeerManagerTest.java +++ b/framework/src/test/java/org/tron/core/net/peer/PeerManagerTest.java @@ -135,4 +135,32 @@ public void testGetPeers() throws Exception { Assert.assertEquals(2, peers.size()); } + @Test + public void testSortPeers() throws Exception { + PeerConnection p1 = new PeerConnection(); + PeerConnection p2 = new PeerConnection(); + + List peers = new ArrayList<>(); + peers.add(p1); + peers.add(p2); + + Field field = PeerManager.class.getDeclaredField("peers"); + field.setAccessible(true); + field.set(PeerManager.class, Collections.synchronizedList(peers)); + + PeerManager.sortPeers(); + + Channel c1 = new Channel(); + c1.updateAvgLatency(100000L); + ReflectUtils.setFieldValue(p1, "channel", c1); + + Channel c2 = new Channel(); + c2.updateAvgLatency(1000L); + ReflectUtils.setFieldValue(p2, "channel", c2); + + PeerManager.sortPeers(); + + Assert.assertEquals(PeerManager.getPeers().get(0), p2); + } + } diff --git a/framework/src/test/java/org/tron/core/net/peer/PeerStatusCheckMockTest.java b/framework/src/test/java/org/tron/core/net/peer/PeerStatusCheckMockTest.java new file mode 100644 index 00000000000..80b1abdc35d --- /dev/null +++ b/framework/src/test/java/org/tron/core/net/peer/PeerStatusCheckMockTest.java @@ -0,0 +1,26 @@ +package org.tron.core.net.peer; + +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.spy; + +import org.junit.After; +import org.junit.Test; +import org.mockito.Mockito; + +public class PeerStatusCheckMockTest { + @After + public void clearMocks() { + Mockito.framework().clearInlineMocks(); + } + + @Test + public void testInitException() throws InterruptedException { + PeerStatusCheck peerStatusCheck = spy(new PeerStatusCheck()); + doThrow(new RuntimeException("test exception")).when(peerStatusCheck).statusCheck(); + peerStatusCheck.init(); + + // the initialDelay of scheduleWithFixedDelay is 5s + Thread.sleep(5000L); + } + +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/net/peer/PeerStatusCheckTest.java b/framework/src/test/java/org/tron/core/net/peer/PeerStatusCheckTest.java new file mode 100644 index 00000000000..53e678c7ca4 --- /dev/null +++ b/framework/src/test/java/org/tron/core/net/peer/PeerStatusCheckTest.java @@ -0,0 +1,73 @@ +package org.tron.core.net.peer; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.spy; + +import io.netty.channel.ChannelHandlerContext; +import java.io.IOException; +import java.net.InetSocketAddress; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.mockito.Mockito; +import org.tron.common.application.TronApplicationContext; +import org.tron.common.utils.ReflectUtils; +import org.tron.core.Constant; +import org.tron.core.capsule.BlockCapsule.BlockId; +import org.tron.core.config.DefaultConfig; +import org.tron.core.config.Parameter.NetConstants; +import org.tron.core.config.args.Args; +import org.tron.p2p.connection.Channel; + + +public class PeerStatusCheckTest { + + protected TronApplicationContext context; + private PeerStatusCheck service; + @Rule + public final TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @Before + public void init() throws IOException { + Args.setParam(new String[] {"--output-directory", + temporaryFolder.newFolder().toString(), "--debug"}, Constant.TEST_CONF); + context = new TronApplicationContext(DefaultConfig.class); + service = context.getBean(PeerStatusCheck.class); + } + + /** + * destroy. + */ + @After + public void destroy() { + Args.clearParam(); + context.destroy(); + } + + @Test + public void testCheck() { + int maxConnection = 30; + Assert.assertEquals(maxConnection, Args.getInstance().getMaxConnections()); + Assert.assertEquals(0, PeerManager.getPeers().size()); + + for (int i = 0; i < maxConnection; i++) { + InetSocketAddress inetSocketAddress = new InetSocketAddress("201.0.0." + i, 10001); + Channel c1 = spy(Channel.class); + ReflectUtils.setFieldValue(c1, "inetSocketAddress", inetSocketAddress); + ReflectUtils.setFieldValue(c1, "inetAddress", inetSocketAddress.getAddress()); + ReflectUtils.setFieldValue(c1, "ctx", spy(ChannelHandlerContext.class)); + Mockito.doNothing().when(c1).send((byte[]) any()); + + PeerManager.add(context, c1); + } + + PeerManager.getPeers().get(0).getSyncBlockRequested() + .put(new BlockId(), System.currentTimeMillis() - NetConstants.SYNC_TIME_OUT - 1000); + ReflectUtils.invokeMethod(service, "statusCheck"); + + Assert.assertEquals(maxConnection - 1L, PeerManager.getPeers().size()); + } +} diff --git a/framework/src/test/java/org/tron/core/net/service/nodepersist/DBNodeTest.java b/framework/src/test/java/org/tron/core/net/service/nodepersist/DBNodeTest.java new file mode 100644 index 00000000000..171701762ee --- /dev/null +++ b/framework/src/test/java/org/tron/core/net/service/nodepersist/DBNodeTest.java @@ -0,0 +1,52 @@ +package org.tron.core.net.service.nodepersist; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import com.beust.jcommander.internal.Lists; +import org.junit.Before; +import org.junit.Test; + +public class DBNodeTest { + private DBNode dbNode1; + private DBNode dbNode2; + + @Before + public void setUp() { + dbNode1 = new DBNode("localhost", 3306); + dbNode2 = new DBNode(); + } + + @Test + public void testConstructorWithParameters() { + assertEquals("localhost", dbNode1.getHost()); + assertEquals(3306, dbNode1.getPort()); + } + + @Test + public void testDefaultConstructor() { + assertNull(dbNode2.getHost()); + assertEquals(0, dbNode2.getPort()); + } + + @Test + public void testSetAndGetHost() { + dbNode2.setHost("127.0.0.1"); + assertEquals("127.0.0.1", dbNode2.getHost()); + } + + @Test + public void testSetAndGetPort() { + dbNode2.setPort(5432); + assertEquals(5432, dbNode2.getPort()); + } + + + @Test + public void testDBNodes() { + DBNodes dbNodes = new DBNodes(); + dbNodes.setNodes(Lists.newArrayList(dbNode1, dbNode2)); + assertEquals(3306, dbNodes.getNodes().get(0).getPort()); + assertEquals(0, dbNodes.getNodes().get(1).getPort()); + } +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/net/services/AdvServiceTest.java b/framework/src/test/java/org/tron/core/net/services/AdvServiceTest.java index d79b54f6f45..04a6315f522 100644 --- a/framework/src/test/java/org/tron/core/net/services/AdvServiceTest.java +++ b/framework/src/test/java/org/tron/core/net/services/AdvServiceTest.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.net.InetSocketAddress; + import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -73,10 +74,17 @@ private void testAddInv() { Item itemBlock = new Item(Sha256Hash.ZERO_HASH, InventoryType.BLOCK); flag = service.addInv(itemBlock); + Assert.assertFalse(flag); + + BlockCapsule.BlockId blockId = new BlockCapsule.BlockId(Sha256Hash.ZERO_HASH, 1000L); + itemBlock = new Item(blockId, InventoryType.BLOCK); + flag = service.addInv(itemBlock); Assert.assertTrue(flag); flag = service.addInv(itemBlock); Assert.assertFalse(flag); + blockId = new BlockCapsule.BlockId(Sha256Hash.ZERO_HASH, 10000L); + itemBlock = new Item(blockId, InventoryType.BLOCK); service.addInvToCache(itemBlock); flag = service.addInv(itemBlock); Assert.assertFalse(flag); @@ -105,12 +113,28 @@ private void testBroadcast() { } private void testTrxBroadcast() { - Protocol.Transaction trx = Protocol.Transaction.newBuilder().build(); + Protocol.Transaction trx = Protocol.Transaction.newBuilder() + .setRawData( + Protocol.Transaction.raw.newBuilder() + .setRefBlockNum(1) + .setExpiration(System.currentTimeMillis() + 3000).build()).build(); CommonParameter.getInstance().setValidContractProtoThreadNum(1); TransactionMessage msg = new TransactionMessage(trx); service.broadcast(msg); Item item = new Item(msg.getMessageId(), InventoryType.TRX); Assert.assertNotNull(service.getMessage(item)); + + Protocol.Transaction expiredTrx = Protocol.Transaction.newBuilder() + .setRawData( + Protocol.Transaction.raw.newBuilder() + .setRefBlockNum(1) + .setExpiration(System.currentTimeMillis() - 1).build()) + .build(); + CommonParameter.getInstance().setValidContractProtoThreadNum(1); + TransactionMessage msg1 = new TransactionMessage(expiredTrx); + service.broadcast(msg); + Item item1 = new Item(msg1.getMessageId(), InventoryType.TRX); + Assert.assertNull(service.getMessage(item1)); } } diff --git a/framework/src/test/java/org/tron/core/net/services/HandShakeServiceTest.java b/framework/src/test/java/org/tron/core/net/services/HandShakeServiceTest.java index e027749458f..f4fabce5d64 100644 --- a/framework/src/test/java/org/tron/core/net/services/HandShakeServiceTest.java +++ b/framework/src/test/java/org/tron/core/net/services/HandShakeServiceTest.java @@ -21,6 +21,7 @@ import org.mockito.Mockito; import org.springframework.context.ApplicationContext; import org.tron.common.application.TronApplicationContext; +import org.tron.common.utils.ByteArray; import org.tron.common.utils.ReflectUtils; import org.tron.common.utils.Sha256Hash; import org.tron.core.ChainBaseManager; @@ -38,6 +39,7 @@ import org.tron.p2p.connection.Channel; import org.tron.p2p.discover.Node; import org.tron.p2p.utils.NetUtil; +import org.tron.program.Version; import org.tron.protos.Discover.Endpoint; import org.tron.protos.Protocol; import org.tron.protos.Protocol.HelloMessage.Builder; @@ -99,6 +101,9 @@ public void testOkHelloMessage() Node node = new Node(NetUtil.getNodeId(), a1.getAddress().getHostAddress(), null, a1.getPort()); HelloMessage helloMessage = new HelloMessage(node, System.currentTimeMillis(), ChainBaseManager.getChainBaseManager()); + + Assert.assertEquals(Version.getVersion(), + new String(helloMessage.getHelloMessage().getCodeVersion().toByteArray())); method.invoke(p2pEventHandler, peer, helloMessage.getSendBytes()); //dup hello message @@ -133,6 +138,37 @@ public void testInvalidHelloMessage() { } } + @Test + public void testInvalidHelloMessage2() throws Exception { + Protocol.HelloMessage.Builder builder = getTestHelloMessageBuilder(); + Assert.assertTrue(new HelloMessage(builder.build().toByteArray()).valid()); + + builder.setAddress(ByteString.copyFrom(new byte[201])); + HelloMessage helloMessage = new HelloMessage(builder.build().toByteArray()); + Assert.assertFalse(helloMessage.valid()); + + builder.setAddress(ByteString.copyFrom(new byte[200])); + helloMessage = new HelloMessage(builder.build().toByteArray()); + Assert.assertTrue(helloMessage.valid()); + + builder.setSignature(ByteString.copyFrom(new byte[201])); + helloMessage = new HelloMessage(builder.build().toByteArray()); + Assert.assertFalse(helloMessage.valid()); + + builder.setSignature(ByteString.copyFrom(new byte[200])); + helloMessage = new HelloMessage(builder.build().toByteArray()); + Assert.assertTrue(helloMessage.valid()); + + builder.setCodeVersion(ByteString.copyFrom(new byte[201])); + helloMessage = new HelloMessage(builder.build().toByteArray()); + Assert.assertFalse(helloMessage.valid()); + + builder.setCodeVersion(ByteString.copyFrom(new byte[200])); + helloMessage = new HelloMessage(builder.build().toByteArray()); + Assert.assertTrue(helloMessage.valid()); + } + + @Test public void testRelayHelloMessage() throws NoSuchMethodException { InetSocketAddress a1 = new InetSocketAddress("127.0.0.1", 10001); @@ -262,4 +298,13 @@ private Protocol.HelloMessage.Builder getHelloMessageBuilder(Node from, long tim return builder; } + + private Protocol.HelloMessage.Builder getTestHelloMessageBuilder() { + InetSocketAddress a1 = new InetSocketAddress("127.0.0.1", 10001); + Node node = new Node(NetUtil.getNodeId(), a1.getAddress().getHostAddress(), null, a1.getPort()); + Protocol.HelloMessage.Builder builder = + getHelloMessageBuilder(node, System.currentTimeMillis(), + ChainBaseManager.getChainBaseManager()); + return builder; + } } diff --git a/framework/src/test/java/org/tron/core/net/services/RelayServiceTest.java b/framework/src/test/java/org/tron/core/net/services/RelayServiceTest.java index 777472bdc35..5e22e538e80 100644 --- a/framework/src/test/java/org/tron/core/net/services/RelayServiceTest.java +++ b/framework/src/test/java/org/tron/core/net/services/RelayServiceTest.java @@ -1,31 +1,45 @@ package org.tron.core.net.services; +import static org.mockito.Mockito.mock; + import com.google.common.collect.Lists; import com.google.protobuf.ByteString; +import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Set; import javax.annotation.Resource; + +import lombok.extern.slf4j.Slf4j; import org.bouncycastle.util.encoders.Hex; import org.junit.Assert; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.mockito.Mockito; +import org.springframework.context.ApplicationContext; import org.tron.common.BaseTest; import org.tron.common.utils.ReflectUtils; +import org.tron.core.ChainBaseManager; import org.tron.core.Constant; import org.tron.core.capsule.BlockCapsule; import org.tron.core.capsule.WitnessCapsule; import org.tron.core.config.args.Args; import org.tron.core.net.P2pEventHandlerImpl; import org.tron.core.net.message.adv.BlockMessage; +import org.tron.core.net.message.handshake.HelloMessage; import org.tron.core.net.peer.Item; import org.tron.core.net.peer.PeerConnection; +import org.tron.core.net.peer.PeerManager; import org.tron.core.net.service.relay.RelayService; +import org.tron.p2p.connection.Channel; +import org.tron.p2p.discover.Node; +import org.tron.p2p.utils.NetUtil; import org.tron.protos.Protocol; +@Slf4j(topic = "net") public class RelayServiceTest extends BaseTest { @Resource @@ -49,6 +63,7 @@ public void test() throws Exception { initWitness(); testGetNextWitnesses(); testBroadcast(); + testCheckHelloMessage(); } private void initWitness() { @@ -119,4 +134,38 @@ private ByteString getFromHexString(String s) { return ByteString.copyFrom(Hex.decode(s)); } -} + private void testCheckHelloMessage() { + ByteString address = getFromHexString("A04711BF7AFBDF44557DEFBDF4C4E7AA6138C6331F"); + InetSocketAddress a1 = new InetSocketAddress("127.0.0.1", 10001); + Node node = new Node(NetUtil.getNodeId(), a1.getAddress().getHostAddress(), + null, a1.getPort()); + HelloMessage helloMessage = new HelloMessage(node, System.currentTimeMillis(), + ChainBaseManager.getChainBaseManager()); + helloMessage.setHelloMessage(helloMessage.getHelloMessage().toBuilder() + .setAddress(address).build()); + Channel c1 = mock(Channel.class); + Mockito.when(c1.getInetSocketAddress()).thenReturn(a1); + Mockito.when(c1.getInetAddress()).thenReturn(a1.getAddress()); + Channel c2 = mock(Channel.class); + Mockito.when(c2.getInetSocketAddress()).thenReturn(a1); + Mockito.when(c2.getInetAddress()).thenReturn(a1.getAddress()); + Args.getInstance().fastForward = true; + ApplicationContext ctx = (ApplicationContext) ReflectUtils.getFieldObject(p2pEventHandler, + "ctx"); + PeerConnection peer1 = PeerManager.add(ctx, c1); + assert peer1 != null; + peer1.setAddress(address); + PeerConnection peer2 = PeerManager.add(ctx, c2); + assert peer2 != null; + peer2.setAddress(address); + try { + Field field = service.getClass().getDeclaredField("witnessScheduleStore"); + field.setAccessible(true); + field.set(service, chainBaseManager.getWitnessScheduleStore()); + boolean res = service.checkHelloMessage(helloMessage, c1); + Assert.assertFalse(res); + } catch (Exception e) { + logger.info("{}", e.getMessage()); + } + } +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/net/services/ResilienceServiceTest.java b/framework/src/test/java/org/tron/core/net/services/ResilienceServiceTest.java new file mode 100644 index 00000000000..ce723e5c991 --- /dev/null +++ b/framework/src/test/java/org/tron/core/net/services/ResilienceServiceTest.java @@ -0,0 +1,205 @@ +package org.tron.core.net.services; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.spy; + +import io.netty.channel.ChannelHandlerContext; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.HashSet; +import java.util.Set; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.mockito.Mockito; +import org.tron.common.application.TronApplicationContext; +import org.tron.common.utils.ReflectUtils; +import org.tron.core.ChainBaseManager; +import org.tron.core.Constant; +import org.tron.core.config.DefaultConfig; +import org.tron.core.config.args.Args; +import org.tron.core.net.peer.PeerConnection; +import org.tron.core.net.peer.PeerManager; +import org.tron.core.net.service.effective.ResilienceService; +import org.tron.p2p.connection.Channel; + +public class ResilienceServiceTest { + + protected TronApplicationContext context; + private ResilienceService service; + private ChainBaseManager chainBaseManager; + + @Rule + public final TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @Before + public void init() throws IOException { + Args.setParam(new String[] {"--output-directory", + temporaryFolder.newFolder().toString(), "--debug"}, Constant.TEST_CONF); + context = new TronApplicationContext(DefaultConfig.class); + chainBaseManager = context.getBean(ChainBaseManager.class); + service = context.getBean(ResilienceService.class); + } + + @Test + public void testDisconnectRandom() { + int maxConnection = 30; + Assert.assertEquals(maxConnection, Args.getInstance().getMaxConnections()); + clearPeers(); + Assert.assertEquals(0, PeerManager.getPeers().size()); + + for (int i = 0; i < maxConnection + 1; i++) { + InetSocketAddress inetSocketAddress = new InetSocketAddress("201.0.0." + i, 10001); + Channel c1 = spy(Channel.class); + ReflectUtils.setFieldValue(c1, "inetSocketAddress", inetSocketAddress); + ReflectUtils.setFieldValue(c1, "inetAddress", inetSocketAddress.getAddress()); + ReflectUtils.setFieldValue(c1, "ctx", spy(ChannelHandlerContext.class)); + Mockito.doNothing().when(c1).send((byte[]) any()); + + PeerManager.add(context, c1); + } + for (PeerConnection peer : PeerManager.getPeers() + .subList(0, ResilienceService.minBroadcastPeerSize)) { + peer.setNeedSyncFromPeer(false); + peer.setNeedSyncFromUs(false); + peer.setLastInteractiveTime(System.currentTimeMillis() - 1000); + } + for (PeerConnection peer : PeerManager.getPeers() + .subList(ResilienceService.minBroadcastPeerSize, maxConnection + 1)) { + peer.setNeedSyncFromPeer(false); + peer.setNeedSyncFromUs(true); + } + int size1 = (int) PeerManager.getPeers().stream() + .filter(peer -> !peer.isNeedSyncFromUs() && !peer.isNeedSyncFromPeer()) + .count(); + Assert.assertEquals(ResilienceService.minBroadcastPeerSize, size1); + Assert.assertEquals(maxConnection + 1, PeerManager.getPeers().size()); + + //disconnect from broadcasting peer + ReflectUtils.invokeMethod(service, "disconnectRandom"); + size1 = (int) PeerManager.getPeers().stream() + .filter(peer -> !peer.isNeedSyncFromUs() && !peer.isNeedSyncFromPeer()) + .count(); + Assert.assertEquals(ResilienceService.minBroadcastPeerSize - 1, size1); + Assert.assertEquals(maxConnection, PeerManager.getPeers().size()); + + //disconnect from syncing peer + ReflectUtils.invokeMethod(service, "disconnectRandom"); + size1 = (int) PeerManager.getPeers().stream() + .filter(peer -> !peer.isNeedSyncFromUs() && !peer.isNeedSyncFromPeer()) + .count(); + Assert.assertEquals(ResilienceService.minBroadcastPeerSize - 1, size1); + Assert.assertEquals(maxConnection - 1, PeerManager.getPeers().size()); + } + + @Test + public void testDisconnectLan() { + int minConnection = 8; + Assert.assertEquals(minConnection, Args.getInstance().getMinConnections()); + clearPeers(); + Assert.assertEquals(0, PeerManager.getPeers().size()); + + for (int i = 0; i < 9; i++) { + InetSocketAddress inetSocketAddress = new InetSocketAddress("201.0.0." + i, 10001); + Channel c1 = spy(Channel.class); + ReflectUtils.setFieldValue(c1, "inetSocketAddress", inetSocketAddress); + ReflectUtils.setFieldValue(c1, "inetAddress", inetSocketAddress.getAddress()); + ReflectUtils.setFieldValue(c1, "isActive", true); + ReflectUtils.setFieldValue(c1, "ctx", spy(ChannelHandlerContext.class)); + Mockito.doNothing().when(c1).send((byte[]) any()); + + PeerManager.add(context, c1); + } + for (PeerConnection peer : PeerManager.getPeers()) { + peer.setNeedSyncFromPeer(false); + peer.setNeedSyncFromUs(false); + } + Assert.assertEquals(9, PeerManager.getPeers().size()); + + boolean isLan = ReflectUtils.invokeMethod(service, "isLanNode"); + Assert.assertTrue(isLan); + + PeerConnection p1 = PeerManager.getPeers().get(1); + InetSocketAddress address1 = p1.getChannel().getInetSocketAddress(); + p1.setLastInteractiveTime( + System.currentTimeMillis() - Args.getInstance().inactiveThreshold * 1000L - 1000); + PeerConnection p2 = PeerManager.getPeers().get(2); + InetSocketAddress address2 = p2.getChannel().getInetSocketAddress(); + p2.setLastInteractiveTime( + System.currentTimeMillis() - Args.getInstance().inactiveThreshold * 1000L - 2000); + + ReflectUtils.invokeMethod(service, "disconnectLan"); + Assert.assertEquals(8, PeerManager.getPeers().size()); + Set addressSet = new HashSet<>(); + PeerManager.getPeers() + .forEach(p -> addressSet.add(p.getChannel().getInetSocketAddress())); + Assert.assertTrue(addressSet.contains(address1)); + Assert.assertFalse(addressSet.contains(address2)); + + ReflectUtils.invokeMethod(service, "disconnectLan"); + Assert.assertEquals(7, PeerManager.getPeers().size()); + addressSet.clear(); + PeerManager.getPeers() + .forEach(p -> addressSet.add(p.getChannel().getInetSocketAddress())); + Assert.assertFalse(addressSet.contains(address1)); + + ReflectUtils.invokeMethod(service, "disconnectLan"); + Assert.assertEquals(7, PeerManager.getPeers().size()); + } + + @Test + public void testDisconnectIsolated2() { + int maxConnection = 30; + Assert.assertEquals(maxConnection, Args.getInstance().getMaxConnections()); + clearPeers(); + Assert.assertEquals(0, PeerManager.getPeers().size()); + + int addSize = (int) (maxConnection * ResilienceService.retentionPercent) + 2; //26 + for (int i = 0; i < addSize; i++) { + InetSocketAddress inetSocketAddress = new InetSocketAddress("201.0.0." + i, 10001); + Channel c1 = spy(Channel.class); + ReflectUtils.setFieldValue(c1, "inetSocketAddress", inetSocketAddress); + ReflectUtils.setFieldValue(c1, "inetAddress", inetSocketAddress.getAddress()); + // 1 ~ 3 is active, 4 ~ 26 is not active + ReflectUtils.setFieldValue(c1, "isActive", i <= 2); + ReflectUtils.setFieldValue(c1, "ctx", spy(ChannelHandlerContext.class)); + Mockito.doNothing().when(c1).send((byte[]) any()); + + PeerManager.add(context, c1); + } + PeerManager.getPeers().get(10).setNeedSyncFromUs(false); + PeerManager.getPeers().get(10).setNeedSyncFromPeer(false); + chainBaseManager.setLatestSaveBlockTime( + System.currentTimeMillis() - ResilienceService.blockNotChangeThreshold - 100L); + boolean isIsolated = ReflectUtils.invokeMethod(service, "isIsolateLand2"); + Assert.assertTrue(isIsolated); + + ReflectUtils.invokeMethod(service, "disconnectIsolated2"); + int activeNodeSize = (int) PeerManager.getPeers().stream() + .filter(p -> p.getChannel().isActive()) + .count(); + int passiveSize = (int) PeerManager.getPeers().stream() + .filter(p -> !p.getChannel().isActive()) + .count(); + Assert.assertEquals(2, activeNodeSize); + Assert.assertEquals((int) (maxConnection * ResilienceService.retentionPercent), + activeNodeSize + passiveSize); + Assert.assertEquals((int) (maxConnection * ResilienceService.retentionPercent), + PeerManager.getPeers().size()); + } + + private void clearPeers() { + for (PeerConnection p : PeerManager.getPeers()) { + PeerManager.remove(p.getChannel()); + } + } + + @After + public void destroy() { + Args.clearParam(); + context.destroy(); + } +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/net/services/SyncServiceTest.java b/framework/src/test/java/org/tron/core/net/services/SyncServiceTest.java index 89c081eaab5..c2883fb349d 100644 --- a/framework/src/test/java/org/tron/core/net/services/SyncServiceTest.java +++ b/framework/src/test/java/org/tron/core/net/services/SyncServiceTest.java @@ -85,9 +85,11 @@ public void testStartSync() { peer.setChannel(c1); + ReflectUtils.setFieldValue(peer, "tronState", TronState.SYNCING); + service.startSync(peer); - ReflectUtils.setFieldValue(peer, "tronState", TronState.SYNCING); + ReflectUtils.setFieldValue(peer, "tronState", TronState.INIT); service.startSync(peer); } catch (Exception e) { diff --git a/framework/src/test/java/org/tron/core/net/services/TronStatsManagerTest.java b/framework/src/test/java/org/tron/core/net/services/TronStatsManagerTest.java index 369955f4e7f..a940a14d392 100644 --- a/framework/src/test/java/org/tron/core/net/services/TronStatsManagerTest.java +++ b/framework/src/test/java/org/tron/core/net/services/TronStatsManagerTest.java @@ -1,5 +1,7 @@ package org.tron.core.net.services; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -24,4 +26,38 @@ public void testOnDisconnect() { Assert.assertEquals(Protocol.ReasonCode.UNKNOWN, statistics.getDisconnectReason()); } + @Test + public void testWork() throws Exception { + TronStatsManager manager = new TronStatsManager(); + Field field1 = manager.getClass().getDeclaredField("TCP_TRAFFIC_IN"); + field1.setAccessible(true); + field1.set(manager, 1L); + + Field field2 = manager.getClass().getDeclaredField("TCP_TRAFFIC_OUT"); + field2.setAccessible(true); + field2.set(manager, 1L); + + Field field3 = manager.getClass().getDeclaredField("UDP_TRAFFIC_IN"); + field3.setAccessible(true); + field3.set(manager, 1L); + + Field field4 = manager.getClass().getDeclaredField("UDP_TRAFFIC_OUT"); + field4.setAccessible(true); + field4.set(manager, 1L); + + Assert.assertEquals(field1.get(manager), 1L); + Assert.assertEquals(field2.get(manager), 1L); + Assert.assertEquals(field3.get(manager), 1L); + Assert.assertEquals(field4.get(manager), 1L); + + Method method = manager.getClass().getDeclaredMethod("work"); + method.setAccessible(true); + method.invoke(manager); + + Assert.assertEquals(field1.get(manager), 0L); + Assert.assertEquals(field2.get(manager), 0L); + Assert.assertEquals(field3.get(manager), 0L); + Assert.assertEquals(field4.get(manager), 0L); + } + } diff --git a/framework/src/test/java/org/tron/core/pbft/PbftApiTest.java b/framework/src/test/java/org/tron/core/pbft/PbftApiTest.java index 9bc942d6684..3d5096a5702 100755 --- a/framework/src/test/java/org/tron/core/pbft/PbftApiTest.java +++ b/framework/src/test/java/org/tron/core/pbft/PbftApiTest.java @@ -17,6 +17,8 @@ import org.junit.Test; import org.tron.common.BaseTest; import org.tron.common.crypto.ECKey; +import org.tron.common.parameter.CommonParameter; +import org.tron.common.utils.PublicMethod; import org.tron.common.utils.Sha256Hash; import org.tron.common.utils.Utils; import org.tron.core.ChainBaseManager; @@ -35,7 +37,9 @@ public class PbftApiTest extends BaseTest { @BeforeClass public static void init() { - Args.setParam(new String[]{"-d", dbPath(), "-w"}, Constant.TEST_CONF); + Args.setParam(new String[]{"-d", dbPath()}, Constant.TEST_CONF); + CommonParameter.getInstance().setPBFTHttpEnable(true); + CommonParameter.getInstance().setPBFTHttpPort(PublicMethod.chooseRandomPort()); } @Test @@ -58,11 +62,11 @@ public void pbftapi() throws IOException { Assert.assertTrue(dynamicPropertiesStore.getLatestBlockHeaderNumber() >= 10); commonDataBase.saveLatestPbftBlockNum(6); - httpApiOnPBFTService.init(Args.getInstance()); httpApiOnPBFTService.start(); CloseableHttpResponse response; try (CloseableHttpClient httpClient = HttpClients.createDefault()) { - HttpGet httpGet = new HttpGet("http://127.0.0.1:8092/walletpbft/getnowblock"); + HttpGet httpGet = new HttpGet("http://127.0.0.1/" + + CommonParameter.getInstance().getPBFTHttpPort() + "/walletpbft/getnowblock"); response = httpClient.execute(httpGet); String responseString = EntityUtils.toString(response.getEntity()); JSONObject jsonObject = JSON.parseObject(responseString); diff --git a/framework/src/test/java/org/tron/core/pbft/PbftTest.java b/framework/src/test/java/org/tron/core/pbft/PbftTest.java index a5d74ad7a37..33a46516988 100644 --- a/framework/src/test/java/org/tron/core/pbft/PbftTest.java +++ b/framework/src/test/java/org/tron/core/pbft/PbftTest.java @@ -29,6 +29,7 @@ public void testPbftSrMessage() { ByteString.copyFrom(ByteArray.fromHexString("41df309fef25b311e7895562bd9e11aab2a58816d2"))); PbftMessage pbftSrMessage = PbftMessage .prePrepareSRLMsg(blockCapsule, srList, 1, miner); + PbftMessage.fullNodePrePrepareSRLMsg(blockCapsule, srList, 1); System.out.println(pbftSrMessage); } diff --git a/framework/src/test/java/org/tron/core/services/ComputeRewardTest.java b/framework/src/test/java/org/tron/core/services/ComputeRewardTest.java new file mode 100644 index 00000000000..c2caafd393c --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/ComputeRewardTest.java @@ -0,0 +1,304 @@ +package org.tron.core.services; + +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.protobuf.ByteString; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.tron.common.application.TronApplicationContext; +import org.tron.common.error.TronDBException; +import org.tron.common.es.ExecutorServiceManager; +import org.tron.common.utils.ByteArray; +import org.tron.common.utils.ReflectUtils; +import org.tron.core.Constant; +import org.tron.core.capsule.AccountCapsule; +import org.tron.core.capsule.BytesCapsule; +import org.tron.core.capsule.WitnessCapsule; +import org.tron.core.config.DefaultConfig; +import org.tron.core.config.args.Args; +import org.tron.core.exception.TronError; +import org.tron.core.service.MortgageService; +import org.tron.core.service.RewardViCalService; +import org.tron.core.store.AccountStore; +import org.tron.core.store.DelegationStore; +import org.tron.core.store.DynamicPropertiesStore; +import org.tron.core.store.RewardViStore; +import org.tron.core.store.WitnessStore; +import org.tron.protos.Protocol; + +public class ComputeRewardTest { + + private static final byte[] OWNER_ADDRESS = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1bf0"); + + private static final byte[] OWNER_ADDRESS_2 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1bf1"); + + private static final byte[] OWNER_ADDRESS_3 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1bf2"); + + private static final byte[] SR_ADDRESS_1 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c00"); + private static final byte[] SR_ADDRESS_2 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c01"); + private static final byte[] SR_ADDRESS_3 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c02"); + private static final byte[] SR_ADDRESS_4 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c03"); + private static final byte[] SR_ADDRESS_5 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c04"); + private static final byte[] SR_ADDRESS_6 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c05"); + private static final byte[] SR_ADDRESS_7 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c06"); + private static final byte[] SR_ADDRESS_8 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c07"); + private static final byte[] SR_ADDRESS_9 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c08"); + private static final byte[] SR_ADDRESS_10 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c09"); + private static final byte[] SR_ADDRESS_11 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c10"); + private static final byte[] SR_ADDRESS_12 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c11"); + private static final byte[] SR_ADDRESS_13 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c12"); + private static final byte[] SR_ADDRESS_14 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c13"); + private static final byte[] SR_ADDRESS_15 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c14"); + private static final byte[] SR_ADDRESS_16 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c15"); + private static final byte[] SR_ADDRESS_17 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c16"); + private static final byte[] SR_ADDRESS_18 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c17"); + private static final byte[] SR_ADDRESS_19 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c18"); + private static final byte[] SR_ADDRESS_20 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c19"); + private static final byte[] SR_ADDRESS_21 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c20"); + private static final byte[] SR_ADDRESS_22 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c21"); + private static final byte[] SR_ADDRESS_23 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c22"); + private static final byte[] SR_ADDRESS_24 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c23"); + private static final byte[] SR_ADDRESS_25 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c24"); + private static final byte[] SR_ADDRESS_26 = ByteArray.fromHexString( + "4105b9e8af8ee371cad87317f442d155b39fbd1c25"); + + private static TronApplicationContext context; + private static DynamicPropertiesStore propertiesStore; + private static DelegationStore delegationStore; + private static AccountStore accountStore; + private static RewardViCalService rewardViCalService; + private static WitnessStore witnessStore; + private static MortgageService mortgageService; + private static RewardViStore rewardViStore; + @Rule + public final TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @After + public void destroy() { + context.destroy(); + Args.clearParam(); + } + + /** + * Init data. + */ + @Before + public void init() throws IOException { + Args.setParam(new String[]{"--output-directory", temporaryFolder.newFolder().toString(), + "--p2p-disable", "true"}, Constant.TEST_CONF); + context = new TronApplicationContext(DefaultConfig.class); + propertiesStore = context.getBean(DynamicPropertiesStore.class); + delegationStore = context.getBean(DelegationStore.class); + accountStore = context.getBean(AccountStore.class); + rewardViCalService = context.getBean(RewardViCalService.class); + witnessStore = context.getBean(WitnessStore.class); + mortgageService = context.getBean(MortgageService.class); + rewardViStore = context.getBean(RewardViStore.class); + setUp(); + } + + private void setUp() { + // mock flush service + Map flushServices = new HashMap<>(); + flushServices.put("propertiesStore", MoreExecutors.listeningDecorator( + ExecutorServiceManager.newSingleThreadExecutor( + "flush-service-propertiesStore"))); + flushServices.put("delegationStore", MoreExecutors.listeningDecorator( + ExecutorServiceManager.newSingleThreadExecutor( + "flush-service-delegationStore"))); + flushServices.put("accountStore", MoreExecutors.listeningDecorator( + ExecutorServiceManager.newSingleThreadExecutor("flush-service-accountStore"))); + flushServices.put("witnessStore", MoreExecutors.listeningDecorator( + ExecutorServiceManager.newSingleThreadExecutor("flush-service-witnessStore"))); + + List> futures = new ArrayList<>(flushServices.size()); + + try { + flushServices.get("propertiesStore").submit(() -> { + propertiesStore.saveChangeDelegation(1); + propertiesStore.saveCurrentCycleNumber(4); + propertiesStore.saveNewRewardAlgorithmEffectiveCycle(); + propertiesStore.saveLatestBlockHeaderNumber(1); + }).get(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new TronDBException(e); + } catch (ExecutionException e) { + throw new TronDBException(e); + } + + try { + Thread.sleep(1000 * 6); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new TronDBException(e); + } + + List votes = new ArrayList<>(32); + votes.add(new Vote(46188095536L, 5, 1496122605L, SR_ADDRESS_1)); + votes.add(new Vote(48618386224L, 5, 1582867684L, SR_ADDRESS_2)); + votes.add(new Vote(13155856728L, 5, 586969566L, SR_ADDRESS_3)); + votes.add(new Vote(41883707392L, 5, 1342484905L, SR_ADDRESS_4)); + votes.add(new Vote(62017323832L, 5, 2061119522L, SR_ADDRESS_5)); + votes.add(new Vote(19227712L, 3, 722417L, SR_ADDRESS_6)); + votes.add(new Vote(46634987592L, 3, 1599681706L, SR_ADDRESS_7)); + votes.add(new Vote(49112700L, 3, 1753127L, SR_ADDRESS_8)); + votes.add(new Vote(40835355868L, 6, 1467015537L, SR_ADDRESS_9)); + votes.add(new Vote(10045616L, 5, 362326L, SR_ADDRESS_10)); + votes.add(new Vote(34534983616L, 5, 1217718846L, SR_ADDRESS_11)); + votes.add(new Vote(32387926028L, 5, 1292557190L, SR_ADDRESS_12)); + votes.add(new Vote(36516086396L, 5, 1295716573L, SR_ADDRESS_13)); + votes.add(new Vote(48411501224L, 5, 1575483226L, SR_ADDRESS_14)); + votes.add(new Vote(154785960L, 5, 6905922L, SR_ADDRESS_15)); + votes.add(new Vote(59057915168L, 6, 1956059729L, SR_ADDRESS_16)); + votes.add(new Vote(62921824L, 3, 2245904L, SR_ADDRESS_17)); + votes.add(new Vote(1180144L, 3, 42148L, SR_ADDRESS_18)); + votes.add(new Vote(104313216L, 5, 4654248L, SR_ADDRESS_19)); + votes.add(new Vote(20429168760L, 1, 759569195L, SR_ADDRESS_20)); + votes.add(new Vote(4706184L, 3, 168069L, SR_ADDRESS_21)); + votes.add(new Vote(55804071064L, 5, 1839919389L, SR_ADDRESS_22)); + votes.add(new Vote(6074042856L, 6, 216802459L, SR_ADDRESS_23)); + votes.add(new Vote(40729360L, 5, 1817205L, SR_ADDRESS_24)); + votes.add(new Vote(31250017036L, 5, 1242358644L, SR_ADDRESS_25)); + votes.add(new Vote(15003660L, 5, 669546L, SR_ADDRESS_26)); + + futures.add(flushServices.get("delegationStore").submit(() -> { + delegationStore.setBeginCycle(OWNER_ADDRESS, 2); + delegationStore.setEndCycle(OWNER_ADDRESS, 3); + delegationStore.setBeginCycle(OWNER_ADDRESS_2, 1); + delegationStore.setEndCycle(OWNER_ADDRESS_2, 2); + delegationStore.setBeginCycle(OWNER_ADDRESS_3, 5); + for (Vote vote : votes) { + delegationStore.addReward(3, vote.srAddress, vote.totalReward); + delegationStore.setWitnessVote(3, vote.srAddress, vote.totalVotes); + } + })); + + futures.add(flushServices.get("witnessStore").submit(() -> { + for (Vote vote : votes) { + witnessStore.put(vote.srAddress, new WitnessCapsule(Protocol.Witness.newBuilder() + .setAddress(ByteString.copyFrom(vote.srAddress)) + .setVoteCount(vote.totalVotes) + .build())); + } + })); + + futures.add(flushServices.get("accountStore").submit(() -> { + Protocol.Account.Builder accountBuilder = Protocol.Account.newBuilder(); + accountBuilder.setAddress(ByteString.copyFrom(OWNER_ADDRESS)); + for (Vote vote : votes) { + accountBuilder.addVotes(Protocol.Vote.newBuilder() + .setVoteAddress(ByteString.copyFrom(vote.srAddress)) + .setVoteCount(vote.userVotes)); + + } + accountStore.put(OWNER_ADDRESS, new AccountCapsule(accountBuilder.build())); + })); + Future future = Futures.allAsList(futures); + try { + future.get(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new TronDBException(e); + } catch (ExecutionException e) { + throw new TronDBException(e); + } + try { + flushServices.get("propertiesStore").submit(() -> { + propertiesStore.saveAllowOldRewardOpt(1); + propertiesStore.saveLatestBlockHeaderNumber(3); + propertiesStore.saveCurrentCycleNumber(5); + }).get(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new TronDBException(e); + } catch (ExecutionException e) { + throw new TronDBException(e); + } + } + + @Test + public void query() { + Assert.assertEquals(3189, mortgageService.queryReward(OWNER_ADDRESS)); + // mock root is error + rewardViStore.put("test".getBytes(), "test".getBytes()); + ReflectUtils.invokeMethod(rewardViCalService,"maybeRun"); + + // mock no need + propertiesStore.saveCurrentCycleNumber(0); + // reset + propertiesStore.put("NEW_REWARD_ALGORITHM_EFFECTIVE_CYCLE".getBytes(), + new BytesCapsule(ByteArray.fromLong(Long.MAX_VALUE))); + // set + propertiesStore.saveNewRewardAlgorithmEffectiveCycle(); + ReflectUtils.invokeMethod(rewardViCalService,"maybeRun"); + + // mock maybeRun exception + propertiesStore.saveCurrentCycleNumber(4); + // reset + propertiesStore.put("NEW_REWARD_ALGORITHM_EFFECTIVE_CYCLE".getBytes(), + new BytesCapsule(ByteArray.fromLong(Long.MAX_VALUE))); + // set + propertiesStore.saveNewRewardAlgorithmEffectiveCycle(); + propertiesStore.saveCurrentCycleNumber(5); + rewardViStore.close(); + TronError thrown = Assert.assertThrows(TronError.class, () -> + ReflectUtils.invokeMethod(rewardViCalService,"maybeRun")); + Assert.assertEquals(TronError.ErrCode.REWARD_VI_CALCULATOR, thrown.getErrCode()); + } + + static class Vote { + long totalVotes; + long userVotes; + long totalReward; + byte[] srAddress; + + public Vote(long totalReward, long userVotes, long totalVotes, byte[] srAddress) { + this.totalVotes = totalVotes; + this.userVotes = userVotes; + this.totalReward = totalReward; + this.srAddress = srAddress; + } + } +} diff --git a/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java b/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java index e2ea87a1d0f..5c898eb42d6 100644 --- a/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java +++ b/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java @@ -107,6 +107,7 @@ private void testWithdraw() { public void test() { manager.getDynamicPropertiesStore().saveChangeDelegation(1); + manager.getDynamicPropertiesStore().saveConsensusLogicOptimization(1); byte[] sr27 = decodeFromBase58Check("TLTDZBcPoJ8tZ6TTEeEqEvwYFk2wgotSfD"); manager.getDelegationStore().setBrokerage(0, sr27, 10); manager.getDelegationStore().setBrokerage(1, sr27, 20); diff --git a/framework/src/test/java/org/tron/core/services/NodeInfoServiceTest.java b/framework/src/test/java/org/tron/core/services/NodeInfoServiceTest.java index 19d0540e5e6..be0a96f632b 100644 --- a/framework/src/test/java/org/tron/core/services/NodeInfoServiceTest.java +++ b/framework/src/test/java/org/tron/core/services/NodeInfoServiceTest.java @@ -4,21 +4,15 @@ import com.alibaba.fastjson.JSON; import com.google.protobuf.ByteString; -import io.grpc.ManagedChannelBuilder; import java.net.InetSocketAddress; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; import org.mockito.Mockito; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletGrpc.WalletBlockingStub; import org.tron.common.application.TronApplicationContext; import org.tron.common.entity.NodeInfo; import org.tron.common.utils.Sha256Hash; -import org.tron.common.utils.client.Configuration; import org.tron.core.capsule.BlockCapsule; import org.tron.core.net.P2pEventHandlerImpl; -import org.tron.core.net.peer.PeerManager; import org.tron.p2p.connection.Channel; import org.tron.program.Version; @@ -29,8 +23,6 @@ public class NodeInfoServiceTest { private NodeInfoService nodeInfoService; private WitnessProductBlockService witnessProductBlockService; private P2pEventHandlerImpl p2pEventHandler; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); public NodeInfoServiceTest(TronApplicationContext context) { nodeInfoService = context.getBean("nodeInfoService", NodeInfoService.class); @@ -60,12 +52,4 @@ public void test() { logger.info("{}", JSON.toJSONString(nodeInfo)); } - public void testGrpc() { - WalletBlockingStub walletStub = WalletGrpc - .newBlockingStub(ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext() - .build()); - logger.info("getNodeInfo: {}", walletStub.getNodeInfo(EmptyMessage.getDefaultInstance())); - } - } diff --git a/framework/src/test/java/org/tron/core/services/ProposalServiceTest.java b/framework/src/test/java/org/tron/core/services/ProposalServiceTest.java index 0ba32b27f2e..300a38a0916 100644 --- a/framework/src/test/java/org/tron/core/services/ProposalServiceTest.java +++ b/framework/src/test/java/org/tron/core/services/ProposalServiceTest.java @@ -1,5 +1,6 @@ package org.tron.core.services; +import static org.tron.core.utils.ProposalUtil.ProposalType.CONSENSUS_LOGIC_OPTIMIZATION; import static org.tron.core.utils.ProposalUtil.ProposalType.ENERGY_FEE; import static org.tron.core.utils.ProposalUtil.ProposalType.TRANSACTION_FEE; import static org.tron.core.utils.ProposalUtil.ProposalType.WITNESS_127_PAY_PER_BLOCK; @@ -106,4 +107,28 @@ public void testUpdateTransactionFee() { Assert.assertEquals(expResult, currentHistory); } + @Test + public void testUpdateConsensusLogicOptimization() { + long v = dbManager.getDynamicPropertiesStore().getConsensusLogicOptimization(); + Assert.assertEquals(v, 0); + Assert.assertTrue(!dbManager.getDynamicPropertiesStore().allowConsensusLogicOptimization()); + Assert.assertFalse(dbManager.getDynamicPropertiesStore().allowWitnessSortOptimization()); + Assert.assertFalse(dbManager.getDynamicPropertiesStore().disableJavaLangMath()); + + long value = 1; + Proposal proposal = + Proposal.newBuilder().putParameters(CONSENSUS_LOGIC_OPTIMIZATION.getCode(), value).build(); + ProposalCapsule proposalCapsule = new ProposalCapsule(proposal); + proposalCapsule.setExpirationTime(1627279200000L); + boolean result = ProposalService.process(dbManager, proposalCapsule); + Assert.assertTrue(result); + + v = dbManager.getDynamicPropertiesStore().getConsensusLogicOptimization(); + Assert.assertEquals(v, value); + + Assert.assertTrue(dbManager.getDynamicPropertiesStore().allowConsensusLogicOptimization()); + Assert.assertTrue(dbManager.getDynamicPropertiesStore().allowWitnessSortOptimization()); + Assert.assertTrue(dbManager.getDynamicPropertiesStore().disableJavaLangMath()); + } + } \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java b/framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java index 8b45b871af7..3ae090d3caf 100644 --- a/framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java +++ b/framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java @@ -135,14 +135,20 @@ public static void init() throws IOException { Args.setParam(new String[]{"-d", temporaryFolder.newFolder().toString()}, Constant.TEST_CONF); String OWNER_ADDRESS = Wallet.getAddressPreFixString() + "548794500882809695a8a687866e76d4271a1abc"; + getInstance().setRpcEnable(true); getInstance().setRpcPort(PublicMethod.chooseRandomPort()); + getInstance().setRpcSolidityEnable(true); getInstance().setRpcOnSolidityPort(PublicMethod.chooseRandomPort()); + getInstance().setRpcPBFTEnable(true); getInstance().setRpcOnPBFTPort(PublicMethod.chooseRandomPort()); - String fullNode = String.format("%s:%d", getInstance().getNodeDiscoveryBindIp(), + getInstance().setMetricsPrometheusPort(PublicMethod.chooseRandomPort()); + getInstance().setMetricsPrometheusEnable(true); + getInstance().setP2pDisable(true); + String fullNode = String.format("%s:%d", getInstance().getNodeLanIp(), getInstance().getRpcPort()); - String solidityNode = String.format("%s:%d", getInstance().getNodeDiscoveryBindIp(), + String solidityNode = String.format("%s:%d", getInstance().getNodeLanIp(), getInstance().getRpcOnSolidityPort()); - String pBFTNode = String.format("%s:%d", getInstance().getNodeDiscoveryBindIp(), + String pBFTNode = String.format("%s:%d", getInstance().getNodeLanIp(), getInstance().getRpcOnPBFTPort()); ManagedChannel channelFull = ManagedChannelBuilder.forTarget(fullNode) @@ -162,11 +168,6 @@ public static void init() throws IOException { blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); blockingStubPBFT = WalletSolidityGrpc.newBlockingStub(channelPBFT); - RpcApiService rpcApiService = context.getBean(RpcApiService.class); - RpcApiServiceOnSolidity rpcApiServiceOnSolidity = - context.getBean(RpcApiServiceOnSolidity.class); - RpcApiServiceOnPBFT rpcApiServiceOnPBFT = context.getBean(RpcApiServiceOnPBFT.class); - Manager manager = context.getBean(Manager.class); ownerAddress = ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)); @@ -176,9 +177,6 @@ public static void init() throws IOException { manager.getDynamicPropertiesStore().saveAllowShieldedTransaction(1); manager.getDynamicPropertiesStore().saveAllowShieldedTRC20Transaction(1); Application appTest = ApplicationFactory.create(context); - appTest.addService(rpcApiService); - appTest.addService(rpcApiServiceOnSolidity); - appTest.addService(rpcApiServiceOnPBFT); appTest.startup(); } diff --git a/framework/src/test/java/org/tron/core/services/WalletApiTest.java b/framework/src/test/java/org/tron/core/services/WalletApiTest.java index 0a87c348fdb..8890d4bfd9e 100644 --- a/framework/src/test/java/org/tron/core/services/WalletApiTest.java +++ b/framework/src/test/java/org/tron/core/services/WalletApiTest.java @@ -5,8 +5,8 @@ import lombok.extern.slf4j.Slf4j; import org.junit.After; import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; +import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.tron.api.GrpcAPI.EmptyMessage; @@ -14,7 +14,7 @@ import org.tron.common.application.Application; import org.tron.common.application.ApplicationFactory; import org.tron.common.application.TronApplicationContext; -import org.tron.common.utils.client.Configuration; +import org.tron.common.utils.PublicMethod; import org.tron.core.Constant; import org.tron.core.config.DefaultConfig; import org.tron.core.config.args.Args; @@ -23,34 +23,34 @@ @Slf4j public class WalletApiTest { - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); private static TronApplicationContext context; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private RpcApiService rpcApiService; - private Application appT; + private static Application appT; - @Before - public void init() throws IOException { + + @BeforeClass + public static void init() throws IOException { Args.setParam(new String[]{ "-d", temporaryFolder.newFolder().toString(), "--p2p-disable", "true"}, Constant.TEST_CONF); + Args.getInstance().setRpcPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setRpcEnable(true); context = new TronApplicationContext(DefaultConfig.class); appT = ApplicationFactory.create(context); - rpcApiService = context.getBean(RpcApiService.class); - appT.addService(rpcApiService); appT.startup(); } @Test public void listNodesTest() { + String fullNode = String.format("%s:%d", "127.0.0.1", + Args.getInstance().getRpcPort()); WalletGrpc.WalletBlockingStub walletStub = WalletGrpc - .newBlockingStub(ManagedChannelBuilder.forTarget(fullnode) + .newBlockingStub(ManagedChannelBuilder.forTarget(fullNode) .usePlaintext() .build()); Assert.assertTrue(walletStub.listNodes(EmptyMessage.getDefaultInstance()) - .getNodesList().size() == 0); + .getNodesList().isEmpty()); } @After diff --git a/framework/src/test/java/org/tron/core/services/filter/HttpApiAccessFilterTest.java b/framework/src/test/java/org/tron/core/services/filter/HttpApiAccessFilterTest.java index 5f883fc8c07..420d890aa48 100644 --- a/framework/src/test/java/org/tron/core/services/filter/HttpApiAccessFilterTest.java +++ b/framework/src/test/java/org/tron/core/services/filter/HttpApiAccessFilterTest.java @@ -14,10 +14,10 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; import org.tron.common.BaseTest; import org.tron.common.parameter.CommonParameter; +import org.tron.common.utils.PublicMethod; import org.tron.core.Constant; import org.tron.core.config.args.Args; import org.tron.core.services.http.FullNodeHttpApiService; @@ -39,21 +39,18 @@ public class HttpApiAccessFilterTest extends BaseTest { static { Args.setParam(new String[]{"-d", dbPath()}, Constant.TEST_CONF); Args.getInstance().setFullNodeAllowShieldedTransactionArgs(false); - } - - /** - * init dependencies. - */ - @Before - public void init() { - appT.addService(httpApiService); - appT.addService(httpApiOnSolidityService); - appT.addService(httpApiOnPBFTService); - appT.startup(); + Args.getInstance().setFullNodeHttpEnable(true); + Args.getInstance().setFullNodeHttpPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setPBFTHttpEnable(true); + Args.getInstance().setPBFTHttpPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setSolidityNodeHttpEnable(true); + Args.getInstance().setSolidityHttpPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setP2pDisable(true); } @Test public void testHttpFilter() { + appT.startup(); List disabledApiList = new ArrayList<>(); disabledApiList.add("getaccount"); disabledApiList.add("getnowblock"); diff --git a/framework/src/test/java/org/tron/core/services/filter/LiteFnQueryGrpcInterceptorTest.java b/framework/src/test/java/org/tron/core/services/filter/LiteFnQueryGrpcInterceptorTest.java index 00f2c2fc086..84869ea0750 100644 --- a/framework/src/test/java/org/tron/core/services/filter/LiteFnQueryGrpcInterceptorTest.java +++ b/framework/src/test/java/org/tron/core/services/filter/LiteFnQueryGrpcInterceptorTest.java @@ -55,14 +55,18 @@ public class LiteFnQueryGrpcInterceptorTest { @BeforeClass public static void init() throws IOException { Args.setParam(new String[]{"-d", temporaryFolder.newFolder().toString()}, Constant.TEST_CONF); + Args.getInstance().setRpcEnable(true); Args.getInstance().setRpcPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setRpcSolidityEnable(true); Args.getInstance().setRpcOnSolidityPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setRpcPBFTEnable(true); Args.getInstance().setRpcOnPBFTPort(PublicMethod.chooseRandomPort()); - String fullnode = String.format("%s:%d", Args.getInstance().getNodeDiscoveryBindIp(), + Args.getInstance().setP2pDisable(true); + String fullnode = String.format("%s:%d", Args.getInstance().getNodeLanIp(), Args.getInstance().getRpcPort()); - String solidityNode = String.format("%s:%d", Args.getInstance().getNodeDiscoveryBindIp(), + String solidityNode = String.format("%s:%d", Args.getInstance().getNodeLanIp(), Args.getInstance().getRpcOnSolidityPort()); - String pBFTNode = String.format("%s:%d", Args.getInstance().getNodeDiscoveryBindIp(), + String pBFTNode = String.format("%s:%d", Args.getInstance().getNodeLanIp(), Args.getInstance().getRpcOnPBFTPort()); channelFull = ManagedChannelBuilder.forTarget(fullnode) .usePlaintext() @@ -78,14 +82,8 @@ public static void init() throws IOException { blockingStubFull = WalletGrpc.newBlockingStub(channelFull); blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); blockingStubpBFT = WalletSolidityGrpc.newBlockingStub(channelpBFT); - RpcApiService rpcApiService = context.getBean(RpcApiService.class); - RpcApiServiceOnSolidity rpcOnSolidity = context.getBean(RpcApiServiceOnSolidity.class); - RpcApiServiceOnPBFT rpcApiServiceOnPBFT = context.getBean(RpcApiServiceOnPBFT.class); chainBaseManager = context.getBean(ChainBaseManager.class); Application appTest = ApplicationFactory.create(context); - appTest.addService(rpcApiService); - appTest.addService(rpcOnSolidity); - appTest.addService(rpcApiServiceOnPBFT); appTest.startup(); } diff --git a/framework/src/test/java/org/tron/core/services/filter/LiteFnQueryHttpFilterTest.java b/framework/src/test/java/org/tron/core/services/filter/LiteFnQueryHttpFilterTest.java index 5fd4711273e..0f0bdf1eb1f 100644 --- a/framework/src/test/java/org/tron/core/services/filter/LiteFnQueryHttpFilterTest.java +++ b/framework/src/test/java/org/tron/core/services/filter/LiteFnQueryHttpFilterTest.java @@ -7,7 +7,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.Set; -import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; @@ -19,28 +18,33 @@ import org.junit.Before; import org.junit.Test; import org.tron.common.BaseTest; +import org.tron.common.utils.PublicMethod; import org.tron.core.Constant; import org.tron.core.config.args.Args; -import org.tron.core.services.http.FullNodeHttpApiService; -import org.tron.core.services.interfaceOnPBFT.http.PBFT.HttpApiOnPBFTService; -import org.tron.core.services.interfaceOnSolidity.http.solidity.HttpApiOnSolidityService; @Slf4j public class LiteFnQueryHttpFilterTest extends BaseTest { private final String ip = "127.0.0.1"; private int fullHttpPort; - @Resource - private FullNodeHttpApiService httpApiService; - @Resource - private HttpApiOnSolidityService httpApiOnSolidityService; - @Resource - private HttpApiOnPBFTService httpApiOnPBFTService; private final CloseableHttpClient httpClient = HttpClients.createDefault(); static { Args.setParam(new String[]{"-d", dbPath()}, Constant.TEST_CONF); Args.getInstance().setFullNodeAllowShieldedTransactionArgs(false); + Args.getInstance().setRpcEnable(false); + Args.getInstance().setRpcSolidityEnable(false); + Args.getInstance().setRpcPBFTEnable(false); + Args.getInstance().setFullNodeHttpEnable(true); + Args.getInstance().setFullNodeHttpPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setPBFTHttpEnable(true); + Args.getInstance().setPBFTHttpPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setSolidityNodeHttpEnable(true); + Args.getInstance().setSolidityHttpPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setJsonRpcHttpFullNodeEnable(false); + Args.getInstance().setJsonRpcHttpSolidityNodeEnable(false); + Args.getInstance().setJsonRpcHttpPBFTNodeEnable(false); + Args.getInstance().setP2pDisable(true); } /** @@ -48,9 +52,6 @@ public class LiteFnQueryHttpFilterTest extends BaseTest { */ @Before public void init() { - appT.addService(httpApiService); - appT.addService(httpApiOnSolidityService); - appT.addService(httpApiOnPBFTService); appT.startup(); } diff --git a/framework/src/test/java/org/tron/core/services/filter/RpcApiAccessInterceptorTest.java b/framework/src/test/java/org/tron/core/services/filter/RpcApiAccessInterceptorTest.java index 7d95c0c368a..900ca304e7d 100644 --- a/framework/src/test/java/org/tron/core/services/filter/RpcApiAccessInterceptorTest.java +++ b/framework/src/test/java/org/tron/core/services/filter/RpcApiAccessInterceptorTest.java @@ -56,14 +56,18 @@ public class RpcApiAccessInterceptorTest { @BeforeClass public static void init() throws IOException { Args.setParam(new String[] {"-d", temporaryFolder.newFolder().toString()}, Constant.TEST_CONF); + Args.getInstance().setRpcEnable(true); Args.getInstance().setRpcPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setRpcSolidityEnable(true); Args.getInstance().setRpcOnSolidityPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setRpcPBFTEnable(true); Args.getInstance().setRpcOnPBFTPort(PublicMethod.chooseRandomPort()); - String fullNode = String.format("%s:%d", Args.getInstance().getNodeDiscoveryBindIp(), + Args.getInstance().setP2pDisable(true); + String fullNode = String.format("%s:%d", Args.getInstance().getNodeLanIp(), Args.getInstance().getRpcPort()); - String solidityNode = String.format("%s:%d", Args.getInstance().getNodeDiscoveryBindIp(), + String solidityNode = String.format("%s:%d", Args.getInstance().getNodeLanIp(), Args.getInstance().getRpcOnSolidityPort()); - String pBFTNode = String.format("%s:%d", Args.getInstance().getNodeDiscoveryBindIp(), + String pBFTNode = String.format("%s:%d", Args.getInstance().getNodeLanIp(), Args.getInstance().getRpcOnPBFTPort()); ManagedChannel channelFull = ManagedChannelBuilder.forTarget(fullNode) @@ -82,15 +86,7 @@ public static void init() throws IOException { blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); blockingStubPBFT = WalletSolidityGrpc.newBlockingStub(channelPBFT); - RpcApiService rpcApiService = context.getBean(RpcApiService.class); - RpcApiServiceOnSolidity rpcApiServiceOnSolidity = - context.getBean(RpcApiServiceOnSolidity.class); - RpcApiServiceOnPBFT rpcApiServiceOnPBFT = context.getBean(RpcApiServiceOnPBFT.class); - Application appTest = ApplicationFactory.create(context); - appTest.addService(rpcApiService); - appTest.addService(rpcApiServiceOnSolidity); - appTest.addService(rpcApiServiceOnPBFT); appTest.startup(); } diff --git a/framework/src/test/java/org/tron/core/services/http/BroadcastServletTest.java b/framework/src/test/java/org/tron/core/services/http/BroadcastServletTest.java index 37956e71762..d6bf3850f30 100644 --- a/framework/src/test/java/org/tron/core/services/http/BroadcastServletTest.java +++ b/framework/src/test/java/org/tron/core/services/http/BroadcastServletTest.java @@ -27,6 +27,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.tron.common.utils.FileUtil; +import org.tron.common.utils.PublicMethod; import org.tron.core.services.http.solidity.mockito.HttpUrlStreamHandler; @Slf4j @@ -100,7 +101,8 @@ public void doPostTest() throws IOException { final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); - String href = "http://127.0.0.1:8090/wallet/broadcasttransaction"; + String href = "http://127.0.0.1/" + + PublicMethod.chooseRandomPort() + "/wallet/broadcasttransaction"; httpUrlStreamHandler.addConnection(new URL(href), httpUrlConnection); httpUrlConnection.setRequestMethod("POST"); httpUrlConnection.setRequestProperty("Content-Type", "application/json"); diff --git a/framework/src/test/java/org/tron/core/services/http/ClearABIServletTest.java b/framework/src/test/java/org/tron/core/services/http/ClearABIServletTest.java new file mode 100644 index 00000000000..a3a051ec6c9 --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/ClearABIServletTest.java @@ -0,0 +1,92 @@ +package org.tron.core.services.http; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.tron.common.utils.client.utils.HttpMethed.createRequest; + +import com.alibaba.fastjson.JSONObject; +import com.google.protobuf.ByteString; + +import java.io.UnsupportedEncodingException; +import javax.annotation.Resource; + +import org.apache.http.client.methods.HttpPost; + +import org.junit.Assert; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.common.utils.ByteArray; +import org.tron.core.Constant; +import org.tron.core.capsule.ContractCapsule; +import org.tron.core.config.args.Args; +import org.tron.protos.contract.SmartContractOuterClass; + +public class ClearABIServletTest extends BaseTest { + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + @Resource + private ClearABIServlet clearABIServlet; + + private static final String SMART_CONTRACT_NAME = "smart_contract_test"; + private static String CONTRACT_ADDRESS = "A0B4750E2CD76E19DCA331BF5D089B71C3C2798548"; + private static String OWNER_ADDRESS; + private static final long SOURCE_ENERGY_LIMIT = 10L; + + + + private SmartContractOuterClass.SmartContract.Builder createContract( + String contractAddress, String contractName) { + OWNER_ADDRESS = + "A099357684BC659F5166046B56C95A0E99F1265CBD"; + SmartContractOuterClass.SmartContract.Builder builder = + SmartContractOuterClass.SmartContract.newBuilder(); + builder.setName(contractName); + builder.setOriginAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))); + builder.setContractAddress(ByteString.copyFrom(ByteArray.fromHexString(contractAddress))); + builder.setOriginEnergyLimit(SOURCE_ENERGY_LIMIT); + return builder; + } + + @Test + public void testClearABI() { + chainBaseManager.getDynamicPropertiesStore() + .saveAllowTvmConstantinople(1); + SmartContractOuterClass.SmartContract.Builder contract = + createContract(CONTRACT_ADDRESS, SMART_CONTRACT_NAME); + chainBaseManager.getContractStore().put( + ByteArray.fromHexString(CONTRACT_ADDRESS), + new ContractCapsule(contract.build())); + + String jsonParam = "{" + + " \"owner_address\": \"A099357684BC659F5166046B56C95A0E99F1265CBD\"," + + " \"contract_address\": \"A0B4750E2CD76E19DCA331BF5D089B71C3C2798548\"" + + "}"; + MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); + request.setContentType("application/json"); + request.setContent(jsonParam.getBytes(UTF_8)); + + MockHttpServletResponse response = new MockHttpServletResponse(); + clearABIServlet.doPost(request, response); + Assert.assertEquals(200, response.getStatus()); + try { + String contentAsString = response.getContentAsString(); + JSONObject result = JSONObject.parseObject(contentAsString); + assertTrue(result.containsKey("raw_data")); + assertTrue(result.containsKey("txID")); + } catch (UnsupportedEncodingException e) { + fail(e.getMessage()); + } + + } + +} diff --git a/framework/src/test/java/org/tron/core/services/http/CreateAccountServletTest.java b/framework/src/test/java/org/tron/core/services/http/CreateAccountServletTest.java new file mode 100644 index 00000000000..bbc00ce81f0 --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/CreateAccountServletTest.java @@ -0,0 +1,75 @@ +package org.tron.core.services.http; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.fail; +import static org.tron.common.utils.client.utils.HttpMethed.createRequest; + +import com.alibaba.fastjson.JSONObject; +import com.google.protobuf.ByteString; + +import java.io.UnsupportedEncodingException; +import javax.annotation.Resource; + +import org.apache.http.client.methods.HttpPost; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.common.utils.ByteArray; +import org.tron.core.Constant; +import org.tron.core.capsule.AccountCapsule; +import org.tron.core.config.args.Args; +import org.tron.protos.Protocol; + + +public class CreateAccountServletTest extends BaseTest { + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + @Resource + private CreateAccountServlet createAccountServlet; + + @Before + public void init() { + AccountCapsule accountCapsule = new AccountCapsule( + ByteString.copyFrom(ByteArray + .fromHexString("A099357684BC659F5166046B56C95A0E99F1265CD1")), + ByteString.copyFromUtf8("owner"), + Protocol.AccountType.forNumber(1)); + + chainBaseManager.getAccountStore().put(accountCapsule.createDbKey(), + accountCapsule); + } + + @Test + public void testCreate() { + String jsonParam = "{" + + "\"owner_address\": \"A099357684BC659F5166046B56C95A0E99F1265CD1\"," + + "\"account_address\": \"A0B4750E2CD76E19DCA331BF5D089B71C3C2798541\"" + + "}"; + MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); + request.setContentType("application/json"); + request.setContent(jsonParam.getBytes(UTF_8)); + + MockHttpServletResponse response = new MockHttpServletResponse(); + createAccountServlet.doPost(request, response); + + Assert.assertEquals(200, response.getStatus()); + try { + String contentAsString = response.getContentAsString(); + JSONObject result = JSONObject.parseObject(contentAsString); + Assert.assertTrue(result.containsKey("raw_data")); + Assert.assertTrue(result.containsKey("txID")); + } catch (UnsupportedEncodingException e) { + fail(e.getMessage()); + } + } +} diff --git a/framework/src/test/java/org/tron/core/services/http/CreateAssetIssueServletTest.java b/framework/src/test/java/org/tron/core/services/http/CreateAssetIssueServletTest.java new file mode 100644 index 00000000000..4c70eb9252c --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/CreateAssetIssueServletTest.java @@ -0,0 +1,90 @@ +package org.tron.core.services.http; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.fail; +import static org.tron.common.utils.client.utils.HttpMethed.createRequest; + +import com.alibaba.fastjson.JSONObject; +import com.google.protobuf.ByteString; + +import java.io.UnsupportedEncodingException; +import javax.annotation.Resource; + +import org.apache.http.client.methods.HttpPost; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.common.utils.ByteArray; +import org.tron.core.Constant; +import org.tron.core.capsule.AccountCapsule; +import org.tron.core.config.args.Args; +import org.tron.protos.Protocol; + +public class CreateAssetIssueServletTest extends BaseTest { + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + @Resource + private CreateAssetIssueServlet createAssetIssueServlet; + + @Before + public void init() { + AccountCapsule accountCapsule = new AccountCapsule( + ByteString.copyFrom(ByteArray + .fromHexString("A099357684BC659F5166046B56C95A0E99F1265CD1")), + ByteString.copyFromUtf8("owner"), + Protocol.AccountType.forNumber(1)); + accountCapsule.setBalance(10000000000L); + + chainBaseManager.getAccountStore().put(accountCapsule.createDbKey(), + accountCapsule); + } + + @Test + public void testCreate() { + String jsonParam = "{" + + " \"owner_address\": \"A099357684BC659F5166046B56C95A0E99F1265CD1\"," + + " \"name\": \"0x6173736574497373756531353330383934333132313538\"," + + " \"abbr\": \"0x6162627231353330383934333132313538\"," + + " \"total_supply\": 4321," + + " \"trx_num\": 1," + + " \"num\": 1," + + " \"start_time\": 1530894315158," + + " \"end_time\": 1533894312158," + + " \"description\": \"007570646174654e616d6531353330363038383733343633\"," + + " \"url\": \"007570646174654e616d6531353330363038383733343633\"," + + " \"free_asset_net_limit\": 10000," + + " \"public_free_asset_net_limit\": 10000," + + " \"frozen_supply\": {" + + " \"frozen_amount\": 1," + + " \"frozen_days\": 2" + + " }" + + "}"; + MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); + request.setContentType("application/json"); + request.setContent(jsonParam.getBytes(UTF_8)); + + MockHttpServletResponse response = new MockHttpServletResponse(); + createAssetIssueServlet.doPost(request, response); + Assert.assertEquals(200, response.getStatus()); + try { + String contentAsString = response.getContentAsString(); + JSONObject result = JSONObject.parseObject(contentAsString); + Assert.assertTrue(result.containsKey("raw_data")); + Assert.assertTrue(result.containsKey("txID")); + } catch (UnsupportedEncodingException e) { + fail(e.getMessage()); + } + + } + +} diff --git a/framework/src/test/java/org/tron/core/services/http/CreateSpendAuthSigServletTest.java b/framework/src/test/java/org/tron/core/services/http/CreateSpendAuthSigServletTest.java new file mode 100644 index 00000000000..301e4472e69 --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/CreateSpendAuthSigServletTest.java @@ -0,0 +1,60 @@ +package org.tron.core.services.http; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.fail; +import static org.tron.common.utils.client.utils.HttpMethed.createRequest; + +import com.alibaba.fastjson.JSONObject; +import java.io.UnsupportedEncodingException; +import javax.annotation.Resource; +import org.apache.http.client.methods.HttpPost; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.core.Constant; +import org.tron.core.config.args.Args; + +public class CreateSpendAuthSigServletTest extends BaseTest { + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + @Resource + private CreateSpendAuthSigServlet createSpendAuthSigServlet; + + @Test + public void testCreateSpendAuthSig() { + String jsonParam = "{" + + " \"ask\": \"e3ebcba1531f6d9158d9c162660c5d7c04dadf77d" + + "85d7436a9c98b291ff69a09\"," + + " \"tx_hash\": \"3b78fee6e956f915ffe082284c5f18640edca9" + + "c57a5f227e5f7d7eb65ad61502\"," + + " \"alpha\": \"2608999c3a97d005a879ecdaa16fd29ae434fb67" + + "b177c5e875b0c829e6a1db04\"" + + "}"; + MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); + request.setContentType("application/json"); + request.setContent(jsonParam.getBytes(UTF_8)); + + MockHttpServletResponse response = new MockHttpServletResponse(); + createSpendAuthSigServlet.doPost(request, response); + Assert.assertEquals(200, response.getStatus()); + try { + String contentAsString = response.getContentAsString(); + JSONObject result = JSONObject.parseObject(contentAsString); + Assert.assertTrue(result.containsKey("value")); + String resultValue = (String) result.get("value"); + Assert.assertNotNull(resultValue); + } catch (UnsupportedEncodingException e) { + fail(e.getMessage()); + } + } + +} diff --git a/framework/src/test/java/org/tron/core/services/http/CreateWitnessServletTest.java b/framework/src/test/java/org/tron/core/services/http/CreateWitnessServletTest.java new file mode 100644 index 00000000000..6cd6e9e2482 --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/CreateWitnessServletTest.java @@ -0,0 +1,88 @@ +package org.tron.core.services.http; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.fail; +import static org.tron.common.utils.client.utils.HttpMethed.createRequest; + +import com.alibaba.fastjson.JSONObject; +import com.google.protobuf.ByteString; + +import java.io.UnsupportedEncodingException; +import javax.annotation.Resource; + +import org.apache.http.client.methods.HttpPost; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.common.crypto.ECKey; +import org.tron.common.utils.ByteArray; +import org.tron.common.utils.Utils; +import org.tron.core.Constant; +import org.tron.core.capsule.AccountCapsule; +import org.tron.core.capsule.WitnessCapsule; +import org.tron.core.config.args.Args; +import org.tron.protos.Protocol; + +public class CreateWitnessServletTest extends BaseTest { + + @Resource + private CreateWitnessServlet createWitnessServlet; + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + private static WitnessCapsule witnessCapsule; + private static AccountCapsule accountCapsule; + + @Before + public void init() { + ECKey ecKey = new ECKey(Utils.getRandom()); + ByteString address = ByteString.copyFrom(ecKey.getAddress()); + + accountCapsule = + new AccountCapsule(Protocol.Account + .newBuilder() + .setAddress(address).build()); + accountCapsule.setBalance(10000000L); + dbManager.getAccountStore().put(accountCapsule + .getAddress().toByteArray(), accountCapsule); + } + + @Test + public void testCreateWitness() { + chainBaseManager.getDynamicPropertiesStore() + .saveAccountUpgradeCost(1L); + String hexAddress = ByteArray + .toHexString(accountCapsule.getAddress().toByteArray()); + String jsonParam = "{\"owner_address\":\"" + + hexAddress + "\"," + + " \"url\": \"00757064617" + + "4654e616d6531353330363038383733343633\"}"; + MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); + request.setContentType("application/json"); + request.setContent(jsonParam.getBytes(UTF_8)); + + MockHttpServletResponse response = new MockHttpServletResponse(); + createWitnessServlet.doPost(request, response); + Assert.assertEquals(200, response.getStatus()); + try { + String contentAsString = response.getContentAsString(); + JSONObject result = JSONObject.parseObject(contentAsString); + Assert.assertTrue(result.containsKey("raw_data")); + Assert.assertTrue(result.containsKey("txID")); + } catch (UnsupportedEncodingException e) { + fail(e.getMessage()); + } + } + +} + + diff --git a/framework/src/test/java/org/tron/core/services/http/GetAccountByIdServletTest.java b/framework/src/test/java/org/tron/core/services/http/GetAccountByIdServletTest.java new file mode 100644 index 00000000000..38c23a971ff --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/GetAccountByIdServletTest.java @@ -0,0 +1,47 @@ +package org.tron.core.services.http; + +import static org.apache.commons.lang3.StringUtils.isNotEmpty; + +import javax.annotation.Resource; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.core.Constant; +import org.tron.core.config.args.Args; + +public class GetAccountByIdServletTest extends BaseTest { + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + @Resource + private GetAccountByIdServlet getAccountByIdServlet; + + public MockHttpServletRequest createRequest(String contentType) { + MockHttpServletRequest request = new MockHttpServletRequest(); + request.setMethod("POST"); + if (isNotEmpty(contentType)) { + request.setContentType(contentType); + } + request.setCharacterEncoding("UTF-8"); + return request; + } + + @Test + public void testGetAccountById() { + String jsonParam = "{\"account_id\": \"6161616162626262\"}"; + MockHttpServletRequest request = createRequest("application/json"); + request.setContent(jsonParam.getBytes()); + MockHttpServletResponse response = new MockHttpServletResponse(); + + getAccountByIdServlet.doPost(request, response); + Assert.assertEquals(200, response.getStatus()); + } +} diff --git a/framework/src/test/java/org/tron/core/services/http/GetBlockByIdServletTest.java b/framework/src/test/java/org/tron/core/services/http/GetBlockByIdServletTest.java new file mode 100644 index 00000000000..8b213e12640 --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/GetBlockByIdServletTest.java @@ -0,0 +1,51 @@ +package org.tron.core.services.http; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.tron.common.utils.client.utils.HttpMethed.createRequest; + +import javax.annotation.Resource; + +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.core.Constant; +import org.tron.core.config.args.Args; + +public class GetBlockByIdServletTest extends BaseTest { + + @Resource + private GetBlockByIdServlet getBlockByIdServlet; + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + @Test + public void testGetBlockById() { + String jsonParam = "{\"value\": " + + "\"0000000002951a2f65db6725c2d0583f1ab9bdb1520eeedece99d9c98f3\"}"; + MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); + request.setContentType("application/json"); + request.setContent(jsonParam.getBytes(UTF_8)); + MockHttpServletResponse response = new MockHttpServletResponse(); + getBlockByIdServlet.doPost(request, response); + Assert.assertEquals(200, response.getStatus()); + } + + @Test + public void testGet() { + MockHttpServletRequest request = createRequest(HttpGet.METHOD_NAME); + request.addParameter("value", "0000000002951a2f65db6725c2d0583f1ab9bdb1520eeedece99d9c98f3"); + MockHttpServletResponse response = new MockHttpServletResponse(); + getBlockByIdServlet.doGet(request, response); + Assert.assertEquals(200, response.getStatus()); + } +} diff --git a/framework/src/test/java/org/tron/core/services/http/GetBlockByNumServletTest.java b/framework/src/test/java/org/tron/core/services/http/GetBlockByNumServletTest.java new file mode 100644 index 00000000000..5ff84c54dbe --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/GetBlockByNumServletTest.java @@ -0,0 +1,69 @@ +package org.tron.core.services.http; + +import static org.junit.Assert.assertTrue; +import static org.tron.common.utils.client.utils.HttpMethed.createRequest; + +import com.alibaba.fastjson.JSONObject; + +import java.io.UnsupportedEncodingException; +import javax.annotation.Resource; + +import org.apache.http.client.methods.HttpPost; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.core.Constant; +import org.tron.core.config.args.Args; + +public class GetBlockByNumServletTest extends BaseTest { + + @Resource + private GetBlockByNumServlet getBlockByNumServlet; + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + @Test + public void testGetBlockByNum() { + String jsonParam = "{\"number\": 1}"; + MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); + request.setContentType("application/json"); + request.setContent(jsonParam.getBytes()); + MockHttpServletResponse response = new MockHttpServletResponse(); + + try { + getBlockByNumServlet.doPost(request, response); + String contentAsString = response.getContentAsString(); + JSONObject result = JSONObject.parseObject(contentAsString); + assertTrue(result.containsKey("blockID")); + assertTrue(result.containsKey("transactions")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + + @Test + public void testGet() { + String jsonParam = "{\"number\": 1}"; + MockHttpServletRequest request = createRequest("application/json"); + request.setContent(jsonParam.getBytes()); + MockHttpServletResponse response = new MockHttpServletResponse(); + + try { + getBlockByNumServlet.doPost(request, response); + String contentAsString = response.getContentAsString(); + JSONObject result = JSONObject.parseObject(contentAsString); + assertTrue(result.containsKey("blockID")); + assertTrue(result.containsKey("transactions")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + +} diff --git a/framework/src/test/java/org/tron/core/services/http/GetTransactionInfoByBlockNumServletTest.java b/framework/src/test/java/org/tron/core/services/http/GetTransactionInfoByBlockNumServletTest.java new file mode 100644 index 00000000000..0a1a2e4ac5a --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/GetTransactionInfoByBlockNumServletTest.java @@ -0,0 +1,79 @@ +package org.tron.core.services.http; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.tron.common.utils.client.utils.HttpMethed.createRequest; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.io.UnsupportedEncodingException; +import javax.annotation.Resource; + +import org.apache.http.client.methods.HttpPost; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.common.utils.ByteArray; +import org.tron.core.Constant; + +import org.tron.core.capsule.TransactionInfoCapsule; +import org.tron.core.capsule.TransactionRetCapsule; +import org.tron.core.config.args.Args; +import org.tron.core.db.TransactionStoreTest; + +public class GetTransactionInfoByBlockNumServletTest extends BaseTest { + + @Resource + private GetTransactionInfoByBlockNumServlet getTransactionInfoByBlockNumServlet; + private static final byte[] transactionId = TransactionStoreTest.randomBytes(32); + private static TransactionRetCapsule transactionRetCapsule; + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + @Before + public void init() { + byte[] blockNum = ByteArray.fromLong(100); + TransactionInfoCapsule transactionInfoCapsule = new TransactionInfoCapsule(); + + transactionInfoCapsule.setId(transactionId); + transactionInfoCapsule.setFee(1000L); + transactionInfoCapsule.setBlockNumber(100L); + transactionInfoCapsule.setBlockTimeStamp(200L); + + transactionRetCapsule = new TransactionRetCapsule(); + transactionRetCapsule.addTransactionInfo(transactionInfoCapsule.getInstance()); + chainBaseManager.getTransactionRetStore() + .put(blockNum, transactionRetCapsule); + } + + @Test + public void testGetTransactionInfoByBlockNum() { + String jsonParam = "{\"num\" : 100}"; + MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); + request.setContentType("application/json"); + request.setContent(jsonParam.getBytes(UTF_8)); + MockHttpServletResponse response = new MockHttpServletResponse(); + + getTransactionInfoByBlockNumServlet.doPost(request, response); + Assert.assertEquals(200, response.getStatus()); + try { + String contentAsString = response.getContentAsString(); + JSONArray array = JSONArray.parseArray(contentAsString); + Assert.assertEquals(1, array.size()); + JSONObject object = (JSONObject) array.get(0); + Assert.assertEquals(1000, object.get("fee")); + Assert.assertEquals(100, object.get("blockNumber")); + } catch (UnsupportedEncodingException e) { + Assert.fail(e.getMessage()); + } + } +} diff --git a/framework/src/test/java/org/tron/core/services/http/GetTransactionInfoByIdServletTest.java b/framework/src/test/java/org/tron/core/services/http/GetTransactionInfoByIdServletTest.java new file mode 100644 index 00000000000..900c41c7df8 --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/GetTransactionInfoByIdServletTest.java @@ -0,0 +1,126 @@ +package org.tron.core.services.http; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.tron.common.utils.client.utils.HttpMethed.createRequest; + +import com.alibaba.fastjson.JSONObject; +import com.google.protobuf.ByteString; + +import java.io.UnsupportedEncodingException; +import javax.annotation.Resource; + +import org.apache.http.client.methods.HttpPost; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.common.utils.ByteArray; +import org.tron.core.Constant; +import org.tron.core.Wallet; +import org.tron.core.capsule.AccountCapsule; +import org.tron.core.capsule.TransactionCapsule; +import org.tron.core.capsule.TransactionInfoCapsule; +import org.tron.core.capsule.TransactionRetCapsule; +import org.tron.core.config.args.Args; +import org.tron.core.db.TransactionStore; +import org.tron.core.db.TransactionStoreTest; +import org.tron.core.store.TransactionRetStore; +import org.tron.protos.Protocol; +import org.tron.protos.contract.BalanceContract; + +public class GetTransactionInfoByIdServletTest extends BaseTest { + + @Resource + private GetTransactionInfoByIdServlet getTransactionInfoByIdServlet; + @Resource + private TransactionStore transactionStore; + @Resource + private TransactionRetStore transactionRetStore; + + private static final String OWNER_ADDRESS = + Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049abc"; + private static final String TO_ADDRESS = + Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049abc"; + private static final long AMOUNT = 100; + private static final byte[] KEY_1 = TransactionStoreTest.randomBytes(21); + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + @Before + public void init() { + byte[] blockNum = ByteArray.fromLong(100); + TransactionInfoCapsule transactionInfoCapsule = new TransactionInfoCapsule(); + + transactionInfoCapsule.setId(KEY_1); + transactionInfoCapsule.setFee(1000L); + transactionInfoCapsule.setBlockNumber(100L); + transactionInfoCapsule.setBlockTimeStamp(200L); + + TransactionRetCapsule transactionRetCapsule = new TransactionRetCapsule(); + transactionRetCapsule.addTransactionInfo(transactionInfoCapsule.getInstance()); + chainBaseManager.getTransactionRetStore() + .put(blockNum, transactionRetCapsule); + transactionRetStore.put(blockNum, transactionRetCapsule); + + AccountCapsule owner = new AccountCapsule( + ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)), + ByteString.copyFromUtf8("owner"), + Protocol.AccountType.forNumber(1)); + owner.setBalance(1000000L); + + AccountCapsule to = new AccountCapsule( + ByteString.copyFrom(ByteArray.fromHexString(TO_ADDRESS)), + ByteString.copyFromUtf8("to"), + Protocol.AccountType.forNumber(1)); + to.setBalance(1000000L); + + chainBaseManager.getAccountStore().put(owner.createDbKey(), + owner); + chainBaseManager.getAccountStore().put(to.createDbKey(), + to); + BalanceContract.TransferContract transferContract = + getContract(AMOUNT, OWNER_ADDRESS, TO_ADDRESS); + TransactionCapsule transactionCapsule = new TransactionCapsule(transferContract, + chainBaseManager.getAccountStore()); + transactionCapsule.setBlockNum(100L); + transactionStore.put(KEY_1, transactionCapsule); + } + + private BalanceContract.TransferContract getContract(long count, + String owneraddress, String toaddress) { + return BalanceContract.TransferContract.newBuilder() + .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(owneraddress))) + .setToAddress(ByteString.copyFrom(ByteArray.fromHexString(toaddress))) + .setAmount(count) + .build(); + } + + @Test + public void testGetInfoById() { + String jsonParam = "{\"value\" : " + + "\"" + ByteArray.toHexString(KEY_1) + "\"}"; + MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); + request.setContentType("application/json"); + request.setContent(jsonParam.getBytes(UTF_8)); + MockHttpServletResponse response = new MockHttpServletResponse(); + + getTransactionInfoByIdServlet.doPost(request, response); + Assert.assertEquals(200, response.getStatus()); + try { + String contentAsString = response.getContentAsString(); + JSONObject jsonObject = JSONObject.parseObject(contentAsString); + Assert.assertEquals(1000, jsonObject.get("fee")); + Assert.assertEquals(100, jsonObject.get("blockNumber")); + } catch (UnsupportedEncodingException e) { + Assert.fail(e.getMessage()); + } + } +} diff --git a/framework/src/test/java/org/tron/core/services/http/GetTransactionListFromPendingServletTest.java b/framework/src/test/java/org/tron/core/services/http/GetTransactionListFromPendingServletTest.java new file mode 100644 index 00000000000..614d520280d --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/GetTransactionListFromPendingServletTest.java @@ -0,0 +1,38 @@ +package org.tron.core.services.http; + +import static org.junit.Assert.assertEquals; +import static org.tron.common.utils.client.utils.HttpMethed.createRequest; + +import javax.annotation.Resource; + +import org.apache.http.client.methods.HttpGet; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.core.Constant; +import org.tron.core.config.args.Args; + + +public class GetTransactionListFromPendingServletTest extends BaseTest { + + @Resource + private GetTransactionListFromPendingServlet getTransactionListFromPendingServlet; + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + @Test + public void testGet() { + MockHttpServletRequest request = createRequest(HttpGet.METHOD_NAME); + MockHttpServletResponse response = new MockHttpServletResponse(); + getTransactionListFromPendingServlet.doPost(request, response); + assertEquals(200, response.getStatus()); + } + +} diff --git a/framework/src/test/java/org/tron/core/services/http/JsonFormatTest.java b/framework/src/test/java/org/tron/core/services/http/JsonFormatTest.java new file mode 100644 index 00000000000..a8525b0f526 --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/JsonFormatTest.java @@ -0,0 +1,255 @@ +package org.tron.core.services.http; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import com.google.protobuf.ByteString; +import com.google.protobuf.UnknownFieldSet; + +import java.io.CharArrayReader; +import java.io.IOException; +import java.io.StringWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.After; +import org.junit.Test; +import org.mockito.Mockito; +import org.tron.protos.Protocol; + +public class JsonFormatTest { + @After + public void clearMocks() { + Mockito.framework().clearInlineMocks(); + } + + @Test + public void testPrintErrorMsg() { + Exception ex = new Exception("test"); + String out = JsonFormat.printErrorMsg(ex); + assertEquals("{\"Error\":\"test\"}", out); + } + + @Test + public void testPrintWithHelloMessage() throws IOException { + Protocol.HelloMessage message = Protocol.HelloMessage.newBuilder() + .setAddress(ByteString.copyFrom("address".getBytes())) + .build(); + StringWriter output = new StringWriter(); + + JsonFormat.print(message, output, true); + assertNotNull(output.toString()); + } + + private UnknownFieldSet createValidUnknownFieldSet() { + UnknownFieldSet unknownFieldSet2 = UnknownFieldSet.newBuilder().build(); + UnknownFieldSet.Field unknownField1 = UnknownFieldSet.Field.newBuilder() + .addFixed32(123) + .addFixed64(12345L) + .addGroup(unknownFieldSet2) + .addLengthDelimited(ByteString.copyFrom("length".getBytes())) + .addVarint(12345678L) + .build(); + + return UnknownFieldSet.newBuilder() + .addField(1, unknownField1) + .build(); + } + + @Test + public void testPrintWithFields() throws IOException { + UnknownFieldSet unknownFieldSet = createValidUnknownFieldSet(); + StringWriter output = new StringWriter(); + JsonFormat.print(unknownFieldSet, output, true); + assertNotNull(output.toString()); + } + + @Test + public void testPrintToString() { + UnknownFieldSet unknownFieldSet = createValidUnknownFieldSet(); + String output = JsonFormat.printToString(unknownFieldSet, true); + assertNotNull(output); + } + + @Test + public void testUnsignedToString() throws Exception { + Method privateMethod = JsonFormat.class.getDeclaredMethod("unsignedToString", int.class); + privateMethod.setAccessible(true); + String out3 = (String)privateMethod.invoke(null, 100); + assertEquals("100", out3); + String out4 = (String)privateMethod.invoke(null, -100); + assertNotNull(out4); + } + + @Test + public void testToStringBuilderWithNonReadableInput() throws Exception { + String inputString = "Hello, World!"; + Readable input = new CharArrayReader(inputString.toCharArray()); + + Method privateMethod = JsonFormat.class.getDeclaredMethod("toStringBuilder", Readable.class); + privateMethod.setAccessible(true); + + StringBuilder out = (StringBuilder)privateMethod.invoke(null, input); + assertEquals(inputString, out.toString()); + } + + + @Test + public void testUnicodeEscaped() throws Exception { + Method privateMethod = JsonFormat.class.getDeclaredMethod("unicodeEscaped", char.class); + privateMethod.setAccessible(true); + + + char input1 = 0x09; + String out = (String)privateMethod.invoke(null, input1); + assertNotNull(out); + + char input2 = 0x99; + String out2 = (String)privateMethod.invoke(null, input2); + assertNotNull(out2); + + char input3 = 0x999; + String out3 = (String)privateMethod.invoke(null, input3); + assertNotNull(out3); + + char input4 = 0x1001; + String out4 = (String)privateMethod.invoke(null, input4); + assertNotNull(out4); + } + + @Test + public void testEscapeText() throws Exception { + Method privateMethod = JsonFormat.class.getDeclaredMethod("escapeText", String.class); + privateMethod.setAccessible(true); + + String input1 = "\b\f\n\r\t\\\"\\b\\f\\n\\r\\t\\\\\"test123"; + String out = (String)privateMethod.invoke(null, input1); + assertNotNull(out); + } + + @Test + public void testAppendEscapedUnicode() throws Exception { + Method privateMethod = JsonFormat.class.getDeclaredMethod("appendEscapedUnicode", + StringBuilder.class, char.class); + privateMethod.setAccessible(true); + + char input1 = 0x09; + StringBuilder out1 = new StringBuilder(); + + privateMethod.invoke(null, out1, input1); + assertNotNull(out1); + + char input2 = 0x99; + StringBuilder out2 = new StringBuilder(); + privateMethod.invoke(null, out2, input2); + assertNotNull(out2); + + char input3 = 0x999; + StringBuilder out3 = new StringBuilder(); + privateMethod.invoke(null, out3, input3); + assertNotNull(out3); + + char input4 = 0x1001; + StringBuilder out4 = new StringBuilder(); + privateMethod.invoke(null, out4, input4); + assertNotNull(out4); + } + + @Test + public void testUnescapeText() throws Exception { + Method privateMethod = JsonFormat.class.getDeclaredMethod("unescapeText", String.class); + privateMethod.setAccessible(true); + + String input = "\\u1234\\b\\f\\n\\r\\t\\\\\"test123";; + String out = (String)privateMethod.invoke(null, input); + assertNotNull(out); + } + + @Test + public void testDigitValue() throws Exception { + Method privateMethod = JsonFormat.class.getDeclaredMethod("digitValue", char.class); + privateMethod.setAccessible(true); + + char input = '1'; + int out = (int)privateMethod.invoke(null, input); + assertEquals(1, out); + + char input1 = 'b'; + int out1 = (int)privateMethod.invoke(null, input1); + assertEquals(11, out1); + + char input2 = 'B'; + int out2 = (int)privateMethod.invoke(null, input2); + assertEquals(11, out2); + } + + @Test + public void testParseUInt64() throws Exception { + Method privateMethod = JsonFormat.class.getDeclaredMethod("parseUInt64", String.class); + privateMethod.setAccessible(true); + + String input = "12312312312"; + long out = (long)privateMethod.invoke(null, input); + assertEquals(12312312312L, out); + + String input1 = "0x10"; + long out1 = (long)privateMethod.invoke(null, input1); + assertEquals(16L, out1); + + String input2 = "010"; + long out2 = (long)privateMethod.invoke(null, input2); + assertEquals(8L, out2); + + String input3 = "-12312312312"; + Throwable thrown = assertThrows(InvocationTargetException.class, () -> { + privateMethod.invoke(null, input3); + }); + Throwable cause = thrown.getCause(); + assertTrue(cause instanceof NumberFormatException); + } + + @Test + public void testParseInteger() throws Exception { + Method privateMethod = JsonFormat.class.getDeclaredMethod("parseInteger", + String.class, boolean.class, boolean.class); + privateMethod.setAccessible(true); + + String input1 = "92233720368547758070"; + Throwable thrown = assertThrows(InvocationTargetException.class, () -> { + privateMethod.invoke(null,input1, true, true); + }); + Throwable cause = thrown.getCause(); + assertTrue(cause instanceof NumberFormatException); + + String input5 = "92233720368547758070"; + thrown = assertThrows(InvocationTargetException.class, () -> { + privateMethod.invoke(null,input5, false, true); + }); + cause = thrown.getCause(); + assertTrue(cause instanceof NumberFormatException); + + String input2 = "-92233720368547758"; + thrown = assertThrows(InvocationTargetException.class, () -> { + privateMethod.invoke(null,input2, false, true); + }); + cause = thrown.getCause(); + assertTrue(cause instanceof NumberFormatException); + + String input3 = "92233720368547758070"; + thrown = assertThrows(InvocationTargetException.class, () -> { + privateMethod.invoke(null,input3, false, false); + }); + cause = thrown.getCause(); + assertTrue(cause instanceof NumberFormatException); + + String input4 = "-92233720368547758070"; + thrown = assertThrows(InvocationTargetException.class, () -> { + privateMethod.invoke(null,input4, true, false); + }); + cause = thrown.getCause(); + assertTrue(cause instanceof NumberFormatException); + } + +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/services/http/TriggerSmartContractServletTest.java b/framework/src/test/java/org/tron/core/services/http/TriggerSmartContractServletTest.java index f363b7fbefc..c6fa5da76e4 100644 --- a/framework/src/test/java/org/tron/core/services/http/TriggerSmartContractServletTest.java +++ b/framework/src/test/java/org/tron/core/services/http/TriggerSmartContractServletTest.java @@ -1,7 +1,6 @@ package org.tron.core.services.http; import com.google.gson.JsonObject; -import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpResponse; import org.bouncycastle.util.encoders.Hex; @@ -9,10 +8,9 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.tron.common.BaseTest; import org.tron.common.utils.ByteArray; -import org.tron.common.utils.client.Configuration; +import org.tron.common.utils.PublicMethod; import org.tron.common.utils.client.utils.HttpMethed; import org.tron.core.Constant; import org.tron.core.capsule.ContractCapsule; @@ -25,31 +23,25 @@ @Slf4j public class TriggerSmartContractServletTest extends BaseTest { - private static final String httpNode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list") - .get(0); + private static String httpNode; private static final byte[] ownerAddr = Hex.decode("410000000000000000000000000000000000000000"); private static final byte[] contractAddr = Hex.decode( "41000000000000000000000000000000000000dEaD"); - @Resource - private FullNodeHttpApiService httpApiService; - @BeforeClass public static void init() throws Exception { Args.setParam( - new String[]{"--output-directory", dbPath(), "--debug", "--witness"}, Constant.TEST_CONF); + new String[]{"--output-directory", dbPath(), "--debug"}, Constant.TEST_CONF); Args.getInstance().needSyncCheck = false; - - // build app context - DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - beanFactory.setAllowCircularReferences(false); + Args.getInstance().setFullNodeHttpEnable(true); + Args.getInstance().setFullNodeHttpPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setP2pDisable(true); + httpNode = String.format("%s:%d", "127.0.0.1", + Args.getInstance().getFullNodeHttpPort()); } @Before public void before() { - appT.addService(httpApiService); - // start services appT.startup(); diff --git a/framework/src/test/java/org/tron/core/services/http/UpdateAccountServletTest.java b/framework/src/test/java/org/tron/core/services/http/UpdateAccountServletTest.java new file mode 100644 index 00000000000..e5064e2013b --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/UpdateAccountServletTest.java @@ -0,0 +1,77 @@ +package org.tron.core.services.http; + +import static org.tron.common.utils.client.utils.HttpMethed.createRequest; + +import javax.annotation.Resource; +import org.apache.http.client.methods.HttpPost; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.tron.common.BaseTest; +import org.tron.core.Constant; +import org.tron.core.config.args.Args; + +public class UpdateAccountServletTest extends BaseTest { + + static { + Args.setParam( + new String[]{ + "--output-directory", dbPath(), + }, Constant.TEST_CONF + ); + } + + @Resource + private UpdateAccountServlet updateAccountServlet; + + private String getParam() { + return "{" + + " \"owner_address\": \"TXmVpin5vq5gdZsciyyjdZgKRUju4st1wM\"," + + " \"owner\": {" + + " \"type\": 0," + + " \"permission_name\": \"owner\"," + + " \"threshold\": 1," + + " \"keys\": [{" + + " \"address\": \"TXmVpin5vq5gdZsciyyjdZgKRUju4st1wM\"," + + " \"weight\": 1" + + " }]" + + " }," + + " \"witness\": {" + + " \"type\": 1," + + " \"permission_name\": \"witness\"," + + " \"threshold\": 1," + + " \"keys\": [{" + + " \"address\": \"TXmVpin5vq5gdZsciyyjdZgKRUju4st1wM\"," + + " \"weight\": 1" + + " }]" + + " }," + + " \"actives\": [{" + + " \"type\": 2," + + " \"permission_name\": \"active12323\"," + + " \"threshold\": 2," + + " \"operations\": " + + "\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," + + " \"keys\": [{" + + " \"address\": \"TXmVpin5vq5gdZsciyyjdZgKRUju4st1wM\"," + + " \"weight\": 1" + + " }, {" + + " \"address\": \"TXmVpin5vq5gdZsciyyjdZgKRUju4st1wM\"," + + " \"weight\": 1" + + " }]" + + " }]," + + " \"visible\": true}"; + } + + @Test + public void test() { + String jsonParam = getParam(); + MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); + request.setContentType("application/json"); + request.setContent(jsonParam.getBytes()); + MockHttpServletResponse response = new MockHttpServletResponse(); + + updateAccountServlet.doPost(request, response); + Assert.assertEquals(200, response.getStatus()); + } +} diff --git a/framework/src/test/java/org/tron/core/services/http/UtilMockTest.java b/framework/src/test/java/org/tron/core/services/http/UtilMockTest.java new file mode 100644 index 00000000000..221c5a7a165 --- /dev/null +++ b/framework/src/test/java/org/tron/core/services/http/UtilMockTest.java @@ -0,0 +1,243 @@ +package org.tron.core.services.http; + +import com.alibaba.fastjson.JSONObject; +import com.google.protobuf.ByteString; + +import java.security.InvalidParameterException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.tron.api.GrpcAPI; +import org.tron.common.utils.Sha256Hash; +import org.tron.core.capsule.BlockCapsule; +import org.tron.core.capsule.TransactionCapsule; +import org.tron.p2p.utils.ByteArray; +import org.tron.protos.Protocol; +import org.tron.protos.contract.BalanceContract; +import org.tron.protos.contract.SmartContractOuterClass; + +public class UtilMockTest { + @After + public void clearMocks() { + Mockito.framework().clearInlineMocks(); + } + + + @Test + public void testPrintTransactionFee() { + Protocol.ResourceReceipt resourceReceipt = Protocol.ResourceReceipt.newBuilder() + .build(); + Protocol.TransactionInfo result = Protocol.TransactionInfo.newBuilder() + .setReceipt(resourceReceipt) + .build(); + String transactionFee = JsonFormat.printToString(result, true); + String out = Util.printTransactionFee(transactionFee); + Assert.assertNotNull(out); + } + + @Test + public void testPrintBlockList() { + BlockCapsule blockCapsule1 = new BlockCapsule(1, Sha256Hash.ZERO_HASH, + System.currentTimeMillis(), Sha256Hash.ZERO_HASH.getByteString()); + BlockCapsule blockCapsule2 = new BlockCapsule(1, Sha256Hash.ZERO_HASH, + System.currentTimeMillis(), Sha256Hash.ZERO_HASH.getByteString()); + GrpcAPI.BlockList list = GrpcAPI.BlockList.newBuilder() + .addBlock(blockCapsule1.getInstance()) + .addBlock(blockCapsule2.getInstance()) + .build(); + String out = Util.printBlockList(list, true); + Assert.assertNotNull(out); + } + + @Test + public void testPrintTransactionList() { + TransactionCapsule transactionCapsule = getTransactionCapsuleExample(); + GrpcAPI.TransactionList list = GrpcAPI.TransactionList.newBuilder() + .addTransaction(transactionCapsule.getInstance()) + .build(); + String out = Util.printTransactionList(list, true); + Assert.assertNotNull(out); + } + + private TransactionCapsule getTransactionCapsuleExample() { + final String OWNER_ADDRESS = "41548794500882809695a8a687866e76d4271a1abc"; + final String RECEIVER_ADDRESS = "41abd4b9367799eaa3197fecb144eb71de1e049150"; + BalanceContract.TransferContract.Builder builder2 = + BalanceContract.TransferContract.newBuilder() + .setOwnerAddress( + ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))) + .setToAddress( + ByteString.copyFrom(ByteArray.fromHexString(RECEIVER_ADDRESS))); + return new TransactionCapsule(builder2.build(), + Protocol.Transaction.Contract.ContractType.TransferContract); + } + + @Test + public void testPrintTransactionSignWeight() { + TransactionCapsule transactionCapsule = getTransactionCapsuleExample(); + GrpcAPI.TransactionExtention transactionExtention = + GrpcAPI.TransactionExtention.newBuilder() + .setTransaction(transactionCapsule.getInstance()) + .build(); + GrpcAPI.TransactionSignWeight txSignWeight = + GrpcAPI.TransactionSignWeight.newBuilder() + .setTransaction(transactionExtention) + .build(); + + String out = Util.printTransactionSignWeight(txSignWeight, true); + Assert.assertNotNull(out); + } + + @Test + public void testPrintTransactionApprovedList() { + TransactionCapsule transactionCapsule = getTransactionCapsuleExample(); + GrpcAPI.TransactionExtention transactionExtention = + GrpcAPI.TransactionExtention.newBuilder() + .setTransaction(transactionCapsule.getInstance()) + .build(); + GrpcAPI.TransactionApprovedList transactionApprovedList = + GrpcAPI.TransactionApprovedList.newBuilder() + .setTransaction(transactionExtention) + .build(); + String out = Util.printTransactionApprovedList( + transactionApprovedList, true); + Assert.assertNotNull(out); + } + + @Test + public void testGenerateContractAddress() { + final String OWNER_ADDRESS = "41548794500882809695a8a687866e76d4271a1abc"; + TransactionCapsule transactionCapsule = getTransactionCapsuleExample(); + byte[] out = Util.generateContractAddress( + transactionCapsule.getInstance(), OWNER_ADDRESS.getBytes()); + Assert.assertNotNull(out); + } + + @Test + public void testPrintTransactionToJSON() { + final String OWNER_ADDRESS = "41548794500882809695a8a687866e76d4271a1abc"; + SmartContractOuterClass.CreateSmartContract.Builder builder2 = + SmartContractOuterClass.CreateSmartContract.newBuilder() + .setOwnerAddress( + ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))); + TransactionCapsule transactionCapsule = new TransactionCapsule(builder2.build(), + Protocol.Transaction.Contract.ContractType.CreateSmartContract); + + JSONObject out = Util.printTransactionToJSON( + transactionCapsule.getInstance(), true); + Assert.assertNotNull(out); + } + + @Test + public void testGetContractType() { + String out = Util.getContractType("{\"contractType\":\"123\"}\n"); + Assert.assertEquals("123", out); + } + + @Test + public void testGetHexAddress() { + String out = Util.getHexAddress("TBxSocpujP6UGKV5ydXNVTDQz7fAgdmoaB"); + Assert.assertNotNull(out); + + Assert.assertNull(Util.getHexAddress(null)); + } + + @Test + public void testSetTransactionPermissionId() { + TransactionCapsule transactionCapsule = getTransactionCapsuleExample(); + Protocol.Transaction out = Util.setTransactionPermissionId( + 123, transactionCapsule.getInstance()); + Assert.assertNotNull(out); + } + + @Test + public void testSetTransactionExtraData() { + TransactionCapsule transactionCapsule = getTransactionCapsuleExample(); + JSONObject jsonObject = JSONObject.parseObject("{\"extra_data\":\"test\"}"); + Protocol.Transaction out = Util.setTransactionExtraData(jsonObject, + transactionCapsule.getInstance(), true); + Assert.assertNotNull(out); + } + + @Test + public void testConvertOutput() { + Protocol.Account account = Protocol.Account.newBuilder().build(); + String out = Util.convertOutput(account); + Assert.assertNotNull(out); + + account = Protocol.Account.newBuilder() + .setAssetIssuedID(ByteString.copyFrom("asset_issued_ID".getBytes())) + .build(); + out = Util.convertOutput(account); + Assert.assertNotNull(out); + } + + @Test + public void testConvertLogAddressToTronAddress() { + List logs = new ArrayList<>(); + logs.add(Protocol.TransactionInfo.Log.newBuilder() + .setAddress(ByteString.copyFrom("address".getBytes())) + .setData(ByteString.copyFrom("data".getBytes())) + .addTopics(ByteString.copyFrom("topic".getBytes())) + .build()); + + Protocol.TransactionInfo.Builder builder = Protocol.TransactionInfo.newBuilder() + .addAllLog(logs); + List logList = + Util.convertLogAddressToTronAddress(builder.build()); + Assert.assertNotNull(logList.size() > 0); + } + + @Test + public void testValidateParameter() { + String contract = "{\"address\":\"owner_address\"}"; + Assert.assertThrows( + InvalidParameterException.class, + () -> { + Util.validateParameter(contract); + } + ); + String contract1 = + "{\"owner_address\":\"owner_address\"," + + " \"contract_address1\":\"contract_address\", \"data1\":\"data\"}"; + Assert.assertThrows( + InvalidParameterException.class, + () -> { + Util.validateParameter(contract1); + } + ); + String contract2 = + "{\"owner_address\":\"owner_address\", " + + "\"function_selector\":\"function_selector\", \"data\":\"data\"}"; + Assert.assertThrows( + InvalidParameterException.class, + () -> { + Util.validateParameter(contract2); + } + ); + } + + @Test + public void testGetJsonString() { + String str = ""; + String ret = Util.getJsonString(str); + Assert.assertTrue(StringUtils.isEmpty(ret)); + + String str1 = "{\"owner_address\":\"owner_address\"}"; + String ret1 = Util.getJsonString(str1); + Assert.assertTrue(str1.equals(ret1)); + + String str2 = "owner_address=owner_address&contract_address=contract_address"; + String ret2 = Util.getJsonString(str2); + String expect = + "{\"owner_address\":\"owner_address\"," + + "\"contract_address\":\"contract_address\"}"; + Assert.assertEquals(expect, ret2); + } + +} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/core/services/http/solidity/GetTransactionByIdSolidityServletTest.java b/framework/src/test/java/org/tron/core/services/http/solidity/GetTransactionByIdSolidityServletTest.java index 70c74e3a2a7..e1abb41d1e1 100644 --- a/framework/src/test/java/org/tron/core/services/http/solidity/GetTransactionByIdSolidityServletTest.java +++ b/framework/src/test/java/org/tron/core/services/http/solidity/GetTransactionByIdSolidityServletTest.java @@ -27,6 +27,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.tron.common.utils.FileUtil; +import org.tron.common.utils.PublicMethod; import org.tron.core.services.http.solidity.mockito.HttpUrlStreamHandler; @@ -91,7 +92,8 @@ public void doPostTest() throws IOException { final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); - String href = "http://127.0.0.1:8091/walletsolidity/gettransactioninfobyid"; + String href = "http://127.0.0.1/" + + PublicMethod.chooseRandomPort() + "/walletsolidity/gettransactioninfobyid"; httpUrlStreamHandler.addConnection(new URL(href), httpUrlConnection); httpUrlConnection.setRequestMethod("POST"); httpUrlConnection.setRequestProperty("Content-Type", "application/json"); @@ -146,7 +148,8 @@ public void doGetTest() throws IOException { final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); - String href = "http://127.0.0.1:8091/walletsolidity/gettransactioninfobyid"; + String href = "http://127.0.0.1/" + + PublicMethod.chooseRandomPort() + "/walletsolidity/gettransactioninfobyid"; httpUrlStreamHandler.addConnection(new URL(href), httpUrlConnection); httpUrlConnection.setRequestMethod("GET"); httpUrlConnection.setRequestProperty("Content-Type", "application/json"); diff --git a/framework/src/test/java/org/tron/core/services/stop/BlockTimeStopTest.java b/framework/src/test/java/org/tron/core/services/stop/BlockTimeStopTest.java index 86c32e66507..1e16ad6c3b0 100644 --- a/framework/src/test/java/org/tron/core/services/stop/BlockTimeStopTest.java +++ b/framework/src/test/java/org/tron/core/services/stop/BlockTimeStopTest.java @@ -5,7 +5,7 @@ import java.util.Date; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; -import org.quartz.CronExpression; +import org.tron.common.cron.CronExpression; import org.tron.common.parameter.CommonParameter; @Slf4j diff --git a/framework/src/test/java/org/tron/core/services/stop/ConditionallyStopTest.java b/framework/src/test/java/org/tron/core/services/stop/ConditionallyStopTest.java index dc3d02e7ced..b417b27b380 100644 --- a/framework/src/test/java/org/tron/core/services/stop/ConditionallyStopTest.java +++ b/framework/src/test/java/org/tron/core/services/stop/ConditionallyStopTest.java @@ -82,7 +82,7 @@ public void init() throws Exception { initDbPath(); logger.info("Full node running."); - Args.setParam(new String[] {"-d", dbPath, "-w"}, Constant.TEST_CONF); + Args.setParam(new String[] {"-d", dbPath}, Constant.TEST_CONF); Args.getInstance().setNodeListenPort(10000 + port.incrementAndGet()); initParameter(Args.getInstance()); diff --git a/framework/src/test/java/org/tron/core/tire/TrieTest.java b/framework/src/test/java/org/tron/core/tire/TrieTest.java index ba5c536c987..7005198ad8b 100644 --- a/framework/src/test/java/org/tron/core/tire/TrieTest.java +++ b/framework/src/test/java/org/tron/core/tire/TrieTest.java @@ -26,6 +26,7 @@ import org.bouncycastle.util.Arrays; import org.junit.Assert; import org.junit.Test; +import org.tron.core.capsule.utils.FastByteComparisons; import org.tron.core.capsule.utils.RLP; import org.tron.core.trie.TrieImpl; import org.tron.core.trie.TrieImpl.Node; @@ -151,4 +152,11 @@ private void assertFalse(byte[] key1, byte[] key2, TrieImpl trieCopy) { Assert.assertFalse(trieCopy.verifyProof(trieCopy.getRootHash(), key2, trieCopy.prove(key1))); } + @Test + public void testFastByteComparisons() { + byte[] test1 = new byte[] {0x00, 0x00, 0x01, 0x02, 0x03, 0x04}; + byte[] test2 = new byte[] {0x00, 0x01, 0x02, 0x03, 0x04}; + Assert.assertEquals(0, FastByteComparisons.compareTo(test1, 1, 5, test2, 0, 5)); + } + } diff --git a/framework/src/test/java/org/tron/core/zksnark/LibrustzcashTest.java b/framework/src/test/java/org/tron/core/zksnark/LibrustzcashTest.java index 67353eb24b1..049fb2528b1 100644 --- a/framework/src/test/java/org/tron/core/zksnark/LibrustzcashTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/LibrustzcashTest.java @@ -4,6 +4,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; +import static org.tron.common.math.Maths.random; +import static org.tron.common.math.Maths.round; import static org.tron.common.zksnark.JLibrustzcash.librustzcashCheckDiversifier; import static org.tron.common.zksnark.JLibrustzcash.librustzcashComputeCm; import static org.tron.common.zksnark.JLibrustzcash.librustzcashIvkToPkd; @@ -78,7 +80,6 @@ public static void init() { "--output-directory", dbPath(), "--storage-db-directory", dbDirectory, "--storage-index-directory", indexDirectory, - "-w", "--debug" }, "config-test-mainnet.conf" @@ -87,7 +88,7 @@ public static void init() { } private static int randomInt(int minInt, int maxInt) { - return (int) Math.round(Math.random() * (maxInt - minInt) + minInt); + return (int) round(random(true) * (maxInt - minInt) + minInt, true); } public static void test(byte[] K, byte[] ovk, byte[] cv, byte[] cm, byte[] epk) diff --git a/framework/src/test/java/org/tron/core/zksnark/MerkleTreeTest.java b/framework/src/test/java/org/tron/core/zksnark/MerkleTreeTest.java index cb70adb35a2..faea3780135 100644 --- a/framework/src/test/java/org/tron/core/zksnark/MerkleTreeTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/MerkleTreeTest.java @@ -36,7 +36,6 @@ public class MerkleTreeTest extends BaseTest { "--output-directory", dbPath(), "--storage-db-directory", dbDirectory, "--storage-index-directory", indexDirectory, - "-w", "--debug" }, "config-test-mainnet.conf" diff --git a/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java b/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java index e59060540e9..3c3fb14b2b1 100644 --- a/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java @@ -23,7 +23,6 @@ public class NoteEncDecryTest extends BaseTest { private static final String FROM_ADDRESS; - private static final String ADDRESS_ONE_PRIVATE_KEY; private static final long OWNER_BALANCE = 100_000_000; private static final long FROM_AMOUNT = 110_000_000; private static final long tokenId = 1; @@ -42,7 +41,6 @@ public class NoteEncDecryTest extends BaseTest { static { Args.setParam(new String[]{"--output-directory", dbPath()}, "config-localtest.conf"); FROM_ADDRESS = Wallet.getAddressPreFixString() + "a7d8a35b260395c14aa456297662092ba3b76fc0"; - ADDRESS_ONE_PRIVATE_KEY = "7f7f701e94d4f1dd60ee5205e7ea8ee31121427210417b608a6b2e96433549a7"; } /** diff --git a/framework/src/test/java/org/tron/core/zksnark/SaplingNoteTest.java b/framework/src/test/java/org/tron/core/zksnark/SaplingNoteTest.java index 60f6c8c0826..da4df70d9ac 100644 --- a/framework/src/test/java/org/tron/core/zksnark/SaplingNoteTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/SaplingNoteTest.java @@ -1,5 +1,8 @@ package org.tron.core.zksnark; +import static org.tron.common.math.Maths.random; +import static org.tron.common.math.Maths.round; + import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -30,7 +33,7 @@ public static void removeDb() { } private static int randomInt(int minInt, int maxInt) { - return (int) Math.round(Math.random() * (maxInt - minInt) + minInt); + return (int) round(random(true) * (maxInt - minInt) + minInt, true); } @Test diff --git a/framework/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java b/framework/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java index 4a844c49c3c..7746066abfa 100644 --- a/framework/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java @@ -1695,6 +1695,7 @@ public SpendDescriptionCapsule generateSpendProof(SpendDescriptionInfo spend, lo System.out.println( "rk:" + ByteArray.toHexString(spendDescriptionCapsule.getRk().toByteArray())); spendDescriptionCapsule.setRk(fakeRk); + spendDescriptionCapsule.setRk(ByteString.copyFrom(fakeRk)); return spendDescriptionCapsule; } }; @@ -1737,6 +1738,9 @@ public SpendDescriptionCapsule generateSpendProof(SpendDescriptionInfo spend, lo .toHexString(spendDescriptionCapsule.getZkproof().toByteArray())); spendDescriptionCapsule.setZkproof(fakeProof); + spendDescriptionCapsule.setZkproof(ByteString.copyFrom(fakeProof)); + spendDescriptionCapsule.setSpendAuthoritySignature(spendDescriptionCapsule + .getSpendAuthoritySignature()); return spendDescriptionCapsule; } }; @@ -1775,6 +1779,7 @@ public SpendDescriptionCapsule generateSpendProof(SpendDescriptionInfo spend, lo System.out.println( "nf:" + ByteArray.toHexString(spendDescriptionCapsule.getNullifier().toByteArray())); spendDescriptionCapsule.setNullifier(bytes); + spendDescriptionCapsule.setNullifier(ByteString.copyFrom(bytes)); return spendDescriptionCapsule; } }; @@ -1811,6 +1816,9 @@ public SpendDescriptionCapsule generateSpendProof(SpendDescriptionInfo spend, lo System.out.println( "bytes:" + ByteArray.toHexString(spendDescriptionCapsule.getAnchor().toByteArray())); spendDescriptionCapsule.setAnchor(bytes); + spendDescriptionCapsule.setAnchor(ByteString.copyFrom(bytes)); + spendDescriptionCapsule.setValueCommitment(new byte[32]); + spendDescriptionCapsule.setValueCommitment(ByteString.copyFrom(new byte[32])); return spendDescriptionCapsule; } }; @@ -1827,5 +1835,14 @@ public SpendDescriptionCapsule generateSpendProof(SpendDescriptionInfo spend, lo System.out.println("Done"); } } + + SpendDescriptionCapsule c = new SpendDescriptionCapsule(new byte[32]); + SpendDescriptionCapsule c1 = new SpendDescriptionCapsule(ByteString.copyFrom(new byte[32]), + ByteString.copyFrom(new byte[32]), + ByteString.copyFrom(new byte[32]), + ByteString.copyFrom(new byte[32]), + ByteString.copyFrom(new byte[32]),ByteString.copyFrom(new byte[32])); + Assert.assertNotNull(c); + Assert.assertNotNull(c1); } } diff --git a/framework/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java b/framework/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java index c963a92bb9d..2a7545f7a9b 100755 --- a/framework/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java @@ -1,5 +1,8 @@ package org.tron.core.zksnark; +import static org.tron.common.utils.PublicMethod.getHexAddressByPrivateKey; +import static org.tron.common.utils.PublicMethod.getRandomPrivateKey; + import com.google.common.primitives.Bytes; import com.google.protobuf.Any; import com.google.protobuf.ByteString; @@ -25,6 +28,7 @@ import org.tron.common.crypto.ECKey; import org.tron.common.parameter.CommonParameter; import org.tron.common.utils.ByteArray; +import org.tron.common.utils.PublicMethod; import org.tron.common.utils.Sha256Hash; import org.tron.common.utils.client.utils.TransactionUtils; import org.tron.common.zksnark.IncrementalMerkleTreeContainer; @@ -124,8 +128,8 @@ public class ShieldedReceiveTest extends BaseTest { static { Args.setParam(new String[]{"--output-directory", dbPath()}, "config-localtest.conf"); - FROM_ADDRESS = Wallet.getAddressPreFixString() + "a7d8a35b260395c14aa456297662092ba3b76fc0"; - ADDRESS_ONE_PRIVATE_KEY = "7f7f701e94d4f1dd60ee5205e7ea8ee31121427210417b608a6b2e96433549a7"; + ADDRESS_ONE_PRIVATE_KEY = getRandomPrivateKey(); + FROM_ADDRESS = getHexAddressByPrivateKey(ADDRESS_ONE_PRIVATE_KEY);; } /** @@ -316,7 +320,7 @@ public void testBroadcastBeforeAllowZksnark() } /* - * generate spendproof, dataToBeSigned, outputproof example dynamicly according to the params file + * generate spendproof, dataToBeSigned, outputproof example dynamically according to the params file */ public String[] generateSpendAndOutputParams() throws ZksnarkException, BadItemException { librustzcashInitZksnarkParams(); @@ -368,6 +372,8 @@ public String[] generateSpendAndOutputParams() throws ZksnarkException, BadItemE // generate checkSpendParams SpendDescription spendDescription = builder.getContractBuilder().getSpendDescription(0); + SpendDescriptionCapsule spendDescriptionCapsule = new SpendDescriptionCapsule(spendDescription); + Assert.assertNotNull(spendDescriptionCapsule); CheckSpendParams checkSpendParams = new CheckSpendParams(ctx, spendDescription.getValueCommitment().toByteArray(), spendDescription.getAnchor().toByteArray(), @@ -872,20 +878,43 @@ private ReceiveDescriptionCapsule changeGenerateOutputProof(ReceiveDescriptionIn JLibrustzcash.librustzcashSaplingProvingCtxFree(ctx); throw new ZksnarkException("Output proof failed"); } - + ReceiveDescriptionCapsule c = new ReceiveDescriptionCapsule(new byte[32]); + ReceiveDescriptionCapsule c1 = + new ReceiveDescriptionCapsule(ReceiveDescription.newBuilder().build()); + ReceiveDescriptionCapsule c2 = + new ReceiveDescriptionCapsule(ByteString.copyFrom(new byte[32]), + ByteString.copyFrom(new byte[32]), + ByteString.copyFrom(new byte[32]), + ByteString.copyFrom(new byte[32]), + ByteString.copyFrom(new byte[32]), + ByteString.copyFrom(new byte[32])); + Assert.assertNotNull(c); + Assert.assertNotNull(c1); + Assert.assertNotNull(c2); ReceiveDescriptionCapsule receiveDescriptionCapsule = new ReceiveDescriptionCapsule(); receiveDescriptionCapsule.setValueCommitment(cv); + receiveDescriptionCapsule.setValueCommitment(ByteString.copyFrom(cv)); receiveDescriptionCapsule.setNoteCommitment(cm); + receiveDescriptionCapsule.setNoteCommitment(ByteString.copyFrom(cm)); receiveDescriptionCapsule.setEpk(encryptor.getEpk()); + receiveDescriptionCapsule.setEpk(ByteString.copyFrom(encryptor.getEpk())); receiveDescriptionCapsule.setCEnc(enc.getEncCiphertext()); + receiveDescriptionCapsule.setCEnc(ByteString.copyFrom(enc.getEncCiphertext())); receiveDescriptionCapsule.setZkproof(zkProof); + receiveDescriptionCapsule.setZkproof(ByteString.copyFrom(zkProof)); + receiveDescriptionCapsule.getEphemeralKey(); + receiveDescriptionCapsule.getData(); + receiveDescriptionCapsule.getZkproof(); + receiveDescriptionCapsule.getOutCiphertext(); OutgoingPlaintext outPlaintext = new OutgoingPlaintext(output.getNote().getPkD(), encryptor.getEsk()); - receiveDescriptionCapsule.setCOut(outPlaintext + byte[] bytes = outPlaintext .encrypt(output.getOvk(), receiveDescriptionCapsule.getValueCommitment().toByteArray(), receiveDescriptionCapsule.getCm().toByteArray(), - encryptor).getData()); + encryptor).getData(); + receiveDescriptionCapsule.setCOut(bytes); + receiveDescriptionCapsule.setCOut(ByteString.copyFrom(bytes)); Note newNote = output.getNote(); byte[] newCm; @@ -2369,10 +2398,10 @@ public void testMemoNotEnough() throws ContractValidateException, TooBigTransact */ @Test public void pushSameSkAndScanAndSpend() throws Exception { - - byte[] privateKey = ByteArray - .fromHexString("f4df789d3210ac881cb900464dd30409453044d2777060a0c391cbdf4c6a4f57"); + List localPrivateKeys = Args.getLocalWitnesses().getPrivateKeys(); + byte[] privateKey = ByteArray.fromHexString(localPrivateKeys.get(0)); final ECKey ecKey = ECKey.fromPrivate(privateKey); + assert ecKey != null; byte[] witnessAddress = ecKey.getAddress(); WitnessCapsule witnessCapsule = new WitnessCapsule(ByteString.copyFrom(witnessAddress)); chainBaseManager.addWitness(ByteString.copyFrom(witnessAddress)); diff --git a/framework/src/test/java/org/tron/program/LiteFullNodeToolTest.java b/framework/src/test/java/org/tron/program/LiteFullNodeToolTest.java deleted file mode 100644 index d1da0bf00d8..00000000000 --- a/framework/src/test/java/org/tron/program/LiteFullNodeToolTest.java +++ /dev/null @@ -1,202 +0,0 @@ -package org.tron.program; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.io.File; -import java.nio.file.Paths; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.After; -import org.junit.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.application.Application; -import org.tron.common.application.ApplicationFactory; -import org.tron.common.application.TronApplicationContext; -import org.tron.common.config.DbBackupConfig; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.FileUtil; -import org.tron.common.utils.PublicMethod; -import org.tron.common.utils.Utils; -import org.tron.core.config.DefaultConfig; -import org.tron.core.config.args.Args; -import org.tron.core.services.RpcApiService; -import org.tron.core.services.interfaceOnSolidity.RpcApiServiceOnSolidity; -import org.tron.tool.litefullnode.LiteFullNodeTool; - -@Slf4j -@Deprecated -public class LiteFullNodeToolTest { - - private TronApplicationContext context; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelFull; - private Application appTest; - private String databaseDir; - - private static String dbPath = "output_lite_fn"; - - /** - * init logic. - */ - public void startApp() { - context = new TronApplicationContext(DefaultConfig.class); - appTest = ApplicationFactory.create(context); - appTest.addService(context.getBean(RpcApiService.class)); - appTest.addService(context.getBean(RpcApiServiceOnSolidity.class)); - appTest.startup(); - - String fullNode = String.format("%s:%d", "127.0.0.1", - Args.getInstance().getRpcPort()); - channelFull = ManagedChannelBuilder.forTarget(fullNode) - .usePlaintext() - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - /** - * Delete the database when exited. - */ - public static void destroy(String dbPath) { - File f = new File(dbPath); - if (f.exists()) { - if (FileUtil.deleteDir(f)) { - logger.info("Release resources successful."); - } else { - logger.info("Release resources failure."); - } - } - } - - /** - * shutdown the fullNode. - */ - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - context.close(); - } - - public void init() { - destroy(dbPath); // delete if prev failed - Args.setParam(new String[]{"-d", dbPath, "-w"}, "config-localtest.conf"); - // allow account root - Args.getInstance().setAllowAccountStateRoot(1); - Args.getInstance().setRpcPort(PublicMethod.chooseRandomPort()); - databaseDir = Args.getInstance().getStorage().getDbDirectory(); - // init dbBackupConfig to avoid NPE - Args.getInstance().dbBackupConfig = DbBackupConfig.getInstance(); - } - - @After - public void clear() { - destroy(dbPath); - Args.clearParam(); - dbPath = "output_lite_fn"; - } - - @Test - public void testToolsWithLevelDB() throws InterruptedException { - logger.info("testToolsWithLevelDB start"); - testTools("LEVELDB", 1); - } - - @Test - public void testToolsWithLevelDBV2() throws InterruptedException { - logger.info("testToolsWithLevelDB start"); - testTools("LEVELDB", 2); - } - - @Test - public void testToolsWithRocksDB() throws InterruptedException { - logger.info("testToolsWithRocksDB start"); - testTools("ROCKSDB", 1); - } - - private void testTools(String dbType, int checkpointVersion) - throws InterruptedException { - dbPath = String.format("%s_%s_%d", dbPath, dbType, System.currentTimeMillis()); - init(); - final String[] argsForSnapshot = - new String[]{"-o", "split", "-t", "snapshot", "--fn-data-path", - dbPath + File.separator + databaseDir, "--dataset-path", - dbPath}; - final String[] argsForHistory = - new String[]{"-o", "split", "-t", "history", "--fn-data-path", - dbPath + File.separator + databaseDir, "--dataset-path", - dbPath}; - final String[] argsForMerge = - new String[]{"-o", "merge", "--fn-data-path", dbPath + File.separator + databaseDir, - "--dataset-path", dbPath + File.separator + "history"}; - Args.getInstance().getStorage().setDbEngine(dbType); - Args.getInstance().getStorage().setCheckpointVersion(checkpointVersion); - LiteFullNodeTool.setRecentBlks(3); - // start fullNode - startApp(); - // produce transactions for 18 seconds - generateSomeTransactions(18); - // stop the node - shutdown(); - // delete tran-cache - FileUtil.deleteDir(Paths.get(dbPath, databaseDir, "trans-cache").toFile()); - // generate snapshot - LiteFullNodeTool.main(argsForSnapshot); - // start fullNode - startApp(); - // produce transactions for 6 seconds - generateSomeTransactions(6); - // stop the node - shutdown(); - // generate history - LiteFullNodeTool.main(argsForHistory); - // backup original database to database_bak - File database = new File(Paths.get(dbPath, databaseDir).toString()); - if (!database.renameTo(new File(Paths.get(dbPath, databaseDir + "_bak").toString()))) { - throw new RuntimeException( - String.format("rename %s to %s failed", database.getPath(), - Paths.get(dbPath, databaseDir))); - } - // change snapshot to the new database - File snapshot = new File(Paths.get(dbPath, "snapshot").toString()); - if (!snapshot.renameTo(new File(Paths.get(dbPath, databaseDir).toString()))) { - throw new RuntimeException( - String.format("rename snapshot to %s failed", - Paths.get(dbPath, databaseDir))); - } - // start and validate the snapshot - startApp(); - generateSomeTransactions(6); - // stop the node - shutdown(); - // merge history - LiteFullNodeTool.main(argsForMerge); - // start and validate - startApp(); - generateSomeTransactions(6); - shutdown(); - LiteFullNodeTool.reSetRecentBlks(); - } - - private void generateSomeTransactions(int during) { - during *= 1000; // ms - int runTime = 0; - int sleepOnce = 100; - while (true) { - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] address = ecKey2.getAddress(); - - String sunPri = "cba92a516ea09f620a16ff7ee95ce0df1d56550a8babe9964981a7144c8a784a"; - byte[] sunAddress = PublicMethod.getFinalAddress(sunPri); - PublicMethod.sendcoin(address, 1L, - sunAddress, sunPri, blockingStubFull); - try { - Thread.sleep(sleepOnce); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if ((runTime += sleepOnce) > during) { - return; - } - } - } -} diff --git a/framework/src/test/java/org/tron/program/SolidityNodeTest.java b/framework/src/test/java/org/tron/program/SolidityNodeTest.java index a77fa2fa8c6..a95d07c0c11 100755 --- a/framework/src/test/java/org/tron/program/SolidityNodeTest.java +++ b/framework/src/test/java/org/tron/program/SolidityNodeTest.java @@ -1,12 +1,8 @@ package org.tron.program; -import java.io.File; -import java.io.IOException; import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; -import org.junit.AfterClass; import org.junit.Assert; -import org.junit.BeforeClass; import org.junit.Test; import org.tron.common.BaseTest; import org.tron.common.client.DatabaseGrpcClient; @@ -26,41 +22,10 @@ public class SolidityNodeTest extends BaseTest { SolidityNodeHttpApiService solidityNodeHttpApiService; static { - try { - Args.setParam(new String[]{"-d", temporaryFolder.newFolder().toString()}, Constant.TEST_CONF); - } catch (IOException e) { - Assert.fail("create temp directory failed."); - } + Args.setParam(new String[]{"-d", dbPath()}, Constant.TEST_CONF); Args.getInstance().setSolidityNode(true); } - /** - * init db. - */ - @BeforeClass - public static void init() { - } - - /** - * remo db when after test. - */ - @AfterClass - public static void removeDb() { - Args.clearParam(); - } - - private static Boolean deleteFolder(File index) { - if (!index.isDirectory() || index.listFiles().length <= 0) { - return index.delete(); - } - for (File file : index.listFiles()) { - if (null != file && !deleteFolder(file)) { - return false; - } - } - return index.delete(); - } - @Test public void testSolidityArgs() { Assert.assertNotNull(Args.getInstance().getTrustNodeAddr()); @@ -69,7 +34,6 @@ public void testSolidityArgs() { @Test public void testSolidityGrpcCall() { - rpcApiService.init(Args.getInstance()); rpcApiService.start(); DatabaseGrpcClient databaseGrpcClient = null; String address = Args.getInstance().getTrustNodeAddr(); @@ -99,7 +63,8 @@ public void testSolidityGrpcCall() { @Test public void testSolidityNodeHttpApiService() { - solidityNodeHttpApiService.init(Args.getInstance()); + solidityNodeHttpApiService.start(); + // start again solidityNodeHttpApiService.start(); solidityNodeHttpApiService.stop(); Assert.assertTrue(true); diff --git a/framework/src/test/java/org/tron/program/SupplementTest.java b/framework/src/test/java/org/tron/program/SupplementTest.java index ffa6b14f46b..3dfa23dfce4 100644 --- a/framework/src/test/java/org/tron/program/SupplementTest.java +++ b/framework/src/test/java/org/tron/program/SupplementTest.java @@ -1,8 +1,10 @@ package org.tron.program; +import static org.apache.commons.lang3.StringUtils.EMPTY; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.tron.keystore.WalletUtils.passwordValid; import java.io.File; import java.io.IOException; @@ -21,6 +23,7 @@ import org.tron.core.Constant; import org.tron.core.capsule.StorageRowCapsule; import org.tron.core.capsule.utils.RLP; +import org.tron.core.config.TronLogShutdownHook; import org.tron.core.config.args.Args; import org.tron.core.services.http.HttpSelfFormatFieldName; import org.tron.core.store.StorageRowStore; @@ -130,4 +133,18 @@ public void testGet() throws Exception { RLP.unwrapList(new byte[] {1,2,3,4,5,6,7}); } + @Test + public void testPasswordValid() { + assertFalse(passwordValid(EMPTY)); + assertFalse(passwordValid("12345")); + assertTrue(passwordValid("123456")); + } + + @Test + public void testRun() { + TronLogShutdownHook hook = new TronLogShutdownHook(); + hook.run(); + assertTrue(true); + } + } diff --git a/framework/src/test/resources/args-test.conf b/framework/src/test/resources/args-test.conf new file mode 100644 index 00000000000..cf5d0b8d718 --- /dev/null +++ b/framework/src/test/resources/args-test.conf @@ -0,0 +1,225 @@ +net { + // type = mainnet + type = testnet +} + + +storage { + # Directory for storing persistent data + + db.engine = "LEVELDB" + db.directory = "database", + index.directory = "index", + + # You can custom these 14 databases' configs: + + # account, account-index, asset-issue, block, block-index, + # block_KDB, peers, properties, recent-block, trans, + # utxo, votes, witness, witness_schedule. + + # Otherwise, db configs will remain defualt and data will be stored in + # the path of "output-directory" or which is set by "-d" ("--output-directory"). + + # Attention: name is a required field that must be set !!! + default = { + maxOpenFiles = 50 + } + defaultM = { + maxOpenFiles = 500 + } + defaultL = { + maxOpenFiles = 1000 + } + properties = [ + { + name = "account", + path = "storage_directory_test", + createIfMissing = true, + paranoidChecks = true, + verifyChecksums = true, + compressionType = 1, // compressed with snappy + blockSize = 4096, // 4 KB = 4 * 1024 B + writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B + cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B + maxOpenFiles = 100 + }, + { + name = "account-index", + path = "storage_directory_test", + createIfMissing = true, + paranoidChecks = true, + verifyChecksums = true, + compressionType = 1, // compressed with snappy + blockSize = 4096, // 4 KB = 4 * 1024 B + writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B + cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B + maxOpenFiles = 100 + }, + { # only for unit test + name = "test_name", + path = "test_path", + createIfMissing = false, + paranoidChecks = false, + verifyChecksums = false, + compressionType = 1, + blockSize = 2, + writeBufferSize = 3, + cacheSize = 4, + maxOpenFiles = 5 + }, + ] + + needToUpdateAsset = false + +} + +node.discovery = { + enable = true + persist = true + external.ip = "46.168.1.1" +} + +node { + + trustNode = "127.0.0.1:50051" + + listen.port = 18888 + + connection.timeout = 2 + + active = [] + + maxConnections = 30 + minConnections = 8 + minActiveConnections = 3 + inactiveThreshold = 600 //seconds + + p2p { + version = 43 # 43: testnet; 101: debug + } + + rpc { + port = 50051 + } + +} + +sync { + node.count = 30 +} + +seed.node = { + ip.list = [ + ] +} + +genesis.block = { + # Reserve balance + assets = [ + { + accountName = "Devaccount" + accountType = "AssetIssue" + address = "27d3byPxZXKQWfXX7sJvemJJuv5M65F3vjS" + balance = "10000000000000000" + }, + { + accountName = "Zion" + accountType = "AssetIssue" + address = "27fXgQ46DcjEsZ444tjZPKULcxiUfDrDjqj" + balance = "15000000000000000" + }, + { + accountName = "Sun" + accountType = "AssetIssue" + address = "27SWXcHuQgFf9uv49FknBBBYBaH3DUk4JPx" + balance = "10000000000000000" + }, + { + accountName = "Blackhole" + accountType = "AssetIssue" + address = "27WtBq2KoSy5v8VnVZBZHHJcDuWNiSgjbE3" + balance = "-9223372036854775808" + } + ] + + witnesses = [ + { + address: 27Ssb1WE8FArwJVRRb8Dwy3ssVGuLY8L3S1 + url = "http://mercury.org/", + voteCount = 105 + }, + { + address: 27anh4TDZJGYpsn4BjXzb7uEArNALxwiZZW + url = "http://venus.org/", + voteCount = 104 + }, + { + address: 27Wkfa5iEJtsKAKdDzSmF1b2gDm5s49kvdZ + url = "http://earth.org/", + voteCount = 103 + }, + { + address: 27bqKYX9Bgv7dgTY7xBw5SUHZ8EGaPSikjx + url = "http://mars.org/", + voteCount = 102 + }, + { + address: 27fASUY6qKtsaAEPz6QxhZac2KYVz2ZRTXW + url = "http://jupiter.org/", + voteCount = 101 + }, + { + address: 27Q3RSbiqm59VXcF8shQWHKbyztfso5FwvP + url = "http://saturn.org/", + voteCount = 100 + }, + { + address: 27YkUVSuvCK3K84DbnFnxYUxozpi793PTqZ + url = "http://uranus.org/", + voteCount = 99 + }, + { + address: 27kdTBTDJ16hK3Xqr8PpCuQJmje1b94CDJU + url = "http://neptune.org/", + voteCount = 98 + }, + { + address: 27mw9UpRy7inTMQ5kUzsdTc2QZ6KvtCX4uB + url = "http://pluto.org/", + voteCount = 97 + }, + { + address: 27QzC4PeQZJ2kFMUXiCo4S8dx3VWN5U9xcg + url = "http://altair.org/", + voteCount = 96 + }, + { + address: 27VZHn9PFZwNh7o2EporxmLkpe157iWZVkh + url = "http://alphalyrae.org/", + voteCount = 95 + } + ] + + timestamp = "0" #2017-8-26 12:00:00 + + parentHash = "0x0000000000000000000000000000000000000000000000000000000000000000" +} + + +localwitness = [ + +] + +block = { + needSyncCheck = true # first node : false, other : true +} + +vm = { + supportConstant = true + minTimeRatio = 0.0 + maxTimeRatio = 5.0 +} +committee = { + allowCreationOfContracts = 1 //mainnet:0 (reset by committee),test:1 + allowOldRewardOpt = 1 +} diff --git a/framework/src/test/resources/config-localtest.conf b/framework/src/test/resources/config-localtest.conf index c6ecaf28173..ff31369a915 100644 --- a/framework/src/test/resources/config-localtest.conf +++ b/framework/src/test/resources/config-localtest.conf @@ -57,7 +57,6 @@ storage { node.discovery = { enable = true persist = true - bind.ip = "" external.ip = null } @@ -97,6 +96,7 @@ node { # check the peer data transfer ,disconnect factor isOpenFullTcpDisconnect = true + inactiveThreshold = 600 //seconds p2p { version = 333 # 11111: mainnet; 20180622: testnet @@ -117,14 +117,21 @@ node { ] http { + fullNodeEnable = false fullNodePort = 8090 + solidityEnable = false solidityPort = 8091 + PBFTEnable = false + PBFTPort = 8092 } rpc { + enable = false port = 50051 - # default value is 50061 - # solidityPort = 50061 + solidityEnable = false + solidityPort = 50061 + PBFTEnable = false + PBFTPort = 50071 # Number of gRPC thread, default availableProcessors / 2 # thread = 16 @@ -146,6 +153,9 @@ node { # The maximum size of header list allowed to be received, default 8192 # maxHeaderListSize = + + # The switch of the reflection service, effective for all gRPC services + reflectionService = true } jsonrpc { @@ -155,6 +165,8 @@ node { # httpSolidityPort = 8555 # httpPBFTEnable = true # httpPBFTPort = 8565 + # maxBlockRange = 5000 + # maxSubTopics = 1000 } } @@ -185,8 +197,6 @@ genesis.block = { accountType = "AssetIssue" address = "TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW" balance = "25000000000000000" - #priKey = D95611A9AF2A2A45359106222ED1AFED48853D9A44DEFF8DC7913F5CBA727366 - #password = 2VYRqa8qKkU1kQYiLtGv7UiFPZpE3v+Nx5E/XLpyc2Y= }, # the account of payment @@ -195,8 +205,6 @@ genesis.block = { accountType = "AssetIssue" address = "TGehVcNhud84JDCGrNHKVz9jEAVKUpbuiv" balance = "10000000000000000" - #priKey = cba92a516ea09f620a16ff7ee95ce0df1d56550a8babe9964981a7144c8a784a - #password = y6kqUW6gn2IKFv9+6Vzg3x1WVQqLq+mWSYGnFEyKeEo= }, # the account of coin burn @@ -205,37 +213,31 @@ genesis.block = { accountType = "AssetIssue" address = "THKrowiEfCe8evdbaBzDDvQjM5DGeB3s3F" balance = "-9223372036854775808" - #priKey = 8E812436A0E3323166E1F0E8BA79E19E217B2C4A53C970D4CCA0CFB1078979DF - #password = joEkNqDjMjFm4fDounnhniF7LEpTyXDUzKDPsQeJed8= } ] witnesses = [ { - address: TN3zfjYUmMFK3ZsHSsrdJoNRtGkQmZLBLz + address: TEDapYSVvAZ3aYH7w8N9tMEEFKaNKUD5Bp url = "http://test.org/", voteCount = 106 - #priKey = f4df789d3210ac881cb900464dd30409453044d2777060a0c391cbdf4c6a4f57 6666 }, // { // address: TPrLL5ckUdMaPNgJYmGv23qtYjBE34aBf8 // url = "http://mercury.org/", // voteCount = 105 - // #priKey = f5583fd20e13073900a513f333ed13db8c9e83e7e3cf37e74adacef96c5afeaa 7777 // }, // { // address: TEZBh76rouEQpB2zqYVopbRXGx7RfyWorT // #address: 27TfVERREG3FeWMHEAQ95tWHG4sb3ANn3Qe // url = "http://venus.org/", // voteCount = 104 - // #priKey = 9f5c5e48bf87cf92017313082e8cf0f58ccfce423097f0fcebf801695fc99bd4 8888 // }, // { // address: TN27wbfCLEN1gP2PZAxHgU3QZrntsLyxdj // #address: 27b8RUuyZnNPFNZGct2bZkNu9MnGWNAdH3Z // url = "http://earth.org/", // voteCount = 103 - // #priKey = 6781f44d9a2083b14fad1702b8e9ba82749162b795e2fc3f136192fc63f80de2 9999 // }, ] @@ -253,7 +255,7 @@ genesis.block = { //localWitnessAccountAddress = TN3zfjYUmMFK3ZsHSsrdJoNRtGkQmZLBLz localwitness = [ - f4df789d3210ac881cb900464dd30409453044d2777060a0c391cbdf4c6a4f57 + 1234567890123456789012345678901234567890123456789012345678901234 ] diff --git a/framework/src/test/resources/config-test-dbbackup.conf b/framework/src/test/resources/config-test-dbbackup.conf index bb64a87ef69..4f9ddf8d32b 100644 --- a/framework/src/test/resources/config-test-dbbackup.conf +++ b/framework/src/test/resources/config-test-dbbackup.conf @@ -60,7 +60,6 @@ storage { node.discovery = { enable = true persist = true - bind.ip = "" external.ip = null } diff --git a/framework/src/test/resources/config-test-index.conf b/framework/src/test/resources/config-test-index.conf index b9fbf5b2c43..faa2f93dc5e 100644 --- a/framework/src/test/resources/config-test-index.conf +++ b/framework/src/test/resources/config-test-index.conf @@ -54,7 +54,6 @@ storage { node.discovery = { enable = true persist = true - bind.ip = "" external.ip = null } @@ -77,9 +76,25 @@ node { version = 43 # 43: testnet; 101: debug } + http { + fullNodeEnable = false + solidityEnable = false + PBFTEnable = false + } + + jsonrpc { + httpFullNodeEnable = false + httpSolidityEnable = false + httpPBFTEnable = false + # maxBlockRange = 5000 + # maxSubTopics = 1000 + } + rpc { port = 50051 - + enable = false + solidityEnable = false + PBFTEnable = false # Number of gRPC thread, default availableProcessors / 2 # thread = 16 diff --git a/framework/src/test/resources/config-test-mainnet.conf b/framework/src/test/resources/config-test-mainnet.conf index 43a01a0feb9..12acad64d8d 100644 --- a/framework/src/test/resources/config-test-mainnet.conf +++ b/framework/src/test/resources/config-test-mainnet.conf @@ -53,7 +53,6 @@ storage { node.discovery = { enable = true persist = true - bind.ip = "127.0.0.1" external.ip = "46.168.1.1" } @@ -83,6 +82,26 @@ node { version = 43 # 43: testnet; 101: debug } + http { + fullNodeEnable = false + solidityEnable = false + PBFTEnable = false + } + + jsonrpc { + httpFullNodeEnable = false + httpSolidityEnable = false + httpPBFTEnable = false + # maxBlockRange = 5000 + # maxSubTopics = 1000 + } + + rpc { + enable = false + solidityEnable = false + PBFTEnable = false + } + } sync { diff --git a/framework/src/test/resources/config-test-storagetest.conf b/framework/src/test/resources/config-test-storagetest.conf index 5098e39b650..25127cdab91 100644 --- a/framework/src/test/resources/config-test-storagetest.conf +++ b/framework/src/test/resources/config-test-storagetest.conf @@ -76,7 +76,6 @@ storage { node.discovery = { enable = true persist = true - bind.ip = "127.0.0.1" external.ip = "46.168.1.1" } @@ -285,4 +284,6 @@ vm = { } committee = { allowCreationOfContracts = 1 //mainnet:0 (reset by committee),test:1 + allowOldRewardOpt = 1 + allowNewRewardAlgorithm = 1 } diff --git a/framework/src/test/resources/config-test.conf b/framework/src/test/resources/config-test.conf index cf7ca5e2f42..eaa6659a8c4 100644 --- a/framework/src/test/resources/config-test.conf +++ b/framework/src/test/resources/config-test.conf @@ -69,12 +69,17 @@ storage { # if true, transaction cache initialization will be faster. default false txCache.initOptimization = true + # data root setting, for check data, currently, only reward-vi is used. + + merkleRoot = { + reward-vi = e0ebe2f3243391ed674dff816a07f589a3279420d6d88bc823b6a9d5778337ce + } + } node.discovery = { enable = true persist = true - bind.ip = "127.0.0.1" external.ip = "46.168.1.1" } @@ -95,16 +100,24 @@ node { # nodeId = e437a4836b77ad9d9ffe73ee782ef2614e6d8370fcf62191a6e488276e23717147073a7ce0b444d485fff5a0c34c4577251a7a990cf80d8542e21b95aa8c5e6c # } ] + inactiveThreshold = 600 //seconds p2p { version = 43 # 43: testnet; 101: debug } http { - fullNodeEnable = true - fullNodePort = 8090 - solidityEnable = true - solidityPort = 8091 + fullNodeEnable = false + solidityEnable = false + PBFTEnable = false + } + + jsonrpc { + httpFullNodeEnable = false + httpSolidityEnable = false + httpPBFTEnable = false + # maxBlockRange = 5000 + # maxSubTopics = 1000 } # use your ipv6 address for node discovery and tcp connection, default false @@ -126,7 +139,7 @@ node { dnsDomain = "nodes1.example.org" # dns private key used to publish, required if publish is true, hex string of length 64 - dnsPrivate = "b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291" + dnsPrivate = "1234567890123456789012345678901234567890123456789012345678901234" # known dns urls to publish if publish is true, url format tree://{pubkey}@{domain}, default empty knownUrls = [ @@ -166,6 +179,9 @@ node { } rpc { + enable = false + solidityEnable = false + PBFTEnable = false port = 50051 PBFTPort = 50072 @@ -190,6 +206,9 @@ node { # The maximum size of header list allowed to be received, default 8192 # maxHeaderListSize = + + # The switch of the reflection service, effective for all gRPC services + reflectionService = true } } diff --git a/framework/src/test/resources/testng.conf b/framework/src/test/resources/testng.conf deleted file mode 100644 index 2e5b9a375e0..00000000000 --- a/framework/src/test/resources/testng.conf +++ /dev/null @@ -1,539 +0,0 @@ -net { - type = mainnet -} - -fullnode = { - ip.list = [ - #Docker env - "127.0.0.1:50051", - "127.0.0.1:50052", - - #New beat1 - "39.106.145.222:50051", - "101.200.46.37:50051", - #"101.200.46.37:50051", - - #New beta2 - "101.200.46.37:50052", - "39.106.145.222:50052", - "101.200.46.37:50052", - - #Stress env - #"47.94.243.150:50051", - #"39.106.110.112:50051", - - #MainNet env - #"47.95.206.44:50051", - #"47.95.206.44:50051", - - - ] -} - -solidityNode = { - ip.list = [ - #Docker env - "127.0.0.1:50053", - "127.0.0.1:50062", - "127.0.0.1:50071", - - #New beat 1 - "39.106.145.222:50061", - "39.106.145.222:50061", - #"39.106.145.222:50071", - - #New beat 2 - "101.200.46.37:50053", - "101.200.46.37:50062", - "101.200.46.37:50071", - #"101.200.46.37:50071", - - - #Main Net env - #"47.95.206.44:50061", - ] -} - -httpnode = { - ip.list = [ - #docker env - "127.0.0.1:8090", - "127.0.0.1:8093", - "127.0.0.1:8097", - "127.0.0.1:8091", - "127.0.0.1:8098", - - - #New beta 2 - "101.200.46.37:50091", - "39.106.145.222:50091", - "101.200.46.37:50192", - "101.200.46.37:50094", - "101.200.46.37:50082", - #"101.200.46.37:50082", - ] -} - -eventnode = { - ip.list = [ - "tcp://127.0.0.1:50096", - #"tcp://39.106.145.222:50096", - ] -} - -jsonRpcNode = { - ip.list = [ - #"101.200.46.37:50545", - "127.0.0.1:50545", - "127.0.0.1:50555", - ] -} - -ethHttpsNode = { - host.list = [ - "mainnet.infura.io", - #"47.95.206.44:50545", - ] -} - - -foundationAccount = { - key1 = FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6 - key2 = 6815B367FDDE637E53E9ADC8E69424E07724333C9A2B973CFA469975E20753FC - #Main_in_mock_foundationAccount_key - #key1 = 324a2052e491e99026442d81df4d2777292840c1b3949e20696c49096c6bacb8 - #key2 = 2925e186bb1e88988855f11ebf20ea3a6e19ed92328b0ffb576122e769d45b68 -} - - -witness = { - key1 = 369F095838EB6EED45D4F6312AF962D5B9DE52927DA9F04174EE49F9AF54BC77 - key2 = 9FD8E129DE181EA44C6129F727A6871440169568ADE002943EAD0E7A16D8EDAC - key3 = 291C233A5A7660FB148BAE07FCBCF885224F2DF453239BD983F859E8E5AA4602 - key4 = 99676348CBF9501D07819BD4618ED885210CB5A03FEAF6BFF28F0AF8E1DE7DBE - key5 = FA090CFB9F3A6B00BE95FE185E82BBCFC4DA959CA6A795D275635ECF5D58466D - #replay env witness - #key1 = 0528dc17428585fc4dece68b79fa7912270a1fe8e85f244372f59eb7e8925e04 - #key2 = 553c7b0dee17d3f5b334925f5a90fe99fb0b93d47073d69ec33eead8459d171e - #key3 = 324a2052e491e99026442d81df4d2777292840c1b3949e20696c49096c6bacb8 - #key4 = ff5d867c4434ac17d264afc6696e15365832d5e8000f75733ebb336d66df148d - #key5 = 2925e186bb1e88988855f11ebf20ea3a6e19ed92328b0ffb576122e769d45b68 -} - -mainWitness = { - key1 = 22a6aca17f8ec257cc57e190902767d7fedf908bba920b4fbeaab8f158e0da17 - key2 = b6d8d3382c32d4d066c4f830a7e53c3da9ad8b9665dda4ca081b6cd4e807d09c - key3 = 03caf867c46aaf86d56aa446db80cb49305126b77bfaccfe57ab17bdb4993ccc - key4 = 763009595dd132aaf2d248999f2c6e7ba0acbbd9a9dfd88f7c2c158d97327645 - key5 = a21a3074d4d84685efaffcd7c04e3eccb541ec4c85f61c41a099cd598ad39825 - key6 = 541a2d585fcea7e9b1803df4eb49af0eb09f1fa2ce06aa5b8ed60ac95655d66d - key7 = 7d5a7396d6430edb7f66aa5736ef388f2bea862c9259de8ad8c2cfe080f6f5a0 - key8 = 7c4977817417495f4ca0c35ab3d5a25e247355d68f89f593f3fea2ab62c8644f - key9 = 4521c13f65cc9f5c1daa56923b8598d4015801ad28379675c64106f5f6afec30 - key10 = f33101ea976d90491dcb9669be568db8bbc1ad23d90be4dede094976b67d550e - key11 = 1bb32958909299db452d3c9bbfd15fd745160d63e4985357874ee57708435a00 - key12 = 29c91bd8b27c807d8dc2d2991aa0fbeafe7f54f4de9fac1e1684aa57242e3922 - key13 = 97317d4d68a0c5ce14e74ad04dfc7521f142f5c0f247b632c8f94c755bdbe669 - key14 = 1fe1d91bbe3ac4ac5dc9866c157ef7615ec248e3fd4f7d2b49b0428da5e046b2 - key15 = 7c37ef485e186e07952bcc8e30cd911a6cd9f2a847736c89132762fb67a42329 - key16 = bcc142d57d872cd2cc1235bca454f2efd5a87f612856c979cc5b45a7399272a8 - key17 = 6054824dc03546f903a06da1f405e72409379b83395d0bbb3d4563f56e828d52 - key18 = 87cc8832b1b4860c3c69994bbfcdae9b520e6ce40cbe2a90566e707a7e04fc70 - key19 = c96c92c8a5f68ffba2ced3f7cd4baa6b784838a366f62914efdc79c6c18cd7d0 - key20 = d29e34899a21dc801c2be88184bed29a66246b5d85f26e8c77922ee2403a1934 - key21 = dc51f31e4de187c1c2530d65fb8f2958dff4c37f8cea430ce98d254baae37564 - key22 = ff43b371d67439bb8b6fa6c4ff615c954682008343d4cb2583b19f50adbac90f - key23 = dbc78781ad27f3751358333412d5edc85b13e5eee129a1a77f7232baadafae0e - key24 = a79a37a3d868e66456d76b233cb894d664b75fd91861340f3843db05ab3a8c66 - key25 = a8107ea1c97c90cd4d84e79cd79d327def6362cc6fd498fc3d3766a6a71924f6 - key26 = b5076206430b2ca069ae2f4dc6f20dd0d74551559878990d1df12a723c228039 - key27 = 442513e2e801bc42d14d33b8148851dae756d08eeb48881a44e1b2002b3fb700 -} - -defaultParameter = { - maxFeeLimit = 1000000000 - assetDescription = stest-assetissue - assetUrl = github.com/tronprotocol/wallet/stest - multiSignFee = 1000000 - updateAccountPermissionFee = 100000000 - httpConnectionTimeout = 19000 - httpSoTimeout = 18000 - createWitnessAmount = 9999000000 - operations = 7fff1fc0033e3300000000000000000000000000000000000000000000000000 - delayTransactionFee = 100000 - cancleDelayTransactionFee = 50000 - solidityCompilerVersion = "v5" - solidityCompile = "../solcDIR/solc" - zenTokenOwnerKey = 2925e186bb1e88988855f11ebf20ea3a6e19ed92328b0ffb576122e769d45b68 - zenTokenId = 1000001 - zenTokenFee = 10000000 - zenTokenWhenCreateNewAddress = 1000000 - zenTrc20TokenOwnerKey = ede941a01eb8234866f60c7e8e95db4614bb0d05298d82bae0abea81f1861046 - jsonRpcOwnerKey = dbc78781ad27f3751358333412d5edc85b13e5eee129a1a77f7232baadafae0e - blackHoleAddress = THmtHi1Rzq4gSKYGEKv1DPkV7au6xU1AUB -} - - -code = { - code_AssertException_testdivideInt = "608060405234801561001057600080fd5b5060ac8061001f6000396000f300608060405260043610603d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166226ff5581146042575b600080fd5b348015604d57600080fd5b50605a600435602435606c565b60408051918252519081900360200190f35b60008183811515607857fe5b0593925050505600a165627a7a72305820b587002bc926764a997a3925613203906e484069ff4e2f8324b4dce6088326220029" - code_AssertException_testfindArgsContractMinTest = "608060405234801561001057600080fd5b50610134806100206000396000f3006080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663329000b58114610045575b600080fd5b34801561005157600080fd5b5061005d60043561006f565b60408051918252519081900360200190f35b604080516003808252608082019092526000916060919060208201838038833901905050905060018160008151811015156100a657fe5b602090810290910101528051600290829060019081106100c257fe5b602090810290910101528051600390829060029081106100de57fe5b6020908102909101015280518190849081106100f657fe5b906020019060200201519150509190505600a165627a7a72305820e426d63fe06962cb78b523edb9295a369bc2cc1b82cac5740d74e924b1a398c40029" - code_AssertException_testbyteMinContract = "608060405234801561001057600080fd5b50610305806100206000396000f3006080604052600436106100405763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166383be82a38114610045575b600080fd5b34801561005157600080fd5b5061005d600435610092565b604080517fff000000000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b60408051600380825281830190925260009160208201606080388339505081516100c392600092506020019061023e565b50600c60f860020a0260008081546001816001161561010002031660029004811015156100ec57fe5b81546001161561010b5790600052602060002090602091828204019190065b601f036101000a81548160ff0219169060f860020a84040217905550600d60f860020a0260006001815460018160011615610100020316600290048110151561015057fe5b81546001161561016f5790600052602060002090602091828204019190065b601f036101000a81548160ff0219169060f860020a84040217905550600e60f860020a026000600281546001816001161561010002031660029004811015156101b457fe5b8154600116156101d35790600052602060002090602091828204019190065b601f036101000a81548160ff0219169060f860020a84040217905550600082815460018160011615610100020316600290048110151561020f57fe5b81546001161561022e5790600052602060002090602091828204019190065b905460f860020a911a0292915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061027f57805160ff19168380011785556102ac565b828001600101855582156102ac579182015b828111156102ac578251825591602001919060010190610291565b506102b89291506102bc565b5090565b6102d691905b808211156102b857600081556001016102c2565b905600a165627a7a72305820c42a0dcadb40b736d1d61cf46a58a66e740573568264ed5ce2f9b1de442d39fe0029" - code_AssertException_testenum = "608060405234801561001057600080fd5b5060f18061001f6000396000f30060806040526004361060485763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166367cb61b68114604d578063fb76fa52146082575b600080fd5b348015605857600080fd5b50605f609c565b60405180826003811115606e57fe5b60ff16815260200191505060405180910390f35b348015608d57600080fd5b50609a60ff6004351660a5565b005b60005460ff1690565b6000805482919060ff1916600183600381111560bd57fe5b0217905550505600a165627a7a723058201ad3f79794ab99b9429a737984c9e0722214f7412fa23f4f8895f58032e222360029" - code_AssertException_testmoveRight = "608060405234801561001057600080fd5b5060b38061001f6000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630599d3dc81146043575b600080fd5b348015604e57600080fd5b506058600435606a565b60408051918252519081900360200190f35b60008160056000821215607957fe5b60029190910a9005929150505600a165627a7a72305820e944c4077f7d4f205074c52900d041d56d5f700a779aed8ced4af969f99464760029" - code_AssertException_testuninitializedContract = "608060405234801561001057600080fd5b5060e18061001f6000396000f30060806040526004361060485763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166366e41cb78114604d5780636b59084d146071575b600080fd5b348015605857600080fd5b50605f6083565b60408051918252519081900360200190f35b348015607c57600080fd5b50605f609c565b600060b36096600460058363ffffffff16565b91505090565b600060af60966004600563ffffffff8416565b0290565bfe00a165627a7a72305820adcb5758cba4260d0f840e31e0b97435395f43728ddfe8024de688c29583dd220029" - code_AssertException_testTestAssertContract = "608060405234801561001057600080fd5b5060b58061001f6000396000f300608060405260043610605c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632b813bc081146061578063357815c414607557806350bff6bf146075578063a26388bb146075575b600080fd5b348015606c57600080fd5b5060736087565b005b348015608057600080fd5b506073605c565bfe00a165627a7a723058209284d2c51e121903dde36db88dae131b1b20dc83b987a6f491dcac2d9b2d30db0029" - - code_ContractGrammar001_testGrammar001 = "608060405234801561001057600080fd5b50610105806100206000396000f30060806040526004361060525763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630a75057381146057578063cd580ff3146083578063f0fdf834146098575b600080fd5b348015606257600080fd5b506071600435151560243560ad565b60408051918252519081900360200190f35b348015608e57600080fd5b50607160043560ce565b34801560a357600080fd5b50607160043560d4565b600060d4831560ba575060ce5b60c6838263ffffffff16565b949350505050565b60020290565b8002905600a165627a7a7230582032df33d18c9876ca1a32117c2b4c526215a9dd8feeb3c9d849690539b3a992ac0029" - code_ContractGrammar001_testGrammar002 = "610199610030600b82828239805160001a6073146000811461002057610022565bfe5b5030600052607381538281f300730000000000000000000000000000000000000000301460806040526004361061006d5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663483b8a1481146100725780636ce8e081146100a1578063831cb739146100bc575b600080fd5b81801561007e57600080fd5b5061008d6004356024356100d7565b604080519115158252519081900360200190f35b8180156100ad57600080fd5b5061008d600435602435610117565b8180156100c857600080fd5b5061008d60043560243561012d565b60008181526020839052604081205460ff1615156100f757506000610111565b506000818152602083905260409020805460ff1916905560015b92915050565b6000908152602091909152604090205460ff1690565b60008181526020839052604081205460ff161561014c57506000610111565b50600090815260209190915260409020805460ff19166001908117909155905600a165627a7a723058205198109bfdc1087cafa3e909576bdb656bb058100cf618ef42eecaeb64e30b7f0029" - code1_ContractGrammar001_testGrammar002 = "608060405234801561001057600080fd5b50610139806100206000396000f3006080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663f207564e8114610045575b600080fd5b34801561005157600080fd5b5061005d60043561005f565b005b73__browser/TvmTest_p1_Grammar_002.sol:S__63831cb7396000836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808381526020018281526020019250505060206040518083038186803b1580156100d357600080fd5b505af41580156100e7573d6000803e3d6000fd5b505050506040513d60208110156100fd57600080fd5b5051151561010a57600080fd5b505600a165627a7a7230582044978981980e6552ad10452a66a2038edf7739f149dcced7705b0e329d594f300029" - code_ContractGrammar001_testGrammar003 = "610199610030600b82828239805160001a6073146000811461002057610022565bfe5b5030600052607381538281f300730000000000000000000000000000000000000000301460806040526004361061006d5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663483b8a1481146100725780636ce8e081146100a1578063831cb739146100bc575b600080fd5b81801561007e57600080fd5b5061008d6004356024356100d7565b604080519115158252519081900360200190f35b8180156100ad57600080fd5b5061008d600435602435610117565b8180156100c857600080fd5b5061008d60043560243561012d565b60008181526020839052604081205460ff1615156100f757506000610111565b506000818152602083905260409020805460ff1916905560015b92915050565b6000908152602091909152604090205460ff1690565b60008181526020839052604081205460ff161561014c57506000610111565b50600090815260209190915260409020805460ff19166001908117909155905600a165627a7a72305820026d1eee826a0f8eb329643f3547e967fb7631f83b1855c607bdd82706af37520029" - code1_ContractGrammar001_testGrammar003 = "608060405234801561001057600080fd5b50610137806100206000396000f3006080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663f207564e8114610045575b600080fd5b34801561005157600080fd5b5061005d60043561005f565b005b604080517f831cb7390000000000000000000000000000000000000000000000000000000081526000600482015260248101839052905173__browser/TvmTest_p1_Grammar_003.sol:S__9163831cb739916044808301926020929190829003018186803b1580156100d157600080fd5b505af41580156100e5573d6000803e3d6000fd5b505050506040513d60208110156100fb57600080fd5b5051151561010857600080fd5b505600a165627a7a72305820de817c43c8f916d8e300ee0f317061f220ba7971379253fc437c52ab40295d6f0029" - code_ContractGrammar001_testGrammar004 = "60f561002f600b82828239805160001a6073146000811461001f57610021565bfe5b5030600052607381538281f300730000000000000000000000000000000000000000301460806040526004361060555763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166324fef5c88114605a575b600080fd5b818015606557600080fd5b5060726004356024356084565b60408051918252519081900360200190f35b6000805b835481101560bc57828482815481101515609e57fe5b9060005260206000200154141560b55780915060c2565b6001016088565b60001991505b50929150505600a165627a7a72305820dd50badae5d39d8013dd477274519025531d3c7c11cd98cd10290fbace71b9510029" - code1_ContractGrammar001_testGrammar004 = "608060405234801561001057600080fd5b50610281806100206000396000f3006080604052600436106100615763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630178fe3f8114610066578063e33b870714610090578063e81cf24c146100aa578063f0ba8440146100c5575b600080fd5b34801561007257600080fd5b5061007e6004356100dd565b60408051918252519081900360200190f35b34801561009c57600080fd5b506100a86004356100ff565b005b3480156100b657600080fd5b506100a8600435602435610131565b3480156100d157600080fd5b5061007e600435610236565b600080828154811015156100ed57fe5b90600052602060002001549050919050565b600080546001810182559080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5630155565b604080517f24fef5c800000000000000000000000000000000000000000000000000000000815260006004820181905260248201859052915173__browser/TvmTest_p1_Grammar_004.sol:S__916324fef5c8916044808301926020929190829003018186803b1580156101a557600080fd5b505af41580156101b9573d6000803e3d6000fd5b505050506040513d60208110156101cf57600080fd5b5051905060001981141561021457600080546001810182559080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56301829055610231565b8160008281548110151561022457fe5b6000918252602090912001555b505050565b600080548290811061024457fe5b6000918252602090912001549050815600a165627a7a72305820e8c6ea7734c94bd93e5388cb46b5a5ba3807df808e86fb52d4fa2a792685d9280029" - code_ContractGrammar001_testGrammar006 = "608060405234801561001057600080fd5b50610159806100206000396000f3006080604052600436106100825763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166321183e8d81146100875780637f6b590c146100a15780638de6f511146100b9578063b3de648b146100a1578063e668f6b6146100b9578063e7708d03146100b9578063fb095f2e146100a1575b600080fd5b34801561009357600080fd5b5061009f6004356100d1565b005b3480156100ad57600080fd5b5061009f6004356100e2565b3480156100c557600080fd5b5061009f6004356100e5565b600a5b6000190180156100d4575050565b50565b6100e2565b50919050565b828110156100ea576002909102906001016100f0565b60008180156101245761011b60018403610106565b830291506100ea565b506001929150505600a165627a7a723058209488a62acdb28a3bac209504cc3dd53d2ef7bf56cbb835e431c507bbc2b0b20b0029" - - code_ContractGrammar002_testGrammar007 = "608060405234801561001057600080fd5b506000602081905260017fe831479d2c88b7e2c4154b0e3fd4b67c62580aba2734ac954410a8c097fac7c35560027f156aefbe71d87b3f83e37064ce76ea7eb25ea897d2708aad4c1d03439058d3a3557f7a7a790000000000000000000000000000000000000000000000000000000000905260077fd0d0b23e4a00f3e9683c2bc8ad2b8ee67c66dc4b2ae07ae98ee14d014badcf83556101b2806100b66000396000f3006080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166337721ab7811461005b578063a633d8d414610129578063ec56a37314610153575b600080fd5b34801561006757600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526100b494369492936024939284019190819084018382808284375094975061016b9650505050505050565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100ee5781810151838201526020016100d6565b50505050905090810190601f16801561011b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013557600080fd5b5061014160043561016e565b60408051918252519081900360200190f35b34801561015f57600080fd5b50610141600435610174565b90565b60030a90565b600060208190529081526040902054815600a165627a7a72305820dda8d0ad404466b0389ba7a490a63e5acc2d4eaf8ee3f4937e09084fba1f5a5a0029" - code1_ContractGrammar002_testGrammar007 = "608060405234801561001057600080fd5b5060405160208061033d833981016040525160018054600160a060020a0319908116600160a060020a039384161791829055600280549290931691161790556102df8061005e6000396000f3006080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166349de3f08811461005b5780639e3151a814610085578063f6598275146100b5575b600080fd5b34801561006757600080fd5b506100736004356100cd565b60408051918252519081900360200190f35b34801561009157600080fd5b506100b373ffffffffffffffffffffffffffffffffffffffff600435166101c9565b005b3480156100c157600080fd5b50610073600435610205565b600254604080517fec56a37300000000000000000000000000000000000000000000000000000000815260048101849052905160009273ffffffffffffffffffffffffffffffffffffffff169163ec56a37391602480830192602092919082900301818787803b15801561014057600080fd5b505af1158015610154573d6000803e3d6000fd5b505050506040513d602081101561016a57600080fd5b50506001546040805173ffffffffffffffffffffffffffffffffffffffff9092168252336020830152818101849052517f09208868f8090ea021d1f0e2ed8182e6a6f23a1f447267430e531bf2003c09199181900360600190a1919050565b6000805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600254604080517fa633d8d4000000000000000000000000000000000000000000000000000000008152600481018490529051600092839273ffffffffffffffffffffffffffffffffffffffff9091169163a633d8d49160248082019260209290919082900301818787803b15801561027d57600080fd5b505af1158015610291573d6000803e3d6000fd5b505050506040513d60208110156102a757600080fd5b505192909201929150505600a165627a7a723058208c58520ab7ab3c09ab693d81d3c7746deb66b7515d4258f26a379367fca4b95d0029" - code_ContractGrammar002_testGrammar008 = "608060405234801561001057600080fd5b50610188806100206000396000f30060806040526004361061004b5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663dba7ab6c8114610050578063f5f5ba7214610077575b600080fd5b34801561005c57600080fd5b50610065610101565b60408051918252519081900360200190f35b34801561008357600080fd5b5061008c610125565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100c65781810151838201526020016100ae565b50505050905090810190601f1680156100f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b7f6d69616f7700000000000000000000000000000000000000000000000000000090565b60408051808201909152600681527f46656c696e6500000000000000000000000000000000000000000000000000006020820152905600a165627a7a723058206cd9ce9902b03355d5f4bd8e0e4c4d9cd5b5d65364c50454f2418305ab515b4f0029" - code_ContractGrammar002_testGrammar010 = "608060405234801561001057600080fd5b506101b7806100206000396000f30060806040526004361061004b5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166355b775ea8114610050578063f198f5df14610080575b600080fd5b34801561005c57600080fd5b5061007e73ffffffffffffffffffffffffffffffffffffffff60043516610095565b005b34801561008c57600080fd5b5061007e6100d1565b6000805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663370158ea600a610320906040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016020604051808303818589803b15801561015b57600080fd5b5088f115801561016f573d6000803e3d6000fd5b5050505050506040513d602081101561018757600080fd5b50505600a165627a7a72305820f2b3e0e175369ea0df0aef7c6b9e8644b34c144efe85d21cb38539d1abd32e970029" - code_ContractGrammar002_testGrammar011 = "608060405234801561001057600080fd5b5060c88061001f6000396000f30060806040526004361060485763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166313d1aa2e8114604d578063e2179b8e146077575b600080fd5b348015605857600080fd5b506065600435602435608b565b60408051918252519081900360200190f35b348015608257600080fd5b506089608f565b005b5090565b609960036002608b565b505600a165627a7a723058202aeac1a0dbc6913a9378d4e8294f1061e5798083067aa9db5d95d8d78f24d5430029" - code_ContractGrammar002_testGrammar012 = "608060405234801561001057600080fd5b50610169806100206000396000f3006080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663370158ea8114610045575b600080fd5b61004d6100c7565b6040805198895273ffffffffffffffffffffffffffffffffffffffff97881660208a01527bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19909616888701526060880194909452608087019290925260a086015290921660c084015260e083019190915251908190036101000190f35b6000806000806000806000806000806000806000806000805a9f50339e50507bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19600035169c50349b50429a503a995032985050303196508d95508c94508b93508a925089915088905050505050505090919293949596975600a165627a7a72305820ba2fd5e479d9fa3924efa9cef8dde8690cf0618a742fe972533b7eb5b2b3ca990029" - code_ContractGrammar002_testGrammar013 = "60806040526000805534801561001457600080fd5b5060018054600160a060020a0319163317905561014c806100366000396000f3006080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166341c0e1b5811461005b578063a87d942c14610072578063d09de08a14610099575b600080fd5b34801561006757600080fd5b506100706100ae565b005b34801561007e57600080fd5b506100876100eb565b60408051918252519081900360200190f35b3480156100a557600080fd5b506100706100f1565b60015473ffffffffffffffffffffffffffffffffffffffff163314156100e95760015473ffffffffffffffffffffffffffffffffffffffff16ff5b565b60005490565b600154600a9073ffffffffffffffffffffffffffffffffffffffff1633141561011d5760008054820190555b505600a165627a7a72305820604072633e1ae10ab2bb71c55f8678aafe925bee8ebffa82a1eddc5c2ed1fc2d0029" - - code_ContractGrammar003_testGrammar014 = "608060405234801561001057600080fd5b50610435806100206000396000f3006080604052600436106100745763ffffffff60e060020a6000350416633da5d187811461007957806343c3a43a1461009f578063b053ebd4146100c3578063c8287909146100f4578063d7d21f5b14610109578063dd92afef1461012d578063ee9e398114610154578063fa06834b14610175575b600080fd5b34801561008557600080fd5b5061009d600160a060020a036004351660243561018a565b005b3480156100ab57600080fd5b5061009d600160a060020a0360043516602435610205565b3480156100cf57600080fd5b506100d8610282565b60408051600160a060020a039092168252519081900360200190f35b34801561010057600080fd5b506100d8610291565b34801561011557600080fd5b5061009d600160a060020a03600435166024356102a0565b34801561013957600080fd5b5061014261031d565b60408051918252519081900360200190f35b34801561016057600080fd5b5061009d600160a060020a0360043516610323565b34801561018157600080fd5b50610142610403565b81600160a060020a031660405180807f73657456616c75652875696e74323536290000000000000000000000000000008152506011019050604051809103902060e060020a9004826040518263ffffffff1660e060020a02815260040180828152602001915050600060405180830381865af4505050505050565b81600160a060020a031660405180807f73657456616c75652875696e74323536290000000000000000000000000000008152506011019050604051809103902060e060020a9004826040518263ffffffff1660e060020a028152600401808281526020019150506000604051808303816000875af1505050505050565b600154600160a060020a031681565b600154600160a060020a031690565b81600160a060020a031660405180807f73657456616c75652875696e74323536290000000000000000000000000000008152506011019050604051809103902060e060020a9004826040518263ffffffff1660e060020a028152600401808281526020019150506000604051808303816000875af2505050505050565b60005481565b80600160a060020a031660405180807f61646428290000000000000000000000000000000000000000000000000000008152506005019050604051809103902060e060020a90046040518163ffffffff1660e060020a0281526004016000604051808303816000875af1925050505080600160a060020a031660405180807f61646428290000000000000000000000000000000000000000000000000000008152506005019050604051809103902060e060020a90046040518163ffffffff1660e060020a0281526004016000604051808303816000875af15050505050565b600054905600a165627a7a7230582093a7a067c2321655a53783d1d54310cf8d57828093eeb9cf511536f8834f2de50029" - code1_ContractGrammar003_testGrammar014 = "608060405234801561001057600080fd5b5061055d806100206000396000f30060806040526004361061007f5763ffffffff60e060020a6000350416630eec1aba81146100845780631645c6c8146100b5578063466427c0146100cd5780634f2be91f146100e557806355241077146100fc578063b053ebd414610114578063c828790914610129578063dd92afef1461013e578063fa06834b14610165575b600080fd5b34801561009057600080fd5b5061009961017a565b60408051600160a060020a039092168252519081900360200190f35b3480156100c157600080fd5b50610099600435610189565b3480156100d957600080fd5b506100996004356101a4565b3480156100f157600080fd5b506100fa6101bf565b005b34801561010857600080fd5b506100fa600435610407565b34801561012057600080fd5b5061009961042b565b34801561013557600080fd5b5061009961043a565b34801561014a57600080fd5b50610153610449565b60408051918252519081900360200190f35b34801561017157600080fd5b5061015361044f565b600254600160a060020a031681565b600460205260009081526040902054600160a060020a031681565b600360205260009081526040902054600160a060020a031681565b600080546001018155806101d1610455565b604051809103906000f0801580156101ed573d6000803e3d6000fd5b50915081600160a060020a03166338cc48316040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561022e57600080fd5b505af1158015610242573d6000803e3d6000fd5b505050506040513d602081101561025857600080fd5b5051600080548152600360209081526040808320805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0395861617905580517f38cc48310000000000000000000000000000000000000000000000000000000081529051938616936338cc483193600480840194938390030190829087803b1580156102e157600080fd5b505af11580156102f5573d6000803e3d6000fd5b505050506040513d602081101561030b57600080fd5b50516002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909216919091179055610341610455565b604051809103906000f08015801561035d573d6000803e3d6000fd5b50905080600160a060020a03166338cc48316040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561039e57600080fd5b505af11580156103b2573d6000803e3d6000fd5b505050506040513d60208110156103c857600080fd5b5051600080548152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039092169190911790555050565b6000556001805473ffffffffffffffffffffffffffffffffffffffff191633179055565b600154600160a060020a031681565b600154600160a060020a031690565b60005481565b60005490565b60405160cd80610465833901905600608060405234801561001057600080fd5b5060ae8061001f6000396000f300608060405260043610603e5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166338cc483181146043575b600080fd5b348015604e57600080fd5b506055607e565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b30905600a165627a7a7230582002da030c3a635a762a2cd57a6d82b2c8a097197a64cad72ca827e7e227e67dd90029a165627a7a7230582023d343e99ca6abe7ec5591fd8706cb1a6d5bb25e9868b17445ad3171a6e295fd0029" - code_ContractGrammar003_testGrammar015 = "608060405234801561001057600080fd5b50610317806100206000396000f3006080604052600436106100535763ffffffff60e060020a600035041663292a1c6881146100b357806342a78883146100da57806342bb5a26146100f457806366b0bae0146101095780637c06885a1461011e575b34801561005f57600080fd5b507f17c1956f6e992470102c5fc953bf560fda31fabee8737cf8e77bdde00eb5698d6000366040518080602001828103825284848281815260200192508082843760405192018290039550909350505050a1005b3480156100bf57600080fd5b506100c8610133565b60408051918252519081900360200190f35b3480156100e657600080fd5b506100f2600435610168565b005b34801561010057600080fd5b506100c86101c4565b34801561011557600080fd5b506100f26101f9565b34801561012a57600080fd5b506100f261027c565b604080517f457869737446756e6343616c6c65642862797465732c75696e743235362900008152905190819003601e01902090565b7fb776d49293459725ca7d6a5abc60e389d2f3d067d4f028ba9cd790f69659984660003683604051808060200183815260200182810382528585828181526020019250808284376040519201829003965090945050505050a150565b604080517f46616c6c6261636b43616c6c65642862797465732900000000000000000000008152905190819003601501902090565b600060405180807f66756e6374696f6e4e6f744578697374282900000000000000000000000000008152506012019050604051809103902090503073ffffffffffffffffffffffffffffffffffffffff168160e060020a90046040518163ffffffff1660e060020a0281526004016000604051808303816000875af15050505050565b604080517f657869737446756e632875696e743235362900000000000000000000000000008152815190819003601201812063ffffffff60e060020a8083049182160283526001600484015292519092309290916024808301926000929190829003018183875af150505050505600a165627a7a7230582065d5e244faea44396a1826f0c2919055c883a00eef975f72a579ee7f0c654a0b0029" - code_ContractGrammar003_testGrammar016 = "608060405234801561001057600080fd5b50610270806100206000396000f3006080604052600436106100275763ffffffff60e060020a600035041663bef55ef3811461002c575b600080fd5b34801561003857600080fd5b50610041610043565b005b60008061004e610157565b604051809103906000f08015801561006a573d6000803e3d6000fd5b5091508173ffffffffffffffffffffffffffffffffffffffff16635b4b73a960036040518263ffffffff1660e060020a02815260040180828152602001915050600060405180830381600087803b1580156100c457600080fd5b505af11580156100d8573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff16633bc5de306040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561012757600080fd5b505af115801561013b573d6000803e3d6000fd5b505050506040513d602081101561015157600080fd5b50505050565b60405160de80610167833901905600608060405234801561001057600080fd5b5060bf8061001f6000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633bc5de308114604d5780635b4b73a9146071575b600080fd5b348015605857600080fd5b50605f6088565b60408051918252519081900360200190f35b348015607c57600080fd5b506086600435608e565b005b60005490565b6000555600a165627a7a72305820f4a95b9ecc5b7f7b57cbf2caff1c5f2f5e6e2dbd28464523cc05abde5864fd010029a165627a7a723058207ab90bb4123df32a1805dc37faaac054a403d1ab28007eb48c99ea48fefae6e90029" - code1_ContractGrammar003_testGrammar016 = "608060405234801561001057600080fd5b50610214806100206000396000f3006080604052600436106100565763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633bc5de30811461005b5780635b4b73a914610082578063e2179b8e1461009c575b600080fd5b34801561006757600080fd5b506100706100b1565b60408051918252519081900360200190f35b34801561008e57600080fd5b5061009a6004356100b7565b005b3480156100a857600080fd5b5061009a6100bc565b60005490565b600055565b6000806100c76100fb565b604051809103906000f0801580156100e3573d6000803e3d6000fd5b5091506100f2600360056100f7565b505050565b0190565b60405160de8061010b833901905600608060405234801561001057600080fd5b5060bf8061001f6000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633bc5de308114604d5780635b4b73a9146071575b600080fd5b348015605857600080fd5b50605f6088565b60408051918252519081900360200190f35b348015607c57600080fd5b506086600435608e565b005b60005490565b6000555600a165627a7a72305820f4a95b9ecc5b7f7b57cbf2caff1c5f2f5e6e2dbd28464523cc05abde5864fd010029a165627a7a723058205eb1e089faa9ff3eba073d682ee515d9d086d2ce3d4043109292b99a8a91d15f0029" - code_ContractGrammar003_testGrammar017 = "608060405234801561001057600080fd5b50610306806100206000396000f3006080604052600436106100565763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630121b93f811461005b5780635f72f4501461006857806397a9dae914610094575b600080fd5b6100666004356100d7565b005b34801561007457600080fd5b50610080600435610160565b604080519115158252519081900360200190f35b3480156100a057600080fd5b506100c573ffffffffffffffffffffffffffffffffffffffff600435166024356101e4565b60408051918252519081900360200190f35b60009081526001602081815260408084208151808301835233815234818501818152600384018054808901909155885260048401909552929095209451855473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff90911617855591519390920192909255600290910180549091019055565b600081815260016020819052604082209081015460028201548391111561018a57600092506101dd565b506002810180546000918290558254604051919273ffffffffffffffffffffffffffffffffffffffff9091169183156108fc0291849190818181858888f1935050505015156101d857600080fd5b600192505b5050919050565b6040805160808101825273ffffffffffffffffffffffffffffffffffffffff9384168152602080820193845260009282018381526060830184815293805260019182905291517fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49805473ffffffffffffffffffffffffffffffffffffffff1916919096161790945591517fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb4a5590517fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb4b55517fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb4c55905600a165627a7a72305820774c07868cec7fa6d603c6bffa4ad224b2c7523a44248047a445872f15b064980029" - code_ContractGrammar003_testGrammar018 = "608060405234801561001057600080fd5b5061025b806100206000396000f3006080604052600436106100775763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166307423b35811461007c5780634c15d6db146100a35780635ee41656146100b8578063a449e8eb146100cd578063b7a0961a146100e2578063d23d7e8a1461007c575b600080fd5b34801561008857600080fd5b506100916100f7565b60408051918252519081900360200190f35b3480156100af57600080fd5b5061009161012c565b3480156100c457600080fd5b5061009161013a565b3480156100d957600080fd5b50610091610147565b3480156100ee57600080fd5b506100916101b4565b604080517f31310000000000000000000000000000000000000000000000000000000000008152905190819003600201902090565b600060046003600209905090565b6000600360028008905090565b6000600260405180807f313100000000000000000000000000000000000000000000000000000000000081525060020190506020604051808303816000865af1158015610198573d6000803e3d6000fd5b5050506040513d60208110156101ad57600080fd5b5051905090565b6000600360405180807f313100000000000000000000000000000000000000000000000000000000000081525060020190506020604051808303816000865af1158015610205573d6000803e3d6000fd5b505050604051516c01000000000000000000000000026bffffffffffffffffffffffff19169050905600a165627a7a72305820af56e004716c8ccf6d0609f6bcdc39fa45fda7fbc38e049ef6bab4609abf86e10029" - code_ContractGrammar003_testGrammar019 = "6080604052348015600f57600080fd5b50603580601d6000396000f3006080604052600080fd00a165627a7a7230582027e85e5bf589c5cecb1dd0d8712fa54ff07ff16b4dca5a602c53587c17898b2f0029" - code_ContractGrammar003_testGrammar020 = "608060405234801561001057600080fd5b5060a48061001f6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063ccb5f721146044575b600080fd5b348015604f57600080fd5b5060566058565b005b620f424080141515606857600080fd5b600180141515607657600080fd5b5600a165627a7a72305820fdd16dc5b670249de6546a7474b1c29f5894578d17a251188bc616cc4476022c0029" - code_ContractScenario004_deployErc20TronToken = "60c0604052600660808190527f54726f6e6978000000000000000000000000000000000000000000000000000060a090815261003e916000919061013c565b506040805180820190915260038082527f545258000000000000000000000000000000000000000000000000000000000060209092019182526100839160019161013c565b506006600281905560006005558054600160a860020a03191690553480156100aa57600080fd5b50604051602080610abc83398101604081815291516006805461010060a860020a031916336101000217905567016345785d8a00006005819055600160a060020a03821660008181526003602090815286822084905592855294519294909390927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3506101d7565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017d57805160ff19168380011785556101aa565b828001600101855582156101aa579182015b828111156101aa57825182559160200191906001019061018f565b506101b69291506101ba565b5090565b6101d491905b808211156101b657600081556001016101c0565b90565b6108d6806101e66000396000f3006080604052600436106100cf5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100d457806307da68f51461015e578063095ea7b31461017557806318160ddd146101ad57806323b872dd146101d4578063313ce567146101fe57806342966c681461021357806370a082311461022b57806375f12b211461024c57806395d89b4114610261578063a9059cbb14610276578063be9a65551461029a578063c47f0027146102af578063dd62ed3e14610308575b600080fd5b3480156100e057600080fd5b506100e961032f565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561012357818101518382015260200161010b565b50505050905090810190601f1680156101505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016a57600080fd5b506101736103bd565b005b34801561018157600080fd5b50610199600160a060020a03600435166024356103e5565b604080519115158252519081900360200190f35b3480156101b957600080fd5b506101c261049e565b60408051918252519081900360200190f35b3480156101e057600080fd5b50610199600160a060020a03600435811690602435166044356104a4565b34801561020a57600080fd5b506101c26105c1565b34801561021f57600080fd5b506101736004356105c7565b34801561023757600080fd5b506101c2600160a060020a036004351661065e565b34801561025857600080fd5b50610199610670565b34801561026d57600080fd5b506100e9610679565b34801561028257600080fd5b50610199600160a060020a03600435166024356106d3565b3480156102a657600080fd5b5061017361079d565b3480156102bb57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526101739436949293602493928401919081908401838280828437509497506107c29650505050505050565b34801561031457600080fd5b506101c2600160a060020a03600435811690602435166107f2565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103b55780601f1061038a576101008083540402835291602001916103b5565b820191906000526020600020905b81548152906001019060200180831161039857829003601f168201915b505050505081565b6006546101009004600160a060020a031633146103d657fe5b6006805460ff19166001179055565b60065460009060ff16156103f557fe5b3315156103fe57fe5b81158061042c5750336000908152600460209081526040808320600160a060020a0387168452909152902054155b151561043757600080fd5b336000818152600460209081526040808320600160a060020a03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a350600192915050565b60055481565b60065460009060ff16156104b457fe5b3315156104bd57fe5b600160a060020a0384166000908152600360205260409020548211156104e257600080fd5b600160a060020a038316600090815260036020526040902054828101101561050957600080fd5b600160a060020a038416600090815260046020908152604080832033845290915290205482111561053957600080fd5b600160a060020a03808416600081815260036020908152604080832080548801905593881680835284832080548890039055600482528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060019392505050565b60025481565b336000908152600360205260409020548111156105e357600080fd5b336000818152600360209081526040808320805486900390558280527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff805486019055805185815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350565b60036020526000908152604090205481565b60065460ff1681565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103b55780601f1061038a576101008083540402835291602001916103b5565b60065460009060ff16156106e357fe5b3315156106ec57fe5b3360009081526003602052604090205482111561070857600080fd5b600160a060020a038316600090815260036020526040902054828101101561072f57600080fd5b33600081815260036020908152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b6006546101009004600160a060020a031633146107b657fe5b6006805460ff19169055565b6006546101009004600160a060020a031633146107db57fe5b80516107ee90600090602084019061080f565b5050565b600460209081526000928352604080842090915290825290205481565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061085057805160ff191683800117855561087d565b8280016001018555821561087d579182015b8281111561087d578251825591602001919060010190610862565b5061088992915061088d565b5090565b6108a791905b808211156108895760008155600101610893565b905600a165627a7a72305820d00bcb788ca406de94859b8bc4bda50c3c65ca67e1217ccccee92f59a92ae5e20029" - code_ContractScenario005_deployIcoContract = "60c0604052600660808190527f54726f6e6978000000000000000000000000000000000000000000000000000060a090815261003e916000919061013c565b506040805180820190915260038082527f545258000000000000000000000000000000000000000000000000000000000060209092019182526100839160019161013c565b506006600281905560006005558054600160a860020a03191690553480156100aa57600080fd5b50604051602080610abc83398101604081815291516006805461010060a860020a031916336101000217905567016345785d8a00006005819055600160a060020a03821660008181526003602090815286822084905592855294519294909390927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3506101d7565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017d57805160ff19168380011785556101aa565b828001600101855582156101aa579182015b828111156101aa57825182559160200191906001019061018f565b506101b69291506101ba565b5090565b6101d491905b808211156101b657600081556001016101c0565b90565b6108d6806101e66000396000f3006080604052600436106100cf5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100d457806307da68f51461015e578063095ea7b31461017557806318160ddd146101ad57806323b872dd146101d4578063313ce567146101fe57806342966c681461021357806370a082311461022b57806375f12b211461024c57806395d89b4114610261578063a9059cbb14610276578063be9a65551461029a578063c47f0027146102af578063dd62ed3e14610308575b600080fd5b3480156100e057600080fd5b506100e961032f565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561012357818101518382015260200161010b565b50505050905090810190601f1680156101505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016a57600080fd5b506101736103bd565b005b34801561018157600080fd5b50610199600160a060020a03600435166024356103e5565b604080519115158252519081900360200190f35b3480156101b957600080fd5b506101c261049e565b60408051918252519081900360200190f35b3480156101e057600080fd5b50610199600160a060020a03600435811690602435166044356104a4565b34801561020a57600080fd5b506101c26105c1565b34801561021f57600080fd5b506101736004356105c7565b34801561023757600080fd5b506101c2600160a060020a036004351661065e565b34801561025857600080fd5b50610199610670565b34801561026d57600080fd5b506100e9610679565b34801561028257600080fd5b50610199600160a060020a03600435166024356106d3565b3480156102a657600080fd5b5061017361079d565b3480156102bb57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526101739436949293602493928401919081908401838280828437509497506107c29650505050505050565b34801561031457600080fd5b506101c2600160a060020a03600435811690602435166107f2565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103b55780601f1061038a576101008083540402835291602001916103b5565b820191906000526020600020905b81548152906001019060200180831161039857829003601f168201915b505050505081565b6006546101009004600160a060020a031633146103d657fe5b6006805460ff19166001179055565b60065460009060ff16156103f557fe5b3315156103fe57fe5b81158061042c5750336000908152600460209081526040808320600160a060020a0387168452909152902054155b151561043757600080fd5b336000818152600460209081526040808320600160a060020a03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a350600192915050565b60055481565b60065460009060ff16156104b457fe5b3315156104bd57fe5b600160a060020a0384166000908152600360205260409020548211156104e257600080fd5b600160a060020a038316600090815260036020526040902054828101101561050957600080fd5b600160a060020a038416600090815260046020908152604080832033845290915290205482111561053957600080fd5b600160a060020a03808416600081815260036020908152604080832080548801905593881680835284832080548890039055600482528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060019392505050565b60025481565b336000908152600360205260409020548111156105e357600080fd5b336000818152600360209081526040808320805486900390558280527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff805486019055805185815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350565b60036020526000908152604090205481565b60065460ff1681565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103b55780601f1061038a576101008083540402835291602001916103b5565b60065460009060ff16156106e357fe5b3315156106ec57fe5b3360009081526003602052604090205482111561070857600080fd5b600160a060020a038316600090815260036020526040902054828101101561072f57600080fd5b33600081815260036020908152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b6006546101009004600160a060020a031633146107b657fe5b6006805460ff19169055565b6006546101009004600160a060020a031633146107db57fe5b80516107ee90600090602084019061080f565b5050565b600460209081526000928352604080842090915290825290205481565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061085057805160ff191683800117855561087d565b8280016001018555821561087d579182015b8281111561087d578251825591602001919060010190610862565b5061088992915061088d565b5090565b6108a791905b808211156108895760008155600101610893565b905600a165627a7a72305820d00bcb788ca406de94859b8bc4bda50c3c65ca67e1217ccccee92f59a92ae5e20029" - code_ContractScenario006_deployFomo3D = "60c0604052600660808190527f464f4d4f3344000000000000000000000000000000000000000000000000000060a0908152620000409160009190620000b8565b506040805180820190915260038082527f463344000000000000000000000000000000000000000000000000000000000060209092019182526200008791600191620000b8565b5068056bc75e2d631000006002556000600855600b805460ff19169055348015620000b157600080fd5b506200015d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620000fb57805160ff19168380011785556200012b565b828001600101855582156200012b579182015b828111156200012b5782518255916020019190600101906200010e565b50620001399291506200013d565b5090565b6200015a91905b8082111562000139576000815560010162000144565b90565b611688806200016d6000396000f3006080604052600436106101685763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166265318b811461017657806306fdde03146101a957806310d0ffdd1461023357806318160ddd1461024b578063226093731461026057806327defa1f14610278578063313ce567146102a1578063392efb52146102cc5780633ccfd60b146102e45780634b750334146102fb57806356d399e814610310578063688abbf7146103255780636b2f46321461033f57806370a08231146103545780638328b610146103755780638620410b1461038d57806389135ae9146103a25780638fea64bd146103bf578063949e8acd146103d457806395d89b41146103e9578063a8e04f34146103fe578063a9059cbb14610413578063b84c824614610437578063c47f002714610490578063e4849b32146104e9578063e9fad8ee14610501578063f088d54714610516578063fdb5a03e1461052a575b61017334600061053f565b50005b34801561018257600080fd5b50610197600160a060020a0360043516610b15565b60408051918252519081900360200190f35b3480156101b557600080fd5b506101be610b50565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f85781810151838201526020016101e0565b50505050905090810190601f1680156102255780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023f57600080fd5b50610197600435610bde565b34801561025757600080fd5b50610197610c0e565b34801561026c57600080fd5b50610197600435610c15565b34801561028457600080fd5b5061028d610c4e565b604080519115158252519081900360200190f35b3480156102ad57600080fd5b506102b6610c57565b6040805160ff9092168252519081900360200190f35b3480156102d857600080fd5b5061028d600435610c5c565b3480156102f057600080fd5b506102f9610c71565b005b34801561030757600080fd5b50610197610d44565b34801561031c57600080fd5b50610197610d98565b34801561033157600080fd5b506101976004351515610d9e565b34801561034b57600080fd5b50610197610de1565b34801561036057600080fd5b50610197600160a060020a0360043516610de6565b34801561038157600080fd5b506102f9600435610e01565b34801561039957600080fd5b50610197610e48565b3480156103ae57600080fd5b506102f96004356024351515610e90565b3480156103cb57600080fd5b506102f9610ef2565b3480156103e057600080fd5b50610197610ef4565b3480156103f557600080fd5b506101be610f07565b34801561040a57600080fd5b506102f9610f61565b34801561041f57600080fd5b5061028d600160a060020a0360043516602435610faf565b34801561044357600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526102f99436949293602493928401919081908401838280828437509497506111699650505050505050565b34801561049c57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526102f99436949293602493928401919081908401838280828437509497506111c29650505050505050565b3480156104f557600080fd5b506102f9600435611216565b34801561050d57600080fd5b506102f9611367565b610197600160a060020a0360043516611394565b34801561053657600080fd5b506102f96113a0565b60008060008060008060008060008a6000339050600b60009054906101000a900460ff16801561058157506801158e460913d000008261057d610de1565b0311155b1561088e57600160a060020a03811660009081526003602052604090205460ff16151560011480156105d65750600160a060020a038116600090815260076020526040902054670de0b6b3a764000090830111155b15156105e157600080fd5b600160a060020a0381166000908152600760205260409020546106049083611456565b600160a060020a03821660009081526007602052604090205533995061062b8d600561146c565b985061063889600361146c565b97506106448989611483565b96506106508d8a611483565b955061065b86611495565b9450680100000000000000008702935060008511801561068557506008546106838682611456565b115b151561069057600080fd5b600160a060020a038c16158015906106ba575089600160a060020a03168c600160a060020a031614155b80156106e05750600254600160a060020a038d1660009081526004602052604090205410155b1561072657600160a060020a038c166000908152600560205260409020546107089089611456565b600160a060020a038d16600090815260056020526040902055610741565b6107308789611456565b965068010000000000000000870293505b600060085411156107a55761075860085486611456565b600881905568010000000000000000880281151561077257fe5b6009805492909104909101905560085468010000000000000000880281151561079757fe5b0485028403840393506107ab565b60088590555b600160a060020a038a166000908152600460205260409020546107ce9086611456565b600460008c600160a060020a0316600160a060020a031681526020019081526020016000208190555083856009540203925082600660008c600160a060020a0316600160a060020a03168152602001908152602001600020600082825401925050819055508b600160a060020a03168a600160a060020a03167f022c0d992e4d873a3748436d960d5140c1f9721cf73f7ca5ec679d3d9f4fe2d58f88604051808381526020018281526020019250505060405180910390a3849a50610b05565b600b805460ff191690553399506108a68d600561146c565b98506108b389600361146c565b97506108bf8989611483565b96506108cb8d8a611483565b95506108d686611495565b9450680100000000000000008702935060008511801561090057506008546108fe8682611456565b115b151561090b57600080fd5b600160a060020a038c1615801590610935575089600160a060020a03168c600160a060020a031614155b801561095b5750600254600160a060020a038d1660009081526004602052604090205410155b156109a157600160a060020a038c166000908152600560205260409020546109839089611456565b600160a060020a038d166000908152600560205260409020556109bc565b6109ab8789611456565b965068010000000000000000870293505b60006008541115610a20576109d360085486611456565b60088190556801000000000000000088028115156109ed57fe5b60098054929091049091019055600854680100000000000000008802811515610a1257fe5b048502840384039350610a26565b60088590555b600160a060020a038a16600090815260046020526040902054610a499086611456565b600460008c600160a060020a0316600160a060020a031681526020019081526020016000208190555083856009540203925082600660008c600160a060020a0316600160a060020a03168152602001908152602001600020600082825401925050819055508b600160a060020a03168a600160a060020a03167f022c0d992e4d873a3748436d960d5140c1f9721cf73f7ca5ec679d3d9f4fe2d58f88604051808381526020018281526020019250505060405180910390a3849a505b5050505050505050505092915050565b600160a060020a0316600090815260066020908152604080832054600490925290912054600954680100000000000000009102919091030490565b6000805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610bd65780601f10610bab57610100808354040283529160200191610bd6565b820191906000526020600020905b815481529060010190602001808311610bb957829003601f168201915b505050505081565b6000808080610bee85600561146c565b9250610bfa8584611483565b9150610c0582611495565b95945050505050565b6008545b90565b6000806000806008548511151515610c2c57600080fd5b610c358561152d565b9250610c4283600561146c565b9150610c058383611483565b600b5460ff1681565b601281565b600a6020526000908152604090205460ff1681565b6000806000610c806001610d9e565b11610c8a57600080fd5b339150610c976000610d9e565b600160a060020a038316600081815260066020908152604080832080546801000000000000000087020190556005909152808220805490839055905193019350909183156108fc0291849190818181858888f19350505050158015610d00573d6000803e3d6000fd5b50604080518281529051600160a060020a038416917fccad973dcd043c7d680389db4378bd6b9775db7124092e9e0422c9e46d7985dc919081900360200190a25050565b60008060008060085460001415610d62576414f46b04009350610d92565b610d73670de0b6b3a764000061152d565b9250610d8083600561146c565b9150610d8c8383611483565b90508093505b50505090565b60025481565b60003382610db457610daf81610b15565b610dd8565b600160a060020a038116600090815260056020526040902054610dd682610b15565b015b91505b50919050565b303190565b600160a060020a031660009081526004602052604090205490565b604080516c010000000000000000000000003390810282528251918290036014019091206000908152600a602052919091205460ff161515610e4257600080fd5b50600255565b60008060008060085460001415610e665764199c82cc009350610d92565b610e77670de0b6b3a764000061152d565b9250610e8483600561146c565b9150610d8c8383611456565b604080516c010000000000000000000000003390810282528251918290036014019091206000908152600a602052919091205460ff161515610ed157600080fd5b506000918252600a6020526040909120805460ff1916911515919091179055565b565b600033610f0081610de6565b91505b5090565b60018054604080516020600284861615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610bd65780601f10610bab57610100808354040283529160200191610bd6565b604080516c010000000000000000000000003390810282528251918290036014019091206000908152600a602052919091205460ff161515610fa257600080fd5b50600b805460ff19169055565b600080600080600080610fc0610ef4565b11610fca57600080fd5b600b5433945060ff16158015610ff85750600160a060020a0384166000908152600460205260409020548611155b151561100357600080fd5b600061100f6001610d9e565b111561101d5761101d610c71565b61102886600561146c565b92506110348684611483565b915061103f8361152d565b905061104d60085484611483565b600855600160a060020a0384166000908152600460205260409020546110739087611483565b600160a060020a0380861660009081526004602052604080822093909355908916815220546110a29083611456565b600160a060020a0388811660008181526004602090815260408083209590955560098054948a16835260069091528482208054948c02909403909355825491815292909220805492850290920190915554600854611116919068010000000000000000840281151561111057fe5b04611456565b600955604080518381529051600160a060020a03808a1692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35060019695505050505050565b604080516c010000000000000000000000003390810282528251918290036014019091206000908152600a602052919091205460ff1615156111aa57600080fd5b81516111bd9060019060208501906115ce565b505050565b604080516c010000000000000000000000003390810282528251918290036014019091206000908152600a602052919091205460ff16151561120357600080fd5b81516111bd9060009060208501906115ce565b6000806000806000806000611229610ef4565b1161123357600080fd5b3360008181526004602052604090205490965087111561125257600080fd5b86945061125e8561152d565b935061126b84600561146c565b92506112778484611483565b915061128560085486611483565b600855600160a060020a0386166000908152600460205260409020546112ab9086611483565b600160a060020a0387166000908152600460209081526040808320939093556009546006909152918120805492880268010000000000000000860201928390039055600854919250101561131b5761131760095460085468010000000000000000860281151561111057fe5b6009555b60408051868152602081018490528151600160a060020a038916927fc4823739c5787d2ca17e404aa47d5569ae71dfb49cbf21b3f6152ed238a31139928290030190a250505050505050565b33600081815260046020526040812054908111156113885761138881611216565b611390610c71565b5050565b6000610ddb348361053f565b6000806000806113b06001610d9e565b116113ba57600080fd5b6113c46000610d9e565b3360008181526006602090815260408083208054680100000000000000008702019055600590915281208054908290559092019450925061140690849061053f565b905081600160a060020a03167fbe339fc14b041c2b0e0f3dd2cd325d0c3668b78378001e53160eab36153264588483604051808381526020018281526020019250505060405180910390a2505050565b60008282018381101561146557fe5b9392505050565b600080828481151561147a57fe5b04949350505050565b60008282111561148f57fe5b50900390565b6008546000906c01431e0fae6d7217caa00000009082906402540be40061151a611514730380d4bd8a8678c1bb542c80deb4800000000000880268056bc75e2d631000006002860a02017005e0a1fd2712875988becaad0000000000850201780197d4df19d605767337e9f14d3eec8920e40000000000000001611599565b85611483565b81151561152357fe5b0403949350505050565b600854600090670de0b6b3a76400008381019181019083906115866414f46b04008285046402540be40002018702600283670de0b6b3a763ffff1982890a8b900301046402540be4000281151561158057fe5b04611483565b81151561158f57fe5b0495945050505050565b80600260018201045b81811015610ddb5780915060028182858115156115bb57fe5b04018115156115c657fe5b0490506115a2565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061160f57805160ff191683800117855561163c565b8280016001018555821561163c579182015b8281111561163c578251825591602001919060010190611621565b50610f0392610c129250905b80821115610f0357600081556001016116485600a165627a7a723058202986f1ef7924e33e9f5613300f260c5fd9f05700de3217343d70f3a5fea5f76d0029" - code_ContractScenario007_deployErc721CardMigration = "6000805460a060020a60ff021916905560e0604052602360808190527f68747470733a2f2f6170692e676f6473756e636861696e65642e636f6d2f636160a09081527f72642f000000000000000000000000000000000000000000000000000000000060c0526200007491601091906200023e565b503480156200008257600080fd5b5060405160208062004212833981016040525160008054600160a060020a03191633179055620000db7f01ffc9a700000000000000000000000000000000000000000000000000000000640100000000620001d1810204565b6200010f7f80ac58cd00000000000000000000000000000000000000000000000000000000640100000000620001d1810204565b620001437f4f558e7900000000000000000000000000000000000000000000000000000000640100000000620001d1810204565b620001777f780e9d6300000000000000000000000000000000000000000000000000000000640100000000620001d1810204565b620001ab7f5b5e139f00000000000000000000000000000000000000000000000000000000640100000000620001d1810204565b60158054600160a060020a031916600160a060020a0392909216919091179055620002e3565b7fffffffff0000000000000000000000000000000000000000000000000000000080821614156200020157600080fd5b7fffffffff00000000000000000000000000000000000000000000000000000000166000908152600c60205260409020805460ff19166001179055565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200028157805160ff1916838001178555620002b1565b82800160010185558215620002b1579182015b82811115620002b157825182559160200191906001019062000294565b50620002bf929150620002c3565b5090565b620002e091905b80821115620002bf5760008155600101620002ca565b90565b613f1f80620002f36000396000f3006080604052600436106103425763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166301ffc9a7811461034757806305c4af9d1461037d57806306fdde031461040c578063081812fc14610496578063095ea7b3146104ca5780630bbe0ee3146104f05780630c340a241461055b5780630e359f1614610570578063100cdd911461058857806318160ddd146105dd57806319fa8f50146106045780631fa24aa71461063657806323b872dd1461065157806324a96d701461067b5780632f745c59146106c5578063396ed600146106e95780633cb4ff3c146107015780633f4ba83a1461071657806342842e0e1461072b57806342966c6814610755578063454b06081461076d5780634cc90115146107855780634f558e791461079d5780634f6ccce7146107b55780634fb31a6a146107cd578063524773ce1461080d5780635bd9d9a5146108225780635c975abb1461083d5780635dcbd8bb146108525780636352211e1461087b57806367025dcf1461089357806370a08231146108e95780637a8b9b851461090a578063818d4b5d14610925578063821f830f146109495780638456cb591461096a578063850e37601461097f5780638dc10768146109b15780638e7e879f146109ea5780639188d31214610a3f578063943b82f114610a5757806395d89b4114610a97578063986e82f214610aac578063a22cb46514610ac8578063a3f4df7e14610aee578063a5487e5114610b03578063a71aec7314610b1b578063a9059cbb14610b37578063ad94d90114610b4e578063b5cab1ce14610bb1578063b84c139214610bc6578063b88d4fde14610bde578063bc734f0f14610c4d578063bcb3962114610c62578063c42cf53514610c77578063c87b56dd14610c98578063c968aab314610cb0578063caa1916814610ccb578063ce9fdb7014610ced578063ced28d7714610d2c578063d7643e1814610d78578063d80f862114610d8d578063dfb6a75f14610da5578063e3c7336b14610dea578063e7cf548c14611007578063e985e9c51461101c578063eeffbe4e14611043578063f03034521461105b578063f5f23b52146110be578063f76f8d78146110d9578063fb36eba1146110ee575b600080fd5b34801561035357600080fd5b50610369600160e060020a03196004351661111c565b604080519115158252519081900360200190f35b34801561038957600080fd5b5061039961ffff6004351661113b565b604080518a1515815260ff808b166020830152898116928201929092529087166060820152608081018660048111156103ce57fe5b60ff90811682529586166020820152938516604080860191909152928516606085015250909216608082015290519081900360a00195509350505050f35b34801561041857600080fd5b50610421611296565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561045b578181015183820152602001610443565b50505050905090810190601f1680156104885780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104a257600080fd5b506104ae6004356112ce565b60408051600160a060020a039092168252519081900360200190f35b3480156104d657600080fd5b506104ee600160a060020a03600435166024356112e9565b005b3480156104fc57600080fd5b5060408051602060046044358181013583810280860185019096528085526104ee958335600160a060020a0390811696602480359092169636969560649592949301928291850190849080828437509497506113299650505050505050565b34801561056757600080fd5b506104ae611365565b34801561057c57600080fd5b50610369600435611374565b34801561059457600080fd5b50604080516020600480358082013583810280860185019096528085526104ee953695939460249493850192918291850190849080828437509497506113899650505050505050565b3480156105e957600080fd5b506105f26113bd565b60408051918252519081900360200190f35b34801561061057600080fd5b506106196113c3565b60408051600160e060020a03199092168252519081900360200190f35b34801561064257600080fd5b506104ee60ff600435166113e7565b34801561065d57600080fd5b506104ee600160a060020a036004358116906024351660443561143c565b34801561068757600080fd5b506106ae61ffff6004351660ff602435811690604435811690606435166084351515611469565b6040805161ffff9092168252519081900360200190f35b3480156106d157600080fd5b506105f2600160a060020a03600435166024356114ff565b3480156106f557600080fd5b506106ae60043561156f565b34801561070d57600080fd5b506105f26115a5565b34801561072257600080fd5b506104ee6115b8565b34801561073757600080fd5b506104ee600160a060020a036004358116906024351660443561162e565b34801561076157600080fd5b506104ee600435611660565b34801561077957600080fd5b506104ee600435611691565b34801561079157600080fd5b506106ae60043561180c565b3480156107a957600080fd5b5061036960043561181a565b3480156107c157600080fd5b506105f2600435611837565b3480156107d957600080fd5b506104ee61ffff6004351660ff60243581169060443581169060643581169060843581169060a43581169060c43516611850565b34801561081957600080fd5b506105f2611b03565b34801561082e57600080fd5b5061036960ff60043516611b09565b34801561084957600080fd5b50610369611b1e565b34801561085e57600080fd5b506104ee61ffff6004351667ffffffffffffffff60243516611b2e565b34801561088757600080fd5b506104ae600435611c0c565b6040805160206004602480358281013584810280870186019097528086526104ee968435600160a060020a031696369660449591949091019291829185019084908082843750949750611c369650505050505050565b3480156108f557600080fd5b506105f2600160a060020a0360043516611c6b565b34801561091657600080fd5b5061036960ff60043516611c86565b34801561093157600080fd5b50610369600160a060020a0360043516602435611c9b565b34801561095557600080fd5b506104ee600160a060020a0360043516611cc1565b34801561097657600080fd5b506104ee611d37565b34801561098b57600080fd5b5061099b61ffff60043516611db2565b6040805160ff9092168252519081900360200190f35b3480156109bd57600080fd5b506109c9600435611dc0565b6040805161ffff938416815291909216602082015281519081900390910190f35b3480156109f657600080fd5b50604080516020600480358082013583810280860185019096528085526104ee95369593946024949385019291829185019084908082843750949750611ded9650505050505050565b348015610a4b57600080fd5b506109c9600435611e21565b348015610a6357600080fd5b50610a7361ffff60043516611e75565b6040805167ffffffffffffffff909316835290151560208301528051918290030190f35b348015610aa357600080fd5b50610421611ecc565b348015610ab857600080fd5b50610a7361ffff60043516611f03565b348015610ad457600080fd5b506104ee600160a060020a03600435166024351515611f30565b348015610afa57600080fd5b50610421611fb4565b348015610b0f57600080fd5b506106ae600435611feb565b348015610b2757600080fd5b5061036961ffff60043516611ff9565b6104ee600160a060020a0360043516602435612029565b348015610b5a57600080fd5b50604080516020600460248035828101358481028087018601909752808652610369968435600160a060020a0316963696604495919490910192918291850190849080828437509497506120849650505050505050565b348015610bbd57600080fd5b506104216120e8565b348015610bd257600080fd5b506104ae600435612176565b348015610bea57600080fd5b50604080516020601f6064356004818101359283018490048402850184019095528184526104ee94600160a060020a03813581169560248035909216956044359536956084940191819084018382808284375094975061219e9650505050505050565b348015610c5957600080fd5b506104ee6121d6565b348015610c6e57600080fd5b5061099b61225e565b348015610c8357600080fd5b506104ee600160a060020a0360043516612267565b348015610ca457600080fd5b506104216004356122ad565b348015610cbc57600080fd5b506104ee60ff6004351661234f565b348015610cd757600080fd5b506106ae60ff6004351661ffff602435166123a0565b348015610cf957600080fd5b506106ae61ffff6004351660ff60243581169060443581169060643581169060843581169060a4351660c4351515612534565b348015610d3857600080fd5b506106ae61ffff6004351660ff60243581169060443581169060643581169060843581169060a43581169060c43581169060e435166101043515156125cc565b348015610d8457600080fd5b506106ae61266c565b348015610d9957600080fd5b506106ae60043561267b565b348015610db157600080fd5b506106ae61ffff6004351660ff60243581169060443581169060643581169060843581169060a43581169060c4351660e4351515612689565b348015610df657600080fd5b50604080516020600480358082013583810280860185019096528085526106ae95369593946024949385019291829185019084908082843750506040805187358901803560208181028481018201909552818452989b9a998901989297509082019550935083925085019084908082843750506040805187358901803560208181028481018201909552818452989b9a998901989297509082019550935083925085019084908082843750506040805187358901803560208181028481018201909552818452989b9a998901989297509082019550935083925085019084908082843750506040805187358901803560208181028481018201909552818452989b9a998901989297509082019550935083925085019084908082843750506040805187358901803560208181028481018201909552818452989b9a998901989297509082019550935083925085019084908082843750506040805187358901803560208181028481018201909552818452989b9a998901989297509082019550935083925085019084908082843750506040805187358901803560208181028481018201909552818452989b9a998901989297509082019550935083925085019084908082843750506040805187358901803560208181028481018201909552818452989b9a9989019892975090820195509350839250850190849080828437509497506127269650505050505050565b34801561101357600080fd5b506105f26128b5565b34801561102857600080fd5b50610369600160a060020a03600435811690602435166128bb565b34801561104f57600080fd5b506106ae6004356128e9565b34801561106757600080fd5b506040805160206004602480358281013584810280870186019097528086526104ee968435600160a060020a0316963696604495919490910192918291850190849080828437509497506128f79650505050505050565b3480156110ca57600080fd5b506104ee60ff6004351661292c565b3480156110e557600080fd5b50610421612961565b3480156110fa57600080fd5b506105f2600160a060020a036004351661ffff60243581169060443516612998565b600160e060020a0319166000908152600c602052604090205460ff1690565b6000806000806000806000806000611151613df2565b61ffff8b16600090815260066020908152604091829020825161012081018452815460ff8082161515835261010082048116948301949094526201000081048416948201949094526301000000840483166060820152929091608084019164010000000090041660048111156111c357fe5b60048111156111ce57fe5b81526020016000820160059054906101000a900460ff1660ff1660ff1681526020016000820160069054906101000a900460ff1660ff1660ff1681526020016000820160079054906101000a900460ff1660ff1660ff1681526020016000820160089054906101000a900460ff1660ff1660ff16815250509050806000015181602001518260400151836060015184608001518560a001518660c001518760e00151886101000151995099509950995099509950995099509950509193959799909294969850565b60408051808201909152600e81527f476f647320556e636861696e656400000000000000000000000000000000000060208201525b90565b6000908152600e6020526040902054600160a060020a031690565b6113106001828154811015156112fb57fe5b60009182526020909120015461ffff16611ff9565b151561131b57600080fd5b6113258282612b50565b5050565b60005b815181101561135f576113578484848481518110151561134857fe5b9060200190602002015161143c565b60010161132c565b50505050565b600054600160a060020a031681565b60166020526000908152604090205460ff1681565b60005b8151811015611325576113b582828151811015156113a657fe5b90602001906020020151611660565b60010161138c565b60015490565b7f01ffc9a70000000000000000000000000000000000000000000000000000000081565b600054600160a060020a031633146113fe57600080fd5b60ff80821660009081526003602052604090205416151561141e57600080fd5b60ff166000908152600460205260409020805460ff19166001179055565b61144e6001828154811015156112fb57fe5b151561145957600080fd5b611464838383612c06565b505050565b6000611473613df2565b600054600160a060020a0316331461148a57600080fd5b6040805161012081018252600180825260ff808a16602084015260055416928201929092526060810191909152608081018660048111156114c757fe5b815260ff861660208201526000604082018190526060820181905260809091015290506114f5878285612c99565b5095945050505050565b600061150a83611c6b565b821061151557600080fd5b600160a060020a038316600090815260116020526040902080548390811061153957fe5b90600052602060002090600691828204019190066005029054906101000a900464ffffffffff1664ffffffffff16905092915050565b600b80548290811061157d57fe5b9060005260206000209060109182820401919006600202915054906101000a900461ffff1681565b60006013546115b26113bd565b03905090565b600054600160a060020a031633146115cf57600080fd5b60005460a060020a900460ff1615156115e757600080fd5b6000805474ff0000000000000000000000000000000000000000191681556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b339190a1565b80611639338261312c565b151561164457600080fd5b61135f848484602060405190810160405280600081525061219e565b803361166b82611c0c565b600160a060020a03161461167e57600080fd5b601380546001019055611325338361318b565b6000818152601660205260408120548190819060ff16156116b157600080fd5b6000848152601660209081526040808320805460ff1916600117905560155481517f6352211e000000000000000000000000000000000000000000000000000000008152600481018990529151600160a060020a0390911693636352211e93602480850194919392918390030190829087803b15801561173057600080fd5b505af1158015611744573d6000803e3d6000fd5b505050506040513d602081101561175a57600080fd5b5051601554604080517f9188d312000000000000000000000000000000000000000000000000000000008152600481018890528151939650600160a060020a0390921692639188d3129260248082019392918290030181600087803b1580156117c257600080fd5b505af11580156117d6573d6000803e3d6000fd5b505050506040513d60408110156117ec57600080fd5b50805160209091015190925090506118058383836131c9565b5050505050565b600780548290811061157d57fe5b6000908152600d6020526040902054600160a060020a0316151590565b60006118416113bd565b821061184c57600080fd5b5090565b611858613df2565b600054600160a060020a0316331461186f57600080fd5b61ffff8816600090815260066020908152604091829020825161012081018452815460ff8082161515835261010082048116948301949094526201000081048416948201949094526301000000840483166060820152929091608084019164010000000090041660048111156118e157fe5b60048111156118ec57fe5b8152905460ff650100000000008204811660208085019190915266010000000000008304821660408086019190915267010000000000000084048316606086015268010000000000000000909304821660809094019390935283820151811660009081526003909352912054919250161561196657600080fd5b610120604051908101604052806001151581526020018860ff168152602001826040015160ff1681526020018760ff168152602001826080015160048111156119ab57fe5b815260ff87811660208084019190915287821660408085019190915287831660608086019190915287841660809586015261ffff8e166000908152600684528290208651815494880151938801519288015160ff199095169015151761ff001916610100938616939093029290921762ff0000191662010000918516919091021763ff00000019166301000000929093169190910291909117808255918301519091829064ff000000001916640100000000836004811115611a6957fe5b021790555060a0820151815460c084015160e08501516101009095015165ff0000000000199092166501000000000060ff948516021766ff00000000000019166601000000000000918416919091021767ff000000000000001916670100000000000000948316949094029390931768ff000000000000000019166801000000000000000091909316029190911790555050505050505050565b60135481565b60046020526000908152604090205460ff1681565b60005460a060020a900460ff1681565b611b36613e3e565b600054600160a060020a03163314611b4d57600080fd5b5061ffff821660009081526002602090815260409182902082518084019093525467ffffffffffffffff8116835268010000000000000000900460ff1615801591830191909152611b9d57600080fd5b5060408051808201825267ffffffffffffffff92831681526001602080830191825261ffff90951660009081526002909552919093209251835491511515680100000000000000000268ff0000000000000000199190931667ffffffffffffffff199092169190911716179055565b6000818152600d6020526040812054600160a060020a0316801515611c3057600080fd5b92915050565b60005b815181101561146457611c63838383815181101515611c5457fe5b90602001906020020151612029565b600101611c39565b600160a060020a031660009081526011602052604090205490565b60036020526000908152604090205460ff1681565b600082600160a060020a0316611cb083611c0c565b600160a060020a0316149392505050565b600054600160a060020a03163314611cd857600080fd5b601480546001810182556000919091527fce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4ec01805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600054600160a060020a03163314611d4e57600080fd5b60005460a060020a900460ff1615611d6557600080fd5b6000805474ff0000000000000000000000000000000000000000191660a060020a1781556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff6259190a1565b6103e861ffff919091160490565b6001805482908110611dce57fe5b60009182526020909120015461ffff8082169250620100009091041682565b60005b815181101561132557611e198282815181101515611e0a57fe5b90602001906020020151611691565b600101611df0565b600080611e2c613e3e565b6001805485908110611e3a57fe5b60009182526020918290206040805180820190915291015461ffff808216808452620100009092041691909201819052909590945092505050565b600080611e80613e3e565b50505061ffff1660009081526002602090815260409182902082518084019093525467ffffffffffffffff81168084526801000000000000000090910460ff1615159290910182905291565b60408051808201909152600481527f474f445300000000000000000000000000000000000000000000000000000000602082015290565b60026020526000908152604090205467ffffffffffffffff81169068010000000000000000900460ff1682565b600160a060020a038216331415611f4657600080fd5b336000818152600f60209081526040808320600160a060020a03871680855290835292819020805460ff1916861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b60408051808201909152600e81527f476f647320556e636861696e6564000000000000000000000000000000000000602082015281565b600a80548290811061157d57fe5b61ffff1660009081526006602090815260408083205462010000900460ff90811684526003909252909120541690565b803361203482611c0c565b600160a060020a03161461204757600080fd5b6120596001838154811015156112fb57fe5b151561206457600080fd5b600160a060020a038316151561207957600080fd5b6114643384846132ae565b6000806000835111151561209757600080fd5b5060005b82518110156120dc576120c58484838151811015156120b657fe5b90602001906020020151611c9b565b15156120d457600091506120e1565b60010161209b565b600191505b5092915050565b6010805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561216e5780601f106121435761010080835404028352916020019161216e565b820191906000526020600020905b81548152906001019060200180831161215157829003601f168201915b505050505081565b601480548290811061218457fe5b600091825260209091200154600160a060020a0316905081565b816121a9338261312c565b15156121b457600080fd5b6121bf85858561143c565b6121cb85858585613300565b151561180557600080fd5b600054600160a060020a031633146121ed57600080fd5b60055460ff908116111561220057600080fd5b6005805460ff8082166001011660ff199091161790556000612223600782613e55565b506000612231600882613e55565b50600061223f600982613e55565b50600061224d600a82613e55565b50600061225b600b82613e55565b50565b60055460ff1681565b600054600160a060020a0316331461227e57600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6010805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152606093611c30939192909183018282801561233c5780601f106123115761010080835404028352916020019161233c565b820191906000526020600020905b81548152906001019060200180831161231f57829003601f168201915b505050505061234a8461346d565b613560565b600054600160a060020a0316331461236657600080fd5b60ff808216600090815260046020526040902054161561238557600080fd5b60ff166000908152600360205260409020805460ff19169055565b600080808080808760048111156123b357fe5b141561240357600b805461ffff88168115156123cb57fe5b068154811015156123d857fe5b90600052602060002090601091828204019190066002029054906101000a900461ffff16945061252a565b600187600481111561241157fe5b141561242957600a805461ffff88168115156123cb57fe5b600287600481111561243757fe5b141561244f576009805461ffff88168115156123cb57fe5b600387600481111561245d57fe5b1415612475576008805461ffff88168115156123cb57fe5b600487600481111561248357fe5b1415610342575060005b600754811015612518576007805461ffff881683018115156124ab57fe5b068154811015156124b857fe5b90600052602060002090601091828204019190066002029054906101000a900461ffff1693506124e784611e75565b9093509150818015612503575060008367ffffffffffffffff16115b156125105783945061252a565b60010161248d565b6008805461ffff88168115156123cb57fe5b5050505092915050565b600061253e613df2565b600054600160a060020a0316331461255557600080fd5b60408051610120810182526001815260ff808b1660208301526005541691810191909152600360608201526080810188600481111561259057fe5b815260ff8089166020830152878116604083015286166060820152600060809091015290506125c0898285612c99565b50979650505050505050565b60006125d6613df2565b600054600160a060020a031633146125ed57600080fd5b60408051610120810182526001815260ff808d1660208301526005548116928201929092529086166060820152608081018a600481111561262a57fe5b81526020018960ff1681526020018860ff1681526020018760ff1681526020018560ff16815250905061265e8b8285612c99565b509998505050505050505050565b600554610100900461ffff1681565b600980548290811061157d57fe5b6000612693613df2565b600054600160a060020a031633146126aa57600080fd5b60408051610120810182526001815260ff808c166020830152600554169181019190915260026060820152608081018960048111156126e557fe5b81526020018860ff1681526020018760ff1681526020018660ff1681526020018560ff1681525090506127198a8285612c99565b5098975050505050505050565b600080612731613df2565b600054600160a060020a0316331461274857600080fd5b600091505b8b518210156128a657610120604051908101604052806001151581526020018c8481518110151561277a57fe5b602090810290910181015160ff9081168352600554169082015287516040909101908890859081106127a857fe5b9060200190602002015160ff1681526020018b848151811015156127c857fe5b9060200190602002015160048111156127dd57fe5b81526020018a848151811015156127f057fe5b9060200190602002015160ff168152602001898481518110151561281057fe5b9060200190602002015160ff168152602001888481518110151561283057fe5b9060200190602002015160ff168152602001868481518110151561285057fe5b9060200190602002015160ff16815250905061289b8c8381518110151561287357fe5b9060200190602002015182868581518110151561288c57fe5b90602001906020020151612c99565b60019091019061274d565b50509998505050505050505050565b60135490565b600160a060020a039182166000908152600f6020908152604080832093909416825291909152205460ff1690565b600880548290811061157d57fe5b60005b81518110156114645761292483838381518110151561291557fe5b906020019060200201516112e9565b6001016128fa565b600054600160a060020a0316331461294357600080fd5b60ff166000908152600360205260409020805460ff19166001179055565b60408051808201909152600481527f474f445300000000000000000000000000000000000000000000000000000000602082015281565b60006129a2613df2565b60008054819060a060020a900460ff16156129bc57600080fd5b6129c461359c565b15156129cf57600080fd5b61ffff8616600090815260066020908152604091829020825161012081018452815460ff808216151583526101008204811694830194909452620100008104841694820194909452630100000084048316606082015292909160808401916401000000009004166004811115612a4157fe5b6004811115612a4c57fe5b8152905460ff6501000000000082048116602084015266010000000000008204811660408085019190915267010000000000000083048216606085015268010000000000000000909204811660809093019290925260055490830151929550918116911614612aba57600080fd5b600483608001516004811115612acc57fe5b1415612b3a57612adb86611e75565b9092509050801580612af7575060008267ffffffffffffffff16115b1515612b0257600080fd5b61ffff86166000908152600260205260409020805467ffffffffffffffff19811667ffffffffffffffff918216600019019091161790555b612b458787876131c9565b979650505050505050565b6000612b5b82611c0c565b9050600160a060020a038381169082161415612b7657600080fd5b33600160a060020a0382161480612b925750612b9281336128bb565b1515612b9d57600080fd5b6000828152600e6020526040808220805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b80612c11338261312c565b1515612c1c57600080fd5b600160a060020a0384161515612c3157600080fd5b600160a060020a0383161515612c4657600080fd5b612c5084836135ed565b612c5a848361365c565b612c6483836138bd565b8183600160a060020a031685600160a060020a0316600080516020613ed483398151915260405160405180910390a450505050565b61ffff831660009081526006602052604081205460ff1615612cba57600080fd5b6001835261ffff8416600090815260066020908152604091829020855181549287015193870151606088015160ff199094169115159190911761ff00191661010060ff958616021762ff0000191662010000918516919091021763ff000000191663010000009390921692909202178082556080850151859291829064ff000000001916640100000000836004811115612d5057fe5b021790555060a08201518160000160056101000a81548160ff021916908360ff16021790555060c08201518160000160066101000a81548160ff021916908360ff16021790555060e08201518160000160076101000a81548160ff021916908360ff1602179055506101008201518160000160086101000a81548160ff021916908360ff1602179055509050506005600181819054906101000a900461ffff168092919060010191906101000a81548161ffff021916908361ffff160217905550507f2f7e8f79713fd202353aaa4d413bb73a3bc66d59a540f646415fd9acee7e59c684600560009054906101000a900460ff16856020015186608001518760a001518860c001518960e001518a606001518b61010001518b604051808b61ffff1661ffff1681526020018a60ff1660ff1681526020018960ff1660ff168152602001886004811115612e9f57fe5b60ff90811682529788166020820152958716604080880191909152948716606087015250918516608085015290931660a083015291151560c082015290519081900360e001945092505050a1811561135f575060808201516000816004811115612f0557fe5b1415612f6857600b80546001810182556000919091527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db960108204018054600f9092166002026101000a61ffff818102199093169287160291909117905561135f565b6001816004811115612f7657fe5b1415612fd957600a80546001810182556000919091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a860108204018054600f9092166002026101000a61ffff818102199093169287160291909117905561135f565b6002816004811115612fe757fe5b141561304a57600980546001810182556000919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af60108204018054600f9092166002026101000a61ffff818102199093169287160291909117905561135f565b600381600481111561305857fe5b14156130bb57600880546001810182556000919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee360108204018054600f9092166002026101000a61ffff818102199093169287160291909117905561135f565b60048160048111156130c957fe5b141561034257600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68860108204018054600f9092166002026101000a61ffff818102199093169287160291909117905561135f565b60008061313883611c0c565b905080600160a060020a031684600160a060020a03161480613173575083600160a060020a0316613168846112ce565b600160a060020a0316145b80613183575061318381856128bb565b949350505050565b61319582826135ed565b61319f828261365c565b6040518190600090600160a060020a03851690600080516020613ed4833981519152908390a45050565b60006131d3613e3e565b506040805180820190915261ffff80851682528381166020830190815260018054808201825560009190915283517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf68201805493518516620100000263ffff0000199290951661ffff199094169390931716929092179055613255868261398e565b6040805161ffff808816825286166020820152600160a060020a03881681830152905182917fe8a3345b7ca502cc541c08a705987fa4c03d9f59c0427175387a64cbd8f46594919081900360600190a295945050505050565b6132b883826135ed565b6132c2838261365c565b6132cc82826138bd565b8082600160a060020a031684600160a060020a0316600080516020613ed483398151915260405160405180910390a4505050565b60008061331585600160a060020a03166139d7565b15156133245760019150613464565b6040517f150b7a020000000000000000000000000000000000000000000000000000000081523360048201818152600160a060020a03898116602485015260448401889052608060648501908152875160848601528751918a169463150b7a0294938c938b938b93909160a490910190602085019080838360005b838110156133b757818101518382015260200161339f565b50505050905090810190601f1680156133e45780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b15801561340657600080fd5b505af115801561341a573d6000803e3d6000fd5b505050506040513d602081101561343057600080fd5b5051600160e060020a031981167f150b7a020000000000000000000000000000000000000000000000000000000014925090505b50949350505050565b606060008082818515156134b65760408051808201909152600181527f300000000000000000000000000000000000000000000000000000000000000060208201529450613557565b8593505b83156134d157600190920191600a840493506134ba565b826040519080825280601f01601f1916602001820160405280156134ff578160200160208202803883390190505b5091505060001982015b851561355357815160001982019160f860020a6030600a8a06010291849190811061353057fe5b906020010190600160f860020a031916908160001a905350600a86049550613509565b8194505b50505050919050565b6040805160208181018352600080835283518083018552818152845192830190945281526060926135959286928692906139df565b9392505050565b6000805b6014548110156135e55760148054829081106135b857fe5b600091825260209091200154600160a060020a03163314156135dd576001915061184c565b6001016135a0565b600091505090565b81600160a060020a031661360082611c0c565b600160a060020a03161461361357600080fd5b6000818152600e6020526040902054600160a060020a031615611325576000908152600e60205260409020805473ffffffffffffffffffffffffffffffffffffffff1916905550565b600080600061366b8585613c40565b601280548590811061367957fe5b60009182526020808320600883040154600160a060020a0389168452601190915260409092205460079091166004026101000a90910463ffffffff90811694506136c79190600190613c9216565b600160a060020a0386166000908152601160205260409020805491935090839081106136ef57fe5b90600052602060002090600691828204019190066005029054906101000a900464ffffffffff169050806011600087600160a060020a0316600160a060020a031681526020019081526020016000208463ffffffff1681548110151561375157fe5b90600052602060002090600691828204019190066005026101000a81548164ffffffffff021916908364ffffffffff16021790555060006011600087600160a060020a0316600160a060020a03168152602001908152602001600020838154811015156137ba57fe5b90600052602060002090600691828204019190066005026101000a81548164ffffffffff021916908364ffffffffff1602179055506011600086600160a060020a0316600160a060020a031681526020019081526020016000208054809190600190036138279190613e89565b50600060128581548110151561383957fe5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff1602179055508260128264ffffffffff1681548110151561388357fe5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff1602179055505050505050565b60006138c98383613ca4565b50600160a060020a03821660009081526011602052604090205463ffffffff811681146138f557600080fd5b600160a060020a038316600090815260116020908152604082208054600181018255908352912060068083049091018054919092066005026101000a64ffffffffff8181021990921691851602179055601280548291908490811061395657fe5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff160217905550505050565b600160a060020a03821615156139a357600080fd5b6139ad8282613d01565b6040518190600160a060020a03841690600090600080516020613ed4833981519152908290a45050565b6000903b1190565b6060806060806060806060806000808e98508d97508c96508b95508a94508451865188518a518c51010101016040519080825280601f01601f191660200182016040528015613a38578160200160208202803883390190505b50935083925060009150600090505b8851811015613aa5578881815181101515613a5e57fe5b90602001015160f860020a900460f860020a028383806001019450815181101515613a8557fe5b906020010190600160f860020a031916908160001a905350600101613a47565b5060005b8751811015613b07578781815181101515613ac057fe5b90602001015160f860020a900460f860020a028383806001019450815181101515613ae757fe5b906020010190600160f860020a031916908160001a905350600101613aa9565b5060005b8651811015613b69578681815181101515613b2257fe5b90602001015160f860020a900460f860020a028383806001019450815181101515613b4957fe5b906020010190600160f860020a031916908160001a905350600101613b0b565b5060005b8551811015613bcb578581815181101515613b8457fe5b90602001015160f860020a900460f860020a028383806001019450815181101515613bab57fe5b906020010190600160f860020a031916908160001a905350600101613b6d565b5060005b8451811015613c2d578481815181101515613be657fe5b90602001015160f860020a900460f860020a028383806001019450815181101515613c0d57fe5b906020010190600160f860020a031916908160001a905350600101613bcf565b50909d9c50505050505050505050505050565b81600160a060020a0316613c5382611c0c565b600160a060020a031614613c6657600080fd5b6000908152600d60205260409020805473ffffffffffffffffffffffffffffffffffffffff1916905550565b600082821115613c9e57fe5b50900390565b6000818152600d6020526040902054600160a060020a031615613cc657600080fd5b6000908152600d60205260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000613d0d8383613ca4565b50600160a060020a03821660009081526011602052604090205463ffffffff81168114613d3957600080fd5b600160a060020a039290921660009081526011602090815260408220805460018082018355918452918320600680840490910180549190930660050261010090810a64ffffffffff818102199093169690921691909102949094179091556012805491820181559091527fbb8a6a4669ba250d26cd7a459eca9d215f8307e33aebe50379bc5a3617ec344460088204018054600790921660040290920a63ffffffff818102199092169190931692909202919091179055565b6040805161012081018252600080825260208201819052918101829052606081018290529060808201908152600060208201819052604082018190526060820181905260809091015290565b604080518082019091526000808252602082015290565b81548183558181111561146457600f016010900481600f016010900483600052602060002091820191016114649190613eb9565b81548183558181111561146457600501600690048160050160069004836000526020600020918201910161146491905b6112cb91905b8082111561184c5760008155600101613ebf5600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a7230582010fa10dfd0372688e0f7a010b360af415423fe495c99c201f4e1bfab3b1c44210029000000000000000000000000512fbd15bde6570ff09e4438af27ede604024515" - code_ContractScenario008_deployErc721CryptoKitties = "606060409081526002805460a060020a60ff02191690556101c090519081016040908152603c82526078602083015261012c9082015261025860608201526107086080820152610e1060a0820152611c2060c082015261384060e082015261708061010082015261e100610120820152620151806101408201526202a3006101608201526205460061018082015262093a806101a0820152620000a790600390600e620004e4565b50600f60055566071afd498d0000600e553415620000c457600080fd5b6002805460008054600160a060020a033316600160a060020a03199182168117835560a060020a60ff02199093167401000000000000000000000000000000000000000017169091179091556200012f90808060001981640100000000620028f06200013682021704565b5062000649565b6000806200014362000587565b600063ffffffff891689146200015857600080fd5b63ffffffff881688146200016b57600080fd5b61ffff871687146200017c57600080fd5b600287049250600d8361ffff1611156200019557600d92505b61010060405190810160409081528782526001604060020a0342166020830152600090820181905263ffffffff808c1660608401528a16608083015260a082015261ffff80851660c0830152881660e082015260068054919350600191808301620002018382620005cb565b6000928352602090922085916002020181518155602082015160018201805467ffffffffffffffff19166001604060020a039290921691909117905560408201518160010160086101000a8154816001604060020a0302191690836001604060020a0316021790555060608201518160010160106101000a81548163ffffffff021916908363ffffffff16021790555060808201518160010160146101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160010160186101000a81548163ffffffff021916908363ffffffff16021790555060c082015181600101601c6101000a81548161ffff021916908361ffff16021790555060e08201516001909101805461ffff929092167e0100000000000000000000000000000000000000000000000000000000000002600160f060020a039092169190911790555003905063ffffffff811681146200035e57600080fd5b7f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad58582846060015163ffffffff16856080015163ffffffff168651604051600160a060020a03909516855260208501939093526040808501929092526060840152608083019190915260a0909101905180910390a1620003ef60008683640100000000620025e0620003fb82021704565b98975050505050505050565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a03191690911790558316156200048f57600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b600283019183908215620005755791602002820160005b838211156200054157835183826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302620004fb565b8015620005735782816101000a81549063ffffffff021916905560040160208160030104928301926001030262000541565b505b5062000583929150620005ff565b5090565b6101006040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e082015290565b815481835581811511620005fa57600202816002028360005260206000209182019101620005fa919062000626565b505050565b6200062391905b808211156200058357805463ffffffff1916815560010162000606565b90565b6200062391905b808211156200058357600080825560018201556002016200062d565b61309380620006596000396000f3006060604052600436106102a55763ffffffff60e060020a60003504166301ffc9a781146102dd5780630519ce79146103295780630560ff441461035857806305e45546146103f157806306fdde0314610416578063095ea7b3146104295780630a0f81681461044b5780630e583df01461045e57806314001f4c1461047157806318160ddd14610490578063183a7947146104a35780631940a936146104b657806319c2f201146104cc57806321717ebf146104df57806323b872dd146104f257806324e7a38a1461051a57806327d7874c146105395780632ba73c15146105585780633d7d3f5a146105775780633f4ba83a1461059657806346116e6f146105a957806346d22c70146105bf578063481af3d3146105d85780634ad8c938146105ee5780634b85fd551461060d5780634dfff04f146106235780634e0a33791461064557806356129134146106645780635663896e146106865780635c975abb1461069c5780635fd8c710146106af5780636352211e146106c2578063680eba27146106d85780636af04a57146106eb5780636fbde40d146106fe57806370a082311461071d578063715879881461073c5780637a7d49371461075b5780638456cb591461076e5780638462151c1461078157806388c2a0bf146107f357806391876e571461080957806395d89b411461081c5780639d6fac6f1461082f578063a45f4bfc1461085e578063a9059cbb14610874578063b047fb5014610896578063b0c35c05146108a9578063bc4006f5146108bc578063c3bea9af146108cf578063d3e6f49f146108e5578063defb9584146108fb578063e17b25af1461090e578063e6cbe3511461092d578063e98b7f4d14610940578063ed60ade6146109ae578063f1ca9410146109bc578063f2b47d52146109cf578063f7d8c883146109e2575b600b5433600160a060020a03908116911614806102d05750600c5433600160a060020a039081169116145b15156102db57600080fd5b005b34156102e857600080fd5b6103157fffffffff00000000000000000000000000000000000000000000000000000000600435166109f0565b604051901515815260200160405180910390f35b341561033457600080fd5b61033c610c77565b604051600160a060020a03909116815260200160405180910390f35b341561036357600080fd5b61037a600480359060248035908101910135610c86565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156103b657808201518382015260200161039e565b50505050905090810190601f1680156103e35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103fc57600080fd5b610404610d63565b60405190815260200160405180910390f35b341561042157600080fd5b61037a610d69565b341561043457600080fd5b6102db600160a060020a0360043516602435610da0565b341561045657600080fd5b61033c610e2a565b341561046957600080fd5b610404610e39565b341561047c57600080fd5b6102db600160a060020a0360043516610e44565b341561049b57600080fd5b610404610ef1565b34156104ae57600080fd5b610404610efc565b34156104c157600080fd5b610315600435610f02565b34156104d757600080fd5b610404610f47565b34156104ea57600080fd5b61033c610f4e565b34156104fd57600080fd5b6102db600160a060020a0360043581169060243516604435610f5d565b341561052557600080fd5b6102db600160a060020a0360043516610fe4565b341561054457600080fd5b6102db600160a060020a0360043516611091565b341561056357600080fd5b6102db600160a060020a03600435166110e3565b341561058257600080fd5b6102db600435602435604435606435611135565b34156105a157600080fd5b6102db611214565b34156105b457600080fd5b61033c6004356112ac565b34156105ca57600080fd5b6103156004356024356112c7565b34156105e357600080fd5b61033c600435611347565b34156105f957600080fd5b6102db600435602435604435606435611362565b341561061857600080fd5b6102db600435611428565b341561062e57600080fd5b6102db600160a060020a0360043516602435611448565b341561065057600080fd5b6102db600160a060020a03600435166114a2565b341561066f57600080fd5b6102db600435600160a060020a03602435166114f4565b341561069157600080fd5b6102db600435611560565b34156106a757600080fd5b6103156115c8565b34156106ba57600080fd5b6102db6115d8565b34156106cd57600080fd5b61033c600435611649565b34156106e357600080fd5b61040461166d565b34156106f657600080fd5b61033c611673565b341561070957600080fd5b6102db600160a060020a0360043516611682565b341561072857600080fd5b610404600160a060020a036004351661172f565b341561074757600080fd5b6102db600160a060020a036004351661174a565b341561076657600080fd5b6104046117d8565b341561077957600080fd5b6102db6117de565b341561078c57600080fd5b6107a0600160a060020a036004351661186a565b60405160208082528190810183818151815260200191508051906020019060200280838360005b838110156107df5780820151838201526020016107c7565b505050509050019250505060405180910390f35b34156107fe57600080fd5b61040460043561194b565b341561081457600080fd5b6102db611c1b565b341561082757600080fd5b61037a611d0e565b341561083a57600080fd5b610845600435611d45565b60405163ffffffff909116815260200160405180910390f35b341561086957600080fd5b61033c600435611d72565b341561087f57600080fd5b6102db600160a060020a0360043516602435611d8d565b34156108a157600080fd5b61033c611e30565b34156108b457600080fd5b610404611e3f565b34156108c757600080fd5b61033c611e45565b34156108da57600080fd5b6102db600435611e54565b34156108f057600080fd5b610315600435611f47565b341561090657600080fd5b610404612010565b341561091957600080fd5b6102db600160a060020a0360043516612016565b341561093857600080fd5b61033c612053565b341561094b57600080fd5b610956600435612062565b6040519915158a5297151560208a01526040808a01979097526060890195909552608088019390935260a087019190915260c086015260e0850152610100840152610120830191909152610140909101905180910390f35b6102db6004356024356121c3565b34156109c757600080fd5b610404612316565b34156109da57600080fd5b61033c61231c565b6102db60043560243561232b565b60006040517f737570706f727473496e7465726661636528627974657334290000000000000081526019016040518091039020600160e060020a03191682600160e060020a0319161480610c6f57506040517f746f6b656e4d657461646174612875696e743235362c737472696e67290000008152601d0160405180910390206040517f746f6b656e734f664f776e657228616464726573732900000000000000000000815260160160405180910390206040517f7472616e7366657246726f6d28616464726573732c616464726573732c75696e81527f7432353629000000000000000000000000000000000000000000000000000000602082015260250160405180910390206040517f7472616e7366657228616464726573732c75696e743235362900000000000000815260190160405180910390206040517f617070726f766528616464726573732c75696e74323536290000000000000000815260180160405180910390206040517f6f776e65724f662875696e743235362900000000000000000000000000000000815260100160405180910390206040517f62616c616e63654f662861646472657373290000000000000000000000000000815260120160405180910390206040517f746f74616c537570706c792829000000000000000000000000000000000000008152600d0160405180910390206040517f73796d626f6c2829000000000000000000000000000000000000000000000000815260080160405180910390206040517f6e616d652829000000000000000000000000000000000000000000000000000081526006016040518091039020181818181818181818600160e060020a03191682600160e060020a031916145b90505b919050565b600154600160a060020a031681565b610c8e612fa0565b610c96612fb2565b600d54600090600160a060020a03161515610cb057600080fd5b600d54600160a060020a031663cb4799f2878787600060405160a0015260405160e060020a63ffffffff861602815260048101848152604060248301908152604483018490529091606401848480828437820191505094505050505060a060405180830381600087803b1515610d2557600080fd5b6102c65a03f11515610d3657600080fd5b50505060405180608001805160209091016040529092509050610d59828261251d565b9695505050505050565b60115481565b60408051908101604052600d81527f43727970746f4b69747469657300000000000000000000000000000000000000602082015281565b60025460a060020a900460ff1615610db757600080fd5b610dc13382612572565b1515610dcc57600080fd5b610dd68183612592565b7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925338383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a15050565b600054600160a060020a031681565b662386f26fc1000081565b6000805433600160a060020a03908116911614610e6057600080fd5b5080600160a060020a0381166376190f8f6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610ea857600080fd5b6102c65a03f11515610eb957600080fd5b505050604051805190501515610ece57600080fd5b600c8054600160a060020a031916600160a060020a039290921691909117905550565b600654600019015b90565b600f5481565b6000808211610f1057600080fd5b6006805483908110610f1e57fe5b600091825260209091206002909102016001015460c060020a900463ffffffff16151592915050565b6201518081565b600c54600160a060020a031681565b60025460a060020a900460ff1615610f7457600080fd5b600160a060020a0382161515610f8957600080fd5b30600160a060020a031682600160a060020a031614151515610faa57600080fd5b610fb433826125c0565b1515610fbf57600080fd5b610fc98382612572565b1515610fd457600080fd5b610fdf8383836125e0565b505050565b6000805433600160a060020a0390811691161461100057600080fd5b5080600160a060020a0381166354c15b826000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561104857600080fd5b6102c65a03f1151561105957600080fd5b50505060405180519050151561106e57600080fd5b60108054600160a060020a031916600160a060020a039290921691909117905550565b60005433600160a060020a039081169116146110ac57600080fd5b600160a060020a03811615156110c157600080fd5b60008054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a039081169116146110fe57600080fd5b600160a060020a038116151561111357600080fd5b60028054600160a060020a031916600160a060020a0392909216919091179055565b60025460a060020a900460ff161561114c57600080fd5b6111563385612572565b151561116157600080fd5b61116a84610f02565b1561117457600080fd5b600b5461118b908590600160a060020a0316612592565b600b54600160a060020a03166327ebe40a858585853360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156111fa57600080fd5b6102c65a03f1151561120b57600080fd5b50505050505050565b60005433600160a060020a0390811691161461122f57600080fd5b60025460a060020a900460ff16151561124757600080fd5b600b54600160a060020a0316151561125e57600080fd5b600c54600160a060020a0316151561127557600080fd5b601054600160a060020a0316151561128c57600080fd5b601354600160a060020a0316156112a257600080fd5b6112aa6126c8565b565b600a60205260009081526040902054600160a060020a031681565b600080808085116112d757600080fd5b600084116112e457600080fd5b60068054869081106112f257fe5b9060005260206000209060020201915060068481548110151561131157fe5b9060005260206000209060020201905061132d8286838761271b565b801561133e575061133e848661289b565b95945050505050565b600960205260009081526040902054600160a060020a031681565b60025460a060020a900460ff161561137957600080fd5b6113833385612572565b151561138e57600080fd5b61139784611f47565b15156113a257600080fd5b600c546113b9908590600160a060020a0316612592565b600c54600160a060020a03166327ebe40a858585853360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156111fa57600080fd5b60025433600160a060020a0390811691161461144357600080fd5b600e55565b60025460a060020a900460ff161561145f57600080fd5b6114693382612572565b151561147457600080fd5b6000908152600a602052604090208054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a039081169116146114bd57600080fd5b600160a060020a03811615156114d257600080fd5b60018054600160a060020a031916600160a060020a0392909216919091179055565b60025460009033600160a060020a0390811691161461151257600080fd5b5080600160a060020a03811615156115325750600254600160a060020a03165b601154611388901061154357600080fd5b60118054600101905561155a6000808086856128f0565b50505050565b60025433600160a060020a039081169116148061158b575060005433600160a060020a039081169116145b806115a4575060015433600160a060020a039081169116145b15156115af57600080fd5b60035463ffffffff1681106115c357600080fd5b600555565b60025460a060020a900460ff1681565b600154600090819033600160a060020a039081169116146115f857600080fd5b30600160a060020a0316319150600e54600f546001010290508082111561164557600154600160a060020a031681830380156108fc0290604051600060405180830381858888f150505050505b5050565b600081815260076020526040902054600160a060020a0316801515610c7257600080fd5b61afc881565b601354600160a060020a031681565b6000805433600160a060020a0390811691161461169e57600080fd5b5080600160a060020a0381166385b861886000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156116e657600080fd5b6102c65a03f115156116f757600080fd5b50505060405180519050151561170c57600080fd5b600b8054600160a060020a031916600160a060020a039290921691909117905550565b600160a060020a031660009081526008602052604090205490565b60005433600160a060020a0390811691161461176557600080fd5b60025460a060020a900460ff16151561177d57600080fd5b60138054600160a060020a031916600160a060020a0383161790557f450db8da6efbe9c22f2347f7c2021231df1fc58d3ae9a2fa75d39fa44619930581604051600160a060020a03909116815260200160405180910390a150565b60055481565b60025433600160a060020a0390811691161480611809575060005433600160a060020a039081169116145b80611822575060015433600160a060020a039081169116145b151561182d57600080fd5b60025460a060020a900460ff161561184457600080fd5b6002805474ff0000000000000000000000000000000000000000191660a060020a179055565b611872612fa0565b600061187c612fa0565b600080600061188a8761172f565b94508415156118ba5760006040518059106118a25750595b90808252806020026020018201604052509550611941565b846040518059106118c85750595b908082528060200260200182016040525093506118e3610ef1565b925060009150600190505b82811161193d57600081815260076020526040902054600160a060020a0388811691161415611935578084838151811061192457fe5b602090810290910101526001909101905b6001016118ee565b8395505b5050505050919050565b600080600080600080600080600260149054906101000a900460ff1615151561197357600080fd5b600680548a90811061198157fe5b60009182526020909120600290910201600181015490975067ffffffffffffffff1615156119ae57600080fd5b611a438761010060405190810160409081528254825260019092015467ffffffffffffffff8082166020840152680100000000000000008204169282019290925263ffffffff608060020a83048116606083015260a060020a83048116608083015260c060020a83041660a082015261ffff60e060020a8304811660c083015260f060020a90920490911660e0820152612b9c565b1515611a4e57600080fd5b60018701546006805460c060020a90920463ffffffff1697509087908110611a7257fe5b600091825260209091206001808a015460029093029091019081015490965061ffff60f060020a92839004811696509190041684901115611ac057600185015460f060020a900461ffff1693505b6010548754865460018a0154600160a060020a0390931692630d9f5aed92919068010000000000000000900467ffffffffffffffff166000190160006040516020015260405160e060020a63ffffffff86160281526004810193909352602483019190915267ffffffffffffffff166044820152606401602060405180830381600087803b1515611b5057600080fd5b6102c65a03f11515611b6157600080fd5b505050604051805160008b81526007602052604090205460018a810154929650600160a060020a039091169450611bb092508b9160c060020a900463ffffffff1690870161ffff1686866128f0565b6001880180547bffffffff00000000000000000000000000000000000000000000000019169055600f8054600019019055600e54909150600160a060020a0333169080156108fc0290604051600060405180830381858888f150939c9b505050505050505050505050565b60025433600160a060020a0390811691161480611c46575060005433600160a060020a039081169116145b80611c5f575060015433600160a060020a039081169116145b1515611c6a57600080fd5b600b54600160a060020a0316635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b1515611ca957600080fd5b6102c65a03f11515611cba57600080fd5b5050600c54600160a060020a03169050635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b1515611cfd57600080fd5b6102c65a03f11515610fdf57600080fd5b60408051908101604052600281527f434b000000000000000000000000000000000000000000000000000000000000602082015281565b600381600e8110611d5257fe5b60089182820401919006600402915054906101000a900463ffffffff1681565b600760205260009081526040902054600160a060020a031681565b60025460a060020a900460ff1615611da457600080fd5b600160a060020a0382161515611db957600080fd5b30600160a060020a031682600160a060020a031614151515611dda57600080fd5b600b54600160a060020a0383811691161415611df557600080fd5b600c54600160a060020a0383811691161415611e1057600080fd5b611e1a3382612572565b1515611e2557600080fd5b6116453383836125e0565b600254600160a060020a031681565b600e5481565b600d54600160a060020a031681565b60025460009033600160a060020a03908116911614611e7257600080fd5b60125461afc89010611e8357600080fd5b611e92600080600085306128f0565b600b54909150611eac908290600160a060020a0316612592565b600b54600160a060020a03166327ebe40a82611ec6612bd4565b6000620151803060405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b1515611f2657600080fd5b6102c65a03f11515611f3757600080fd5b5050601280546001019055505050565b600080808311611f5657600080fd5b6006805484908110611f6457fe5b906000526020600020906002020190506120098161010060405190810160409081528254825260019092015467ffffffffffffffff8082166020840152680100000000000000008204169282019290925263ffffffff608060020a83048116606083015260a060020a83048116608083015260c060020a83041660a082015261ffff60e060020a8304811660c083015260f060020a90920490911660e0820152612c82565b9392505050565b61138881565b60005433600160a060020a0390811691161461203157600080fd5b600d8054600160a060020a031916600160a060020a0392909216919091179055565b600b54600160a060020a031681565b600080600080600080600080600080600060068c81548110151561208257fe5b906000526020600020906002020190508060010160189054906101000a900463ffffffff1663ffffffff16600014159a50438160010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff161115995080600101601c9054906101000a900461ffff1661ffff1698508060010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff1697508060010160189054906101000a900463ffffffff1663ffffffff1696508060010160009054906101000a900467ffffffffffffffff1667ffffffffffffffff1695508060010160109054906101000a900463ffffffff1663ffffffff1694508060010160149054906101000a900463ffffffff1663ffffffff16935080600101601e9054906101000a900461ffff1661ffff16925080600001549150509193959799509193959799565b60025460009060a060020a900460ff16156121dd57600080fd5b6121e73383612572565b15156121f257600080fd5b6121fb82611f47565b151561220657600080fd5b6122108284612cb9565b151561221b57600080fd5b600c54600160a060020a031663c55d0f568460006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561226c57600080fd5b6102c65a03f1151561227d57600080fd5b5050506040518051600e549092508201341015905061229b57600080fd5b600c54600e54600160a060020a039091169063454a2ab39034038560405160e060020a63ffffffff851602815260048101919091526024016000604051808303818588803b15156122eb57600080fd5b6125ee5a03f115156122fc57600080fd5b50505050610fdf8263ffffffff168463ffffffff16612d08565b60125481565b601054600160a060020a031681565b600254600090819060a060020a900460ff161561234757600080fd5b600e5434101561235657600080fd5b6123603385612572565b151561236b57600080fd5b612375838561289b565b151561238057600080fd5b600680548590811061238e57fe5b906000526020600020906002020191506124338261010060405190810160409081528254825260019092015467ffffffffffffffff8082166020840152680100000000000000008204169282019290925263ffffffff608060020a83048116606083015260a060020a83048116608083015260c060020a83041660a082015261ffff60e060020a8304811660c083015260f060020a90920490911660e0820152612c82565b151561243e57600080fd5b600680548490811061244c57fe5b906000526020600020906002020190506124f18161010060405190810160409081528254825260019092015467ffffffffffffffff8082166020840152680100000000000000008204169282019290925263ffffffff608060020a83048116606083015260a060020a83048116608083015260c060020a83041660a082015261ffff60e060020a8304811660c083015260f060020a90920490911660e0820152612c82565b15156124fc57600080fd5b6125088285838661271b565b151561251357600080fd5b61155a8484612d08565b612525612fa0565b61252d612fa0565b6000808460405180591061253e5750595b818152601f19601f8301168101602001604052905092505060208201905084612568828287612e72565b5090949350505050565b600090815260076020526040902054600160a060020a0391821691161490565b6000918252600960205260409091208054600160a060020a031916600160a060020a03909216919091179055565b600090815260096020526040902054600160a060020a0391821691161490565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a031916909117905583161561267357600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b60005433600160a060020a039081169116146126e357600080fd5b60025460a060020a900460ff1615156126fb57600080fd5b6002805474ff000000000000000000000000000000000000000019169055565b60008184141561272d57506000612893565b6001850154608060020a900463ffffffff1682148061275c5750600185015460a060020a900463ffffffff1682145b1561276957506000612893565b6001830154608060020a900463ffffffff168414806127985750600183015460a060020a900463ffffffff1684145b156127a557506000612893565b6001830154608060020a900463ffffffff1615806127d257506001850154608060020a900463ffffffff16155b156127df57506001612893565b60018581015490840154608060020a9182900463ffffffff9081169290910416148061282a575060018086015490840154608060020a900463ffffffff90811660a060020a90920416145b1561283757506000612893565b6001808601549084015460a060020a900463ffffffff908116608060020a90920416148061288257506001858101549084015460a060020a9182900463ffffffff9081169290910416145b1561288f57506000612893565b5060015b949350505050565b6000818152600760205260408082205484835290822054600160a060020a0391821691168082148061133e57506000858152600a6020526040902054600160a060020a03908116908316149250505092915050565b6000806128fb612fdb565b600063ffffffff8916891461290f57600080fd5b63ffffffff8816881461292157600080fd5b61ffff8716871461293157600080fd5b600287049250600d8361ffff16111561294957600d92505b610100604051908101604090815287825267ffffffffffffffff42166020830152600090820181905263ffffffff808c1660608401528a16608083015260a082015261ffff80851660c0830152881660e0820152600680549193506001918083016129b4838261301f565b6000928352602090922085916002020181518155602082015160018201805467ffffffffffffffff191667ffffffffffffffff9290921691909117905560408201518160010160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060608201518160010160106101000a81548163ffffffff021916908363ffffffff16021790555060808201518160010160146101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160010160186101000a81548163ffffffff021916908363ffffffff16021790555060c082015181600101601c6101000a81548161ffff021916908361ffff16021790555060e08201516001909101805461ffff9290921660f060020a027dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092169190911790555003905063ffffffff81168114612b0f57600080fd5b7f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad58582846060015163ffffffff16856080015163ffffffff168651604051600160a060020a03909516855260208501939093526040808501929092526060840152608083019190915260a0909101905180910390a1612b90600086836125e0565b98975050505050505050565b60008160a0015163ffffffff1615801590610c6f57504367ffffffffffffffff16826040015167ffffffffffffffff16111592915050565b600b5460009081908190600160a060020a031663eac9d94c82604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515612c2257600080fd5b6102c65a03f11515612c3357600080fd5b50505060405180519250506fffffffffffffffffffffffffffffffff82168214612c5c57600080fd5b50600281048101662386f26fc10000811015612c7c5750662386f26fc100005b92915050565b60008160a0015163ffffffff16158015610c6f57504367ffffffffffffffff16826040015167ffffffffffffffff16111592915050565b6000806000600685815481101515612ccd57fe5b90600052602060002090600202019150600684815481101515612cec57fe5b9060005260206000209060020201905061133e8286838761271b565b600080600683815481101515612d1a57fe5b90600052602060002090600202019150600684815481101515612d3957fe5b600091825260209091206002909102016001810180547bffffffff000000000000000000000000000000000000000000000000191660c060020a63ffffffff8716021790559050612d8982612eb7565b612d9281612eb7565b6000848152600a602090815260408083208054600160a060020a031990811690915586845281842080549091169055600f8054600190810190915587845260079092529182902054908301547f241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b8092600160a060020a0390921691879187916801000000000000000090910467ffffffffffffffff1690518085600160a060020a0316600160a060020a031681526020018481526020018381526020018267ffffffffffffffff16815260200194505050505060405180910390a150505050565b60005b60208210612e985782518452602084019350602083019250602082039150612e75565b6001826020036101000a03905080198351168185511617909352505050565b600554600182015443919060039060e060020a900461ffff16600e8110612eda57fe5b600891828204019190066004029054906101000a900463ffffffff1663ffffffff16811515612f0557fe5b6001840180546fffffffffffffffff0000000000000000191668010000000000000000939092049390930167ffffffffffffffff16919091021790819055600d60e060020a90910461ffff161015612f9d576001818101805461ffff60e060020a8083048216909401169092027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092169190911790555b50565b60206040519081016040526000815290565b60806040519081016040526004815b60008152600019919091019060200181612fc15790505090565b6101006040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e082015290565b815481835581811511610fdf57600083815260209020610fdf91610ef99160029182028101918502015b808211156130635760008082556001820155600201613049565b50905600a165627a7a72305820a6465fc1ce7ab1a92906ff7206b23d80a21bbd50b85b4bde6a91f8e6b2e3edde0029" - code_ContractScenario009_deployContainLibraryContract = "608060405234801561001057600080fd5b50610139806100206000396000f3006080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663f207564e8114610045575b600080fd5b34801561005157600080fd5b5061005d60043561005f565b005b73610199610030600b82828239805160001a6073146000811461002057610022565bfe5b5030600052607381538281f300730000000000000000000000000000000000000000301460806040526004361061006d5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663483b8a1481146100725780636ce8e081146100a1578063831cb739146100bc575b600080fd5b81801561007e57600080fd5b5061008d6004356024356100d7565b604080519115158252519081900360200190f35b8180156100ad57600080fd5b5061008d600435602435610117565b8180156100c857600080fd5b5061008d60043560243561012d565b60008181526020839052604081205460ff1615156100f757506000610111565b506000818152602083905260409020805460ff1916905560015b92915050565b6000908152602091909152604090205460ff1690565b60008181526020839052604081205460ff161561014c57506000610111565b50600090815260209190915260409020805460ff19166001908117909155905600a165627a7a723058200bc4068752b78840d32288f8eeffe2618c356d76fe09451d92f808cf28d4d22e0029" - code_ContractScenario010_deployContainLibraryContract = "608060405234801561001057600080fd5b50610731806100206000396000f3006080604052600436106100a35763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100a8578063095ea7b31461013257806318160ddd146101585780632f745c591461017f5780636352211e146101a35780636914db60146101d757806370a08231146101ef57806395d89b4114610210578063a9059cbb14610225578063b2e6ceeb14610249575b600080fd5b3480156100b457600080fd5b506100bd610261565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100f75781810151838201526020016100df565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013e57600080fd5b50610156600160a060020a0360043516602435610298565b005b34801561016457600080fd5b5061016d61032d565b60408051918252519081900360200190f35b34801561018b57600080fd5b5061016d600160a060020a0360043516602435610336565b3480156101af57600080fd5b506101bb60043561035e565b60408051600160a060020a039092168252519081900360200190f35b3480156101e357600080fd5b506100bd600435610397565b3480156101fb57600080fd5b5061016d600160a060020a0360043516610438565b34801561021c57600080fd5b506100bd610453565b34801561023157600080fd5b50610156600160a060020a036004351660243561048a565b34801561025557600080fd5b5061015660043561059d565b60408051808201909152601181527f54726f6e2045524337323120546f6b656e000000000000000000000000000000602082015290565b6102a18161035e565b600160a060020a031633146102b557600080fd5b33600160a060020a03831614156102cb57600080fd5b336000818152600360209081526040808320600160a060020a03871680855290835292819020859055805185815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35050565b64e8d4a5100090565b600160a060020a03919091166000908152600460209081526040808320938352929052205490565b60008181526002602052604081205460ff16151561037b57600080fd5b50600090815260016020526040902054600160a060020a031690565b60008181526005602090815260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084526060939283018282801561042c5780601f106104015761010080835404028352916020019161042c565b820191906000526020600020905b81548152906001019060200180831161040f57829003601f168201915b50505050509050919050565b600160a060020a031660009081526020819052604090205490565b60408051808201909152600581527f5437323154000000000000000000000000000000000000000000000000000000602082015290565b6000818152600260205260408120543391849160ff1615156104ab57600080fd5b6104b48461035e565b600160a060020a038481169116146104cb57600080fd5b600160a060020a0383811690831614156104e457600080fd5b600160a060020a03821615156104f957600080fd5b508161050581856106a7565b600160a060020a0381811660008181526020818152604080832080546000190190558883526001808352818420805473ffffffffffffffffffffffffffffffffffffffff19169689169687179055858452838352928190208054909301909255815188815291517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050505050565b600081815260026020526040812054819060ff1615156105bc57600080fd5b6105c58361035e565b9150339050600160a060020a0382168114156105e057600080fd5b600160a060020a03808316600090815260036020908152604080832093851683529290522054831461061157600080fd5b600160a060020a0382811660008181526020818152604080832080546000190190558783526001808352818420805473ffffffffffffffffffffffffffffffffffffffff19169688169687179055858452838352928190208054909301909255815187815291517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a3505050565b60005b600160a060020a0383166000908152600460209081526040808320848452909152902054821461070057600160a060020a03831660009081526004602090815260408083208484529091528120556001016106aa565b5050505600a165627a7a72305820d3ca2ca957b72f4c5028c633a6ad4bafe13572bf949793fabe72e34eb640d2c50029" - code_ContractScenario012_deployTransactionCoin = "60806040526000805561029f806100176000396000f3006080604052600436106100985763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166312065fe0811461009d5780632e52d606146100b7578063483f5a7f146100cc5780634f8632ba146100e25780635896476c146101135780638b47145f14610128578063b6b55f2514610144578063f46771d91461014f578063ff18253b14610163575b600080fd5b6100a561019b565b60408051918252519081900360200190f35b3480156100c357600080fd5b506100a56101a0565b6100e0600160a060020a03600435166101a6565b005b3480156100ee57600080fd5b506100f76101df565b60408051600160a060020a039092168252519081900360200190f35b34801561011f57600080fd5b506100e06101ee565b6101306101f9565b604080519115158252519081900360200190f35b610130600435610217565b6100e0600160a060020a036004351661023a565b34801561016f57600080fd5b5061017861026c565b60408051600160a060020a03909316835260208301919091528051918290030190f35b303190565b60005481565b604051600160a060020a038216903480156108fc02916000818181858888f193505050501580156101db573d6000803e3d6000fd5b5050565b600154600160a060020a031681565b600080546001019055565b6040516000903390829060019082818181858883f194505050505090565b604051600090339083156108fc0290849084818181858888f19695505050505050565b604051600160a060020a0382169060009060059082818181858883f193505050501580156101db573d6000803e3d6000fd5b33803190915600a165627a7a72305820fd081d59bd77b97252e4a657177023ae7352e1fe802dd638ec6b9fa5df59d6110029" - code_ContractScenario013_deployTronTrxAndSunContract = "6080604052348015600f57600080fd5b50600180141515601e57600080fd5b603c80141515602c57600080fd5b610e1080141515603b57600080fd5b6201518080141515604b57600080fd5b62093a8080141515605b57600080fd5b6301e1338080141515606c57600080fd5b620f424080141515607c57600080fd5b60358060896000396000f3006080604052600080fd00a165627a7a723058206a36395ee2292959a89e7956d6826a7107c490331e4505fc319010873c26392b0029" - code_ContractScenario013_triggerTronTrxAndSunContract = "608060405234801561001057600080fd5b5061011a806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316ada547146044575b600080fd5b348015604f57600080fd5b506056606c565b6040518082815260200191505060405180910390f35b6000600180141515607c57600080fd5b603c80141515608a57600080fd5b610e1080141515609957600080fd5b620151808014151560a957600080fd5b62093a808014151560b957600080fd5b6301e133808014151560ca57600080fd5b620f42408014151560da57600080fd5b60018014151560e857600080fd5b429050905600a165627a7a72305820eacfee595582d9244a2fb5f052905bd240f87864fb8f602f85fd31fe3b89cda80029" - code_ContractScenario014_testTripleTrigger = "608060405260d2806100126000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633d96d24c81146043575b600080fd5b606273ffffffffffffffffffffffffffffffffffffffff600435166064565b005b60405173ffffffffffffffffffffffffffffffffffffffff82169060009060059082818181858883f1935050505015801560a2573d6000803e3d6000fd5b50505600a165627a7a72305820e2d0e2bbf60a802771a52693e71a934ef01e5c5f6a584b5a3f24f5088866de4d0029" - code1_ContractScenario014_testTripleTrigger = "6080604052604051602080610263833981016040525160008054600160a060020a03909216600160a060020a031990921691909117905561021e806100456000396000f30060806040526004361061003d5763ffffffff60e060020a600035041663b3b638ab8114610042578063df5dd9c814610065578063ecb0b86214610086575b600080fd5b61006373ffffffffffffffffffffffffffffffffffffffff600435166100c4565b005b61006373ffffffffffffffffffffffffffffffffffffffff6004351661014e565b34801561009257600080fd5b5061009b6101d6565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b60008054604080517f73656e643553756e546f526563656976657228616464726573732900000000008152815190819003601b01812063ffffffff60e060020a91829004908116909102825273ffffffffffffffffffffffffffffffffffffffff8681166004840152925192909316936024808301939192829003018183875af150505050600080fd5b60008054604080517f73656e643553756e546f526563656976657228616464726573732900000000008152815190819003601b01812063ffffffff60e060020a91829004908116909102825273ffffffffffffffffffffffffffffffffffffffff8681166004840152925192909316936024808301939192829003018183875af15050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a7230582065632ad682ad1abe06031e0f1471af18b8caeaddc98c67de6765b9f01ce8aa320029" - code2_ContractScenario014_testTripleTrigger = "60806040526040516020806101df833981016040525160008054600160a060020a03909216600160a060020a031990921691909117905561019a806100456000396000f30060806040526004361061004b5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663025750698114610050578063ecb0b86214610073575b600080fd5b61007173ffffffffffffffffffffffffffffffffffffffff600435166100b1565b005b34801561007f57600080fd5b50610088610152565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b60008054604080517f74726967676572436f6e747261637431286164647265737329000000000000008152815190819003601901812063ffffffff7c010000000000000000000000000000000000000000000000000000000091829004908116909102825273ffffffffffffffffffffffffffffffffffffffff8681166004840152925192909316936024808301939192829003018183875af15050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a723058205a66bc83322abbfb01da52698e6f5a6b2ca2ff7c17793c1ff9db3a6c7e7f6cb10029" - code_TronDice_tronDice = "6080604052620ef420600155600060678190558054600160a060020a03191633179055610699806100316000396000f3006080604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633ccfd60b81146100875780638da5cb5b146100ae578063acfff377146100df578063d0e30db0146100ea578063d263b7eb146100f4578063f2fde38b14610109578063fd2ba8b01461012a575b600080fd5b34801561009357600080fd5b5061009c61013f565b60408051918252519081900360200190f35b3480156100ba57600080fd5b506100c3610221565b60408051600160a060020a039092168252519081900360200190f35b61009c600435610230565b6100f26104b8565b005b34801561010057600080fd5b506100f2610504565b34801561011557600080fd5b506100f2600160a060020a0360043516610529565b34801561013657600080fd5b5061009c6105bd565b3360009081526002602052604081205481811161015b57600080fd5b336000818152600260205260408082208290555183156108fc0291849190818181858888f19350505050151561019057600080fd5b33600360646067548115156101a157fe5b06606481106101ac57fe5b01805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055606780546001019055604080513381526020810183905281517f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364929181900390910190a1919050565b600054600160a060020a031681565b600080600080600080600080600060618a10801561024e575060018a115b151561025957600080fd5b620f42403410158015610270575064174876e80034105b151561027b57600080fd5b336003606460675481151561028c57fe5b066064811061029757fe5b01805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790556067805460010190553497504360001901409650600360648806606481106102e757fe5b015460675460408051600160a060020a039093168a81014182019081014201909301845290519283900360200190922091975095506064900660010193508984101561045c576103388a60016105d0565b9250610346600154846105e4565b91507fdef9eb05d56d654703e420fad711aa89f7a03dc78c4d1c9a9d6d2548dad540653031610377846127106105e4565b60408051928352349190910260208301528051918290030190a161039d826127106105e4565b34023031116103ab57600080fd5b6103c06103b88984610622565b6127106105e4565b336000908152600260205260409020549091506103dd9082610646565b3360008181526002602090815260409182902093909355805191825234928201929092528082018c9052606081018690526080810185905260a0810184905260c0810183905260e081018a905290517fec1c9e10dd62d178aa9c345b3dc5e131cd479d8388331e77b668a16b8f95bdc0918190036101000190a16104aa565b604080513381523460208201528082018c905260608101869052608081018a905290517fc16d5d73a3ed9d2611bf92d1b1bcfa0568410a9b7c94ba5c70135d3a4657a8989181900360a00190a15b509198975050505050505050565b600054600160a060020a031633146104cf57600080fd5b6040805134815290517f4d6ce1e535dbade1c23defba91e23b8f791ce5edc0cc320257a2b364e4e384269181900360200190a1565b600054600160a060020a0316331461051b57600080fd5b600054600160a060020a0316ff5b600054600160a060020a0316331461054057600080fd5b600160a060020a038116151561055557600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b3360009081526002602052604090205490565b60006105de8383111561065e565b50900390565b6000806105f36000841161065e565b82848115156105fe57fe5b04905061061b838581151561060f57fe5b0682850201851461065e565b9392505050565b600082820261061b841580610641575083858381151561063e57fe5b04145b61065e565b600082820161061b8482108015906106415750838210155b80151561066a57600080fd5b505600a165627a7a7230582094b570d711e59ef03fa2e2ac5e6b4b46cd0bec830c732bc75460783f0392ea000029" - code_TvmContract_deployErc721CryptoKitties = "606060409081526002805460a060020a60ff02191690556101c090519081016040908152603c82526078602083015261012c9082015261025860608201526107086080820152610e1060a0820152611c2060c082015261384060e082015261708061010082015261e100610120820152620151806101408201526202a3006101608201526205460061018082015262093a806101a0820152620000a790600390600e620004e4565b50600f60055566071afd498d0000600e553415620000c457600080fd5b6002805460008054600160a060020a033316600160a060020a03199182168117835560a060020a60ff02199093167401000000000000000000000000000000000000000017169091179091556200012f90808060001981640100000000620028f06200013682021704565b5062000649565b6000806200014362000587565b600063ffffffff891689146200015857600080fd5b63ffffffff881688146200016b57600080fd5b61ffff871687146200017c57600080fd5b600287049250600d8361ffff1611156200019557600d92505b61010060405190810160409081528782526001604060020a0342166020830152600090820181905263ffffffff808c1660608401528a16608083015260a082015261ffff80851660c0830152881660e082015260068054919350600191808301620002018382620005cb565b6000928352602090922085916002020181518155602082015160018201805467ffffffffffffffff19166001604060020a039290921691909117905560408201518160010160086101000a8154816001604060020a0302191690836001604060020a0316021790555060608201518160010160106101000a81548163ffffffff021916908363ffffffff16021790555060808201518160010160146101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160010160186101000a81548163ffffffff021916908363ffffffff16021790555060c082015181600101601c6101000a81548161ffff021916908361ffff16021790555060e08201516001909101805461ffff929092167e0100000000000000000000000000000000000000000000000000000000000002600160f060020a039092169190911790555003905063ffffffff811681146200035e57600080fd5b7f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad58582846060015163ffffffff16856080015163ffffffff168651604051600160a060020a03909516855260208501939093526040808501929092526060840152608083019190915260a0909101905180910390a1620003ef60008683640100000000620025e0620003fb82021704565b98975050505050505050565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a03191690911790558316156200048f57600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b600283019183908215620005755791602002820160005b838211156200054157835183826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302620004fb565b8015620005735782816101000a81549063ffffffff021916905560040160208160030104928301926001030262000541565b505b5062000583929150620005ff565b5090565b6101006040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e082015290565b815481835581811511620005fa57600202816002028360005260206000209182019101620005fa919062000626565b505050565b6200062391905b808211156200058357805463ffffffff1916815560010162000606565b90565b6200062391905b808211156200058357600080825560018201556002016200062d565b61309380620006596000396000f3006060604052600436106102a55763ffffffff60e060020a60003504166301ffc9a781146102dd5780630519ce79146103295780630560ff441461035857806305e45546146103f157806306fdde0314610416578063095ea7b3146104295780630a0f81681461044b5780630e583df01461045e57806314001f4c1461047157806318160ddd14610490578063183a7947146104a35780631940a936146104b657806319c2f201146104cc57806321717ebf146104df57806323b872dd146104f257806324e7a38a1461051a57806327d7874c146105395780632ba73c15146105585780633d7d3f5a146105775780633f4ba83a1461059657806346116e6f146105a957806346d22c70146105bf578063481af3d3146105d85780634ad8c938146105ee5780634b85fd551461060d5780634dfff04f146106235780634e0a33791461064557806356129134146106645780635663896e146106865780635c975abb1461069c5780635fd8c710146106af5780636352211e146106c2578063680eba27146106d85780636af04a57146106eb5780636fbde40d146106fe57806370a082311461071d578063715879881461073c5780637a7d49371461075b5780638456cb591461076e5780638462151c1461078157806388c2a0bf146107f357806391876e571461080957806395d89b411461081c5780639d6fac6f1461082f578063a45f4bfc1461085e578063a9059cbb14610874578063b047fb5014610896578063b0c35c05146108a9578063bc4006f5146108bc578063c3bea9af146108cf578063d3e6f49f146108e5578063defb9584146108fb578063e17b25af1461090e578063e6cbe3511461092d578063e98b7f4d14610940578063ed60ade6146109ae578063f1ca9410146109bc578063f2b47d52146109cf578063f7d8c883146109e2575b600b5433600160a060020a03908116911614806102d05750600c5433600160a060020a039081169116145b15156102db57600080fd5b005b34156102e857600080fd5b6103157fffffffff00000000000000000000000000000000000000000000000000000000600435166109f0565b604051901515815260200160405180910390f35b341561033457600080fd5b61033c610c77565b604051600160a060020a03909116815260200160405180910390f35b341561036357600080fd5b61037a600480359060248035908101910135610c86565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156103b657808201518382015260200161039e565b50505050905090810190601f1680156103e35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103fc57600080fd5b610404610d63565b60405190815260200160405180910390f35b341561042157600080fd5b61037a610d69565b341561043457600080fd5b6102db600160a060020a0360043516602435610da0565b341561045657600080fd5b61033c610e2a565b341561046957600080fd5b610404610e39565b341561047c57600080fd5b6102db600160a060020a0360043516610e44565b341561049b57600080fd5b610404610ef1565b34156104ae57600080fd5b610404610efc565b34156104c157600080fd5b610315600435610f02565b34156104d757600080fd5b610404610f47565b34156104ea57600080fd5b61033c610f4e565b34156104fd57600080fd5b6102db600160a060020a0360043581169060243516604435610f5d565b341561052557600080fd5b6102db600160a060020a0360043516610fe4565b341561054457600080fd5b6102db600160a060020a0360043516611091565b341561056357600080fd5b6102db600160a060020a03600435166110e3565b341561058257600080fd5b6102db600435602435604435606435611135565b34156105a157600080fd5b6102db611214565b34156105b457600080fd5b61033c6004356112ac565b34156105ca57600080fd5b6103156004356024356112c7565b34156105e357600080fd5b61033c600435611347565b34156105f957600080fd5b6102db600435602435604435606435611362565b341561061857600080fd5b6102db600435611428565b341561062e57600080fd5b6102db600160a060020a0360043516602435611448565b341561065057600080fd5b6102db600160a060020a03600435166114a2565b341561066f57600080fd5b6102db600435600160a060020a03602435166114f4565b341561069157600080fd5b6102db600435611560565b34156106a757600080fd5b6103156115c8565b34156106ba57600080fd5b6102db6115d8565b34156106cd57600080fd5b61033c600435611649565b34156106e357600080fd5b61040461166d565b34156106f657600080fd5b61033c611673565b341561070957600080fd5b6102db600160a060020a0360043516611682565b341561072857600080fd5b610404600160a060020a036004351661172f565b341561074757600080fd5b6102db600160a060020a036004351661174a565b341561076657600080fd5b6104046117d8565b341561077957600080fd5b6102db6117de565b341561078c57600080fd5b6107a0600160a060020a036004351661186a565b60405160208082528190810183818151815260200191508051906020019060200280838360005b838110156107df5780820151838201526020016107c7565b505050509050019250505060405180910390f35b34156107fe57600080fd5b61040460043561194b565b341561081457600080fd5b6102db611c1b565b341561082757600080fd5b61037a611d0e565b341561083a57600080fd5b610845600435611d45565b60405163ffffffff909116815260200160405180910390f35b341561086957600080fd5b61033c600435611d72565b341561087f57600080fd5b6102db600160a060020a0360043516602435611d8d565b34156108a157600080fd5b61033c611e30565b34156108b457600080fd5b610404611e3f565b34156108c757600080fd5b61033c611e45565b34156108da57600080fd5b6102db600435611e54565b34156108f057600080fd5b610315600435611f47565b341561090657600080fd5b610404612010565b341561091957600080fd5b6102db600160a060020a0360043516612016565b341561093857600080fd5b61033c612053565b341561094b57600080fd5b610956600435612062565b6040519915158a5297151560208a01526040808a01979097526060890195909552608088019390935260a087019190915260c086015260e0850152610100840152610120830191909152610140909101905180910390f35b6102db6004356024356121c3565b34156109c757600080fd5b610404612316565b34156109da57600080fd5b61033c61231c565b6102db60043560243561232b565b60006040517f737570706f727473496e7465726661636528627974657334290000000000000081526019016040518091039020600160e060020a03191682600160e060020a0319161480610c6f57506040517f746f6b656e4d657461646174612875696e743235362c737472696e67290000008152601d0160405180910390206040517f746f6b656e734f664f776e657228616464726573732900000000000000000000815260160160405180910390206040517f7472616e7366657246726f6d28616464726573732c616464726573732c75696e81527f7432353629000000000000000000000000000000000000000000000000000000602082015260250160405180910390206040517f7472616e7366657228616464726573732c75696e743235362900000000000000815260190160405180910390206040517f617070726f766528616464726573732c75696e74323536290000000000000000815260180160405180910390206040517f6f776e65724f662875696e743235362900000000000000000000000000000000815260100160405180910390206040517f62616c616e63654f662861646472657373290000000000000000000000000000815260120160405180910390206040517f746f74616c537570706c792829000000000000000000000000000000000000008152600d0160405180910390206040517f73796d626f6c2829000000000000000000000000000000000000000000000000815260080160405180910390206040517f6e616d652829000000000000000000000000000000000000000000000000000081526006016040518091039020181818181818181818600160e060020a03191682600160e060020a031916145b90505b919050565b600154600160a060020a031681565b610c8e612fa0565b610c96612fb2565b600d54600090600160a060020a03161515610cb057600080fd5b600d54600160a060020a031663cb4799f2878787600060405160a0015260405160e060020a63ffffffff861602815260048101848152604060248301908152604483018490529091606401848480828437820191505094505050505060a060405180830381600087803b1515610d2557600080fd5b6102c65a03f11515610d3657600080fd5b50505060405180608001805160209091016040529092509050610d59828261251d565b9695505050505050565b60115481565b60408051908101604052600d81527f43727970746f4b69747469657300000000000000000000000000000000000000602082015281565b60025460a060020a900460ff1615610db757600080fd5b610dc13382612572565b1515610dcc57600080fd5b610dd68183612592565b7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925338383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a15050565b600054600160a060020a031681565b662386f26fc1000081565b6000805433600160a060020a03908116911614610e6057600080fd5b5080600160a060020a0381166376190f8f6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610ea857600080fd5b6102c65a03f11515610eb957600080fd5b505050604051805190501515610ece57600080fd5b600c8054600160a060020a031916600160a060020a039290921691909117905550565b600654600019015b90565b600f5481565b6000808211610f1057600080fd5b6006805483908110610f1e57fe5b600091825260209091206002909102016001015460c060020a900463ffffffff16151592915050565b6201518081565b600c54600160a060020a031681565b60025460a060020a900460ff1615610f7457600080fd5b600160a060020a0382161515610f8957600080fd5b30600160a060020a031682600160a060020a031614151515610faa57600080fd5b610fb433826125c0565b1515610fbf57600080fd5b610fc98382612572565b1515610fd457600080fd5b610fdf8383836125e0565b505050565b6000805433600160a060020a0390811691161461100057600080fd5b5080600160a060020a0381166354c15b826000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561104857600080fd5b6102c65a03f1151561105957600080fd5b50505060405180519050151561106e57600080fd5b60108054600160a060020a031916600160a060020a039290921691909117905550565b60005433600160a060020a039081169116146110ac57600080fd5b600160a060020a03811615156110c157600080fd5b60008054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a039081169116146110fe57600080fd5b600160a060020a038116151561111357600080fd5b60028054600160a060020a031916600160a060020a0392909216919091179055565b60025460a060020a900460ff161561114c57600080fd5b6111563385612572565b151561116157600080fd5b61116a84610f02565b1561117457600080fd5b600b5461118b908590600160a060020a0316612592565b600b54600160a060020a03166327ebe40a858585853360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156111fa57600080fd5b6102c65a03f1151561120b57600080fd5b50505050505050565b60005433600160a060020a0390811691161461122f57600080fd5b60025460a060020a900460ff16151561124757600080fd5b600b54600160a060020a0316151561125e57600080fd5b600c54600160a060020a0316151561127557600080fd5b601054600160a060020a0316151561128c57600080fd5b601354600160a060020a0316156112a257600080fd5b6112aa6126c8565b565b600a60205260009081526040902054600160a060020a031681565b600080808085116112d757600080fd5b600084116112e457600080fd5b60068054869081106112f257fe5b9060005260206000209060020201915060068481548110151561131157fe5b9060005260206000209060020201905061132d8286838761271b565b801561133e575061133e848661289b565b95945050505050565b600960205260009081526040902054600160a060020a031681565b60025460a060020a900460ff161561137957600080fd5b6113833385612572565b151561138e57600080fd5b61139784611f47565b15156113a257600080fd5b600c546113b9908590600160a060020a0316612592565b600c54600160a060020a03166327ebe40a858585853360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156111fa57600080fd5b60025433600160a060020a0390811691161461144357600080fd5b600e55565b60025460a060020a900460ff161561145f57600080fd5b6114693382612572565b151561147457600080fd5b6000908152600a602052604090208054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a039081169116146114bd57600080fd5b600160a060020a03811615156114d257600080fd5b60018054600160a060020a031916600160a060020a0392909216919091179055565b60025460009033600160a060020a0390811691161461151257600080fd5b5080600160a060020a03811615156115325750600254600160a060020a03165b601154611388901061154357600080fd5b60118054600101905561155a6000808086856128f0565b50505050565b60025433600160a060020a039081169116148061158b575060005433600160a060020a039081169116145b806115a4575060015433600160a060020a039081169116145b15156115af57600080fd5b60035463ffffffff1681106115c357600080fd5b600555565b60025460a060020a900460ff1681565b600154600090819033600160a060020a039081169116146115f857600080fd5b30600160a060020a0316319150600e54600f546001010290508082111561164557600154600160a060020a031681830380156108fc0290604051600060405180830381858888f150505050505b5050565b600081815260076020526040902054600160a060020a0316801515610c7257600080fd5b61afc881565b601354600160a060020a031681565b6000805433600160a060020a0390811691161461169e57600080fd5b5080600160a060020a0381166385b861886000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156116e657600080fd5b6102c65a03f115156116f757600080fd5b50505060405180519050151561170c57600080fd5b600b8054600160a060020a031916600160a060020a039290921691909117905550565b600160a060020a031660009081526008602052604090205490565b60005433600160a060020a0390811691161461176557600080fd5b60025460a060020a900460ff16151561177d57600080fd5b60138054600160a060020a031916600160a060020a0383161790557f450db8da6efbe9c22f2347f7c2021231df1fc58d3ae9a2fa75d39fa44619930581604051600160a060020a03909116815260200160405180910390a150565b60055481565b60025433600160a060020a0390811691161480611809575060005433600160a060020a039081169116145b80611822575060015433600160a060020a039081169116145b151561182d57600080fd5b60025460a060020a900460ff161561184457600080fd5b6002805474ff0000000000000000000000000000000000000000191660a060020a179055565b611872612fa0565b600061187c612fa0565b600080600061188a8761172f565b94508415156118ba5760006040518059106118a25750595b90808252806020026020018201604052509550611941565b846040518059106118c85750595b908082528060200260200182016040525093506118e3610ef1565b925060009150600190505b82811161193d57600081815260076020526040902054600160a060020a0388811691161415611935578084838151811061192457fe5b602090810290910101526001909101905b6001016118ee565b8395505b5050505050919050565b600080600080600080600080600260149054906101000a900460ff1615151561197357600080fd5b600680548a90811061198157fe5b60009182526020909120600290910201600181015490975067ffffffffffffffff1615156119ae57600080fd5b611a438761010060405190810160409081528254825260019092015467ffffffffffffffff8082166020840152680100000000000000008204169282019290925263ffffffff608060020a83048116606083015260a060020a83048116608083015260c060020a83041660a082015261ffff60e060020a8304811660c083015260f060020a90920490911660e0820152612b9c565b1515611a4e57600080fd5b60018701546006805460c060020a90920463ffffffff1697509087908110611a7257fe5b600091825260209091206001808a015460029093029091019081015490965061ffff60f060020a92839004811696509190041684901115611ac057600185015460f060020a900461ffff1693505b6010548754865460018a0154600160a060020a0390931692630d9f5aed92919068010000000000000000900467ffffffffffffffff166000190160006040516020015260405160e060020a63ffffffff86160281526004810193909352602483019190915267ffffffffffffffff166044820152606401602060405180830381600087803b1515611b5057600080fd5b6102c65a03f11515611b6157600080fd5b505050604051805160008b81526007602052604090205460018a810154929650600160a060020a039091169450611bb092508b9160c060020a900463ffffffff1690870161ffff1686866128f0565b6001880180547bffffffff00000000000000000000000000000000000000000000000019169055600f8054600019019055600e54909150600160a060020a0333169080156108fc0290604051600060405180830381858888f150939c9b505050505050505050505050565b60025433600160a060020a0390811691161480611c46575060005433600160a060020a039081169116145b80611c5f575060015433600160a060020a039081169116145b1515611c6a57600080fd5b600b54600160a060020a0316635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b1515611ca957600080fd5b6102c65a03f11515611cba57600080fd5b5050600c54600160a060020a03169050635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b1515611cfd57600080fd5b6102c65a03f11515610fdf57600080fd5b60408051908101604052600281527f434b000000000000000000000000000000000000000000000000000000000000602082015281565b600381600e8110611d5257fe5b60089182820401919006600402915054906101000a900463ffffffff1681565b600760205260009081526040902054600160a060020a031681565b60025460a060020a900460ff1615611da457600080fd5b600160a060020a0382161515611db957600080fd5b30600160a060020a031682600160a060020a031614151515611dda57600080fd5b600b54600160a060020a0383811691161415611df557600080fd5b600c54600160a060020a0383811691161415611e1057600080fd5b611e1a3382612572565b1515611e2557600080fd5b6116453383836125e0565b600254600160a060020a031681565b600e5481565b600d54600160a060020a031681565b60025460009033600160a060020a03908116911614611e7257600080fd5b60125461afc89010611e8357600080fd5b611e92600080600085306128f0565b600b54909150611eac908290600160a060020a0316612592565b600b54600160a060020a03166327ebe40a82611ec6612bd4565b6000620151803060405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b1515611f2657600080fd5b6102c65a03f11515611f3757600080fd5b5050601280546001019055505050565b600080808311611f5657600080fd5b6006805484908110611f6457fe5b906000526020600020906002020190506120098161010060405190810160409081528254825260019092015467ffffffffffffffff8082166020840152680100000000000000008204169282019290925263ffffffff608060020a83048116606083015260a060020a83048116608083015260c060020a83041660a082015261ffff60e060020a8304811660c083015260f060020a90920490911660e0820152612c82565b9392505050565b61138881565b60005433600160a060020a0390811691161461203157600080fd5b600d8054600160a060020a031916600160a060020a0392909216919091179055565b600b54600160a060020a031681565b600080600080600080600080600080600060068c81548110151561208257fe5b906000526020600020906002020190508060010160189054906101000a900463ffffffff1663ffffffff16600014159a50438160010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff161115995080600101601c9054906101000a900461ffff1661ffff1698508060010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff1697508060010160189054906101000a900463ffffffff1663ffffffff1696508060010160009054906101000a900467ffffffffffffffff1667ffffffffffffffff1695508060010160109054906101000a900463ffffffff1663ffffffff1694508060010160149054906101000a900463ffffffff1663ffffffff16935080600101601e9054906101000a900461ffff1661ffff16925080600001549150509193959799509193959799565b60025460009060a060020a900460ff16156121dd57600080fd5b6121e73383612572565b15156121f257600080fd5b6121fb82611f47565b151561220657600080fd5b6122108284612cb9565b151561221b57600080fd5b600c54600160a060020a031663c55d0f568460006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561226c57600080fd5b6102c65a03f1151561227d57600080fd5b5050506040518051600e549092508201341015905061229b57600080fd5b600c54600e54600160a060020a039091169063454a2ab39034038560405160e060020a63ffffffff851602815260048101919091526024016000604051808303818588803b15156122eb57600080fd5b6125ee5a03f115156122fc57600080fd5b50505050610fdf8263ffffffff168463ffffffff16612d08565b60125481565b601054600160a060020a031681565b600254600090819060a060020a900460ff161561234757600080fd5b600e5434101561235657600080fd5b6123603385612572565b151561236b57600080fd5b612375838561289b565b151561238057600080fd5b600680548590811061238e57fe5b906000526020600020906002020191506124338261010060405190810160409081528254825260019092015467ffffffffffffffff8082166020840152680100000000000000008204169282019290925263ffffffff608060020a83048116606083015260a060020a83048116608083015260c060020a83041660a082015261ffff60e060020a8304811660c083015260f060020a90920490911660e0820152612c82565b151561243e57600080fd5b600680548490811061244c57fe5b906000526020600020906002020190506124f18161010060405190810160409081528254825260019092015467ffffffffffffffff8082166020840152680100000000000000008204169282019290925263ffffffff608060020a83048116606083015260a060020a83048116608083015260c060020a83041660a082015261ffff60e060020a8304811660c083015260f060020a90920490911660e0820152612c82565b15156124fc57600080fd5b6125088285838661271b565b151561251357600080fd5b61155a8484612d08565b612525612fa0565b61252d612fa0565b6000808460405180591061253e5750595b818152601f19601f8301168101602001604052905092505060208201905084612568828287612e72565b5090949350505050565b600090815260076020526040902054600160a060020a0391821691161490565b6000918252600960205260409091208054600160a060020a031916600160a060020a03909216919091179055565b600090815260096020526040902054600160a060020a0391821691161490565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a031916909117905583161561267357600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b60005433600160a060020a039081169116146126e357600080fd5b60025460a060020a900460ff1615156126fb57600080fd5b6002805474ff000000000000000000000000000000000000000019169055565b60008184141561272d57506000612893565b6001850154608060020a900463ffffffff1682148061275c5750600185015460a060020a900463ffffffff1682145b1561276957506000612893565b6001830154608060020a900463ffffffff168414806127985750600183015460a060020a900463ffffffff1684145b156127a557506000612893565b6001830154608060020a900463ffffffff1615806127d257506001850154608060020a900463ffffffff16155b156127df57506001612893565b60018581015490840154608060020a9182900463ffffffff9081169290910416148061282a575060018086015490840154608060020a900463ffffffff90811660a060020a90920416145b1561283757506000612893565b6001808601549084015460a060020a900463ffffffff908116608060020a90920416148061288257506001858101549084015460a060020a9182900463ffffffff9081169290910416145b1561288f57506000612893565b5060015b949350505050565b6000818152600760205260408082205484835290822054600160a060020a0391821691168082148061133e57506000858152600a6020526040902054600160a060020a03908116908316149250505092915050565b6000806128fb612fdb565b600063ffffffff8916891461290f57600080fd5b63ffffffff8816881461292157600080fd5b61ffff8716871461293157600080fd5b600287049250600d8361ffff16111561294957600d92505b610100604051908101604090815287825267ffffffffffffffff42166020830152600090820181905263ffffffff808c1660608401528a16608083015260a082015261ffff80851660c0830152881660e0820152600680549193506001918083016129b4838261301f565b6000928352602090922085916002020181518155602082015160018201805467ffffffffffffffff191667ffffffffffffffff9290921691909117905560408201518160010160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060608201518160010160106101000a81548163ffffffff021916908363ffffffff16021790555060808201518160010160146101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160010160186101000a81548163ffffffff021916908363ffffffff16021790555060c082015181600101601c6101000a81548161ffff021916908361ffff16021790555060e08201516001909101805461ffff9290921660f060020a027dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092169190911790555003905063ffffffff81168114612b0f57600080fd5b7f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad58582846060015163ffffffff16856080015163ffffffff168651604051600160a060020a03909516855260208501939093526040808501929092526060840152608083019190915260a0909101905180910390a1612b90600086836125e0565b98975050505050505050565b60008160a0015163ffffffff1615801590610c6f57504367ffffffffffffffff16826040015167ffffffffffffffff16111592915050565b600b5460009081908190600160a060020a031663eac9d94c82604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515612c2257600080fd5b6102c65a03f11515612c3357600080fd5b50505060405180519250506fffffffffffffffffffffffffffffffff82168214612c5c57600080fd5b50600281048101662386f26fc10000811015612c7c5750662386f26fc100005b92915050565b60008160a0015163ffffffff16158015610c6f57504367ffffffffffffffff16826040015167ffffffffffffffff16111592915050565b6000806000600685815481101515612ccd57fe5b90600052602060002090600202019150600684815481101515612cec57fe5b9060005260206000209060020201905061133e8286838761271b565b600080600683815481101515612d1a57fe5b90600052602060002090600202019150600684815481101515612d3957fe5b600091825260209091206002909102016001810180547bffffffff000000000000000000000000000000000000000000000000191660c060020a63ffffffff8716021790559050612d8982612eb7565b612d9281612eb7565b6000848152600a602090815260408083208054600160a060020a031990811690915586845281842080549091169055600f8054600190810190915587845260079092529182902054908301547f241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b8092600160a060020a0390921691879187916801000000000000000090910467ffffffffffffffff1690518085600160a060020a0316600160a060020a031681526020018481526020018381526020018267ffffffffffffffff16815260200194505050505060405180910390a150505050565b60005b60208210612e985782518452602084019350602083019250602082039150612e75565b6001826020036101000a03905080198351168185511617909352505050565b600554600182015443919060039060e060020a900461ffff16600e8110612eda57fe5b600891828204019190066004029054906101000a900463ffffffff1663ffffffff16811515612f0557fe5b6001840180546fffffffffffffffff0000000000000000191668010000000000000000939092049390930167ffffffffffffffff16919091021790819055600d60e060020a90910461ffff161015612f9d576001818101805461ffff60e060020a8083048216909401169092027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092169190911790555b50565b60206040519081016040526000815290565b60806040519081016040526004815b60008152600019919091019060200181612fc15790505090565b6101006040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e082015290565b815481835581811511610fdf57600083815260209020610fdf91610ef99160029182028101918502015b808211156130635760008082556001820155600201613049565b50905600a165627a7a72305820a6465fc1ce7ab1a92906ff7206b23d80a21bbd50b85b4bde6a91f8e6b2e3edde0029" - code_ContractScenario011_deployErc721KittyCore = "6002805460a060020a60ff0219169055610240604052603c6080908152607860a05261012c60c05261025860e05261070861010052610e1061012052611c2061014052613840610160526170806101805261e1006101a052620151806101c0526202a3006101e052620546006102005262093a80610220526200008790600390600e620004e3565b50600f6005556301312d00600e55348015620000a257600080fd5b506002805460008054600160a060020a031990811633908117835560a060020a60ff0219909316740100000000000000000000000000000000000000001716909117909155620001019080806000198164010000000062000108810204565b50620005f1565b6000806200011562000586565b600063ffffffff891689146200012a57600080fd5b63ffffffff881688146200013d57600080fd5b61ffff871687146200014e57600080fd5b600287049250600d8361ffff1611156200016757600d92505b505060408051610100810182528581524267ffffffffffffffff90811660208301908152600093830184815263ffffffff8c8116606086019081528c82166080870190815260a0870188815261ffff8a811660c08a019081528f821660e08b01908152600680546001810182559c528a517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f60028e029081019190915598517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d40909901805498519651955194519251915167ffffffffffffffff19909916998b1699909917604060020a608060020a0319166801000000000000000096909a169590950298909817608060020a63ffffffff021916700100000000000000000000000000000000938616939093029290921760a060020a63ffffffff02191674010000000000000000000000000000000000000000918516919091021760c060020a63ffffffff0219167801000000000000000000000000000000000000000000000000968416969096029590951760e060020a61ffff0219167c01000000000000000000000000000000000000000000000000000000009186169190910217600160f060020a03167e010000000000000000000000000000000000000000000000000000000000009290941691909102929092179055909190811681146200036f57600080fd5b606080830151608080850151855160408051600160a060020a038c1681526020810188905263ffffffff95861681830152929094169482019490945290810192909252517f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad59181900360a00190a1620003f46000868364010000000062000400810204565b98975050505050505050565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a03191690911790558316156200049457600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b60408051600160a060020a0380861682528416602082015280820183905290517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360600190a1505050565b600283019183908215620005745791602002820160005b838211156200054057835183826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302620004fa565b8015620005725782816101000a81549063ffffffff021916905560040160208160030104928301926001030262000540565b505b5062000582929150620005ca565b5090565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915290565b620005ee91905b808211156200058257805463ffffffff19168155600101620005d1565b90565b6130f380620006016000396000f3006080604052600436106102a55763ffffffff60e060020a60003504166301ffc9a781146102d55780630519ce79146103205780630560ff441461035157806305e45546146103ea57806306fdde0314610411578063095ea7b3146104265780630a0f81681461044a5780630e583df01461045f57806314001f4c1461047457806318160ddd14610495578063183a7947146104aa5780631940a936146104bf57806319c2f201146104d757806321717ebf146104ec57806323b872dd1461050157806324e7a38a1461052b57806327d7874c1461054c5780632ba73c151461056d5780633d7d3f5a1461058e5780633f4ba83a146105af57806346116e6f146105c457806346d22c70146105dc578063481af3d3146105f75780634ad8c9381461060f5780634b85fd55146106305780634dfff04f146106485780634e0a33791461066c578063561291341461068d5780635663896e146106b15780635c975abb146106c95780635fd8c710146106de5780636352211e146106f3578063680eba271461070b5780636af04a57146107205780636fbde40d1461073557806370a082311461075657806371587988146107775780637a7d4937146107985780638456cb59146107ad5780638462151c146107c257806388c2a0bf1461083357806391876e571461084b57806395d89b41146108605780639d6fac6f14610875578063a45f4bfc146108a6578063a9059cbb146108be578063b047fb50146108e2578063b0c35c05146108f7578063bc4006f51461090c578063c3bea9af14610921578063d3e6f49f14610939578063defb958414610951578063e17b25af14610966578063e6cbe35114610987578063e98b7f4d1461099c578063ed60ade614610a06578063f1ca941014610a14578063f2b47d5214610a29578063f7d8c88314610a3e575b600b54600160a060020a03163314806102c85750600c54600160a060020a031633145b15156102d357600080fd5b005b3480156102e157600080fd5b5061030c7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1960043516610a4c565b604080519115158252519081900360200190f35b34801561032c57600080fd5b50610335610cdf565b60408051600160a060020a039092168252519081900360200190f35b34801561035d57600080fd5b50610375600480359060248035908101910135610cee565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103af578181015183820152602001610397565b50505050905090810190601f1680156103dc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f657600080fd5b506103ff610df1565b60408051918252519081900360200190f35b34801561041d57600080fd5b50610375610df7565b34801561043257600080fd5b506102d3600160a060020a0360043516602435610e2e565b34801561045657600080fd5b50610335610eb0565b34801561046b57600080fd5b506103ff610ebf565b34801561048057600080fd5b506102d3600160a060020a0360043516610ec6565b3480156104a157600080fd5b506103ff610f79565b3480156104b657600080fd5b506103ff610f83565b3480156104cb57600080fd5b5061030c600435610f89565b3480156104e357600080fd5b506103ff610fce565b3480156104f857600080fd5b50610335610fd5565b34801561050d57600080fd5b506102d3600160a060020a0360043581169060243516604435610fe4565b34801561053757600080fd5b506102d3600160a060020a0360043516611060565b34801561055857600080fd5b506102d3600160a060020a0360043516611113565b34801561057957600080fd5b506102d3600160a060020a0360043516611161565b34801561059a57600080fd5b506102d36004356024356044356064356111af565b3480156105bb57600080fd5b506102d36112a4565b3480156105d057600080fd5b50610335600435611338565b3480156105e857600080fd5b5061030c600435602435611353565b34801561060357600080fd5b506103356004356113d3565b34801561061b57600080fd5b506102d36004356024356044356064356113ee565b34801561063c57600080fd5b506102d36004356114c6565b34801561065457600080fd5b506102d3600160a060020a03600435166024356114e2565b34801561067857600080fd5b506102d3600160a060020a036004351661153c565b34801561069957600080fd5b506102d3600435600160a060020a036024351661158a565b3480156106bd57600080fd5b506102d36004356115f1565b3480156106d557600080fd5b5061030c61164d565b3480156106ea57600080fd5b506102d361165d565b3480156106ff57600080fd5b506103356004356116c1565b34801561071757600080fd5b506103ff6116e5565b34801561072c57600080fd5b506103356116eb565b34801561074157600080fd5b506102d3600160a060020a03600435166116fa565b34801561076257600080fd5b506103ff600160a060020a03600435166117ad565b34801561078357600080fd5b506102d3600160a060020a03600435166117c8565b3480156107a457600080fd5b506103ff61184b565b3480156107b957600080fd5b506102d3611851565b3480156107ce57600080fd5b506107e3600160a060020a03600435166118d1565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561081f578181015183820152602001610807565b505050509050019250505060405180910390f35b34801561083f57600080fd5b506103ff6004356119a3565b34801561085757600080fd5b506102d3611c7f565b34801561086c57600080fd5b50610375611d94565b34801561088157600080fd5b5061088d600435611dcb565b6040805163ffffffff9092168252519081900360200190f35b3480156108b257600080fd5b50610335600435611df8565b3480156108ca57600080fd5b506102d3600160a060020a0360043516602435611e13565b3480156108ee57600080fd5b50610335611eab565b34801561090357600080fd5b506103ff611eba565b34801561091857600080fd5b50610335611ec0565b34801561092d57600080fd5b506102d3600435611ecf565b34801561094557600080fd5b5061030c600435611fb9565b34801561095d57600080fd5b506103ff612088565b34801561097257600080fd5b506102d3600160a060020a036004351661208e565b34801561099357600080fd5b506103356120c7565b3480156109a857600080fd5b506109b46004356120d6565b604080519a15158b5298151560208b0152898901979097526060890195909552608088019390935260a087019190915260c086015260e085015261010084015261012083015251908190036101400190f35b6102d3600435602435612237565b348015610a2057600080fd5b506103ff6123d1565b348015610a3557600080fd5b506103356123d7565b6102d36004356024356123e6565b604080517f737570706f727473496e74657266616365286279746573342900000000000000815290519081900360190190206000907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1983811691161480610cd75750604080517f746f6b656e4d657461646174612875696e743235362c737472696e67290000008152815190819003601d0181207f746f6b656e734f664f776e657228616464726573732900000000000000000000825282519182900360160182207f7472616e7366657246726f6d28616464726573732c616464726573732c75696e83527f7432353629000000000000000000000000000000000000000000000000000000602084015283519283900360250183207f7472616e7366657228616464726573732c75696e743235362900000000000000845284519384900360190184207f617070726f766528616464726573732c75696e74323536290000000000000000855285519485900360180185207f6f776e65724f662875696e743235362900000000000000000000000000000000865286519586900360100186207f62616c616e63654f662861646472657373290000000000000000000000000000875287519687900360120187207f746f74616c537570706c792829000000000000000000000000000000000000008852885197889003600d0188207f73796d626f6c2829000000000000000000000000000000000000000000000000895289519889900360080189207f6e616d65282900000000000000000000000000000000000000000000000000008a529951988990036006019098207bffffffffffffffffffffffffffffffffffffffffffffffffffffffff198c811691909a189098181818181818181891909116145b90505b919050565b600154600160a060020a031681565b6060610cf8613064565b600d54600090600160a060020a03161515610d1257600080fd5b600d54604080517fcb4799f2000000000000000000000000000000000000000000000000000000008152600481018981526024820192835260448201889052600160a060020a039093169263cb4799f2928a928a928a929091606401848480828437820191505094505050505060a060405180830381600087803b158015610d9957600080fd5b505af1158015610dad573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525060a0811015610dd257600080fd5b5060808101519092509050610de782826125e4565b9695505050505050565b60115481565b60408051808201909152600d81527f43727970746f4b69747469657300000000000000000000000000000000000000602082015281565b60025460a060020a900460ff1615610e4557600080fd5b610e4f3382612638565b1515610e5a57600080fd5b610e648183612658565b60408051338152600160a060020a038416602082015280820183905290517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259181900360600190a15050565b600054600160a060020a031681565b6298968081565b60008054600160a060020a03163314610ede57600080fd5b81905080600160a060020a03166376190f8f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610f1f57600080fd5b505af1158015610f33573d6000803e3d6000fd5b505050506040513d6020811015610f4957600080fd5b50511515610f5657600080fd5b600c8054600160a060020a031916600160a060020a039290921691909117905550565b6006546000190190565b600f5481565b6000808211610f9757600080fd5b6006805483908110610fa557fe5b600091825260209091206002909102016001015460c060020a900463ffffffff16151592915050565b6201518081565b600c54600160a060020a031681565b60025460a060020a900460ff1615610ffb57600080fd5b600160a060020a038216151561101057600080fd5b600160a060020a03821630141561102657600080fd5b6110303382612686565b151561103b57600080fd5b6110458382612638565b151561105057600080fd5b61105b8383836126a6565b505050565b60008054600160a060020a0316331461107857600080fd5b81905080600160a060020a03166354c15b826040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156110b957600080fd5b505af11580156110cd573d6000803e3d6000fd5b505050506040513d60208110156110e357600080fd5b505115156110f057600080fd5b60108054600160a060020a031916600160a060020a039290921691909117905550565b600054600160a060020a0316331461112a57600080fd5b600160a060020a038116151561113f57600080fd5b60008054600160a060020a031916600160a060020a0392909216919091179055565b600054600160a060020a0316331461117857600080fd5b600160a060020a038116151561118d57600080fd5b60028054600160a060020a031916600160a060020a0392909216919091179055565b60025460a060020a900460ff16156111c657600080fd5b6111d03385612638565b15156111db57600080fd5b6111e484610f89565b156111ee57600080fd5b600b54611205908590600160a060020a0316612658565b600b54604080517f27ebe40a000000000000000000000000000000000000000000000000000000008152600481018790526024810186905260448101859052606481018490523360848201529051600160a060020a03909216916327ebe40a9160a48082019260009290919082900301818387803b15801561128657600080fd5b505af115801561129a573d6000803e3d6000fd5b5050505050505050565b600054600160a060020a031633146112bb57600080fd5b60025460a060020a900460ff1615156112d357600080fd5b600b54600160a060020a031615156112ea57600080fd5b600c54600160a060020a0316151561130157600080fd5b601054600160a060020a0316151561131857600080fd5b601354600160a060020a03161561132e57600080fd5b611336612788565b565b600a60205260009081526040902054600160a060020a031681565b6000808080851161136357600080fd5b6000841161137057600080fd5b600680548690811061137e57fe5b9060005260206000209060020201915060068481548110151561139d57fe5b906000526020600020906002020190506113b9828683876127d7565b80156113ca57506113ca8486612957565b95945050505050565b600960205260009081526040902054600160a060020a031681565b60025460a060020a900460ff161561140557600080fd5b61140f3385612638565b151561141a57600080fd5b61142384611fb9565b151561142e57600080fd5b600c54611445908590600160a060020a0316612658565b600c54604080517f27ebe40a000000000000000000000000000000000000000000000000000000008152600481018790526024810186905260448101859052606481018490523360848201529051600160a060020a03909216916327ebe40a9160a48082019260009290919082900301818387803b15801561128657600080fd5b600254600160a060020a031633146114dd57600080fd5b600e55565b60025460a060020a900460ff16156114f957600080fd5b6115033382612638565b151561150e57600080fd5b6000908152600a602052604090208054600160a060020a031916600160a060020a0392909216919091179055565b600054600160a060020a0316331461155357600080fd5b600160a060020a038116151561156857600080fd5b60018054600160a060020a031916600160a060020a0392909216919091179055565b600254600090600160a060020a031633146115a457600080fd5b5080600160a060020a03811615156115c45750600254600160a060020a03165b601154611388116115d457600080fd5b6011805460010190556115eb6000808086856129ac565b50505050565b600254600160a060020a03163314806116145750600054600160a060020a031633145b806116295750600154600160a060020a031633145b151561163457600080fd5b60035463ffffffff16811061164857600080fd5b600555565b60025460a060020a900460ff1681565b6001546000908190600160a060020a0316331461167957600080fd5b5050600e54600f54303191600190910102808211156116bd57600154604051600160a060020a039091169082840380156108fc02916000818181858888f150505050505b5050565b600081815260076020526040902054600160a060020a0316801515610cda57600080fd5b61afc881565b601354600160a060020a031681565b60008054600160a060020a0316331461171257600080fd5b81905080600160a060020a03166385b861886040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561175357600080fd5b505af1158015611767573d6000803e3d6000fd5b505050506040513d602081101561177d57600080fd5b5051151561178a57600080fd5b600b8054600160a060020a031916600160a060020a039290921691909117905550565b600160a060020a031660009081526008602052604090205490565b600054600160a060020a031633146117df57600080fd5b60025460a060020a900460ff1615156117f757600080fd5b60138054600160a060020a038316600160a060020a0319909116811790915560408051918252517f450db8da6efbe9c22f2347f7c2021231df1fc58d3ae9a2fa75d39fa4461993059181900360200190a150565b60055481565b600254600160a060020a03163314806118745750600054600160a060020a031633145b806118895750600154600160a060020a031633145b151561189457600080fd5b60025460a060020a900460ff16156118ab57600080fd5b6002805474ff0000000000000000000000000000000000000000191660a060020a179055565b60606000606060008060006118e5876117ad565b9450841515611904576040805160008152602081019091529550611999565b8460405190808252806020026020018201604052801561192e578160200160208202803883390190505b509350611939610f79565b925060009150600190505b82811161199557600081815260076020526040902054600160a060020a038881169116141561198d5780848381518110151561197c57fe5b602090810290910101526001909101905b600101611944565b8395505b5050505050919050565b600080600080600080600080600260149054906101000a900460ff161515156119cb57600080fd5b600680548a9081106119d957fe5b60009182526020909120600290910201600181015490975067ffffffffffffffff161515611a0657600080fd5b604080516101008101825288548152600189015467ffffffffffffffff8082166020840152680100000000000000008204169282019290925263ffffffff608060020a83048116606083015260a060020a83048116608083015260c060020a83041660a082015261ffff60e060020a8304811660c083015260f060020a90920490911660e0820152611a9790612c89565b1515611aa257600080fd5b60018701546006805460c060020a90920463ffffffff1697509087908110611ac657fe5b600091825260209091206001808a015460029093029091019081015490965061ffff60f060020a928390048116965091900416841015611b1357600185015460f060020a900461ffff1693505b6010548754865460018a0154604080517f0d9f5aed0000000000000000000000000000000000000000000000000000000081526004810194909452602484019290925260001967ffffffffffffffff6801000000000000000090920482160116604483015251600160a060020a0390921691630d9f5aed916064808201926020929091908290030181600087803b158015611bad57600080fd5b505af1158015611bc1573d6000803e3d6000fd5b505050506040513d6020811015611bd757600080fd5b505160008a815260076020526040902054600189810154929550600160a060020a039091169350611c20918b9160c060020a90910463ffffffff1690870161ffff1686866129ac565b6001880180547bffffffff00000000000000000000000000000000000000000000000019169055600f8054600019019055600e54604051919250339181156108fc0291906000818181858888f150939c9b505050505050505050505050565b600254600160a060020a0316331480611ca25750600054600160a060020a031633145b80611cb75750600154600160a060020a031633145b1515611cc257600080fd5b600b60009054906101000a9004600160a060020a0316600160a060020a0316635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b158015611d1557600080fd5b505af1158015611d29573d6000803e3d6000fd5b50505050600c60009054906101000a9004600160a060020a0316600160a060020a0316635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b158015611d8057600080fd5b505af11580156115eb573d6000803e3d6000fd5b60408051808201909152600281527f434b000000000000000000000000000000000000000000000000000000000000602082015281565b600381600e8110611dd857fe5b60089182820401919006600402915054906101000a900463ffffffff1681565b600760205260009081526040902054600160a060020a031681565b60025460a060020a900460ff1615611e2a57600080fd5b600160a060020a0382161515611e3f57600080fd5b600160a060020a038216301415611e5557600080fd5b600b54600160a060020a0383811691161415611e7057600080fd5b600c54600160a060020a0383811691161415611e8b57600080fd5b611e953382612638565b1515611ea057600080fd5b6116bd3383836126a6565b600254600160a060020a031681565b600e5481565b600d54600160a060020a031681565b600254600090600160a060020a03163314611ee957600080fd5b60125461afc811611ef957600080fd5b611f08600080600085306129ac565b600b54909150611f22908290600160a060020a0316612658565b600b54600160a060020a03166327ebe40a82611f3c612cb9565b6040805160e060020a63ffffffff861602815260048101939093526024830191909152600060448301819052620151806064840152306084840152905160a48084019382900301818387803b158015611f9457600080fd5b505af1158015611fa8573d6000803e3d6000fd5b505060128054600101905550505050565b600080808311611fc857600080fd5b6006805484908110611fd657fe5b60009182526020918290206040805161010081018252600290930290910180548352600181015467ffffffffffffffff808216958501959095526801000000000000000081049094169183019190915263ffffffff608060020a84048116606084015260a060020a84048116608084015260c060020a84041660a083015261ffff60e060020a8404811660c084015260f060020a90930490921660e082015290915061208190612d7b565b9392505050565b61138881565b600054600160a060020a031633146120a557600080fd5b600d8054600160a060020a031916600160a060020a0392909216919091179055565b600b54600160a060020a031681565b600080600080600080600080600080600060068c8154811015156120f657fe5b906000526020600020906002020190508060010160189054906101000a900463ffffffff1663ffffffff16600014159a50438160010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff161115995080600101601c9054906101000a900461ffff1661ffff1698508060010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff1697508060010160189054906101000a900463ffffffff1663ffffffff1696508060010160009054906101000a900467ffffffffffffffff1667ffffffffffffffff1695508060010160109054906101000a900463ffffffff1663ffffffff1694508060010160149054906101000a900463ffffffff1663ffffffff16935080600101601e9054906101000a900461ffff1661ffff16925080600001549150509193959799509193959799565b60025460009060a060020a900460ff161561225157600080fd5b61225b3383612638565b151561226657600080fd5b61226f82611fb9565b151561227a57600080fd5b6122848284612daa565b151561228f57600080fd5b600c54604080517fc55d0f56000000000000000000000000000000000000000000000000000000008152600481018690529051600160a060020a039092169163c55d0f56916024808201926020929091908290030181600087803b1580156122f657600080fd5b505af115801561230a573d6000803e3d6000fd5b505050506040513d602081101561232057600080fd5b5051600e54909150810134101561233657600080fd5b600c54600e54604080517f454a2ab3000000000000000000000000000000000000000000000000000000008152600481018790529051600160a060020a039093169263454a2ab39234039160248082019260009290919082900301818588803b1580156123a257600080fd5b505af11580156123b6573d6000803e3d6000fd5b505050505061105b8263ffffffff168463ffffffff16612df9565b60125481565b601054600160a060020a031681565b600254600090819060a060020a900460ff161561240257600080fd5b600e5434101561241157600080fd5b61241b3385612638565b151561242657600080fd5b6124308385612957565b151561243b57600080fd5b600680548590811061244957fe5b60009182526020918290206040805161010081018252600290930290910180548352600181015467ffffffffffffffff808216958501959095526801000000000000000081049094169183019190915263ffffffff608060020a84048116606084015260a060020a84048116608084015260c060020a84041660a083015261ffff60e060020a8404811660c084015260f060020a90930490921660e08201529092506124f490612d7b565b15156124ff57600080fd5b600680548490811061250d57fe5b60009182526020918290206040805161010081018252600290930290910180548352600181015467ffffffffffffffff808216958501959095526801000000000000000081049094169183019190915263ffffffff608060020a84048116606084015260a060020a84048116608084015260c060020a84041660a083015261ffff60e060020a8404811660c084015260f060020a90930490921660e08201529091506125b890612d7b565b15156125c357600080fd5b6125cf828583866127d7565b15156125da57600080fd5b6115eb8484612df9565b606080600080846040519080825280601f01601f191660200182016040528015612618578160200160208202803883390190505b509250506020820190508461262e828287612f37565b5090949350505050565b600090815260076020526040902054600160a060020a0391821691161490565b6000918252600960205260409091208054600160a060020a031916600160a060020a03909216919091179055565b600090815260096020526040902054600160a060020a0391821691161490565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a031916909117905583161561273957600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b60408051600160a060020a0380861682528416602082015280820183905290517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360600190a1505050565b600054600160a060020a0316331461279f57600080fd5b60025460a060020a900460ff1615156127b757600080fd5b6002805474ff000000000000000000000000000000000000000019169055565b6000818414156127e95750600061294f565b6001850154608060020a900463ffffffff168214806128185750600185015460a060020a900463ffffffff1682145b156128255750600061294f565b6001830154608060020a900463ffffffff168414806128545750600183015460a060020a900463ffffffff1684145b156128615750600061294f565b6001830154608060020a900463ffffffff16158061288e57506001850154608060020a900463ffffffff16155b1561289b5750600161294f565b60018581015490840154608060020a9182900463ffffffff908116929091041614806128e6575060018086015490840154608060020a900463ffffffff90811660a060020a90920416145b156128f35750600061294f565b6001808601549084015460a060020a900463ffffffff908116608060020a90920416148061293e57506001858101549084015460a060020a9182900463ffffffff9081169290910416145b1561294b5750600061294f565b5060015b949350505050565b6000818152600760205260408082205484835290822054600160a060020a039182169116808214806113ca57506000858152600a6020526040902054600160a060020a03908116908316149250505092915050565b6000806129b7613083565b600063ffffffff891689146129cb57600080fd5b63ffffffff881688146129dd57600080fd5b61ffff871687146129ed57600080fd5b600287049250600d8361ffff161115612a0557600d92505b505060408051610100810182528581524267ffffffffffffffff90811660208301908152600093830184815263ffffffff8c8116606086019081528c82166080870190815260a0870188815261ffff8a811660c08a019081528f821660e08b01908152600680546001810182559c528a517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f60028e029081019190915598517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d40909901805498519651955194519251915167ffffffffffffffff19909916998b16999099176fffffffffffffffff000000000000000019166801000000000000000096909a16959095029890981773ffffffff000000000000000000000000000000001916608060020a938616939093029290921777ffffffff0000000000000000000000000000000000000000191660a060020a91851691909102177bffffffff000000000000000000000000000000000000000000000000191660c060020a96841696909602959095177fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff1660e060020a91861691909102177dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1660f060020a929094169190910292909217905590919081168114612c0357600080fd5b606080830151608080850151855160408051600160a060020a038c1681526020810188905263ffffffff95861681830152929094169482019490945290810192909252517f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad59181900360a00190a1612c7d600086836126a6565b98975050505050505050565b60008160a0015163ffffffff16600014158015610cd75750506040015167ffffffffffffffff4381169116111590565b6000806000600b60009054906101000a9004600160a060020a0316600160a060020a031663eac9d94c6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015612d1157600080fd5b505af1158015612d25573d6000803e3d6000fd5b505050506040513d6020811015612d3b57600080fd5b505191506fffffffffffffffffffffffffffffffff82168214612d5d57600080fd5b5060028104810162989680811015612d755750629896805b92915050565b60008160a0015163ffffffff166000148015610cd75750506040015167ffffffffffffffff4381169116111590565b6000806000600685815481101515612dbe57fe5b90600052602060002090600202019150600684815481101515612ddd57fe5b906000526020600020906002020190506113ca828683876127d7565b600080600683815481101515612e0b57fe5b90600052602060002090600202019150600684815481101515612e2a57fe5b600091825260209091206002909102016001810180547bffffffff000000000000000000000000000000000000000000000000191660c060020a63ffffffff8716021790559050612e7a82612f7b565b612e8381612f7b565b6000848152600a602090815260408083208054600160a060020a031990811690915586845281842080549091169055600f80546001908101909155878452600783529281902054928401548151600160a060020a0390941684529183018790528281018690526801000000000000000090910467ffffffffffffffff166060830152517f241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80916080908290030190a150505050565b60005b60208210612f5c578251845260209384019390920191601f1990910190612f3a565b50905182516020929092036101000a6000190180199091169116179052565b600554600182015443919060039060e060020a900461ffff16600e8110612f9e57fe5b600891828204019190066004029054906101000a900463ffffffff1663ffffffff16811515612fc957fe5b6001840180546fffffffffffffffff0000000000000000191668010000000000000000939092049390930167ffffffffffffffff16919091021790819055600d60e060020a90910461ffff161015613061576001818101805461ffff60e060020a8083048216909401169092027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092169190911790555b50565b6080604051908101604052806004906020820280388339509192915050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810191909152905600a165627a7a723058201424bf1db41fa7ec76f5506a53d8bbcb84ed5b5a6ade2df0bac8deaacb118a8b0029" - code_ContractScenario011_deploySaleClockAuction = "60806040526000805460a060020a60ff02191690556004805460ff1916600117905534801561002d57600080fd5b50604051604080610ee883398101604052805160209091015160008054600160a060020a031916331781558290829061271082111561006b57600080fd5b506002819055604080517f01ffc9a70000000000000000000000000000000000000000000000000000000081527f9a20483d00000000000000000000000000000000000000000000000000000000600482015290518391600160a060020a038316916301ffc9a7916024808201926020929091908290030181600087803b1580156100f557600080fd5b505af1158015610109573d6000803e3d6000fd5b505050506040513d602081101561011f57600080fd5b5051151561012c57600080fd5b60018054600160a060020a03909216600160a060020a031990921691909117905550505050610d88806101606000396000f3006080604052600436106100fb5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166327ebe40a81146101005780633f4ba83a1461012f578063454a2ab314610158578063484eccb4146101635780635c975abb1461018d5780635fd8c710146101a257806378bd7935146101b757806383b5ff8b146102045780638456cb591461021957806385b861881461022e578063878eb368146102435780638a98a9cc1461025b5780638da5cb5b1461027057806396b5a755146102a1578063c55d0f56146102b9578063dd1b7a0f146102d1578063eac9d94c146102e6578063f2fde38b146102fb575b600080fd5b34801561010c57600080fd5b5061012d600435602435604435606435600160a060020a036084351661031c565b005b34801561013b57600080fd5b50610144610414565b604080519115158252519081900360200190f35b61012d60043561048f565b34801561016f57600080fd5b5061017b6004356104f9565b60408051918252519081900360200190f35b34801561019957600080fd5b5061014461050d565b3480156101ae57600080fd5b5061012d61051d565b3480156101c357600080fd5b506101cf60043561057a565b60408051600160a060020a03909616865260208601949094528484019290925260608401526080830152519081900360a00190f35b34801561021057600080fd5b5061017b610610565b34801561022557600080fd5b50610144610616565b34801561023a57600080fd5b50610144610696565b34801561024f57600080fd5b5061012d60043561069f565b34801561026757600080fd5b5061017b61070c565b34801561027c57600080fd5b50610285610712565b60408051600160a060020a039092168252519081900360200190f35b3480156102ad57600080fd5b5061012d600435610721565b3480156102c557600080fd5b5061017b600435610766565b3480156102dd57600080fd5b50610285610798565b3480156102f257600080fd5b5061017b6107a7565b34801561030757600080fd5b5061012d600160a060020a03600435166107db565b610324610d2e565b6fffffffffffffffffffffffffffffffff8516851461034257600080fd5b6fffffffffffffffffffffffffffffffff8416841461036057600080fd5b67ffffffffffffffff8316831461037657600080fd5b600154600160a060020a0316331461038d57600080fd5b610397828761082d565b60a06040519081016040528083600160a060020a03168152602001866fffffffffffffffffffffffffffffffff168152602001856fffffffffffffffffffffffffffffffff1681526020018467ffffffffffffffff1681526020014267ffffffffffffffff16815250905061040c86826108b5565b505050505050565b60008054600160a060020a0316331461042c57600080fd5b60005460a060020a900460ff16151561044457600080fd5b6000805474ff0000000000000000000000000000000000000000191681556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b339190a150600190565b600081815260036020526040812054600160a060020a0316906104b28334610a09565b90506104be3384610b2f565b600154600160a060020a03838116911614156104f45760058054829160069106600581106104e857fe5b01556005805460010190555b505050565b6006816005811061050657fe5b0154905081565b60005460a060020a900460ff1681565b60015460008054600160a060020a039283169216331480610546575033600160a060020a038316145b151561055157600080fd5b604051600160a060020a03831690303180156108fc02916000818181858888f150505050505050565b6000818152600360205260408120819081908190819061059981610b9d565b15156105a457600080fd5b80546001820154600290920154600160a060020a03909116986fffffffffffffffffffffffffffffffff8084169950700100000000000000000000000000000000909304909216965067ffffffffffffffff808216965068010000000000000000909104169350915050565b60025481565b60008054600160a060020a0316331461062e57600080fd5b60005460a060020a900460ff161561064557600080fd5b6000805474ff0000000000000000000000000000000000000000191660a060020a1781556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff6259190a150600190565b60045460ff1681565b6000805460a060020a900460ff1615156106b857600080fd5b600054600160a060020a031633146106cf57600080fd5b5060008181526003602052604090206106e781610b9d565b15156106f257600080fd5b8054610708908390600160a060020a0316610bbe565b5050565b60055481565b600054600160a060020a031681565b60008181526003602052604081209061073982610b9d565b151561074457600080fd5b508054600160a060020a031633811461075c57600080fd5b6104f48382610bbe565b600081815260036020526040812061077d81610b9d565b151561078857600080fd5b61079181610c08565b9392505050565b600154600160a060020a031681565b600080805b60058110156107d157600681600581106107c257fe5b015491909101906001016107ac565b5060059004919050565b600054600160a060020a031633146107f257600080fd5b600160a060020a0381161561082a576000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b600154604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015230602483015260448201859052915191909216916323b872dd91606480830192600092919082900301818387803b1580156108a157600080fd5b505af115801561040c573d6000803e3d6000fd5b603c816060015167ffffffffffffffff16101515156108d357600080fd5b60008281526003602090815260409182902083518154600160a060020a0390911673ffffffffffffffffffffffffffffffffffffffff1990911617815581840151600182018054858701516fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000081029482166fffffffffffffffffffffffffffffffff19909316831790911693909317909155606080870151600290940180546080808a015167ffffffffffffffff90811668010000000000000000026fffffffffffffffff0000000000000000199190981667ffffffffffffffff1990931683171696909617909155865189815295860192909252848601929092529083015291517fa9c8dfcda5664a5a124c713e386da27de87432d5b668e79458501eb296389ba7929181900390910190a15050565b60008281526003602052604081208180808080610a2586610b9d565b1515610a3057600080fd5b610a3986610c08565b945084881015610a4857600080fd5b8554600160a060020a03169350610a5e89610c98565b6000851115610ab057610a7085610ce5565b6040519093508386039250600160a060020a0385169083156108fc029084906000818181858888f19350505050158015610aae573d6000803e3d6000fd5b505b5060405184880390339082156108fc029083906000818181858888f19350505050158015610ae2573d6000803e3d6000fd5b50604080518a815260208101879052338183015290517f4fcc30d90a842164dd58501ab874a101a3749c3d4747139cefe7c876f4ccebd29181900360600190a15092979650505050505050565b600154604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152602482018590529151919092169163a9059cbb91604480830192600092919082900301818387803b1580156108a157600080fd5b6002015460006801000000000000000090910467ffffffffffffffff161190565b610bc782610c98565b610bd18183610b2f565b6040805183815290517f2809c7e17bf978fbc7194c0a694b638c4215e9140cacc6c38ca36010b45697df9181900360200190a15050565b6002810154600090819068010000000000000000900467ffffffffffffffff16421115610c4e5750600282015468010000000000000000900467ffffffffffffffff1642035b60018301546002840154610791916fffffffffffffffffffffffffffffffff80821692700100000000000000000000000000000000909204169067ffffffffffffffff1684610cf1565b6000908152600360205260408120805473ffffffffffffffffffffffffffffffffffffffff19168155600181019190915560020180546fffffffffffffffffffffffffffffffff19169055565b60025461271091020490565b6000808080858510610d0557869350610d23565b878703925085858402811515610d1757fe5b05915081880190508093505b505050949350505050565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152905600a165627a7a723058203c3d7d4039d9d9a82dd65c7bc046590e8fe3580af952a66fe24052959889bef50029" - code_ContractScenario011_deploySiringClockAuction = "60806040526000805460a060020a60ff02191690556004805460ff1916600117905534801561002d57600080fd5b50604051604080610e1a83398101604052805160209091015160008054600160a060020a031916331781558290829061271082111561006b57600080fd5b506002819055604080517f01ffc9a70000000000000000000000000000000000000000000000000000000081527f9a20483d00000000000000000000000000000000000000000000000000000000600482015290518391600160a060020a038316916301ffc9a7916024808201926020929091908290030181600087803b1580156100f557600080fd5b505af1158015610109573d6000803e3d6000fd5b505050506040513d602081101561011f57600080fd5b5051151561012c57600080fd5b60018054600160a060020a03909216600160a060020a031990921691909117905550505050610cba806101606000396000f3006080604052600436106100da5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166327ebe40a81146100df5780633f4ba83a1461010e578063454a2ab3146101375780635c975abb146101425780635fd8c7101461015757806376190f8f1461016c57806378bd79351461018157806383b5ff8b146101ce5780638456cb59146101f5578063878eb3681461020a5780638da5cb5b1461022257806396b5a75514610253578063c55d0f561461026b578063dd1b7a0f14610283578063f2fde38b14610298575b600080fd5b3480156100eb57600080fd5b5061010c600435602435604435606435600160a060020a03608435166102b9565b005b34801561011a57600080fd5b506101236103b1565b604080519115158252519081900360200190f35b61010c60043561042c565b34801561014e57600080fd5b50610123610478565b34801561016357600080fd5b5061010c610488565b34801561017857600080fd5b506101236104e5565b34801561018d57600080fd5b506101996004356104ee565b60408051600160a060020a03909616865260208601949094528484019290925260608401526080830152519081900360a00190f35b3480156101da57600080fd5b506101e3610584565b60408051918252519081900360200190f35b34801561020157600080fd5b5061012361058a565b34801561021657600080fd5b5061010c60043561060a565b34801561022e57600080fd5b50610237610673565b60408051600160a060020a039092168252519081900360200190f35b34801561025f57600080fd5b5061010c600435610682565b34801561027757600080fd5b506101e36004356106cc565b34801561028f57600080fd5b506102376106fe565b3480156102a457600080fd5b5061010c600160a060020a036004351661070d565b6102c1610c60565b6fffffffffffffffffffffffffffffffff851685146102df57600080fd5b6fffffffffffffffffffffffffffffffff841684146102fd57600080fd5b67ffffffffffffffff8316831461031357600080fd5b600154600160a060020a0316331461032a57600080fd5b610334828761075f565b60a06040519081016040528083600160a060020a03168152602001866fffffffffffffffffffffffffffffffff168152602001856fffffffffffffffffffffffffffffffff1681526020018467ffffffffffffffff1681526020014267ffffffffffffffff1681525090506103a986826107e7565b505050505050565b60008054600160a060020a031633146103c957600080fd5b60005460a060020a900460ff1615156103e157600080fd5b6000805474ff0000000000000000000000000000000000000000191681556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b339190a150600190565b600154600090600160a060020a0316331461044657600080fd5b50600081815260036020526040902054600160a060020a0316610469823461093b565b506104748183610a61565b5050565b60005460a060020a900460ff1681565b60015460008054600160a060020a0392831692163314806104b1575033600160a060020a038316145b15156104bc57600080fd5b604051600160a060020a03831690303180156108fc02916000818181858888f150505050505050565b60045460ff1681565b6000818152600360205260408120819081908190819061050d81610acf565b151561051857600080fd5b80546001820154600290920154600160a060020a03909116986fffffffffffffffffffffffffffffffff8084169950700100000000000000000000000000000000909304909216965067ffffffffffffffff808216965068010000000000000000909104169350915050565b60025481565b60008054600160a060020a031633146105a257600080fd5b60005460a060020a900460ff16156105b957600080fd5b6000805474ff0000000000000000000000000000000000000000191660a060020a1781556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff6259190a150600190565b6000805460a060020a900460ff16151561062357600080fd5b600054600160a060020a0316331461063a57600080fd5b50600081815260036020526040902061065281610acf565b151561065d57600080fd5b8054610474908390600160a060020a0316610af0565b600054600160a060020a031681565b60008181526003602052604081209061069a82610acf565b15156106a557600080fd5b508054600160a060020a03163381146106bd57600080fd5b6106c78382610af0565b505050565b60008181526003602052604081206106e381610acf565b15156106ee57600080fd5b6106f781610b3a565b9392505050565b600154600160a060020a031681565b600054600160a060020a0316331461072457600080fd5b600160a060020a0381161561075c576000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b600154604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015230602483015260448201859052915191909216916323b872dd91606480830192600092919082900301818387803b1580156107d357600080fd5b505af11580156103a9573d6000803e3d6000fd5b603c816060015167ffffffffffffffff161015151561080557600080fd5b60008281526003602090815260409182902083518154600160a060020a0390911673ffffffffffffffffffffffffffffffffffffffff1990911617815581840151600182018054858701516fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000081029482166fffffffffffffffffffffffffffffffff19909316831790911693909317909155606080870151600290940180546080808a015167ffffffffffffffff90811668010000000000000000026fffffffffffffffff0000000000000000199190981667ffffffffffffffff1990931683171696909617909155865189815295860192909252848601929092529083015291517fa9c8dfcda5664a5a124c713e386da27de87432d5b668e79458501eb296389ba7929181900390910190a15050565b6000828152600360205260408120818080808061095786610acf565b151561096257600080fd5b61096b86610b3a565b94508488101561097a57600080fd5b8554600160a060020a0316935061099089610bca565b60008511156109e2576109a285610c17565b6040519093508386039250600160a060020a0385169083156108fc029084906000818181858888f193505050501580156109e0573d6000803e3d6000fd5b505b5060405184880390339082156108fc029083906000818181858888f19350505050158015610a14573d6000803e3d6000fd5b50604080518a815260208101879052338183015290517f4fcc30d90a842164dd58501ab874a101a3749c3d4747139cefe7c876f4ccebd29181900360600190a15092979650505050505050565b600154604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152602482018590529151919092169163a9059cbb91604480830192600092919082900301818387803b1580156107d357600080fd5b6002015460006801000000000000000090910467ffffffffffffffff161190565b610af982610bca565b610b038183610a61565b6040805183815290517f2809c7e17bf978fbc7194c0a694b638c4215e9140cacc6c38ca36010b45697df9181900360200190a15050565b6002810154600090819068010000000000000000900467ffffffffffffffff16421115610b805750600282015468010000000000000000900467ffffffffffffffff1642035b600183015460028401546106f7916fffffffffffffffffffffffffffffffff80821692700100000000000000000000000000000000909204169067ffffffffffffffff1684610c23565b6000908152600360205260408120805473ffffffffffffffffffffffffffffffffffffffff19168155600181019190915560020180546fffffffffffffffffffffffffffffffff19169055565b60025461271091020490565b6000808080858510610c3757869350610c55565b878703925085858402811515610c4957fe5b05915081880190508093505b505050949350505050565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152905600a165627a7a723058208d1842c4569ecc7005642ae981f6c77b856b1d9a921f3792bdb4219144ae25e00029" - code_ContractScenario011_deployGeneScienceInterface = "608060405234801561001057600080fd5b5060dc8061001f6000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630d9f5aed8114604d57806354c15b8214607a575b600080fd5b348015605857600080fd5b50606860043560243560443560a0565b60408051918252519081900360200190f35b348015608557600080fd5b50608c60ab565b604080519115158252519081900360200190f35b600292909101010490565b6001905600a165627a7a72305820d9550024d511527e5124d542daf0a0f3168b9bece6a238bcbccba8b61d3f0bdb0029" - code_WalletTestAccount012_storageAndCpu = "608060405234801561001057600080fd5b5061045c806100206000396000f30060806040526004361061006d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806304c58438146100725780634f2be91f1461009f578063812db772146100b657806393cd5755146100e3578063d1cd64e914610189575b600080fd5b34801561007e57600080fd5b5061009d600480360381019080803590602001909291905050506101a0565b005b3480156100ab57600080fd5b506100b4610230565b005b3480156100c257600080fd5b506100e1600480360381019080803590602001909291905050506102a2565b005b3480156100ef57600080fd5b5061010e600480360381019080803590602001909291905050506102c3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014e578082015181840152602081019050610133565b50505050905090810190601f16801561017b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019557600080fd5b5061019e61037e565b005b6000600190505b8181101561022c5760008060018154018082558091505090600182039060005260206000200160006040805190810160405280600881526020017f31323334353637380000000000000000000000000000000000000000000000008152509091909150908051906020019061021d92919061038b565b505080806001019150506101a7565b5050565b60008060018154018082558091505090600182039060005260206000200160006040805190810160405280600881526020017f61626364656667680000000000000000000000000000000000000000000000008152509091909150908051906020019061029e92919061038b565b5050565b6000600190505b81811115156102bf5780806001019150506102a9565b5050565b6000818154811015156102d257fe5b906000526020600020016000915090508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103765780601f1061034b57610100808354040283529160200191610376565b820191906000526020600020905b81548152906001019060200180831161035957829003601f168201915b505050505081565b6000808060010191505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106103cc57805160ff19168380011785556103fa565b828001600101855582156103fa579182015b828111156103f95782518255916020019190600101906103de565b5b509050610407919061040b565b5090565b61042d91905b80821115610429576000816000905550600101610411565b5090565b905600a165627a7a7230582087d9880a135295a17100f63b8941457f4369204d3ccc9ce4a1abf99820eb68480029" - code_TestExceptionCodeAndAbi_testtimeout = "6080604052600060035534801561001557600080fd5b5061027b806100256000396000f3006080604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633755cd3c81146100875780637d965688146100b1578063a05b2577146100c9578063b0d6304d146100e1578063bbe1d75b14610115578063f8a8fd6d1461012a578063fe75faab14610141575b600080fd5b34801561009357600080fd5b5061009f600435610159565b60408051918252519081900360200190f35b3480156100bd57600080fd5b5061009f600435610178565b3480156100d557600080fd5b5061009f600435610198565b3480156100ed57600080fd5b5061009f73ffffffffffffffffffffffffffffffffffffffff600435811690602435166101e2565b34801561012157600080fd5b5061009f6101ff565b34801561013657600080fd5b5061013f610205565b005b34801561014d57600080fd5b5061009f600435610218565b600080548290811061016757fe5b600091825260209091200154905081565b600080805b83811015610191576001918201910161017d565b5092915050565b600080805b838110156101915760008054600181810183559180527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56301829055918201910161019d565b600260209081526000928352604080842090915290825290205481565b60015481565b600380546001019055610216610205565b565b60006102238261022e565b600181905592915050565b600061023c6002830361022e565b6102486001840361022e565b01929150505600a165627a7a7230582077fd7ac1cd0908622d05db388922d485d6f8e3a546590b97ec8398f87f0c8a580029" - code_TestMapBigLongAndNumbers_deployErc721KittyCore = "608060405234801561001057600080fd5b506108e3806100206000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663058294c5811461009d5780630f8286c61461011d57806327e235e3146101b35780634a53ac83146101e65780637d9656881461020757806386b714e21461021f578063931fdba214610234578063babfe8e114610258578063e68c24ae146102bc575b600080fd5b3480156100a957600080fd5b506040805160206004803580820135601f810184900484028501840190955284845261010194369492936024939284019190819084018382808284375094975050509235600160a060020a031693506102e092505050565b60408051600160a060020a039092168252519081900360200190f35b34801561012957600080fd5b5061013e600160a060020a0360043516610310565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610178578181015183820152602001610160565b50505050905090810190601f1680156101a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101bf57600080fd5b506101d4600160a060020a03600435166103aa565b60408051918252519081900360200190f35b3480156101f257600080fd5b5061013e600160a060020a03600435166103bc565b34801561021357600080fd5b506101d4600435610422565b34801561022b57600080fd5b5061013e610442565b34801561024057600080fd5b50610101600160a060020a036004351660243561049d565b34801561026457600080fd5b506040805160206004803580820135601f810184900484028501840190955284845261010194369492936024939284019190819084018382808284375094975050509235600160a060020a0316935061066892505050565b3480156102c857600080fd5b50610101600435600160a060020a0360243516610690565b600160a060020a03811660009081526002602090815260408220845161030892860190610790565b509092915050565b60016020818152600092835260409283902080548451600294821615610100026000190190911693909304601f81018390048302840183019094528383529192908301828280156103a25780601f10610377576101008083540402835291602001916103a2565b820191906000526020600020905b81548152906001019060200180831161038557829003601f168201915b505050505081565b60006020819052908152604090205481565b600260208181526000928352604092839020805484516001821615610100026000190190911693909304601f81018390048302840183019094528383529192908301828280156103a25780601f10610377576101008083540402835291602001916103a2565b600080805b8381101561043b5760019182019101610427565b5092915050565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103a25780601f10610377576101008083540402835291602001916103a2565b6040805180820190915260018082527f6100000000000000000000000000000000000000000000000000000000000000602090920191825260009182916104e691600391610790565b50600090505b82811015610619576003805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181526105fc9361058e93919290918301828280156105845780601f1061055957610100808354040283529160200191610584565b820191906000526020600020905b81548152906001019060200180831161056757829003601f168201915b50505050506106af565b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526105f093909290918301828280156105845780601f1061055957610100808354040283529160200191610584565b9063ffffffff6106d516565b805161061091600391602090910190610790565b506001016104ec565b60036001600086600160a060020a0316600160a060020a03168152602001908152602001600020908054600181600116156101000203166002900461065f92919061080e565b50929392505050565b600160a060020a03811660009081526001602090815260408220845161030892860190610790565b600160a060020a03811660009081526020819052604090209190915590565b6106b7610883565b50604080518082019091528151815260209182019181019190915290565b606080600083600001518560000151016040519080825280601f01601f191660200182016040528015610712578160200160208202803883390190505b50915060208201905061072e818660200151876000015161074c565b845160208501518551610744928401919061074c565b509392505050565b60005b60208210610771578251845260209384019390920191601f199091019061074f565b50905182516020929092036101000a6000190180199091169116179052565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106107d157805160ff19168380011785556107fe565b828001600101855582156107fe579182015b828111156107fe5782518255916020019190600101906107e3565b5061080a92915061089a565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061084757805485556107fe565b828001600101855582156107fe57600052602060002091601f016020900482015b828111156107fe578254825591600101919060010190610868565b604080518082019091526000808252602082015290565b6108b491905b8082111561080a57600081556001016108a0565b905600a165627a7a72305820f826fbe07a4ee048e7cd47a00e3ca43677011f846fb9e00e1f8202a84a5159540029" - code_TestNetErc721Cat_deployErc721KittyCore = "6002805460a060020a60ff0219169055610240604052603c6080908152607860a05261012c60c05261025860e05261070861010052610e1061012052611c2061014052613840610160526170806101805261e1006101a052620151806101c0526202a3006101e052620546006102005262093a80610220526200008790600390600e620004e3565b50600f6005556301312d00600e55348015620000a257600080fd5b506002805460008054600160a060020a031990811633908117835560a060020a60ff0219909316740100000000000000000000000000000000000000001716909117909155620001019080806000198164010000000062000108810204565b50620005f1565b6000806200011562000586565b600063ffffffff891689146200012a57600080fd5b63ffffffff881688146200013d57600080fd5b61ffff871687146200014e57600080fd5b600287049250600d8361ffff1611156200016757600d92505b505060408051610100810182528581524267ffffffffffffffff90811660208301908152600093830184815263ffffffff8c8116606086019081528c82166080870190815260a0870188815261ffff8a811660c08a019081528f821660e08b01908152600680546001810182559c528a517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f60028e029081019190915598517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d40909901805498519651955194519251915167ffffffffffffffff19909916998b1699909917604060020a608060020a0319166801000000000000000096909a169590950298909817608060020a63ffffffff021916700100000000000000000000000000000000938616939093029290921760a060020a63ffffffff02191674010000000000000000000000000000000000000000918516919091021760c060020a63ffffffff0219167801000000000000000000000000000000000000000000000000968416969096029590951760e060020a61ffff0219167c01000000000000000000000000000000000000000000000000000000009186169190910217600160f060020a03167e010000000000000000000000000000000000000000000000000000000000009290941691909102929092179055909190811681146200036f57600080fd5b606080830151608080850151855160408051600160a060020a038c1681526020810188905263ffffffff95861681830152929094169482019490945290810192909252517f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad59181900360a00190a1620003f46000868364010000000062000400810204565b98975050505050505050565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a03191690911790558316156200049457600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b60408051600160a060020a0380861682528416602082015280820183905290517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360600190a1505050565b600283019183908215620005745791602002820160005b838211156200054057835183826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302620004fa565b8015620005725782816101000a81549063ffffffff021916905560040160208160030104928301926001030262000540565b505b5062000582929150620005ca565b5090565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915290565b620005ee91905b808211156200058257805463ffffffff19168155600101620005d1565b90565b6130f380620006016000396000f3006080604052600436106102a55763ffffffff60e060020a60003504166301ffc9a781146102d55780630519ce79146103205780630560ff441461035157806305e45546146103ea57806306fdde0314610411578063095ea7b3146104265780630a0f81681461044a5780630e583df01461045f57806314001f4c1461047457806318160ddd14610495578063183a7947146104aa5780631940a936146104bf57806319c2f201146104d757806321717ebf146104ec57806323b872dd1461050157806324e7a38a1461052b57806327d7874c1461054c5780632ba73c151461056d5780633d7d3f5a1461058e5780633f4ba83a146105af57806346116e6f146105c457806346d22c70146105dc578063481af3d3146105f75780634ad8c9381461060f5780634b85fd55146106305780634dfff04f146106485780634e0a33791461066c578063561291341461068d5780635663896e146106b15780635c975abb146106c95780635fd8c710146106de5780636352211e146106f3578063680eba271461070b5780636af04a57146107205780636fbde40d1461073557806370a082311461075657806371587988146107775780637a7d4937146107985780638456cb59146107ad5780638462151c146107c257806388c2a0bf1461083357806391876e571461084b57806395d89b41146108605780639d6fac6f14610875578063a45f4bfc146108a6578063a9059cbb146108be578063b047fb50146108e2578063b0c35c05146108f7578063bc4006f51461090c578063c3bea9af14610921578063d3e6f49f14610939578063defb958414610951578063e17b25af14610966578063e6cbe35114610987578063e98b7f4d1461099c578063ed60ade614610a06578063f1ca941014610a14578063f2b47d5214610a29578063f7d8c88314610a3e575b600b54600160a060020a03163314806102c85750600c54600160a060020a031633145b15156102d357600080fd5b005b3480156102e157600080fd5b5061030c7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1960043516610a4c565b604080519115158252519081900360200190f35b34801561032c57600080fd5b50610335610cdf565b60408051600160a060020a039092168252519081900360200190f35b34801561035d57600080fd5b50610375600480359060248035908101910135610cee565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103af578181015183820152602001610397565b50505050905090810190601f1680156103dc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f657600080fd5b506103ff610df1565b60408051918252519081900360200190f35b34801561041d57600080fd5b50610375610df7565b34801561043257600080fd5b506102d3600160a060020a0360043516602435610e2e565b34801561045657600080fd5b50610335610eb0565b34801561046b57600080fd5b506103ff610ebf565b34801561048057600080fd5b506102d3600160a060020a0360043516610ec6565b3480156104a157600080fd5b506103ff610f79565b3480156104b657600080fd5b506103ff610f83565b3480156104cb57600080fd5b5061030c600435610f89565b3480156104e357600080fd5b506103ff610fce565b3480156104f857600080fd5b50610335610fd5565b34801561050d57600080fd5b506102d3600160a060020a0360043581169060243516604435610fe4565b34801561053757600080fd5b506102d3600160a060020a0360043516611060565b34801561055857600080fd5b506102d3600160a060020a0360043516611113565b34801561057957600080fd5b506102d3600160a060020a0360043516611161565b34801561059a57600080fd5b506102d36004356024356044356064356111af565b3480156105bb57600080fd5b506102d36112a4565b3480156105d057600080fd5b50610335600435611338565b3480156105e857600080fd5b5061030c600435602435611353565b34801561060357600080fd5b506103356004356113d3565b34801561061b57600080fd5b506102d36004356024356044356064356113ee565b34801561063c57600080fd5b506102d36004356114c6565b34801561065457600080fd5b506102d3600160a060020a03600435166024356114e2565b34801561067857600080fd5b506102d3600160a060020a036004351661153c565b34801561069957600080fd5b506102d3600435600160a060020a036024351661158a565b3480156106bd57600080fd5b506102d36004356115f1565b3480156106d557600080fd5b5061030c61164d565b3480156106ea57600080fd5b506102d361165d565b3480156106ff57600080fd5b506103356004356116c1565b34801561071757600080fd5b506103ff6116e5565b34801561072c57600080fd5b506103356116eb565b34801561074157600080fd5b506102d3600160a060020a03600435166116fa565b34801561076257600080fd5b506103ff600160a060020a03600435166117ad565b34801561078357600080fd5b506102d3600160a060020a03600435166117c8565b3480156107a457600080fd5b506103ff61184b565b3480156107b957600080fd5b506102d3611851565b3480156107ce57600080fd5b506107e3600160a060020a03600435166118d1565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561081f578181015183820152602001610807565b505050509050019250505060405180910390f35b34801561083f57600080fd5b506103ff6004356119a3565b34801561085757600080fd5b506102d3611c7f565b34801561086c57600080fd5b50610375611d94565b34801561088157600080fd5b5061088d600435611dcb565b6040805163ffffffff9092168252519081900360200190f35b3480156108b257600080fd5b50610335600435611df8565b3480156108ca57600080fd5b506102d3600160a060020a0360043516602435611e13565b3480156108ee57600080fd5b50610335611eab565b34801561090357600080fd5b506103ff611eba565b34801561091857600080fd5b50610335611ec0565b34801561092d57600080fd5b506102d3600435611ecf565b34801561094557600080fd5b5061030c600435611fb9565b34801561095d57600080fd5b506103ff612088565b34801561097257600080fd5b506102d3600160a060020a036004351661208e565b34801561099357600080fd5b506103356120c7565b3480156109a857600080fd5b506109b46004356120d6565b604080519a15158b5298151560208b0152898901979097526060890195909552608088019390935260a087019190915260c086015260e085015261010084015261012083015251908190036101400190f35b6102d3600435602435612237565b348015610a2057600080fd5b506103ff6123d1565b348015610a3557600080fd5b506103356123d7565b6102d36004356024356123e6565b604080517f737570706f727473496e74657266616365286279746573342900000000000000815290519081900360190190206000907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1983811691161480610cd75750604080517f746f6b656e4d657461646174612875696e743235362c737472696e67290000008152815190819003601d0181207f746f6b656e734f664f776e657228616464726573732900000000000000000000825282519182900360160182207f7472616e7366657246726f6d28616464726573732c616464726573732c75696e83527f7432353629000000000000000000000000000000000000000000000000000000602084015283519283900360250183207f7472616e7366657228616464726573732c75696e743235362900000000000000845284519384900360190184207f617070726f766528616464726573732c75696e74323536290000000000000000855285519485900360180185207f6f776e65724f662875696e743235362900000000000000000000000000000000865286519586900360100186207f62616c616e63654f662861646472657373290000000000000000000000000000875287519687900360120187207f746f74616c537570706c792829000000000000000000000000000000000000008852885197889003600d0188207f73796d626f6c2829000000000000000000000000000000000000000000000000895289519889900360080189207f6e616d65282900000000000000000000000000000000000000000000000000008a529951988990036006019098207bffffffffffffffffffffffffffffffffffffffffffffffffffffffff198c811691909a189098181818181818181891909116145b90505b919050565b600154600160a060020a031681565b6060610cf8613064565b600d54600090600160a060020a03161515610d1257600080fd5b600d54604080517fcb4799f2000000000000000000000000000000000000000000000000000000008152600481018981526024820192835260448201889052600160a060020a039093169263cb4799f2928a928a928a929091606401848480828437820191505094505050505060a060405180830381600087803b158015610d9957600080fd5b505af1158015610dad573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525060a0811015610dd257600080fd5b5060808101519092509050610de782826125e4565b9695505050505050565b60115481565b60408051808201909152600d81527f43727970746f4b69747469657300000000000000000000000000000000000000602082015281565b60025460a060020a900460ff1615610e4557600080fd5b610e4f3382612638565b1515610e5a57600080fd5b610e648183612658565b60408051338152600160a060020a038416602082015280820183905290517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259181900360600190a15050565b600054600160a060020a031681565b6298968081565b60008054600160a060020a03163314610ede57600080fd5b81905080600160a060020a03166376190f8f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610f1f57600080fd5b505af1158015610f33573d6000803e3d6000fd5b505050506040513d6020811015610f4957600080fd5b50511515610f5657600080fd5b600c8054600160a060020a031916600160a060020a039290921691909117905550565b6006546000190190565b600f5481565b6000808211610f9757600080fd5b6006805483908110610fa557fe5b600091825260209091206002909102016001015460c060020a900463ffffffff16151592915050565b6201518081565b600c54600160a060020a031681565b60025460a060020a900460ff1615610ffb57600080fd5b600160a060020a038216151561101057600080fd5b600160a060020a03821630141561102657600080fd5b6110303382612686565b151561103b57600080fd5b6110458382612638565b151561105057600080fd5b61105b8383836126a6565b505050565b60008054600160a060020a0316331461107857600080fd5b81905080600160a060020a03166354c15b826040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156110b957600080fd5b505af11580156110cd573d6000803e3d6000fd5b505050506040513d60208110156110e357600080fd5b505115156110f057600080fd5b60108054600160a060020a031916600160a060020a039290921691909117905550565b600054600160a060020a0316331461112a57600080fd5b600160a060020a038116151561113f57600080fd5b60008054600160a060020a031916600160a060020a0392909216919091179055565b600054600160a060020a0316331461117857600080fd5b600160a060020a038116151561118d57600080fd5b60028054600160a060020a031916600160a060020a0392909216919091179055565b60025460a060020a900460ff16156111c657600080fd5b6111d03385612638565b15156111db57600080fd5b6111e484610f89565b156111ee57600080fd5b600b54611205908590600160a060020a0316612658565b600b54604080517f27ebe40a000000000000000000000000000000000000000000000000000000008152600481018790526024810186905260448101859052606481018490523360848201529051600160a060020a03909216916327ebe40a9160a48082019260009290919082900301818387803b15801561128657600080fd5b505af115801561129a573d6000803e3d6000fd5b5050505050505050565b600054600160a060020a031633146112bb57600080fd5b60025460a060020a900460ff1615156112d357600080fd5b600b54600160a060020a031615156112ea57600080fd5b600c54600160a060020a0316151561130157600080fd5b601054600160a060020a0316151561131857600080fd5b601354600160a060020a03161561132e57600080fd5b611336612788565b565b600a60205260009081526040902054600160a060020a031681565b6000808080851161136357600080fd5b6000841161137057600080fd5b600680548690811061137e57fe5b9060005260206000209060020201915060068481548110151561139d57fe5b906000526020600020906002020190506113b9828683876127d7565b80156113ca57506113ca8486612957565b95945050505050565b600960205260009081526040902054600160a060020a031681565b60025460a060020a900460ff161561140557600080fd5b61140f3385612638565b151561141a57600080fd5b61142384611fb9565b151561142e57600080fd5b600c54611445908590600160a060020a0316612658565b600c54604080517f27ebe40a000000000000000000000000000000000000000000000000000000008152600481018790526024810186905260448101859052606481018490523360848201529051600160a060020a03909216916327ebe40a9160a48082019260009290919082900301818387803b15801561128657600080fd5b600254600160a060020a031633146114dd57600080fd5b600e55565b60025460a060020a900460ff16156114f957600080fd5b6115033382612638565b151561150e57600080fd5b6000908152600a602052604090208054600160a060020a031916600160a060020a0392909216919091179055565b600054600160a060020a0316331461155357600080fd5b600160a060020a038116151561156857600080fd5b60018054600160a060020a031916600160a060020a0392909216919091179055565b600254600090600160a060020a031633146115a457600080fd5b5080600160a060020a03811615156115c45750600254600160a060020a03165b601154611388116115d457600080fd5b6011805460010190556115eb6000808086856129ac565b50505050565b600254600160a060020a03163314806116145750600054600160a060020a031633145b806116295750600154600160a060020a031633145b151561163457600080fd5b60035463ffffffff16811061164857600080fd5b600555565b60025460a060020a900460ff1681565b6001546000908190600160a060020a0316331461167957600080fd5b5050600e54600f54303191600190910102808211156116bd57600154604051600160a060020a039091169082840380156108fc02916000818181858888f150505050505b5050565b600081815260076020526040902054600160a060020a0316801515610cda57600080fd5b61afc881565b601354600160a060020a031681565b60008054600160a060020a0316331461171257600080fd5b81905080600160a060020a03166385b861886040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561175357600080fd5b505af1158015611767573d6000803e3d6000fd5b505050506040513d602081101561177d57600080fd5b5051151561178a57600080fd5b600b8054600160a060020a031916600160a060020a039290921691909117905550565b600160a060020a031660009081526008602052604090205490565b600054600160a060020a031633146117df57600080fd5b60025460a060020a900460ff1615156117f757600080fd5b60138054600160a060020a038316600160a060020a0319909116811790915560408051918252517f450db8da6efbe9c22f2347f7c2021231df1fc58d3ae9a2fa75d39fa4461993059181900360200190a150565b60055481565b600254600160a060020a03163314806118745750600054600160a060020a031633145b806118895750600154600160a060020a031633145b151561189457600080fd5b60025460a060020a900460ff16156118ab57600080fd5b6002805474ff0000000000000000000000000000000000000000191660a060020a179055565b60606000606060008060006118e5876117ad565b9450841515611904576040805160008152602081019091529550611999565b8460405190808252806020026020018201604052801561192e578160200160208202803883390190505b509350611939610f79565b925060009150600190505b82811161199557600081815260076020526040902054600160a060020a038881169116141561198d5780848381518110151561197c57fe5b602090810290910101526001909101905b600101611944565b8395505b5050505050919050565b600080600080600080600080600260149054906101000a900460ff161515156119cb57600080fd5b600680548a9081106119d957fe5b60009182526020909120600290910201600181015490975067ffffffffffffffff161515611a0657600080fd5b604080516101008101825288548152600189015467ffffffffffffffff8082166020840152680100000000000000008204169282019290925263ffffffff608060020a83048116606083015260a060020a83048116608083015260c060020a83041660a082015261ffff60e060020a8304811660c083015260f060020a90920490911660e0820152611a9790612c89565b1515611aa257600080fd5b60018701546006805460c060020a90920463ffffffff1697509087908110611ac657fe5b600091825260209091206001808a015460029093029091019081015490965061ffff60f060020a928390048116965091900416841015611b1357600185015460f060020a900461ffff1693505b6010548754865460018a0154604080517f0d9f5aed0000000000000000000000000000000000000000000000000000000081526004810194909452602484019290925260001967ffffffffffffffff6801000000000000000090920482160116604483015251600160a060020a0390921691630d9f5aed916064808201926020929091908290030181600087803b158015611bad57600080fd5b505af1158015611bc1573d6000803e3d6000fd5b505050506040513d6020811015611bd757600080fd5b505160008a815260076020526040902054600189810154929550600160a060020a039091169350611c20918b9160c060020a90910463ffffffff1690870161ffff1686866129ac565b6001880180547bffffffff00000000000000000000000000000000000000000000000019169055600f8054600019019055600e54604051919250339181156108fc0291906000818181858888f150939c9b505050505050505050505050565b600254600160a060020a0316331480611ca25750600054600160a060020a031633145b80611cb75750600154600160a060020a031633145b1515611cc257600080fd5b600b60009054906101000a9004600160a060020a0316600160a060020a0316635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b158015611d1557600080fd5b505af1158015611d29573d6000803e3d6000fd5b50505050600c60009054906101000a9004600160a060020a0316600160a060020a0316635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b158015611d8057600080fd5b505af11580156115eb573d6000803e3d6000fd5b60408051808201909152600281527f434b000000000000000000000000000000000000000000000000000000000000602082015281565b600381600e8110611dd857fe5b60089182820401919006600402915054906101000a900463ffffffff1681565b600760205260009081526040902054600160a060020a031681565b60025460a060020a900460ff1615611e2a57600080fd5b600160a060020a0382161515611e3f57600080fd5b600160a060020a038216301415611e5557600080fd5b600b54600160a060020a0383811691161415611e7057600080fd5b600c54600160a060020a0383811691161415611e8b57600080fd5b611e953382612638565b1515611ea057600080fd5b6116bd3383836126a6565b600254600160a060020a031681565b600e5481565b600d54600160a060020a031681565b600254600090600160a060020a03163314611ee957600080fd5b60125461afc811611ef957600080fd5b611f08600080600085306129ac565b600b54909150611f22908290600160a060020a0316612658565b600b54600160a060020a03166327ebe40a82611f3c612cb9565b6040805160e060020a63ffffffff861602815260048101939093526024830191909152600060448301819052620151806064840152306084840152905160a48084019382900301818387803b158015611f9457600080fd5b505af1158015611fa8573d6000803e3d6000fd5b505060128054600101905550505050565b600080808311611fc857600080fd5b6006805484908110611fd657fe5b60009182526020918290206040805161010081018252600290930290910180548352600181015467ffffffffffffffff808216958501959095526801000000000000000081049094169183019190915263ffffffff608060020a84048116606084015260a060020a84048116608084015260c060020a84041660a083015261ffff60e060020a8404811660c084015260f060020a90930490921660e082015290915061208190612d7b565b9392505050565b61138881565b600054600160a060020a031633146120a557600080fd5b600d8054600160a060020a031916600160a060020a0392909216919091179055565b600b54600160a060020a031681565b600080600080600080600080600080600060068c8154811015156120f657fe5b906000526020600020906002020190508060010160189054906101000a900463ffffffff1663ffffffff16600014159a50438160010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff161115995080600101601c9054906101000a900461ffff1661ffff1698508060010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff1697508060010160189054906101000a900463ffffffff1663ffffffff1696508060010160009054906101000a900467ffffffffffffffff1667ffffffffffffffff1695508060010160109054906101000a900463ffffffff1663ffffffff1694508060010160149054906101000a900463ffffffff1663ffffffff16935080600101601e9054906101000a900461ffff1661ffff16925080600001549150509193959799509193959799565b60025460009060a060020a900460ff161561225157600080fd5b61225b3383612638565b151561226657600080fd5b61226f82611fb9565b151561227a57600080fd5b6122848284612daa565b151561228f57600080fd5b600c54604080517fc55d0f56000000000000000000000000000000000000000000000000000000008152600481018690529051600160a060020a039092169163c55d0f56916024808201926020929091908290030181600087803b1580156122f657600080fd5b505af115801561230a573d6000803e3d6000fd5b505050506040513d602081101561232057600080fd5b5051600e54909150810134101561233657600080fd5b600c54600e54604080517f454a2ab3000000000000000000000000000000000000000000000000000000008152600481018790529051600160a060020a039093169263454a2ab39234039160248082019260009290919082900301818588803b1580156123a257600080fd5b505af11580156123b6573d6000803e3d6000fd5b505050505061105b8263ffffffff168463ffffffff16612df9565b60125481565b601054600160a060020a031681565b600254600090819060a060020a900460ff161561240257600080fd5b600e5434101561241157600080fd5b61241b3385612638565b151561242657600080fd5b6124308385612957565b151561243b57600080fd5b600680548590811061244957fe5b60009182526020918290206040805161010081018252600290930290910180548352600181015467ffffffffffffffff808216958501959095526801000000000000000081049094169183019190915263ffffffff608060020a84048116606084015260a060020a84048116608084015260c060020a84041660a083015261ffff60e060020a8404811660c084015260f060020a90930490921660e08201529092506124f490612d7b565b15156124ff57600080fd5b600680548490811061250d57fe5b60009182526020918290206040805161010081018252600290930290910180548352600181015467ffffffffffffffff808216958501959095526801000000000000000081049094169183019190915263ffffffff608060020a84048116606084015260a060020a84048116608084015260c060020a84041660a083015261ffff60e060020a8404811660c084015260f060020a90930490921660e08201529091506125b890612d7b565b15156125c357600080fd5b6125cf828583866127d7565b15156125da57600080fd5b6115eb8484612df9565b606080600080846040519080825280601f01601f191660200182016040528015612618578160200160208202803883390190505b509250506020820190508461262e828287612f37565b5090949350505050565b600090815260076020526040902054600160a060020a0391821691161490565b6000918252600960205260409091208054600160a060020a031916600160a060020a03909216919091179055565b600090815260096020526040902054600160a060020a0391821691161490565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a031916909117905583161561273957600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b60408051600160a060020a0380861682528416602082015280820183905290517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360600190a1505050565b600054600160a060020a0316331461279f57600080fd5b60025460a060020a900460ff1615156127b757600080fd5b6002805474ff000000000000000000000000000000000000000019169055565b6000818414156127e95750600061294f565b6001850154608060020a900463ffffffff168214806128185750600185015460a060020a900463ffffffff1682145b156128255750600061294f565b6001830154608060020a900463ffffffff168414806128545750600183015460a060020a900463ffffffff1684145b156128615750600061294f565b6001830154608060020a900463ffffffff16158061288e57506001850154608060020a900463ffffffff16155b1561289b5750600161294f565b60018581015490840154608060020a9182900463ffffffff908116929091041614806128e6575060018086015490840154608060020a900463ffffffff90811660a060020a90920416145b156128f35750600061294f565b6001808601549084015460a060020a900463ffffffff908116608060020a90920416148061293e57506001858101549084015460a060020a9182900463ffffffff9081169290910416145b1561294b5750600061294f565b5060015b949350505050565b6000818152600760205260408082205484835290822054600160a060020a039182169116808214806113ca57506000858152600a6020526040902054600160a060020a03908116908316149250505092915050565b6000806129b7613083565b600063ffffffff891689146129cb57600080fd5b63ffffffff881688146129dd57600080fd5b61ffff871687146129ed57600080fd5b600287049250600d8361ffff161115612a0557600d92505b505060408051610100810182528581524267ffffffffffffffff90811660208301908152600093830184815263ffffffff8c8116606086019081528c82166080870190815260a0870188815261ffff8a811660c08a019081528f821660e08b01908152600680546001810182559c528a517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f60028e029081019190915598517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d40909901805498519651955194519251915167ffffffffffffffff19909916998b16999099176fffffffffffffffff000000000000000019166801000000000000000096909a16959095029890981773ffffffff000000000000000000000000000000001916608060020a938616939093029290921777ffffffff0000000000000000000000000000000000000000191660a060020a91851691909102177bffffffff000000000000000000000000000000000000000000000000191660c060020a96841696909602959095177fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff1660e060020a91861691909102177dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1660f060020a929094169190910292909217905590919081168114612c0357600080fd5b606080830151608080850151855160408051600160a060020a038c1681526020810188905263ffffffff95861681830152929094169482019490945290810192909252517f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad59181900360a00190a1612c7d600086836126a6565b98975050505050505050565b60008160a0015163ffffffff16600014158015610cd75750506040015167ffffffffffffffff4381169116111590565b6000806000600b60009054906101000a9004600160a060020a0316600160a060020a031663eac9d94c6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015612d1157600080fd5b505af1158015612d25573d6000803e3d6000fd5b505050506040513d6020811015612d3b57600080fd5b505191506fffffffffffffffffffffffffffffffff82168214612d5d57600080fd5b5060028104810162989680811015612d755750629896805b92915050565b60008160a0015163ffffffff166000148015610cd75750506040015167ffffffffffffffff4381169116111590565b6000806000600685815481101515612dbe57fe5b90600052602060002090600202019150600684815481101515612ddd57fe5b906000526020600020906002020190506113ca828683876127d7565b600080600683815481101515612e0b57fe5b90600052602060002090600202019150600684815481101515612e2a57fe5b600091825260209091206002909102016001810180547bffffffff000000000000000000000000000000000000000000000000191660c060020a63ffffffff8716021790559050612e7a82612f7b565b612e8381612f7b565b6000848152600a602090815260408083208054600160a060020a031990811690915586845281842080549091169055600f80546001908101909155878452600783529281902054928401548151600160a060020a0390941684529183018790528281018690526801000000000000000090910467ffffffffffffffff166060830152517f241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80916080908290030190a150505050565b60005b60208210612f5c578251845260209384019390920191601f1990910190612f3a565b50905182516020929092036101000a6000190180199091169116179052565b600554600182015443919060039060e060020a900461ffff16600e8110612f9e57fe5b600891828204019190066004029054906101000a900463ffffffff1663ffffffff16811515612fc957fe5b6001840180546fffffffffffffffff0000000000000000191668010000000000000000939092049390930167ffffffffffffffff16919091021790819055600d60e060020a90910461ffff161015613061576001818101805461ffff60e060020a8083048216909401169092027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092169190911790555b50565b6080604051908101604052806004906020820280388339509192915050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810191909152905600a165627a7a723058201424bf1db41fa7ec76f5506a53d8bbcb84ed5b5a6ade2df0bac8deaacb118a8b0029" - code_TestNetErc721Cat_deploySaleClockAuction = "60806040526000805460a060020a60ff02191690556004805460ff1916600117905534801561002d57600080fd5b50604051604080610ee883398101604052805160209091015160008054600160a060020a031916331781558290829061271082111561006b57600080fd5b506002819055604080517f01ffc9a70000000000000000000000000000000000000000000000000000000081527f9a20483d00000000000000000000000000000000000000000000000000000000600482015290518391600160a060020a038316916301ffc9a7916024808201926020929091908290030181600087803b1580156100f557600080fd5b505af1158015610109573d6000803e3d6000fd5b505050506040513d602081101561011f57600080fd5b5051151561012c57600080fd5b60018054600160a060020a03909216600160a060020a031990921691909117905550505050610d88806101606000396000f3006080604052600436106100fb5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166327ebe40a81146101005780633f4ba83a1461012f578063454a2ab314610158578063484eccb4146101635780635c975abb1461018d5780635fd8c710146101a257806378bd7935146101b757806383b5ff8b146102045780638456cb591461021957806385b861881461022e578063878eb368146102435780638a98a9cc1461025b5780638da5cb5b1461027057806396b5a755146102a1578063c55d0f56146102b9578063dd1b7a0f146102d1578063eac9d94c146102e6578063f2fde38b146102fb575b600080fd5b34801561010c57600080fd5b5061012d600435602435604435606435600160a060020a036084351661031c565b005b34801561013b57600080fd5b50610144610414565b604080519115158252519081900360200190f35b61012d60043561048f565b34801561016f57600080fd5b5061017b6004356104f9565b60408051918252519081900360200190f35b34801561019957600080fd5b5061014461050d565b3480156101ae57600080fd5b5061012d61051d565b3480156101c357600080fd5b506101cf60043561057a565b60408051600160a060020a03909616865260208601949094528484019290925260608401526080830152519081900360a00190f35b34801561021057600080fd5b5061017b610610565b34801561022557600080fd5b50610144610616565b34801561023a57600080fd5b50610144610696565b34801561024f57600080fd5b5061012d60043561069f565b34801561026757600080fd5b5061017b61070c565b34801561027c57600080fd5b50610285610712565b60408051600160a060020a039092168252519081900360200190f35b3480156102ad57600080fd5b5061012d600435610721565b3480156102c557600080fd5b5061017b600435610766565b3480156102dd57600080fd5b50610285610798565b3480156102f257600080fd5b5061017b6107a7565b34801561030757600080fd5b5061012d600160a060020a03600435166107db565b610324610d2e565b6fffffffffffffffffffffffffffffffff8516851461034257600080fd5b6fffffffffffffffffffffffffffffffff8416841461036057600080fd5b67ffffffffffffffff8316831461037657600080fd5b600154600160a060020a0316331461038d57600080fd5b610397828761082d565b60a06040519081016040528083600160a060020a03168152602001866fffffffffffffffffffffffffffffffff168152602001856fffffffffffffffffffffffffffffffff1681526020018467ffffffffffffffff1681526020014267ffffffffffffffff16815250905061040c86826108b5565b505050505050565b60008054600160a060020a0316331461042c57600080fd5b60005460a060020a900460ff16151561044457600080fd5b6000805474ff0000000000000000000000000000000000000000191681556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b339190a150600190565b600081815260036020526040812054600160a060020a0316906104b28334610a09565b90506104be3384610b2f565b600154600160a060020a03838116911614156104f45760058054829160069106600581106104e857fe5b01556005805460010190555b505050565b6006816005811061050657fe5b0154905081565b60005460a060020a900460ff1681565b60015460008054600160a060020a039283169216331480610546575033600160a060020a038316145b151561055157600080fd5b604051600160a060020a03831690303180156108fc02916000818181858888f150505050505050565b6000818152600360205260408120819081908190819061059981610b9d565b15156105a457600080fd5b80546001820154600290920154600160a060020a03909116986fffffffffffffffffffffffffffffffff8084169950700100000000000000000000000000000000909304909216965067ffffffffffffffff808216965068010000000000000000909104169350915050565b60025481565b60008054600160a060020a0316331461062e57600080fd5b60005460a060020a900460ff161561064557600080fd5b6000805474ff0000000000000000000000000000000000000000191660a060020a1781556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff6259190a150600190565b60045460ff1681565b6000805460a060020a900460ff1615156106b857600080fd5b600054600160a060020a031633146106cf57600080fd5b5060008181526003602052604090206106e781610b9d565b15156106f257600080fd5b8054610708908390600160a060020a0316610bbe565b5050565b60055481565b600054600160a060020a031681565b60008181526003602052604081209061073982610b9d565b151561074457600080fd5b508054600160a060020a031633811461075c57600080fd5b6104f48382610bbe565b600081815260036020526040812061077d81610b9d565b151561078857600080fd5b61079181610c08565b9392505050565b600154600160a060020a031681565b600080805b60058110156107d157600681600581106107c257fe5b015491909101906001016107ac565b5060059004919050565b600054600160a060020a031633146107f257600080fd5b600160a060020a0381161561082a576000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b600154604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015230602483015260448201859052915191909216916323b872dd91606480830192600092919082900301818387803b1580156108a157600080fd5b505af115801561040c573d6000803e3d6000fd5b603c816060015167ffffffffffffffff16101515156108d357600080fd5b60008281526003602090815260409182902083518154600160a060020a0390911673ffffffffffffffffffffffffffffffffffffffff1990911617815581840151600182018054858701516fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000081029482166fffffffffffffffffffffffffffffffff19909316831790911693909317909155606080870151600290940180546080808a015167ffffffffffffffff90811668010000000000000000026fffffffffffffffff0000000000000000199190981667ffffffffffffffff1990931683171696909617909155865189815295860192909252848601929092529083015291517fa9c8dfcda5664a5a124c713e386da27de87432d5b668e79458501eb296389ba7929181900390910190a15050565b60008281526003602052604081208180808080610a2586610b9d565b1515610a3057600080fd5b610a3986610c08565b945084881015610a4857600080fd5b8554600160a060020a03169350610a5e89610c98565b6000851115610ab057610a7085610ce5565b6040519093508386039250600160a060020a0385169083156108fc029084906000818181858888f19350505050158015610aae573d6000803e3d6000fd5b505b5060405184880390339082156108fc029083906000818181858888f19350505050158015610ae2573d6000803e3d6000fd5b50604080518a815260208101879052338183015290517f4fcc30d90a842164dd58501ab874a101a3749c3d4747139cefe7c876f4ccebd29181900360600190a15092979650505050505050565b600154604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152602482018590529151919092169163a9059cbb91604480830192600092919082900301818387803b1580156108a157600080fd5b6002015460006801000000000000000090910467ffffffffffffffff161190565b610bc782610c98565b610bd18183610b2f565b6040805183815290517f2809c7e17bf978fbc7194c0a694b638c4215e9140cacc6c38ca36010b45697df9181900360200190a15050565b6002810154600090819068010000000000000000900467ffffffffffffffff16421115610c4e5750600282015468010000000000000000900467ffffffffffffffff1642035b60018301546002840154610791916fffffffffffffffffffffffffffffffff80821692700100000000000000000000000000000000909204169067ffffffffffffffff1684610cf1565b6000908152600360205260408120805473ffffffffffffffffffffffffffffffffffffffff19168155600181019190915560020180546fffffffffffffffffffffffffffffffff19169055565b60025461271091020490565b6000808080858510610d0557869350610d23565b878703925085858402811515610d1757fe5b05915081880190508093505b505050949350505050565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152905600a165627a7a723058203c3d7d4039d9d9a82dd65c7bc046590e8fe3580af952a66fe24052959889bef50029" - code_TestNetErc721Cat_deploySiringClockAuction = "60806040526000805460a060020a60ff02191690556004805460ff1916600117905534801561002d57600080fd5b50604051604080610e1a83398101604052805160209091015160008054600160a060020a031916331781558290829061271082111561006b57600080fd5b506002819055604080517f01ffc9a70000000000000000000000000000000000000000000000000000000081527f9a20483d00000000000000000000000000000000000000000000000000000000600482015290518391600160a060020a038316916301ffc9a7916024808201926020929091908290030181600087803b1580156100f557600080fd5b505af1158015610109573d6000803e3d6000fd5b505050506040513d602081101561011f57600080fd5b5051151561012c57600080fd5b60018054600160a060020a03909216600160a060020a031990921691909117905550505050610cba806101606000396000f3006080604052600436106100da5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166327ebe40a81146100df5780633f4ba83a1461010e578063454a2ab3146101375780635c975abb146101425780635fd8c7101461015757806376190f8f1461016c57806378bd79351461018157806383b5ff8b146101ce5780638456cb59146101f5578063878eb3681461020a5780638da5cb5b1461022257806396b5a75514610253578063c55d0f561461026b578063dd1b7a0f14610283578063f2fde38b14610298575b600080fd5b3480156100eb57600080fd5b5061010c600435602435604435606435600160a060020a03608435166102b9565b005b34801561011a57600080fd5b506101236103b1565b604080519115158252519081900360200190f35b61010c60043561042c565b34801561014e57600080fd5b50610123610478565b34801561016357600080fd5b5061010c610488565b34801561017857600080fd5b506101236104e5565b34801561018d57600080fd5b506101996004356104ee565b60408051600160a060020a03909616865260208601949094528484019290925260608401526080830152519081900360a00190f35b3480156101da57600080fd5b506101e3610584565b60408051918252519081900360200190f35b34801561020157600080fd5b5061012361058a565b34801561021657600080fd5b5061010c60043561060a565b34801561022e57600080fd5b50610237610673565b60408051600160a060020a039092168252519081900360200190f35b34801561025f57600080fd5b5061010c600435610682565b34801561027757600080fd5b506101e36004356106cc565b34801561028f57600080fd5b506102376106fe565b3480156102a457600080fd5b5061010c600160a060020a036004351661070d565b6102c1610c60565b6fffffffffffffffffffffffffffffffff851685146102df57600080fd5b6fffffffffffffffffffffffffffffffff841684146102fd57600080fd5b67ffffffffffffffff8316831461031357600080fd5b600154600160a060020a0316331461032a57600080fd5b610334828761075f565b60a06040519081016040528083600160a060020a03168152602001866fffffffffffffffffffffffffffffffff168152602001856fffffffffffffffffffffffffffffffff1681526020018467ffffffffffffffff1681526020014267ffffffffffffffff1681525090506103a986826107e7565b505050505050565b60008054600160a060020a031633146103c957600080fd5b60005460a060020a900460ff1615156103e157600080fd5b6000805474ff0000000000000000000000000000000000000000191681556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b339190a150600190565b600154600090600160a060020a0316331461044657600080fd5b50600081815260036020526040902054600160a060020a0316610469823461093b565b506104748183610a61565b5050565b60005460a060020a900460ff1681565b60015460008054600160a060020a0392831692163314806104b1575033600160a060020a038316145b15156104bc57600080fd5b604051600160a060020a03831690303180156108fc02916000818181858888f150505050505050565b60045460ff1681565b6000818152600360205260408120819081908190819061050d81610acf565b151561051857600080fd5b80546001820154600290920154600160a060020a03909116986fffffffffffffffffffffffffffffffff8084169950700100000000000000000000000000000000909304909216965067ffffffffffffffff808216965068010000000000000000909104169350915050565b60025481565b60008054600160a060020a031633146105a257600080fd5b60005460a060020a900460ff16156105b957600080fd5b6000805474ff0000000000000000000000000000000000000000191660a060020a1781556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff6259190a150600190565b6000805460a060020a900460ff16151561062357600080fd5b600054600160a060020a0316331461063a57600080fd5b50600081815260036020526040902061065281610acf565b151561065d57600080fd5b8054610474908390600160a060020a0316610af0565b600054600160a060020a031681565b60008181526003602052604081209061069a82610acf565b15156106a557600080fd5b508054600160a060020a03163381146106bd57600080fd5b6106c78382610af0565b505050565b60008181526003602052604081206106e381610acf565b15156106ee57600080fd5b6106f781610b3a565b9392505050565b600154600160a060020a031681565b600054600160a060020a0316331461072457600080fd5b600160a060020a0381161561075c576000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b600154604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015230602483015260448201859052915191909216916323b872dd91606480830192600092919082900301818387803b1580156107d357600080fd5b505af11580156103a9573d6000803e3d6000fd5b603c816060015167ffffffffffffffff161015151561080557600080fd5b60008281526003602090815260409182902083518154600160a060020a0390911673ffffffffffffffffffffffffffffffffffffffff1990911617815581840151600182018054858701516fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000081029482166fffffffffffffffffffffffffffffffff19909316831790911693909317909155606080870151600290940180546080808a015167ffffffffffffffff90811668010000000000000000026fffffffffffffffff0000000000000000199190981667ffffffffffffffff1990931683171696909617909155865189815295860192909252848601929092529083015291517fa9c8dfcda5664a5a124c713e386da27de87432d5b668e79458501eb296389ba7929181900390910190a15050565b6000828152600360205260408120818080808061095786610acf565b151561096257600080fd5b61096b86610b3a565b94508488101561097a57600080fd5b8554600160a060020a0316935061099089610bca565b60008511156109e2576109a285610c17565b6040519093508386039250600160a060020a0385169083156108fc029084906000818181858888f193505050501580156109e0573d6000803e3d6000fd5b505b5060405184880390339082156108fc029083906000818181858888f19350505050158015610a14573d6000803e3d6000fd5b50604080518a815260208101879052338183015290517f4fcc30d90a842164dd58501ab874a101a3749c3d4747139cefe7c876f4ccebd29181900360600190a15092979650505050505050565b600154604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152602482018590529151919092169163a9059cbb91604480830192600092919082900301818387803b1580156107d357600080fd5b6002015460006801000000000000000090910467ffffffffffffffff161190565b610af982610bca565b610b038183610a61565b6040805183815290517f2809c7e17bf978fbc7194c0a694b638c4215e9140cacc6c38ca36010b45697df9181900360200190a15050565b6002810154600090819068010000000000000000900467ffffffffffffffff16421115610b805750600282015468010000000000000000900467ffffffffffffffff1642035b600183015460028401546106f7916fffffffffffffffffffffffffffffffff80821692700100000000000000000000000000000000909204169067ffffffffffffffff1684610c23565b6000908152600360205260408120805473ffffffffffffffffffffffffffffffffffffffff19168155600181019190915560020180546fffffffffffffffffffffffffffffffff19169055565b60025461271091020490565b6000808080858510610c3757869350610c55565b878703925085858402811515610c4957fe5b05915081880190508093505b505050949350505050565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152905600a165627a7a723058208d1842c4569ecc7005642ae981f6c77b856b1d9a921f3792bdb4219144ae25e00029" - code_TestNetErc721Cat_deployGeneScienceInterface = "608060405234801561001057600080fd5b5060dc8061001f6000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630d9f5aed8114604d57806354c15b8214607a575b600080fd5b348015605857600080fd5b50606860043560243560443560a0565b60408051918252519081900360200190f35b348015608557600080fd5b50608c60ab565b604080519115158252519081900360200190f35b600292909101010490565b6001905600a165627a7a72305820d9550024d511527e5124d542daf0a0f3168b9bece6a238bcbccba8b61d3f0bdb0029" - code_TestNetFomo3D_deployErc721CryptoKitties = "60c0604052600660808190527f464f4d4f3344000000000000000000000000000000000000000000000000000060a0908152620000409160009190620000b3565b506040805180820190915260038082527f463344000000000000000000000000000000000000000000000000000000000060209092019182526200008791600191620000b3565b506305f5e1006002556000600855600b805460ff19169055348015620000ac57600080fd5b5062000158565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620000f657805160ff191683800117855562000126565b8280016001018555821562000126579182015b828111156200012657825182559160200191906001019062000109565b506200013492915062000138565b5090565b6200015591905b808211156200013457600081556001016200013f565b90565b61165980620001686000396000f3006080604052600436106101685763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166265318b811461017657806306fdde03146101a957806310d0ffdd1461023357806318160ddd1461024b578063226093731461026057806327defa1f14610278578063313ce567146102a1578063392efb52146102cc5780633ccfd60b146102e45780634b750334146102fb57806356d399e814610310578063688abbf7146103255780636b2f46321461033f57806370a08231146103545780638328b610146103755780638620410b1461038d57806389135ae9146103a25780638fea64bd146103bf578063949e8acd146103d457806395d89b41146103e9578063a8e04f34146103fe578063a9059cbb14610413578063b84c824614610437578063c47f002714610490578063e4849b32146104e9578063e9fad8ee14610501578063f088d54714610516578063fdb5a03e1461052a575b61017334600061053f565b50005b34801561018257600080fd5b50610197600160a060020a0360043516610b15565b60408051918252519081900360200190f35b3480156101b557600080fd5b506101be610b50565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f85781810151838201526020016101e0565b50505050905090810190601f1680156102255780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023f57600080fd5b50610197600435610bde565b34801561025757600080fd5b50610197610c0e565b34801561026c57600080fd5b50610197600435610c15565b34801561028457600080fd5b5061028d610c4e565b604080519115158252519081900360200190f35b3480156102ad57600080fd5b506102b6610c57565b6040805160ff9092168252519081900360200190f35b3480156102d857600080fd5b5061028d600435610c5c565b3480156102f057600080fd5b506102f9610c71565b005b34801561030757600080fd5b50610197610d44565b34801561031c57600080fd5b50610197610d93565b34801561033157600080fd5b506101976004351515610d99565b34801561034b57600080fd5b50610197610ddc565b34801561036057600080fd5b50610197600160a060020a0360043516610de1565b34801561038157600080fd5b506102f9600435610dfc565b34801561039957600080fd5b50610197610e43565b3480156103ae57600080fd5b506102f96004356024351515610e87565b3480156103cb57600080fd5b506102f9610ee9565b3480156103e057600080fd5b50610197610eeb565b3480156103f557600080fd5b506101be610efe565b34801561040a57600080fd5b506102f9610f58565b34801561041f57600080fd5b5061028d600160a060020a0360043516602435610fa6565b34801561044357600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526102f99436949293602493928401919081908401838280828437509497506111609650505050505050565b34801561049c57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526102f99436949293602493928401919081908401838280828437509497506111b99650505050505050565b3480156104f557600080fd5b506102f960043561120d565b34801561050d57600080fd5b506102f961135e565b610197600160a060020a036004351661138b565b34801561053657600080fd5b506102f9611397565b60008060008060008060008060008a6000339050600b60009054906101000a900460ff16801561058157506801158e460913d000008261057d610ddc565b0311155b1561088e57600160a060020a03811660009081526003602052604090205460ff16151560011480156105d65750600160a060020a038116600090815260076020526040902054670de0b6b3a764000090830111155b15156105e157600080fd5b600160a060020a038116600090815260076020526040902054610604908361144d565b600160a060020a03821660009081526007602052604090205533995061062b8d6005611463565b9850610638896003611463565b9750610644898961147a565b96506106508d8a61147a565b955061065b8661148c565b945068010000000000000000870293506000851180156106855750600854610683868261144d565b115b151561069057600080fd5b600160a060020a038c16158015906106ba575089600160a060020a03168c600160a060020a031614155b80156106e05750600254600160a060020a038d1660009081526004602052604090205410155b1561072657600160a060020a038c16600090815260056020526040902054610708908961144d565b600160a060020a038d16600090815260056020526040902055610741565b610730878961144d565b965068010000000000000000870293505b600060085411156107a5576107586008548661144d565b600881905568010000000000000000880281151561077257fe5b6009805492909104909101905560085468010000000000000000880281151561079757fe5b0485028403840393506107ab565b60088590555b600160a060020a038a166000908152600460205260409020546107ce908661144d565b600460008c600160a060020a0316600160a060020a031681526020019081526020016000208190555083856009540203925082600660008c600160a060020a0316600160a060020a03168152602001908152602001600020600082825401925050819055508b600160a060020a03168a600160a060020a03167f022c0d992e4d873a3748436d960d5140c1f9721cf73f7ca5ec679d3d9f4fe2d58f88604051808381526020018281526020019250505060405180910390a3849a50610b05565b600b805460ff191690553399506108a68d6005611463565b98506108b3896003611463565b97506108bf898961147a565b96506108cb8d8a61147a565b95506108d68661148c565b9450680100000000000000008702935060008511801561090057506008546108fe868261144d565b115b151561090b57600080fd5b600160a060020a038c1615801590610935575089600160a060020a03168c600160a060020a031614155b801561095b5750600254600160a060020a038d1660009081526004602052604090205410155b156109a157600160a060020a038c16600090815260056020526040902054610983908961144d565b600160a060020a038d166000908152600560205260409020556109bc565b6109ab878961144d565b965068010000000000000000870293505b60006008541115610a20576109d36008548661144d565b60088190556801000000000000000088028115156109ed57fe5b60098054929091049091019055600854680100000000000000008802811515610a1257fe5b048502840384039350610a26565b60088590555b600160a060020a038a16600090815260046020526040902054610a49908661144d565b600460008c600160a060020a0316600160a060020a031681526020019081526020016000208190555083856009540203925082600660008c600160a060020a0316600160a060020a03168152602001908152602001600020600082825401925050819055508b600160a060020a03168a600160a060020a03167f022c0d992e4d873a3748436d960d5140c1f9721cf73f7ca5ec679d3d9f4fe2d58f88604051808381526020018281526020019250505060405180910390a3849a505b5050505050505050505092915050565b600160a060020a0316600090815260066020908152604080832054600490925290912054600954680100000000000000009102919091030490565b6000805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610bd65780601f10610bab57610100808354040283529160200191610bd6565b820191906000526020600020905b815481529060010190602001808311610bb957829003601f168201915b505050505081565b6000808080610bee856005611463565b9250610bfa858461147a565b9150610c058261148c565b95945050505050565b6008545b90565b6000806000806008548511151515610c2c57600080fd5b610c3585611508565b9250610c42836005611463565b9150610c05838361147a565b600b5460ff1681565b600681565b600a6020526000908152604090205460ff1681565b6000806000610c806001610d99565b11610c8a57600080fd5b339150610c976000610d99565b600160a060020a038316600081815260066020908152604080832080546801000000000000000087020190556005909152808220805490839055905193019350909183156108fc0291849190818181858888f19350505050158015610d00573d6000803e3d6000fd5b50604080518281529051600160a060020a038416917fccad973dcd043c7d680389db4378bd6b9775db7124092e9e0422c9e46d7985dc919081900360200190a25050565b60008060008060085460001415610d625764d18c2e28009350610d8d565b610d6e620f4240611508565b9250610d7b836005611463565b9150610d87838361147a565b90508093505b50505090565b60025481565b60003382610daf57610daa81610b15565b610dd3565b600160a060020a038116600090815260056020526040902054610dd182610b15565b015b91505b50919050565b303190565b600160a060020a031660009081526004602052604090205490565b604080516c010000000000000000000000003390810282528251918290036014019091206000908152600a602052919091205460ff161515610e3d57600080fd5b50600255565b60008060008060085460001415610e62576501001d1bf8009350610d8d565b610e6e620f4240611508565b9250610e7b836005611463565b9150610d87838361144d565b604080516c010000000000000000000000003390810282528251918290036014019091206000908152600a602052919091205460ff161515610ec857600080fd5b506000918252600a6020526040909120805460ff1916911515919091179055565b565b600033610ef781610de1565b91505b5090565b60018054604080516020600284861615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610bd65780601f10610bab57610100808354040283529160200191610bd6565b604080516c010000000000000000000000003390810282528251918290036014019091206000908152600a602052919091205460ff161515610f9957600080fd5b50600b805460ff19169055565b600080600080600080610fb7610eeb565b11610fc157600080fd5b600b5433945060ff16158015610fef5750600160a060020a0384166000908152600460205260409020548611155b1515610ffa57600080fd5b60006110066001610d99565b111561101457611014610c71565b61101f866005611463565b925061102b868461147a565b915061103683611508565b90506110446008548461147a565b600855600160a060020a03841660009081526004602052604090205461106a908761147a565b600160a060020a038086166000908152600460205260408082209390935590891681522054611099908361144d565b600160a060020a0388811660008181526004602090815260408083209590955560098054948a16835260069091528482208054948c0290940390935582549181529290922080549285029092019091555460085461110d919068010000000000000000840281151561110757fe5b0461144d565b600955604080518381529051600160a060020a03808a1692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35060019695505050505050565b604080516c010000000000000000000000003390810282528251918290036014019091206000908152600a602052919091205460ff1615156111a157600080fd5b81516111b490600190602085019061159f565b505050565b604080516c010000000000000000000000003390810282528251918290036014019091206000908152600a602052919091205460ff1615156111fa57600080fd5b81516111b490600090602085019061159f565b6000806000806000806000611220610eeb565b1161122a57600080fd5b3360008181526004602052604090205490965087111561124957600080fd5b86945061125585611508565b9350611262846005611463565b925061126e848461147a565b915061127c6008548661147a565b600855600160a060020a0386166000908152600460205260409020546112a2908661147a565b600160a060020a038716600090815260046020908152604080832093909355600954600690915291812080549288026801000000000000000086020192839003905560085491925010156113125761130e60095460085468010000000000000000860281151561110757fe5b6009555b60408051868152602081018490528151600160a060020a038916927fc4823739c5787d2ca17e404aa47d5569ae71dfb49cbf21b3f6152ed238a31139928290030190a250505050505050565b336000818152600460205260408120549081111561137f5761137f8161120d565b611387610c71565b5050565b6000610dd6348361053f565b6000806000806113a76001610d99565b116113b157600080fd5b6113bb6000610d99565b336000818152600660209081526040808320805468010000000000000000870201905560059091528120805490829055909201945092506113fd90849061053f565b905081600160a060020a03167fbe339fc14b041c2b0e0f3dd2cd325d0c3668b78378001e53160eab36153264588483604051808381526020018281526020019250505060405180910390a2505050565b60008282018381101561145c57fe5b9392505050565b600080828481151561147157fe5b04949350505050565b60008282111561148657fe5b50900390565b600854600090670de0b6b3a764000090829064174876e8006114f56114ef692a5a058fc295ed000000880269021e19e0c9bab24000006002860a02016c02863c1f5cdae42f95400000008502016ec097ce7bc90715b34b9f10000000000161156a565b8561147a565b8115156114fe57fe5b0403949350505050565b600854600090620f424083810191810190839061155764d18c2e280082850464174876e80002018702600283620f423f1982890a8b9003010464174876e8000281151561155157fe5b0461147a565b81151561156057fe5b0495945050505050565b80600260018201045b81811015610dd657809150600281828581151561158c57fe5b040181151561159757fe5b049050611573565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106115e057805160ff191683800117855561160d565b8280016001018555821561160d579182015b8281111561160d5782518255916020019190600101906115f2565b50610efa92610c129250905b80821115610efa57600081556001016116195600a165627a7a72305820bf757ace6c45263e75b0a8eb6c539065f0ca610f7bf4378df93a0eff2d0551060029" - code1_TestNetFomo3D_deployErc721CryptoKitties = "608060405234801561001057600080fd5b5061011a806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063f8a8fd6d146044575b600080fd5b348015604f57600080fd5b506056606c565b6040518082815260200191505060405180910390f35b6000600180141515607c57600080fd5b603c80141515608a57600080fd5b610e1080141515609957600080fd5b620151808014151560a957600080fd5b62093a808014151560b957600080fd5b6301e133808014151560ca57600080fd5b620f42408014151560da57600080fd5b60018014151560e857600080fd5b429050905600a165627a7a72305820e8f9994ec320bbc329299a1cec491445178da2a60b219fb25e91adb9c4e4aa930029" - code_TestNetFomo3D_tooLargeStorage = "60e0604090815260808190527f313233343536373831323334353637383132333435363738313233343536373860a081815260c091909152610044916001919061009e565b50604080516060810182528181527f6162636466657467616263646665746761626364666574676162636466657467602082018181529183015261008b916002919061009e565b5034801561009857600080fd5b50610139565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100df57805160ff191683800117855561010c565b8280016001018555821561010c579182015b8281111561010c5782518255916020019190600101906100f1565b5061011892915061011c565b5090565b61013691905b808211156101185760008155600101610122565b90565b6105bb806101486000396000f3006080604052600436106100615763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166386b714e28114610066578063c2985578146100f0578063e6a01b5a14610105578063f8ac93e81461011f575b600080fd5b34801561007257600080fd5b5061007b610134565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100b557818101518382015260200161009d565b50505050905090810190601f1680156100e25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156100fc57600080fd5b5061007b6101c2565b34801561011157600080fd5b5061011d6004356102cc565b005b34801561012b57600080fd5b5061011d6103e0565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156101ba5780601f1061018f576101008083540402835291602001916101ba565b820191906000526020600020905b81548152906001019060200180831161019d57829003601f168201915b505050505081565b60028054604080516020601f600019610100600187161502019094168590049384018190048102820181019092528281526060936102c6936102599383018282801561024f5780601f106102245761010080835404028352916020019161024f565b820191906000526020600020905b81548152906001019060200180831161023257829003601f168201915b50505050506103ff565b60018054604080516020601f6002600019610100878916150201909516949094049384018190048102820181019092528281526102ba939092909183018282801561024f5780601f106102245761010080835404028352916020019161024f565b9063ffffffff61042516565b90505b90565b60006102d66101c2565b80516102ea916000916020909101906104e0565b50600090505b818110156103dc576000805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181526103bf9361035d939192909183018282801561024f5780601f106102245761010080835404028352916020019161024f565b60008054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526102ba939092909183018282801561024f5780601f106102245761010080835404028352916020019161024f565b80516103d3916000916020909101906104e0565b506001016102f0565b5050565b6040805160208101918290526000908190526103fc91816104e0565b50565b61040761055e565b50604080518082019091528151815260209182019181019190915290565b606080600083600001518560000151016040519080825280601f01601f191660200182016040528015610462578160200160208202803883390190505b50915060208201905061047e818660200151876000015161049c565b845160208501518551610494928401919061049c565b509392505050565b60005b602082106104c1578251845260209384019390920191601f199091019061049f565b50905182516020929092036101000a6000190180199091169116179052565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061052157805160ff191683800117855561054e565b8280016001018555821561054e579182015b8281111561054e578251825591602001919060010190610533565b5061055a929150610575565b5090565b604080518082019091526000808252602082015290565b6102c991905b8082111561055a576000815560010161057b5600a165627a7a723058207e0cfcb8e796037851028c428aca173ecd924a4572c51605ecebbf548fecdf3d0029" - code_TestStorageAndCpu_storageAndCpu = "6080604052600060045534801561001557600080fd5b506104c0806100256000396000f3006080604052600436106100a35763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632656df4881146100a85780633755cd3c146100bf5780636f269385146100e95780637d965688146100fe578063a05b257714610116578063b0d6304d1461012e578063b648763914610162578063bbe1d75b146101ec578063f8a8fd6d14610201578063fe75faab14610216575b600080fd5b3480156100b457600080fd5b506100bd61022e565b005b3480156100cb57600080fd5b506100d7600435610230565b60408051918252519081900360200190f35b3480156100f557600080fd5b506100bd61024f565b34801561010a57600080fd5b506100d7600435610296565b34801561012257600080fd5b506100d76004356102b6565b34801561013a57600080fd5b506100d773ffffffffffffffffffffffffffffffffffffffff60043581169060243516610300565b34801561016e57600080fd5b5061017761031d565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b1578181015183820152602001610199565b50505050905090810190601f1680156101de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f857600080fd5b506100d76103ab565b34801561020d57600080fd5b506100bd6103b1565b34801561022257600080fd5b506100d76004356103c2565b565b600180548290811061023e57fe5b600091825260209091200154905081565b6040805180820190915260088082527f31323334353637380000000000000000000000000000000000000000000000006020909201918252610293916000916103f9565b50565b600080805b838110156102af576001918201910161029b565b5092915050565b600080805b838110156102af5760018054808201825560008290527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60182905591820191016102bb565b600360209081526000928352604080842090915290825290205481565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103a35780601f10610378576101008083540402835291602001916103a3565b820191906000526020600020905b81548152906001019060200180831161038657829003601f168201915b505050505081565b60025481565b60048054600101905561022e6103b1565b60006103cd826103d8565b600281905592915050565b60006103e6600283036103d8565b6103f2600184036103d8565b0192915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061043a57805160ff1916838001178555610467565b82800160010185558215610467579182015b8281111561046757825182559160200191906001019061044c565b50610473929150610477565b5090565b61049191905b80821115610473576000815560010161047d565b905600a165627a7a72305820ca3a4850a926264dc27c0e3483830bac3385c61565c738281b05d747d20676670029" - code_WalletTestAccount013 = "608060405234801561001057600080fd5b5061045c806100206000396000f30060806040526004361061006d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806304c58438146100725780634f2be91f1461009f578063812db772146100b657806393cd5755146100e3578063d1cd64e914610189575b600080fd5b34801561007e57600080fd5b5061009d600480360381019080803590602001909291905050506101a0565b005b3480156100ab57600080fd5b506100b4610230565b005b3480156100c257600080fd5b506100e1600480360381019080803590602001909291905050506102a2565b005b3480156100ef57600080fd5b5061010e600480360381019080803590602001909291905050506102c3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014e578082015181840152602081019050610133565b50505050905090810190601f16801561017b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019557600080fd5b5061019e61037e565b005b6000600190505b8181101561022c5760008060018154018082558091505090600182039060005260206000200160006040805190810160405280600881526020017f31323334353637380000000000000000000000000000000000000000000000008152509091909150908051906020019061021d92919061038b565b505080806001019150506101a7565b5050565b60008060018154018082558091505090600182039060005260206000200160006040805190810160405280600881526020017f61626364656667680000000000000000000000000000000000000000000000008152509091909150908051906020019061029e92919061038b565b5050565b6000600190505b81811115156102bf5780806001019150506102a9565b5050565b6000818154811015156102d257fe5b906000526020600020016000915090508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103765780601f1061034b57610100808354040283529160200191610376565b820191906000526020600020905b81548152906001019060200180831161035957829003601f168201915b505050505081565b6000808060010191505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106103cc57805160ff19168380011785556103fa565b828001600101855582156103fa579182015b828111156103f95782518255916020019190600101906103de565b5b509050610407919061040b565b5090565b61042d91905b80821115610429576000816000905550600101610411565b5090565b905600a165627a7a7230582087d9880a135295a17100f63b8941457f4369204d3ccc9ce4a1abf99820eb68480029" - code_ContractEventAndLog1 = "608060405234801561001057600080fd5b50610e6c806100206000396000f3006080604052600436106100fc576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630265ec371461010b5780630a98bcec146101155780630d16a1e31461013557806312d2c2091461013f57806340de00d314610149578063462da3081461017c57806360edcb5f1461018657806367392426146101905780636cb244f11461019a5780636e5f4528146101cd57806372f48b1a146101d7578063797d1255146101f75780638615960d14610232578063bd85753b14610249578063ce6db7c0146102f8578063d0a0eadc146103a7578063d228d484146103be578063d52aca67146103e9575b34801561010857600080fd5b50005b6101136103f3565b005b61013360048036038101908080359060200190929190505050610485565b005b61013d610535565b005b61014761057c565b005b34801561015557600080fd5b5061015e610669565b60405180826000191660001916815260200191505060405180910390f35b6101846106cc565b005b61018e610798565b005b61019861080a565b005b3480156101a657600080fd5b506101af610872565b60405180826000191660001916815260200191505060405180910390f35b6101d56108af565b005b6101f56004803603810190808035906020019092919050505061095b565b005b34801561020357600080fd5b506102306004803603810190808035151590602001909291908035151590602001909291905050506109e1565b005b34801561023e57600080fd5b50610247610a23565b005b34801561025557600080fd5b506102f6600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610aba565b005b34801561030457600080fd5b506103a5600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610bbd565b005b3480156103b357600080fd5b506103bc610c9f565b005b3480156103ca57600080fd5b506103d3610d7c565b6040518082815260200191505060405180910390f35b6103f1610d9b565b005b60008030915034905034600102600019168273ffffffffffffffffffffffffffffffffffffffff16600102600019163373ffffffffffffffffffffffffffffffffffffffff16600102600019167fbeabacc8ffedac16e9a60acdb2ca743d80c2ebb44977a93fa8e483c74d2b35a860010260405180826000191660001916815260200191505060405180910390a35050565b6000806000309250349150600090505b8381101561052f5734600102600019168373ffffffffffffffffffffffffffffffffffffffff16600102600019163373ffffffffffffffffffffffffffffffffffffffff16600102600019167fbeabacc8ffedac16e9a60acdb2ca743d80c2ebb44977a93fa8e483c74d2b35a860010260405180826000191660001916815260200191505060405180910390a38080600101915050610495565b50505050565b600080309150349050808273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1660405160405180910390a35050565b600080309150349050808273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fbeabacc8ffedac16e9a60acdb2ca743d80c2ebb44977a93fa8e483c74d2b35a860405160405180910390a48173ffffffffffffffffffffffffffffffffffffffff16600102600019163373ffffffffffffffffffffffffffffffffffffffff166001026000191634600102600019167fbeabacc8ffedac16e9a60acdb2ca743d80c2ebb44977a93fa8e483c74d2b35a860010260405180826000191660001916815260200191505060405180910390a35050565b600060405180807f7472616e7366657228616464726573732c616464726573732c75696e7432353681526020017f290000000000000000000000000000000000000000000000000000000000000081525060210190506040518091039020905090565b600080309150349050808273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1660405160405180910390a38173ffffffffffffffffffffffffffffffffffffffff16600102600019163373ffffffffffffffffffffffffffffffffffffffff166001026000191634600102600019167fbeabacc8ffedac16e9a60acdb2ca743d80c2ebb44977a93fa8e483c74d2b35a860010260405180826000191660001916815260200191505060405180910390a35050565b6000803091503490508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f233b34846284da6adf1006478380fa328232b0a6ede5041bfe21ea9be1b3b88a836040518082815260200191505060405180910390a35050565b600080309150349050808273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fbeabacc8ffedac16e9a60acdb2ca743d80c2ebb44977a93fa8e483c74d2b35a860405160405180910390a45050565b600060405180807f4465706f73697428616464726573732c686173683235362c75696e743235362981525060200190506040518091039020905090565b6000803091503490507f0c2fb0b24194d40c1d753915af9ba7185bd7a703e4374ca9fb376a4f7c91dcca338383604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060405180910390a15050565b6000806000309250349150600090505b838110156109db57818373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fbeabacc8ffedac16e9a60acdb2ca743d80c2ebb44977a93fa8e483c74d2b35a860405160405180910390a4808060010191505061096b565b50505050565b8015157f37f1c240387a938c945ab44c1cff92ff6d224ce37ee4db1d770944201f6fcc2983604051808215151515815260200191505060405180910390a25050565b7f4e2428acf9e70e881e61b1dabc7589a9c3800a9737a6a67e29f70a1397925b2c600160c8610bb8619c40604051808560ff1681526020018467ffffffffffffffff168152602001836fffffffffffffffffffffffffffffffff168152602001827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16815260200194505050505060405180910390a1565b806040518082805190602001908083835b602083101515610af05780518252602082019150602081019050602083039250610acb565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390207fcb164b075277ecd24c68a6ff14fbdd71a2c6cc9cf7bec9797b8227471f740dfa836040518080602001828103825283818151815260200191508051906020019080838360005b83811015610b7f578082015181840152602081019050610b64565b50505050905090810190601f168015610bac5780820380516001836020036101000a031916815260200191505b509250505060405180910390a25050565b806040518082805190602001908083835b602083101515610bf35780518252602082019150602081019050602083039250610bce565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020826040518080602001828103825283818151815260200191508051906020019080838360005b83811015610c61578082015181840152602081019050610c46565b50505050905090810190601f168015610c8e5780820380516001836020036101000a031916815260200191505b509250505060405180910390a15050565b7fb24eee86cea7aa22cfdcfaa01da5152afa042fd9a0a446ef038034c705bc25d57fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8307ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4487ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd9da600604051808560000b81526020018460080b81526020018360100b815260200182601c0b815260200194505050505060405180910390a1565b60003073ffffffffffffffffffffffffffffffffffffffff1631905090565b600080309150349050807f39f02551491f3fe37d6822a5987d21ac6d6385c6dc38b97a29699a5bb45f038a3384604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a250505600a165627a7a723058206121fcbe7b56027d526e504c463f8f29064931be358774a6a065110af09d21b70029" - code_ContractEventAndLog2 = "608060405234801561001057600080fd5b50610369806100206000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680634247b80e14610066578063d0e30db014610070578063d228d4841461007a575b34801561006357600080fd5b50005b61006e6100a5565b005b6100786102b6565b005b34801561008657600080fd5b5061008f61031e565b6040518082815260200191505060405180910390f35b6000806000630420042076010000000000000000000000000000000000000000000002925063042004206f01000000000000000000000000000000029150630420042060010290507f88c75e92614e379252c5b1847e9753f9668ebb5ebb9a148333bdf0458d3d9cdf838383604051808475ffffffffffffffffffffffffffffffffffffffffffff191675ffffffffffffffffffffffffffffffffffffffffffff19168152602001836effffffffffffffffffffffffffffff19166effffffffffffffffffffffffffffff191681526020018260001916600019168152602001935050505060405180910390a1828282604051808475ffffffffffffffffffffffffffffffffffffffffffff191675ffffffffffffffffffffffffffffffffffffffffffff19168152602001836effffffffffffffffffffffffffffff19166effffffffffffffffffffffffffffff191681526020018260001916600019168152602001935050505060405180910390a08060001916826effffffffffffffffffffffffffffff19168475ffffffffffffffffffffffffffffffffffffffffffff19167f47f711f8177f4e1a7a44e07049543e0b69ef4b740c817c404c3ef911623fa89160405160405180910390a48060001916826effffffffffffffffffffffffffffff19168475ffffffffffffffffffffffffffffffffffffffffffff191660405160405180910390a3505050565b600080309150349050808273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fbeabacc8ffedac16e9a60acdb2ca743d80c2ebb44977a93fa8e483c74d2b35a860405160405180910390a45050565b60003073ffffffffffffffffffffffffffffffffffffffff16319050905600a165627a7a72305820f5c3bb96350b175387f95b45f915f736ba0468b0880f65c542b8b55d261e72760029" - - code_OriginEnergyLimit001 = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5061014e8061003a6000396000f3006080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663329000b58114610045575b600080fd5b34801561005157600080fd5b50d3801561005e57600080fd5b50d2801561006b57600080fd5b50610077600435610089565b60408051918252519081900360200190f35b604080516003808252608082019092526000916060919060208201838038833901905050905060018160008151811015156100c057fe5b602090810290910101528051600290829060019081106100dc57fe5b602090810290910101528051600390829060029081106100f857fe5b60209081029091010152805181908490811061011057fe5b906020019060200201519150509190505600a165627a7a7230582058dd457e2aeba46e78dd8b9c36b777d362763c05ec1ad62e0d79de51ff3dde790029" - code_OriginEnergyLimit004 = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5061014e8061003a6000396000f3006080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663329000b58114610045575b600080fd5b34801561005157600080fd5b50d3801561005e57600080fd5b50d2801561006b57600080fd5b50610077600435610089565b60408051918252519081900360200190f35b604080516003808252608082019092526000916060919060208201838038833901905050905060018160008151811015156100c057fe5b602090810290910101528051600290829060019081106100dc57fe5b602090810290910101528051600390829060029081106100f857fe5b60209081029091010152805181908490811061011057fe5b906020019060200201519150509190505600a165627a7a723058206503efa46ed431a2604563d7764b4b9e6ca03238259cb133c878592fc43a4b670029" - - - code_ContractTrcToken001_transferTokenContract = "6080604052d3600055d2600155346002556101418061001f6000396000f3006080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305c24200811461005b5780633be9ece71461008157806371dc08ce146100aa575b600080fd5b6100636100b2565b60408051938452602084019290925282820152519081900360600190f35b6100a873ffffffffffffffffffffffffffffffffffffffff600435166024356044356100c0565b005b61006361010d565b600054600154600254909192565b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad0945050505050158015610107573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820a2fb39541e90eda9a2f5f9e7905ef98e66e60dd4b38e00b05de418da3154e7570029" - code_ContractTrcToken002_transferTokenContract = "6080604052610118806100136000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece78114604d57806371dc08ce146074575b600080fd5b607273ffffffffffffffffffffffffffffffffffffffff600435166024356044356098565b005b607a60e4565b60408051938452602084019290925282820152519081900360600190f35b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560de573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820b8d4f8ea5443a03d615ea5dfe7a7435498522f9c7abeb25583d953ee2d20be4a0029" - code_ContractTrcToken005_transferTokenContract = "6080604052610118806100136000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece78114604d57806371dc08ce146074575b600080fd5b607273ffffffffffffffffffffffffffffffffffffffff600435166024356044356098565b005b607a60e4565b60408051938452602084019290925282820152519081900360600190f35b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560de573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820b8d4f8ea5443a03d615ea5dfe7a7435498522f9c7abeb25583d953ee2d20be4a0029" - code_ContractTrcToken006_transferTokenContract = "6080604052610118806100136000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece78114604d57806371dc08ce146074575b600080fd5b607273ffffffffffffffffffffffffffffffffffffffff600435166024356044356098565b005b607a60e4565b60408051938452602084019290925282820152519081900360600190f35b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560de573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820b8d4f8ea5443a03d615ea5dfe7a7435498522f9c7abeb25583d953ee2d20be4a0029" - code_ContractTrcToken011_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken011_resultContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken012_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken014_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken014_resultContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken016_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken016_resultContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken017_recieveTokenContract = "60806040526000805560c5806100166000396000f30060806040526004361060485763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166362548c7b8114604a578063890eba68146050575b005b6048608c565b348015605b57600080fd5b50d38015606757600080fd5b50d28015607357600080fd5b50607a6093565b60408051918252519081900360200190f35b6001600055565b600054815600a165627a7a723058204c4f1bb8eca0c4f1678cc7cc1179e03d99da2a980e6792feebe4d55c89c022830029" - code_ContractTrcToken042_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken042_recieveTokenContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken043_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken043_recieveTokenContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken046_transferTokenContract = "6080604052610118806100136000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece78114604d57806371dc08ce146074575b600080fd5b607273ffffffffffffffffffffffffffffffffffffffff600435166024356044356098565b005b607a60e4565b60408051938452602084019290925282820152519081900360600190f35b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560de573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820b8d4f8ea5443a03d615ea5dfe7a7435498522f9c7abeb25583d953ee2d20be4a0029" - code_ContractTrcToken047_transferTokenContract = "6080604052610118806100136000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece78114604d57806371dc08ce146074575b600080fd5b607273ffffffffffffffffffffffffffffffffffffffff600435166024356044356098565b005b607a60e4565b60408051938452602084019290925282820152519081900360600190f35b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560de573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820b8d4f8ea5443a03d615ea5dfe7a7435498522f9c7abeb25583d953ee2d20be4a0029" - code2_ContractTrcToken023_tokenTest = "608060405260e2806100126000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece781146043575b600080fd5b606873ffffffffffffffffffffffffffffffffffffffff60043516602435604435606a565b005b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560b0573d6000803e3d6000fd5b505050505600a165627a7a7230582006508824be321d3ad4594b1b2dae9099960f982a99b5e1121896fbbb115967780029" - code_ContractTrcToken023_tokenTest = "60806040526000805560b3806100166000396000f300608060405260043610603e5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663890eba6881146045575b6001600055005b348015605057600080fd5b50d38015605c57600080fd5b50d28015606857600080fd5b50606f6081565b60408051918252519081900360200190f35b600054815600a165627a7a72305820fc51dbe84825144f5e50d2ab8c418a5b1bfe75a31b054528816f2311b2632d6d0029" - code_ContractTrcToken026_BTest = "6080604052610145806100136000396000f3006080604052600436106100275763ffffffff60e060020a600035041663cb35b7e28114610029575b005b61002773ffffffffffffffffffffffffffffffffffffffff600435811690602435166044356064358373ffffffffffffffffffffffffffffffffffffffff1660405180807f7472616e7328616464726573732c75696e743235362c747263546f6b656e2900815250601f019050604051809103902060e060020a90048484846040518463ffffffff1660e060020a028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200182815260200193505050506000604051808303816000875af150505050505050505600a165627a7a72305820f80979e10a32bf6d6995716d7c5b159944473c2db9ac4ca5e780cfcd620261260029" - code1_ContractTrcToken026_CTest = "608060405260d9806100126000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416634f53d8a881146040575b005b603e73ffffffffffffffffffffffffffffffffffffffff6004351660243560443560405173ffffffffffffffffffffffffffffffffffffffff84169083156108fc029084908490600081818185878a8ad094505050505015801560a7573d6000803e3d6000fd5b505050505600a165627a7a723058203db4692a33e354b8bb6b6274f3c25ca36facafc80e996629c2b7c8e79ef40f2e0029" - code1_ContractTrcToken026_tokenTest = "6080604052610257806100136000396000f3006080604052600436106100325763ffffffff60e060020a6000350416636409a1c0811461003457806383efe58114610067575b005b61003273ffffffffffffffffffffffffffffffffffffffff6004358116906024358116906044351660643560843561009a565b61003273ffffffffffffffffffffffffffffffffffffffff60043581169060243581169060443516606435608435610163565b604080517f7472616e734328616464726573732c616464726573732c75696e743235362c7481527f7263546f6b656e290000000000000000000000000000000000000000000000006020820152815190819003602801812063ffffffff60e060020a91829004908116909102825273ffffffffffffffffffffffffffffffffffffffff8781166004840152868116602484015260448301869052606483018590529251928816929091608480820192600092909190829003018183875af1505050505050505050565b604080517f7472616e734328616464726573732c616464726573732c75696e743235362c7481527f7263546f6b656e290000000000000000000000000000000000000000000000006020820152815190819003602801812063ffffffff60e060020a91829004908116909102825273ffffffffffffffffffffffffffffffffffffffff87811660048401528681166024840152604483018690526064830185905292519288169290916084808201926000929091908290030181865af45050505050505050505600a165627a7a72305820554cb78d3d6082a8b93092e5edd2b66b83a47707eb8cbbfdbb06a0806fce72840029" - code_ContractTrcToken027_BTest = "6080604052610145806100136000396000f3006080604052600436106100275763ffffffff60e060020a600035041663cb35b7e28114610029575b005b61002773ffffffffffffffffffffffffffffffffffffffff600435811690602435166044356064358373ffffffffffffffffffffffffffffffffffffffff1660405180807f7472616e7328616464726573732c75696e743235362c747263546f6b656e2900815250601f019050604051809103902060e060020a90048484846040518463ffffffff1660e060020a028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200182815260200193505050506000604051808303816000875af150505050505050505600a165627a7a72305820f80979e10a32bf6d6995716d7c5b159944473c2db9ac4ca5e780cfcd620261260029" - code_ContractTrcToken027_CTest = "608060405260d9806100126000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416634f53d8a881146040575b005b603e73ffffffffffffffffffffffffffffffffffffffff6004351660243560443560405173ffffffffffffffffffffffffffffffffffffffff84169083156108fc029084908490600081818185878a8ad094505050505015801560a7573d6000803e3d6000fd5b505050505600a165627a7a723058203db4692a33e354b8bb6b6274f3c25ca36facafc80e996629c2b7c8e79ef40f2e0029" - - code_ContractTrcToken027_tokenTest = "6080604052610257806100136000396000f3006080604052600436106100325763ffffffff60e060020a6000350416636409a1c0811461003457806383efe58114610067575b005b61003273ffffffffffffffffffffffffffffffffffffffff6004358116906024358116906044351660643560843561009a565b61003273ffffffffffffffffffffffffffffffffffffffff60043581169060243581169060443516606435608435610163565b604080517f7472616e734328616464726573732c616464726573732c75696e743235362c7481527f7263546f6b656e290000000000000000000000000000000000000000000000006020820152815190819003602801812063ffffffff60e060020a91829004908116909102825273ffffffffffffffffffffffffffffffffffffffff8781166004840152868116602484015260448301869052606483018590529251928816929091608480820192600092909190829003018183875af1505050505050505050565b604080517f7472616e734328616464726573732c616464726573732c75696e743235362c7481527f7263546f6b656e290000000000000000000000000000000000000000000000006020820152815190819003602801812063ffffffff60e060020a91829004908116909102825273ffffffffffffffffffffffffffffffffffffffff87811660048401528681166024840152604483018690526064830185905292519288169290916084808201926000929091908290030181865af45050505050505050505600a165627a7a72305820554cb78d3d6082a8b93092e5edd2b66b83a47707eb8cbbfdbb06a0806fce72840029" - code_ContractTrcToken028_tokenTest = "608060405260016000556102a5806100186000396000f3006080604052600436106100565763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630dbe671f811461005b578063baf462821461009c578063d46300fd146100a9575b600080fd5b34801561006757600080fd5b50d3801561007457600080fd5b50d2801561008157600080fd5b5061008a6100b1565b60408051918252519081900360200190f35b6100a76004356100b7565b005b61008a610182565b60005481565b60006100c1610188565b604051809103906000f0801580156100dd573d6000803e3d6000fd5b5090508073ffffffffffffffffffffffffffffffffffffffff1663205e3c9c836040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b15801561014f57600080fd5b505af1158015610163573d6000803e3d6000fd5b505050506040513d602081101561017957600080fd5b50516000555050565b60005490565b60405160e28061019883390190560060806040526000805560cc806100166000396000f30060806040526004361060485763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663205e3c9c8114604a578063890eba68146065575b005b6053600435608f565b60408051918252519081900360200190f35b348015607057600080fd5b50d38015607c57600080fd5b50d28015608857600080fd5b506053609a565b506009600081905590565b600054815600a165627a7a7230582000d7b938c0aa356a26f89e8816d8cafa65acdc21fbfc77112e7b774cc35ec6fa0029a165627a7a723058204f7b7aa7d1a83605c6830eee3ee774b9a06722e6c70a9dce28a51064abe834160029" - code_ContractTrcToken054_transferTokenContract = "6080604052610118806100136000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece78114604d57806371dc08ce146074575b600080fd5b607273ffffffffffffffffffffffffffffffffffffffff600435166024356044356098565b005b607a60e4565b60408051938452602084019290925282820152519081900360600190f35b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560de573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820b8d4f8ea5443a03d615ea5dfe7a7435498522f9c7abeb25583d953ee2d20be4a0029" - code_ContractTrcToken055_transferTokenContract = "6080604052610118806100136000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece78114604d57806371dc08ce146074575b600080fd5b607273ffffffffffffffffffffffffffffffffffffffff600435166024356044356098565b005b607a60e4565b60408051938452602084019290925282820152519081900360600190f35b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560de573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820b8d4f8ea5443a03d615ea5dfe7a7435498522f9c7abeb25583d953ee2d20be4a0029" - code_ContractTrcToken060_transferTokenContract = "6080604052d3600055d2600155346002556101418061001f6000396000f3006080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305c24200811461005b5780633be9ece71461008157806371dc08ce146100aa575b600080fd5b6100636100b2565b60408051938452602084019290925282820152519081900360600190f35b6100a873ffffffffffffffffffffffffffffffffffffffff600435166024356044356100c0565b005b61006361010d565b600054600154600254909192565b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad0945050505050158015610107573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820a2fb39541e90eda9a2f5f9e7905ef98e66e60dd4b38e00b05de418da3154e7570029" - code_ContractTrcToken061_transferTokenContract = "6080604052d3600055d2600155346002556101418061001f6000396000f3006080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305c24200811461005b5780633be9ece71461008157806371dc08ce146100aa575b600080fd5b6100636100b2565b60408051938452602084019290925282820152519081900360600190f35b6100a873ffffffffffffffffffffffffffffffffffffffff600435166024356044356100c0565b005b61006361010d565b600054600154600254909192565b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad0945050505050158015610107573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820a2fb39541e90eda9a2f5f9e7905ef98e66e60dd4b38e00b05de418da3154e7570029" - code_ContractTrcToken062_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken062_recieveTokenContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken063_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken063_recieveTokenContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken064_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken064_recieveTokenContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken066_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken066_recieveTokenContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken067_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken067_recieveTokenContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken068_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - - code_ContractTrcToken068_recieveTokenContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken071_transferTokenContract = "608060405261022e806100136000396000f3006080604052600436106100775763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f68114610079578063544051aa14610093578063584d4262146100a757806371dc08ce146100cd5780639663d3f2146100ee578063a730416e14610102575b005b610077600160a060020a0360043516602435604435610119565b610077600160a060020a0360043516610159565b6100bb600160a060020a036004351661019c565b60408051918252519081900360200190f35b6100d56101ad565b6040805192835260208301919091528051918290030190f35b610077600160a060020a03600435166101b3565b6100bb600160a060020a03600435166024356101f1565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad0945050505050158015610153573d6000803e3d6000fd5b50505050565b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d0945050505050158015610198573d6000803e3d6000fd5b5050565b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090600190678000000000000001908381818185878a84d0945050505050158015610198573d6000803e3d6000fd5b600160a060020a039190911690d1905600a165627a7a72305820d37032d630dfb2b80dac39db09b9eabfc228e157e20131e49ccde99a2cc3e2710029" - code_ContractTrcToken071_recieveTokenContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken073_transferTokenContract = "608060405260e5806100126000396000f300608060405260043610603e5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663dfc0db988114606f575b34d2d37f70536dc19abf7e0862a7afc0755f548bfd5f0b40cbd9fc87fa19b2e50b454a5660405160405180910390a4005b6078600435607a565b005b604080513481529051d291d3913385d1917fe8e04df6a82498bd5fb1fe7f2168f525c54ee1003b3a56638c858e94fd9e4854919081900360200190a4505600a165627a7a72305820dca795a21bfc9451314c14306b0220175611298bdb59c8b2cfdb1120cb3fda390029" - code_ContractTrcToken074_transferTokenContract = "608060405260e5806100126000396000f300608060405260043610603e5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663dfc0db988114606f575b34d2d37f70536dc19abf7e0862a7afc0755f548bfd5f0b40cbd9fc87fa19b2e50b454a5660405160405180910390a4005b6078600435607a565b005b604080513481529051d291d3913385d1917fe8e04df6a82498bd5fb1fe7f2168f525c54ee1003b3a56638c858e94fd9e4854919081900360200190a4505600a165627a7a72305820dca795a21bfc9451314c14306b0220175611298bdb59c8b2cfdb1120cb3fda390029" - code_ContractTrcToken075_transferTokenContract = "608060405261019c806100136000396000f3006080604052600436106100565763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632ab5cf918114610087578063dfc0db9814610091578063f9a677791461009c575b34d2d37f70536dc19abf7e0862a7afc0755f548bfd5f0b40cbd9fc87fa19b2e50b454a5660405160405180910390a4005b61008f6100a4565b005b61008f6004356100eb565b61008f61012a565b604080513481529051d291d391336780000000000f425319d1917fe8e04df6a82498bd5fb1fe7f2168f525c54ee1003b3a56638c858e94fd9e4854919081900360200190a4565b604080513481529051d291d3913385d1917fe8e04df6a82498bd5fb1fe7f2168f525c54ee1003b3a56638c858e94fd9e4854919081900360200190a450565b604080513481529051d291d391336780000000000f4253d1917fe8e04df6a82498bd5fb1fe7f2168f525c54ee1003b3a56638c858e94fd9e4854919081900360200190a45600a165627a7a723058204eef0c9d8221d37dbe366e9af0815246c4f9239d3f22f27b9db0aa0a3e23aa580029" - code_ContractTrcToken0552_transferTokenContract = "6080604052610118806100136000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece78114604d57806371dc08ce146074575b600080fd5b607273ffffffffffffffffffffffffffffffffffffffff600435166024356044356098565b005b607a60e4565b60408051938452602084019290925282820152519081900360600190f35b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560de573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820b8d4f8ea5443a03d615ea5dfe7a7435498522f9c7abeb25583d953ee2d20be4a0029" - code_ContractTrcToken0553_transferTokenContract = "6080604052610118806100136000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece78114604d57806371dc08ce146074575b600080fd5b607273ffffffffffffffffffffffffffffffffffffffff600435166024356044356098565b005b607a60e4565b60408051938452602084019290925282820152519081900360600190f35b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560de573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820b8d4f8ea5443a03d615ea5dfe7a7435498522f9c7abeb25583d953ee2d20be4a0029" - code_ContractTrcToken0612_transferTokenContract = "6080604052d3600055d2600155346002556101418061001f6000396000f3006080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305c24200811461005b5780633be9ece71461008157806371dc08ce146100aa575b600080fd5b6100636100b2565b60408051938452602084019290925282820152519081900360600190f35b6100a873ffffffffffffffffffffffffffffffffffffffff600435166024356044356100c0565b005b61006361010d565b600054600154600254909192565b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad0945050505050158015610107573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820a2fb39541e90eda9a2f5f9e7905ef98e66e60dd4b38e00b05de418da3154e7570029" - code_ContractTrcToken0613_transferTokenContract = "6080604052d3600055d2600155346002556101418061001f6000396000f3006080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305c24200811461005b5780633be9ece71461008157806371dc08ce146100aa575b600080fd5b6100636100b2565b60408051938452602084019290925282820152519081900360600190f35b6100a873ffffffffffffffffffffffffffffffffffffffff600435166024356044356100c0565b005b61006361010d565b600054600154600254909192565b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad0945050505050158015610107573d6000803e3d6000fd5b50505050565bd3d2349091925600a165627a7a72305820a2fb39541e90eda9a2f5f9e7905ef98e66e60dd4b38e00b05de418da3154e7570029" - code_ContractTrcToken0672_transferTokenContract = "6080604052610343806100136000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663144401f6811461009a5780631ea31431146100b45780632c5c6641146100c8578063544051aa146100dc578063584d4262146100f057806371dc08ce1461011657806393bc91fd14610137578063a730416e1461014b578063acea104514610162575b005b610098600160a060020a0360043516602435604435610176565b610098600160a060020a03600435166101b6565b610098600160a060020a03600435166101f1565b610098600160a060020a0360043516610231565b610104600160a060020a0360043516610270565b60408051918252519081900360200190f35b61011e610281565b6040805192835260208301919091528051918290030190f35b610098600160a060020a0360043516610287565b610104600160a060020a03600435166024356102c7565b610098600160a060020a03600435166102d8565b604051600160a060020a0384169083156108fc029084908490600081818185878a8ad09450505050501580156101b0573d6000803e3d6000fd5b50505050565b604051600160a060020a038216906000906000199082908181818181878a82d09450505050501580156101ed573d6000803e3d6000fd5b5050565b604051600160a060020a0382169060009067800000000000000090620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b604051600160a060020a03821690600090600190680200000000000f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a0316620f4241d190565bd3d29091565b604051600160a060020a03821690600090677fffffffffffffff90620f4241908381818185878a84d09450505050501580156101ed573d6000803e3d6000fd5b600160a060020a039190911690d190565b604051600160a060020a038216906108fc90600090678000000000000001908281818185828a8ad09450505050501580156101ed573d6000803e3d6000fd00a165627a7a72305820716217ff39873b1f852cdc214cfb38a4c2337d18fbd1128b69b2866f7f24ae1c0029" - code_ContractTrcToken0672_recieveTokenContract = "608060405260658060116000396000f30060806040819052d38152d260a0523460c0527fd1ed7a3c020c4f5939654147940a147a8e4e638fa1e8f5664b5efbd1e1f3c4a690606090a10000a165627a7a72305820ea1e6d9606638e6c9e72dcdcc749561b826ec85713c003fae9d4700a2919040f0029" - code_ContractTrcToken029_tokenTest = "608060405261034f806100136000396000f30060806040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630dbe671f8114610050578063c3e911d4146100a8575b600080fd5b34801561005c57600080fd5b50d3801561006957600080fd5b50d2801561007657600080fd5b5061007f6100b8565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6100b66004356024356100d4565b005b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60006100de6101de565b604051809103906000f0801580156100fa573d6000803e3d6000fd5b5090508073ffffffffffffffffffffffffffffffffffffffff1663071f65a883856040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083815260200182815260200192505050602060405180830381600087803b15801561017457600080fd5b505af1158015610188573d6000803e3d6000fd5b505050506040513d602081101561019e57600080fd5b50506000805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff929092169190911790555050565b604051610135806101ef83390190560060806040526000805561011e806100176000396000f30060806040526004361060525763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663071f65a881146054578063890eba68146074578063f96339301460b0575b005b606060043560243560da565b604080519115158252519081900360200190f35b348015607f57600080fd5b50d38015608b57600080fd5b50d28015609757600080fd5b50609e60e6565b60408051918252519081900360200190f35b34801560bb57600080fd5b50d3801560c757600080fd5b50d2801560d357600080fd5b50609e60ec565b50506009600090815590565b60005481565b600054905600a165627a7a72305820a699d9eec788d2a222b703af447d9c2ddffb626fc07a57834af8e3f9bce64dc90029a165627a7a72305820626050611353c2f66f9b94e3935c21fd4dad7cc494b7459f3597451e1b6004de0029" - code_ContractTrcToken030_tokenTest = "608060405260a9806100126000396000f300608060405260043610603e5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663cbf0b0c081146043575b600080fd5b606273ffffffffffffffffffffffffffffffffffffffff600435166064565b005b8073ffffffffffffffffffffffffffffffffffffffff16ff00a165627a7a72305820ad0052aaf68fac3eec3da8d49432d1529ec4df4fa82c1dd2847c088f2575ddb10029" - code_ContractTrcToken031_tokenTest = "608060405260a9806100126000396000f300608060405260043610603e5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663cbf0b0c081146043575b600080fd5b606273ffffffffffffffffffffffffffffffffffffffff600435166064565b005b8073ffffffffffffffffffffffffffffffffffffffff16ff00a165627a7a72305820ad0052aaf68fac3eec3da8d49432d1529ec4df4fa82c1dd2847c088f2575ddb10029" - code_ContractTrcToken034_tokenTest = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506101638061003a6000396000f30060806040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416634957baa18114610050578063e308c52714610079575b600080fd5b61007773ffffffffffffffffffffffffffffffffffffffff600435166024356044356100a0565b005b61007773ffffffffffffffffffffffffffffffffffffffff600435166024356044356100ea565b60405173ffffffffffffffffffffffffffffffffffffffff84169083156108fc029084908490600081818185878a8ad09450505050501580156100e7573d6000803e3d6000fd5b50fe5b60405173ffffffffffffffffffffffffffffffffffffffff84169083156108fc029084908490600081818185878a8ad0945050505050158015610131573d6000803e3d6000fd5b50600080fd00a165627a7a723058204c2d6334ac3ea724949482094951c3b7d11fea1e87b58110d562ef47ddd45c7b0029" - code_ContractTrcToken035_tokenTest = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506101638061003a6000396000f30060806040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416634957baa18114610050578063e308c52714610079575b600080fd5b61007773ffffffffffffffffffffffffffffffffffffffff600435166024356044356100a0565b005b61007773ffffffffffffffffffffffffffffffffffffffff600435166024356044356100ea565b60405173ffffffffffffffffffffffffffffffffffffffff84169083156108fc029084908490600081818185878a8ad09450505050501580156100e7573d6000803e3d6000fd5b50fe5b60405173ffffffffffffffffffffffffffffffffffffffff84169083156108fc029084908490600081818185878a8ad0945050505050158015610131573d6000803e3d6000fd5b50600080fd00a165627a7a723058204c2d6334ac3ea724949482094951c3b7d11fea1e87b58110d562ef47ddd45c7b0029" - code_ContractTrcToken036_transferTokenWithPureTest = "60806040526101db806100136000396000f3006080604052600436106100405763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416639d9e5a388114610042575b005b34801561004e57600080fd5b50d3801561005b57600080fd5b50d2801561006857600080fd5b5061004073ffffffffffffffffffffffffffffffffffffffff600435166024356040805134815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160408051d2815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160408051d3815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160405173ffffffffffffffffffffffffffffffffffffffff831690d280156108fc0291d390600081818185878a8ad0945050505050158015610167573d6000803e3d6000fd5b5060405173ffffffffffffffffffffffffffffffffffffffff8316903480156108fc02916000818181858888f193505050501580156101aa573d6000803e3d6000fd5b5050505600a165627a7a7230582052825d8daae4fb444ce76f049e019c2c66d7b29584058ee7cc88a389e22f41dc0029" - code_ContractTrcToken036_transferTokenWithViewTest = "60806040526101db806100136000396000f3006080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663abecd9838114610042575b005b34801561004e57600080fd5b50d3801561005b57600080fd5b50d2801561006857600080fd5b5061004073ffffffffffffffffffffffffffffffffffffffff600435166024356040805134815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160408051d2815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160408051d3815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160405173ffffffffffffffffffffffffffffffffffffffff831690d280156108fc0291d390600081818185878a8ad0945050505050158015610167573d6000803e3d6000fd5b5060405173ffffffffffffffffffffffffffffffffffffffff8316903480156108fc02916000818181858888f193505050501580156101aa573d6000803e3d6000fd5b5050505600a165627a7a7230582020ddb4a20df32d91af717609926b277d218ac25965d8003ff48adf57a0f10f950029" - code_ContractTrcToken036_transferTokenWithOutPayableTest = "60806040526101db806100136000396000f3006080604052600436106100405763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632b38e5478114610042575b005b34801561004e57600080fd5b50d3801561005b57600080fd5b50d2801561006857600080fd5b5061004073ffffffffffffffffffffffffffffffffffffffff600435166024356040805134815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160408051d2815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160408051d3815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160405173ffffffffffffffffffffffffffffffffffffffff831690d280156108fc0291d390600081818185878a8ad0945050505050158015610167573d6000803e3d6000fd5b5060405173ffffffffffffffffffffffffffffffffffffffff8316903480156108fc02916000818181858888f193505050501580156101aa573d6000803e3d6000fd5b5050505600a165627a7a723058203c20218af63eda8b09394f27964892ee199fa89d93e03506f9a0390dc0b9605d0029" - code_ContractTrcToken037_receiveTrc10Test = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5060ba806100396000396000f300608060405260043610603e5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663ec17fded81146040575b005b348015604b57600080fd5b50d38015605757600080fd5b50d28015606357600080fd5b50603e6004356024356044353082d18314607c57600080fd5b3382d18114608957600080fd5b5050505600a165627a7a723058205da58c4884728798dd87f6219bad7230ff56c1859ca6402bcc3f1584ca0af8080029" - code_ContractTrcToken037_tokenTest = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506101ff8061003a6000396000f3006080604052600436106100275763ffffffff60e060020a6000350416639d01174f811461002c575b600080fd5b61004d73ffffffffffffffffffffffffffffffffffffffff6004351661004f565b005b30d39081d19073ffffffffffffffffffffffffffffffffffffffff831690d1d2821461007a57600080fd5bd2821461008657600080fd5b60405173ffffffffffffffffffffffffffffffffffffffff84169083156108fc02908490d390600081818185878a8ad09450505050501580156100cd573d6000803e3d6000fd5b5030d3d1156100db57600080fd5b80820173ffffffffffffffffffffffffffffffffffffffff8416d3d11461010157600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1660405180807f636865636b54726331302875696e743235362c747263546f6b656e2c75696e7481526020017f32353629000000000000000000000000000000000000000000000000000000008152506024019050604051809103902060e060020a9004838301d360006040518463ffffffff1660e060020a028152600401808481526020018381526020018260ff16815260200193505050506000604051808303816000875af19250505015156101ce57600080fd5b5050505600a165627a7a72305820e91d5a5eda7d9da85983cf55171fa13b3dbf99ebe851321c02831b3f74d7bafc0029" - code_ContractTrcToken038_tokenTest = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506101b78061003a6000396000f3006080604052600436106100275763ffffffff60e060020a6000350416639d01174f811461002c575b600080fd5b61004d73ffffffffffffffffffffffffffffffffffffffff6004351661004f565b005b30d39081d19073ffffffffffffffffffffffffffffffffffffffff831690d1d2821461007a57600080fd5bd2821461008657600080fd5b60405173ffffffffffffffffffffffffffffffffffffffff84169083156108fc02908490d390600081818185878a8ad09450505050501580156100cd573d6000803e3d6000fd5b508273ffffffffffffffffffffffffffffffffffffffff1660405180807f4173736572744572726f72282900000000000000000000000000000000000000815250600d019050604051809103902060e060020a90046040518163ffffffff1660e060020a0281526004016000604051808303816000875af192505050151561015457600080fd5b30d3d1821461016257600080fd5b73ffffffffffffffffffffffffffffffffffffffff8316d3d1811461018657600080fd5b5050505600a165627a7a72305820962d49fbc330584b84b59e537e7450a5ca38cccf106466907e402f8653ab1dee0029" - code_ContractTrcToken038_BTest = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506094806100396000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631966216581146040575b005b348015604b57600080fd5b50d38015605757600080fd5b50d28015606357600080fd5b50603efe00a165627a7a723058200fc1cef003f4eb28c1edc4c7b62c1012237dd9db791e8dac7a9671319ac003440029" - code_ContractTrcToken039_ProxyTest = "60806040526101bc806100136000396000f30060806040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633659cfe681146100965780635c60da1b146100e0575b60005473ffffffffffffffffffffffffffffffffffffffff1680151561007057600080fd5b6040513660008237600081368185600019f43d6000833e808015610092573d83f35b3d83fd5b3480156100a257600080fd5b50d380156100af57600080fd5b50d280156100bc57600080fd5b506100de73ffffffffffffffffffffffffffffffffffffffff60043516610138565b005b3480156100ec57600080fd5b50d380156100f957600080fd5b50d2801561010657600080fd5b5061010f610174565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6000805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a7230582047b47a8f57880f0c2c028e44406b1868bbee2151938629caad7b65668d6a8a140029" - code_ContractTrcToken039_ATest = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5060de806100396000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630455012181146043575b600080fd5b606860043573ffffffffffffffffffffffffffffffffffffffff60243516604435606a565b005b60405173ffffffffffffffffffffffffffffffffffffffff83169084156108fc029085906000818181858888f1935050505015801560ac573d6000803e3d6000fd5b505050505600a165627a7a72305820542cde58d75afb60ec2226b95c592a973666b56931d8ea8d7ed0d0a6bd16e7ea0029" - code_ContractTrcToken039_BTest = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5060e2806100396000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630455012181146043575b600080fd5b606860043573ffffffffffffffffffffffffffffffffffffffff60243516604435606a565b005b60405173ffffffffffffffffffffffffffffffffffffffff83169084156108fc029085908490600081818185878a8ad094505050505015801560b0573d6000803e3d6000fd5b505050505600a165627a7a72305820cccc1489247eb5366214a034107ebfbea955aac5229e03907a82321a1a4484240029" - code_ContractTrcToken041_transferTokenContract = "608060405260e2806100126000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece781146043575b600080fd5b606873ffffffffffffffffffffffffffffffffffffffff60043516602435604435606a565b005b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560b0573d6000803e3d6000fd5b505050505600a165627a7a72305820d7ac1a3b49eeff286b7f2402b93047e60deb6dba47f4f889d921dbcb3bb81f8a0029" - code_ContractTrcToken048_transferTokenContract = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5061010f8061003a6000396000f30060806040526004361060485763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663a94b16d08114604d578063c0063993146065575b600080fd5b6053606b565b60408051918252519081900360200190f35b605360a7565b6040805134815290516000917ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c744919081900360200190a1503490565b60408051d2815290516000917ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c744919081900360200190a150d2905600a165627a7a7230582016ef7f5bc613147860a1de990c4258eaa2ca12ceb1ab21cd9069f50d1db238020029" - code_ContractTrcToken049_transferTokenContract = "608060405260e2806100126000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece781146043575b600080fd5b606873ffffffffffffffffffffffffffffffffffffffff60043516602435604435606a565b005b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560b0573d6000803e3d6000fd5b505050505600a165627a7a72305820d7ac1a3b49eeff286b7f2402b93047e60deb6dba47f4f889d921dbcb3bb81f8a0029" - code_ContractTrcToken050_transferTokenContract = "608060405260e2806100126000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece781146043575b600080fd5b606873ffffffffffffffffffffffffffffffffffffffff60043516602435604435606a565b005b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560b0573d6000803e3d6000fd5b505050505600a165627a7a72305820d7ac1a3b49eeff286b7f2402b93047e60deb6dba47f4f889d921dbcb3bb81f8a0029" - code_ContractTrcToken051_transferTokenContract = "608060405260e2806100126000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece781146043575b600080fd5b606873ffffffffffffffffffffffffffffffffffffffff60043516602435604435606a565b005b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560b0573d6000803e3d6000fd5b505050505600a165627a7a72305820d7ac1a3b49eeff286b7f2402b93047e60deb6dba47f4f889d921dbcb3bb81f8a0029" - code_ContractTrcToken052_transferTokenContract = "608060405260e2806100126000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633be9ece781146043575b600080fd5b606873ffffffffffffffffffffffffffffffffffffffff60043516602435604435606a565b005b60405173ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8ad094505050505015801560b0573d6000803e3d6000fd5b505050505600a165627a7a72305820d7ac1a3b49eeff286b7f2402b93047e60deb6dba47f4f889d921dbcb3bb81f8a0029" - code_ContractTrcToken036_tokenTest = "60806040526101b4806100136000396000f3006080604052600436106100405763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632849fa4f8114610042575b005b61004073ffffffffffffffffffffffffffffffffffffffff600435166024356040805134815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160408051d2815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160408051d3815290517ff82c50f1848136e6c140b186ea0c768b7deda5efffe42c25e96336a90b26c7449181900360200190a160405173ffffffffffffffffffffffffffffffffffffffff831690d280156108fc0291d390600081818185878a8ad0945050505050158015610140573d6000803e3d6000fd5b5060405173ffffffffffffffffffffffffffffffffffffffff8316903480156108fc02916000818181858888f19350505050158015610183573d6000803e3d6000fd5b5050505600a165627a7a72305820ddc15bf8809c92f9c6b6175f2ce1245ef1d65e5fbeccc2bb2772980cedee1eee0029" - code_ContractTrcToken076_originTest = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506103698061003a6000396000f3006080604052600436106100825763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166317ca5481811461008757806360d10813146100ca57806367e404ce146100f95780638be988cd14610151578063938b5f3214610159578063e8da042414610188578063f8a8fd6d14610190575b600080fd5b34801561009357600080fd5b50d380156100a057600080fd5b50d280156100ad57600080fd5b506100b66101c1565b604080519115158252519081900360200190f35b3480156100d657600080fd5b50d380156100e357600080fd5b50d280156100f057600080fd5b506100b66101e3565b34801561010557600080fd5b50d3801561011257600080fd5b50d2801561011f57600080fd5b50610128610204565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6100b6610220565b34801561016557600080fd5b50d3801561017257600080fd5b50d2801561017f57600080fd5b50610128610241565b6100b661025d565b34801561019c57600080fd5b50d380156101a957600080fd5b50d280156101b657600080fd5b506101bf61027f565b005b6001547501000000000000000000000000000000000000000000900460ff1681565b60015474010000000000000000000000000000000000000000900460ff1681565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60015474010000000000000000000000000000000000000000900460ff1690565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b6001547501000000000000000000000000000000000000000000900460ff1690565b600080543273ffffffffffffffffffffffffffffffffffffffff199182168117928390556001805475ff0000000000000000000000000000000000000000001993163390811774ff00000000000000000000000000000000000000001916921474010000000000000000000000000000000000000000029190911791821673ffffffffffffffffffffffffffffffffffffffff92831692909316919091147501000000000000000000000000000000000000000000029190911790555600a165627a7a72305820487fd902512ac719158b1ec219e9e6648b9f47f7f0396d24044f4dca1de4a3c60029" - code_ContractTrcToken077_AddressTest = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5060b6806100396000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416636241c1d881146043575b600080fd5b348015604e57600080fd5b50d38015605a57600080fd5b50d28015606657600080fd5b50606d607f565b60408051918252519081900360200190f35b6040513090819052905600a165627a7a723058207faa3a33e3b875c23563f2fb8ee4506affcd21d818c8399a71dd76fa973f487d0029" - code_ContractTrcToken077_AddressTest1 = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506092806100396000396000f300608060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416636241c1d881146043575b600080fd5b6049605b565b60408051918252519081900360200190f35b6040513090819052905600a165627a7a723058200245dccce3c678939aba5ad813f3fd8d551ef14f01409a8e36bc3dac301113c40029" - code_ContractTrcToken078_AddressTest1 = "6080604052610264806100136000396000f30060806040526004361061003d5763ffffffff60e060020a600035041663648efe8b811461003f578063b45f578b14610059578063d818452114610073575b005b61003d600160a060020a036004358116906024351661008d565b61003d600160a060020a036004358116906024351661011c565b61003d600160a060020a03600435811690602435166101a9565b81600160a060020a031660405180807f7472616e73666572546f286164647265737329000000000000000000000000008152506013019050604051809103902060e060020a9004826040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a031681526020019150506000604051808303816000875af2505050505050565b81600160a060020a031660405180807f7472616e73666572546f286164647265737329000000000000000000000000008152506013019050604051809103902060e060020a9004826040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050600060405180830381865af4505050505050565b81600160a060020a031660405180807f7472616e73666572546f286164647265737329000000000000000000000000008152506013019050604051809103902060e060020a9004826040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a031681526020019150506000604051808303816000875af15050505050505600a165627a7a7230582068a85b5cb5a41f10a7ba8250baed5adf37129ff04399bccae69e483fc85448a90029" - code_ContractTrcToken078_AddressTest2 = "6080604052610166806100136000396000f3006080604052600436106100325763ffffffff60e060020a6000350416630223024e8114610034578063a03fa7e314610055575b005b61003273ffffffffffffffffffffffffffffffffffffffff60043516610076565b61003273ffffffffffffffffffffffffffffffffffffffff600435166100f7565b8073ffffffffffffffffffffffffffffffffffffffff16600560405180807f73657449282900000000000000000000000000000000000000000000000000008152506006019050604051809103902060e060020a9004906040518263ffffffff1660e060020a02815260040160006040518083038185885af1505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff82169060009060059082818181858883f19350505050158015610136573d6000803e3d6000fd5b50505600a165627a7a72305820ede28ac9884104396c5d52bbf3f480cb637f61bc331c2dc561670e6d2700ad630029" - code_ContractTrcToken078_AddressTest3 = "6080604052610172806100136000396000f30060806040526004361061004b5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166367e404ce8114610087578063938b5f32146100df575b6040805132815233602082015281517fdaf0d4aa9a5679e832ac921da67b43572b4326ee2565442d3ed255b48cfb5161929181900390910190a1005b34801561009357600080fd5b50d380156100a057600080fd5b50d280156100ad57600080fd5b506100b661010e565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100eb57600080fd5b50d380156100f857600080fd5b50d2801561010557600080fd5b506100b661012a565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a7230582084426e82a8fde9cefb0ae9f1561ce743354adada27d217c8614c28829eecbcda0029" - code_ContractTrcToken078_AddressTest4 = "6080604052610264806100136000396000f30060806040526004361061003d5763ffffffff60e060020a600035041663648efe8b811461003f578063b45f578b14610059578063d818452114610073575b005b61003d600160a060020a036004358116906024351661008d565b61003d600160a060020a036004358116906024351661011c565b61003d600160a060020a03600435811690602435166101a9565b81600160a060020a031660405180807f7472616e73666572546f286164647265737329000000000000000000000000008152506013019050604051809103902060e060020a9004826040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a031681526020019150506000604051808303816000875af2505050505050565b81600160a060020a031660405180807f7472616e73666572546f286164647265737329000000000000000000000000008152506013019050604051809103902060e060020a9004826040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050600060405180830381865af4505050505050565b81600160a060020a031660405180807f7472616e73666572546f286164647265737329000000000000000000000000008152506013019050604051809103902060e060020a9004826040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a031681526020019150506000604051808303816000875af15050505050505600a165627a7a7230582068a85b5cb5a41f10a7ba8250baed5adf37129ff04399bccae69e483fc85448a90029" - code_ContractTrcToken078_AddressTest5 = "6080604052610166806100136000396000f3006080604052600436106100325763ffffffff60e060020a6000350416630223024e8114610034578063a03fa7e314610055575b005b61003273ffffffffffffffffffffffffffffffffffffffff60043516610076565b61003273ffffffffffffffffffffffffffffffffffffffff600435166100f7565b8073ffffffffffffffffffffffffffffffffffffffff16600560405180807f73657449282900000000000000000000000000000000000000000000000000008152506006019050604051809103902060e060020a9004906040518263ffffffff1660e060020a02815260040160006040518083038185885af1505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff82169060009060059082818181858883f19350505050158015610136573d6000803e3d6000fd5b50505600a165627a7a72305820ede28ac9884104396c5d52bbf3f480cb637f61bc331c2dc561670e6d2700ad630029" - code_ContractTrcToken078_AddressTest6 = "6080604052610172806100136000396000f30060806040526004361061004b5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166367e404ce8114610087578063938b5f32146100df575b6040805132815233602082015281517fdaf0d4aa9a5679e832ac921da67b43572b4326ee2565442d3ed255b48cfb5161929181900390910190a1005b34801561009357600080fd5b50d380156100a057600080fd5b50d280156100ad57600080fd5b506100b661010e565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100eb57600080fd5b50d380156100f857600080fd5b50d2801561010557600080fd5b506100b661012a565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a7230582084426e82a8fde9cefb0ae9f1561ce743354adada27d217c8614c28829eecbcda0029" - code_veryLarge = "60806040523480156200001157600080fd5b50d380156200001f57600080fd5b50d280156200002d57600080fd5b5061c2ec806200003e6000396000f3fe6080604052600436106200003c577c010000000000000000000000000000000000000000000000000000000060003504631a695230811462000041575b600080fd5b62000077600480360360208110156200005957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1662000079565b005b6040516000906200008a906200c1dc565b604051809103906000f080158015620000a7573d6000803e3d6000fd5b5050604051620000b7906200c1dc565b604051809103906000f080158015620000d4573d6000803e3d6000fd5b5050604051620000e4906200c1dc565b604051809103906000f08015801562000101573d6000803e3d6000fd5b505060405162000111906200c1dc565b604051809103906000f0801580156200012e573d6000803e3d6000fd5b50506040516200013e906200c1dc565b604051809103906000f0801580156200015b573d6000803e3d6000fd5b50506040516200016b906200c1dc565b604051809103906000f08015801562000188573d6000803e3d6000fd5b505060405162000198906200c1dc565b604051809103906000f080158015620001b5573d6000803e3d6000fd5b5050604051620001c5906200c1dc565b604051809103906000f080158015620001e2573d6000803e3d6000fd5b5050604051620001f2906200c1dc565b604051809103906000f0801580156200020f573d6000803e3d6000fd5b50506040516200021f906200c1dc565b604051809103906000f0801580156200023c573d6000803e3d6000fd5b50506040516200024c906200c1dc565b604051809103906000f08015801562000269573d6000803e3d6000fd5b505060405162000279906200c1dc565b604051809103906000f08015801562000296573d6000803e3d6000fd5b5050604051620002a6906200c1dc565b604051809103906000f080158015620002c3573d6000803e3d6000fd5b5050604051620002d3906200c1dc565b604051809103906000f080158015620002f0573d6000803e3d6000fd5b505060405162000300906200c1dc565b604051809103906000f0801580156200031d573d6000803e3d6000fd5b50506040516200032d906200c1dc565b604051809103906000f0801580156200034a573d6000803e3d6000fd5b50506040516200035a906200c1dc565b604051809103906000f08015801562000377573d6000803e3d6000fd5b505060405162000387906200c1dc565b604051809103906000f080158015620003a4573d6000803e3d6000fd5b5050604051620003b4906200c1dc565b604051809103906000f080158015620003d1573d6000803e3d6000fd5b5050604051620003e1906200c1dc565b604051809103906000f080158015620003fe573d6000803e3d6000fd5b50506040516200040e906200c1dc565b604051809103906000f0801580156200042b573d6000803e3d6000fd5b50506040516200043b906200c1dc565b604051809103906000f08015801562000458573d6000803e3d6000fd5b505060405162000468906200c1dc565b604051809103906000f08015801562000485573d6000803e3d6000fd5b505060405162000495906200c1dc565b604051809103906000f080158015620004b2573d6000803e3d6000fd5b5050604051620004c2906200c1dc565b604051809103906000f080158015620004df573d6000803e3d6000fd5b5050604051620004ef906200c1dc565b604051809103906000f0801580156200050c573d6000803e3d6000fd5b50506040516200051c906200c1dc565b604051809103906000f08015801562000539573d6000803e3d6000fd5b505060405162000549906200c1dc565b604051809103906000f08015801562000566573d6000803e3d6000fd5b505060405162000576906200c1dc565b604051809103906000f08015801562000593573d6000803e3d6000fd5b5050604051620005a3906200c1dc565b604051809103906000f080158015620005c0573d6000803e3d6000fd5b5050604051620005d0906200c1dc565b604051809103906000f080158015620005ed573d6000803e3d6000fd5b5050604051620005fd906200c1dc565b604051809103906000f0801580156200061a573d6000803e3d6000fd5b50506040516200062a906200c1dc565b604051809103906000f08015801562000647573d6000803e3d6000fd5b505060405162000657906200c1dc565b604051809103906000f08015801562000674573d6000803e3d6000fd5b505060405162000684906200c1dc565b604051809103906000f080158015620006a1573d6000803e3d6000fd5b5050604051620006b1906200c1dc565b604051809103906000f080158015620006ce573d6000803e3d6000fd5b5050604051620006de906200c1dc565b604051809103906000f080158015620006fb573d6000803e3d6000fd5b50506040516200070b906200c1dc565b604051809103906000f08015801562000728573d6000803e3d6000fd5b505060405162000738906200c1dc565b604051809103906000f08015801562000755573d6000803e3d6000fd5b505060405162000765906200c1dc565b604051809103906000f08015801562000782573d6000803e3d6000fd5b505060405162000792906200c1dc565b604051809103906000f080158015620007af573d6000803e3d6000fd5b5050604051620007bf906200c1dc565b604051809103906000f080158015620007dc573d6000803e3d6000fd5b5050604051620007ec906200c1dc565b604051809103906000f08015801562000809573d6000803e3d6000fd5b505060405162000819906200c1dc565b604051809103906000f08015801562000836573d6000803e3d6000fd5b505060405162000846906200c1dc565b604051809103906000f08015801562000863573d6000803e3d6000fd5b505060405162000873906200c1dc565b604051809103906000f08015801562000890573d6000803e3d6000fd5b5050604051620008a0906200c1dc565b604051809103906000f080158015620008bd573d6000803e3d6000fd5b5050604051620008cd906200c1dc565b604051809103906000f080158015620008ea573d6000803e3d6000fd5b5050604051620008fa906200c1dc565b604051809103906000f08015801562000917573d6000803e3d6000fd5b505060405162000927906200c1dc565b604051809103906000f08015801562000944573d6000803e3d6000fd5b505060405162000954906200c1dc565b604051809103906000f08015801562000971573d6000803e3d6000fd5b505060405162000981906200c1dc565b604051809103906000f0801580156200099e573d6000803e3d6000fd5b5050604051620009ae906200c1dc565b604051809103906000f080158015620009cb573d6000803e3d6000fd5b5050604051620009db906200c1dc565b604051809103906000f080158015620009f8573d6000803e3d6000fd5b505060405162000a08906200c1dc565b604051809103906000f08015801562000a25573d6000803e3d6000fd5b505060405162000a35906200c1dc565b604051809103906000f08015801562000a52573d6000803e3d6000fd5b505060405162000a62906200c1dc565b604051809103906000f08015801562000a7f573d6000803e3d6000fd5b505060405162000a8f906200c1dc565b604051809103906000f08015801562000aac573d6000803e3d6000fd5b505060405162000abc906200c1dc565b604051809103906000f08015801562000ad9573d6000803e3d6000fd5b505060405162000ae9906200c1dc565b604051809103906000f08015801562000b06573d6000803e3d6000fd5b505060405162000b16906200c1dc565b604051809103906000f08015801562000b33573d6000803e3d6000fd5b505060405162000b43906200c1dc565b604051809103906000f08015801562000b60573d6000803e3d6000fd5b505060405162000b70906200c1dc565b604051809103906000f08015801562000b8d573d6000803e3d6000fd5b505060405162000b9d906200c1dc565b604051809103906000f08015801562000bba573d6000803e3d6000fd5b505060405162000bca906200c1dc565b604051809103906000f08015801562000be7573d6000803e3d6000fd5b505060405162000bf7906200c1dc565b604051809103906000f08015801562000c14573d6000803e3d6000fd5b505060405162000c24906200c1dc565b604051809103906000f08015801562000c41573d6000803e3d6000fd5b505060405162000c51906200c1dc565b604051809103906000f08015801562000c6e573d6000803e3d6000fd5b505060405162000c7e906200c1dc565b604051809103906000f08015801562000c9b573d6000803e3d6000fd5b505060405162000cab906200c1dc565b604051809103906000f08015801562000cc8573d6000803e3d6000fd5b505060405162000cd8906200c1dc565b604051809103906000f08015801562000cf5573d6000803e3d6000fd5b505060405162000d05906200c1dc565b604051809103906000f08015801562000d22573d6000803e3d6000fd5b505060405162000d32906200c1dc565b604051809103906000f08015801562000d4f573d6000803e3d6000fd5b505060405162000d5f906200c1dc565b604051809103906000f08015801562000d7c573d6000803e3d6000fd5b505060405162000d8c906200c1dc565b604051809103906000f08015801562000da9573d6000803e3d6000fd5b505060405162000db9906200c1dc565b604051809103906000f08015801562000dd6573d6000803e3d6000fd5b505060405162000de6906200c1dc565b604051809103906000f08015801562000e03573d6000803e3d6000fd5b505060405162000e13906200c1dc565b604051809103906000f08015801562000e30573d6000803e3d6000fd5b505060405162000e40906200c1dc565b604051809103906000f08015801562000e5d573d6000803e3d6000fd5b505060405162000e6d906200c1dc565b604051809103906000f08015801562000e8a573d6000803e3d6000fd5b505060405162000e9a906200c1dc565b604051809103906000f08015801562000eb7573d6000803e3d6000fd5b505060405162000ec7906200c1dc565b604051809103906000f08015801562000ee4573d6000803e3d6000fd5b505060405162000ef4906200c1dc565b604051809103906000f08015801562000f11573d6000803e3d6000fd5b505060405162000f21906200c1dc565b604051809103906000f08015801562000f3e573d6000803e3d6000fd5b505060405162000f4e906200c1dc565b604051809103906000f08015801562000f6b573d6000803e3d6000fd5b505060405162000f7b906200c1dc565b604051809103906000f08015801562000f98573d6000803e3d6000fd5b505060405162000fa8906200c1dc565b604051809103906000f08015801562000fc5573d6000803e3d6000fd5b505060405162000fd5906200c1dc565b604051809103906000f08015801562000ff2573d6000803e3d6000fd5b505060405162001002906200c1dc565b604051809103906000f0801580156200101f573d6000803e3d6000fd5b50506040516200102f906200c1dc565b604051809103906000f0801580156200104c573d6000803e3d6000fd5b50506040516200105c906200c1dc565b604051809103906000f08015801562001079573d6000803e3d6000fd5b505060405162001089906200c1dc565b604051809103906000f080158015620010a6573d6000803e3d6000fd5b5050604051620010b6906200c1dc565b604051809103906000f080158015620010d3573d6000803e3d6000fd5b5050604051620010e3906200c1dc565b604051809103906000f08015801562001100573d6000803e3d6000fd5b505060405162001110906200c1dc565b604051809103906000f0801580156200112d573d6000803e3d6000fd5b50506040516200113d906200c1dc565b604051809103906000f0801580156200115a573d6000803e3d6000fd5b50506040516200116a906200c1dc565b604051809103906000f08015801562001187573d6000803e3d6000fd5b505060405162001197906200c1dc565b604051809103906000f080158015620011b4573d6000803e3d6000fd5b5050604051620011c4906200c1dc565b604051809103906000f080158015620011e1573d6000803e3d6000fd5b5050604051620011f1906200c1dc565b604051809103906000f0801580156200120e573d6000803e3d6000fd5b50506040516200121e906200c1dc565b604051809103906000f0801580156200123b573d6000803e3d6000fd5b50506040516200124b906200c1dc565b604051809103906000f08015801562001268573d6000803e3d6000fd5b505060405162001278906200c1dc565b604051809103906000f08015801562001295573d6000803e3d6000fd5b5050604051620012a5906200c1dc565b604051809103906000f080158015620012c2573d6000803e3d6000fd5b5050604051620012d2906200c1dc565b604051809103906000f080158015620012ef573d6000803e3d6000fd5b5050604051620012ff906200c1dc565b604051809103906000f0801580156200131c573d6000803e3d6000fd5b50506040516200132c906200c1dc565b604051809103906000f08015801562001349573d6000803e3d6000fd5b505060405162001359906200c1dc565b604051809103906000f08015801562001376573d6000803e3d6000fd5b505060405162001386906200c1dc565b604051809103906000f080158015620013a3573d6000803e3d6000fd5b5050604051620013b3906200c1dc565b604051809103906000f080158015620013d0573d6000803e3d6000fd5b5050604051620013e0906200c1dc565b604051809103906000f080158015620013fd573d6000803e3d6000fd5b50506040516200140d906200c1dc565b604051809103906000f0801580156200142a573d6000803e3d6000fd5b50506040516200143a906200c1dc565b604051809103906000f08015801562001457573d6000803e3d6000fd5b505060405162001467906200c1dc565b604051809103906000f08015801562001484573d6000803e3d6000fd5b505060405162001494906200c1dc565b604051809103906000f080158015620014b1573d6000803e3d6000fd5b5050604051620014c1906200c1dc565b604051809103906000f080158015620014de573d6000803e3d6000fd5b5050604051620014ee906200c1dc565b604051809103906000f0801580156200150b573d6000803e3d6000fd5b50506040516200151b906200c1dc565b604051809103906000f08015801562001538573d6000803e3d6000fd5b505060405162001548906200c1dc565b604051809103906000f08015801562001565573d6000803e3d6000fd5b505060405162001575906200c1dc565b604051809103906000f08015801562001592573d6000803e3d6000fd5b5050604051620015a2906200c1dc565b604051809103906000f080158015620015bf573d6000803e3d6000fd5b5050604051620015cf906200c1dc565b604051809103906000f080158015620015ec573d6000803e3d6000fd5b5050604051620015fc906200c1dc565b604051809103906000f08015801562001619573d6000803e3d6000fd5b505060405162001629906200c1dc565b604051809103906000f08015801562001646573d6000803e3d6000fd5b505060405162001656906200c1dc565b604051809103906000f08015801562001673573d6000803e3d6000fd5b505060405162001683906200c1dc565b604051809103906000f080158015620016a0573d6000803e3d6000fd5b5050604051620016b0906200c1dc565b604051809103906000f080158015620016cd573d6000803e3d6000fd5b5050604051620016dd906200c1dc565b604051809103906000f080158015620016fa573d6000803e3d6000fd5b50506040516200170a906200c1dc565b604051809103906000f08015801562001727573d6000803e3d6000fd5b505060405162001737906200c1dc565b604051809103906000f08015801562001754573d6000803e3d6000fd5b505060405162001764906200c1dc565b604051809103906000f08015801562001781573d6000803e3d6000fd5b505060405162001791906200c1dc565b604051809103906000f080158015620017ae573d6000803e3d6000fd5b5050604051620017be906200c1dc565b604051809103906000f080158015620017db573d6000803e3d6000fd5b5050604051620017eb906200c1dc565b604051809103906000f08015801562001808573d6000803e3d6000fd5b505060405162001818906200c1dc565b604051809103906000f08015801562001835573d6000803e3d6000fd5b505060405162001845906200c1dc565b604051809103906000f08015801562001862573d6000803e3d6000fd5b505060405162001872906200c1dc565b604051809103906000f0801580156200188f573d6000803e3d6000fd5b50506040516200189f906200c1dc565b604051809103906000f080158015620018bc573d6000803e3d6000fd5b5050604051620018cc906200c1dc565b604051809103906000f080158015620018e9573d6000803e3d6000fd5b5050604051620018f9906200c1dc565b604051809103906000f08015801562001916573d6000803e3d6000fd5b505060405162001926906200c1dc565b604051809103906000f08015801562001943573d6000803e3d6000fd5b505060405162001953906200c1dc565b604051809103906000f08015801562001970573d6000803e3d6000fd5b505060405162001980906200c1dc565b604051809103906000f0801580156200199d573d6000803e3d6000fd5b5050604051620019ad906200c1dc565b604051809103906000f080158015620019ca573d6000803e3d6000fd5b5050604051620019da906200c1dc565b604051809103906000f080158015620019f7573d6000803e3d6000fd5b505060405162001a07906200c1dc565b604051809103906000f08015801562001a24573d6000803e3d6000fd5b505060405162001a34906200c1dc565b604051809103906000f08015801562001a51573d6000803e3d6000fd5b505060405162001a61906200c1dc565b604051809103906000f08015801562001a7e573d6000803e3d6000fd5b505060405162001a8e906200c1dc565b604051809103906000f08015801562001aab573d6000803e3d6000fd5b505060405162001abb906200c1dc565b604051809103906000f08015801562001ad8573d6000803e3d6000fd5b505060405162001ae8906200c1dc565b604051809103906000f08015801562001b05573d6000803e3d6000fd5b505060405162001b15906200c1dc565b604051809103906000f08015801562001b32573d6000803e3d6000fd5b505060405162001b42906200c1dc565b604051809103906000f08015801562001b5f573d6000803e3d6000fd5b505060405162001b6f906200c1dc565b604051809103906000f08015801562001b8c573d6000803e3d6000fd5b505060405162001b9c906200c1dc565b604051809103906000f08015801562001bb9573d6000803e3d6000fd5b505060405162001bc9906200c1dc565b604051809103906000f08015801562001be6573d6000803e3d6000fd5b505060405162001bf6906200c1dc565b604051809103906000f08015801562001c13573d6000803e3d6000fd5b505060405162001c23906200c1dc565b604051809103906000f08015801562001c40573d6000803e3d6000fd5b505060405162001c50906200c1dc565b604051809103906000f08015801562001c6d573d6000803e3d6000fd5b505060405162001c7d906200c1dc565b604051809103906000f08015801562001c9a573d6000803e3d6000fd5b505060405162001caa906200c1dc565b604051809103906000f08015801562001cc7573d6000803e3d6000fd5b505060405162001cd7906200c1dc565b604051809103906000f08015801562001cf4573d6000803e3d6000fd5b505060405162001d04906200c1dc565b604051809103906000f08015801562001d21573d6000803e3d6000fd5b505060405162001d31906200c1dc565b604051809103906000f08015801562001d4e573d6000803e3d6000fd5b505060405162001d5e906200c1dc565b604051809103906000f08015801562001d7b573d6000803e3d6000fd5b505060405162001d8b906200c1dc565b604051809103906000f08015801562001da8573d6000803e3d6000fd5b505060405162001db8906200c1dc565b604051809103906000f08015801562001dd5573d6000803e3d6000fd5b505060405162001de5906200c1dc565b604051809103906000f08015801562001e02573d6000803e3d6000fd5b505060405162001e12906200c1dc565b604051809103906000f08015801562001e2f573d6000803e3d6000fd5b505060405162001e3f906200c1dc565b604051809103906000f08015801562001e5c573d6000803e3d6000fd5b505060405162001e6c906200c1dc565b604051809103906000f08015801562001e89573d6000803e3d6000fd5b505060405162001e99906200c1dc565b604051809103906000f08015801562001eb6573d6000803e3d6000fd5b505060405162001ec6906200c1dc565b604051809103906000f08015801562001ee3573d6000803e3d6000fd5b505060405162001ef3906200c1dc565b604051809103906000f08015801562001f10573d6000803e3d6000fd5b505060405162001f20906200c1dc565b604051809103906000f08015801562001f3d573d6000803e3d6000fd5b505060405162001f4d906200c1dc565b604051809103906000f08015801562001f6a573d6000803e3d6000fd5b505060405162001f7a906200c1dc565b604051809103906000f08015801562001f97573d6000803e3d6000fd5b505060405162001fa7906200c1dc565b604051809103906000f08015801562001fc4573d6000803e3d6000fd5b505060405162001fd4906200c1dc565b604051809103906000f08015801562001ff1573d6000803e3d6000fd5b505060405162002001906200c1dc565b604051809103906000f0801580156200201e573d6000803e3d6000fd5b50506040516200202e906200c1dc565b604051809103906000f0801580156200204b573d6000803e3d6000fd5b50506040516200205b906200c1dc565b604051809103906000f08015801562002078573d6000803e3d6000fd5b505060405162002088906200c1dc565b604051809103906000f080158015620020a5573d6000803e3d6000fd5b5050604051620020b5906200c1dc565b604051809103906000f080158015620020d2573d6000803e3d6000fd5b5050604051620020e2906200c1dc565b604051809103906000f080158015620020ff573d6000803e3d6000fd5b50506040516200210f906200c1dc565b604051809103906000f0801580156200212c573d6000803e3d6000fd5b50506040516200213c906200c1dc565b604051809103906000f08015801562002159573d6000803e3d6000fd5b505060405162002169906200c1dc565b604051809103906000f08015801562002186573d6000803e3d6000fd5b505060405162002196906200c1dc565b604051809103906000f080158015620021b3573d6000803e3d6000fd5b5050604051620021c3906200c1dc565b604051809103906000f080158015620021e0573d6000803e3d6000fd5b5050604051620021f0906200c1dc565b604051809103906000f0801580156200220d573d6000803e3d6000fd5b50506040516200221d906200c1dc565b604051809103906000f0801580156200223a573d6000803e3d6000fd5b50506040516200224a906200c1dc565b604051809103906000f08015801562002267573d6000803e3d6000fd5b505060405162002277906200c1dc565b604051809103906000f08015801562002294573d6000803e3d6000fd5b5050604051620022a4906200c1dc565b604051809103906000f080158015620022c1573d6000803e3d6000fd5b5050604051620022d1906200c1dc565b604051809103906000f080158015620022ee573d6000803e3d6000fd5b5050604051620022fe906200c1dc565b604051809103906000f0801580156200231b573d6000803e3d6000fd5b50506040516200232b906200c1dc565b604051809103906000f08015801562002348573d6000803e3d6000fd5b505060405162002358906200c1dc565b604051809103906000f08015801562002375573d6000803e3d6000fd5b505060405162002385906200c1dc565b604051809103906000f080158015620023a2573d6000803e3d6000fd5b5050604051620023b2906200c1dc565b604051809103906000f080158015620023cf573d6000803e3d6000fd5b5050604051620023df906200c1dc565b604051809103906000f080158015620023fc573d6000803e3d6000fd5b50506040516200240c906200c1dc565b604051809103906000f08015801562002429573d6000803e3d6000fd5b505060405162002439906200c1dc565b604051809103906000f08015801562002456573d6000803e3d6000fd5b505060405162002466906200c1dc565b604051809103906000f08015801562002483573d6000803e3d6000fd5b505060405162002493906200c1dc565b604051809103906000f080158015620024b0573d6000803e3d6000fd5b5050604051620024c0906200c1dc565b604051809103906000f080158015620024dd573d6000803e3d6000fd5b5050604051620024ed906200c1dc565b604051809103906000f0801580156200250a573d6000803e3d6000fd5b50506040516200251a906200c1dc565b604051809103906000f08015801562002537573d6000803e3d6000fd5b505060405162002547906200c1dc565b604051809103906000f08015801562002564573d6000803e3d6000fd5b505060405162002574906200c1dc565b604051809103906000f08015801562002591573d6000803e3d6000fd5b5050604051620025a1906200c1dc565b604051809103906000f080158015620025be573d6000803e3d6000fd5b5050604051620025ce906200c1dc565b604051809103906000f080158015620025eb573d6000803e3d6000fd5b5050604051620025fb906200c1dc565b604051809103906000f08015801562002618573d6000803e3d6000fd5b505060405162002628906200c1dc565b604051809103906000f08015801562002645573d6000803e3d6000fd5b505060405162002655906200c1dc565b604051809103906000f08015801562002672573d6000803e3d6000fd5b505060405162002682906200c1dc565b604051809103906000f0801580156200269f573d6000803e3d6000fd5b5050604051620026af906200c1dc565b604051809103906000f080158015620026cc573d6000803e3d6000fd5b5050604051620026dc906200c1dc565b604051809103906000f080158015620026f9573d6000803e3d6000fd5b505060405162002709906200c1dc565b604051809103906000f08015801562002726573d6000803e3d6000fd5b505060405162002736906200c1dc565b604051809103906000f08015801562002753573d6000803e3d6000fd5b505060405162002763906200c1dc565b604051809103906000f08015801562002780573d6000803e3d6000fd5b505060405162002790906200c1dc565b604051809103906000f080158015620027ad573d6000803e3d6000fd5b5050604051620027bd906200c1dc565b604051809103906000f080158015620027da573d6000803e3d6000fd5b5050604051620027ea906200c1dc565b604051809103906000f08015801562002807573d6000803e3d6000fd5b505060405162002817906200c1dc565b604051809103906000f08015801562002834573d6000803e3d6000fd5b505060405162002844906200c1dc565b604051809103906000f08015801562002861573d6000803e3d6000fd5b505060405162002871906200c1dc565b604051809103906000f0801580156200288e573d6000803e3d6000fd5b50506040516200289e906200c1dc565b604051809103906000f080158015620028bb573d6000803e3d6000fd5b5050604051620028cb906200c1dc565b604051809103906000f080158015620028e8573d6000803e3d6000fd5b5050604051620028f8906200c1dc565b604051809103906000f08015801562002915573d6000803e3d6000fd5b505060405162002925906200c1dc565b604051809103906000f08015801562002942573d6000803e3d6000fd5b505060405162002952906200c1dc565b604051809103906000f0801580156200296f573d6000803e3d6000fd5b50506040516200297f906200c1dc565b604051809103906000f0801580156200299c573d6000803e3d6000fd5b5050604051620029ac906200c1dc565b604051809103906000f080158015620029c9573d6000803e3d6000fd5b5050604051620029d9906200c1dc565b604051809103906000f080158015620029f6573d6000803e3d6000fd5b505060405162002a06906200c1dc565b604051809103906000f08015801562002a23573d6000803e3d6000fd5b505060405162002a33906200c1dc565b604051809103906000f08015801562002a50573d6000803e3d6000fd5b505060405162002a60906200c1dc565b604051809103906000f08015801562002a7d573d6000803e3d6000fd5b505060405162002a8d906200c1dc565b604051809103906000f08015801562002aaa573d6000803e3d6000fd5b505060405162002aba906200c1dc565b604051809103906000f08015801562002ad7573d6000803e3d6000fd5b505060405162002ae7906200c1dc565b604051809103906000f08015801562002b04573d6000803e3d6000fd5b505060405162002b14906200c1dc565b604051809103906000f08015801562002b31573d6000803e3d6000fd5b505060405162002b41906200c1dc565b604051809103906000f08015801562002b5e573d6000803e3d6000fd5b505060405162002b6e906200c1dc565b604051809103906000f08015801562002b8b573d6000803e3d6000fd5b505060405162002b9b906200c1dc565b604051809103906000f08015801562002bb8573d6000803e3d6000fd5b505060405162002bc8906200c1dc565b604051809103906000f08015801562002be5573d6000803e3d6000fd5b505060405162002bf5906200c1dc565b604051809103906000f08015801562002c12573d6000803e3d6000fd5b505060405162002c22906200c1dc565b604051809103906000f08015801562002c3f573d6000803e3d6000fd5b505060405162002c4f906200c1dc565b604051809103906000f08015801562002c6c573d6000803e3d6000fd5b505060405162002c7c906200c1dc565b604051809103906000f08015801562002c99573d6000803e3d6000fd5b505060405162002ca9906200c1dc565b604051809103906000f08015801562002cc6573d6000803e3d6000fd5b505060405162002cd6906200c1dc565b604051809103906000f08015801562002cf3573d6000803e3d6000fd5b505060405162002d03906200c1dc565b604051809103906000f08015801562002d20573d6000803e3d6000fd5b505060405162002d30906200c1dc565b604051809103906000f08015801562002d4d573d6000803e3d6000fd5b505060405162002d5d906200c1dc565b604051809103906000f08015801562002d7a573d6000803e3d6000fd5b505060405162002d8a906200c1dc565b604051809103906000f08015801562002da7573d6000803e3d6000fd5b505060405162002db7906200c1dc565b604051809103906000f08015801562002dd4573d6000803e3d6000fd5b505060405162002de4906200c1dc565b604051809103906000f08015801562002e01573d6000803e3d6000fd5b505060405162002e11906200c1dc565b604051809103906000f08015801562002e2e573d6000803e3d6000fd5b505060405162002e3e906200c1dc565b604051809103906000f08015801562002e5b573d6000803e3d6000fd5b505060405162002e6b906200c1dc565b604051809103906000f08015801562002e88573d6000803e3d6000fd5b505060405162002e98906200c1dc565b604051809103906000f08015801562002eb5573d6000803e3d6000fd5b505060405162002ec5906200c1dc565b604051809103906000f08015801562002ee2573d6000803e3d6000fd5b505060405162002ef2906200c1dc565b604051809103906000f08015801562002f0f573d6000803e3d6000fd5b505060405162002f1f906200c1dc565b604051809103906000f08015801562002f3c573d6000803e3d6000fd5b505060405162002f4c906200c1dc565b604051809103906000f08015801562002f69573d6000803e3d6000fd5b505060405162002f79906200c1dc565b604051809103906000f08015801562002f96573d6000803e3d6000fd5b505060405162002fa6906200c1dc565b604051809103906000f08015801562002fc3573d6000803e3d6000fd5b505060405162002fd3906200c1dc565b604051809103906000f08015801562002ff0573d6000803e3d6000fd5b505060405162003000906200c1dc565b604051809103906000f0801580156200301d573d6000803e3d6000fd5b50506040516200302d906200c1dc565b604051809103906000f0801580156200304a573d6000803e3d6000fd5b50506040516200305a906200c1dc565b604051809103906000f08015801562003077573d6000803e3d6000fd5b505060405162003087906200c1dc565b604051809103906000f080158015620030a4573d6000803e3d6000fd5b5050604051620030b4906200c1dc565b604051809103906000f080158015620030d1573d6000803e3d6000fd5b5050604051620030e1906200c1dc565b604051809103906000f080158015620030fe573d6000803e3d6000fd5b50506040516200310e906200c1dc565b604051809103906000f0801580156200312b573d6000803e3d6000fd5b50506040516200313b906200c1dc565b604051809103906000f08015801562003158573d6000803e3d6000fd5b505060405162003168906200c1dc565b604051809103906000f08015801562003185573d6000803e3d6000fd5b505060405162003195906200c1dc565b604051809103906000f080158015620031b2573d6000803e3d6000fd5b5050604051620031c2906200c1dc565b604051809103906000f080158015620031df573d6000803e3d6000fd5b5050604051620031ef906200c1dc565b604051809103906000f0801580156200320c573d6000803e3d6000fd5b50506040516200321c906200c1dc565b604051809103906000f08015801562003239573d6000803e3d6000fd5b505060405162003249906200c1dc565b604051809103906000f08015801562003266573d6000803e3d6000fd5b505060405162003276906200c1dc565b604051809103906000f08015801562003293573d6000803e3d6000fd5b5050604051620032a3906200c1dc565b604051809103906000f080158015620032c0573d6000803e3d6000fd5b5050604051620032d0906200c1dc565b604051809103906000f080158015620032ed573d6000803e3d6000fd5b5050604051620032fd906200c1dc565b604051809103906000f0801580156200331a573d6000803e3d6000fd5b50506040516200332a906200c1dc565b604051809103906000f08015801562003347573d6000803e3d6000fd5b505060405162003357906200c1dc565b604051809103906000f08015801562003374573d6000803e3d6000fd5b505060405162003384906200c1dc565b604051809103906000f080158015620033a1573d6000803e3d6000fd5b5050604051620033b1906200c1dc565b604051809103906000f080158015620033ce573d6000803e3d6000fd5b5050604051620033de906200c1dc565b604051809103906000f080158015620033fb573d6000803e3d6000fd5b50506040516200340b906200c1dc565b604051809103906000f08015801562003428573d6000803e3d6000fd5b505060405162003438906200c1dc565b604051809103906000f08015801562003455573d6000803e3d6000fd5b505060405162003465906200c1dc565b604051809103906000f08015801562003482573d6000803e3d6000fd5b505060405162003492906200c1dc565b604051809103906000f080158015620034af573d6000803e3d6000fd5b5050604051620034bf906200c1dc565b604051809103906000f080158015620034dc573d6000803e3d6000fd5b5050604051620034ec906200c1dc565b604051809103906000f08015801562003509573d6000803e3d6000fd5b505060405162003519906200c1dc565b604051809103906000f08015801562003536573d6000803e3d6000fd5b505060405162003546906200c1dc565b604051809103906000f08015801562003563573d6000803e3d6000fd5b505060405162003573906200c1dc565b604051809103906000f08015801562003590573d6000803e3d6000fd5b5050604051620035a0906200c1dc565b604051809103906000f080158015620035bd573d6000803e3d6000fd5b5050604051620035cd906200c1dc565b604051809103906000f080158015620035ea573d6000803e3d6000fd5b5050604051620035fa906200c1dc565b604051809103906000f08015801562003617573d6000803e3d6000fd5b505060405162003627906200c1dc565b604051809103906000f08015801562003644573d6000803e3d6000fd5b505060405162003654906200c1dc565b604051809103906000f08015801562003671573d6000803e3d6000fd5b505060405162003681906200c1dc565b604051809103906000f0801580156200369e573d6000803e3d6000fd5b5050604051620036ae906200c1dc565b604051809103906000f080158015620036cb573d6000803e3d6000fd5b5050604051620036db906200c1dc565b604051809103906000f080158015620036f8573d6000803e3d6000fd5b505060405162003708906200c1dc565b604051809103906000f08015801562003725573d6000803e3d6000fd5b505060405162003735906200c1dc565b604051809103906000f08015801562003752573d6000803e3d6000fd5b505060405162003762906200c1dc565b604051809103906000f0801580156200377f573d6000803e3d6000fd5b50506040516200378f906200c1dc565b604051809103906000f080158015620037ac573d6000803e3d6000fd5b5050604051620037bc906200c1dc565b604051809103906000f080158015620037d9573d6000803e3d6000fd5b5050604051620037e9906200c1dc565b604051809103906000f08015801562003806573d6000803e3d6000fd5b505060405162003816906200c1dc565b604051809103906000f08015801562003833573d6000803e3d6000fd5b505060405162003843906200c1dc565b604051809103906000f08015801562003860573d6000803e3d6000fd5b505060405162003870906200c1dc565b604051809103906000f0801580156200388d573d6000803e3d6000fd5b50506040516200389d906200c1dc565b604051809103906000f080158015620038ba573d6000803e3d6000fd5b5050604051620038ca906200c1dc565b604051809103906000f080158015620038e7573d6000803e3d6000fd5b5050604051620038f7906200c1dc565b604051809103906000f08015801562003914573d6000803e3d6000fd5b505060405162003924906200c1dc565b604051809103906000f08015801562003941573d6000803e3d6000fd5b505060405162003951906200c1dc565b604051809103906000f0801580156200396e573d6000803e3d6000fd5b50506040516200397e906200c1dc565b604051809103906000f0801580156200399b573d6000803e3d6000fd5b5050604051620039ab906200c1dc565b604051809103906000f080158015620039c8573d6000803e3d6000fd5b5050604051620039d8906200c1dc565b604051809103906000f080158015620039f5573d6000803e3d6000fd5b505060405162003a05906200c1dc565b604051809103906000f08015801562003a22573d6000803e3d6000fd5b505060405162003a32906200c1dc565b604051809103906000f08015801562003a4f573d6000803e3d6000fd5b505060405162003a5f906200c1dc565b604051809103906000f08015801562003a7c573d6000803e3d6000fd5b505060405162003a8c906200c1dc565b604051809103906000f08015801562003aa9573d6000803e3d6000fd5b505060405162003ab9906200c1dc565b604051809103906000f08015801562003ad6573d6000803e3d6000fd5b505060405162003ae6906200c1dc565b604051809103906000f08015801562003b03573d6000803e3d6000fd5b505060405162003b13906200c1dc565b604051809103906000f08015801562003b30573d6000803e3d6000fd5b505060405162003b40906200c1dc565b604051809103906000f08015801562003b5d573d6000803e3d6000fd5b505060405162003b6d906200c1dc565b604051809103906000f08015801562003b8a573d6000803e3d6000fd5b505060405162003b9a906200c1dc565b604051809103906000f08015801562003bb7573d6000803e3d6000fd5b505060405162003bc7906200c1dc565b604051809103906000f08015801562003be4573d6000803e3d6000fd5b505060405162003bf4906200c1dc565b604051809103906000f08015801562003c11573d6000803e3d6000fd5b505060405162003c21906200c1dc565b604051809103906000f08015801562003c3e573d6000803e3d6000fd5b505060405162003c4e906200c1dc565b604051809103906000f08015801562003c6b573d6000803e3d6000fd5b505060405162003c7b906200c1dc565b604051809103906000f08015801562003c98573d6000803e3d6000fd5b505060405162003ca8906200c1dc565b604051809103906000f08015801562003cc5573d6000803e3d6000fd5b505060405162003cd5906200c1dc565b604051809103906000f08015801562003cf2573d6000803e3d6000fd5b505060405162003d02906200c1dc565b604051809103906000f08015801562003d1f573d6000803e3d6000fd5b505060405162003d2f906200c1dc565b604051809103906000f08015801562003d4c573d6000803e3d6000fd5b505060405162003d5c906200c1dc565b604051809103906000f08015801562003d79573d6000803e3d6000fd5b505060405162003d89906200c1dc565b604051809103906000f08015801562003da6573d6000803e3d6000fd5b505060405162003db6906200c1dc565b604051809103906000f08015801562003dd3573d6000803e3d6000fd5b505060405162003de3906200c1dc565b604051809103906000f08015801562003e00573d6000803e3d6000fd5b505060405162003e10906200c1dc565b604051809103906000f08015801562003e2d573d6000803e3d6000fd5b505060405162003e3d906200c1dc565b604051809103906000f08015801562003e5a573d6000803e3d6000fd5b505060405162003e6a906200c1dc565b604051809103906000f08015801562003e87573d6000803e3d6000fd5b505060405162003e97906200c1dc565b604051809103906000f08015801562003eb4573d6000803e3d6000fd5b505060405162003ec4906200c1dc565b604051809103906000f08015801562003ee1573d6000803e3d6000fd5b505060405162003ef1906200c1dc565b604051809103906000f08015801562003f0e573d6000803e3d6000fd5b505060405162003f1e906200c1dc565b604051809103906000f08015801562003f3b573d6000803e3d6000fd5b505060405162003f4b906200c1dc565b604051809103906000f08015801562003f68573d6000803e3d6000fd5b505060405162003f78906200c1dc565b604051809103906000f08015801562003f95573d6000803e3d6000fd5b505060405162003fa5906200c1dc565b604051809103906000f08015801562003fc2573d6000803e3d6000fd5b505060405162003fd2906200c1dc565b604051809103906000f08015801562003fef573d6000803e3d6000fd5b505060405162003fff906200c1dc565b604051809103906000f0801580156200401c573d6000803e3d6000fd5b50506040516200402c906200c1dc565b604051809103906000f08015801562004049573d6000803e3d6000fd5b505060405162004059906200c1dc565b604051809103906000f08015801562004076573d6000803e3d6000fd5b505060405162004086906200c1dc565b604051809103906000f080158015620040a3573d6000803e3d6000fd5b5050604051620040b3906200c1dc565b604051809103906000f080158015620040d0573d6000803e3d6000fd5b5050604051620040e0906200c1dc565b604051809103906000f080158015620040fd573d6000803e3d6000fd5b50506040516200410d906200c1dc565b604051809103906000f0801580156200412a573d6000803e3d6000fd5b50506040516200413a906200c1dc565b604051809103906000f08015801562004157573d6000803e3d6000fd5b505060405162004167906200c1dc565b604051809103906000f08015801562004184573d6000803e3d6000fd5b505060405162004194906200c1dc565b604051809103906000f080158015620041b1573d6000803e3d6000fd5b5050604051620041c1906200c1dc565b604051809103906000f080158015620041de573d6000803e3d6000fd5b5050604051620041ee906200c1dc565b604051809103906000f0801580156200420b573d6000803e3d6000fd5b50506040516200421b906200c1dc565b604051809103906000f08015801562004238573d6000803e3d6000fd5b505060405162004248906200c1dc565b604051809103906000f08015801562004265573d6000803e3d6000fd5b505060405162004275906200c1dc565b604051809103906000f08015801562004292573d6000803e3d6000fd5b5050604051620042a2906200c1dc565b604051809103906000f080158015620042bf573d6000803e3d6000fd5b5050604051620042cf906200c1dc565b604051809103906000f080158015620042ec573d6000803e3d6000fd5b5050604051620042fc906200c1dc565b604051809103906000f08015801562004319573d6000803e3d6000fd5b505060405162004329906200c1dc565b604051809103906000f08015801562004346573d6000803e3d6000fd5b505060405162004356906200c1dc565b604051809103906000f08015801562004373573d6000803e3d6000fd5b505060405162004383906200c1dc565b604051809103906000f080158015620043a0573d6000803e3d6000fd5b5050604051620043b0906200c1dc565b604051809103906000f080158015620043cd573d6000803e3d6000fd5b5050604051620043dd906200c1dc565b604051809103906000f080158015620043fa573d6000803e3d6000fd5b50506040516200440a906200c1dc565b604051809103906000f08015801562004427573d6000803e3d6000fd5b505060405162004437906200c1dc565b604051809103906000f08015801562004454573d6000803e3d6000fd5b505060405162004464906200c1dc565b604051809103906000f08015801562004481573d6000803e3d6000fd5b505060405162004491906200c1dc565b604051809103906000f080158015620044ae573d6000803e3d6000fd5b5050604051620044be906200c1dc565b604051809103906000f080158015620044db573d6000803e3d6000fd5b5050604051620044eb906200c1dc565b604051809103906000f08015801562004508573d6000803e3d6000fd5b505060405162004518906200c1dc565b604051809103906000f08015801562004535573d6000803e3d6000fd5b505060405162004545906200c1dc565b604051809103906000f08015801562004562573d6000803e3d6000fd5b505060405162004572906200c1dc565b604051809103906000f0801580156200458f573d6000803e3d6000fd5b50506040516200459f906200c1dc565b604051809103906000f080158015620045bc573d6000803e3d6000fd5b5050604051620045cc906200c1dc565b604051809103906000f080158015620045e9573d6000803e3d6000fd5b5050604051620045f9906200c1dc565b604051809103906000f08015801562004616573d6000803e3d6000fd5b505060405162004626906200c1dc565b604051809103906000f08015801562004643573d6000803e3d6000fd5b505060405162004653906200c1dc565b604051809103906000f08015801562004670573d6000803e3d6000fd5b505060405162004680906200c1dc565b604051809103906000f0801580156200469d573d6000803e3d6000fd5b5050604051620046ad906200c1dc565b604051809103906000f080158015620046ca573d6000803e3d6000fd5b5050604051620046da906200c1dc565b604051809103906000f080158015620046f7573d6000803e3d6000fd5b505060405162004707906200c1dc565b604051809103906000f08015801562004724573d6000803e3d6000fd5b505060405162004734906200c1dc565b604051809103906000f08015801562004751573d6000803e3d6000fd5b505060405162004761906200c1dc565b604051809103906000f0801580156200477e573d6000803e3d6000fd5b50506040516200478e906200c1dc565b604051809103906000f080158015620047ab573d6000803e3d6000fd5b5050604051620047bb906200c1dc565b604051809103906000f080158015620047d8573d6000803e3d6000fd5b5050604051620047e8906200c1dc565b604051809103906000f08015801562004805573d6000803e3d6000fd5b505060405162004815906200c1dc565b604051809103906000f08015801562004832573d6000803e3d6000fd5b505060405162004842906200c1dc565b604051809103906000f0801580156200485f573d6000803e3d6000fd5b50506040516200486f906200c1dc565b604051809103906000f0801580156200488c573d6000803e3d6000fd5b50506040516200489c906200c1dc565b604051809103906000f080158015620048b9573d6000803e3d6000fd5b5050604051620048c9906200c1dc565b604051809103906000f080158015620048e6573d6000803e3d6000fd5b5050604051620048f6906200c1dc565b604051809103906000f08015801562004913573d6000803e3d6000fd5b505060405162004923906200c1dc565b604051809103906000f08015801562004940573d6000803e3d6000fd5b505060405162004950906200c1dc565b604051809103906000f0801580156200496d573d6000803e3d6000fd5b50506040516200497d906200c1dc565b604051809103906000f0801580156200499a573d6000803e3d6000fd5b5050604051620049aa906200c1dc565b604051809103906000f080158015620049c7573d6000803e3d6000fd5b5050604051620049d7906200c1dc565b604051809103906000f080158015620049f4573d6000803e3d6000fd5b505060405162004a04906200c1dc565b604051809103906000f08015801562004a21573d6000803e3d6000fd5b505060405162004a31906200c1dc565b604051809103906000f08015801562004a4e573d6000803e3d6000fd5b505060405162004a5e906200c1dc565b604051809103906000f08015801562004a7b573d6000803e3d6000fd5b505060405162004a8b906200c1dc565b604051809103906000f08015801562004aa8573d6000803e3d6000fd5b505060405162004ab8906200c1dc565b604051809103906000f08015801562004ad5573d6000803e3d6000fd5b505060405162004ae5906200c1dc565b604051809103906000f08015801562004b02573d6000803e3d6000fd5b505060405162004b12906200c1dc565b604051809103906000f08015801562004b2f573d6000803e3d6000fd5b505060405162004b3f906200c1dc565b604051809103906000f08015801562004b5c573d6000803e3d6000fd5b505060405162004b6c906200c1dc565b604051809103906000f08015801562004b89573d6000803e3d6000fd5b505060405162004b99906200c1dc565b604051809103906000f08015801562004bb6573d6000803e3d6000fd5b505060405162004bc6906200c1dc565b604051809103906000f08015801562004be3573d6000803e3d6000fd5b505060405162004bf3906200c1dc565b604051809103906000f08015801562004c10573d6000803e3d6000fd5b505060405162004c20906200c1dc565b604051809103906000f08015801562004c3d573d6000803e3d6000fd5b505060405162004c4d906200c1dc565b604051809103906000f08015801562004c6a573d6000803e3d6000fd5b505060405162004c7a906200c1dc565b604051809103906000f08015801562004c97573d6000803e3d6000fd5b505060405162004ca7906200c1dc565b604051809103906000f08015801562004cc4573d6000803e3d6000fd5b505060405162004cd4906200c1dc565b604051809103906000f08015801562004cf1573d6000803e3d6000fd5b505060405162004d01906200c1dc565b604051809103906000f08015801562004d1e573d6000803e3d6000fd5b505060405162004d2e906200c1dc565b604051809103906000f08015801562004d4b573d6000803e3d6000fd5b505060405162004d5b906200c1dc565b604051809103906000f08015801562004d78573d6000803e3d6000fd5b505060405162004d88906200c1dc565b604051809103906000f08015801562004da5573d6000803e3d6000fd5b505060405162004db5906200c1dc565b604051809103906000f08015801562004dd2573d6000803e3d6000fd5b505060405162004de2906200c1dc565b604051809103906000f08015801562004dff573d6000803e3d6000fd5b505060405162004e0f906200c1dc565b604051809103906000f08015801562004e2c573d6000803e3d6000fd5b505060405162004e3c906200c1dc565b604051809103906000f08015801562004e59573d6000803e3d6000fd5b505060405162004e69906200c1dc565b604051809103906000f08015801562004e86573d6000803e3d6000fd5b505060405162004e96906200c1dc565b604051809103906000f08015801562004eb3573d6000803e3d6000fd5b505060405162004ec3906200c1dc565b604051809103906000f08015801562004ee0573d6000803e3d6000fd5b505060405162004ef0906200c1dc565b604051809103906000f08015801562004f0d573d6000803e3d6000fd5b505060405162004f1d906200c1dc565b604051809103906000f08015801562004f3a573d6000803e3d6000fd5b505060405162004f4a906200c1dc565b604051809103906000f08015801562004f67573d6000803e3d6000fd5b505060405162004f77906200c1dc565b604051809103906000f08015801562004f94573d6000803e3d6000fd5b505060405162004fa4906200c1dc565b604051809103906000f08015801562004fc1573d6000803e3d6000fd5b505060405162004fd1906200c1dc565b604051809103906000f08015801562004fee573d6000803e3d6000fd5b505060405162004ffe906200c1dc565b604051809103906000f0801580156200501b573d6000803e3d6000fd5b50506040516200502b906200c1dc565b604051809103906000f08015801562005048573d6000803e3d6000fd5b505060405162005058906200c1dc565b604051809103906000f08015801562005075573d6000803e3d6000fd5b505060405162005085906200c1dc565b604051809103906000f080158015620050a2573d6000803e3d6000fd5b5050604051620050b2906200c1dc565b604051809103906000f080158015620050cf573d6000803e3d6000fd5b5050604051620050df906200c1dc565b604051809103906000f080158015620050fc573d6000803e3d6000fd5b50506040516200510c906200c1dc565b604051809103906000f08015801562005129573d6000803e3d6000fd5b505060405162005139906200c1dc565b604051809103906000f08015801562005156573d6000803e3d6000fd5b505060405162005166906200c1dc565b604051809103906000f08015801562005183573d6000803e3d6000fd5b505060405162005193906200c1dc565b604051809103906000f080158015620051b0573d6000803e3d6000fd5b5050604051620051c0906200c1dc565b604051809103906000f080158015620051dd573d6000803e3d6000fd5b5050604051620051ed906200c1dc565b604051809103906000f0801580156200520a573d6000803e3d6000fd5b50506040516200521a906200c1dc565b604051809103906000f08015801562005237573d6000803e3d6000fd5b505060405162005247906200c1dc565b604051809103906000f08015801562005264573d6000803e3d6000fd5b505060405162005274906200c1dc565b604051809103906000f08015801562005291573d6000803e3d6000fd5b5050604051620052a1906200c1dc565b604051809103906000f080158015620052be573d6000803e3d6000fd5b5050604051620052ce906200c1dc565b604051809103906000f080158015620052eb573d6000803e3d6000fd5b5050604051620052fb906200c1dc565b604051809103906000f08015801562005318573d6000803e3d6000fd5b505060405162005328906200c1dc565b604051809103906000f08015801562005345573d6000803e3d6000fd5b505060405162005355906200c1dc565b604051809103906000f08015801562005372573d6000803e3d6000fd5b505060405162005382906200c1dc565b604051809103906000f0801580156200539f573d6000803e3d6000fd5b5050604051620053af906200c1dc565b604051809103906000f080158015620053cc573d6000803e3d6000fd5b5050604051620053dc906200c1dc565b604051809103906000f080158015620053f9573d6000803e3d6000fd5b505060405162005409906200c1dc565b604051809103906000f08015801562005426573d6000803e3d6000fd5b505060405162005436906200c1dc565b604051809103906000f08015801562005453573d6000803e3d6000fd5b505060405162005463906200c1dc565b604051809103906000f08015801562005480573d6000803e3d6000fd5b505060405162005490906200c1dc565b604051809103906000f080158015620054ad573d6000803e3d6000fd5b5050604051620054bd906200c1dc565b604051809103906000f080158015620054da573d6000803e3d6000fd5b5050604051620054ea906200c1dc565b604051809103906000f08015801562005507573d6000803e3d6000fd5b505060405162005517906200c1dc565b604051809103906000f08015801562005534573d6000803e3d6000fd5b505060405162005544906200c1dc565b604051809103906000f08015801562005561573d6000803e3d6000fd5b505060405162005571906200c1dc565b604051809103906000f0801580156200558e573d6000803e3d6000fd5b50506040516200559e906200c1dc565b604051809103906000f080158015620055bb573d6000803e3d6000fd5b5050604051620055cb906200c1dc565b604051809103906000f080158015620055e8573d6000803e3d6000fd5b5050604051620055f8906200c1dc565b604051809103906000f08015801562005615573d6000803e3d6000fd5b505060405162005625906200c1dc565b604051809103906000f08015801562005642573d6000803e3d6000fd5b505060405162005652906200c1dc565b604051809103906000f0801580156200566f573d6000803e3d6000fd5b50506040516200567f906200c1dc565b604051809103906000f0801580156200569c573d6000803e3d6000fd5b5050604051620056ac906200c1dc565b604051809103906000f080158015620056c9573d6000803e3d6000fd5b5050604051620056d9906200c1dc565b604051809103906000f080158015620056f6573d6000803e3d6000fd5b505060405162005706906200c1dc565b604051809103906000f08015801562005723573d6000803e3d6000fd5b505060405162005733906200c1dc565b604051809103906000f08015801562005750573d6000803e3d6000fd5b505060405162005760906200c1dc565b604051809103906000f0801580156200577d573d6000803e3d6000fd5b50506040516200578d906200c1dc565b604051809103906000f080158015620057aa573d6000803e3d6000fd5b5050604051620057ba906200c1dc565b604051809103906000f080158015620057d7573d6000803e3d6000fd5b5050604051620057e7906200c1dc565b604051809103906000f08015801562005804573d6000803e3d6000fd5b505060405162005814906200c1dc565b604051809103906000f08015801562005831573d6000803e3d6000fd5b505060405162005841906200c1dc565b604051809103906000f0801580156200585e573d6000803e3d6000fd5b50506040516200586e906200c1dc565b604051809103906000f0801580156200588b573d6000803e3d6000fd5b50506040516200589b906200c1dc565b604051809103906000f080158015620058b8573d6000803e3d6000fd5b5050604051620058c8906200c1dc565b604051809103906000f080158015620058e5573d6000803e3d6000fd5b5050604051620058f5906200c1dc565b604051809103906000f08015801562005912573d6000803e3d6000fd5b505060405162005922906200c1dc565b604051809103906000f0801580156200593f573d6000803e3d6000fd5b50506040516200594f906200c1dc565b604051809103906000f0801580156200596c573d6000803e3d6000fd5b50506040516200597c906200c1dc565b604051809103906000f08015801562005999573d6000803e3d6000fd5b5050604051620059a9906200c1dc565b604051809103906000f080158015620059c6573d6000803e3d6000fd5b5050604051620059d6906200c1dc565b604051809103906000f080158015620059f3573d6000803e3d6000fd5b505060405162005a03906200c1dc565b604051809103906000f08015801562005a20573d6000803e3d6000fd5b505060405162005a30906200c1dc565b604051809103906000f08015801562005a4d573d6000803e3d6000fd5b505060405162005a5d906200c1dc565b604051809103906000f08015801562005a7a573d6000803e3d6000fd5b505060405162005a8a906200c1dc565b604051809103906000f08015801562005aa7573d6000803e3d6000fd5b505060405162005ab7906200c1dc565b604051809103906000f08015801562005ad4573d6000803e3d6000fd5b505060405162005ae4906200c1dc565b604051809103906000f08015801562005b01573d6000803e3d6000fd5b505060405162005b11906200c1dc565b604051809103906000f08015801562005b2e573d6000803e3d6000fd5b505060405162005b3e906200c1dc565b604051809103906000f08015801562005b5b573d6000803e3d6000fd5b505060405162005b6b906200c1dc565b604051809103906000f08015801562005b88573d6000803e3d6000fd5b505060405162005b98906200c1dc565b604051809103906000f08015801562005bb5573d6000803e3d6000fd5b505060405162005bc5906200c1dc565b604051809103906000f08015801562005be2573d6000803e3d6000fd5b505060405162005bf2906200c1dc565b604051809103906000f08015801562005c0f573d6000803e3d6000fd5b505060405162005c1f906200c1dc565b604051809103906000f08015801562005c3c573d6000803e3d6000fd5b505060405162005c4c906200c1dc565b604051809103906000f08015801562005c69573d6000803e3d6000fd5b505060405162005c79906200c1dc565b604051809103906000f08015801562005c96573d6000803e3d6000fd5b505060405162005ca6906200c1dc565b604051809103906000f08015801562005cc3573d6000803e3d6000fd5b505060405162005cd3906200c1dc565b604051809103906000f08015801562005cf0573d6000803e3d6000fd5b505060405162005d00906200c1dc565b604051809103906000f08015801562005d1d573d6000803e3d6000fd5b505060405162005d2d906200c1dc565b604051809103906000f08015801562005d4a573d6000803e3d6000fd5b505060405162005d5a906200c1dc565b604051809103906000f08015801562005d77573d6000803e3d6000fd5b505060405162005d87906200c1dc565b604051809103906000f08015801562005da4573d6000803e3d6000fd5b505060405162005db4906200c1dc565b604051809103906000f08015801562005dd1573d6000803e3d6000fd5b505060405162005de1906200c1dc565b604051809103906000f08015801562005dfe573d6000803e3d6000fd5b505060405162005e0e906200c1dc565b604051809103906000f08015801562005e2b573d6000803e3d6000fd5b505060405162005e3b906200c1dc565b604051809103906000f08015801562005e58573d6000803e3d6000fd5b505060405162005e68906200c1dc565b604051809103906000f08015801562005e85573d6000803e3d6000fd5b505060405162005e95906200c1dc565b604051809103906000f08015801562005eb2573d6000803e3d6000fd5b505060405162005ec2906200c1dc565b604051809103906000f08015801562005edf573d6000803e3d6000fd5b505060405162005eef906200c1dc565b604051809103906000f08015801562005f0c573d6000803e3d6000fd5b505060405162005f1c906200c1dc565b604051809103906000f08015801562005f39573d6000803e3d6000fd5b505060405162005f49906200c1dc565b604051809103906000f08015801562005f66573d6000803e3d6000fd5b505060405162005f76906200c1dc565b604051809103906000f08015801562005f93573d6000803e3d6000fd5b505060405162005fa3906200c1dc565b604051809103906000f08015801562005fc0573d6000803e3d6000fd5b505060405162005fd0906200c1dc565b604051809103906000f08015801562005fed573d6000803e3d6000fd5b505060405162005ffd906200c1dc565b604051809103906000f0801580156200601a573d6000803e3d6000fd5b50506040516200602a906200c1dc565b604051809103906000f08015801562006047573d6000803e3d6000fd5b505060405162006057906200c1dc565b604051809103906000f08015801562006074573d6000803e3d6000fd5b505060405162006084906200c1dc565b604051809103906000f080158015620060a1573d6000803e3d6000fd5b5050604051620060b1906200c1dc565b604051809103906000f080158015620060ce573d6000803e3d6000fd5b5050604051620060de906200c1dc565b604051809103906000f080158015620060fb573d6000803e3d6000fd5b50506040516200610b906200c1dc565b604051809103906000f08015801562006128573d6000803e3d6000fd5b505060405162006138906200c1dc565b604051809103906000f08015801562006155573d6000803e3d6000fd5b505060405162006165906200c1dc565b604051809103906000f08015801562006182573d6000803e3d6000fd5b505060405162006192906200c1dc565b604051809103906000f080158015620061af573d6000803e3d6000fd5b5050604051620061bf906200c1dc565b604051809103906000f080158015620061dc573d6000803e3d6000fd5b5050604051620061ec906200c1dc565b604051809103906000f08015801562006209573d6000803e3d6000fd5b505060405162006219906200c1dc565b604051809103906000f08015801562006236573d6000803e3d6000fd5b505060405162006246906200c1dc565b604051809103906000f08015801562006263573d6000803e3d6000fd5b505060405162006273906200c1dc565b604051809103906000f08015801562006290573d6000803e3d6000fd5b5050604051620062a0906200c1dc565b604051809103906000f080158015620062bd573d6000803e3d6000fd5b5050604051620062cd906200c1dc565b604051809103906000f080158015620062ea573d6000803e3d6000fd5b5050604051620062fa906200c1dc565b604051809103906000f08015801562006317573d6000803e3d6000fd5b505060405162006327906200c1dc565b604051809103906000f08015801562006344573d6000803e3d6000fd5b505060405162006354906200c1dc565b604051809103906000f08015801562006371573d6000803e3d6000fd5b505060405162006381906200c1dc565b604051809103906000f0801580156200639e573d6000803e3d6000fd5b5050604051620063ae906200c1dc565b604051809103906000f080158015620063cb573d6000803e3d6000fd5b5050604051620063db906200c1dc565b604051809103906000f080158015620063f8573d6000803e3d6000fd5b505060405162006408906200c1dc565b604051809103906000f08015801562006425573d6000803e3d6000fd5b505060405162006435906200c1dc565b604051809103906000f08015801562006452573d6000803e3d6000fd5b505060405162006462906200c1dc565b604051809103906000f0801580156200647f573d6000803e3d6000fd5b50506040516200648f906200c1dc565b604051809103906000f080158015620064ac573d6000803e3d6000fd5b5050604051620064bc906200c1dc565b604051809103906000f080158015620064d9573d6000803e3d6000fd5b5050604051620064e9906200c1dc565b604051809103906000f08015801562006506573d6000803e3d6000fd5b505060405162006516906200c1dc565b604051809103906000f08015801562006533573d6000803e3d6000fd5b505060405162006543906200c1dc565b604051809103906000f08015801562006560573d6000803e3d6000fd5b505060405162006570906200c1dc565b604051809103906000f0801580156200658d573d6000803e3d6000fd5b50506040516200659d906200c1dc565b604051809103906000f080158015620065ba573d6000803e3d6000fd5b5050604051620065ca906200c1dc565b604051809103906000f080158015620065e7573d6000803e3d6000fd5b5050604051620065f7906200c1dc565b604051809103906000f08015801562006614573d6000803e3d6000fd5b505060405162006624906200c1dc565b604051809103906000f08015801562006641573d6000803e3d6000fd5b505060405162006651906200c1dc565b604051809103906000f0801580156200666e573d6000803e3d6000fd5b50506040516200667e906200c1dc565b604051809103906000f0801580156200669b573d6000803e3d6000fd5b5050604051620066ab906200c1dc565b604051809103906000f080158015620066c8573d6000803e3d6000fd5b5050604051620066d8906200c1dc565b604051809103906000f080158015620066f5573d6000803e3d6000fd5b505060405162006705906200c1dc565b604051809103906000f08015801562006722573d6000803e3d6000fd5b505060405162006732906200c1dc565b604051809103906000f0801580156200674f573d6000803e3d6000fd5b50506040516200675f906200c1dc565b604051809103906000f0801580156200677c573d6000803e3d6000fd5b50506040516200678c906200c1dc565b604051809103906000f080158015620067a9573d6000803e3d6000fd5b5050604051620067b9906200c1dc565b604051809103906000f080158015620067d6573d6000803e3d6000fd5b5050604051620067e6906200c1dc565b604051809103906000f08015801562006803573d6000803e3d6000fd5b505060405162006813906200c1dc565b604051809103906000f08015801562006830573d6000803e3d6000fd5b505060405162006840906200c1dc565b604051809103906000f0801580156200685d573d6000803e3d6000fd5b50506040516200686d906200c1dc565b604051809103906000f0801580156200688a573d6000803e3d6000fd5b50506040516200689a906200c1dc565b604051809103906000f080158015620068b7573d6000803e3d6000fd5b5050604051620068c7906200c1dc565b604051809103906000f080158015620068e4573d6000803e3d6000fd5b5050604051620068f4906200c1dc565b604051809103906000f08015801562006911573d6000803e3d6000fd5b505060405162006921906200c1dc565b604051809103906000f0801580156200693e573d6000803e3d6000fd5b50506040516200694e906200c1dc565b604051809103906000f0801580156200696b573d6000803e3d6000fd5b50506040516200697b906200c1dc565b604051809103906000f08015801562006998573d6000803e3d6000fd5b5050604051620069a8906200c1dc565b604051809103906000f080158015620069c5573d6000803e3d6000fd5b5050604051620069d5906200c1dc565b604051809103906000f080158015620069f2573d6000803e3d6000fd5b505060405162006a02906200c1dc565b604051809103906000f08015801562006a1f573d6000803e3d6000fd5b505060405162006a2f906200c1dc565b604051809103906000f08015801562006a4c573d6000803e3d6000fd5b505060405162006a5c906200c1dc565b604051809103906000f08015801562006a79573d6000803e3d6000fd5b505060405162006a89906200c1dc565b604051809103906000f08015801562006aa6573d6000803e3d6000fd5b505060405162006ab6906200c1dc565b604051809103906000f08015801562006ad3573d6000803e3d6000fd5b505060405162006ae3906200c1dc565b604051809103906000f08015801562006b00573d6000803e3d6000fd5b505060405162006b10906200c1dc565b604051809103906000f08015801562006b2d573d6000803e3d6000fd5b505060405162006b3d906200c1dc565b604051809103906000f08015801562006b5a573d6000803e3d6000fd5b505060405162006b6a906200c1dc565b604051809103906000f08015801562006b87573d6000803e3d6000fd5b505060405162006b97906200c1dc565b604051809103906000f08015801562006bb4573d6000803e3d6000fd5b505060405162006bc4906200c1dc565b604051809103906000f08015801562006be1573d6000803e3d6000fd5b505060405162006bf1906200c1dc565b604051809103906000f08015801562006c0e573d6000803e3d6000fd5b505060405162006c1e906200c1dc565b604051809103906000f08015801562006c3b573d6000803e3d6000fd5b505060405162006c4b906200c1dc565b604051809103906000f08015801562006c68573d6000803e3d6000fd5b505060405162006c78906200c1dc565b604051809103906000f08015801562006c95573d6000803e3d6000fd5b505060405162006ca5906200c1dc565b604051809103906000f08015801562006cc2573d6000803e3d6000fd5b505060405162006cd2906200c1dc565b604051809103906000f08015801562006cef573d6000803e3d6000fd5b505060405162006cff906200c1dc565b604051809103906000f08015801562006d1c573d6000803e3d6000fd5b505060405162006d2c906200c1dc565b604051809103906000f08015801562006d49573d6000803e3d6000fd5b505060405162006d59906200c1dc565b604051809103906000f08015801562006d76573d6000803e3d6000fd5b505060405162006d86906200c1dc565b604051809103906000f08015801562006da3573d6000803e3d6000fd5b505060405162006db3906200c1dc565b604051809103906000f08015801562006dd0573d6000803e3d6000fd5b505060405162006de0906200c1dc565b604051809103906000f08015801562006dfd573d6000803e3d6000fd5b505060405162006e0d906200c1dc565b604051809103906000f08015801562006e2a573d6000803e3d6000fd5b505060405162006e3a906200c1dc565b604051809103906000f08015801562006e57573d6000803e3d6000fd5b505060405162006e67906200c1dc565b604051809103906000f08015801562006e84573d6000803e3d6000fd5b505060405162006e94906200c1dc565b604051809103906000f08015801562006eb1573d6000803e3d6000fd5b505060405162006ec1906200c1dc565b604051809103906000f08015801562006ede573d6000803e3d6000fd5b505060405162006eee906200c1dc565b604051809103906000f08015801562006f0b573d6000803e3d6000fd5b505060405162006f1b906200c1dc565b604051809103906000f08015801562006f38573d6000803e3d6000fd5b505060405162006f48906200c1dc565b604051809103906000f08015801562006f65573d6000803e3d6000fd5b505060405162006f75906200c1dc565b604051809103906000f08015801562006f92573d6000803e3d6000fd5b505060405162006fa2906200c1dc565b604051809103906000f08015801562006fbf573d6000803e3d6000fd5b505060405162006fcf906200c1dc565b604051809103906000f08015801562006fec573d6000803e3d6000fd5b505060405162006ffc906200c1dc565b604051809103906000f08015801562007019573d6000803e3d6000fd5b505060405162007029906200c1dc565b604051809103906000f08015801562007046573d6000803e3d6000fd5b505060405162007056906200c1dc565b604051809103906000f08015801562007073573d6000803e3d6000fd5b505060405162007083906200c1dc565b604051809103906000f080158015620070a0573d6000803e3d6000fd5b5050604051620070b0906200c1dc565b604051809103906000f080158015620070cd573d6000803e3d6000fd5b5050604051620070dd906200c1dc565b604051809103906000f080158015620070fa573d6000803e3d6000fd5b50506040516200710a906200c1dc565b604051809103906000f08015801562007127573d6000803e3d6000fd5b505060405162007137906200c1dc565b604051809103906000f08015801562007154573d6000803e3d6000fd5b505060405162007164906200c1dc565b604051809103906000f08015801562007181573d6000803e3d6000fd5b505060405162007191906200c1dc565b604051809103906000f080158015620071ae573d6000803e3d6000fd5b5050604051620071be906200c1dc565b604051809103906000f080158015620071db573d6000803e3d6000fd5b5050604051620071eb906200c1dc565b604051809103906000f08015801562007208573d6000803e3d6000fd5b505060405162007218906200c1dc565b604051809103906000f08015801562007235573d6000803e3d6000fd5b505060405162007245906200c1dc565b604051809103906000f08015801562007262573d6000803e3d6000fd5b505060405162007272906200c1dc565b604051809103906000f0801580156200728f573d6000803e3d6000fd5b50506040516200729f906200c1dc565b604051809103906000f080158015620072bc573d6000803e3d6000fd5b5050604051620072cc906200c1dc565b604051809103906000f080158015620072e9573d6000803e3d6000fd5b5050604051620072f9906200c1dc565b604051809103906000f08015801562007316573d6000803e3d6000fd5b505060405162007326906200c1dc565b604051809103906000f08015801562007343573d6000803e3d6000fd5b505060405162007353906200c1dc565b604051809103906000f08015801562007370573d6000803e3d6000fd5b505060405162007380906200c1dc565b604051809103906000f0801580156200739d573d6000803e3d6000fd5b5050604051620073ad906200c1dc565b604051809103906000f080158015620073ca573d6000803e3d6000fd5b5050604051620073da906200c1dc565b604051809103906000f080158015620073f7573d6000803e3d6000fd5b505060405162007407906200c1dc565b604051809103906000f08015801562007424573d6000803e3d6000fd5b505060405162007434906200c1dc565b604051809103906000f08015801562007451573d6000803e3d6000fd5b505060405162007461906200c1dc565b604051809103906000f0801580156200747e573d6000803e3d6000fd5b50506040516200748e906200c1dc565b604051809103906000f080158015620074ab573d6000803e3d6000fd5b5050604051620074bb906200c1dc565b604051809103906000f080158015620074d8573d6000803e3d6000fd5b5050604051620074e8906200c1dc565b604051809103906000f08015801562007505573d6000803e3d6000fd5b505060405162007515906200c1dc565b604051809103906000f08015801562007532573d6000803e3d6000fd5b505060405162007542906200c1dc565b604051809103906000f0801580156200755f573d6000803e3d6000fd5b50506040516200756f906200c1dc565b604051809103906000f0801580156200758c573d6000803e3d6000fd5b50506040516200759c906200c1dc565b604051809103906000f080158015620075b9573d6000803e3d6000fd5b5050604051620075c9906200c1dc565b604051809103906000f080158015620075e6573d6000803e3d6000fd5b5050604051620075f6906200c1dc565b604051809103906000f08015801562007613573d6000803e3d6000fd5b505060405162007623906200c1dc565b604051809103906000f08015801562007640573d6000803e3d6000fd5b505060405162007650906200c1dc565b604051809103906000f0801580156200766d573d6000803e3d6000fd5b50506040516200767d906200c1dc565b604051809103906000f0801580156200769a573d6000803e3d6000fd5b5050604051620076aa906200c1dc565b604051809103906000f080158015620076c7573d6000803e3d6000fd5b5050604051620076d7906200c1dc565b604051809103906000f080158015620076f4573d6000803e3d6000fd5b505060405162007704906200c1dc565b604051809103906000f08015801562007721573d6000803e3d6000fd5b505060405162007731906200c1dc565b604051809103906000f0801580156200774e573d6000803e3d6000fd5b50506040516200775e906200c1dc565b604051809103906000f0801580156200777b573d6000803e3d6000fd5b50506040516200778b906200c1dc565b604051809103906000f080158015620077a8573d6000803e3d6000fd5b5050604051620077b8906200c1dc565b604051809103906000f080158015620077d5573d6000803e3d6000fd5b5050604051620077e5906200c1dc565b604051809103906000f08015801562007802573d6000803e3d6000fd5b505060405162007812906200c1dc565b604051809103906000f0801580156200782f573d6000803e3d6000fd5b50506040516200783f906200c1dc565b604051809103906000f0801580156200785c573d6000803e3d6000fd5b50506040516200786c906200c1dc565b604051809103906000f08015801562007889573d6000803e3d6000fd5b505060405162007899906200c1dc565b604051809103906000f080158015620078b6573d6000803e3d6000fd5b5050604051620078c6906200c1dc565b604051809103906000f080158015620078e3573d6000803e3d6000fd5b5050604051620078f3906200c1dc565b604051809103906000f08015801562007910573d6000803e3d6000fd5b505060405162007920906200c1dc565b604051809103906000f0801580156200793d573d6000803e3d6000fd5b50506040516200794d906200c1dc565b604051809103906000f0801580156200796a573d6000803e3d6000fd5b50506040516200797a906200c1dc565b604051809103906000f08015801562007997573d6000803e3d6000fd5b5050604051620079a7906200c1dc565b604051809103906000f080158015620079c4573d6000803e3d6000fd5b5050604051620079d4906200c1dc565b604051809103906000f080158015620079f1573d6000803e3d6000fd5b505060405162007a01906200c1dc565b604051809103906000f08015801562007a1e573d6000803e3d6000fd5b505060405162007a2e906200c1dc565b604051809103906000f08015801562007a4b573d6000803e3d6000fd5b505060405162007a5b906200c1dc565b604051809103906000f08015801562007a78573d6000803e3d6000fd5b505060405162007a88906200c1dc565b604051809103906000f08015801562007aa5573d6000803e3d6000fd5b505060405162007ab5906200c1dc565b604051809103906000f08015801562007ad2573d6000803e3d6000fd5b505060405162007ae2906200c1dc565b604051809103906000f08015801562007aff573d6000803e3d6000fd5b505060405162007b0f906200c1dc565b604051809103906000f08015801562007b2c573d6000803e3d6000fd5b505060405162007b3c906200c1dc565b604051809103906000f08015801562007b59573d6000803e3d6000fd5b505060405162007b69906200c1dc565b604051809103906000f08015801562007b86573d6000803e3d6000fd5b505060405162007b96906200c1dc565b604051809103906000f08015801562007bb3573d6000803e3d6000fd5b505060405162007bc3906200c1dc565b604051809103906000f08015801562007be0573d6000803e3d6000fd5b505060405162007bf0906200c1dc565b604051809103906000f08015801562007c0d573d6000803e3d6000fd5b505060405162007c1d906200c1dc565b604051809103906000f08015801562007c3a573d6000803e3d6000fd5b505060405162007c4a906200c1dc565b604051809103906000f08015801562007c67573d6000803e3d6000fd5b505060405162007c77906200c1dc565b604051809103906000f08015801562007c94573d6000803e3d6000fd5b505060405162007ca4906200c1dc565b604051809103906000f08015801562007cc1573d6000803e3d6000fd5b505060405162007cd1906200c1dc565b604051809103906000f08015801562007cee573d6000803e3d6000fd5b505060405162007cfe906200c1dc565b604051809103906000f08015801562007d1b573d6000803e3d6000fd5b505060405162007d2b906200c1dc565b604051809103906000f08015801562007d48573d6000803e3d6000fd5b505060405162007d58906200c1dc565b604051809103906000f08015801562007d75573d6000803e3d6000fd5b505060405162007d85906200c1dc565b604051809103906000f08015801562007da2573d6000803e3d6000fd5b505060405162007db2906200c1dc565b604051809103906000f08015801562007dcf573d6000803e3d6000fd5b505060405162007ddf906200c1dc565b604051809103906000f08015801562007dfc573d6000803e3d6000fd5b505060405162007e0c906200c1dc565b604051809103906000f08015801562007e29573d6000803e3d6000fd5b505060405162007e39906200c1dc565b604051809103906000f08015801562007e56573d6000803e3d6000fd5b505060405162007e66906200c1dc565b604051809103906000f08015801562007e83573d6000803e3d6000fd5b505060405162007e93906200c1dc565b604051809103906000f08015801562007eb0573d6000803e3d6000fd5b505060405162007ec0906200c1dc565b604051809103906000f08015801562007edd573d6000803e3d6000fd5b505060405162007eed906200c1dc565b604051809103906000f08015801562007f0a573d6000803e3d6000fd5b505060405162007f1a906200c1dc565b604051809103906000f08015801562007f37573d6000803e3d6000fd5b505060405162007f47906200c1dc565b604051809103906000f08015801562007f64573d6000803e3d6000fd5b505060405162007f74906200c1dc565b604051809103906000f08015801562007f91573d6000803e3d6000fd5b505060405162007fa1906200c1dc565b604051809103906000f08015801562007fbe573d6000803e3d6000fd5b505060405162007fce906200c1dc565b604051809103906000f08015801562007feb573d6000803e3d6000fd5b505060405162007ffb906200c1dc565b604051809103906000f08015801562008018573d6000803e3d6000fd5b505060405162008028906200c1dc565b604051809103906000f08015801562008045573d6000803e3d6000fd5b505060405162008055906200c1dc565b604051809103906000f08015801562008072573d6000803e3d6000fd5b505060405162008082906200c1dc565b604051809103906000f0801580156200809f573d6000803e3d6000fd5b5050604051620080af906200c1dc565b604051809103906000f080158015620080cc573d6000803e3d6000fd5b5050604051620080dc906200c1dc565b604051809103906000f080158015620080f9573d6000803e3d6000fd5b505060405162008109906200c1dc565b604051809103906000f08015801562008126573d6000803e3d6000fd5b505060405162008136906200c1dc565b604051809103906000f08015801562008153573d6000803e3d6000fd5b505060405162008163906200c1dc565b604051809103906000f08015801562008180573d6000803e3d6000fd5b505060405162008190906200c1dc565b604051809103906000f080158015620081ad573d6000803e3d6000fd5b5050604051620081bd906200c1dc565b604051809103906000f080158015620081da573d6000803e3d6000fd5b5050604051620081ea906200c1dc565b604051809103906000f08015801562008207573d6000803e3d6000fd5b505060405162008217906200c1dc565b604051809103906000f08015801562008234573d6000803e3d6000fd5b505060405162008244906200c1dc565b604051809103906000f08015801562008261573d6000803e3d6000fd5b505060405162008271906200c1dc565b604051809103906000f0801580156200828e573d6000803e3d6000fd5b50506040516200829e906200c1dc565b604051809103906000f080158015620082bb573d6000803e3d6000fd5b5050604051620082cb906200c1dc565b604051809103906000f080158015620082e8573d6000803e3d6000fd5b5050604051620082f8906200c1dc565b604051809103906000f08015801562008315573d6000803e3d6000fd5b505060405162008325906200c1dc565b604051809103906000f08015801562008342573d6000803e3d6000fd5b505060405162008352906200c1dc565b604051809103906000f0801580156200836f573d6000803e3d6000fd5b50506040516200837f906200c1dc565b604051809103906000f0801580156200839c573d6000803e3d6000fd5b5050604051620083ac906200c1dc565b604051809103906000f080158015620083c9573d6000803e3d6000fd5b5050604051620083d9906200c1dc565b604051809103906000f080158015620083f6573d6000803e3d6000fd5b505060405162008406906200c1dc565b604051809103906000f08015801562008423573d6000803e3d6000fd5b505060405162008433906200c1dc565b604051809103906000f08015801562008450573d6000803e3d6000fd5b505060405162008460906200c1dc565b604051809103906000f0801580156200847d573d6000803e3d6000fd5b50506040516200848d906200c1dc565b604051809103906000f080158015620084aa573d6000803e3d6000fd5b5050604051620084ba906200c1dc565b604051809103906000f080158015620084d7573d6000803e3d6000fd5b5050604051620084e7906200c1dc565b604051809103906000f08015801562008504573d6000803e3d6000fd5b505060405162008514906200c1dc565b604051809103906000f08015801562008531573d6000803e3d6000fd5b505060405162008541906200c1dc565b604051809103906000f0801580156200855e573d6000803e3d6000fd5b50506040516200856e906200c1dc565b604051809103906000f0801580156200858b573d6000803e3d6000fd5b50506040516200859b906200c1dc565b604051809103906000f080158015620085b8573d6000803e3d6000fd5b5050604051620085c8906200c1dc565b604051809103906000f080158015620085e5573d6000803e3d6000fd5b5050604051620085f5906200c1dc565b604051809103906000f08015801562008612573d6000803e3d6000fd5b505060405162008622906200c1dc565b604051809103906000f0801580156200863f573d6000803e3d6000fd5b50506040516200864f906200c1dc565b604051809103906000f0801580156200866c573d6000803e3d6000fd5b50506040516200867c906200c1dc565b604051809103906000f08015801562008699573d6000803e3d6000fd5b5050604051620086a9906200c1dc565b604051809103906000f080158015620086c6573d6000803e3d6000fd5b5050604051620086d6906200c1dc565b604051809103906000f080158015620086f3573d6000803e3d6000fd5b505060405162008703906200c1dc565b604051809103906000f08015801562008720573d6000803e3d6000fd5b505060405162008730906200c1dc565b604051809103906000f0801580156200874d573d6000803e3d6000fd5b50506040516200875d906200c1dc565b604051809103906000f0801580156200877a573d6000803e3d6000fd5b50506040516200878a906200c1dc565b604051809103906000f080158015620087a7573d6000803e3d6000fd5b5050604051620087b7906200c1dc565b604051809103906000f080158015620087d4573d6000803e3d6000fd5b5050604051620087e4906200c1dc565b604051809103906000f08015801562008801573d6000803e3d6000fd5b505060405162008811906200c1dc565b604051809103906000f0801580156200882e573d6000803e3d6000fd5b50506040516200883e906200c1dc565b604051809103906000f0801580156200885b573d6000803e3d6000fd5b50506040516200886b906200c1dc565b604051809103906000f08015801562008888573d6000803e3d6000fd5b505060405162008898906200c1dc565b604051809103906000f080158015620088b5573d6000803e3d6000fd5b5050604051620088c5906200c1dc565b604051809103906000f080158015620088e2573d6000803e3d6000fd5b5050604051620088f2906200c1dc565b604051809103906000f0801580156200890f573d6000803e3d6000fd5b50506040516200891f906200c1dc565b604051809103906000f0801580156200893c573d6000803e3d6000fd5b50506040516200894c906200c1dc565b604051809103906000f08015801562008969573d6000803e3d6000fd5b505060405162008979906200c1dc565b604051809103906000f08015801562008996573d6000803e3d6000fd5b5050604051620089a6906200c1dc565b604051809103906000f080158015620089c3573d6000803e3d6000fd5b5050604051620089d3906200c1dc565b604051809103906000f080158015620089f0573d6000803e3d6000fd5b505060405162008a00906200c1dc565b604051809103906000f08015801562008a1d573d6000803e3d6000fd5b505060405162008a2d906200c1dc565b604051809103906000f08015801562008a4a573d6000803e3d6000fd5b505060405162008a5a906200c1dc565b604051809103906000f08015801562008a77573d6000803e3d6000fd5b505060405162008a87906200c1dc565b604051809103906000f08015801562008aa4573d6000803e3d6000fd5b505060405162008ab4906200c1dc565b604051809103906000f08015801562008ad1573d6000803e3d6000fd5b505060405162008ae1906200c1dc565b604051809103906000f08015801562008afe573d6000803e3d6000fd5b505060405162008b0e906200c1dc565b604051809103906000f08015801562008b2b573d6000803e3d6000fd5b505060405162008b3b906200c1dc565b604051809103906000f08015801562008b58573d6000803e3d6000fd5b505060405162008b68906200c1dc565b604051809103906000f08015801562008b85573d6000803e3d6000fd5b505060405162008b95906200c1dc565b604051809103906000f08015801562008bb2573d6000803e3d6000fd5b505060405162008bc2906200c1dc565b604051809103906000f08015801562008bdf573d6000803e3d6000fd5b505060405162008bef906200c1dc565b604051809103906000f08015801562008c0c573d6000803e3d6000fd5b505060405162008c1c906200c1dc565b604051809103906000f08015801562008c39573d6000803e3d6000fd5b505060405162008c49906200c1dc565b604051809103906000f08015801562008c66573d6000803e3d6000fd5b505060405162008c76906200c1dc565b604051809103906000f08015801562008c93573d6000803e3d6000fd5b505060405162008ca3906200c1dc565b604051809103906000f08015801562008cc0573d6000803e3d6000fd5b505060405162008cd0906200c1dc565b604051809103906000f08015801562008ced573d6000803e3d6000fd5b505060405162008cfd906200c1dc565b604051809103906000f08015801562008d1a573d6000803e3d6000fd5b505060405162008d2a906200c1dc565b604051809103906000f08015801562008d47573d6000803e3d6000fd5b505060405162008d57906200c1dc565b604051809103906000f08015801562008d74573d6000803e3d6000fd5b505060405162008d84906200c1dc565b604051809103906000f08015801562008da1573d6000803e3d6000fd5b505060405162008db1906200c1dc565b604051809103906000f08015801562008dce573d6000803e3d6000fd5b505060405162008dde906200c1dc565b604051809103906000f08015801562008dfb573d6000803e3d6000fd5b505060405162008e0b906200c1dc565b604051809103906000f08015801562008e28573d6000803e3d6000fd5b505060405162008e38906200c1dc565b604051809103906000f08015801562008e55573d6000803e3d6000fd5b505060405162008e65906200c1dc565b604051809103906000f08015801562008e82573d6000803e3d6000fd5b505060405162008e92906200c1dc565b604051809103906000f08015801562008eaf573d6000803e3d6000fd5b505060405162008ebf906200c1dc565b604051809103906000f08015801562008edc573d6000803e3d6000fd5b505060405162008eec906200c1dc565b604051809103906000f08015801562008f09573d6000803e3d6000fd5b505060405162008f19906200c1dc565b604051809103906000f08015801562008f36573d6000803e3d6000fd5b505060405162008f46906200c1dc565b604051809103906000f08015801562008f63573d6000803e3d6000fd5b505060405162008f73906200c1dc565b604051809103906000f08015801562008f90573d6000803e3d6000fd5b505060405162008fa0906200c1dc565b604051809103906000f08015801562008fbd573d6000803e3d6000fd5b505060405162008fcd906200c1dc565b604051809103906000f08015801562008fea573d6000803e3d6000fd5b505060405162008ffa906200c1dc565b604051809103906000f08015801562009017573d6000803e3d6000fd5b505060405162009027906200c1dc565b604051809103906000f08015801562009044573d6000803e3d6000fd5b505060405162009054906200c1dc565b604051809103906000f08015801562009071573d6000803e3d6000fd5b505060405162009081906200c1dc565b604051809103906000f0801580156200909e573d6000803e3d6000fd5b5050604051620090ae906200c1dc565b604051809103906000f080158015620090cb573d6000803e3d6000fd5b5050604051620090db906200c1dc565b604051809103906000f080158015620090f8573d6000803e3d6000fd5b505060405162009108906200c1dc565b604051809103906000f08015801562009125573d6000803e3d6000fd5b505060405162009135906200c1dc565b604051809103906000f08015801562009152573d6000803e3d6000fd5b505060405162009162906200c1dc565b604051809103906000f0801580156200917f573d6000803e3d6000fd5b50506040516200918f906200c1dc565b604051809103906000f080158015620091ac573d6000803e3d6000fd5b5050604051620091bc906200c1dc565b604051809103906000f080158015620091d9573d6000803e3d6000fd5b5050604051620091e9906200c1dc565b604051809103906000f08015801562009206573d6000803e3d6000fd5b505060405162009216906200c1dc565b604051809103906000f08015801562009233573d6000803e3d6000fd5b505060405162009243906200c1dc565b604051809103906000f08015801562009260573d6000803e3d6000fd5b505060405162009270906200c1dc565b604051809103906000f0801580156200928d573d6000803e3d6000fd5b50506040516200929d906200c1dc565b604051809103906000f080158015620092ba573d6000803e3d6000fd5b5050604051620092ca906200c1dc565b604051809103906000f080158015620092e7573d6000803e3d6000fd5b5050604051620092f7906200c1dc565b604051809103906000f08015801562009314573d6000803e3d6000fd5b505060405162009324906200c1dc565b604051809103906000f08015801562009341573d6000803e3d6000fd5b505060405162009351906200c1dc565b604051809103906000f0801580156200936e573d6000803e3d6000fd5b50506040516200937e906200c1dc565b604051809103906000f0801580156200939b573d6000803e3d6000fd5b5050604051620093ab906200c1dc565b604051809103906000f080158015620093c8573d6000803e3d6000fd5b5050604051620093d8906200c1dc565b604051809103906000f080158015620093f5573d6000803e3d6000fd5b505060405162009405906200c1dc565b604051809103906000f08015801562009422573d6000803e3d6000fd5b505060405162009432906200c1dc565b604051809103906000f0801580156200944f573d6000803e3d6000fd5b50506040516200945f906200c1dc565b604051809103906000f0801580156200947c573d6000803e3d6000fd5b50506040516200948c906200c1dc565b604051809103906000f080158015620094a9573d6000803e3d6000fd5b5050604051620094b9906200c1dc565b604051809103906000f080158015620094d6573d6000803e3d6000fd5b5050604051620094e6906200c1dc565b604051809103906000f08015801562009503573d6000803e3d6000fd5b505060405162009513906200c1dc565b604051809103906000f08015801562009530573d6000803e3d6000fd5b505060405162009540906200c1dc565b604051809103906000f0801580156200955d573d6000803e3d6000fd5b50506040516200956d906200c1dc565b604051809103906000f0801580156200958a573d6000803e3d6000fd5b50506040516200959a906200c1dc565b604051809103906000f080158015620095b7573d6000803e3d6000fd5b5050604051620095c7906200c1dc565b604051809103906000f080158015620095e4573d6000803e3d6000fd5b5050604051620095f4906200c1dc565b604051809103906000f08015801562009611573d6000803e3d6000fd5b505060405162009621906200c1dc565b604051809103906000f0801580156200963e573d6000803e3d6000fd5b50506040516200964e906200c1dc565b604051809103906000f0801580156200966b573d6000803e3d6000fd5b50506040516200967b906200c1dc565b604051809103906000f08015801562009698573d6000803e3d6000fd5b5050604051620096a8906200c1dc565b604051809103906000f080158015620096c5573d6000803e3d6000fd5b5050604051620096d5906200c1dc565b604051809103906000f080158015620096f2573d6000803e3d6000fd5b505060405162009702906200c1dc565b604051809103906000f0801580156200971f573d6000803e3d6000fd5b50506040516200972f906200c1dc565b604051809103906000f0801580156200974c573d6000803e3d6000fd5b50506040516200975c906200c1dc565b604051809103906000f08015801562009779573d6000803e3d6000fd5b505060405162009789906200c1dc565b604051809103906000f080158015620097a6573d6000803e3d6000fd5b5050604051620097b6906200c1dc565b604051809103906000f080158015620097d3573d6000803e3d6000fd5b5050604051620097e3906200c1dc565b604051809103906000f08015801562009800573d6000803e3d6000fd5b505060405162009810906200c1dc565b604051809103906000f0801580156200982d573d6000803e3d6000fd5b50506040516200983d906200c1dc565b604051809103906000f0801580156200985a573d6000803e3d6000fd5b50506040516200986a906200c1dc565b604051809103906000f08015801562009887573d6000803e3d6000fd5b505060405162009897906200c1dc565b604051809103906000f080158015620098b4573d6000803e3d6000fd5b5050604051620098c4906200c1dc565b604051809103906000f080158015620098e1573d6000803e3d6000fd5b5050604051620098f1906200c1dc565b604051809103906000f0801580156200990e573d6000803e3d6000fd5b50506040516200991e906200c1dc565b604051809103906000f0801580156200993b573d6000803e3d6000fd5b50506040516200994b906200c1dc565b604051809103906000f08015801562009968573d6000803e3d6000fd5b505060405162009978906200c1dc565b604051809103906000f08015801562009995573d6000803e3d6000fd5b5050604051620099a5906200c1dc565b604051809103906000f080158015620099c2573d6000803e3d6000fd5b5050604051620099d2906200c1dc565b604051809103906000f080158015620099ef573d6000803e3d6000fd5b5050604051620099ff906200c1dc565b604051809103906000f08015801562009a1c573d6000803e3d6000fd5b505060405162009a2c906200c1dc565b604051809103906000f08015801562009a49573d6000803e3d6000fd5b505060405162009a59906200c1dc565b604051809103906000f08015801562009a76573d6000803e3d6000fd5b505060405162009a86906200c1dc565b604051809103906000f08015801562009aa3573d6000803e3d6000fd5b505060405162009ab3906200c1dc565b604051809103906000f08015801562009ad0573d6000803e3d6000fd5b505060405162009ae0906200c1dc565b604051809103906000f08015801562009afd573d6000803e3d6000fd5b505060405162009b0d906200c1dc565b604051809103906000f08015801562009b2a573d6000803e3d6000fd5b505060405162009b3a906200c1dc565b604051809103906000f08015801562009b57573d6000803e3d6000fd5b505060405162009b67906200c1dc565b604051809103906000f08015801562009b84573d6000803e3d6000fd5b505060405162009b94906200c1dc565b604051809103906000f08015801562009bb1573d6000803e3d6000fd5b505060405162009bc1906200c1dc565b604051809103906000f08015801562009bde573d6000803e3d6000fd5b505060405162009bee906200c1dc565b604051809103906000f08015801562009c0b573d6000803e3d6000fd5b505060405162009c1b906200c1dc565b604051809103906000f08015801562009c38573d6000803e3d6000fd5b505060405162009c48906200c1dc565b604051809103906000f08015801562009c65573d6000803e3d6000fd5b505060405162009c75906200c1dc565b604051809103906000f08015801562009c92573d6000803e3d6000fd5b505060405162009ca2906200c1dc565b604051809103906000f08015801562009cbf573d6000803e3d6000fd5b505060405162009ccf906200c1dc565b604051809103906000f08015801562009cec573d6000803e3d6000fd5b505060405162009cfc906200c1dc565b604051809103906000f08015801562009d19573d6000803e3d6000fd5b505060405162009d29906200c1dc565b604051809103906000f08015801562009d46573d6000803e3d6000fd5b505060405162009d56906200c1dc565b604051809103906000f08015801562009d73573d6000803e3d6000fd5b505060405162009d83906200c1dc565b604051809103906000f08015801562009da0573d6000803e3d6000fd5b505060405162009db0906200c1dc565b604051809103906000f08015801562009dcd573d6000803e3d6000fd5b505060405162009ddd906200c1dc565b604051809103906000f08015801562009dfa573d6000803e3d6000fd5b505060405162009e0a906200c1dc565b604051809103906000f08015801562009e27573d6000803e3d6000fd5b505060405162009e37906200c1dc565b604051809103906000f08015801562009e54573d6000803e3d6000fd5b505060405162009e64906200c1dc565b604051809103906000f08015801562009e81573d6000803e3d6000fd5b505060405162009e91906200c1dc565b604051809103906000f08015801562009eae573d6000803e3d6000fd5b505060405162009ebe906200c1dc565b604051809103906000f08015801562009edb573d6000803e3d6000fd5b505060405162009eeb906200c1dc565b604051809103906000f08015801562009f08573d6000803e3d6000fd5b505060405162009f18906200c1dc565b604051809103906000f08015801562009f35573d6000803e3d6000fd5b505060405162009f45906200c1dc565b604051809103906000f08015801562009f62573d6000803e3d6000fd5b505060405162009f72906200c1dc565b604051809103906000f08015801562009f8f573d6000803e3d6000fd5b505060405162009f9f906200c1dc565b604051809103906000f08015801562009fbc573d6000803e3d6000fd5b505060405162009fcc906200c1dc565b604051809103906000f08015801562009fe9573d6000803e3d6000fd5b505060405162009ff9906200c1dc565b604051809103906000f0801580156200a016573d6000803e3d6000fd5b50506040516200a026906200c1dc565b604051809103906000f0801580156200a043573d6000803e3d6000fd5b50506040516200a053906200c1dc565b604051809103906000f0801580156200a070573d6000803e3d6000fd5b50506040516200a080906200c1dc565b604051809103906000f0801580156200a09d573d6000803e3d6000fd5b50506040516200a0ad906200c1dc565b604051809103906000f0801580156200a0ca573d6000803e3d6000fd5b50506040516200a0da906200c1dc565b604051809103906000f0801580156200a0f7573d6000803e3d6000fd5b50506040516200a107906200c1dc565b604051809103906000f0801580156200a124573d6000803e3d6000fd5b50506040516200a134906200c1dc565b604051809103906000f0801580156200a151573d6000803e3d6000fd5b50506040516200a161906200c1dc565b604051809103906000f0801580156200a17e573d6000803e3d6000fd5b50506040516200a18e906200c1dc565b604051809103906000f0801580156200a1ab573d6000803e3d6000fd5b50506040516200a1bb906200c1dc565b604051809103906000f0801580156200a1d8573d6000803e3d6000fd5b50506040516200a1e8906200c1dc565b604051809103906000f0801580156200a205573d6000803e3d6000fd5b50506040516200a215906200c1dc565b604051809103906000f0801580156200a232573d6000803e3d6000fd5b50506040516200a242906200c1dc565b604051809103906000f0801580156200a25f573d6000803e3d6000fd5b50506040516200a26f906200c1dc565b604051809103906000f0801580156200a28c573d6000803e3d6000fd5b50506040516200a29c906200c1dc565b604051809103906000f0801580156200a2b9573d6000803e3d6000fd5b50506040516200a2c9906200c1dc565b604051809103906000f0801580156200a2e6573d6000803e3d6000fd5b50506040516200a2f6906200c1dc565b604051809103906000f0801580156200a313573d6000803e3d6000fd5b50506040516200a323906200c1dc565b604051809103906000f0801580156200a340573d6000803e3d6000fd5b50506040516200a350906200c1dc565b604051809103906000f0801580156200a36d573d6000803e3d6000fd5b50506040516200a37d906200c1dc565b604051809103906000f0801580156200a39a573d6000803e3d6000fd5b50506040516200a3aa906200c1dc565b604051809103906000f0801580156200a3c7573d6000803e3d6000fd5b50506040516200a3d7906200c1dc565b604051809103906000f0801580156200a3f4573d6000803e3d6000fd5b50506040516200a404906200c1dc565b604051809103906000f0801580156200a421573d6000803e3d6000fd5b50506040516200a431906200c1dc565b604051809103906000f0801580156200a44e573d6000803e3d6000fd5b50506040516200a45e906200c1dc565b604051809103906000f0801580156200a47b573d6000803e3d6000fd5b50506040516200a48b906200c1dc565b604051809103906000f0801580156200a4a8573d6000803e3d6000fd5b50506040516200a4b8906200c1dc565b604051809103906000f0801580156200a4d5573d6000803e3d6000fd5b50506040516200a4e5906200c1dc565b604051809103906000f0801580156200a502573d6000803e3d6000fd5b50506040516200a512906200c1dc565b604051809103906000f0801580156200a52f573d6000803e3d6000fd5b50506040516200a53f906200c1dc565b604051809103906000f0801580156200a55c573d6000803e3d6000fd5b50506040516200a56c906200c1dc565b604051809103906000f0801580156200a589573d6000803e3d6000fd5b50506040516200a599906200c1dc565b604051809103906000f0801580156200a5b6573d6000803e3d6000fd5b50506040516200a5c6906200c1dc565b604051809103906000f0801580156200a5e3573d6000803e3d6000fd5b50506040516200a5f3906200c1dc565b604051809103906000f0801580156200a610573d6000803e3d6000fd5b50506040516200a620906200c1dc565b604051809103906000f0801580156200a63d573d6000803e3d6000fd5b50506040516200a64d906200c1dc565b604051809103906000f0801580156200a66a573d6000803e3d6000fd5b50506040516200a67a906200c1dc565b604051809103906000f0801580156200a697573d6000803e3d6000fd5b50506040516200a6a7906200c1dc565b604051809103906000f0801580156200a6c4573d6000803e3d6000fd5b50506040516200a6d4906200c1dc565b604051809103906000f0801580156200a6f1573d6000803e3d6000fd5b50506040516200a701906200c1dc565b604051809103906000f0801580156200a71e573d6000803e3d6000fd5b50506040516200a72e906200c1dc565b604051809103906000f0801580156200a74b573d6000803e3d6000fd5b50506040516200a75b906200c1dc565b604051809103906000f0801580156200a778573d6000803e3d6000fd5b50506040516200a788906200c1dc565b604051809103906000f0801580156200a7a5573d6000803e3d6000fd5b50506040516200a7b5906200c1dc565b604051809103906000f0801580156200a7d2573d6000803e3d6000fd5b50506040516200a7e2906200c1dc565b604051809103906000f0801580156200a7ff573d6000803e3d6000fd5b50506040516200a80f906200c1dc565b604051809103906000f0801580156200a82c573d6000803e3d6000fd5b50506040516200a83c906200c1dc565b604051809103906000f0801580156200a859573d6000803e3d6000fd5b50506040516200a869906200c1dc565b604051809103906000f0801580156200a886573d6000803e3d6000fd5b50506040516200a896906200c1dc565b604051809103906000f0801580156200a8b3573d6000803e3d6000fd5b50506040516200a8c3906200c1dc565b604051809103906000f0801580156200a8e0573d6000803e3d6000fd5b50506040516200a8f0906200c1dc565b604051809103906000f0801580156200a90d573d6000803e3d6000fd5b50506040516200a91d906200c1dc565b604051809103906000f0801580156200a93a573d6000803e3d6000fd5b50506040516200a94a906200c1dc565b604051809103906000f0801580156200a967573d6000803e3d6000fd5b50506040516200a977906200c1dc565b604051809103906000f0801580156200a994573d6000803e3d6000fd5b50506040516200a9a4906200c1dc565b604051809103906000f0801580156200a9c1573d6000803e3d6000fd5b50506040516200a9d1906200c1dc565b604051809103906000f0801580156200a9ee573d6000803e3d6000fd5b50506040516200a9fe906200c1dc565b604051809103906000f0801580156200aa1b573d6000803e3d6000fd5b50506040516200aa2b906200c1dc565b604051809103906000f0801580156200aa48573d6000803e3d6000fd5b50506040516200aa58906200c1dc565b604051809103906000f0801580156200aa75573d6000803e3d6000fd5b50506040516200aa85906200c1dc565b604051809103906000f0801580156200aaa2573d6000803e3d6000fd5b50506040516200aab2906200c1dc565b604051809103906000f0801580156200aacf573d6000803e3d6000fd5b50506040516200aadf906200c1dc565b604051809103906000f0801580156200aafc573d6000803e3d6000fd5b50506040516200ab0c906200c1dc565b604051809103906000f0801580156200ab29573d6000803e3d6000fd5b50506040516200ab39906200c1dc565b604051809103906000f0801580156200ab56573d6000803e3d6000fd5b50506040516200ab66906200c1dc565b604051809103906000f0801580156200ab83573d6000803e3d6000fd5b50506040516200ab93906200c1dc565b604051809103906000f0801580156200abb0573d6000803e3d6000fd5b50506040516200abc0906200c1dc565b604051809103906000f0801580156200abdd573d6000803e3d6000fd5b50506040516200abed906200c1dc565b604051809103906000f0801580156200ac0a573d6000803e3d6000fd5b50506040516200ac1a906200c1dc565b604051809103906000f0801580156200ac37573d6000803e3d6000fd5b50506040516200ac47906200c1dc565b604051809103906000f0801580156200ac64573d6000803e3d6000fd5b50506040516200ac74906200c1dc565b604051809103906000f0801580156200ac91573d6000803e3d6000fd5b50506040516200aca1906200c1dc565b604051809103906000f0801580156200acbe573d6000803e3d6000fd5b50506040516200acce906200c1dc565b604051809103906000f0801580156200aceb573d6000803e3d6000fd5b50506040516200acfb906200c1dc565b604051809103906000f0801580156200ad18573d6000803e3d6000fd5b50506040516200ad28906200c1dc565b604051809103906000f0801580156200ad45573d6000803e3d6000fd5b50506040516200ad55906200c1dc565b604051809103906000f0801580156200ad72573d6000803e3d6000fd5b50506040516200ad82906200c1dc565b604051809103906000f0801580156200ad9f573d6000803e3d6000fd5b50506040516200adaf906200c1dc565b604051809103906000f0801580156200adcc573d6000803e3d6000fd5b50506040516200addc906200c1dc565b604051809103906000f0801580156200adf9573d6000803e3d6000fd5b50506040516200ae09906200c1dc565b604051809103906000f0801580156200ae26573d6000803e3d6000fd5b50506040516200ae36906200c1dc565b604051809103906000f0801580156200ae53573d6000803e3d6000fd5b50506040516200ae63906200c1dc565b604051809103906000f0801580156200ae80573d6000803e3d6000fd5b50506040516200ae90906200c1dc565b604051809103906000f0801580156200aead573d6000803e3d6000fd5b50506040516200aebd906200c1dc565b604051809103906000f0801580156200aeda573d6000803e3d6000fd5b50506040516200aeea906200c1dc565b604051809103906000f0801580156200af07573d6000803e3d6000fd5b50506040516200af17906200c1dc565b604051809103906000f0801580156200af34573d6000803e3d6000fd5b50506040516200af44906200c1dc565b604051809103906000f0801580156200af61573d6000803e3d6000fd5b50506040516200af71906200c1dc565b604051809103906000f0801580156200af8e573d6000803e3d6000fd5b50506040516200af9e906200c1dc565b604051809103906000f0801580156200afbb573d6000803e3d6000fd5b50506040516200afcb906200c1dc565b604051809103906000f0801580156200afe8573d6000803e3d6000fd5b50506040516200aff8906200c1dc565b604051809103906000f0801580156200b015573d6000803e3d6000fd5b50506040516200b025906200c1dc565b604051809103906000f0801580156200b042573d6000803e3d6000fd5b50506040516200b052906200c1dc565b604051809103906000f0801580156200b06f573d6000803e3d6000fd5b50506040516200b07f906200c1dc565b604051809103906000f0801580156200b09c573d6000803e3d6000fd5b50506040516200b0ac906200c1dc565b604051809103906000f0801580156200b0c9573d6000803e3d6000fd5b50506040516200b0d9906200c1dc565b604051809103906000f0801580156200b0f6573d6000803e3d6000fd5b50506040516200b106906200c1dc565b604051809103906000f0801580156200b123573d6000803e3d6000fd5b50506040516200b133906200c1dc565b604051809103906000f0801580156200b150573d6000803e3d6000fd5b50506040516200b160906200c1dc565b604051809103906000f0801580156200b17d573d6000803e3d6000fd5b50506040516200b18d906200c1dc565b604051809103906000f0801580156200b1aa573d6000803e3d6000fd5b50506040516200b1ba906200c1dc565b604051809103906000f0801580156200b1d7573d6000803e3d6000fd5b50506040516200b1e7906200c1dc565b604051809103906000f0801580156200b204573d6000803e3d6000fd5b50506040516200b214906200c1dc565b604051809103906000f0801580156200b231573d6000803e3d6000fd5b50506040516200b241906200c1dc565b604051809103906000f0801580156200b25e573d6000803e3d6000fd5b50506040516200b26e906200c1dc565b604051809103906000f0801580156200b28b573d6000803e3d6000fd5b50506040516200b29b906200c1dc565b604051809103906000f0801580156200b2b8573d6000803e3d6000fd5b50506040516200b2c8906200c1dc565b604051809103906000f0801580156200b2e5573d6000803e3d6000fd5b50506040516200b2f5906200c1dc565b604051809103906000f0801580156200b312573d6000803e3d6000fd5b50506040516200b322906200c1dc565b604051809103906000f0801580156200b33f573d6000803e3d6000fd5b50506040516200b34f906200c1dc565b604051809103906000f0801580156200b36c573d6000803e3d6000fd5b50506040516200b37c906200c1dc565b604051809103906000f0801580156200b399573d6000803e3d6000fd5b50506040516200b3a9906200c1dc565b604051809103906000f0801580156200b3c6573d6000803e3d6000fd5b50506040516200b3d6906200c1dc565b604051809103906000f0801580156200b3f3573d6000803e3d6000fd5b50506040516200b403906200c1dc565b604051809103906000f0801580156200b420573d6000803e3d6000fd5b50506040516200b430906200c1dc565b604051809103906000f0801580156200b44d573d6000803e3d6000fd5b50506040516200b45d906200c1dc565b604051809103906000f0801580156200b47a573d6000803e3d6000fd5b50506040516200b48a906200c1dc565b604051809103906000f0801580156200b4a7573d6000803e3d6000fd5b50506040516200b4b7906200c1dc565b604051809103906000f0801580156200b4d4573d6000803e3d6000fd5b50506040516200b4e4906200c1dc565b604051809103906000f0801580156200b501573d6000803e3d6000fd5b50506040516200b511906200c1dc565b604051809103906000f0801580156200b52e573d6000803e3d6000fd5b50506040516200b53e906200c1dc565b604051809103906000f0801580156200b55b573d6000803e3d6000fd5b50506040516200b56b906200c1dc565b604051809103906000f0801580156200b588573d6000803e3d6000fd5b50506040516200b598906200c1dc565b604051809103906000f0801580156200b5b5573d6000803e3d6000fd5b50506040516200b5c5906200c1dc565b604051809103906000f0801580156200b5e2573d6000803e3d6000fd5b50506040516200b5f2906200c1dc565b604051809103906000f0801580156200b60f573d6000803e3d6000fd5b50506040516200b61f906200c1dc565b604051809103906000f0801580156200b63c573d6000803e3d6000fd5b50506040516200b64c906200c1dc565b604051809103906000f0801580156200b669573d6000803e3d6000fd5b50506040516200b679906200c1dc565b604051809103906000f0801580156200b696573d6000803e3d6000fd5b50506040516200b6a6906200c1dc565b604051809103906000f0801580156200b6c3573d6000803e3d6000fd5b50506040516200b6d3906200c1dc565b604051809103906000f0801580156200b6f0573d6000803e3d6000fd5b50506040516200b700906200c1dc565b604051809103906000f0801580156200b71d573d6000803e3d6000fd5b50506040516200b72d906200c1dc565b604051809103906000f0801580156200b74a573d6000803e3d6000fd5b50506040516200b75a906200c1dc565b604051809103906000f0801580156200b777573d6000803e3d6000fd5b50506040516200b787906200c1dc565b604051809103906000f0801580156200b7a4573d6000803e3d6000fd5b50506040516200b7b4906200c1dc565b604051809103906000f0801580156200b7d1573d6000803e3d6000fd5b50506040516200b7e1906200c1dc565b604051809103906000f0801580156200b7fe573d6000803e3d6000fd5b50506040516200b80e906200c1dc565b604051809103906000f0801580156200b82b573d6000803e3d6000fd5b50506040516200b83b906200c1dc565b604051809103906000f0801580156200b858573d6000803e3d6000fd5b50506040516200b868906200c1dc565b604051809103906000f0801580156200b885573d6000803e3d6000fd5b50506040516200b895906200c1dc565b604051809103906000f0801580156200b8b2573d6000803e3d6000fd5b50506040516200b8c2906200c1dc565b604051809103906000f0801580156200b8df573d6000803e3d6000fd5b50506040516200b8ef906200c1dc565b604051809103906000f0801580156200b90c573d6000803e3d6000fd5b50506040516200b91c906200c1dc565b604051809103906000f0801580156200b939573d6000803e3d6000fd5b50506040516200b949906200c1dc565b604051809103906000f0801580156200b966573d6000803e3d6000fd5b50506040516200b976906200c1dc565b604051809103906000f0801580156200b993573d6000803e3d6000fd5b50506040516200b9a3906200c1dc565b604051809103906000f0801580156200b9c0573d6000803e3d6000fd5b50506040516200b9d0906200c1dc565b604051809103906000f0801580156200b9ed573d6000803e3d6000fd5b50506040516200b9fd906200c1dc565b604051809103906000f0801580156200ba1a573d6000803e3d6000fd5b50506040516200ba2a906200c1dc565b604051809103906000f0801580156200ba47573d6000803e3d6000fd5b50506040516200ba57906200c1dc565b604051809103906000f0801580156200ba74573d6000803e3d6000fd5b50506040516200ba84906200c1dc565b604051809103906000f0801580156200baa1573d6000803e3d6000fd5b50506040516200bab1906200c1dc565b604051809103906000f0801580156200bace573d6000803e3d6000fd5b50506040516200bade906200c1dc565b604051809103906000f0801580156200bafb573d6000803e3d6000fd5b50506040516200bb0b906200c1dc565b604051809103906000f0801580156200bb28573d6000803e3d6000fd5b50506040516200bb38906200c1dc565b604051809103906000f0801580156200bb55573d6000803e3d6000fd5b50506040516200bb65906200c1dc565b604051809103906000f0801580156200bb82573d6000803e3d6000fd5b50506040516200bb92906200c1dc565b604051809103906000f0801580156200bbaf573d6000803e3d6000fd5b50506040516200bbbf906200c1dc565b604051809103906000f0801580156200bbdc573d6000803e3d6000fd5b50506040516200bbec906200c1dc565b604051809103906000f0801580156200bc09573d6000803e3d6000fd5b50506040516200bc19906200c1dc565b604051809103906000f0801580156200bc36573d6000803e3d6000fd5b50506040516200bc46906200c1dc565b604051809103906000f0801580156200bc63573d6000803e3d6000fd5b50506040516200bc73906200c1dc565b604051809103906000f0801580156200bc90573d6000803e3d6000fd5b50506040516200bca0906200c1dc565b604051809103906000f0801580156200bcbd573d6000803e3d6000fd5b50506040516200bccd906200c1dc565b604051809103906000f0801580156200bcea573d6000803e3d6000fd5b50506040516200bcfa906200c1dc565b604051809103906000f0801580156200bd17573d6000803e3d6000fd5b50506040516200bd27906200c1dc565b604051809103906000f0801580156200bd44573d6000803e3d6000fd5b50506040516200bd54906200c1dc565b604051809103906000f0801580156200bd71573d6000803e3d6000fd5b50506040516200bd81906200c1dc565b604051809103906000f0801580156200bd9e573d6000803e3d6000fd5b50506040516200bdae906200c1dc565b604051809103906000f0801580156200bdcb573d6000803e3d6000fd5b50506040516200bddb906200c1dc565b604051809103906000f0801580156200bdf8573d6000803e3d6000fd5b50506040516200be08906200c1dc565b604051809103906000f0801580156200be25573d6000803e3d6000fd5b50506040516200be35906200c1dc565b604051809103906000f0801580156200be52573d6000803e3d6000fd5b50506040516200be62906200c1dc565b604051809103906000f0801580156200be7f573d6000803e3d6000fd5b50506040516200be8f906200c1dc565b604051809103906000f0801580156200beac573d6000803e3d6000fd5b50506040516200bebc906200c1dc565b604051809103906000f0801580156200bed9573d6000803e3d6000fd5b50506040516200bee9906200c1dc565b604051809103906000f0801580156200bf06573d6000803e3d6000fd5b50506040516200bf16906200c1dc565b604051809103906000f0801580156200bf33573d6000803e3d6000fd5b50506040516200bf43906200c1dc565b604051809103906000f0801580156200bf60573d6000803e3d6000fd5b50506040516200bf70906200c1dc565b604051809103906000f0801580156200bf8d573d6000803e3d6000fd5b50506040516200bf9d906200c1dc565b604051809103906000f0801580156200bfba573d6000803e3d6000fd5b50506040516200bfca906200c1dc565b604051809103906000f0801580156200bfe7573d6000803e3d6000fd5b50506040516200bff7906200c1dc565b604051809103906000f0801580156200c014573d6000803e3d6000fd5b50506040516200c024906200c1dc565b604051809103906000f0801580156200c041573d6000803e3d6000fd5b50506040516200c051906200c1dc565b604051809103906000f0801580156200c06e573d6000803e3d6000fd5b50506040516200c07e906200c1dc565b604051809103906000f0801580156200c09b573d6000803e3d6000fd5b50506040516200c0ab906200c1dc565b604051809103906000f0801580156200c0c8573d6000803e3d6000fd5b50506040516200c0d8906200c1dc565b604051809103906000f0801580156200c0f5573d6000803e3d6000fd5b50506040516200c105906200c1dc565b604051809103906000f0801580156200c122573d6000803e3d6000fd5b50506040516200c132906200c1dc565b604051809103906000f0801580156200c14f573d6000803e3d6000fd5b50506040516200c15f906200c1dc565b604051809103906000f0801580156200c17c573d6000803e3d6000fd5b50506040516200c18c906200c1dc565b604051809103906000f0801580156200c1a9573d6000803e3d6000fd5b50506040516200c1b9906200c1dc565b604051809103906000f0801580156200c1d6573d6000803e3d6000fd5b50505050565b60d7806200c1ea8339019056fe608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50609e806100396000396000f3fe6080604052600436106038577c010000000000000000000000000000000000000000000000000000000060003504631a6952308114603d575b600080fd5b606d60048036036020811015605157600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16606f565b005b5056fea165627a7a7230582083f7a0331a259c77978d4e827b5b676f9e07ff2fa04be79c314e25873f3b11040029a165627a7a7230582084782da67a2e82014f2871d2e67c7a7d13b0595d88286112fb82e4f6ea3cf8700029" - code_Scenario015_TRC20_TRON = "6060604052604060405190810160405280600681526020017f54726f6e697800000000000000000000000000000000000000000000000000008152506000908051906020019062000052929190620001b6565b50604060405190810160405280600381526020017f545258000000000000000000000000000000000000000000000000000000000081525060019080519060200190620000a1929190620001b6565b50600660025560006005556000600660006101000a81548160ff0219169083151502179055506000600660016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034156200011257fe5b5b33600660016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555067016345785d8a000060058190555067016345785d8a0000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b62000265565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001f957805160ff19168380011785556200022a565b828001600101855582156200022a579182015b82811115620002295782518255916020019190600101906200020c565b5b5090506200023991906200023d565b5090565b6200026291905b808211156200025e57600081600090555060010162000244565b5090565b90565b61111480620002756000396000f300606060405236156100ce576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d057806307da68f514610169578063095ea7b31461017b57806318160ddd146101d257806323b872dd146101f8578063313ce5671461026e57806342966c681461029457806370a08231146102b457806375f12b21146102fe57806395d89b4114610328578063a9059cbb146103c1578063be9a655514610418578063c47f00271461042a578063dd62ed3e14610484575bfe5b34156100d857fe5b6100e06104ed565b604051808060200182810382528381815181526020019150805190602001908083836000831461012f575b80518252602083111561012f5760208201915060208101905060208303925061010b565b505050905090810190601f16801561015b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561017157fe5b61017961058b565b005b341561018357fe5b6101b8600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610603565b604051808215151515815260200191505060405180910390f35b34156101da57fe5b6101e26107cb565b6040518082815260200191505060405180910390f35b341561020057fe5b610254600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506107d1565b604051808215151515815260200191505060405180910390f35b341561027657fe5b61027e610b11565b6040518082815260200191505060405180910390f35b341561029c57fe5b6102b26004808035906020019091905050610b17565b005b34156102bc57fe5b6102e8600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c3f565b6040518082815260200191505060405180910390f35b341561030657fe5b61030e610c57565b604051808215151515815260200191505060405180910390f35b341561033057fe5b610338610c6a565b6040518080602001828103825283818151815260200191508051906020019080838360008314610387575b80518252602083111561038757602082019150602081019050602083039250610363565b505050905090810190601f1680156103b35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103c957fe5b6103fe600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610d08565b604051808215151515815260200191505060405180910390f35b341561042057fe5b610428610f31565b005b341561043257fe5b610482600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610fa9565b005b341561048c57fe5b6104d7600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061101e565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105835780601f1061055857610100808354040283529160200191610583565b820191906000526020600020905b81548152906001019060200180831161056657829003601f168201915b505050505081565b3373ffffffffffffffffffffffffffffffffffffffff16600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156105e457fe5b6001600660006101000a81548160ff0219169083151502179055505b5b565b6000600660009054906101000a900460ff1615151561061e57fe5b3373ffffffffffffffffffffffffffffffffffffffff1660001415151561064157fe5b60008214806106cc57506000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054145b15156106d85760006000fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a3600190505b5b5b92915050565b60055481565b6000600660009054906101000a900460ff161515156107ec57fe5b3373ffffffffffffffffffffffffffffffffffffffff1660001415151561080f57fe5b81600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561085e5760006000fd5b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401101515156108ee5760006000fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561097a5760006000fd5b81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b5b5b9392505050565b60025481565b80600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610b665760006000fd5b80600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508060036000600073ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060003373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35b50565b60036020528060005260406000206000915090505481565b600660009054906101000a900460ff1681565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610d005780601f10610cd557610100808354040283529160200191610d00565b820191906000526020600020905b815481529060010190602001808311610ce357829003601f168201915b505050505081565b6000600660009054906101000a900460ff16151515610d2357fe5b3373ffffffffffffffffffffffffffffffffffffffff16600014151515610d4657fe5b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610d955760006000fd5b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110151515610e255760006000fd5b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b5b5b92915050565b3373ffffffffffffffffffffffffffffffffffffffff16600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610f8a57fe5b6000600660006101000a81548160ff0219169083151502179055505b5b565b3373ffffffffffffffffffffffffffffffffffffffff16600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561100257fe5b8060009080519060200190611018929190611043565b505b5b50565b6004602052816000526040600020602052806000526040600020600091509150505481565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061108457805160ff19168380011785556110b2565b828001600101855582156110b2579182015b828111156110b1578251825591602001919060010190611096565b5b5090506110bf91906110c3565b5090565b6110e591905b808211156110e15760008160009055506001016110c9565b5090565b905600a165627a7a723058204858328431ff0a4e0db74ff432e5805ce4bcf91a1c59650a93bd7c1aec5e0fe10029" - code_MainGateway = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50604051602080611df8833981016040818152915160008054600160a060020a0319163317815560016004819055600160a060020a0383168083526003602090815292869020805460ff191690921790915583529251909283927f51b292b9f000ae271c781ab0e5f63c49de0000ab30e186d92a03bbaf3325a4a3929081900390910190a15050611d38806100c06000396000f3006080604052600436106101195763ffffffff60e060020a6000350416630aa33f758114610144578063190791da146101935780634b398e991461021c5780635821563e1461022457806361857b441461022c578063715018a61461026a5780637276575c146102995780637ecebe00146102d7578063898de999146103245780638d3e651d146103535780638da5cb5b146103dc57806394042b46146104275780639435455f14610459578063a165302a14610499578063a8ced426146104d7578063bc2de9b01461055d578063bcad917b14610598578063cb912b1e14610650578063cd9df8e1146106d3578063d3d5177b14610702578063e77256f814610743578063e7fc18f8146107c6578063f2fde38b14610801575b620f4240d311156101315761012c61083c565b610142565b6000341115610142576101426108b4565b005b34801561015057600080fd5b50d3801561015d57600080fd5b50d2801561016a57600080fd5b5061017f600160a060020a0360043516610906565b604080519115158252519081900360200190f35b34801561019f57600080fd5b50d380156101ac57600080fd5b50d280156101b957600080fd5b50604080516020601f60643560048181013592830184900484028501840190955281845261014294600160a060020a0381358116956024803590921695604435953695608494019181908401838280828437509497506109489650505050505050565b6101426108b4565b61014261083c565b34801561023857600080fd5b50d3801561024557600080fd5b50d2801561025257600080fd5b50610142600435600160a060020a0360243516610cb2565b34801561027657600080fd5b50d3801561028357600080fd5b50d2801561029057600080fd5b50610142610e35565b3480156102a557600080fd5b50d380156102b257600080fd5b50d280156102bf57600080fd5b50610142600435600160a060020a0360243516610ea1565b3480156102e357600080fd5b50d380156102f057600080fd5b50d280156102fd57600080fd5b50610312600160a060020a0360043516610ff6565b60408051918252519081900360200190f35b34801561033057600080fd5b50d3801561033d57600080fd5b50d2801561034a57600080fd5b50610312611008565b34801561035f57600080fd5b50d3801561036c57600080fd5b50d2801561037957600080fd5b50604080516020601f60643560048181013592830184900484028501840190955281845261014294600160a060020a03813581169560248035909216956044359536956084940191819084018382808284375094975061100e9650505050505050565b3480156103e857600080fd5b50d380156103f557600080fd5b50d2801561040257600080fd5b5061040b6112ed565b60408051600160a060020a039092168252519081900360200190f35b34801561043357600080fd5b50d3801561044057600080fd5b50d2801561044d57600080fd5b506103126004356112fc565b34801561046557600080fd5b50d3801561047257600080fd5b50d2801561047f57600080fd5b50610142600160a060020a0360043516602435151561130e565b3480156104a557600080fd5b50d380156104b257600080fd5b50d280156104bf57600080fd5b5061017f600435600160a060020a0360243516611350565b3480156104e357600080fd5b50d380156104f057600080fd5b50d280156104fd57600080fd5b50604080516020601f60643560048181013592830184900484028501840190955281845261014294600160a060020a0381351694602480359560443595369560849493019181908401838280828437509497506113789650505050505050565b34801561056957600080fd5b50d3801561057657600080fd5b50d2801561058357600080fd5b5061040b600160a060020a036004351661163a565b3480156105a457600080fd5b50d380156105b157600080fd5b50d280156105be57600080fd5b50604080516020600460443581810135601f810184900484028501840190955284845261061b948235600160a060020a03169460248035953695946064949201919081908401838280828437509497506116559650505050505050565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b34801561065c57600080fd5b50d3801561066957600080fd5b50d2801561067657600080fd5b50604080516020600460443581810135601f810184900484028501840190955284845261061b948235600160a060020a031694602480359536959460649492019190819084018382808284375094975061172c9650505050505050565b3480156106df57600080fd5b50d380156106ec57600080fd5b50d280156106f957600080fd5b50610312611803565b34801561070e57600080fd5b50d3801561071b57600080fd5b50d2801561072857600080fd5b50610142600160a060020a0360043581169060243516611809565b34801561074f57600080fd5b50d3801561075c57600080fd5b50d2801561076957600080fd5b50604080516020600460443581810135601f8101849004840285018401909552848452610142948235600160a060020a03169460248035953695946064949201919081908401838280828437509497506118589650505050505050565b3480156107d257600080fd5b50d380156107df57600080fd5b50d280156107ec57600080fd5b50610312600160a060020a0360043516611af6565b34801561080d57600080fd5b50d3801561081a57600080fd5b50d2801561082757600080fd5b50610142600160a060020a0360043516611b11565bd360009081526006602052604090205461085c90d263ffffffff611b3416565bd3600081815260066020908152604091829020939093558051338152d29381019390935282810191909152517f752bc43ba57e4a49162727f5fb5d6f7b0e017826011a02a0b3cddcd70c49b1459181900360600190a1565b6005546108c7903463ffffffff611b3416565b6005556040805133815234602082015281517f1bab02886c659969cbb004cc17dc19be19f193323a306e26c669bedb29c651f7929181900390910190a1565b60008054600160a060020a038381169116141561092557506001610943565b50600160a060020a03811660009081526003602052604090205460ff165b919050565b83828483606060008061095a33610906565b151561096557600080fd5b6040805160028082526060820183529091602083019080388339505050600160a060020a03881660009081526002602052604081205482519295509185919081106109ac57fe5b6020908102909101015282518690849060019081106109c757fe5b906020019060200201818152505084836040516020018083600160a060020a0316600160a060020a03166c01000000000000000000000000028152601401828051906020019060200280838360005b83811015610a2e578181015183820152602001610a16565b50505050905001925050506040516020818303038152906040526040518082805190602001908083835b60208310610a775780518252601f199092019160209182019101610a58565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209450610ab29250849150869050611b4a565b9050600160a060020a0380821690881614610b05576040805160e560020a62461bcd02815260206004820152601e6024820152600080516020611ced833981519152604482015290519081900360640190fd5b600160a060020a038a1660009081526008602090815260408083208c845290915290205460ff161515610b82576040805160e560020a62461bcd02815260206004820152601260248201527f446f6573206e6f74206f776e20746f6b656e0000000000000000000000000000604482015290519081900360640190fd5b89600160a060020a031663a9059cbb8c8b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050600060405180830381600087803b158015610be557600080fd5b505af1158015610bf9573d6000803e3d6000fd5b505050600160a060020a03808c1660009081526008602090815260408083208e845290915290819020805460ff1916905551908d1691507f591f2d33d85291e32c4067b5a497caf3ddb5b1830eba9909e66006ec3a0051b4906003908d908d9080845b60ff168152600160a060020a0390931660208401525060408083019190915251908190036060019150a2505050600160a060020a0390931660009081526002602052604090208054600101905550505050505050565b600160a060020a03818116600090815260016020526040902054161515610d11576040805160e560020a62461bcd0281526020600482015260136024820152600080516020611ccd833981519152604482015290519081900360640190fd5b604080517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018490529051600160a060020a038316916323b872dd9160648083019260209291908290030181600087803b158015610d7f57600080fd5b505af1158015610d93573d6000803e3d6000fd5b505050506040513d6020811015610da957600080fd5b5050600160a060020a038116600090815260076020526040902054610dd4908363ffffffff611b3416565b600160a060020a03821660008181526007602090815260409182902093909355805133815292830185905282810191909152517fe669217c299ce4efdf9b6269aaa41cc844a89016bdb0badde25a2e2f469cc3409181900360600190a15050565b600054600160a060020a03163314610e4c57600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600160a060020a03818116600090815260016020526040902054161515610f00576040805160e560020a62461bcd0281526020600482015260136024820152600080516020611ccd833981519152604482015290519081900360640190fd5b604080517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018490529051600160a060020a038316916323b872dd91606480830192600092919082900301818387803b158015610f6d57600080fd5b505af1158015610f81573d6000803e3d6000fd5b505050600160a060020a0382166000818152600860209081526040808320878452825291829020805460ff19166001179055815133815290810186905280820192909252517fdf4b094c64ac1ec490d3302edb22d396ed9c1f23b14d2c307e04858399cc393292509081900360600190a15050565b60026020526000908152604090205481565b60045481565b83828483606060008061102033610906565b151561102b57600080fd5b6040805160028082526060820183529091602083019080388339505050600160a060020a038816600090815260026020526040812054825192955091859190811061107257fe5b60209081029091010152825186908490600190811061108d57fe5b906020019060200201818152505084836040516020018083600160a060020a0316600160a060020a03166c01000000000000000000000000028152601401828051906020019060200280838360005b838110156110f45781810151838201526020016110dc565b50505050905001925050506040516020818303038152906040526040518082805190602001908083835b6020831061113d5780518252601f19909201916020918201910161111e565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912094506111789250849150869050611b4a565b9050600160a060020a03808216908816146111cb576040805160e560020a62461bcd02815260206004820152601e6024820152600080516020611ced833981519152604482015290519081900360640190fd5b600160a060020a038a166000908152600760205260409020546111f4908a63ffffffff611be116565b600560020160008c600160a060020a0316600160a060020a031681526020019081526020016000208190555089600160a060020a031663a9059cbb8c8b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b15801561128357600080fd5b505af1158015611297573d6000803e3d6000fd5b505050506040513d60208110156112ad57600080fd5b5050604051600160a060020a038c16907f591f2d33d85291e32c4067b5a497caf3ddb5b1830eba9909e66006ec3a0051b4906002908d908d908084610c5c565b600054600160a060020a031681565b60009081526006602052604090205490565b600054600160a060020a0316331461132557600080fd5b600160a060020a03919091166000908152600360205260409020805460ff1916911515919091179055565b600160a060020a03166000908152600860209081526040808320938352929052205460ff1690565b83828483606060008061138a33610906565b151561139557600080fd5b604080516003808252608082019092529060208201606080388339019050509250848360008151811015156113c657fe5b6020908102909101810191909152600160a060020a0388166000908152600290915260409020548351849060019081106113fc57fe5b60209081029091010152825186908490600290811061141757fe5b90602001906020020181815250508260405160200180828051906020019060200280838360005b8381101561145657818101518382015260200161143e565b505050509050019150506040516020818303038152906040526040518082805190602001908083835b6020831061149e5780518252601f19909201916020918201910161147f565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912094506114d99250849150869050611b4a565b9050600160a060020a038082169088161461152c576040805160e560020a62461bcd02815260206004820152601e6024820152600080516020611ced833981519152604482015290519081900360640190fd5b60008a81526006602052604090205461154b908a63ffffffff611be116565b60008b815260066020526040902055600160a060020a038b1689156108fc028a8c8015801561157957600080fd5b50806780000000000000001115801561159157600080fd5b5080620f4240101580156115a457600080fd5b50604051600081818185878a8ad09450505050501580156115c9573d6000803e3d6000fd5b506040805160018152602081018c90528082018b9052905133917f472adea2ebbd52a19b140bc25ddcbbe8d3317953a32da818924bab945e4709b1919081900360600190a2505050600160a060020a0390931660009081526002602052604090208054600101905550505050505050565b600160205260009081526040902054600160a060020a031681565b33600090815260016020526040812054600160a060020a031615156116b2576040805160e560020a62461bcd0281526020600482015260136024820152600080516020611ccd833981519152604482015290519081900360640190fd5b6116bb83611bf6565b60408051600160a060020a038616815260208101859052338183015290517fe669217c299ce4efdf9b6269aaa41cc844a89016bdb0badde25a2e2f469cc3409181900360600190a1507fbcad917b000000000000000000000000000000000000000000000000000000009392505050565b33600090815260016020526040812054600160a060020a03161515611789576040805160e560020a62461bcd0281526020600482015260136024820152600080516020611ccd833981519152604482015290519081900360640190fd5b61179283611c29565b60408051600160a060020a038616815260208101859052338183015290517fdf4b094c64ac1ec490d3302edb22d396ed9c1f23b14d2c307e04858399cc39329181900360600190a1507fcb912b1e000000000000000000000000000000000000000000000000000000009392505050565b60055490565b61181233610906565b151561181d57600080fd5b600160a060020a039182166000908152600160205260409020805473ffffffffffffffffffffffffffffffffffffffff191691909216179055565b82823083606060008061186a33610906565b151561187557600080fd5b6040805160028082526060820183529091602083019080388339505050600160a060020a03881660009081526002602052604081205482519295509185919081106118bc57fe5b6020908102909101015282518690849060019081106118d757fe5b906020019060200201818152505084836040516020018083600160a060020a0316600160a060020a03166c01000000000000000000000000028152601401828051906020019060200280838360005b8381101561193e578181015183820152602001611926565b50505050905001925050506040516020818303038152906040526040518082805190602001908083835b602083106119875780518252601f199092019160209182019101611968565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912094506119c29250849150869050611b4a565b9050600160a060020a0380821690881614611a15576040805160e560020a62461bcd02815260206004820152601e6024820152600080516020611ced833981519152604482015290519081900360640190fd5b600554611a28908a63ffffffff611be116565b600555604051600160a060020a038b16908a156108fc02908b906000818181858888f19350505050158015611a61573d6000803e3d6000fd5b5089600160a060020a03167f591f2d33d85291e32c4067b5a497caf3ddb5b1830eba9909e66006ec3a0051b46000808c60405180846003811115611aa157fe5b60ff168152600160a060020a0390931660208401525060408083019190915251908190036060019150a2505050600160a060020a03909316600090815260026020526040902080546001019055505050505050565b600160a060020a031660009081526007602052604090205490565b600054600160a060020a03163314611b2857600080fd5b611b3181611c4f565b50565b81810182811015611b4457600080fd5b92915050565b60208101516040820151604183015160009260ff90911691601b831015611b7257601b830192505b60408051600080825260208083018085528a905260ff8716838501526060830186905260808301859052925160019360a0808501949193601f19840193928390039091019190865af1158015611bcc573d6000803e3d6000fd5b5050604051601f190151979650505050505050565b600082821115611bf057600080fd5b50900390565b33600090815260076020526040902054611c16908263ffffffff611b3416565b3360009081526007602052604090205550565b33600090815260086020908152604080832093835292905220805460ff19166001179055565b600160a060020a0381161515611c6457600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039290921691909117905556004e6f7420616e20616c6c6f776520746f6b656e000000000000000000000000004d657373616765206e6f74207369676e65642062792061206761696e65720000a165627a7a723058205cb7d7406fcca2093208cdfb8fa6d9a1ce5e4ae6b526286910d1b63990e322030029" - code_SideGateway = "608060405260068054600160a060020a03199081166201000017909155600780549091166201000117905534801561003657600080fd5b50d3801561004357600080fd5b50d2801561005057600080fd5b50604051602080613c54833981016040908152905160048054600160a060020a03191633179055600160a060020a03166000908152600360205220805460ff19166001179055613baf806100a56000396000f300608060405260043610620001195763ffffffff60e060020a6000350416630a61c59f81146200011e5780630bb0482f14620001605780630f40ef09146200028e5780631f1767eb14620002dc57806331775cc6146200032e578063455042361462000377578063473c3bd714620003c257806355781fcf146200041e57806367bf590314620005175780637ce67366146200054b5780638da5cb5b14620005ce5780639435455f1462000602578063ab15bdf81462000647578063addd5099146200073b578063bcad917b146200077b578063cb912b1e1462000838578063db13a12b14620008c0578063ded8454a1462000900578063ede1a1e91462000940578063eff457d2146200098e578063fce16fec14620009d1575b600080fd5b3480156200012b57600080fd5b50d380156200013957600080fd5b50d280156200014757600080fd5b506200015e600160a060020a036004351662000a1a565b005b3480156200016d57600080fd5b50d380156200017b57600080fd5b50d280156200018957600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526200021694369492936024939284019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a99988101979196509182019450925082915084018382808284375094975062000ac29650505050505050565b6040805160208082528351818301528351919283929083019185019080838360005b838110156200025257818101518382015260200162000238565b50505050905090810190601f168015620002805780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6040805160206004803580820135601f81018490048402850184019095528484526200015e94369492936024939284019190819084018382808284375094975062000bb49650505050505050565b348015620002e957600080fd5b50d38015620002f757600080fd5b50d280156200030557600080fd5b506200015e600160a060020a036004351660243560443560643560843560ff60a4351662000ca3565b3480156200033b57600080fd5b50d380156200034957600080fd5b50d280156200035757600080fd5b506200015e600160a060020a036004358116906024351660443562000e9c565b3480156200038457600080fd5b50d380156200039257600080fd5b50d28015620003a057600080fd5b50620003ae60043562001022565b604080519115158252519081900360200190f35b348015620003cf57600080fd5b50d38015620003dd57600080fd5b50d28015620003eb57600080fd5b5062000402600160a060020a036004351662001037565b60408051600160a060020a039092168252519081900360200190f35b3480156200042b57600080fd5b50d380156200043957600080fd5b50d280156200044757600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526200040294369492936024939284019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a99988101979196509182019450925082915084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a9998810197919650918201945092508291508401838280828437509497505050923560ff1693506200105292505050565b3480156200052457600080fd5b50d380156200053257600080fd5b50d280156200054057600080fd5b506200040262001344565b3480156200055857600080fd5b50d380156200056657600080fd5b50d280156200057457600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526200040294369492936024939284019190819084018382808284375094975050509235600160a060020a031693506200135392505050565b348015620005db57600080fd5b50d38015620005e957600080fd5b50d28015620005f757600080fd5b5062000402620013da565b3480156200060f57600080fd5b50d380156200061d57600080fd5b50d280156200062b57600080fd5b506200015e600160a060020a03600435166024351515620013e9565b3480156200065457600080fd5b50d380156200066257600080fd5b50d280156200067057600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526200040294369492936024939284019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a99988101979196509182019450925082915084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a9998810197919650918201945092508291508401838280828437509497506200142c9650505050505050565b3480156200074857600080fd5b50d380156200075657600080fd5b50d280156200076457600080fd5b50620003ae600160a060020a036004351662001712565b3480156200078857600080fd5b50d380156200079657600080fd5b50d28015620007a457600080fd5b50604080516020600460443581810135601f810184900484028501840190955284845262000803948235600160a060020a0316946024803595369594606494920191908190840183828082843750949750620017279650505050505050565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b3480156200084557600080fd5b50d380156200085357600080fd5b50d280156200086157600080fd5b50604080516020600460443581810135601f810184900484028501840190955284845262000803948235600160a060020a0316946024803595369594606494920191908190840183828082843750949750620019019650505050505050565b348015620008cd57600080fd5b50d38015620008db57600080fd5b50d28015620008e957600080fd5b5062000402600160a060020a036004351662001b01565b3480156200090d57600080fd5b50d380156200091b57600080fd5b50d280156200092957600080fd5b5062000216600160a060020a036004351662001b1c565b6040805160206004803580820135601f81018490048402850184019095528484526200015e94369492936024939284019190819084018382808284375094975062001b519650505050505050565b3480156200099b57600080fd5b50d38015620009a957600080fd5b50d28015620009b757600080fd5b506200015e600160a060020a036004351660243562001cf1565b348015620009de57600080fd5b50d38015620009ec57600080fd5b50d28015620009fa57600080fd5b506200015e600160a060020a036004358116906024351660443562001dbf565b600454600160a060020a0316331462000a3257600080fd5b600160a060020a038116151562000a93576040805160e560020a62461bcd02815260206004820152601e60248201527f5f73756e546f6b656e41646472657373203d3d20616464726573732830290000604482015290519081900360640190fd5b6005805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6060826041836040516020018084805190602001908083835b6020831062000afc5780518252601f19909201916020918201910162000adb565b6001836020036101000a0380198251168184511680821785525050505050509050018360ff167f010000000000000000000000000000000000000000000000000000000000000002815260010182805190602001908083835b6020831062000b765780518252601f19909201916020918201910162000b55565b6001836020036101000a0380198251168184511680821785525050505050509050019350505050604051602081830303815290604052905092915050565b6040516000903480156108fc029183818181858288f1935050505015801562000be1573d6000803e3d6000fd5b507f7a47a70a1221ce1b92f8d000c55e2c92c0255a381cf1be25c3ca697593ecc96a3334836040518084600160a060020a0316600160a060020a0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101562000c6357818101518382015260200162000c49565b50505050905090810190601f16801562000c915780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a150565b3360009081526003602052604081205460ff16151562000cc257600080fd5b620f42408611801562000cd85750621e84808611155b151562000d55576040805160e560020a62461bcd02815260206004820152602360248201527f7472633130203c3d2031303030303030206f72207472633130203e203230303060448201527f3030300000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b5060008581526002602052604090205460ff1680151562000d8a576000868152600260205260409020805460ff191660011790555b60075460408051878152602081018990528082018790526060810186905260ff851660808201529051600160a060020a039092169160a0808301926000929190829003018183865af1505050600160a060020a0387166108fc86150286888015801562000df657600080fd5b50806780000000000000001115801562000e0f57600080fd5b5080620f42401015801562000e2357600080fd5b50604051600081818185878a8ad094505050505015801562000e49573d6000803e3d6000fd5b5060408051600160a060020a03891681526020810188905280820187905290517f4aac44dc080543b9fe45d9dfaad396001ee0ecdc07499d64e2e798bfffc42fde9181900360600190a150505050505050565b3360009081526003602052604081205460ff16151562000ebb57600080fd5b50600160a060020a038083166000908152602081905260409020541680151562000f54576040805160e560020a62461bcd028152602060048201526024808201527f746865206d61696e20636861696e2061646472657373206861736e2774206d6160448201527f7070656400000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b80600160a060020a03166340c10f1985846040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050600060405180830381600087803b15801562000fb857600080fd5b505af115801562000fcd573d6000803e3d6000fd5b505060408051600160a060020a0380861682528816602082015280820186905290517f48c104169bad147dfc9c0b2ac8fc83202a035d4d9632e24e839680be759772089350908190036060019150a150505050565b60026020526000908152604090205460ff1681565b600060208190529081526040902054600160a060020a031681565b600080600062001063873362001353565b600160a060020a038082166000908152602081905260409020549193501615620010fd576040805160e560020a62461bcd02815260206004820152602160248201527f746865206d61696e20636861696e206164647265737320686173206d6170706560448201527f6400000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600554600160a060020a03838116911614156200118a576040805160e560020a62461bcd02815260206004820152602360248201527f6d61696e436861696e41646472657373203d3d2073756e546f6b656e4164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b308686866200119862001f45565b600160a060020a038516815260ff82166060820152608060208083018281528651928401929092528551604084019160a08501919088019080838360005b83811015620011f0578181015183820152602001620011d6565b50505050905090810190601f1680156200121e5780820380516001836020036101000a031916815260200191505b50838103825285518152855160209182019187019080838360005b838110156200125357818101518382015260200162001239565b50505050905090810190601f168015620012815780820380516001836020036101000a031916815260200191505b509650505050505050604051809103906000f080158015620012a7573d6000803e3d6000fd5b50600160a060020a03808416600081815260208181526040808320805495871673ffffffffffffffffffffffffffffffffffffffff1996871681179091558084526001835292819020805490951684179094558351338152908101929092528183015290519192507fee201bea1b0aff77f5f792b979e4732ba6605c2203d0f92f9aa45625eff88222919081900360600190a19695505050505050565b600554600160a060020a031681565b6000606080620013638462001b1c565b915062001371858362000ac2565b9050806040518082805190602001908083835b60208310620013a55780518252601f19909201916020918201910162001384565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912098975050505050505050565b600454600160a060020a031681565b600454600160a060020a031633146200140157600080fd5b600160a060020a03919091166000908152600360205260409020805460ff1916911515919091179055565b60008060006200143d863362001353565b600160a060020a038082166000908152602081905260409020549193501615620014d7576040805160e560020a62461bcd02815260206004820152602160248201527f746865206d61696e20636861696e206164647265737320686173206d6170706560448201527f6400000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600554600160a060020a038381169116141562001564576040805160e560020a62461bcd02815260206004820152602360248201527f6d61696e436861696e41646472657373203d3d2073756e546f6b656e4164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b3085856200157162001f56565b600160a060020a0384168152606060208083018281528551928401929092528451604084019160808501919087019080838360005b83811015620015c0578181015183820152602001620015a6565b50505050905090810190601f168015620015ee5780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b838110156200162357818101518382015260200162001609565b50505050905090810190601f168015620016515780820380516001836020036101000a031916815260200191505b5095505050505050604051809103906000f08015801562001676573d6000803e3d6000fd5b50600160a060020a03808416600081815260208181526040808320805495871673ffffffffffffffffffffffffffffffffffffffff1996871681179091558084526001835292819020805490951684179094558351338152908101929092528183015290519192507fa2399d6f422f35b470d7aff96f7b2d8ce1c07bc14d978c9fbad6083461c564a7919081900360600190a195945050505050565b60036020526000908152604090205460ff1681565b33600081815260016020526040812054909190600160a060020a03168015156200179b576040805160e560020a62461bcd02815260206004820152601e60248201527f6d61696e436861696e41646472657373203d3d20616464726573732830290000604482015290519081900360640190fd5b81600160a060020a03166342966c68866040518263ffffffff1660e060020a02815260040180828152602001915050600060405180830381600087803b158015620017e557600080fd5b505af1158015620017fa573d6000803e3d6000fd5b505050507fc7b54407df97321a6170a99eeb667db3dc95205c9a9b12a4f1673bac84066544868683876040518085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015620018985781810151838201526020016200187e565b50505050905090810190601f168015620018c65780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1507fbcad917b0000000000000000000000000000000000000000000000000000000095945050505050565b33600081815260016020526040812054909190600160a060020a03168015156200199b576040805160e560020a62461bcd02815260206004820152602360248201527f74686520747263373231206d7573742068617665206265656e206465706f736960448201527f7465640000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b81600160a060020a03166342966c68866040518263ffffffff1660e060020a02815260040180828152602001915050600060405180830381600087803b158015620019e557600080fd5b505af1158015620019fa573d6000803e3d6000fd5b505050507fa93bdc38faeb2081566bca9d2c041ba1545a11a459c67a8baf5c671a262e9b7c868683876040518085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101562001a9857818101518382015260200162001a7e565b50505050905090810190601f16801562001ac65780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1507fcb912b1e0000000000000000000000000000000000000000000000000000000095945050505050565b600160205260009081526040902054600160a060020a031681565b60408051600160a060020a03929092167414000000000000000000000000000000000000000018601483015260348201905290565bd360009081526002602052604090205460ff16151562001bbb576040805160e560020a62461bcd02815260206004820152601e60248201527f74726331304d61705b6d73672e746f6b656e69645d203d3d2066616c73650000604482015290519081900360640190fd5b6000d280156108fc0290d38015801562001bd457600080fd5b50806780000000000000001115801562001bed57600080fd5b5080620f42401015801562001c0157600080fd5b50604051600081818185878a8ad094505050505015801562001c27573d6000803e3d6000fd5b507f4cdc0dc16c2640bf1cbeebfe9055747d6c36b74120ed1d06440846a8150cc4c333d2d3846040518085600160a060020a0316600160a060020a0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101562001cb057818101518382015260200162001c96565b50505050905090810190601f16801562001cde5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a150565b3360009081526003602052604090205460ff16151562001d1057600080fd5b600654604080518381529051600160a060020a03909216916020808301926000929190829003018183865af15050604051600160a060020a038416915082156108fc029083906000818181858888f1935050505015801562001d76573d6000803e3d6000fd5b5060408051600160a060020a03841681526020810183905281517f0e3147459e9437f793e793b98df267ee885cfe4ad096b279287f03dcd0ca0497929181900390910190a15050565b3360009081526003602052604081205460ff16151562001dde57600080fd5b50600160a060020a038083166000908152602081905260409020541680151562001e77576040805160e560020a62461bcd028152602060048201526024808201527f746865206d61696e20636861696e2061646472657373206861736e2774206d6160448201527f7070656400000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b80600160a060020a03166340c10f1985846040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050600060405180830381600087803b15801562001edb57600080fd5b505af115801562001ef0573d6000803e3d6000fd5b505060408051600160a060020a0380861682528816602082015280820186905290517fb49dbda83c867b85d55c88d22a084e7db05c8a29e16d027af1b02105906d16bc9350908190036060019150a150505050565b604051610d7c8062001f6883390190565b604051610ea08062002ce4833901905600608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50604051610d7c380380610d7c833981016040908152815160208084015192840151606085015160038054600160a060020a031916600160a060020a0386161790559385018051939590949101929091610089916004918601906100bf565b50815161009d9060059060208501906100bf565b506006805460ff191660ff92909216919091179055505060006002555061015a565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061010057805160ff191683800117855561012d565b8280016001018555821561012d579182015b8281111561012d578251825591602001919060010190610112565b5061013992915061013d565b5090565b61015791905b808211156101395760008155600101610143565b90565b610c13806101696000396000f3006080604052600436106100da5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100df578063095ea7b314610183578063116191b6146101d557806318160ddd1461022057806323b872dd14610261578063313ce567146102a557806339509351146102ea57806340c10f191461032857806342966c681461036857806349e118931461039a57806370a082311461041257806395d89b411461044d578063a457c2d71461047c578063a9059cbb146104ba578063dd62ed3e146104f8575b600080fd5b3480156100eb57600080fd5b50d380156100f857600080fd5b50d2801561010557600080fd5b5061010e610539565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610148578181015183820152602001610130565b50505050905090810190601f1680156101755780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561018f57600080fd5b50d3801561019c57600080fd5b50d280156101a957600080fd5b506101c1600160a060020a03600435166024356105c7565b604080519115158252519081900360200190f35b3480156101e157600080fd5b50d380156101ee57600080fd5b50d280156101fb57600080fd5b506102046105dd565b60408051600160a060020a039092168252519081900360200190f35b34801561022c57600080fd5b50d3801561023957600080fd5b50d2801561024657600080fd5b5061024f6105ec565b60408051918252519081900360200190f35b34801561026d57600080fd5b50d3801561027a57600080fd5b50d2801561028757600080fd5b506101c1600160a060020a03600435811690602435166044356105f2565b3480156102b157600080fd5b50d380156102be57600080fd5b50d280156102cb57600080fd5b506102d4610649565b6040805160ff9092168252519081900360200190f35b3480156102f657600080fd5b50d3801561030357600080fd5b50d2801561031057600080fd5b506101c1600160a060020a0360043516602435610652565b34801561033457600080fd5b50d3801561034157600080fd5b50d2801561034e57600080fd5b50610366600160a060020a036004351660243561068e565b005b34801561037457600080fd5b50d3801561038157600080fd5b50d2801561038e57600080fd5b5061036660043561074f565b3480156103a657600080fd5b50d380156103b357600080fd5b50d280156103c057600080fd5b5060408051602060046024803582810135601f810185900485028601850190965285855261036695833595369560449491939091019190819084018382808284375094975061075c9650505050505050565b34801561041e57600080fd5b50d3801561042b57600080fd5b50d2801561043857600080fd5b5061024f600160a060020a03600435166108d0565b34801561045957600080fd5b50d3801561046657600080fd5b50d2801561047357600080fd5b5061010e6108eb565b34801561048857600080fd5b50d3801561049557600080fd5b50d280156104a257600080fd5b506101c1600160a060020a0360043516602435610946565b3480156104c657600080fd5b50d380156104d357600080fd5b50d280156104e057600080fd5b506101c1600160a060020a0360043516602435610982565b34801561050457600080fd5b50d3801561051157600080fd5b50d2801561051e57600080fd5b5061024f600160a060020a036004358116906024351661098f565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105bf5780601f10610594576101008083540402835291602001916105bf565b820191906000526020600020905b8154815290600101906020018083116105a257829003601f168201915b505050505081565b60006105d43384846109ba565b50600192915050565b600354600160a060020a031681565b60025490565b60006105ff848484610a46565b600160a060020a03841660009081526001602090815260408083203380855292529091205461063f91869161063a908663ffffffff610b1316565b6109ba565b5060019392505050565b60065460ff1681565b336000818152600160209081526040808320600160a060020a038716845290915281205490916105d491859061063a908663ffffffff610b2816565b600354600160a060020a031633146106a557600080fd5b600160a060020a03821615156106ba57600080fd5b6002546106cd908263ffffffff610b2816565b600255600160a060020a0382166000908152602081905260409020546106f9908263ffffffff610b2816565b600160a060020a0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6107593382610b3e565b50565b60035460009061077590600160a060020a031684610982565b506003546040517fbcad917b000000000000000000000000000000000000000000000000000000008152336004820181815260248301879052606060448401908152865160648501528651600160a060020a039095169463bcad917b94899389939092909160840190602085019080838360005b838110156108015781810151838201526020016107e9565b50505050905090810190601f16801561082e5780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b15801561084f57600080fd5b505af1158015610863573d6000803e3d6000fd5b505050506040513d602081101561087957600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167fbcad917b00000000000000000000000000000000000000000000000000000000146108cb57600080fd5b505050565b600160a060020a031660009081526020819052604090205490565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105bf5780601f10610594576101008083540402835291602001916105bf565b336000818152600160209081526040808320600160a060020a038716845290915281205490916105d491859061063a908663ffffffff610b1316565b60006105d4338484610a46565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b600160a060020a03821615156109cf57600080fd5b600160a060020a03831615156109e457600080fd5b600160a060020a03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600160a060020a0382161515610a5b57600080fd5b600160a060020a038316600090815260208190526040902054610a84908263ffffffff610b1316565b600160a060020a038085166000908152602081905260408082209390935590841681522054610ab9908263ffffffff610b2816565b600160a060020a038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600082821115610b2257600080fd5b50900390565b81810182811015610b3857600080fd5b92915050565b600160a060020a0382161515610b5357600080fd5b600254610b66908263ffffffff610b1316565b600255600160a060020a038216600090815260208190526040902054610b92908263ffffffff610b1316565b600160a060020a038316600081815260208181526040808320949094558351858152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a350505600a165627a7a7230582030edf24eb27134d7c77898452315198f9886970c7fed0049b49cd05f121562db0029608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5060405162000ea038038062000ea083398101604090815281516020808401519284015160048054600160a060020a031916600160a060020a038516179055928401805192949093019161008491600591908501906100a1565b5080516100989060069060208401906100a1565b5050505061013c565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100e257805160ff191683800117855561010f565b8280016001018555821561010f579182015b8281111561010f5782518255916020019190600101906100f4565b5061011b92915061011f565b5090565b61013991905b8082111561011b5760008155600101610125565b90565b610d54806200014c6000396000f3006080604052600436106100cf5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100d4578063081812fc14610178578063095ea7b3146101c6578063116191b61461020657806323b872dd1461023557806340c10f191461027957806342966c68146102b757806349e11893146102e95780636352211e1461036157806370a082311461039357806395d89b41146103e0578063a22cb4651461040f578063a9059cbb1461044f578063e985e9c51461048d575b600080fd5b3480156100e057600080fd5b50d380156100ed57600080fd5b50d280156100fa57600080fd5b506101036104e2565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013d578181015183820152602001610125565b50505050905090810190601f16801561016a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561018457600080fd5b50d3801561019157600080fd5b50d2801561019e57600080fd5b506101aa600435610570565b60408051600160a060020a039092168252519081900360200190f35b3480156101d257600080fd5b50d380156101df57600080fd5b50d280156101ec57600080fd5b50610204600160a060020a03600435166024356105a2565b005b34801561021257600080fd5b50d3801561021f57600080fd5b50d2801561022c57600080fd5b506101aa610658565b34801561024157600080fd5b50d3801561024e57600080fd5b50d2801561025b57600080fd5b50610204600160a060020a0360043581169060243516604435610667565b34801561028557600080fd5b50d3801561029257600080fd5b50d2801561029f57600080fd5b50610204600160a060020a036004351660243561068c565b3480156102c357600080fd5b50d380156102d057600080fd5b50d280156102dd57600080fd5b50610204600435610763565b3480156102f557600080fd5b50d3801561030257600080fd5b50d2801561030f57600080fd5b5060408051602060046024803582810135601f81018590048502860185019096528585526102049583359536956044949193909101919081908401838280828437509497506107709650505050505050565b34801561036d57600080fd5b50d3801561037a57600080fd5b50d2801561038757600080fd5b506101aa6004356108e0565b34801561039f57600080fd5b50d380156103ac57600080fd5b50d280156103b957600080fd5b506103ce600160a060020a036004351661090a565b60408051918252519081900360200190f35b3480156103ec57600080fd5b50d380156103f957600080fd5b50d2801561040657600080fd5b5061010361093d565b34801561041b57600080fd5b50d3801561042857600080fd5b50d2801561043557600080fd5b50610204600160a060020a03600435166024351515610998565b34801561045b57600080fd5b50d3801561046857600080fd5b50d2801561047557600080fd5b50610204600160a060020a0360043516602435610a1c565b34801561049957600080fd5b50d380156104a657600080fd5b50d280156104b357600080fd5b506104ce600160a060020a0360043581169060243516610a2b565b604080519115158252519081900360200190f35b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105685780601f1061053d57610100808354040283529160200191610568565b820191906000526020600020905b81548152906001019060200180831161054b57829003601f168201915b505050505081565b600061057b82610a59565b151561058657600080fd5b50600090815260016020526040902054600160a060020a031690565b60006105ad826108e0565b9050600160a060020a0383811690821614156105c857600080fd5b33600160a060020a03821614806105e457506105e48133610a2b565b15156105ef57600080fd5b600082815260016020526040808220805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600454600160a060020a031681565b6106713382610a76565b151561067c57600080fd5b610687838383610ad5565b505050565b600454600160a060020a031633146106a357600080fd5b600160a060020a03821615156106b857600080fd5b6106c181610a59565b156106cb57600080fd5b600081815260208181526040808320805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03871690811790915583526002909152902054610718906001610bf0565b600160a060020a0383166000818152600260205260408082209390935591518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b61076d3382610c00565b50565b60045460009061078990600160a060020a031684610a1c565b600480546040517fcb912b1e0000000000000000000000000000000000000000000000000000000081523392810183815260248201879052606060448301908152865160648401528651600160a060020a039094169463cb912b1e949093899389939092909160840190602085019080838360005b838110156108165781810151838201526020016107fe565b50505050905090810190601f1680156108435780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b15801561086457600080fd5b505af1158015610878573d6000803e3d6000fd5b505050506040513d602081101561088e57600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167fcb912b1e000000000000000000000000000000000000000000000000000000001461068757600080fd5b600081815260208190526040812054600160a060020a031680151561090457600080fd5b92915050565b6000600160a060020a038216151561092157600080fd5b50600160a060020a031660009081526002602052604090205490565b6006805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105685780601f1061053d57610100808354040283529160200191610568565b600160a060020a0382163314156109ae57600080fd5b336000818152600360209081526040808320600160a060020a03871680855290835292819020805460ff1916861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b610a27338383610ad5565b5050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205460ff1690565b600090815260208190526040902054600160a060020a0316151590565b600080610a82836108e0565b905080600160a060020a031684600160a060020a03161480610abd575083600160a060020a0316610ab284610570565b600160a060020a0316145b80610acd5750610acd8185610a2b565b949350505050565b82600160a060020a0316610ae8826108e0565b600160a060020a031614610afb57600080fd5b600160a060020a0382161515610b1057600080fd5b610b1981610ccb565b600160a060020a038316600090815260026020526040902054610b4390600163ffffffff610d1316565b600160a060020a038085166000908152600260205260408082209390935590841681522054610b7990600163ffffffff610bf016565b600160a060020a03808416600081815260026020908152604080832095909555858252819052838120805473ffffffffffffffffffffffffffffffffffffffff1916831790559251849391928716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b8181018281101561090457600080fd5b81600160a060020a0316610c13826108e0565b600160a060020a031614610c2657600080fd5b610c2f81610ccb565b600160a060020a038216600090815260026020526040902054610c5990600163ffffffff610d1316565b600160a060020a038316600081815260026020908152604080832094909455848252819052828120805473ffffffffffffffffffffffffffffffffffffffff191690559151839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600081815260016020526040902054600160a060020a03161561076d576000908152600160205260409020805473ffffffffffffffffffffffffffffffffffffffff19169055565b600082821115610d2257600080fd5b509003905600a165627a7a72305820e95bf2b25cae43edb66a8c2c9a5784778a3163ec94f09ffb86ca32624f6a8b1b0029a165627a7a72305820642e8c16e0d0768025001430bcf8dea875428b07fc9214f0b1b37c74a5b34c660029" - code_shieldTrc20Token = "60806040526002805460ff1916600617905534801561001d57600080fd5b506040516109a53803806109a583398101604090815281516020808401518385015160025460ff16600a0a84026003819055336000908152600485529586205590850180519395909491019261007592850190610092565b508051610089906001906020840190610092565b5050505061012d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100d357805160ff1916838001178555610100565b82800160010185558215610100579182015b828111156101005782518255916020019190600101906100e5565b5061010c929150610110565b5090565b61012a91905b8082111561010c5760008155600101610116565b90565b6108698061013c6000396000f3006080604052600436106100b95763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100be578063095ea7b31461014857806318160ddd1461018057806323b872dd146101a7578063313ce567146101d157806342966c68146101fc57806370a082311461021457806379cc67901461023557806395d89b4114610259578063a9059cbb1461026e578063cae9ca5114610292578063dd62ed3e146102fb575b600080fd5b3480156100ca57600080fd5b506100d3610322565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561010d5781810151838201526020016100f5565b50505050905090810190601f16801561013a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015457600080fd5b5061016c600160a060020a03600435166024356103b0565b604080519115158252519081900360200190f35b34801561018c57600080fd5b506101956103dd565b60408051918252519081900360200190f35b3480156101b357600080fd5b5061016c600160a060020a03600435811690602435166044356103e3565b3480156101dd57600080fd5b506101e6610453565b6040805160ff9092168252519081900360200190f35b34801561020857600080fd5b5061016c60043561045c565b34801561022057600080fd5b50610195600160a060020a03600435166104d4565b34801561024157600080fd5b5061016c600160a060020a03600435166024356104e6565b34801561026557600080fd5b506100d36105b7565b34801561027a57600080fd5b5061016c600160a060020a0360043516602435610611565b34801561029e57600080fd5b50604080516020600460443581810135601f810184900484028501840190955284845261016c948235600160a060020a03169460248035953695946064949201919081908401838280828437509497506106259650505050505050565b34801561030757600080fd5b50610195600160a060020a036004358116906024351661073e565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103a85780601f1061037d576101008083540402835291602001916103a8565b820191906000526020600020905b81548152906001019060200180831161038b57829003601f168201915b505050505081565b336000908152600560209081526040808320600160a060020a039590951683529390529190912055600190565b60035481565b600160a060020a038316600090815260056020908152604080832033845290915281205482111561041357600080fd5b600160a060020a038416600090815260056020908152604080832033845290915290208054839003905561044884848461075b565b506001949350505050565b60025460ff1681565b3360009081526004602052604081205482111561047857600080fd5b3360008181526004602090815260409182902080548690039055600380548690039055815185815291517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59281900390910190a2506001919050565b60046020526000908152604090205481565b600160a060020a03821660009081526004602052604081205482111561050b57600080fd5b600160a060020a038316600090815260056020908152604080832033845290915290205482111561053b57600080fd5b600160a060020a0383166000818152600460209081526040808320805487900390556005825280832033845282529182902080548690039055600380548690039055815185815291517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59281900390910190a250600192915050565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103a85780601f1061037d576101008083540402835291602001916103a8565b600061061e33848461075b565b9392505050565b60008361063281856103b0565b15610736576040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081523360048201818152602483018790523060448401819052608060648501908152875160848601528751600160a060020a03871695638f4ffcb195948b94938b939192909160a490910190602085019080838360005b838110156106ca5781810151838201526020016106b2565b50505050905090810190601f1680156106f75780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561071957600080fd5b505af115801561072d573d6000803e3d6000fd5b50505050600191505b509392505050565b600560209081526000928352604080842090915290825290205481565b600080600160a060020a038416151561077357600080fd5b600160a060020a03851660009081526004602052604090205483111561079857600080fd5b600160a060020a03841660009081526004602052604090205483810110156107bf57600080fd5b50600160a060020a0380841660008181526004602090815260408083208054958a1680855282852080548a81039091559486905281548901909155815188815291519390950194927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019493505050505600a165627a7a723058208600353fffbf658cb8b57929fba657c57e83d756e4101cf874b153cc6eb4bb1c0029" - code_shield = "6104806040527f010000000000000000000000000000000000000000000000000000000000000060809081527f817de36ab2d57feb077634bca77819c8e0bd298c04f6fed0e6a83cc1356ca15560a0527fffe9fc03f18b176c998806439ff0bb8ad193afdb27b2ccbc88856916dd804e3460c0527fd8283386ef2ef07ebdbb4383c12a739a953a4d6e0d6fb1139a4036d693bfbb6c60e0527fe110de65c907b9dea4ae0bd83a4b0a51bea175646a64c12b4c9f931b2cb31b49610100527f912d82b2c2bca231f71efcf61737fbf0a08befa0416215aeef53e8bb6d23390a610120527f8ac9cf9c391e3fd42891d27238a81a8a5c1d3a72b1bcbea8cf44a58ce7389613610140527fd6c639ac24b46bd19341c91b13fdcab31581ddaf7f1411336a271f3d0aa52813610160527f7b99abdc3730991cc9274727d7d82d28cb794edbc7034b4f0053ff7c4b680444610180527f43ff5457f13b926b61df552d4e402ee6dc1463f99a535f9a713439264d5b616b6101a0527fba49b659fbd0b7334211ea6a9d9df185c757e70aa81da562fb912b84f49bce726101c0527f4777c8776a3b1e69b73a62fa701fa4f7a6282d9aee2c7a6b82e7937d7081c23c6101e0527fec677114c27206f5debc1c1ed66f95e2b1885da5b7be3d736b1de98579473048610200527f1b77dac4d24fb7258c3c528704c59430b630718bec486421837021cf75dab651610220527fbd74b25aacb92378a871bf27d225cfc26baca344a1ea35fdd94510f3d157082c610240527fd6acdedf95f608e09fa53fb43dcd0990475726c5131210c9e5caeab97f0e642f610260527f1ea6675f9551eeb9dfaaa9247bc9858270d3d3a4c5afa7177a984d5ed1be2451610280527f6edb16d01907b759977d7650dad7e3ec049af1a3d875380b697c862c9ec5d51c6102a0527fcd1c8dbf6e3acc7a80439bc4962cf25b9dce7c896f3a5bd70803fc5a0e33cf006102c0527f6aca8448d8263e547d5ff2950e2ed3839e998d31cbc6ac9fd57bc6002b1592166102e0527f8d5fa43e5a10d11605ac7430ba1f5d81fb1b68d29a640405767749e841527673610300527f08eeab0c13abd6069e6310197bf80f9c1ea6de78fd19cbae24d4a520e6cf3023610320527f0769557bc682b1bf308646fd0b22e648e8b9e98f57e29f5af40f6edb833e2c49610340527f4c6937d78f42685f84b43ad3b7b00f81285662f85c6a68ef11d62ad1a3ee0850610360527ffee0e52802cb0c46b1eb4d376c62697f4759f6c8917fa352571202fd778fd712610380527f16d6252968971a83da8521d65382e61f0176646d771c91528e3276ee45383e4a6103a0527fd2e1642c9a462229289e5b0e3b7f9008e0301cbb93385ee0e21da2545073cb586103c0527fa5122c08ff9c161d9ca6fc462073396c7d7d38e8ee48cdb3bea7e2230134ed6a6103e0527f28e7b841dcbc47cceb69d7cb8d94245fb7cb2ba3a7a6bc18f13f945f7dbd6e2a610400527fe1f34b034d4a3cd28557e2907ebf990c918f64ecb50a94f01d6fda5ca5c7ef72610420527f12935f14b676509b81eb49ef25f39269ed72309238b4c145803544b646dca62d610440527fb2eed031d4d6a4f02a097f80b54cc1541d4163c6b6f5971f88b6e41d35c5381461046052620004b390602890602062000580565b50348015620004c157600080fd5b50d38015620004cf57600080fd5b50d28015620004dd57600080fd5b506040516200354738038062003547833981016040819052620005009162000615565b604d811062000546576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200053d90620006b5565b60405180910390fd5b600a0a60005560488054336001600160a01b031991821617909155604980549091166001600160a01b039290921691909117905562000713565b8260208101928215620005b1579160200282015b82811115620005b157825182559160200191906001019062000594565b50620005bf929150620005c3565b5090565b620005e091905b80821115620005bf5760008155600101620005ca565b90565b8051620005f081620006ee565b620005fb81620006d0565b9392505050565b80516200060f8162000708565b92915050565b600080604083850312156200062957600080fd5b6000620006378585620005e3565b92505060206200064a8582860162000602565b9150509250929050565b600062000663602a83620006c7565b7f546865207363616c696e67466163746f724578706f6e656e74206973206f757481527f206f662072616e67652100000000000000000000000000000000000000000000602082015260400192915050565b602080825281016200060f8162000654565b90815260200190565b60006001600160a01b0382166200060f565b6001600160a81b031690565b620006f981620006e2565b81146200070557600080fd5b50565b620006f981620005e0565b612e2480620007236000396000f3fe608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50600436106100c35760003560e01c80639110a55b1161008b5780639110a55b14610134578063ae6dead714610147578063cc1058751461015a578063d7b0fef11461016d578063e176507314610175578063ed3437f814610196576100c3565b80632997e86b146100c85780632a6bb45a146100f157806330e69fc314610104578063313529361461010c578063855d175e1461011f575b600080fd5b6100db6100d6366004611c30565b61019e565b6040516100e89190612a7d565b60405180910390f35b6100db6100ff366004611c30565b6101b0565b6100db6101c2565b6100db61011a366004611c30565b6101c8565b61013261012d366004611c6c565b6101da565b005b610132610142366004611a3d565b6105a9565b6100db610155366004611c30565b610bd4565b610132610168366004611b22565b610be6565b6100db61106c565b610188610183366004611c30565b611072565b6040516100e8929190612a8b565b6100db6111c5565b60036020526000908152604090205481565b60066020526000908152604090205481565b60015481565b60056020526000908152604090205481565b6049546040516323b872dd60e01b815233916000916001600160a01b03909116906323b872dd9061021390859030908b90600401612852565b602060405180830381600087803b15801561022d57600080fd5b505af1158015610241573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506102659190810190611c12565b90508061028d5760405162461bcd60e51b815260040161028490612ad8565b60405180910390fd5b8435600090815260066020526040902054156102bb5760405162461bcd60e51b815260040161028490612b58565b60006102c6876111cb565b905060006002308389886040516020016102e394939291906127fc565b60408051601f19818403018152908290526102fd91612846565b602060405180830381855afa15801561031a573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525061033d9190810190611c4e565b90506060630100000188888585600760015460405161036196959493929190612a1d565b600060405180830381855afa15801561037e573d6000803e3d6000fd5b5050503d80600081146103ad576040519150601f19603f3d011682016040523d82523d6000602084013e6103b2565b606091505b5090506000816000815181106103c457fe5b602002602001015160001c9050806001146103f15760405162461bcd60e51b815260040161028490612b68565b60008260018151811061040057fe5b60209081029190910181015160015463ffffffff016000818152600590935260409092208c359055915081610435578a356007555b60015b826001018110156104aa576002600019830104915084816001018151811061045c57fe5b60200260200101516005600084815260200190815260200160002081905550828114156104a2576000828152600560205260409020546007846021811061049f57fe5b01555b600101610438565b508382600201815181106104ba57fe5b60209081029190910181015160028190556000818152600490925260408220558b906020020135600660008d81602090810291909101358252810191909152604001600090812091909155600180548082019091557fbe22cbc129fd01d04b02a7b3258b72e8c8ae5bfcf054d7f0359779be627a6b27918d9060200201358d600160200201358e600260200201358d60405161055a959493929190612bb8565b60405180910390a17f36bf5aa3964be01dbd95a0154a8930793fe68353bdc580871ffb2c911366bbc7888d60405161059392919061287a565b60405180910390a1505050505050505050505050565b600188108015906105bb575060028811155b6105d75760405162461bcd60e51b815260040161028490612b98565b8786146105f65760405162461bcd60e51b815260040161028490612b08565b60018410801590610608575060028411155b6106245760405162461bcd60e51b815260040161028490612b18565b8381146106435760405162461bcd60e51b815260040161028490612b38565b60005b8881101561070757600360008b8b8481811061065e57fe5b905061014002016000600a811061067157fe5b60200201358152602001908152602001600020546000801b146106a65760405162461bcd60e51b815260040161028490612ba8565b600460008b8b848181106106b657fe5b905061014002016001600a81106106c957fe5b60200201358152602001908152602001600020546000801b14156106ff5760405162461bcd60e51b815260040161028490612af8565b600101610646565b5060005b84811015610773576006600087878481811061072357fe5b9050610120020160006009811061073657fe5b60200201358152602001908152602001600020546000801b1461076b5760405162461bcd60e51b815260040161028490612ae8565b60010161070b565b5060006002308b8b898988886040516020016107959796959493929190612751565b60408051601f19818403018152908290526107af91612846565b602060405180830381855afa1580156107cc573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506107ef9190810190611c4e565b9050606063010000028b8b8b8b8b8b8b896000600760015460405161081e9b9a999897969594939291906128bd565b600060405180830381855afa15801561083b573d6000803e3d6000fd5b5050503d806000811461086a576040519150601f19603f3d011682016040523d82523d6000602084013e61086f565b606091505b50905060008160008151811061088157fe5b602002602001015160001c9050806001146108ae5760405162461bcd60e51b815260040161028490612b68565b600160005b888110156109d95760008483806001019450815181106108cf57fe5b602090810291909101015160015490915063ffffffff018b8b848181106108f257fe5b9050610120020160006009811061090557fe5b60008381526005602090815260409091209102919091013590558161094c578b8b8481811061093057fe5b9050610120020160006009811061094357fe5b60200201356007555b60015b826001018110156109c4576002600019830104915086858060010196508151811061097657fe5b60200260200101516005600084815260200190815260200160002081905550828114156109bc57600082815260056020526040902054600784602181106109b957fe5b01555b60010161094f565b505060018054810181559190910190506108b3565b508281815181106109e657fe5b60209081029190910181015160028190556000818152600490925260408220555b8c811015610a8f5760008e8e83818110610a1d57fe5b905061014002016000600a8110610a3057fe5b602002013590508060036000838152602001908152602001600020819055507fd13faa8100906cf559aebacf9c16532cfc9708645c198c8f15798ee049dbcfc181604051610a7e9190612a7d565b60405180910390a150600101610a07565b5060005b88811015610bc457898982818110610aa757fe5b90506101200201600060098110610aba57fe5b6020020135600660008c8c85818110610acf57fe5b90506101200201600060098110610ae257fe5b60200201358152602001908152602001600020819055507f0f190e6ff1f0e1c1f4ec51aecdafdd02278c568898b57df5ca7dccba83a8181c818b8b905003600154038b8b84818110610b3057fe5b90506101200201600060098110610b4357fe5b60200201358c8c85818110610b5457fe5b90506101200201600160098110610b6757fe5b60200201358d8d86818110610b7857fe5b90506101200201600260098110610b8b57fe5b60200201358b8b87818110610b9c57fe5b90506102a00201604051610bb4959493929190612bb8565b60405180910390a1600101610a93565b5050505050505050505050505050565b60046020526000908152604090205481565b6000610bf1896111cb565b905060006002308d888888888e89604051602001610c16989796959493929190612795565b60408051601f1981840301815290829052610c3091612846565b602060405180830381855afa158015610c4d573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250610c709190810190611c4e565b8c356000818152600360209081526040909120549293509091908e01359015610cab5760405162461bcd60e51b815260040161028490612ba8565b600081815260046020526040902054610cd65760405162461bcd60e51b815260040161028490612af8565b6001871115610cf75760405162461bcd60e51b815260040161028490612b28565b868514610d165760405162461bcd60e51b815260040161028490612b88565b86610d9d57600063010000038f8f878f88604051610d389594939291906129cc565b602060405180830381855afa158015610d55573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250610d789190810190611c12565b905080610d975760405162461bcd60e51b815260040161028490612b68565b50610f21565b610f218e600a806020026040519081016040528092919082600a60200280828437600081840152601f19601f8201169050808301925050505050508e6002806020026040519081016040528092919082600260200280828437600081840152601f19601f820116905080830192505050505050868e6002806020026040519081016040528092919082600260200280828437600081840152601f19601f820116905080830192505050505050878d8d808060200260200160405190810160405280939291908181526020016000905b82821015610eae576040805161012081810190925290808402870190600990839083908082843760009201919091525050508152600190910190602001610e6c565b50505050508c8c808060200260200160405190810160405280939291908181526020016000905b82821015610f1757604080516102a081810190925290808402870190601590839083908082843760009201919091525050508152600190910190602001610ed5565b505050505061124e565b60008281526003602052604090819020839055517fd13faa8100906cf559aebacf9c16532cfc9708645c198c8f15798ee049dbcfc190610f62908490612a7d565b60405180910390a16000604960009054906101000a90046001600160a01b03166001600160a01b031663a9059cbb8c8f6040518363ffffffff1660e01b8152600401610faf92919061287a565b602060405180830381600087803b158015610fc957600080fd5b505af1158015610fdd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506110019190810190611c12565b9050806110205760405162461bcd60e51b815260040161028490612b48565b7f1daf70c304f467a9efbc9ac1ca7bfe859a478aa6c4b88131b4dbb1547029b9728b8e8c60405161105393929190612895565b60405180910390a1505050505050505050505050505050565b60025481565b600061107c611842565b600154831061109d5760405162461bcd60e51b815260040161028490612b78565b63ffffffff83016110ac611842565b60006110b7866115ab565b905060006110c587836115fa565b905060005b60208163ffffffff1610156111b4578263ffffffff168163ffffffff16141561110d57818482601f0363ffffffff166020811061110357fe5b60200201526111a2565b600285066111415760056000600187038152602001908152602001600020548482601f0363ffffffff166020811061110357fe5b60018501600090815260056020526040902054156111715760018501600090815260056020526040902054611187565b60288163ffffffff166020811061118457fe5b01545b8482601f0363ffffffff166020811061119c57fe5b60200201525b600260001986010494506001016110ca565b505060025494509092505050915091565b60005481565b60008082116111ec5760405162461bcd60e51b815260040161028490612ac8565b60005461120090839063ffffffff61174c16565b1561121d5760405162461bcd60e51b815260040161028490612ab8565b6000805461123290849063ffffffff61179516565b9050677fffffffffffffff811061124857600080fd5b92915050565b60008260008151811061125d57fe5b602002602001015160006009811061127157fe5b6020020151905060066000828152602001908152602001600020546000801b146112ad5760405162461bcd60e51b815260040161028490612ae8565b604080516001808252818301909252606091816020015b6112cc611861565b8152602001906001900390816112c457905050905088816000815181106112ef57fe5b6020908102919091010152604080516001808252818301909252606091816020015b611319611880565b815260200190600190039081611311579050509050888160008151811061133c57fe5b6020026020010181905250606063010000028383888b8b8e600760015460405161136d98979695949392919061294e565b600060405180830381855afa15801561138a573d6000803e3d6000fd5b5050503d80600081146113b9576040519150601f19603f3d011682016040523d82523d6000602084013e6113be565b606091505b5090506000816000815181106113d057fe5b602002602001015160001c9050806001146113fd5760405162461bcd60e51b815260040161028490612b68565b60008260018151811061140c57fe5b60209081029190910181015160015463ffffffff016000818152600590935260409092208890559150816114405760078790555b60015b826001018110156114b5576002600019830104915084816001018151811061146757fe5b60200260200101516005600084815260200190815260200160002081905550828114156114ad57600082815260056020526040902054600784602181106114aa57fe5b01555b600101611443565b508382600201815181106114c557fe5b602090810291909101810151600281905560008181526004835260408082209290925589815260069092528120889055600180548082019091558a517f3814d251636df4a739162facca3862684b45af01ce54bcc56ea488fa6a69412d928a918d919061152e57fe5b602002602001015160016009811061154257fe5b60200201518c60008151811061155457fe5b602002602001015160026009811061156857fe5b60200201518c60008151811061157a57fe5b6020026020010151604051611593959493929190612bfb565b60405180910390a15050505050505050505050505050565b60015460009063ffffffff83019063fffffffe01825b60026000198301046002600019850104146115f25760026000198401049250600260001983010491506001016115c1565b949350505050565b60015463fffffffe0160008181526005602052604081205490918291829163ffffffff8088019290871661167b578183101561163c5794506112489350505050565b8183141561167b576002830661166b575050600019016000908152600560205260409020549250611248915050565b5050602854935061124892505050565b60005b8763ffffffff168163ffffffff16101561174057600283066116ba576000198301600090815260056020526040902054955090935083906116d5565b81955060288163ffffffff16602081106116d057fe5b015494505b63010000048187876040516116ec93929190612c3e565b602060405180830381855afa158015611709573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525061172c9190810190611c4e565b91506002600019840104925060010161167e565b50979650505050505050565b600061178e83836040518060400160405280601881526020017f536166654d6174683a206d6f64756c6f206279207a65726f00000000000000008152506117d7565b9392505050565b600061178e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061180b565b600081836117f85760405162461bcd60e51b81526004016102849190612aa7565b5082848161180257fe5b06949350505050565b6000818361182c5760405162461bcd60e51b81526004016102849190612aa7565b50600083858161183857fe5b0495945050505050565b6040518061040001604052806020906020820280388339509192915050565b604051806101400160405280600a906020820280388339509192915050565b60405180604001604052806002906020820280388339509192915050565b80356118a981612d93565b61178e81612cbd565b60008083601f8401126118c457600080fd5b50813567ffffffffffffffff8111156118dc57600080fd5b602083019150836101408202830111156118f557600080fd5b9250929050565b60008083601f84011261190e57600080fd5b50813567ffffffffffffffff81111561192657600080fd5b602083019150836102a08202830111156118f557600080fd5b60008083601f84011261195157600080fd5b50813567ffffffffffffffff81111561196957600080fd5b6020830191508360408202830111156118f557600080fd5b60008083601f84011261199357600080fd5b50813567ffffffffffffffff8111156119ab57600080fd5b602083019150836101208202830111156118f557600080fd5b80610140810183101561124857600080fd5b806102a0810183101561124857600080fd5b806040810183101561124857600080fd5b806060810183101561124857600080fd5b80610120810183101561124857600080fd5b805161124881612daa565b803561124881612db3565b805161124881612db3565b600080600080600080600080600060c08a8c031215611a5b57600080fd5b893567ffffffffffffffff811115611a7257600080fd5b611a7e8c828d016118b2565b995099505060208a013567ffffffffffffffff811115611a9d57600080fd5b611aa98c828d0161193f565b975097505060408a013567ffffffffffffffff811115611ac857600080fd5b611ad48c828d01611981565b95509550506060611ae78c828d016119e8565b93505060a08a013567ffffffffffffffff811115611b0457600080fd5b611b108c828d016118fc565b92509250509295985092959850929598565b6000806000806000806000806000806102a08b8d031215611b4257600080fd5b6000611b4e8d8d6119c4565b9a5050610140611b608d828e016119e8565b995050610180611b728d828e01611a27565b9850506101a0611b848d828e016119e8565b9750506101e0611b968d828e0161189e565b965050610200611ba88d828e016119f9565b9550506102608b013567ffffffffffffffff811115611bc657600080fd5b611bd28d828e01611981565b94509450506102808b013567ffffffffffffffff811115611bf257600080fd5b611bfe8d828e016118fc565b92509250509295989b9194979a5092959850565b600060208284031215611c2457600080fd5b60006115f28484611a1c565b600060208284031215611c4257600080fd5b60006115f28484611a27565b600060208284031215611c6057600080fd5b60006115f28484611a32565b6000806000806104208587031215611c8357600080fd5b6000611c8f8787611a27565b9450506020611ca087828801611a0a565b935050610140611cb2878288016119e8565b925050610180611cc4878288016119d6565b91505092959194509250565b6000611cdc838361203e565b50506101400190565b6000611cdc838361204f565b6000611cfd83836120a3565b50506102a00190565b6000611d1283836120fc565b505060400190565b6000611d128383612154565b6000611d32838361224b565b50506101200190565b6000611d328383612258565b6000611d5383836122a4565b505060200190565b611d6481612cbd565b82525050565b611d64611d7682612cbd565b612d55565b6000611d878385612cab565b9350611d9282612c59565b8060005b85811015611dc857611da88284612cb9565b611db28882611cd0565b9750611dbd83612c8a565b925050600101611d96565b509495945050505050565b6000611ddf8385612cb4565b9350611dea82612c59565b8060005b85811015611dc857611e008284612cb9565b611e0a8882611cd0565b9750611e1583612c8a565b925050600101611dee565b6000611e2b82612c62565b611e358185612cab565b9350611e4083612c5c565b8060005b83811015611dc8578151611e588882611ce5565b9750611e6383612c5c565b925050600101611e44565b6000611e7a8385612cb4565b9350611e8582612c59565b8060005b85811015611dc857611e9b8284612cb9565b611ea58882611cf1565b9750611eb083612c91565b925050600101611e89565b6000611ec78385612cab565b9350611ed282612c59565b8060005b85811015611dc857611ee88284612cb9565b611ef28882611d06565b9750611efd83612c98565b925050600101611ed6565b6000611f1382612c62565b611f1d8185612cab565b9350611f2883612c5c565b8060005b83811015611dc8578151611f408882611d1a565b9750611f4b83612c5c565b925050600101611f2c565b6000611f628385612cab565b9350611f6d82612c59565b8060005b85811015611dc857611f838284612cb9565b611f8d8882611d26565b9750611f9883612c9e565b925050600101611f71565b6000611faf8385612cb4565b9350611fba82612c59565b8060005b85811015611dc857611fd08284612cb9565b611fda8882611d26565b9750611fe583612c9e565b925050600101611fbe565b6000611ffb82612c62565b6120058185612cab565b935061201083612c5c565b8060005b83811015611dc85781516120288882611d3b565b975061203383612c5c565b925050600101612014565b61204b6101408383612d06565b5050565b61205881612c66565b6120628184612cb4565b925061206d82612c59565b8060005b8381101561209b5781516120858782611d47565b965061209083612c5c565b925050600101612071565b505050505050565b61204b6102a08383612d06565b6120b981612c6c565b6120c38184612cb4565b92506120ce82612c59565b8060005b8381101561209b5781516120e68782611d47565b96506120f183612c5c565b9250506001016120d2565b61204b60408383612d06565b61211181612c72565b61211b8184612cb4565b925061212682612c59565b8060005b8381101561209b57815161213e8782611d47565b965061214983612c5c565b92505060010161212a565b61215d81612c72565b6121678184612cb4565b925061217282612c59565b8060005b8381101561209b57815161218a8782611d47565b965061219583612c5c565b925050600101612176565b6121a981612c78565b6121b38184612cb4565b92506121be82612c59565b8060005b8381101561209b5781516121d68782611d47565b96506121e183612c5c565b9250506001016121c2565b6121f581612c7e565b6121ff8184612cb4565b925061220a82612c59565b8060005b8381101561209b5761221f82612d71565b6122298782611d47565b965061223483612ca5565b92505060010161220e565b61204b60608383612d06565b61204b6101208383612d06565b61226181612c84565b61226b8184612cb4565b925061227682612c59565b8060005b8381101561209b57815161228e8782611d47565b965061229983612c5c565b92505060010161227a565b611d6481612c59565b60006122b882612c62565b6122c28185612cb4565b93506122d2818560208601612d12565b9290920192915050565b611d6481612cfb565b60006122f082612c62565b6122fa8185612cab565b935061230a818560208601612d12565b61231381612d7d565b9093019392505050565b600061232a603183612cab565b7f56616c7565206d75737420626520696e7465676572206d756c7469706c6573208152706f66207363616c696e67466163746f722160781b602082015260400192915050565b600061237d601783612cab565b7f56616c7565206d75737420626520706f73697469766521000000000000000000815260200192915050565b60006123b6601483612cab565b735472616e7366657246726f6d206661696c65642160601b815260200192915050565b60006123e6601983612cab565b7f4475706c6963617465206e6f7465436f6d6d69746d656e742100000000000000815260200192915050565b600061241f601683612cab565b7554686520616e63686f72206d7573742065786973742160501b815260200192915050565b6000612451603d83612cab565b7f496e707574206e756d626572206d75737420626520657175616c20746f20737081527f656e64417574686f726974795369676e6174757265206e756d62657221000000602082015260400192915050565b60006124b0601d83612cab565b7f4f7574707574206e756d626572206d7573742062652031206f72203221000000815260200192915050565b60006124e9601e83612cab565b7f4f7574707574206e756d6265722063616e6e6f74206578636565642031210000815260200192915050565b6000612522602883612cab565b7f4f7574707574206e756d626572206d75737420626520657175616c20746f2063815267206e756d6265722160c01b602082015260400192915050565b600061256c601083612cab565b6f5472616e73666572206661696c65642160801b815260200192915050565b6000612598601a83612cab565b7f4475706c6963617465206e6f7465436f6d6d69746d656e747321000000000000815260200192915050565b60006125d1603f83612cab565b7f5468652070726f6f6620616e64207369676e61747572652068617665206e6f7481527f206265656e2076657269666965642062792074686520636f6e74726163742100602082015260400192915050565b6000612630602a83612cab565b7f506f736974696f6e2073686f756c6420626520736d616c6c6572207468616e208152696c656166436f756e742160b01b602082015260400192915050565b600061267c602b83612cab565b7f4f7574707574206e756d626572206d75737420626520657175616c20746f206c81526a656e677468206f6620632160a81b602082015260400192915050565b60006126c9601c83612cab565b7f496e707574206e756d626572206d7573742062652031206f7220322100000000815260200192915050565b6000612702602083612cab565b7f546865206e6f74652068617320616c7265616479206265656e207370656e7421815260200192915050565b611d6481612ce5565b611d6481612cee565b611d6461274c82612cee565b612d66565b600061275d828a611d6a565b60148201915061276e82888a611dd3565b915061277b828688611fa3565b9150612788828486611e6e565b9998505050505050505050565b60006127a1828b611d6a565b6014820191506127b1828a61203e565b610140820191506127c382888a611fa3565b91506127d0828688611e6e565b91506127dc8285611d6a565b6014820191506127ec8284612740565b5060080198975050505050505050565b60006128088287611d6a565b6014820191506128188286612740565b600882019150612828828561224b565b6101208201915061283982846120a3565b506102a001949350505050565b600061178e82846122ad565b606081016128608286611d5b565b61286d6020830185611d5b565b6115f260408301846122a4565b604081016128888285611d5b565b61178e60208301846122a4565b60a081016128a38286611d5b565b6128b060208301856122a4565b6115f2604083018461223f565b61052080825281016128d0818d8f611d7b565b905081810360208301526128e5818b8d611ebb565b905081810360408301526128fa81898b611f56565b905061290960608301886120fc565b61291660a08301876122a4565b61292360c08301866122dc565b61293060e08301856121ec565b61293e6105008301846122a4565b9c9b505050505050505050505050565b6105208082528101612960818b611e20565b90508181036020830152612974818a611f08565b905081810360408301526129888189611ff0565b90506129976060830188612108565b6129a460a08301876122a4565b6129b160c0830186612737565b6129be60e08301856121ec565b6127886105008301846122a4565b61020081016129db828861203e565b6129e96101408301876120fc565b6129f7610180830186612737565b612a056101a08301856120fc565b612a136101e08301846122a4565b9695505050505050565b6105e08101612a2c828961224b565b612a3a6101208301886120fc565b612a48610160830187612737565b612a566101808301866122a4565b612a646101a08301856121ec565b612a726105c08301846122a4565b979650505050505050565b6020810161124882846122a4565b6104208101612a9a82856122a4565b61178e60208301846121a0565b6020808252810161178e81846122e5565b602080825281016112488161231d565b6020808252810161124881612370565b60208082528101611248816123a9565b60208082528101611248816123d9565b6020808252810161124881612412565b6020808252810161124881612444565b60208082528101611248816124a3565b60208082528101611248816124dc565b6020808252810161124881612515565b602080825281016112488161255f565b602080825281016112488161258b565b60208082528101611248816125c4565b6020808252810161124881612623565b602080825281016112488161266f565b60208082528101611248816126bc565b60208082528101611248816126f5565b6103208101612bc782886122a4565b612bd460208301876122a4565b612be160408301866122a4565b612bee60608301856122a4565b612a1360808301846120a3565b6103208101612c0a82886122a4565b612c1760208301876122a4565b612c2460408301866122a4565b612c3160608301856122a4565b612a1360808301846120b0565b60608101612c4c828661272e565b61286d60208301856122a4565b90565b60200190565b5190565b50600a90565b50601590565b50600290565b50602090565b50602190565b50600990565b6101400190565b6102a00190565b60400190565b6101200190565b60010190565b90815260200190565b919050565b5090565b600061124882612ccd565b151590565b6001600160a01b031690565b6001600160a81b031690565b63ffffffff1690565b67ffffffffffffffff1690565b600061124882612cee565b82818337506000910152565b60005b83811015612d2d578181015183820152602001612d15565b83811115612d3c576000848401525b50505050565b6000611248612d5083612c59565b612c59565b600061124882600061124882612d8d565b600061124882612d87565b60006112488254612d42565b601f01601f191690565b60c01b90565b60601b90565b612d9c81612cd9565b8114612da757600080fd5b50565b612d9c81612cc8565b612d9c81612c5956fea36474726f6e58207ef421e01e827fa1d2e384579b655503e18aef0f4bf9ff3e5176a254c97da9036c6578706572696d656e74616cf564736f6c637828302e352e31322d646576656c6f702e323032302e362e31352b636f6d6d69742e34323336323638380065" - code_getAddressChange = "608060405260e3806100126000396000f3fe6080604052348015600f57600080fd5b50d38015601b57600080fd5b50d28015602757600080fd5b5060043610604a5760003560e01c806358c6464814604f578063b4cef28d146071575b600080fd5b605560a6565b604080516001600160a01b039092168252519081900360200190f35b609460048036036020811015608557600080fd5b50356001600160a01b031660aa565b60408051918252519081900360200190f35b3090565b50479056fea26474726f6e58208f096542a0e814a7dd8434fd85def0ee9521b022f5cad9176f1c993e2615bdad64736f6c634300050f0031" - code_fallbackOldVersionTest = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506101d98061003a6000396000f3fe60c0604052600860808190526766616c6c6261636b60c01b60a0908152610029916000919061010a565b506040805181815260008054600260001961010060018416150201909116049282018390527f1f0af026fd1015e37743a803fa8c7b92c09a6fc99890b1681a1e3c888427c25e9290918291369190819060208201906060830190869080156100d25780601f106100a7576101008083540402835291602001916100d2565b820191906000526020600020905b8154815290600101906020018083116100b557829003601f168201915b50508381038252848152602001858580828437600083820152604051601f909101601f191690920182900397509095505050505050a1005b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061014b57805160ff1916838001178555610178565b82800160010185558215610178579182015b8281111561017857825182559160200191906001019061015d565b50610184929150610188565b5090565b6101a291905b80821115610184576000815560010161018e565b9056fea26474726f6e5820e77b862582c00095aa34fd5c2839c0d8f209bdac194c0adeec660fa15a08fbe464736f6c634300050f0031" - code_fallbackOldVersionCall = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506101748061003a6000396000f3fe60806040526004361061001e5760003560e01c8063f55332ab14610023575b600080fd5b6100496004803603602081101561003957600080fd5b50356001600160a01b031661005d565b604080519115158252519081900360200190f35b60408051600481526024810182526020810180516001600160e01b031663f85396d760e01b1781529151815160009384936001600160a01b038716939092909182918083835b602083106100c25780518252601f1990920191602091820191016100a3565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610124576040519150601f19603f3d011682016040523d82523d6000602084013e610129565b606091505b505090508061013757600080fd5b5060019291505056fea26474726f6e58203498e1c23a661ae640e44836405d25839850ec79748cabd2dab945fd13ee0c7c64736f6c634300050f0031" - code_arrayLength_0.5.15 = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506102708061003a6000396000f3fe608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50600436106100455760003560e01c8063cbcec91e1461004a575b600080fd5b6100526100a2565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561008e578181015183820152602001610076565b505050509050019250505060405180910390f35b60008054600181018255818052602081047f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56301805460ff601f9093166101000a928302191690911790556060906003906100fc90826101e5565b50600080549061010f90600183016101e5565b5060008054906101239060001983016101e5565b5060008054906101379060001983016101e5565b50600080548061014357fe5b60008281526020808220600019909301818104909301805460ff601f86166101000a0219169055919092558154604080518284028101840190915281815292918301828280156101da57602002820191906000526020600020906000905b825461010083900a900460f81b6001600160f81b0319168152602060019283018181049485019490930390920291018084116101a15790505b505050505090505b90565b81548183558181111561021957601f016020900481601f01602090048360005260206000209182019101610219919061021e565b505050565b6101e291905b808211156102385760008155600101610224565b509056fea26474726f6e582030f1b13e292e442f2c4de67e0d5bb6f78dd7f44f99e5f2fa3952de6c9d94dd8b64736f6c634300050e0031" - code_override001 = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5060d8806100396000396000f3fe6080604052348015600f57600080fd5b50d38015601b57600080fd5b50d28015602757600080fd5b506004361060545760003560e01c80630c55699c14605957806355241077146071578063a56dfe4a14608d575b600080fd5b605f6093565b60408051918252519081900360200190f35b608b60048036036020811015608557600080fd5b50356099565b005b605f609e565b60005481565b600155565b6001548156fea26474726f6e58204b9c06785956097a789fe5d4b75dbe9390a30c48c3080d3c14d8655cb84e11e564736f6c634300050f0031" - code_override002 = "6080604052600460005534801561001557600080fd5b50d3801561002257600080fd5b50d2801561002f57600080fd5b5061012b8061003f6000396000f3fe6080604052348015600f57600080fd5b50d38015601b57600080fd5b50d28015602757600080fd5b506004361060545760003560e01c80630c55699c1460595780635524107714607157806374d393f014608d575b600080fd5b605f60a7565b60408051918252519081900360200190f35b608b60048036036020811015608557600080fd5b503560ad565b005b608b6004803603602081101560a157600080fd5b503560f2565b60005481565b6006600054101560f2576040805162461bcd60e51b815260206004820152600b60248201526a3c1036bab9ba101f1e901b60a91b604482015290519081900360640190fd5b60005556fea26474726f6e5820d72f89553adaa33af6034260ea794957bdaebd8e26bccaac25c685c1bd1e8f2764736f6c634300050f0031" - code_override003 = "608060405260008054600160ff19918216811761ff0019169092556301efa6ad9091556301efa6ac19600255630166654f6003908155600480546001600160a01b03191673dcad3a6d3569df655070ded06cb7a1b2ccd1d3af1790557fb55a21aaee0ce8f1c8ffaa0dbd23105cb55a21aaee0ce8f1c8ffaa0dbd23105c6005556006805490921617905534801561009557600080fd5b50d380156100a257600080fd5b50d280156100af57600080fd5b506101c8806100bf6000396000f3fe608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50600436106100a25760003560e01c806398f42fe31161007557806398f42fe31461012d578063a223e05d14610135578063e5aa3d581461013d578063f8aab23814610145576100a2565b806375f12b21146100a757806383cdfab8146100c357806387cfa5bf146100dd578063938b5f3214610109575b600080fd5b6100af61014d565b604080519115158252519081900360200190f35b6100cb61015b565b60408051918252519081900360200190f35b6100e5610161565b604051808260038111156100f557fe5b60ff16815260200191505060405180910390f35b61011161016a565b604080516001600160a01b039092168252519081900360200190f35b6100e5610179565b6100cb610182565b6100cb610188565b6100cb61018e565b600054610100900460ff1681565b60025481565b60005460ff1681565b6004546001600160a01b031681565b60065460ff1681565b60035481565b60015481565b6005548156fea26474726f6e5820dacca6ecfb02875aede259b98aa35a6aba6aea8284a01f0c82fdeba6ffc8012d64736f6c634300050f0031" - code_virtual001 = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506103778061003a6000396000f3fe608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506004361061007c5760003560e01c80630c55699c146100815780631e26fd331461009b57806355241077146100bc5780637fcaf666146100d9578063a56dfe4a14610149578063c5d7802e14610165575b600080fd5b6100896101e2565b60408051918252519081900360200190f35b6100ba600480360360208110156100b157600080fd5b503515156101e8565b005b6100ba600480360360208110156100d257600080fd5b50356101fb565b6100ba600480360360208110156100ef57600080fd5b81019060208101813564010000000081111561010a57600080fd5b82018360208201111561011c57600080fd5b8035906020019184600183028401116401000000008311171561013e57600080fd5b509092509050610200565b610151610211565b604080519115158252519081900360200190f35b61016d61021a565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101a757818101518382015260200161018f565b50505050905090810190601f1680156101d45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60015481565b6002805460ff1916911515919091179055565b600155565b61020c600083836102a8565b505050565b60025460ff1681565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102a05780601f10610275576101008083540402835291602001916102a0565b820191906000526020600020905b81548152906001019060200180831161028357829003601f168201915b505050505081565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102e95782800160ff19823516178555610316565b82800160010185558215610316579182015b828111156103165782358255916020019190600101906102fb565b50610322929150610326565b5090565b61034091905b80821115610322576000815560010161032c565b9056fea26474726f6e5820b48ac0b0a646831f6a4069f95888081a6e12cd0ffb453b66d879c3f04e3b71ec64736f6c634300050f0031" - code_slotAndOffset_06x = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5060ba806100396000396000f3fe6080604052348015600f57600080fd5b50d38015601b57600080fd5b50d28015602757600080fd5b5060043610604a5760003560e01c8063b1cb267b14604f578063d46300fd14606e575b600080fd5b60556074565b6040805192835260208301919091528051918290030190f35b6055607c565b600460009091565b60016000909156fea264697066735822122076bb65351c887d12efbc6982560551c4979591981777ea571d32f7f267f8888864736f6c634300060c0033" -} - - -abi = { - abi_Scenario015_TRC20_TRON = "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"view\"},{\"constant\":false,\"inputs\":[],\"name\":\"stop\",\"outputs\":[],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"nonpayable\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"nonpayable\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"view\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"nonpayable\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"view\"},{\"constant\":false,\"inputs\":[{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"nonpayable\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"view\"},{\"constant\":true,\"inputs\":[],\"name\":\"stopped\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"view\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"view\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"nonpayable\"},{\"constant\":false,\"inputs\":[],\"name\":\"start\",\"outputs\":[],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"nonpayable\"},{\"constant\":false,\"inputs\":[{\"name\":\"_name\",\"type\":\"string\"}],\"name\":\"setName\",\"outputs\":[],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"nonpayable\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\",\"stateMutability\":\"view\"},{\"inputs\":[],\"payable\":false,\"type\":\"constructor\",\"stateMutability\":\"nonpayable\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"}]" - abi_AssertException_testdivideInt = "[{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"int256\"},{\"name\":\"y\",\"type\":\"int256\"}],\"name\":\"divideIHaveArgsReturn\",\"outputs\":[{\"name\":\"z\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_AssertException_testfindArgsContractMinTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"i\",\"type\":\"uint256\"}],\"name\":\"findArgsByIndexTest\",\"outputs\":[{\"name\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_AssertException_testbyteMinContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"i\",\"type\":\"uint256\"}],\"name\":\"testBytesGet\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes1\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_AssertException_testenum = "[{\"constant\":true,\"inputs\":[],\"name\":\"getChoice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"choice\",\"type\":\"uint8\"}],\"name\":\"setGoStraight\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_AssertException_testmoveRight = "[{\"constant\":false,\"inputs\":[{\"name\":\"i\",\"type\":\"int256\"}],\"name\":\"binaryMoveR\",\"outputs\":[{\"name\":\"z\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_AssertException_testuninitializedContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"test2\",\"outputs\":[{\"name\":\"\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"test1\",\"outputs\":[{\"name\":\"\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_AssertException_testTestAssertContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"testAssert\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"testRequire\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"testThrow\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"testRevert\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - - abi_ContractGrammar001_testGrammar001 = "[{\"constant\":false,\"inputs\":[{\"name\":\"useB\",\"type\":\"bool\"},{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"select\",\"outputs\":[{\"name\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"b\",\"outputs\":[{\"name\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"a\",\"outputs\":[{\"name\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractGrammar001_testGrammar002 = "[{\"constant\":false,\"inputs\":[{\"name\":\"self\",\"type\":\"Set.Data storage\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"remove\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"self\",\"type\":\"Set.Data storage\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"contains\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"self\",\"type\":\"Set.Data storage\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"insert\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi1_ContractGrammar001_testGrammar002 = "[{\"constant\":false,\"inputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"register\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractGrammar001_testGrammar003 = "[{\"constant\":false,\"inputs\":[{\"name\":\"self\",\"type\":\"Set.Data storage\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"remove\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"self\",\"type\":\"Set.Data storage\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"contains\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"self\",\"type\":\"Set.Data storage\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"insert\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi1_ContractGrammar001_testGrammar003 = "[{\"constant\":false,\"inputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"register\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractGrammar001_testGrammar004 = "[{\"constant\":false,\"inputs\":[{\"name\":\"self\",\"type\":\"uint256[] storage\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"indexOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi1_ContractGrammar001_testGrammar004 = "[{\"constant\":false,\"inputs\":[{\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getData\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"append\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_old\",\"type\":\"uint256\"},{\"name\":\"_new\",\"type\":\"uint256\"}],\"name\":\"replace\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"data\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" - abi_ContractGrammar001_testGrammar006 = "[{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"d4\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"d\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"d5\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"f\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"d6\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"d1\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"d2\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - - abi_ContractGrammar002_testGrammar007 = "[{\"constant\":true,\"inputs\":[{\"name\":\"_name\",\"type\":\"string\"}],\"name\":\"getDougName\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_age\",\"type\":\"uint256\"}],\"name\":\"getDougAge\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"contracts\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]" - abi1_ContractGrammar002_testGrammar007 = "[{\"constant\":false,\"inputs\":[{\"name\":\"_name\",\"type\":\"bytes32\"}],\"name\":\"uintOfName\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_doug\",\"type\":\"address\"}],\"name\":\"setDOUG\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_age\",\"type\":\"uint256\"}],\"name\":\"dougOfage\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"dogInterfaceAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"name\",\"type\":\"bytes32\"}],\"name\":\"FetchContract\",\"type\":\"event\"}]" - abi_ContractGrammar002_testGrammar008 = "[{\"constant\":false,\"inputs\":[],\"name\":\"utterance\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getContractName\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractGrammar002_testGrammar010 = "[{\"constant\":false,\"inputs\":[{\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setFeed\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"callFeed\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractGrammar002_testGrammar011 = "[{\"constant\":false,\"inputs\":[{\"name\":\"key\",\"type\":\"uint256\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"f\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"g\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractGrammar002_testGrammar012 = "[{\"constant\":false,\"inputs\":[],\"name\":\"info\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"bytes4\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"}]" - abi_ContractGrammar002_testGrammar013 = "[{\"constant\":false,\"inputs\":[],\"name\":\"kill\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"increment\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]" - - abi_ContractGrammar003_testGrammar014 = "[{\"constant\":false,\"inputs\":[{\"name\":\"bAddress\",\"type\":\"address\"},{\"name\":\"_number\",\"type\":\"uint256\"}],\"name\":\"delegatecallTest\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"bAddress\",\"type\":\"address\"},{\"name\":\"_number\",\"type\":\"uint256\"}],\"name\":\"callTest\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"senderForB\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getsenderForB\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"bAddress\",\"type\":\"address\"},{\"name\":\"_number\",\"type\":\"uint256\"}],\"name\":\"callcodeTest\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"numberForB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"bAddress\",\"type\":\"address\"}],\"name\":\"callAddTest\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getnumberForB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi1_ContractGrammar003_testGrammar014 = "[{\"constant\":true,\"inputs\":[],\"name\":\"addr11\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"addr2\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"addr1\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"add\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_number\",\"type\":\"uint256\"}],\"name\":\"setValue\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"senderForB\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getsenderForB\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"numberForB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getnumberForB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractGrammar003_testGrammar015 = "[{\"constant\":true,\"inputs\":[],\"name\":\"ExistFuncCalledTopic\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"para\",\"type\":\"uint256\"}],\"name\":\"existFunc\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"FallbackCalledTopic\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"callNonExistFunc\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"callExistFunc\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"FallbackCalled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"name\":\"para\",\"type\":\"uint256\"}],\"name\":\"ExistFuncCalled\",\"type\":\"event\"}]" - abi_ContractGrammar003_testGrammar016 = "[{\"constant\":false,\"inputs\":[],\"name\":\"readData\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi1_ContractGrammar003_testGrammar016 = "[{\"constant\":false,\"inputs\":[],\"name\":\"getData\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"a\",\"type\":\"uint256\"}],\"name\":\"setData\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"g\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractGrammar003_testGrammar017 = "[{\"constant\":false,\"inputs\":[{\"name\":\"compaingnID\",\"type\":\"uint256\"}],\"name\":\"vote\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"comapingnId\",\"type\":\"uint256\"}],\"name\":\"check\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"beneficiary\",\"type\":\"address\"},{\"name\":\"goal\",\"type\":\"uint256\"}],\"name\":\"candidate\",\"outputs\":[{\"name\":\"compaingnID\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractGrammar003_testGrammar018 = "[{\"constant\":false,\"inputs\":[],\"name\":\"testKeccak256\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"testMulmod\",\"outputs\":[{\"name\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"testAddmod\",\"outputs\":[{\"name\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"testSha256\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"testRipemd160\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"testSha3\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractGrammar003_testGrammar019 = "[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]" - abi_ContractGrammar003_testGrammar020 = "[{\"constant\":false,\"inputs\":[],\"name\":\"timetest\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractScenario004_deployErc20TronToken = "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"stop\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"stopped\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"start\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_name\",\"type\":\"string\"}],\"name\":\"setName\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_addressFounder\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"}]" - abi_ContractScenario005_deployIcoContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"checkGoalReached\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"deadline\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"beneficiary\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"tokenReward\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"fundingGoal\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"amountRaised\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"price\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"safeWithdrawal\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"ifSuccessfulSendTo\",\"type\":\"address\"},{\"name\":\"fundingGoalInEthers\",\"type\":\"uint256\"},{\"name\":\"durationInMinutes\",\"type\":\"uint256\"},{\"name\":\"finneyCostOfEachToken\",\"type\":\"uint256\"},{\"name\":\"addressOfTokenUsedAsReward\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"totalAmountRaised\",\"type\":\"uint256\"}],\"name\":\"GoalReached\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"backer\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"isContribution\",\"type\":\"bool\"}],\"name\":\"FundTransfer\",\"type\":\"event\"}]" - abi_ContractScenario006_deployFomo3D = "[{\"constant\":true,\"inputs\":[{\"name\":\"_customerAddress\",\"type\":\"address\"}],\"name\":\"dividendsOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_ethereumToSpend\",\"type\":\"uint256\"}],\"name\":\"calculateTokensReceived\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokensToSell\",\"type\":\"uint256\"}],\"name\":\"calculateEthereumReceived\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"onlyAmbassadors\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"administrators\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"sellPrice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"stakingRequirement\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_includeReferralBonus\",\"type\":\"bool\"}],\"name\":\"myDividends\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalEthereumBalance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_customerAddress\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_amountOfTokens\",\"type\":\"uint256\"}],\"name\":\"setStakingRequirement\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"buyPrice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_identifier\",\"type\":\"bytes32\"},{\"name\":\"_status\",\"type\":\"bool\"}],\"name\":\"setAdministrator\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"Hourglass\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"myTokens\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"disableInitialStage\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_toAddress\",\"type\":\"address\"},{\"name\":\"_amountOfTokens\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_symbol\",\"type\":\"string\"}],\"name\":\"setSymbol\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_name\",\"type\":\"string\"}],\"name\":\"setName\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_amountOfTokens\",\"type\":\"uint256\"}],\"name\":\"sell\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"exit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_referredBy\",\"type\":\"address\"}],\"name\":\"buy\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"reinvest\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"customerAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"incomingEthereum\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"tokensMinted\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"referredBy\",\"type\":\"address\"}],\"name\":\"onTokenPurchase\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"customerAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokensBurned\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"ethereumEarned\",\"type\":\"uint256\"}],\"name\":\"onTokenSell\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"customerAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"ethereumReinvested\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"tokensMinted\",\"type\":\"uint256\"}],\"name\":\"onReinvestment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"customerAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"ethereumWithdrawn\",\"type\":\"uint256\"}],\"name\":\"onWithdraw\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokens\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]" - abi_ContractScenario007_deployErc721CardMigration = "[{\"constant\":true,\"inputs\":[{\"name\":\"_interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"id\",\"type\":\"uint16\"}],\"name\":\"getProto\",\"outputs\":[{\"name\":\"exists\",\"type\":\"bool\"},{\"name\":\"god\",\"type\":\"uint8\"},{\"name\":\"season\",\"type\":\"uint8\"},{\"name\":\"cardType\",\"type\":\"uint8\"},{\"name\":\"rarity\",\"type\":\"uint8\"},{\"name\":\"mana\",\"type\":\"uint8\"},{\"name\":\"attack\",\"type\":\"uint8\"},{\"name\":\"health\",\"type\":\"uint8\"},{\"name\":\"tribe\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"from\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"transferAllFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"governor\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"migrated\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"burnAll\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"InterfaceId_ERC165\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes4\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"season\",\"type\":\"uint8\"}],\"name\":\"makePermanantlyTradable\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"from\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"externalID\",\"type\":\"uint16\"},{\"name\":\"god\",\"type\":\"uint8\"},{\"name\":\"rarity\",\"type\":\"uint8\"},{\"name\":\"mana\",\"type\":\"uint8\"},{\"name\":\"packable\",\"type\":\"bool\"}],\"name\":\"addSpell\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"common\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getActiveCards\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"migrate\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"mythic\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"exists\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"tokenByIndex\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"index\",\"type\":\"uint16\"},{\"name\":\"god\",\"type\":\"uint8\"},{\"name\":\"cardType\",\"type\":\"uint8\"},{\"name\":\"mana\",\"type\":\"uint8\"},{\"name\":\"attack\",\"type\":\"uint8\"},{\"name\":\"health\",\"type\":\"uint8\"},{\"name\":\"tribe\",\"type\":\"uint8\"}],\"name\":\"replaceProto\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"burnCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"name\":\"seasonTradabilityLocked\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"id\",\"type\":\"uint16\"},{\"name\":\"limit\",\"type\":\"uint64\"}],\"name\":\"setLimit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"transferAll\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"name\":\"seasonTradable\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"proposed\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"owns\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"approved\",\"type\":\"address\"}],\"name\":\"addPack\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"purity\",\"type\":\"uint16\"}],\"name\":\"getShine\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"cards\",\"outputs\":[{\"name\":\"proto\",\"type\":\"uint16\"},{\"name\":\"purity\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"migrateAll\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"getCard\",\"outputs\":[{\"name\":\"proto\",\"type\":\"uint16\"},{\"name\":\"purity\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"id\",\"type\":\"uint16\"}],\"name\":\"getLimit\",\"outputs\":[{\"name\":\"limit\",\"type\":\"uint64\"},{\"name\":\"set\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"name\":\"limits\",\"outputs\":[{\"name\":\"limit\",\"type\":\"uint64\"},{\"name\":\"exists\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NAME\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"rare\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"proto\",\"type\":\"uint16\"}],\"name\":\"isTradable\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"proposed\",\"type\":\"address\"},{\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"ownsAll\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"tokenMetadataBaseURI\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"packs\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"nextSeason\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"currentSeason\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_gov\",\"type\":\"address\"}],\"name\":\"setGovernor\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"season\",\"type\":\"uint8\"}],\"name\":\"makeUntradable\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"rarity\",\"type\":\"uint8\"},{\"name\":\"random\",\"type\":\"uint16\"}],\"name\":\"getRandomCard\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"externalID\",\"type\":\"uint16\"},{\"name\":\"god\",\"type\":\"uint8\"},{\"name\":\"rarity\",\"type\":\"uint8\"},{\"name\":\"mana\",\"type\":\"uint8\"},{\"name\":\"attack\",\"type\":\"uint8\"},{\"name\":\"durability\",\"type\":\"uint8\"},{\"name\":\"packable\",\"type\":\"bool\"}],\"name\":\"addWeapon\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"externalID\",\"type\":\"uint16\"},{\"name\":\"god\",\"type\":\"uint8\"},{\"name\":\"rarity\",\"type\":\"uint8\"},{\"name\":\"mana\",\"type\":\"uint8\"},{\"name\":\"attack\",\"type\":\"uint8\"},{\"name\":\"health\",\"type\":\"uint8\"},{\"name\":\"cardType\",\"type\":\"uint8\"},{\"name\":\"tribe\",\"type\":\"uint8\"},{\"name\":\"packable\",\"type\":\"bool\"}],\"name\":\"addProto\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"protoCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"epic\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"externalID\",\"type\":\"uint16\"},{\"name\":\"god\",\"type\":\"uint8\"},{\"name\":\"rarity\",\"type\":\"uint8\"},{\"name\":\"mana\",\"type\":\"uint8\"},{\"name\":\"attack\",\"type\":\"uint8\"},{\"name\":\"health\",\"type\":\"uint8\"},{\"name\":\"tribe\",\"type\":\"uint8\"},{\"name\":\"packable\",\"type\":\"bool\"}],\"name\":\"addMinion\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"externalIDs\",\"type\":\"uint16[]\"},{\"name\":\"gods\",\"type\":\"uint8[]\"},{\"name\":\"rarities\",\"type\":\"uint8[]\"},{\"name\":\"manas\",\"type\":\"uint8[]\"},{\"name\":\"attacks\",\"type\":\"uint8[]\"},{\"name\":\"healths\",\"type\":\"uint8[]\"},{\"name\":\"cardTypes\",\"type\":\"uint8[]\"},{\"name\":\"tribes\",\"type\":\"uint8[]\"},{\"name\":\"packable\",\"type\":\"bool[]\"}],\"name\":\"addProtos\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getBurnCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"legendary\",\"outputs\":[{\"name\":\"\",\"type\":\"uint16\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"approveAll\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"season\",\"type\":\"uint8\"}],\"name\":\"makeTradable\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"SYMBOL\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"proto\",\"type\":\"uint16\"},{\"name\":\"purity\",\"type\":\"uint16\"}],\"name\":\"createCard\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"previous\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"proto\",\"type\":\"uint16\"},{\"indexed\":false,\"name\":\"purity\",\"type\":\"uint16\"},{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"CardCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_approved\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_operator\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"id\",\"type\":\"uint16\"},{\"indexed\":false,\"name\":\"season\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"god\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"rarity\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"mana\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"attack\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"health\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"cardType\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"tribe\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"packable\",\"type\":\"bool\"}],\"name\":\"NewProtoCard\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"Pause\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"Unpause\",\"type\":\"event\"}]" - abi_ContractScenario008_deployErc721CryptoKitties = "[{\"constant\":true,\"inputs\":[{\"name\":\"_interfaceID\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"cfoAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"_preferredTransport\",\"type\":\"string\"}],\"name\":\"tokenMetadata\",\"outputs\":[{\"name\":\"infoUrl\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"promoCreatedCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ceoAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_STARTING_PRICE\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setSiringAuctionAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pregnantKitties\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"}],\"name\":\"isPregnant\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_AUCTION_DURATION\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"siringAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setGeneScienceAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCEO\",\"type\":\"address\"}],\"name\":\"setCEO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCOO\",\"type\":\"address\"}],\"name\":\"setCOO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"}],\"name\":\"createSaleAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"sireAllowedToAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"canBreedWith\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"kittyIndexToApproved\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"}],\"name\":\"createSiringAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"val\",\"type\":\"uint256\"}],\"name\":\"setAutoBirthFee\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_addr\",\"type\":\"address\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"approveSiring\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCFO\",\"type\":\"address\"}],\"name\":\"setCFO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_genes\",\"type\":\"uint256\"},{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"createPromoKitty\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"secs\",\"type\":\"uint256\"}],\"name\":\"setSecondsPerBlock\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawBalance\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"name\":\"owner\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_CREATION_LIMIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"newContractAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setSaleAuctionAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"count\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_v2Address\",\"type\":\"address\"}],\"name\":\"setNewAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"secondsPerBlock\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"tokensOfOwner\",\"outputs\":[{\"name\":\"ownerTokens\",\"type\":\"uint256[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"}],\"name\":\"giveBirth\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawAuctionBalances\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"cooldowns\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"kittyIndexToOwner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"cooAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"autoBirthFee\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"erc721Metadata\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_genes\",\"type\":\"uint256\"}],\"name\":\"createGen0Auction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"}],\"name\":\"isReadyToBreed\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"PROMO_CREATION_LIMIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_contractAddress\",\"type\":\"address\"}],\"name\":\"setMetadataAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"saleAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_id\",\"type\":\"uint256\"}],\"name\":\"getKitty\",\"outputs\":[{\"name\":\"isGestating\",\"type\":\"bool\"},{\"name\":\"isReady\",\"type\":\"bool\"},{\"name\":\"cooldownIndex\",\"type\":\"uint256\"},{\"name\":\"nextActionAt\",\"type\":\"uint256\"},{\"name\":\"siringWithId\",\"type\":\"uint256\"},{\"name\":\"birthTime\",\"type\":\"uint256\"},{\"name\":\"matronId\",\"type\":\"uint256\"},{\"name\":\"sireId\",\"type\":\"uint256\"},{\"name\":\"generation\",\"type\":\"uint256\"},{\"name\":\"genes\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_sireId\",\"type\":\"uint256\"},{\"name\":\"_matronId\",\"type\":\"uint256\"}],\"name\":\"bidOnSiringAuction\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"gen0CreatedCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"geneScience\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"breedWithAuto\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"matronId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"sireId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"cooldownEndBlock\",\"type\":\"uint256\"}],\"name\":\"Pregnant\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"kittyId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"matronId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"sireId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"genes\",\"type\":\"uint256\"}],\"name\":\"Birth\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"newContract\",\"type\":\"address\"}],\"name\":\"ContractUpgrade\",\"type\":\"event\"}]" - abi_ContractScenario009_deployContainLibraryContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"self\",\"type\":\"Set.Data storage\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"remove\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"self\",\"type\":\"Set.Data storage\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"contains\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"self\",\"type\":\"Set.Data storage\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"insert\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractScenario010_deployContainLibraryContract = "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"name\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"supply\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"name\":\"tokenId\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"name\":\"owner\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenMetadata\",\"outputs\":[{\"name\":\"infoUrl\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"balance\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"symbol\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"takeOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_approved\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"}]" - abi_ContractScenario012_deployTransactionCoin = "[{\"constant\":false,\"inputs\":[],\"name\":\"getBalance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"n\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_receiver\",\"type\":\"address\"}],\"name\":\"sendToAddress\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"user\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"nPlusOne\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"depositOneCoin\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"money\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_receiver\",\"type\":\"address\"}],\"name\":\"sendToAddress2\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getSenderBalance\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractScenario013_deployTronTrxAndSunContract = "[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]" - abi_ContractScenario013_triggerTronTrxAndSunContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"time\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractScenario014_testTripleTrigger = "[{\"constant\":false,\"inputs\":[{\"name\":\"_receiver\",\"type\":\"address\"}],\"name\":\"send5SunToReceiver\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi1_ContractScenario014_testTripleTrigger = "[{\"constant\":false,\"inputs\":[{\"name\":\"_receiver\",\"type\":\"address\"}],\"name\":\"triggerContract1ButRevert\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_receiver\",\"type\":\"address\"}],\"name\":\"triggerContract1\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"payContract\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_add\",\"type\":\"address\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi2_ContractScenario014_testTripleTrigger = "[{\"constant\":false,\"inputs\":[{\"name\":\"_receiver\",\"type\":\"address\"}],\"name\":\"triggerContract2\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"payContract\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_add\",\"type\":\"address\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_TronDice_tronDice = "[{\"constant\":false,\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_point\",\"type\":\"uint256\"}],\"name\":\"rollDice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"deposit\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"ownerkill\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getPendingBalane\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_addr\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_point\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_random\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_P\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_O\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_W\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_B\",\"type\":\"uint256\"}],\"name\":\"UserWin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_addr\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_point\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_random\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_B\",\"type\":\"uint256\"}],\"name\":\"UserLose\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_addr\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"Withdraw\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_balance\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_reward\",\"type\":\"uint256\"}],\"name\":\"RollDice\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"}]" - abi_TvmContract_deployErc721CryptoKitties = "[{\"constant\":true,\"inputs\":[{\"name\":\"_interfaceID\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"cfoAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"_preferredTransport\",\"type\":\"string\"}],\"name\":\"tokenMetadata\",\"outputs\":[{\"name\":\"infoUrl\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"promoCreatedCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ceoAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_STARTING_PRICE\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setSiringAuctionAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pregnantKitties\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"}],\"name\":\"isPregnant\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_AUCTION_DURATION\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"siringAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setGeneScienceAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCEO\",\"type\":\"address\"}],\"name\":\"setCEO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCOO\",\"type\":\"address\"}],\"name\":\"setCOO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"}],\"name\":\"createSaleAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"sireAllowedToAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"canBreedWith\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"kittyIndexToApproved\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"}],\"name\":\"createSiringAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"val\",\"type\":\"uint256\"}],\"name\":\"setAutoBirthFee\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_addr\",\"type\":\"address\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"approveSiring\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCFO\",\"type\":\"address\"}],\"name\":\"setCFO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_genes\",\"type\":\"uint256\"},{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"createPromoKitty\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"secs\",\"type\":\"uint256\"}],\"name\":\"setSecondsPerBlock\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawBalance\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"name\":\"owner\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_CREATION_LIMIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"newContractAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setSaleAuctionAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"count\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_v2Address\",\"type\":\"address\"}],\"name\":\"setNewAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"secondsPerBlock\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"tokensOfOwner\",\"outputs\":[{\"name\":\"ownerTokens\",\"type\":\"uint256[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"}],\"name\":\"giveBirth\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawAuctionBalances\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"cooldowns\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"kittyIndexToOwner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"cooAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"autoBirthFee\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"erc721Metadata\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_genes\",\"type\":\"uint256\"}],\"name\":\"createGen0Auction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"}],\"name\":\"isReadyToBreed\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"PROMO_CREATION_LIMIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_contractAddress\",\"type\":\"address\"}],\"name\":\"setMetadataAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"saleAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_id\",\"type\":\"uint256\"}],\"name\":\"getKitty\",\"outputs\":[{\"name\":\"isGestating\",\"type\":\"bool\"},{\"name\":\"isReady\",\"type\":\"bool\"},{\"name\":\"cooldownIndex\",\"type\":\"uint256\"},{\"name\":\"nextActionAt\",\"type\":\"uint256\"},{\"name\":\"siringWithId\",\"type\":\"uint256\"},{\"name\":\"birthTime\",\"type\":\"uint256\"},{\"name\":\"matronId\",\"type\":\"uint256\"},{\"name\":\"sireId\",\"type\":\"uint256\"},{\"name\":\"generation\",\"type\":\"uint256\"},{\"name\":\"genes\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_sireId\",\"type\":\"uint256\"},{\"name\":\"_matronId\",\"type\":\"uint256\"}],\"name\":\"bidOnSiringAuction\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"gen0CreatedCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"geneScience\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"breedWithAuto\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"matronId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"sireId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"cooldownEndBlock\",\"type\":\"uint256\"}],\"name\":\"Pregnant\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"kittyId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"matronId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"sireId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"genes\",\"type\":\"uint256\"}],\"name\":\"Birth\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"newContract\",\"type\":\"address\"}],\"name\":\"ContractUpgrade\",\"type\":\"event\"}]" - abi_ContractScenario011_deployErc721KittyCore = "[{\"constant\":true,\"inputs\":[{\"name\":\"_interfaceID\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"cfoAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"_preferredTransport\",\"type\":\"string\"}],\"name\":\"tokenMetadata\",\"outputs\":[{\"name\":\"infoUrl\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"promoCreatedCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ceoAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_STARTING_PRICE\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setSiringAuctionAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pregnantKitties\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"}],\"name\":\"isPregnant\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_AUCTION_DURATION\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"siringAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setGeneScienceAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCEO\",\"type\":\"address\"}],\"name\":\"setCEO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCOO\",\"type\":\"address\"}],\"name\":\"setCOO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"}],\"name\":\"createSaleAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"sireAllowedToAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"canBreedWith\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"kittyIndexToApproved\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"}],\"name\":\"createSiringAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"val\",\"type\":\"uint256\"}],\"name\":\"setAutoBirthFee\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_addr\",\"type\":\"address\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"approveSiring\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCFO\",\"type\":\"address\"}],\"name\":\"setCFO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_genes\",\"type\":\"uint256\"},{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"createPromoKitty\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"secs\",\"type\":\"uint256\"}],\"name\":\"setSecondsPerBlock\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawBalance\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"name\":\"owner\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_CREATION_LIMIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"newContractAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setSaleAuctionAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"count\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_v2Address\",\"type\":\"address\"}],\"name\":\"setNewAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"secondsPerBlock\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"tokensOfOwner\",\"outputs\":[{\"name\":\"ownerTokens\",\"type\":\"uint256[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"}],\"name\":\"giveBirth\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawAuctionBalances\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"cooldowns\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"kittyIndexToOwner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"cooAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"autoBirthFee\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"erc721Metadata\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_genes\",\"type\":\"uint256\"}],\"name\":\"createGen0Auction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"}],\"name\":\"isReadyToBreed\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"PROMO_CREATION_LIMIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_contractAddress\",\"type\":\"address\"}],\"name\":\"setMetadataAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"saleAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_id\",\"type\":\"uint256\"}],\"name\":\"getKitty\",\"outputs\":[{\"name\":\"isGestating\",\"type\":\"bool\"},{\"name\":\"isReady\",\"type\":\"bool\"},{\"name\":\"cooldownIndex\",\"type\":\"uint256\"},{\"name\":\"nextActionAt\",\"type\":\"uint256\"},{\"name\":\"siringWithId\",\"type\":\"uint256\"},{\"name\":\"birthTime\",\"type\":\"uint256\"},{\"name\":\"matronId\",\"type\":\"uint256\"},{\"name\":\"sireId\",\"type\":\"uint256\"},{\"name\":\"generation\",\"type\":\"uint256\"},{\"name\":\"genes\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_sireId\",\"type\":\"uint256\"},{\"name\":\"_matronId\",\"type\":\"uint256\"}],\"name\":\"bidOnSiringAuction\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"gen0CreatedCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"geneScience\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"breedWithAuto\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"matronId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"sireId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"cooldownEndBlock\",\"type\":\"uint256\"}],\"name\":\"Pregnant\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"kittyId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"matronId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"sireId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"genes\",\"type\":\"uint256\"}],\"name\":\"Birth\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"newContract\",\"type\":\"address\"}],\"name\":\"ContractUpgrade\",\"type\":\"event\"}]" - abi_ContractScenario011_deploySaleClockAuction = "[{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"},{\"name\":\"_seller\",\"type\":\"address\"}],\"name\":\"createAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"unpause\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"bid\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"lastGen0SalePrices\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawBalance\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"getAuction\",\"outputs\":[{\"name\":\"seller\",\"type\":\"address\"},{\"name\":\"startingPrice\",\"type\":\"uint256\"},{\"name\":\"endingPrice\",\"type\":\"uint256\"},{\"name\":\"duration\",\"type\":\"uint256\"},{\"name\":\"startedAt\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ownerCut\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"pause\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isSaleClockAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"cancelAuctionWhenPaused\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"gen0SaleCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"cancelAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"getCurrentPrice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nonFungibleContract\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"averageGen0SalePrice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_nftAddr\",\"type\":\"address\"},{\"name\":\"_cut\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startingPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endingPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"duration\",\"type\":\"uint256\"}],\"name\":\"AuctionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"totalPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"winner\",\"type\":\"address\"}],\"name\":\"AuctionSuccessful\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"AuctionCancelled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"Pause\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"Unpause\",\"type\":\"event\"}]" - abi_ContractScenario011_deploySiringClockAuction = "[{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"},{\"name\":\"_seller\",\"type\":\"address\"}],\"name\":\"createAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"unpause\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"bid\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawBalance\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isSiringClockAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"getAuction\",\"outputs\":[{\"name\":\"seller\",\"type\":\"address\"},{\"name\":\"startingPrice\",\"type\":\"uint256\"},{\"name\":\"endingPrice\",\"type\":\"uint256\"},{\"name\":\"duration\",\"type\":\"uint256\"},{\"name\":\"startedAt\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ownerCut\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"pause\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"cancelAuctionWhenPaused\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"cancelAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"getCurrentPrice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nonFungibleContract\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_nftAddr\",\"type\":\"address\"},{\"name\":\"_cut\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startingPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endingPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"duration\",\"type\":\"uint256\"}],\"name\":\"AuctionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"totalPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"winner\",\"type\":\"address\"}],\"name\":\"AuctionSuccessful\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"AuctionCancelled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"Pause\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"Unpause\",\"type\":\"event\"}]" - abi_ContractScenario011_deployGeneScienceInterface = "[{\"constant\":true,\"inputs\":[{\"name\":\"genes1\",\"type\":\"uint256\"},{\"name\":\"genes2\",\"type\":\"uint256\"},{\"name\":\"targetBlock\",\"type\":\"uint256\"}],\"name\":\"mixGenes\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isGeneScience\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"}]" - abi_WalletTestAccount012_storageAndCpu = "[{\"constant\":false,\"inputs\":[{\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"add2\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"add\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"fori2\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"args\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"fori\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]" - abi_TestExceptionCodeAndAbi_testExceptionCodeAndAbi = "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"_name\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply1\",\"outputs\":[{\"name\":\"_totalSupply1\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"_decimals\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MAX_UINT256\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"balance\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"_symbol\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_data\",\"type\":\"bytes\"},{\"name\":\"_custom_fallback\",\"type\":\"string\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"Transfer\",\"type\":\"event\"}]" - abi_TestExceptionCodeAndAbi_testtimeout = "[{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"iarray\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"a\",\"type\":\"uint256\"}],\"name\":\"testUseCpu\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"a\",\"type\":\"uint256\"}],\"name\":\"testUseStorage\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"address\"}],\"name\":\"m\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"calculatedFibNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"test\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"n\",\"type\":\"uint256\"}],\"name\":\"setFibonacci\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_TestMapBigLongAndNumbers_deployErc721KittyCore = "[{\"constant\":false,\"inputs\":[{\"name\":\"amount\",\"type\":\"bytes\"},{\"name\":\"addr3\",\"type\":\"address\"}],\"name\":\"update3\",\"outputs\":[{\"name\":\"addr\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"balances1\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"balances\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"balances3\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"a\",\"type\":\"uint256\"}],\"name\":\"testUseCpu\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"s\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"addr2\",\"type\":\"address\"},{\"name\":\"times\",\"type\":\"uint256\"}],\"name\":\"update1\",\"outputs\":[{\"name\":\"addr\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"amount\",\"type\":\"string\"},{\"name\":\"addr3\",\"type\":\"address\"}],\"name\":\"update2\",\"outputs\":[{\"name\":\"addr\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"addr1\",\"type\":\"address\"}],\"name\":\"update\",\"outputs\":[{\"name\":\"addr\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_TestNetErc721Cat_deployErc721KittyCore = "[{\"constant\":true,\"inputs\":[{\"name\":\"_interfaceID\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"cfoAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"_preferredTransport\",\"type\":\"string\"}],\"name\":\"tokenMetadata\",\"outputs\":[{\"name\":\"infoUrl\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"promoCreatedCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ceoAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_STARTING_PRICE\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setSiringAuctionAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pregnantKitties\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"}],\"name\":\"isPregnant\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_AUCTION_DURATION\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"siringAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setGeneScienceAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCEO\",\"type\":\"address\"}],\"name\":\"setCEO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCOO\",\"type\":\"address\"}],\"name\":\"setCOO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"}],\"name\":\"createSaleAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"sireAllowedToAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"canBreedWith\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"kittyIndexToApproved\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"}],\"name\":\"createSiringAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"val\",\"type\":\"uint256\"}],\"name\":\"setAutoBirthFee\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_addr\",\"type\":\"address\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"approveSiring\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newCFO\",\"type\":\"address\"}],\"name\":\"setCFO\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_genes\",\"type\":\"uint256\"},{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"createPromoKitty\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"secs\",\"type\":\"uint256\"}],\"name\":\"setSecondsPerBlock\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawBalance\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"name\":\"owner\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GEN0_CREATION_LIMIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"newContractAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setSaleAuctionAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"count\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_v2Address\",\"type\":\"address\"}],\"name\":\"setNewAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"secondsPerBlock\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"tokensOfOwner\",\"outputs\":[{\"name\":\"ownerTokens\",\"type\":\"uint256[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"}],\"name\":\"giveBirth\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawAuctionBalances\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"cooldowns\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"kittyIndexToOwner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"cooAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"autoBirthFee\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"erc721Metadata\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_genes\",\"type\":\"uint256\"}],\"name\":\"createGen0Auction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_kittyId\",\"type\":\"uint256\"}],\"name\":\"isReadyToBreed\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"PROMO_CREATION_LIMIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_contractAddress\",\"type\":\"address\"}],\"name\":\"setMetadataAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"saleAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_id\",\"type\":\"uint256\"}],\"name\":\"getKitty\",\"outputs\":[{\"name\":\"isGestating\",\"type\":\"bool\"},{\"name\":\"isReady\",\"type\":\"bool\"},{\"name\":\"cooldownIndex\",\"type\":\"uint256\"},{\"name\":\"nextActionAt\",\"type\":\"uint256\"},{\"name\":\"siringWithId\",\"type\":\"uint256\"},{\"name\":\"birthTime\",\"type\":\"uint256\"},{\"name\":\"matronId\",\"type\":\"uint256\"},{\"name\":\"sireId\",\"type\":\"uint256\"},{\"name\":\"generation\",\"type\":\"uint256\"},{\"name\":\"genes\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_sireId\",\"type\":\"uint256\"},{\"name\":\"_matronId\",\"type\":\"uint256\"}],\"name\":\"bidOnSiringAuction\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"gen0CreatedCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"geneScience\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_matronId\",\"type\":\"uint256\"},{\"name\":\"_sireId\",\"type\":\"uint256\"}],\"name\":\"breedWithAuto\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"matronId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"sireId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"cooldownEndBlock\",\"type\":\"uint256\"}],\"name\":\"Pregnant\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"kittyId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"matronId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"sireId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"genes\",\"type\":\"uint256\"}],\"name\":\"Birth\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"newContract\",\"type\":\"address\"}],\"name\":\"ContractUpgrade\",\"type\":\"event\"}]" - abi_TestNetErc721Cat_deploySaleClockAuction = "[{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"},{\"name\":\"_seller\",\"type\":\"address\"}],\"name\":\"createAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"unpause\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"bid\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"lastGen0SalePrices\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawBalance\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"getAuction\",\"outputs\":[{\"name\":\"seller\",\"type\":\"address\"},{\"name\":\"startingPrice\",\"type\":\"uint256\"},{\"name\":\"endingPrice\",\"type\":\"uint256\"},{\"name\":\"duration\",\"type\":\"uint256\"},{\"name\":\"startedAt\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ownerCut\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"pause\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isSaleClockAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"cancelAuctionWhenPaused\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"gen0SaleCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"cancelAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"getCurrentPrice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nonFungibleContract\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"averageGen0SalePrice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_nftAddr\",\"type\":\"address\"},{\"name\":\"_cut\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startingPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endingPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"duration\",\"type\":\"uint256\"}],\"name\":\"AuctionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"totalPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"winner\",\"type\":\"address\"}],\"name\":\"AuctionSuccessful\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"AuctionCancelled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"Pause\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"Unpause\",\"type\":\"event\"}]" - abi_TestNetErc721Cat_deploySiringClockAuction = "[{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"_startingPrice\",\"type\":\"uint256\"},{\"name\":\"_endingPrice\",\"type\":\"uint256\"},{\"name\":\"_duration\",\"type\":\"uint256\"},{\"name\":\"_seller\",\"type\":\"address\"}],\"name\":\"createAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"unpause\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"bid\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdrawBalance\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isSiringClockAuction\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"getAuction\",\"outputs\":[{\"name\":\"seller\",\"type\":\"address\"},{\"name\":\"startingPrice\",\"type\":\"uint256\"},{\"name\":\"endingPrice\",\"type\":\"uint256\"},{\"name\":\"duration\",\"type\":\"uint256\"},{\"name\":\"startedAt\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ownerCut\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"pause\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"cancelAuctionWhenPaused\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"cancelAuction\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"getCurrentPrice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nonFungibleContract\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_nftAddr\",\"type\":\"address\"},{\"name\":\"_cut\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startingPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endingPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"duration\",\"type\":\"uint256\"}],\"name\":\"AuctionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"totalPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"winner\",\"type\":\"address\"}],\"name\":\"AuctionSuccessful\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"AuctionCancelled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"Pause\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"Unpause\",\"type\":\"event\"}]" - abi_TestNetErc721Cat_deployGeneScienceInterface = "[{\"constant\":true,\"inputs\":[{\"name\":\"genes1\",\"type\":\"uint256\"},{\"name\":\"genes2\",\"type\":\"uint256\"},{\"name\":\"targetBlock\",\"type\":\"uint256\"}],\"name\":\"mixGenes\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isGeneScience\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"}]" - abi_TestNetFomo3D_deployErc721CryptoKitties = "[{\"constant\":true,\"inputs\":[{\"name\":\"_customerAddress\",\"type\":\"address\"}],\"name\":\"dividendsOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_ethereumToSpend\",\"type\":\"uint256\"}],\"name\":\"calculateTokensReceived\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokensToSell\",\"type\":\"uint256\"}],\"name\":\"calculateEthereumReceived\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"onlyAmbassadors\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"administrators\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"sellPrice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"stakingRequirement\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_includeReferralBonus\",\"type\":\"bool\"}],\"name\":\"myDividends\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalEthereumBalance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_customerAddress\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_amountOfTokens\",\"type\":\"uint256\"}],\"name\":\"setStakingRequirement\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"buyPrice\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_identifier\",\"type\":\"bytes32\"},{\"name\":\"_status\",\"type\":\"bool\"}],\"name\":\"setAdministrator\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"Hourglass\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"myTokens\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"disableInitialStage\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_toAddress\",\"type\":\"address\"},{\"name\":\"_amountOfTokens\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_symbol\",\"type\":\"string\"}],\"name\":\"setSymbol\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_name\",\"type\":\"string\"}],\"name\":\"setName\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_amountOfTokens\",\"type\":\"uint256\"}],\"name\":\"sell\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"exit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_referredBy\",\"type\":\"address\"}],\"name\":\"buy\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"reinvest\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"customerAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"incomingEthereum\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"tokensMinted\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"referredBy\",\"type\":\"address\"}],\"name\":\"onTokenPurchase\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"customerAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokensBurned\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"ethereumEarned\",\"type\":\"uint256\"}],\"name\":\"onTokenSell\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"customerAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"ethereumReinvested\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"tokensMinted\",\"type\":\"uint256\"}],\"name\":\"onReinvestment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"customerAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"ethereumWithdrawn\",\"type\":\"uint256\"}],\"name\":\"onWithdraw\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokens\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]" - abi1_TestNetFomo3D_deployErc721CryptoKitties = "[{\"constant\":false,\"inputs\":[],\"name\":\"test\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_TestNetFomo3D_tooLargeStorage = "[{\"constant\":true,\"inputs\":[],\"name\":\"s\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"foo\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"times\",\"type\":\"uint256\"}],\"name\":\"slice\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"refresh\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_TestStorageAndCpu_storageAndCpu = "[{\"constant\":false,\"inputs\":[],\"name\":\"oneCpu\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"iarray\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"storage8Char\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"a\",\"type\":\"uint256\"}],\"name\":\"testUseCpu\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"a\",\"type\":\"uint256\"}],\"name\":\"testUseStorage\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"address\"}],\"name\":\"m\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"iarray1\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"calculatedFibNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"test\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"n\",\"type\":\"uint256\"}],\"name\":\"setFibonacci\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_WalletTestAccount013 = "[{\"constant\":false,\"inputs\":[{\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"add2\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"add\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"fori2\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"args\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"fori\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}] " - abi_ContractEventAndLog1 = "[{\"constant\":false,\"inputs\":[],\"name\":\"depositForLog\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"a\",\"type\":\"uint256\"}],\"name\":\"depositForLogCycle\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"depositForAnonymousNoLog\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"depositForEventAndLog\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getTransactionKeccak256\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"depositForAnonymousHasLog\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"depositForEventTwoIndex\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"depositForEvent\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getDepositKeccak256\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"depositForEventNoIndex\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"a\",\"type\":\"uint256\"}],\"name\":\"depositForEventCycle\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"yes\",\"type\":\"bool\"},{\"name\":\"no\",\"type\":\"bool\"}],\"name\":\"triggerBoolEvent\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"triggerUintEvent\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"age\",\"type\":\"string\"}],\"name\":\"triggerStringEvent\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"age\",\"type\":\"string\"}],\"name\":\"triggerStringEventAnonymous\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"triggerintEvent\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getBanlance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"depositForEventOneIndex\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"value1\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"value2\",\"type\":\"uint64\"},{\"indexed\":false,\"name\":\"value3\",\"type\":\"uint128\"},{\"indexed\":false,\"name\":\"value4\",\"type\":\"uint248\"}],\"name\":\"uintErgodic\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"value1\",\"type\":\"int8\"},{\"indexed\":false,\"name\":\"value2\",\"type\":\"int72\"},{\"indexed\":false,\"name\":\"value3\",\"type\":\"int136\"},{\"indexed\":false,\"name\":\"value4\",\"type\":\"int232\"}],\"name\":\"intErgodic\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"name\",\"type\":\"string\"},{\"indexed\":true,\"name\":\"age\",\"type\":\"string\"}],\"name\":\"stringEvent\",\"type\":\"event\"},{\"anonymous\":true,\"inputs\":[{\"indexed\":false,\"name\":\"name\",\"type\":\"string\"},{\"indexed\":true,\"name\":\"age\",\"type\":\"string\"}],\"name\":\"stringEventAnonymous\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"yes\",\"type\":\"bool\"},{\"indexed\":true,\"name\":\"no\",\"type\":\"bool\"}],\"name\":\"boolEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferNoIndex\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferOneIndex\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferTwoIndex\",\"type\":\"event\"},{\"anonymous\":true,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferAnonymous\",\"type\":\"event\"}]" - abi_ContractEventAndLog2 = "[{\"constant\":false,\"inputs\":[],\"name\":\"triggerEventBytes\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"deposit\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getBanlance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"value10\",\"type\":\"bytes10\"},{\"indexed\":false,\"name\":\"value17\",\"type\":\"bytes17\"},{\"indexed\":false,\"name\":\"value32\",\"type\":\"bytes32\"}],\"name\":\"eventBytes\",\"type\":\"event\"},{\"anonymous\":true,\"inputs\":[{\"indexed\":false,\"name\":\"value10\",\"type\":\"bytes10\"},{\"indexed\":false,\"name\":\"value17\",\"type\":\"bytes17\"},{\"indexed\":false,\"name\":\"value32\",\"type\":\"bytes32\"}],\"name\":\"triggerBytesAnonymous\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"value10\",\"type\":\"bytes10\"},{\"indexed\":true,\"name\":\"value17\",\"type\":\"bytes17\"},{\"indexed\":true,\"name\":\"value32\",\"type\":\"bytes32\"}],\"name\":\"eventBytesIndex\",\"type\":\"event\"},{\"anonymous\":true,\"inputs\":[{\"indexed\":true,\"name\":\"value10\",\"type\":\"bytes10\"},{\"indexed\":true,\"name\":\"value17\",\"type\":\"bytes17\"},{\"indexed\":true,\"name\":\"value32\",\"type\":\"bytes32\"}],\"name\":\"triggerBytesAnonymousIndex\",\"type\":\"event\"}]" - - abi_OriginEnergyLimit001 = "[{\"constant\":false,\"inputs\":[{\"name\":\"i\",\"type\":\"uint256\"}],\"name\":\"findArgsByIndexTest\",\"outputs\":[{\"name\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_OriginEnergyLimit004 = "[{\"constant\":false,\"inputs\":[{\"name\":\"i\",\"type\":\"uint256\"}],\"name\":\"findArgsByIndexTest\",\"outputs\":[{\"name\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - - abi_ContractTrcToken001_transferTokenContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"getResultInCon\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]\n" - abi_ContractTrcToken002_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken005_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken006_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken011_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken011_resultContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken012_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken014_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken014_resultContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken016_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken016_resultContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken017_recieveTokenContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"setFlag\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"flag\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken042_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken042_recieveTokenContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken043_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken043_recieveTokenContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken046_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken047_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi2_ContractTrcToken023_tokenTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken023_tokenTest = "[{\"constant\":true,\"inputs\":[],\"name\":\"flag\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken026_BTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"callCAddress\",\"type\":\"address\"},{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transC\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi1_ContractTrcToken026_CTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"trans\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi1_ContractTrcToken026_tokenTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"callBAddress\",\"type\":\"address\"},{\"name\":\"callCAddress\",\"type\":\"address\"},{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"testInCall\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"callBddress\",\"type\":\"address\"},{\"name\":\"callAddressC\",\"type\":\"address\"},{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"testIndelegateCall\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken027_BTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"callCAddress\",\"type\":\"address\"},{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transC\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken027_CTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"trans\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken027_tokenTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"callBAddress\",\"type\":\"address\"},{\"name\":\"callCAddress\",\"type\":\"address\"},{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"testIndelegateCall\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"callBddress\",\"type\":\"address\"},{\"name\":\"callAddressC\",\"type\":\"address\"},{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"testIndelegateCall\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken028_tokenTest = "[{\"constant\":true,\"inputs\":[],\"name\":\"a\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"tokenBalanceWithSameName\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getA\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken054_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken055_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken060_transferTokenContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"getResultInCon\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]\n" - abi_ContractTrcToken061_transferTokenContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"getResultInCon\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]\n" - abi_ContractTrcToken062_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken062_recieveTokenContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken063_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken063_recieveTokenContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken064_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken064_recieveTokenContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken066_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken066_recieveTokenContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken067_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken067_recieveTokenContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken068_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken068_recieveTokenContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken071_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestIDOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken071_recieveTokenContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken073_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getToken\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"logFallback\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"logGetToken\",\"type\":\"event\"}]" - abi_ContractTrcToken074_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getToken\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"logFallback\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"logGetToken\",\"type\":\"event\"}]" - abi_ContractTrcToken075_transferTokenContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"getTokenLongMin\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getToken\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getTokenLongMax\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"logFallback\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"logGetToken\",\"type\":\"event\"}]" - abi_ContractTrcToken0552_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken0553_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken0612_transferTokenContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"getResultInCon\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]\n" - abi_ContractTrcToken0613_transferTokenContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"getResultInCon\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]\n" - abi_ContractTrcToken0672_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"transferTokenTest\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueOverBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueRandomIdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"accountAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalanceTest\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"msgTokenValueAndTokenIdTest\",\"outputs\":[{\"name\":\"\",\"type\":\"trcToken\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValueMaxLong\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTokenTestValue0IdBigInteger\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken0672_recieveTokenContract = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - - abi_ContractTrcToken029_tokenTest = "[{\"constant\":true,\"inputs\":[],\"name\":\"a\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferTokenWithSameName\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken030_tokenTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"kill\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken031_tokenTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"kill\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken034_tokenTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"failTransferTokenError\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"failTransferTokenRevert\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"}]" - abi_ContractTrcToken035_tokenTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"failTransferTokenError\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"failTransferTokenRevert\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"}]" - abi_ContractTrcToken036_transferTokenWithPureTest = "[{\"constant\":true,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"}],\"name\":\"transferTokenWithConstant\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - - abi_ContractTrcToken036_transferTokenWithViewTest = "[{\"constant\":true,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"}],\"name\":\"transferTokenWithView\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken036_transferTokenWithOutPayableTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"}],\"name\":\"transferTokenWithOutPayable\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken037_receiveTrc10Test = "[{\"constant\":false,\"inputs\":[{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"tid\",\"type\":\"trcToken\"},{\"name\":\"meamount\",\"type\":\"uint256\"}],\"name\":\"checkTrc10\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - - abi_ContractTrcToken037_tokenTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"rec\",\"type\":\"address\"}],\"name\":\"receive\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"}]" - abi_ContractTrcToken038_tokenTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"rec\",\"type\":\"address\"}],\"name\":\"receive\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"}]" - abi_ContractTrcToken038_BTest = "[{\"constant\":false,\"inputs\":[],\"name\":\"AssertError\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - - abi_ContractTrcToken039_ProxyTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - - abi_ContractTrcToken039_ATest = "[{\"constant\":false,\"inputs\":[{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"trans\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"}]" - abi_ContractTrcToken039_BTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"}],\"name\":\"trans\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"}]" - abi_ContractTrcToken041_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken048_transferTokenContract = "[{\"constant\":false,\"inputs\":[],\"name\":\"testMsgValue\",\"outputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"testMsgTokenValue\",\"outputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - - abi_ContractTrcToken050_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - - abi_ContractTrcToken051_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - - - abi_ContractTrcToken052_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken036_tokenTest = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"tokenValue\",\"type\":\"uint256\"}],\"name\":\"transferTokenWithPure\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_ContractTrcToken049_transferTokenContract = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"},{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_ContractTrcToken076_originTest = "[{\"constant\":true,\"inputs\":[],\"name\":\"result2\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"result1\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"sender\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getResult1\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"origin\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"getResult2\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"test\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_ContractTrcToken077_AddressTest = "[{\"constant\":true,\"inputs\":[],\"name\":\"addressTest\",\"outputs\":[{\"name\":\"addressValue\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" - abi_ContractTrcToken077_AddressTest1 = "[{\"constant\":false,\"inputs\":[],\"name\":\"addressTest\",\"outputs\":[{\"name\":\"addressValue\",\"type\":\"bytes32\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"}]" - abi_ContractTrcToken078_AddressTest1 = "[{\"constant\":false,\"inputs\":[{\"name\":\"called_address\",\"type\":\"address\"},{\"name\":\"c\",\"type\":\"address\"}],\"name\":\"sendToB3\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"called_address\",\"type\":\"address\"},{\"name\":\"c\",\"type\":\"address\"}],\"name\":\"sendToB\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"called_address\",\"type\":\"address\"},{\"name\":\"c\",\"type\":\"address\"}],\"name\":\"sendToB2\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken078_AddressTest2 = "[{\"constant\":false,\"inputs\":[{\"name\":\"c\",\"type\":\"address\"}],\"name\":\"setIinC\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken078_AddressTest3 = "[{\"constant\":true,\"inputs\":[],\"name\":\"sender\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"origin\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"\",\"type\":\"address\"}],\"name\":\"log\",\"type\":\"event\"}]" - - abi_ContractTrcToken078_AddressTest4 = "[{\"constant\":false,\"inputs\":[{\"name\":\"called_address\",\"type\":\"address\"},{\"name\":\"c\",\"type\":\"address\"}],\"name\":\"sendToB3\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"called_address\",\"type\":\"address\"},{\"name\":\"c\",\"type\":\"address\"}],\"name\":\"sendToB\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"called_address\",\"type\":\"address\"},{\"name\":\"c\",\"type\":\"address\"}],\"name\":\"sendToB2\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - - abi_ContractTrcToken078_AddressTest5 = "[{\"constant\":false,\"inputs\":[{\"name\":\"c\",\"type\":\"address\"}],\"name\":\"setIinC\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}],\"name\":\"transferTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_ContractTrcToken078_AddressTest6 = "[{\"constant\":true,\"inputs\":[],\"name\":\"sender\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"origin\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"\",\"type\":\"address\"}],\"name\":\"log\",\"type\":\"event\"}]" - abi_veryLarge = "[{\"constant\":false,\"inputs\":[],\"name\":\"getBalance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"Address\",\"type\":\"address\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"num\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"}]" - abi_MainGateway = "[{\"constant\":true,\"inputs\":[{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"checkOracle\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"contractAddress\",\"type\":\"address\"},{\"name\":\"uid\",\"type\":\"uint256\"},{\"name\":\"sig\",\"type\":\"bytes\"}],\"name\":\"withdrawTRC721\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"depositTRX\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"depositTRC10\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"contractAddress\",\"type\":\"address\"}],\"name\":\"depositTRC20\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"uid\",\"type\":\"uint256\"},{\"name\":\"contractAddress\",\"type\":\"address\"}],\"name\":\"depositTRC721\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"nonces\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"numOracles\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"contractAddress\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"sig\",\"type\":\"bytes\"}],\"name\":\"withdrawTRC20\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getTRC10\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_oracle\",\"type\":\"address\"},{\"name\":\"isOracle\",\"type\":\"bool\"}],\"name\":\"modifyOracle\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"uid\",\"type\":\"uint256\"},{\"name\":\"contractAddress\",\"type\":\"address\"}],\"name\":\"getNFT\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"sig\",\"type\":\"bytes\"}],\"name\":\"withdrawTRC10\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowes\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onTRC20Received\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes4\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_uid\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onTRC721Received\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes4\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getTRX\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"mainChainToken\",\"type\":\"address\"},{\"name\":\"sideChainToken\",\"type\":\"address\"}],\"name\":\"migrationToken\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"sig\",\"type\":\"bytes\"}],\"name\":\"withdrawTRX\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"contractAddress\",\"type\":\"address\"}],\"name\":\"getTRC20\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_oracle\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TRXReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"TRC10Received\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"contractAddress\",\"type\":\"address\"}],\"name\":\"TRC20Received\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"uid\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"contractAddress\",\"type\":\"address\"}],\"name\":\"TRC721Received\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"kind\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"contractAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"TokenWithdrawn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"kind\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"trcToken\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Token10Withdrawn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"oracle\",\"type\":\"address\"}],\"name\":\"NewOracles\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"previousOwner\",\"type\":\"address\"}],\"name\":\"OwnershipRenounced\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"}]" - abi_SideGateway = "[{\"constant\":false,\"inputs\":[{\"name\":\"_sunTokenAddress\",\"type\":\"address\"}],\"name\":\"setSunTokenAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"b1\",\"type\":\"bytes\"},{\"name\":\"b2\",\"type\":\"bytes\"}],\"name\":\"concatBytes\",\"outputs\":[{\"name\":\"r\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"txData\",\"type\":\"bytes\"}],\"name\":\"withdrawTRX\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"trc10\",\"type\":\"uint256\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"name\",\"type\":\"bytes32\"},{\"name\":\"symbol\",\"type\":\"bytes32\"},{\"name\":\"decimals\",\"type\":\"uint8\"}],\"name\":\"depositTRC10\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"mainChainAddress\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"depositTRC20\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"trc10Map\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"mainToSideContractMap\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"txId\",\"type\":\"bytes\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"symbol\",\"type\":\"string\"},{\"name\":\"decimals\",\"type\":\"uint8\"}],\"name\":\"deployDAppTRC20AndMapping\",\"outputs\":[{\"name\":\"r\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"sunTokenAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"txId\",\"type\":\"bytes\"},{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"calcContractAddress\",\"outputs\":[{\"name\":\"r\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_oracle\",\"type\":\"address\"},{\"name\":\"isOracle\",\"type\":\"bool\"}],\"name\":\"modifyOracle\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"txId\",\"type\":\"bytes\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"symbol\",\"type\":\"string\"}],\"name\":\"deployDAppTRC721AndMapping\",\"outputs\":[{\"name\":\"r\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"oracles\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"from\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"txData\",\"type\":\"bytes\"}],\"name\":\"onTRC20Received\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes4\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"from\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"uint256\"},{\"name\":\"txData\",\"type\":\"bytes\"}],\"name\":\"onTRC721Received\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes4\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"sideToMainContractMap\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"a\",\"type\":\"address\"}],\"name\":\"addressToBytes\",\"outputs\":[{\"name\":\"b\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"txData\",\"type\":\"bytes\"}],\"name\":\"withdrawTRC10\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"depositTRX\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"mainChainAddress\",\"type\":\"address\"},{\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"depositTRC721\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_oracle\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"developer\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"mainChainAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"sideChainAddress\",\"type\":\"address\"}],\"name\":\"DeployDAppTRC20AndMapping\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"developer\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"mainChainAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"sideChainAddress\",\"type\":\"address\"}],\"name\":\"DeployDAppTRC721AndMapping\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"trc10\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"DepositTRC10\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"sideChainAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"DepositTRC20\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"sideChainAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"DepositTRC721\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"DepositTRX\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"trc10\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"txData\",\"type\":\"bytes\"}],\"name\":\"WithdrawTRC10\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"mainChainAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"txData\",\"type\":\"bytes\"}],\"name\":\"WithdrawTRC20\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"mainChainAddress\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"txData\",\"type\":\"bytes\"}],\"name\":\"WithdrawTRC721\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"txData\",\"type\":\"bytes\"}],\"name\":\"WithdrawTRX\",\"type\":\"event\"}]" - abi_shieldTrc20Token = "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"burnFrom\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_extraData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"initialSupply\",\"type\":\"uint256\"},{\"name\":\"tokenName\",\"type\":\"string\"},{\"name\":\"tokenSymbol\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Burn\",\"type\":\"event\"}]" - abi_shield = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"trc20ContractAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"scalingFactorExponent\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"position\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"cm\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"cv\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"epk\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32[21]\",\"name\":\"c\",\"type\":\"bytes32[21]\"}],\"name\":\"BurnNewLeaf\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"position\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"cm\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"cv\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"epk\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32[21]\",\"name\":\"c\",\"type\":\"bytes32[21]\"}],\"name\":\"MintNewLeaf\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"nf\",\"type\":\"bytes32\"}],\"name\":\"NoteSpent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32[3]\",\"name\":\"ciphertext\",\"type\":\"bytes32[3]\"}],\"name\":\"TokenBurn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"TokenMint\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"position\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"cm\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"cv\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"epk\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32[21]\",\"name\":\"c\",\"type\":\"bytes32[21]\"}],\"name\":\"TransferNewLeaf\",\"type\":\"event\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"bytes32[10]\",\"name\":\"input\",\"type\":\"bytes32[10]\"},{\"internalType\":\"bytes32[2]\",\"name\":\"spendAuthoritySignature\",\"type\":\"bytes32[2]\"},{\"internalType\":\"uint256\",\"name\":\"rawValue\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[2]\",\"name\":\"bindingSignature\",\"type\":\"bytes32[2]\"},{\"internalType\":\"address\",\"name\":\"payTo\",\"type\":\"address\"},{\"internalType\":\"bytes32[3]\",\"name\":\"burnCipher\",\"type\":\"bytes32[3]\"},{\"internalType\":\"bytes32[9][]\",\"name\":\"output\",\"type\":\"bytes32[9][]\"},{\"internalType\":\"bytes32[21][]\",\"name\":\"c\",\"type\":\"bytes32[21][]\"}],\"name\":\"burn\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"position\",\"type\":\"uint256\"}],\"name\":\"getPath\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32[32]\",\"name\":\"\",\"type\":\"bytes32[32]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"latestRoot\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"leafCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"rawValue\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[9]\",\"name\":\"output\",\"type\":\"bytes32[9]\"},{\"internalType\":\"bytes32[2]\",\"name\":\"bindingSignature\",\"type\":\"bytes32[2]\"},{\"internalType\":\"bytes32[21]\",\"name\":\"c\",\"type\":\"bytes32[21]\"}],\"name\":\"mint\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"noteCommitment\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"nullifiers\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"roots\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"scalingFactor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"bytes32[10][]\",\"name\":\"input\",\"type\":\"bytes32[10][]\"},{\"internalType\":\"bytes32[2][]\",\"name\":\"spendAuthoritySignature\",\"type\":\"bytes32[2][]\"},{\"internalType\":\"bytes32[9][]\",\"name\":\"output\",\"type\":\"bytes32[9][]\"},{\"internalType\":\"bytes32[2]\",\"name\":\"bindingSignature\",\"type\":\"bytes32[2]\"},{\"internalType\":\"bytes32[21][]\",\"name\":\"c\",\"type\":\"bytes32[21][]\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"tree\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" - abi_getAddressChange = "[{\"inputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"getamount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"testaddress1\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" - abi_fallbackOldVersionTest = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"data\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"msg\",\"type\":\"bytes\"}],\"name\":\"FallbackCall\",\"type\":\"event\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"}]" - abi_fallbackOldversionCall = "[{\"constant\":false,\"inputs\":[{\"internalType\":\"contract Test0\",\"name\":\"test\",\"type\":\"address\"}],\"name\":\"call\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"}]" - abi_arrayLenth_0.5.15 = "[{\"constant\":false,\"inputs\":[],\"name\":\"ChangeSize\",\"outputs\":[{\"internalType\":\"bytes1[]\",\"name\":\"\",\"type\":\"bytes1[]\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - abi_override001 = "[{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_y\",\"type\":\"uint256\"}],\"name\":\"setValue\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"x\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"y\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" - abi_override002 = "[{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_x\",\"type\":\"uint256\"}],\"name\":\"setValue\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_x\",\"type\":\"uint256\"}],\"name\":\"setValue2\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"x\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" - abi_override003 = "[{\"constant\":true,\"inputs\":[],\"name\":\"b32\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"choice\",\"outputs\":[{\"internalType\":\"enum Base.ActionChoices\",\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"choice2\",\"outputs\":[{\"internalType\":\"enum Base.ActionChoices\",\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"i\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"i2\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"origin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"stopped\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ui\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" - abi_virtual001 = "[{\"constant\":false,\"inputs\":[{\"internalType\":\"bool\",\"name\":\"_y\",\"type\":\"bool\"}],\"name\":\"setBool\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"string\",\"name\":\"_z\",\"type\":\"string\"}],\"name\":\"setString\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_x\",\"type\":\"uint256\"}],\"name\":\"setValue\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"x\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"y\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"z\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" - abi_slotAndOffset_06x = "[{\"inputs\":[],\"name\":\"getA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" -} \ No newline at end of file diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml new file mode 100644 index 00000000000..b3c879f6b40 --- /dev/null +++ b/gradle/verification-metadata.xml @@ -0,0 +1,2531 @@ + + + + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 28861d273a5..5c2d1cf016b 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1b00285c540..3994438e229 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Thu Aug 01 15:17:43 CST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/gradlew b/gradlew index cccdd3d517f..83f2acfdc31 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` diff --git a/gradlew.bat b/gradlew.bat index e95643d6a2c..24467a141f7 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/plugins/README.md b/plugins/README.md index 6807bfbb409..0db6f2e6143 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -66,7 +66,6 @@ DB copy provides a helper which can copy LevelDB or RocksDB data quickly on the java -jar Toolkit.jar db cp output-directory/database /tmp/databse ``` - ## DB Lite DB lite provides lite database, parameters are compatible with previous `LiteFullNodeTool`. @@ -135,3 +134,14 @@ Execute move command. java -jar Toolkit.jar db mv -c main_net_config.conf -d /data/tron/output-directory ``` +## DB Root + +DB root provides a helper which can compute merkle root for tiny db. + +NOTE: large db may GC overhead limit exceeded. + +### Available parameters: + +- ``: Source path for database. Default: output-directory/database +- `--db`: db name. +- `-h | --help`: provide the help info diff --git a/plugins/build.gradle b/plugins/build.gradle index 3085bb24bdc..01afaa01708 100644 --- a/plugins/build.gradle +++ b/plugins/build.gradle @@ -5,9 +5,6 @@ plugins { apply plugin: 'application' apply plugin: 'checkstyle' -jacoco { - toolVersion = "0.8.4" -} def versions = [ checkstyle: '8.7', ] @@ -25,20 +22,17 @@ configurations.getByName('checkstyleConfig') { dependencies { //local libraries - compile fileTree(dir: 'libs', include: '*.jar') - testCompile group: 'junit', name: 'junit', version: '4.13.2' - testCompile group: 'org.mockito', name: 'mockito-core', version: '2.13.0' - testCompile group: 'org.hamcrest', name: 'hamcrest-junit', version: '1.0.0.1' - testCompile project(":framework") - testCompile project(":framework").sourceSets.test.output - compile group: 'info.picocli', name: 'picocli', version: '4.6.3' - compile group: 'com.typesafe', name: 'config', version: '1.3.2' - compile group: 'me.tongfei', name: 'progressbar', version: '0.9.3' - compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69' - compile group: 'org.rocksdb', name: 'rocksdbjni', version: '5.15.10' - compile 'io.github.tronprotocol:leveldbjni-all:1.18.2' - compile 'io.github.tronprotocol:leveldb:1.18.2' - compile project(":protocol") + implementation fileTree(dir: 'libs', include: '*.jar') + testImplementation project(":framework") + testImplementation project(":framework").sourceSets.test.output + implementation group: 'info.picocli', name: 'picocli', version: '4.6.3' + implementation group: 'com.typesafe', name: 'config', version: '1.3.2' + implementation group: 'me.tongfei', name: 'progressbar', version: '0.9.3' + implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69' + implementation group: 'org.rocksdb', name: 'rocksdbjni', version: '5.15.10' + implementation 'io.github.tronprotocol:leveldbjni-all:1.18.2' + implementation 'io.github.tronprotocol:leveldb:1.18.2' + implementation project(":protocol") } check.dependsOn 'lint' @@ -100,9 +94,9 @@ def binaryRelease(taskName, jarName, mainClass) { from(sourceSets.main.output) { include "/**" } - + dependsOn project(':protocol').jar // explicit_dependency from { - configurations.compile.collect { + configurations.runtimeClasspath.collect { // https://docs.gradle.org/current/userguide/upgrading_version_6.html#changes_6.3 it.isDirectory() ? it : zipTree(it) } } @@ -123,7 +117,7 @@ def createScript(project, mainClass, name) { outputDir = new File(project.buildDir, 'scripts') mainClassName = mainClass applicationName = name - classpath = project.tasks[JavaPlugin.JAR_TASK_NAME].outputs.files + project.configurations.runtime + classpath = project.tasks[JavaPlugin.JAR_TASK_NAME].outputs.files + project.configurations.runtimeClasspath } project.tasks[name].dependsOn(project.jar) project.applicationDistribution.with { diff --git a/plugins/src/main/java/org/tron/plugins/Db.java b/plugins/src/main/java/org/tron/plugins/Db.java index c67c838a3d6..84654dca934 100644 --- a/plugins/src/main/java/org/tron/plugins/Db.java +++ b/plugins/src/main/java/org/tron/plugins/Db.java @@ -11,7 +11,8 @@ DbArchive.class, DbConvert.class, DbLite.class, - DbCopy.class + DbCopy.class, + DbRoot.class }, commandListHeading = "%nCommands:%n%nThe most commonly used db commands are:%n" ) diff --git a/plugins/src/main/java/org/tron/plugins/DbLite.java b/plugins/src/main/java/org/tron/plugins/DbLite.java index ef7e73ec6d6..732d4913021 100644 --- a/plugins/src/main/java/org/tron/plugins/DbLite.java +++ b/plugins/src/main/java/org/tron/plugins/DbLite.java @@ -355,15 +355,7 @@ private void generateInfoProperties(String propertyfile, long num) private long getLatestBlockHeaderNum(String databaseDir) throws IOException, RocksDBException { // query latest_block_header_number from checkpoint first final String latestBlockHeaderNumber = "latest_block_header_number"; - List cpList = getCheckpointV2List(databaseDir); - DBInterface checkpointDb; - if (cpList.size() > 0) { - String lastestCp = cpList.get(cpList.size() - 1); - checkpointDb = DbTool.getDB( - databaseDir + "/" + DBUtils.CHECKPOINT_DB_V2, lastestCp); - } else { - checkpointDb = DbTool.getDB(databaseDir, CHECKPOINT_DB); - } + DBInterface checkpointDb = getCheckpointDb(databaseDir); Long blockNumber = getLatestBlockHeaderNumFromCP(checkpointDb, latestBlockHeaderNumber.getBytes()); if (blockNumber != null) { @@ -594,7 +586,7 @@ private void mergeBak2Database(String liteDir, BlockNumInfo blockNumInfo) throws private byte[] getDataFromSourceDB(String sourceDir, String dbName, byte[] key) throws IOException, RocksDBException { DBInterface sourceDb = DbTool.getDB(sourceDir, dbName); - DBInterface checkpointDb = DbTool.getDB(sourceDir, CHECKPOINT_DB); + DBInterface checkpointDb = getCheckpointDb(sourceDir); // get data from tmp first. byte[] valueFromTmp = checkpointDb.get(Bytes.concat(simpleEncode(dbName), key)); byte[] value; @@ -672,6 +664,19 @@ private long getSecondBlock(String databaseDir) throws RocksDBException, IOExcep return num; } + private DBInterface getCheckpointDb(String sourceDir) throws IOException, RocksDBException { + List cpList = getCheckpointV2List(sourceDir); + DBInterface checkpointDb; + if (cpList.size() > 0) { + String latestCp = cpList.get(cpList.size() - 1); + checkpointDb = DbTool.getDB( + sourceDir + "/" + DBUtils.CHECKPOINT_DB_V2, latestCp); + } else { + checkpointDb = DbTool.getDB(sourceDir, CHECKPOINT_DB); + } + return checkpointDb; + } + @VisibleForTesting public static void setRecentBlks(long recentBlks) { RECENT_BLKS = recentBlks; diff --git a/plugins/src/main/java/org/tron/plugins/DbRoot.java b/plugins/src/main/java/org/tron/plugins/DbRoot.java new file mode 100644 index 00000000000..7c33219e180 --- /dev/null +++ b/plugins/src/main/java/org/tron/plugins/DbRoot.java @@ -0,0 +1,121 @@ +package org.tron.plugins; + +import com.google.common.collect.Streams; +import com.google.common.primitives.Bytes; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; +import me.tongfei.progressbar.ProgressBar; +import org.rocksdb.RocksDBException; +import org.tron.plugins.utils.MerkleRoot; +import org.tron.plugins.utils.Sha256Hash; +import org.tron.plugins.utils.db.DBInterface; +import org.tron.plugins.utils.db.DBIterator; +import org.tron.plugins.utils.db.DbTool; +import picocli.CommandLine; + +@Slf4j(topic = "db-root") +@CommandLine.Command(name = "root", + description = "compute merkle root for tiny db. NOTE: large db may GC overhead limit exceeded.", + exitCodeListHeading = "Exit Codes:%n", + exitCodeList = { + "0:Successful", + "n:query failed,please check toolkit.log"}) +public class DbRoot implements Callable { + + @CommandLine.Spec + CommandLine.Model.CommandSpec spec; + @CommandLine.Parameters(index = "0", defaultValue = "output-directory/database", + description = "Input path. Default: ${DEFAULT-VALUE}") + private Path db; + + @CommandLine.Option(names = { "--db"}, + description = "db name for show root") + private List dbs; + + @CommandLine.Option(names = {"-h", "--help"}, help = true, description = "display a help message") + private boolean help; + + + @Override + public Integer call() throws Exception { + if (help) { + spec.commandLine().usage(System.out); + return 0; + } + if (!db.toFile().exists()) { + logger.info(" {} does not exist.", db); + spec.commandLine().getErr().println(spec.commandLine().getColorScheme() + .errorText(String.format("%s does not exist.", db))); + return 404; + } + + // remove not exit + if (dbs != null) { + dbs.removeIf(s -> !Paths.get(db.toString(), s).toFile().exists()); + } + + if (dbs == null || dbs.isEmpty()) { + logger.info("Specify at least one exit database: --db dbName."); + spec.commandLine().getErr().println(spec.commandLine().getColorScheme() + .errorText("Specify at least one exit database: --db dbName.")); + return 404; + } + List task = ProgressBar.wrap(dbs.stream(), "root task").parallel() + .map(this::calcMerkleRoot).collect(Collectors.toList()); + task.forEach(this::printInfo); + int code = (int) task.stream().filter(r -> r.code == 1).count(); + if (code > 0) { + spec.commandLine().getErr().println(spec.commandLine().getColorScheme() + .errorText("There are some errors, please check toolkit.log for detail.")); + } + spec.commandLine().getOut().println("root task done."); + return code; + } + + private Ret calcMerkleRoot(String name) { + Ret info = new Ret(); + try (DBInterface database = DbTool.getDB(this.db, name)) { + DBIterator iterator = database.iterator(); + iterator.seekToFirst(); + ArrayList ids = Streams.stream(iterator) + .map(this::getHash) + .collect(Collectors.toCollection(ArrayList::new)); + Sha256Hash root = MerkleRoot.root(ids); + logger.info("db: {},root: {}", database.getName(), root); + info.code = 0; + info.msg = String.format("db: %s,root: %s", database.getName(), root); + } catch (RocksDBException | IOException e) { + logger.error("calc db {} fail", name, e); + info.code = 1; + info.msg = String.format("db: %s,fail: %s", + name, e.getMessage()); + } + return info; + } + + private Sha256Hash getHash(Map.Entry entry) { + return Sha256Hash.of(true, + Bytes.concat(entry.getKey(), entry.getValue())); + } + + private void printInfo(Ret ret) { + if (ret.code == 0) { + spec.commandLine().getOut().println(ret.msg); + } else { + spec.commandLine().getErr().println(spec.commandLine().getColorScheme() + .errorText(ret.msg)); + } + } + + private static class Ret { + private int code; + private String msg; + } +} diff --git a/plugins/src/main/java/org/tron/plugins/utils/ByteArray.java b/plugins/src/main/java/org/tron/plugins/utils/ByteArray.java index 3422c36ca9d..2922d110b7c 100644 --- a/plugins/src/main/java/org/tron/plugins/utils/ByteArray.java +++ b/plugins/src/main/java/org/tron/plugins/utils/ByteArray.java @@ -59,7 +59,7 @@ public static int compareUnsigned(byte[] a, byte[] b) { if (b == null) { return 1; } - int minLen = Math.min(a.length, b.length); + int minLen = StrictMath.min(a.length, b.length); for (int i = 0; i < minLen; ++i) { int aVal = a[i] & 0xFF; int bVal = b[i] & 0xFF; diff --git a/plugins/src/main/java/org/tron/plugins/utils/DBUtils.java b/plugins/src/main/java/org/tron/plugins/utils/DBUtils.java index 19547e2b5a5..f8559d5dba8 100644 --- a/plugins/src/main/java/org/tron/plugins/utils/DBUtils.java +++ b/plugins/src/main/java/org/tron/plugins/utils/DBUtils.java @@ -95,7 +95,8 @@ private static Options newDefaultRocksDbOptions(boolean forBulkLoad) { options.setTargetFileSizeBase(64 * 1024 * 1024); options.setTargetFileSizeMultiplier(1); options.setMaxBytesForLevelBase(512 * 1024 * 1024); - options.setMaxBackgroundCompactions(Math.max(1, Runtime.getRuntime().availableProcessors())); + options.setMaxBackgroundCompactions(StrictMath.max( + 1, Runtime.getRuntime().availableProcessors())); options.setLevel0FileNumCompactionTrigger(4); options.setLevelCompactionDynamicLevelBytes(true); final BlockBasedTableConfig tableCfg; diff --git a/plugins/src/main/java/org/tron/plugins/utils/MarketUtils.java b/plugins/src/main/java/org/tron/plugins/utils/MarketUtils.java index a36fc8ad57c..dbd578a59a3 100644 --- a/plugins/src/main/java/org/tron/plugins/utils/MarketUtils.java +++ b/plugins/src/main/java/org/tron/plugins/utils/MarketUtils.java @@ -130,8 +130,8 @@ public static int comparePriceKey(byte[] o1, byte[] o2) { public static int comparePrice(long price1SellQuantity, long price1BuyQuantity, long price2SellQuantity, long price2BuyQuantity) { try { - return Long.compare(Math.multiplyExact(price1BuyQuantity, price2SellQuantity), - Math.multiplyExact(price2BuyQuantity, price1SellQuantity)); + return Long.compare(StrictMath.multiplyExact(price1BuyQuantity, price2SellQuantity), + StrictMath.multiplyExact(price2BuyQuantity, price1SellQuantity)); } catch (ArithmeticException ex) { // do nothing here, because we will use BigInteger to compute again diff --git a/plugins/src/main/java/org/tron/plugins/utils/MerkleRoot.java b/plugins/src/main/java/org/tron/plugins/utils/MerkleRoot.java new file mode 100644 index 00000000000..055f5dcdee0 --- /dev/null +++ b/plugins/src/main/java/org/tron/plugins/utils/MerkleRoot.java @@ -0,0 +1,68 @@ +package org.tron.plugins.utils; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import lombok.Getter; + +public class MerkleRoot { + + private MerkleRoot() { + + } + + public static Sha256Hash root(List hashList) { + List leaves = createLeaves(hashList); + while (leaves.size() > 1) { + leaves = createParentLeaves(leaves); + } + return leaves.isEmpty() ? Sha256Hash.ZERO_HASH : leaves.get(0).hash; + } + + private static List createParentLeaves(List leaves) { + int step = 2; + int len = leaves.size(); + return IntStream.iterate(0, i -> i + step) + .limit(len) + .filter(i -> i < len) + .mapToObj(i -> { + Leaf right = i + 1 < len ? leaves.get(i + 1) : null; + return createLeaf(leaves.get(i), right); + }).collect(Collectors.toList()); + } + + private static List createLeaves(List hashList) { + int step = 2; + int len = hashList.size(); + return IntStream.iterate(0, i -> i + step) + .limit(len) + .filter(i -> i < len) + .mapToObj(i -> { + Leaf right = i + 1 < len ? createLeaf(hashList.get(i + 1)) : null; + return createLeaf(createLeaf(hashList.get(i)), right); + }).collect(Collectors.toList()); + } + + private static Leaf createLeaf(Leaf left, Leaf right) { + Leaf leaf = new Leaf(); + leaf.hash = right == null ? left.hash : computeHash(left.hash, right.hash); + return leaf; + } + + private static Leaf createLeaf(Sha256Hash hash) { + Leaf leaf = new Leaf(); + leaf.hash = hash; + return leaf; + } + + private static Sha256Hash computeHash(Sha256Hash leftHash, Sha256Hash rightHash) { + return Sha256Hash.of(true, + leftHash.getByteString().concat(rightHash.getByteString()).toByteArray()); + } + + @Getter + private static class Leaf { + + private Sha256Hash hash; + } +} diff --git a/plugins/src/main/java/org/tron/plugins/utils/Sha256Hash.java b/plugins/src/main/java/org/tron/plugins/utils/Sha256Hash.java index 5fe80601b66..67e6e64ea79 100644 --- a/plugins/src/main/java/org/tron/plugins/utils/Sha256Hash.java +++ b/plugins/src/main/java/org/tron/plugins/utils/Sha256Hash.java @@ -21,6 +21,7 @@ import com.google.common.io.ByteStreams; import com.google.common.primitives.Ints; +import com.google.protobuf.ByteString; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -39,7 +40,7 @@ public class Sha256Hash implements Serializable, Comparable { public static final int LENGTH = 32; // bytes - + public static final Sha256Hash ZERO_HASH = wrap(new byte[LENGTH]); private final byte[] bytes; /** @@ -184,6 +185,13 @@ public byte[] getBytes() { return bytes; } + /** + * For pb return ByteString. + */ + public ByteString getByteString() { + return ByteString.copyFrom(bytes); + } + @Override public int compareTo(final Sha256Hash other) { diff --git a/plugins/src/main/java/org/tron/plugins/utils/db/DBInterface.java b/plugins/src/main/java/org/tron/plugins/utils/db/DBInterface.java index b0f7c58c587..513e021c83c 100644 --- a/plugins/src/main/java/org/tron/plugins/utils/db/DBInterface.java +++ b/plugins/src/main/java/org/tron/plugins/utils/db/DBInterface.java @@ -18,4 +18,6 @@ public interface DBInterface extends Closeable { void close() throws IOException; + String getName(); + } diff --git a/plugins/src/main/java/org/tron/plugins/utils/db/DbTool.java b/plugins/src/main/java/org/tron/plugins/utils/db/DbTool.java index 6e8df4c59fb..429025e8f8b 100644 --- a/plugins/src/main/java/org/tron/plugins/utils/db/DbTool.java +++ b/plugins/src/main/java/org/tron/plugins/utils/db/DbTool.java @@ -23,7 +23,7 @@ public class DbTool { private static final Map dbMap = Maps.newConcurrentMap(); - enum DbType { + public enum DbType { LevelDB, RocksDB } @@ -83,11 +83,11 @@ public static DBInterface getDB(String sourceDir, String dbName, DbType type) DBInterface db; switch (type) { case LevelDB: - db = openLevelDb(path); + db = openLevelDb(path, dbName); dbMap.put(path.toString(), db); break; case RocksDB: - db = openRocksDb(path); + db = openRocksDb(path, dbName); dbMap.put(path.toString(), db); break; default: @@ -114,9 +114,9 @@ public static DBInterface getDB(Path sourceDir, String dbName) DbType type = getDbType(sourceDir.toString(), dbName); switch (type) { case LevelDB: - return openLevelDb(path); + return openLevelDb(path, dbName); case RocksDB: - return openRocksDb(path); + return openRocksDb(path, dbName); default: throw new IllegalStateException("Unexpected value: " + type); } @@ -175,12 +175,12 @@ private static DbType getDbType(String sourceDir, String dbName) { } } - private static LevelDBImpl openLevelDb(Path db) throws IOException { - return new LevelDBImpl(DBUtils.newLevelDb(db)); + private static LevelDBImpl openLevelDb(Path db, String name) throws IOException { + return new LevelDBImpl(DBUtils.newLevelDb(db), name); } - private static RocksDBImpl openRocksDb(Path db) throws RocksDBException { - return new RocksDBImpl(DBUtils.newRocksDb(db)); + private static RocksDBImpl openRocksDb(Path db, String name) throws RocksDBException { + return new RocksDBImpl(DBUtils.newRocksDb(db), name); } diff --git a/plugins/src/main/java/org/tron/plugins/utils/db/LevelDBImpl.java b/plugins/src/main/java/org/tron/plugins/utils/db/LevelDBImpl.java index 3a89e77af40..511f4dfd5b4 100644 --- a/plugins/src/main/java/org/tron/plugins/utils/db/LevelDBImpl.java +++ b/plugins/src/main/java/org/tron/plugins/utils/db/LevelDBImpl.java @@ -2,6 +2,7 @@ import com.google.common.collect.Streams; import java.io.IOException; +import lombok.Getter; import org.iq80.leveldb.DB; import org.iq80.leveldb.ReadOptions; @@ -10,8 +11,12 @@ public class LevelDBImpl implements DBInterface { private DB leveldb; - public LevelDBImpl(DB leveldb) { + @Getter + private final String name; + + public LevelDBImpl(DB leveldb, String name) { this.leveldb = leveldb; + this.name = name; } @Override diff --git a/plugins/src/main/java/org/tron/plugins/utils/db/RocksDBImpl.java b/plugins/src/main/java/org/tron/plugins/utils/db/RocksDBImpl.java index 88b25b0413f..50957bbe61b 100644 --- a/plugins/src/main/java/org/tron/plugins/utils/db/RocksDBImpl.java +++ b/plugins/src/main/java/org/tron/plugins/utils/db/RocksDBImpl.java @@ -1,6 +1,7 @@ package org.tron.plugins.utils.db; import java.io.IOException; +import lombok.Getter; import org.rocksdb.RocksDBException; import org.rocksdb.RocksIterator; @@ -8,8 +9,12 @@ public class RocksDBImpl implements DBInterface { private org.rocksdb.RocksDB rocksDB; - public RocksDBImpl(org.rocksdb.RocksDB rocksDB) { + @Getter + private final String name; + + public RocksDBImpl(org.rocksdb.RocksDB rocksDB, String name) { this.rocksDB = rocksDB; + this.name = name; } @Override diff --git a/plugins/src/test/java/org/tron/plugins/DbCopyTest.java b/plugins/src/test/java/org/tron/plugins/DbCopyTest.java index c5cc8f2bb31..9e488a592aa 100644 --- a/plugins/src/test/java/org/tron/plugins/DbCopyTest.java +++ b/plugins/src/test/java/org/tron/plugins/DbCopyTest.java @@ -11,7 +11,7 @@ public class DbCopyTest extends DbTest { @Test public void testRun() { String[] args = new String[] { "db", "cp", INPUT_DIRECTORY, - tmpDir + UUID.randomUUID()}; + genarateTmpDir()}; Assert.assertEquals(0, cli.execute(args)); } @@ -32,7 +32,7 @@ public void testNotExist() { @Test public void testEmpty() throws IOException { String[] args = new String[] {"db", "cp", temporaryFolder.newFolder().toString(), - tmpDir + UUID.randomUUID()}; + genarateTmpDir()}; Assert.assertEquals(0, cli.execute(args)); } @@ -46,7 +46,7 @@ public void testDestIsExist() throws IOException { @Test public void testSrcIsFile() throws IOException { String[] args = new String[] {"db", "cp", temporaryFolder.newFile().toString(), - tmpDir + UUID.randomUUID()}; + genarateTmpDir()}; Assert.assertEquals(403, cli.execute(args)); } diff --git a/plugins/src/test/java/org/tron/plugins/DbLiteTest.java b/plugins/src/test/java/org/tron/plugins/DbLiteTest.java index 8baf48b0b48..b4c66c9820f 100644 --- a/plugins/src/test/java/org/tron/plugins/DbLiteTest.java +++ b/plugins/src/test/java/org/tron/plugins/DbLiteTest.java @@ -1,5 +1,7 @@ package org.tron.plugins; +import static org.tron.common.utils.PublicMethod.getRandomPrivateKey; + import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import java.io.File; @@ -22,8 +24,6 @@ import org.tron.common.utils.Utils; import org.tron.core.config.DefaultConfig; import org.tron.core.config.args.Args; -import org.tron.core.services.RpcApiService; -import org.tron.core.services.interfaceOnSolidity.RpcApiServiceOnSolidity; import picocli.CommandLine; @Slf4j @@ -47,8 +47,6 @@ public class DbLiteTest { public void startApp() { context = new TronApplicationContext(DefaultConfig.class); appTest = ApplicationFactory.create(context); - appTest.addService(context.getBean(RpcApiService.class)); - appTest.addService(context.getBean(RpcApiServiceOnSolidity.class)); appTest.startup(); String fullNode = String.format("%s:%d", "127.0.0.1", @@ -76,6 +74,7 @@ public void init() throws IOException { // allow account root Args.getInstance().setAllowAccountStateRoot(1); Args.getInstance().setRpcPort(PublicMethod.chooseRandomPort()); + Args.getInstance().setRpcEnable(true); databaseDir = Args.getInstance().getStorage().getDbDirectory(); // init dbBackupConfig to avoid NPE Args.getInstance().dbBackupConfig = DbBackupConfig.getInstance(); @@ -117,8 +116,8 @@ void testTools(String dbType, int checkpointVersion) cli.execute(argsForSnapshot); // start fullNode startApp(); - // produce transactions for 6 seconds - generateSomeTransactions(6); + // produce transactions + generateSomeTransactions(checkpointVersion == 1 ? 6 : 18); // stop the node shutdown(); // generate history @@ -139,7 +138,7 @@ void testTools(String dbType, int checkpointVersion) } // start and validate the snapshot startApp(); - generateSomeTransactions(6); + generateSomeTransactions(checkpointVersion == 1 ? 18 : 6); // stop the node shutdown(); // merge history @@ -159,7 +158,7 @@ private void generateSomeTransactions(int during) { ECKey ecKey2 = new ECKey(Utils.getRandom()); byte[] address = ecKey2.getAddress(); - String sunPri = "cba92a516ea09f620a16ff7ee95ce0df1d56550a8babe9964981a7144c8a784a"; + String sunPri = getRandomPrivateKey(); byte[] sunAddress = PublicMethod.getFinalAddress(sunPri); PublicMethod.sendcoin(address, 1L, sunAddress, sunPri, blockingStubFull); diff --git a/plugins/src/test/java/org/tron/plugins/DbRootTest.java b/plugins/src/test/java/org/tron/plugins/DbRootTest.java new file mode 100644 index 00000000000..b86688f77d5 --- /dev/null +++ b/plugins/src/test/java/org/tron/plugins/DbRootTest.java @@ -0,0 +1,82 @@ +package org.tron.plugins; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; +import lombok.extern.slf4j.Slf4j; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.rocksdb.RocksDBException; +import org.tron.plugins.utils.DBUtils; +import org.tron.plugins.utils.db.DBInterface; +import org.tron.plugins.utils.db.DbTool; +import org.tron.plugins.utils.db.LevelDBImpl; +import picocli.CommandLine; + +@Slf4j +public class DbRootTest { + + @Rule + public final TemporaryFolder folder = new TemporaryFolder(); + + CommandLine cli = new CommandLine(new Toolkit()); + + private static final String NORMAL_DB = "normal"; + private static final String EMPTY_DB = "empty"; + private static final String ERROR_DB = "error"; + + @Test + public void testRoot() throws IOException, RocksDBException { + + File file = folder.newFolder(); + + File database = Paths.get(file.getPath(),"database").toFile(); + Assert.assertTrue(database.mkdirs()); + + + try (DBInterface normal = DbTool.getDB(database.toString(), NORMAL_DB, DbTool.DbType.LevelDB); + DBInterface empty = DbTool.getDB(database.toString(), EMPTY_DB, DbTool.DbType.RocksDB)) { + for (int i = 0; i < 10; i++) { + normal.put(("" + i).getBytes(), (NORMAL_DB + "-" + i).getBytes()); + } + } + + String[] args = new String[] {"db", "root", database.toString(), + "--db", NORMAL_DB, "--db", EMPTY_DB}; + Assert.assertEquals(0, cli.execute(args)); + args = new String[] {"db", "root", database.toString(), + "--db", NORMAL_DB}; + Assert.assertEquals(0, cli.execute(args)); + args = new String[] {"db", "root", database.toString(), + "--db", EMPTY_DB}; + Assert.assertEquals(0, cli.execute(args)); + + try (DBInterface errorDb = new LevelDBImpl( + DBUtils.newLevelDb(Paths.get(database.toString(), ERROR_DB)), ERROR_DB)) { + for (int i = 0; i < 10; i++) { + errorDb.put(("" + i).getBytes(), (ERROR_DB + "-" + i).getBytes()); + } + args = new String[] {"db", "root", database.toString(), "--db", ERROR_DB}; + Assert.assertEquals(1, cli.execute(args)); + } + + } + + @Test + public void testHelp() { + String[] args = new String[] {"db", "root", "-h"}; + Assert.assertEquals(0, cli.execute(args)); + } + + @Test + public void testEmpty() throws IOException { + File file = folder.newFolder(); + File database = Paths.get(file.getPath(),"database").toFile(); + String[] args = new String[] {"db", "root", database.toString()}; + Assert.assertEquals(404, cli.execute(args)); + Assert.assertTrue(database.mkdirs()); + Assert.assertEquals(404, cli.execute(args)); + } +} diff --git a/plugins/src/test/java/org/tron/plugins/DbTest.java b/plugins/src/test/java/org/tron/plugins/DbTest.java index 8a5f9de4a67..8605fa18d50 100644 --- a/plugins/src/test/java/org/tron/plugins/DbTest.java +++ b/plugins/src/test/java/org/tron/plugins/DbTest.java @@ -86,4 +86,14 @@ private static void initDB(File file) throws IOException { } } } + + /** + * Generate a not-exist temporary directory path. + * @return temporary path + */ + public String genarateTmpDir() { + File dir = Paths.get(tmpDir, UUID.randomUUID().toString()).toFile(); + dir.deleteOnExit(); + return dir.getPath(); + } } diff --git a/plugins/src/test/java/org/tron/plugins/utils/ByteArrayTest.java b/plugins/src/test/java/org/tron/plugins/utils/ByteArrayTest.java new file mode 100644 index 00000000000..300c983db3a --- /dev/null +++ b/plugins/src/test/java/org/tron/plugins/utils/ByteArrayTest.java @@ -0,0 +1,44 @@ +package org.tron.plugins.utils; + +import lombok.extern.slf4j.Slf4j; +import org.junit.Assert; +import org.junit.Test; + +@Slf4j +public class ByteArrayTest { + + @Test + public void testToStrToInt() { + String test = "abc"; + byte[] testBytes = test.getBytes(); + Assert.assertEquals(test, ByteArray.toStr(testBytes)); + + int i = 5; + Assert.assertEquals(ByteArray.toInt(ByteArray.fromInt(i)), 5); + } + + @Test + public void testFromHexString() { + Assert.assertArrayEquals(ByteArray.EMPTY_BYTE_ARRAY, ByteArray.fromHexString(null)); + + Assert.assertArrayEquals(ByteArray.fromHexString("12"), ByteArray.fromHexString("0x12")); + + Assert.assertArrayEquals(ByteArray.fromHexString("0x2"), ByteArray.fromHexString("0x02")); + } + + @Test + public void testCompareUnsigned() { + byte[] a = new byte[] {1, 2}; + Assert.assertEquals(0, ByteArray.compareUnsigned(a, a)); + Assert.assertEquals(-1, ByteArray.compareUnsigned(null, a)); + Assert.assertEquals(1, ByteArray.compareUnsigned(a, null)); + + byte[] b = new byte[] {1, 3}; + Assert.assertEquals(-1, ByteArray.compareUnsigned(a, b)); + Assert.assertEquals(1, ByteArray.compareUnsigned(b, a)); + + byte[] c = new byte[] {1, 2, 3}; + Assert.assertEquals(-1, ByteArray.compareUnsigned(a, c)); + Assert.assertEquals(1, ByteArray.compareUnsigned(c, a)); + } +} diff --git a/protocol/build.gradle b/protocol/build.gradle index e790e480fa0..535fac43a65 100644 --- a/protocol/build.gradle +++ b/protocol/build.gradle @@ -1,21 +1,23 @@ apply plugin: 'com.google.protobuf' -def protobufVersion = '3.21.12' -def grpcVersion = '1.52.1' +def protobufVersion = '3.25.5' +def grpcVersion = '1.60.0' dependencies { - compile group: 'com.google.protobuf', name: 'protobuf-java', version: protobufVersion - compile group: 'com.google.protobuf', name: 'protobuf-java-util', version: protobufVersion - compile group: 'net.jcip', name: 'jcip-annotations', version: '1.0' + api group: 'com.google.protobuf', name: 'protobuf-java', version: protobufVersion + api group: 'com.google.protobuf', name: 'protobuf-java-util', version: protobufVersion + api 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: grpcVersion - compile group: 'io.grpc', name: 'grpc-protobuf', version: grpcVersion - compile group: 'io.grpc', name: 'grpc-stub', version: grpcVersion + api group: 'io.grpc', name: 'grpc-netty', version: grpcVersion + api group: 'io.grpc', name: 'grpc-protobuf', version: grpcVersion + api group: 'io.grpc', name: 'grpc-stub', version: grpcVersion + api group: 'io.grpc', name: 'grpc-services', version: grpcVersion + // end google grpc - compile group: 'com.google.api.grpc', name: 'proto-google-common-protos', version: '2.15.0' + api group: 'com.google.api.grpc', name: 'proto-google-common-protos', version: '2.15.0' } tasks.matching { it instanceof Test }.all { @@ -64,3 +66,4 @@ clean.doFirst { delete "src/main/java" } +processResources.dependsOn(generateProto) // explicit_dependency diff --git a/protocol/gradle/wrapper/gradle-wrapper.jar b/protocol/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 28861d273a5..00000000000 Binary files a/protocol/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/protocol/gradle/wrapper/gradle-wrapper.properties b/protocol/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 1b0ff046d00..00000000000 --- a/protocol/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Thu Aug 01 15:17:43 CST 2019 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip diff --git a/protocol/src/main/protos/api/api.proto b/protocol/src/main/protos/api/api.proto index 9a7534cf6ce..2505fa48d6f 100644 --- a/protocol/src/main/protos/api/api.proto +++ b/protocol/src/main/protos/api/api.proto @@ -1051,6 +1051,8 @@ message Return { SERVER_BUSY = 9; NO_CONNECTION = 10; NOT_ENOUGH_EFFECTIVE_CONNECTION = 11; + BLOCK_UNSOLIDIFIED = 12; + OTHER_ERROR = 20; } diff --git a/protocol/src/main/protos/core/Tron.proto b/protocol/src/main/protos/core/Tron.proto index 2fc08901e93..2ffefbf9f3e 100644 --- a/protocol/src/main/protos/core/Tron.proto +++ b/protocol/src/main/protos/core/Tron.proto @@ -407,6 +407,7 @@ message Transaction { UNKNOWN = 13; TRANSFER_FAILED = 14; INVALID_CODE = 15; + // please fill in the order according to the serial number } int64 fee = 1; code ret = 2; @@ -626,6 +627,7 @@ message HelloMessage { bytes signature = 8; int32 nodeType = 9; int64 lowestBlockNum = 10; + bytes codeVersion = 11; } message InternalTransaction { diff --git a/quickstart.md b/quickstart.md index 5359af00060..6eda855f1e9 100644 --- a/quickstart.md +++ b/quickstart.md @@ -28,8 +28,9 @@ cd java-tron #### Build the docker image -Use below command to start the build: +Use the command below to navigate to the docker directory and start the build: ``` +cd docker docker build -t tronprotocol/java-tron . ``` @@ -100,7 +101,6 @@ If everything goes well, your terminal console output will look like following : Run Console Output - ``` [PM2] Spawning PM2 daemon with pm2_home=/root/.pm2 [PM2] PM2 Successfully daemonized @@ -166,25 +166,6 @@ If everything goes well, your terminal console output will look like following : (8) TYjQd4xrLZQGYMdLJqsTCuXVGapPqUp9ZX (10000 TRX) (9) THCw6hPZpFcLCWDcsZg3W77rXZ9rJQPncD (10000 TRX) - Private Keys - ================== - - (0) 2b2bddbeea87cecedcaf51eef55877b65725f709d2c0fcdfea0cb52d80acd52b - (1) f08759925316dc6344af538ebe3a619aeab836a0c254adca903cc764f87b0ee9 - (2) 1afc9f033cf9c6058db366b78a9f1b9c909b1b83397c9aed795afa05e9017511 - (3) f8f5bc70e91fc177eefea43b68c97b66536ac317a9300639e9d32a9db2f18a1f - (4) 031015272915917056c117d3cc2a03491a8f22ef450af83f6783efddf7064c59 - (5) 5eb25e2c1144f216aa99bbe2139d84bb6dedfb2c1ed72f3df6684a4c6d2cd96b - (6) f0b781da23992e6a3f536cb60917c3eb6a9c5434fcf441fcb8d7c58c01d6b70e - (7) 158f60a4379688a77d4a420e2f2a3e014ebf9ed0a1a093d7dc01ba23ebc5c970 - (8) e9342bb9108f46573804890a5301530c2834dce3703cd51ab77fba6161afec00 - (9) 2e9f0c507d2ea98dc4005a1afb1b743c629f7c145ccb55f38f75ae73cf8f605c - - HD Wallet - ================== - Mnemonic: border pulse twenty cruise grief shy need raw clean possible begin climb - Base HD Path: m/44'/60'/0'/0/{account_index} - ``` diff --git a/run.md b/run.md index 112478a4db5..c0ecbe4d91f 100644 --- a/run.md +++ b/run.md @@ -14,9 +14,9 @@ Use the [Testnet Config](https://github.com/tronprotocol/TronDeployment/blob/mas **Use the executable JAR(Recommended way):** ```bash -java -jar FullNode.jar -p your private key --witness -c your config.conf(Example:/data/java-tron/config.conf) +java -jar FullNode.jar -p --witness -c your config.conf(Example:/data/java-tron/config.conf) Example: -java -jar FullNode.jar -p 650950B193DDDDB35B6E48912DD28F7AB0E7140C1BFDEFD493348F02295BD812 --witness -c /data/java-tron/config.conf +java -jar FullNode.jar -p --witness -c /data/java-tron/config.conf ``` @@ -65,9 +65,9 @@ Then observe whether block synchronization success,If synchronization successf ```bash cd build/libs -java -jar FullNode.jar -p your private key --witness -c your config.conf (Example:/data/java-tron/config.conf) +java -jar FullNode.jar -p --witness -c your config.conf (Example:/data/java-tron/config.conf) Example: -java -jar FullNode.jar -p 650950B193DDDDB35B6E48912DD28F7AB0E7140C1BFDEFD493348F02295BD812 --witness -c /data/java-tron/config.conf +java -jar FullNode.jar -p --witness -c /data/java-tron/config.conf ``` @@ -81,7 +81,7 @@ java -jar FullNode.jar -p 650950B193DDDDB35B6E48912DD28F7AB0E7140C1BFDEFD493348F Using TaskInputs.file() with something that doesn't resolve to a File object has been deprecated and is scheduled to be removed in Gradle 5.0. Use TaskInputs.files() instead. > Task :run -20:39:22.749 INFO [o.t.c.c.a.Args] private.key = 63e62a71ed39e30bac7223097a173924aad5855959de517ff2987b0e0ec89f1a +20:39:22.749 INFO [o.t.c.c.a.Args] private.key = 63e62a71ed3... 20:39:22.816 WARN [o.t.c.c.a.Args] localwitness size must be one, get the first one 20:39:22.832 INFO [o.t.p.FullNode] Here is the help message.output-directory/ 三月 22, 2018 8:39:23 下午 org.tron.core.services.RpcApiService start diff --git a/shell.md b/shell.md index e457be3c790..700067a9aa3 100644 --- a/shell.md +++ b/shell.md @@ -20,7 +20,7 @@ The script is available in the java-tron project at [github](https://github.com/ sh start.sh --run ``` - Start the servive with options. + Start the service with options. ``` sh start.sh --run -j /data/FullNode.jar -c /data/config.conf -d /data/output-directory @@ -162,7 +162,7 @@ Get the latest released version. sh start.sh --release --run ``` -Following file structure will be generated after executed the above command and the `FullNode.jar` will be started. +Following file structure will be generated after executing the above command and the `FullNode.jar` will be started. ``` ├── ...