From d61e134c40094aed2b56146e3243f596d7d79139 Mon Sep 17 00:00:00 2001 From: vividctrlalt Date: Fri, 27 Feb 2026 15:46:29 +0800 Subject: [PATCH 1/8] ci: make build job depend on PR lint check (#6559) --- .github/workflows/pr-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index f4d77147dd..731bfbbce9 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -68,6 +68,7 @@ jobs: build: name: Build (JDK ${{ matrix.java }} / ${{ matrix.arch }}) + needs: pr-lint runs-on: ${{ matrix.runner }} strategy: fail-fast: false From 13b68eac093652e95f2dfb8c83e5ae7acea70030 Mon Sep 17 00:00:00 2001 From: vividctrlalt Date: Sat, 28 Feb 2026 19:19:23 +0800 Subject: [PATCH 2/8] ci: enhance PR lint and add PR guidelines to CONTRIBUTING.md (#6564) --- .github/workflows/pr-check.yml | 83 ++++++++++++++++++--------- CONTRIBUTING.md | 102 +++++++++++++++++++++++++++++++-- 2 files changed, 151 insertions(+), 34 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 731bfbbce9..f4593f64d4 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -15,55 +15,82 @@ jobs: runs-on: ubuntu-latest steps: - - name: Check PR title format + - name: Validate PR title and description uses: actions/github-script@v7 with: script: | const title = context.payload.pull_request.title; - + const body = context.payload.pull_request.body; const errors = []; + const warnings = []; + + const allowedTypes = ['feat','fix','refactor','docs','style','test','chore','ci','perf','build','revert']; + const knownScopes = [ + 'framework','chainbase','actuator','consensus','common','crypto','plugins','protocol', + 'net','db','vm','tvm','api','jsonrpc','rpc','http','event','config', + 'block','proposal','trie','log','metrics','test','docker','version', + 'freezeV2','DynamicEnergy','stable-coin','reward','lite','toolkit' + ]; - // Title should not be empty or too short + // 1. Title length check if (!title || title.trim().length < 10) { errors.push('PR title is too short (minimum 10 characters).'); } - - // Title should not exceed 72 characters - if (title.length > 72) { + if (title && title.length > 72) { errors.push(`PR title is too long (${title.length}/72 characters).`); } - // Title should follow conventional format: type: description - // Allowed types: feat, fix, refactor, docs, style, test, chore, ci, perf, build, revert - const conventionalRegex = /^(feat|fix|refactor|docs|style|test|chore|ci|perf|build|revert)(\(.+\))?:\s.+/; - if (!conventionalRegex.test(title)) { + // 2. Conventional format check + const conventionalRegex = /^(feat|fix|refactor|docs|style|test|chore|ci|perf|build|revert)(\([^)]+\))?:\s\S.*/; + if (title && !conventionalRegex.test(title)) { errors.push( - 'PR title must follow conventional format: `type: description`\n' + - 'Allowed types: feat, fix, refactor, docs, style, test, chore, ci, perf, build, revert\n' + - 'Example: `feat: add new transaction validation`' + 'PR title must follow conventional format: `type(scope): description`\n' + + ' Allowed types: ' + allowedTypes.map(t => `\`${t}\``).join(', ') + '\n' + + ' Example: `feat(tvm): add blob opcodes`' ); } - if (errors.length > 0) { - const message = '### PR Title Check Failed\n\n' + errors.map(e => `- ${e}`).join('\n'); - core.setFailed(message); - } else { - core.info('PR title format is valid.'); + // 3. No trailing period + if (title && title.endsWith('.')) { + errors.push('PR title should not end with a period (.).'); } - - name: Check PR description - uses: actions/github-script@v7 - with: - script: | - const body = context.payload.pull_request.body; + // 4. Description part should not start with a capital letter + if (title) { + const descMatch = title.match(/^\w+(?:\([^)]+\))?:\s*(.+)/); + if (descMatch) { + const desc = descMatch[1]; + if (/^[A-Z]/.test(desc)) { + errors.push('Description should not start with a capital letter.'); + } + } + } + + // 5. Scope validation (warning only) + if (title) { + const scopeMatch = title.match(/^\w+\(([^)]+)\):/); + if (scopeMatch && !knownScopes.includes(scopeMatch[1])) { + warnings.push(`Unknown scope \`${scopeMatch[1]}\`. See CONTRIBUTING.md for known scopes.`); + } + } + // 6. PR description check if (!body || body.trim().length < 20) { - core.setFailed( - '### PR Description Check Failed\n\n' + - 'PR description is too short or empty. Please describe what this PR does and why.' - ); + errors.push('PR description is too short or empty (minimum 20 characters). Please describe what this PR does and why.'); + } + + // Output warnings + for (const w of warnings) { + core.warning(w); + } + + // Output result + if (errors.length > 0) { + const docLink = 'See [CONTRIBUTING.md](https://github.com/' + context.repo.owner + '/' + context.repo.repo + '/blob/develop/CONTRIBUTING.md#pull-request-guidelines) for details.'; + const message = '### PR Lint Failed\n\n' + errors.map(e => `- ${e}`).join('\n') + '\n\n' + docLink; + core.setFailed(message); } else { - core.info('PR description is valid.'); + core.info('PR lint passed.'); } build: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 79bf8567a6..6b5e9aacf8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,6 +16,9 @@ Here are some guidelines to get started quickly and easily: - [Commit Messages](#Commit-Messages) - [Branch Naming Conventions](#Branch-Naming-Conventions) - [Pull Request Guidelines](#Pull-Request-Guidelines) + - [PR Title Format](#PR-Title-Format) + - [Type and Scope Reference](#Type-and-Scope-Reference) + - [PR Description](#PR-Description) - [Special Situations And How To Deal With Them](#Special-Situations-And-How-To-Deal-With-Them) - [Conduct](#Conduct) @@ -172,8 +175,12 @@ The message header is a single line that contains succinct description of the ch * refactor (refactoring production code) * test (adding or refactoring tests. no production code change) * chore (updating grunt tasks etc. no production code change) +* ci (CI/CD configuration) +* perf (performance improvement) +* build (build system changes) +* revert (reverting a previous commit) -The `scope` can be anything specifying place of the commit change. For example:`protobuf`,`api`,`test`,`docs`,`build`,`db`,`net`.You can use * if there isn't a more fitting scope. +The `scope` can be anything specifying place of the commit change. For example: `framework`, `api`, `tvm`, `db`, `net`. For a full list of scopes, see [Type and Scope Reference](#type-and-scope-reference). You can use `*` if there isn't a more fitting scope. The subject contains a succinct description of the change: 1. Limit the subject line, which briefly describes the purpose of the commit, to 50 characters. @@ -204,13 +211,96 @@ If the purpose of this submission is to modify one issue, you need to refer to t 4. Use `feature/` as the prefix of the `feature` branch, briefly describe the feature in the name, and connect words with underline (e.g., feature/new_resource_model, etc.). ### Pull Request Guidelines +#### PR Title Format + +PR titles must follow the conventional commit format and will be checked by CI: + +``` +type(scope): description +``` + +| Rule | Requirement | +|------|-------------| +| Format | `type: description` or `type(scope): description` | +| Length | 10 ~ 72 characters | +| Type must be one of | `feat` `fix` `refactor` `docs` `style` `test` `chore` `ci` `perf` `build` `revert` | + +#### Type and Scope Reference + +**Type Reference** + +| Type | Purpose | Example | +|------|---------|---------| +| `feat` | New feature | `feat(tvm): add blob opcodes` | +| `fix` | Bug fix | `fix(db): improve resource management` | +| `docs` | Documentation only | `docs: fix formatting issues in README` | +| `style` | Code style (no logic change) | `style: fix import order and line length` | +| `refactor` | Code refactoring (no behavior change) | `refactor(config): simplify parameters` | +| `test` | Adding or updating tests | `test(vm): add unit tests for opcodes` | +| `chore` | Build tooling, dependencies, etc. | `chore(version): bump to v4.7.8` | +| `ci` | CI/CD configuration | `ci: add PR check workflow` | +| `perf` | Performance improvement | `perf(trie): optimize query performance` | +| `build` | Build system changes | `build: add aarch64 support for RocksDB` | +| `revert` | Reverting a previous commit | `revert: restore ApiUtilTest.java` | + +**Module Scopes** + +| Scope | Description | +|-------|-------------| +| `framework` | Core framework, services, APIs, RPC interfaces | +| `chainbase` | Blockchain storage, state management, database layer | +| `actuator` | Transaction execution engine, smart contract operations | +| `consensus` | Consensus mechanism (DPoS, PBFT) | +| `common` | Common utilities, configuration, shared infrastructure | +| `crypto` | Cryptographic functions, key management, signatures | +| `plugins` | Node tools (Toolkit, ArchiveManifest, database plugins) | +| `protocol` | Protocol definitions, protobuf messages, gRPC contracts | + +**Functional Domain Scopes** + +| Scope | Description | Example | +|-------|-------------|---------| +| `net` | P2P networking, message handling, peer sync | `feat(net): optimize sync logic` | +| `db` | Database operations, queries, persistence | `fix(db): handle null pointer in query` | +| `vm` / `tvm` | Virtual machine, bytecode execution, EIP impl | `feat(tvm): implement eip-7823` | +| `api` | HTTP/gRPC API endpoints | `fix(api): handle null response` | +| `jsonrpc` | JSON-RPC interface (Ethereum-compatible) | `fix(jsonrpc): support blockHash param` | +| `rpc` | gRPC services and methods | `fix(rpc): handle timeout correctly` | +| `http` | HTTP server and endpoints | `feat(http): add new endpoint` | +| `event` | Event logging and event service | `feat(event): optimize concurrent writes` | +| `config` | Configuration management, feature flags | `refactor(config): simplify parameters` | +| `block` | Block processing, validation, structure | `fix(block): validate block header` | +| `proposal` | On-chain governance proposals | `feat(proposal): add Osaka proposal` | +| `trie` | Merkle tree, state trie operations | `perf(trie): optimize tree query` | +| `log` | Application logging | `refactor(log): reduce noise` | +| `metrics` | Performance monitoring, Prometheus | `feat(metrics): add Prometheus support` | +| `test` | Test infrastructure and utilities | `test(proposal): add unit test cases` | +| `docker` | Docker containerization and deployment | `feat(docker): add ARM64 support` | +| `version` | Version and release management | `chore(version): bump to v4.7.8` | + +**Feature Scopes** + +| Scope | Description | +|-------|-------------| +| `freezeV2` | Resource delegation / freeze-unfreeze V2 mechanism | +| `DynamicEnergy` | Dynamic energy pricing mechanism | +| `stable-coin` | Stable coin features and operations | +| `reward` | Block producer rewards distribution | +| `lite` | Lite fullnode functionality | +| `toolkit` | Node maintenance tools (Toolkit.jar) | + +#### PR Description + +- PR description must not be empty, minimum **20 characters**. +- Should explain **what** the PR does and **why**. + +#### General Rules + 1. Create one PR for one issue. 2. Avoid massive PRs. -3. Write an overview of the purpose of the PR in its title. -4. Write a description of the PR for future reviewers. -5. Elaborate on the feedback you need (if any). -6. Do not capitalize the first letter. -7. Do not put a period (.) in the end. +3. Elaborate on the feedback you need (if any). +4. Do not capitalize the first letter of the description. +5. Do not put a period (.) at the end of the title. From f24db7b26c9fac1db2bfd9d426812eefd2ff955a Mon Sep 17 00:00:00 2001 From: vividcoder Date: Sun, 1 Mar 2026 22:40:38 +0800 Subject: [PATCH 3/8] refactor: deprecate meaningless net.type and add net.addressPrefix net.type had no practical effect; add net.addressPrefix to explicitly set the address prefix for backward compatibility. - Deprecate net.type, add net.addressPrefix to all .conf files - Add configFilePath to CommonParameter to store resolved config path - Simplify DynamicArgs to reuse configFilePath from startup - Remove unused TESTNET constants and NET_TYPE/NET_CONF constants --- .../common/parameter/CommonParameter.java | 3 ++ .../src/main/java/org/tron/core/Constant.java | 6 +-- .../java/org/tron/core/config/args/Args.java | 19 +++++++-- .../tron/core/config/args/DynamicArgs.java | 40 +++++-------------- .../main/java/org/tron/program/FullNode.java | 3 +- .../src/main/resources/config-backup.conf | 8 +++- framework/src/main/resources/config-beta.conf | 8 +++- .../src/main/resources/config-localtest.conf | 8 +++- .../src/main/resources/config-test-net.conf | 8 +++- framework/src/main/resources/config.conf | 10 +++-- .../java/org/tron/common/TestConstants.java | 1 + .../common/runtime/vm/VMContractTestBase.java | 3 +- .../tron/common/utils/client/Parameter.java | 5 +-- .../tron/core/capsule/BlockCapsuleTest.java | 13 ++---- .../org/tron/core/config/args/ArgsTest.java | 10 +++-- .../core/config/args/DynamicArgsTest.java | 9 ++++- .../core/services/DelegationServiceTest.java | 3 +- .../ratelimiter/GlobalRateLimiterTest.java | 3 +- framework/src/test/resources/args-test.conf | 8 +++- .../src/test/resources/config-localtest.conf | 8 +++- .../test/resources/config-test-dbbackup.conf | 8 +++- .../src/test/resources/config-test-index.conf | 8 +++- .../test/resources/config-test-mainnet.conf | 8 +++- .../resources/config-test-storagetest.conf | 8 +++- framework/src/test/resources/config-test.conf | 8 +++- 25 files changed, 125 insertions(+), 91 deletions(-) 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 0583962f26..d1210b27d6 100644 --- a/common/src/main/java/org/tron/common/parameter/CommonParameter.java +++ b/common/src/main/java/org/tron/common/parameter/CommonParameter.java @@ -32,6 +32,9 @@ public class CommonParameter { @Parameter(names = {"-c", "--config"}, description = "Config file (default:config.conf)") public String shellConfFileName = ""; @Getter + @Setter + public String configFilePath = ""; + @Getter @Parameter(names = {"-d", "--output-directory"}, description = "Data directory for the databases (default:output-directory)") public String outputDirectory = "output-directory"; diff --git a/common/src/main/java/org/tron/core/Constant.java b/common/src/main/java/org/tron/core/Constant.java index 01a1feaf43..c639addfe7 100644 --- a/common/src/main/java/org/tron/core/Constant.java +++ b/common/src/main/java/org/tron/core/Constant.java @@ -2,8 +2,6 @@ public class Constant { - //config for testnet, mainnet, beta - public static final String NET_CONF = "config.conf"; // locate in storageDbDirectory, store the db infos, // now only has the split block number @@ -13,8 +11,6 @@ public class Constant { public static final byte ADD_PRE_FIX_BYTE_MAINNET = (byte) 0x41; //41 + address 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; @@ -67,7 +63,7 @@ public class Constant { // Configuration items - public static final String NET_TYPE = "net.type"; + public static final String NET_ADDRESS_PREFIX = "net.addressPrefix"; public static final String TESTNET = "testnet"; public static final String LOCAL_WITNESS = "localwitness"; public static final String LOCAL_WITNESS_ACCOUNT_ADDRESS = "localWitnessAccountAddress"; diff --git a/framework/src/main/java/org/tron/core/config/args/Args.java b/framework/src/main/java/org/tron/core/config/args/Args.java index 46695986c1..ac7d0a44ac 100644 --- a/framework/src/main/java/org/tron/core/config/args/Args.java +++ b/framework/src/main/java/org/tron/core/config/args/Args.java @@ -101,6 +101,7 @@ public class Args extends CommonParameter { public static void clearParam() { PARAMETER.shellConfFileName = ""; + PARAMETER.configFilePath = ""; PARAMETER.outputDirectory = "output-directory"; PARAMETER.help = false; PARAMETER.witness = false; @@ -402,6 +403,9 @@ public static void setParam(final String[] args, final String confFileName) { exit(0); } + PARAMETER.setConfigFilePath( + StringUtils.isNoneBlank(PARAMETER.shellConfFileName) + ? PARAMETER.shellConfFileName : confFileName); Config config = Configuration.getByFileName(PARAMETER.shellConfFileName, confFileName); setParam(config); } @@ -411,10 +415,17 @@ public static void setParam(final String[] args, final String confFileName) { */ public static void setParam(final Config config) { - if (config.hasPath(Constant.NET_TYPE) - && Constant.TESTNET.equalsIgnoreCase(config.getString(Constant.NET_TYPE))) { - Wallet.setAddressPreFixByte(Constant.ADD_PRE_FIX_BYTE_TESTNET); - Wallet.setAddressPreFixString(Constant.ADD_PRE_FIX_STRING_TESTNET); + if (config.hasPath(Constant.NET_ADDRESS_PREFIX)) { + String prefix = config.getString(Constant.NET_ADDRESS_PREFIX) + .replace("'", "").replace("\"", "").trim(); + byte prefixByte; + if (prefix.startsWith("0x") || prefix.startsWith("0X")) { + prefixByte = (byte) Integer.parseInt(prefix.substring(2), 16); + } else { + prefixByte = (byte) Integer.parseInt(prefix, 16); + } + Wallet.setAddressPreFixByte(prefixByte); + Wallet.setAddressPreFixString(String.format("%02x", prefixByte)); } else { Wallet.setAddressPreFixByte(ADD_PRE_FIX_BYTE_MAINNET); Wallet.setAddressPreFixString(Constant.ADD_PRE_FIX_STRING_MAINNET); diff --git a/framework/src/main/java/org/tron/core/config/args/DynamicArgs.java b/framework/src/main/java/org/tron/core/config/args/DynamicArgs.java index db76858327..371b7736e2 100644 --- a/framework/src/main/java/org/tron/core/config/args/DynamicArgs.java +++ b/framework/src/main/java/org/tron/core/config/args/DynamicArgs.java @@ -1,7 +1,5 @@ package org.tron.core.config.args; -import static org.apache.commons.lang3.StringUtils.isNoneBlank; - import com.typesafe.config.Config; import java.io.File; import java.net.InetAddress; @@ -25,6 +23,7 @@ public class DynamicArgs { private final CommonParameter parameter = Args.getInstance(); + private File configFile; private long lastModified = 0; private ScheduledExecutorService reloadExecutor; @@ -36,11 +35,12 @@ public void init() { reloadExecutor = ExecutorServiceManager.newSingleThreadScheduledExecutor(esName); logger.info("Start the dynamic loading configuration service"); long checkInterval = parameter.getDynamicConfigCheckInterval(); - File config = getConfigFile(); - if (config == null) { + configFile = new File(parameter.getConfigFilePath()); + if (!configFile.exists()) { + logger.warn("Configuration path is required! No such file {}", configFile); return; } - lastModified = config.lastModified(); + lastModified = configFile.lastModified(); reloadExecutor.scheduleWithFixedDelay(() -> { try { run(); @@ -52,36 +52,16 @@ public void init() { } public void run() { - File config = getConfigFile(); - if (config != null) { - long lastModifiedTime = config.lastModified(); - if (lastModifiedTime > lastModified) { - reload(); - lastModified = lastModifiedTime; - } - } - } - - private File getConfigFile() { - String confFilePath; - if (isNoneBlank(parameter.getShellConfFileName())) { - confFilePath = parameter.getShellConfFileName(); - } else { - confFilePath = Constant.NET_CONF; - } - - File confFile = new File(confFilePath); - if (!confFile.exists()) { - logger.warn("Configuration path is required! No such file {}", confFile); - return null; + long lastModifiedTime = configFile.lastModified(); + if (lastModifiedTime > lastModified) { + reload(); + lastModified = lastModifiedTime; } - return confFile; } public void reload() { logger.debug("Reloading ... "); - Config config = Configuration.getByFileName(parameter.getShellConfFileName(), - Constant.NET_CONF); + Config config = Configuration.getByFileName(parameter.getConfigFilePath(), null); updateActiveNodes(config); diff --git a/framework/src/main/java/org/tron/program/FullNode.java b/framework/src/main/java/org/tron/program/FullNode.java index 7d67a0c0ab..b93a4d79b8 100644 --- a/framework/src/main/java/org/tron/program/FullNode.java +++ b/framework/src/main/java/org/tron/program/FullNode.java @@ -9,7 +9,6 @@ import org.tron.common.log.LogService; import org.tron.common.parameter.CommonParameter; import org.tron.common.prometheus.Metrics; -import org.tron.core.Constant; import org.tron.core.config.DefaultConfig; import org.tron.core.config.args.Args; @@ -21,7 +20,7 @@ public class FullNode { */ public static void main(String[] args) { ExitManager.initExceptionHandler(); - Args.setParam(args, Constant.NET_CONF); + Args.setParam(args, "config.conf"); CommonParameter parameter = Args.getInstance(); LogService.load(parameter.getLogbackPath()); diff --git a/framework/src/main/resources/config-backup.conf b/framework/src/main/resources/config-backup.conf index bb3082e42c..ecf14c3024 100644 --- a/framework/src/main/resources/config-backup.conf +++ b/framework/src/main/resources/config-backup.conf @@ -1,6 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - type = mainnet - # type = testnet + # type = mainnet + addressPrefix = "0x41" } storage { diff --git a/framework/src/main/resources/config-beta.conf b/framework/src/main/resources/config-beta.conf index 050df1e45a..b756aed686 100644 --- a/framework/src/main/resources/config-beta.conf +++ b/framework/src/main/resources/config-beta.conf @@ -1,6 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - # type = mainnet - type = testnet + # type = testnet + addressPrefix = "0xa0" } storage { diff --git a/framework/src/main/resources/config-localtest.conf b/framework/src/main/resources/config-localtest.conf index bdd5ea14d3..f5661edd92 100644 --- a/framework/src/main/resources/config-localtest.conf +++ b/framework/src/main/resources/config-localtest.conf @@ -1,6 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - type = mainnet - # type = testnet + # type = mainnet + addressPrefix = "0x41" } storage { diff --git a/framework/src/main/resources/config-test-net.conf b/framework/src/main/resources/config-test-net.conf index ff292a3951..b894bb5bab 100644 --- a/framework/src/main/resources/config-test-net.conf +++ b/framework/src/main/resources/config-test-net.conf @@ -1,6 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - type = mainnet - # type = testnet + # type = mainnet + # addressPrefix = "0x41" } storage { diff --git a/framework/src/main/resources/config.conf b/framework/src/main/resources/config.conf index 54f229e4e2..bdc3479c8d 100644 --- a/framework/src/main/resources/config.conf +++ b/framework/src/main/resources/config.conf @@ -1,8 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - # Type can be 'mainnet' or 'testnet', refers to address type. - # Hex address of 'mainnet' begin with 0x41, and 'testnet' begin with 0xa0. - # Note: 'testnet' is not related to TRON network Nile, Shasta or private net - type = mainnet + # type = mainnet + addressPrefix = "0x41" } storage { diff --git a/framework/src/test/java/org/tron/common/TestConstants.java b/framework/src/test/java/org/tron/common/TestConstants.java index b7b8beb061..9a9bb8d47f 100644 --- a/framework/src/test/java/org/tron/common/TestConstants.java +++ b/framework/src/test/java/org/tron/common/TestConstants.java @@ -3,4 +3,5 @@ public class TestConstants { public static final String TEST_CONF = "config-test.conf"; + public static final String NET_CONF = "config.conf"; } diff --git a/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java b/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java index b64df28caf..63cbce5b30 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java @@ -47,8 +47,7 @@ public class VMContractTestBase { static { // 27Ssb1WE8FArwJVRRb8Dwy3ssVGuLY8L3S1 (test.config) - WITNESS_SR1_ADDRESS = - Constant.ADD_PRE_FIX_STRING_TESTNET + "299F3DB80A24B20A254B89CE639D59132F157F13"; + WITNESS_SR1_ADDRESS = "a0" + "299F3DB80A24B20A254B89CE639D59132F157F13"; } @Before diff --git a/framework/src/test/java/org/tron/common/utils/client/Parameter.java b/framework/src/test/java/org/tron/common/utils/client/Parameter.java index f0531c9516..559ad9489c 100644 --- a/framework/src/test/java/org/tron/common/utils/client/Parameter.java +++ b/framework/src/test/java/org/tron/common/utils/client/Parameter.java @@ -4,11 +4,10 @@ public interface Parameter { interface CommonConstant { - byte ADD_PRE_FIX_BYTE = (byte) 0xa0; //a0 + address ,a0 is version - String ADD_PRE_FIX_STRING = "a0"; + //byte ADD_PRE_FIX_BYTE = (byte) 0xa0; //a0 + address ,a0 is version + // String ADD_PRE_FIX_STRING = "a0"; int ADDRESS_SIZE = 21; int BASE58CHECK_ADDRESS_SIZE = 35; byte ADD_PRE_FIX_BYTE_MAINNET = (byte) 0x41; //41 + address - byte ADD_PRE_FIX_BYTE_TESTNET = (byte) 0xa0; //a0 + address } } 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 87c412dc15..0482bdffae 100644 --- a/framework/src/test/java/org/tron/core/capsule/BlockCapsuleTest.java +++ b/framework/src/test/java/org/tron/core/capsule/BlockCapsuleTest.java @@ -17,7 +17,6 @@ import org.tron.common.utils.LocalWitnesses; 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.config.args.Args; import org.tron.core.exception.BadItemException; @@ -79,15 +78,9 @@ public void testCalcMerkleRoot() throws Exception { .addTransaction(new TransactionCapsule(transferContract2, ContractType.TransferContract)); blockCapsule0.setMerkleRoot(); - if (Constant.ADD_PRE_FIX_BYTE_TESTNET == Wallet.getAddressPreFixByte()) { - Assert.assertEquals( - "53421c1f1bcbbba67a4184cc3dbc1a59f90af7e2b0644dcfc8dc738fe30deffc", - blockCapsule0.getMerkleRoot().toString()); - } else { - Assert.assertEquals( - "5bc862243292e6aa1d5e21a60bb6a673e4c2544709f6363d4a2f85ec29bcfe00", - blockCapsule0.getMerkleRoot().toString()); - } + Assert.assertEquals( + "53421c1f1bcbbba67a4184cc3dbc1a59f90af7e2b0644dcfc8dc738fe30deffc", + blockCapsule0.getMerkleRoot().toString()); logger.info("Transaction[O] Merkle Root : {}", blockCapsule0.getMerkleRoot().toString()); } 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 6fb0e1c3cd..b88e2680cc 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 @@ -59,7 +59,7 @@ public void destroy() { @Test public void get() { Args.setParam(new String[] {"-c", TestConstants.TEST_CONF, "--keystore-factory"}, - Constant.NET_CONF); + "config.conf"); CommonParameter parameter = Args.getInstance(); @@ -71,7 +71,9 @@ public void get() { Args.setLocalWitnesses(localWitnesses); address = ByteArray.toHexString(Args.getLocalWitnesses() .getWitnessAccountAddress()); - Assert.assertEquals(Constant.ADD_PRE_FIX_STRING_TESTNET, DecodeUtil.addressPreFixString); + Assert.assertEquals("a0", DecodeUtil.addressPreFixString); + // configFilePath should be set to shellConfFileName when -c is specified + Assert.assertEquals(TestConstants.TEST_CONF, parameter.getConfigFilePath()); Assert.assertEquals(0, parameter.getBackupPriority()); Assert.assertEquals(3000, parameter.getKeepAliveInterval()); @@ -138,6 +140,8 @@ public void testIpFromLibP2p() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Args.setParam(new String[] {}, TestConstants.TEST_CONF); CommonParameter parameter = Args.getInstance(); + // configFilePath should fall back to confFileName when -c is not specified + Assert.assertEquals(TestConstants.TEST_CONF, parameter.getConfigFilePath()); String configuredExternalIp = parameter.getNodeExternalIp(); Assert.assertEquals("46.168.1.1", configuredExternalIp); @@ -157,7 +161,7 @@ public void testIpFromLibP2p() @Test public void testOldRewardOpt() { thrown.expect(IllegalArgumentException.class); - Args.setParam(new String[] {"-c", "args-test.conf"}, Constant.NET_CONF); + Args.setParam(new String[] {"-c", "args-test.conf"}, "config.conf"); } @Test diff --git a/framework/src/test/java/org/tron/core/config/args/DynamicArgsTest.java b/framework/src/test/java/org/tron/core/config/args/DynamicArgsTest.java index 8e32c40080..43fa59a17a 100644 --- a/framework/src/test/java/org/tron/core/config/args/DynamicArgsTest.java +++ b/framework/src/test/java/org/tron/core/config/args/DynamicArgsTest.java @@ -12,7 +12,6 @@ import org.tron.common.application.TronApplicationContext; import org.tron.common.parameter.CommonParameter; import org.tron.common.utils.ReflectUtils; -import org.tron.core.Constant; import org.tron.core.config.DefaultConfig; import org.tron.core.net.TronNetService; import org.tron.p2p.P2pConfig; @@ -41,15 +40,21 @@ public void destroy() { @Test public void start() { CommonParameter parameter = Args.getInstance(); + // configFilePath should be resolved from confFileName at startup + Assert.assertEquals(TestConstants.TEST_CONF, parameter.getConfigFilePath()); Assert.assertTrue(parameter.isDynamicConfigEnable()); Assert.assertEquals(600, parameter.getDynamicConfigCheckInterval()); dynamicArgs.init(); + // configFile should be initialized from configFilePath during init() + File configFile = (File) ReflectUtils.getFieldObject(dynamicArgs, "configFile"); + Assert.assertNotNull(configFile); + Assert.assertEquals(TestConstants.TEST_CONF, configFile.getName()); Assert.assertEquals(0, (long) ReflectUtils.getFieldObject(dynamicArgs, "lastModified")); TronNetService tronNetService = context.getBean(TronNetService.class); ReflectUtils.setFieldValue(tronNetService, "p2pConfig", new P2pConfig()); - File config = new File(Constant.NET_CONF); + File config = new File(parameter.getConfigFilePath()); if (!config.exists()) { try { config.createNewFile(); 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 a6d360513e..fc60c2afa0 100644 --- a/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java +++ b/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java @@ -10,7 +10,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.tron.common.BaseTest; -import org.tron.core.Constant; import org.tron.core.Wallet; import org.tron.core.capsule.AccountCapsule; import org.tron.core.config.args.Args; @@ -25,7 +24,7 @@ public class DelegationServiceTest extends BaseTest { @BeforeClass public static void init() { Args.setParam(new String[] {"--output-directory", dbPath(), "--debug"}, - Constant.NET_CONF); + "config.conf"); } private void testPay(int cycle) { diff --git a/framework/src/test/java/org/tron/core/services/ratelimiter/GlobalRateLimiterTest.java b/framework/src/test/java/org/tron/core/services/ratelimiter/GlobalRateLimiterTest.java index 5f98239fba..6a7aadaba0 100644 --- a/framework/src/test/java/org/tron/core/services/ratelimiter/GlobalRateLimiterTest.java +++ b/framework/src/test/java/org/tron/core/services/ratelimiter/GlobalRateLimiterTest.java @@ -4,7 +4,6 @@ import org.junit.AfterClass; import org.junit.Assert; import org.junit.Test; -import org.tron.core.Constant; import org.tron.core.config.args.Args; public class GlobalRateLimiterTest { @@ -12,7 +11,7 @@ public class GlobalRateLimiterTest { @Test public void testAcquire() throws Exception { String[] a = new String[0]; - Args.setParam(a, Constant.NET_CONF); + Args.setParam(a, "config.conf"); RuntimeData runtimeData = new RuntimeData(null); Field field = runtimeData.getClass().getDeclaredField("address"); field.setAccessible(true); diff --git a/framework/src/test/resources/args-test.conf b/framework/src/test/resources/args-test.conf index cf5d0b8d71..360e751b5d 100644 --- a/framework/src/test/resources/args-test.conf +++ b/framework/src/test/resources/args-test.conf @@ -1,6 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - // type = mainnet - type = testnet + # type = testnet + addressPrefix = "0xa0" } diff --git a/framework/src/test/resources/config-localtest.conf b/framework/src/test/resources/config-localtest.conf index 8049ceb6cd..90df46fff0 100644 --- a/framework/src/test/resources/config-localtest.conf +++ b/framework/src/test/resources/config-localtest.conf @@ -1,6 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - type = mainnet - # type = testnet + # type = mainnet + addressPrefix = "0x41" } storage { diff --git a/framework/src/test/resources/config-test-dbbackup.conf b/framework/src/test/resources/config-test-dbbackup.conf index 4f9ddf8d32..9668a784ce 100644 --- a/framework/src/test/resources/config-test-dbbackup.conf +++ b/framework/src/test/resources/config-test-dbbackup.conf @@ -1,6 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - type = mainnet - # type = testnet + # type = mainnet + addressPrefix = "0x41" } storage { diff --git a/framework/src/test/resources/config-test-index.conf b/framework/src/test/resources/config-test-index.conf index 3ea6b50b20..400986b18e 100644 --- a/framework/src/test/resources/config-test-index.conf +++ b/framework/src/test/resources/config-test-index.conf @@ -1,6 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - // type = mainnet - type = testnet + # type = testnet + addressPrefix = "0xa0" } diff --git a/framework/src/test/resources/config-test-mainnet.conf b/framework/src/test/resources/config-test-mainnet.conf index 123c8e5d36..277747fb73 100644 --- a/framework/src/test/resources/config-test-mainnet.conf +++ b/framework/src/test/resources/config-test-mainnet.conf @@ -1,6 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - type = mainnet - # type = testnet + # type = mainnet + addressPrefix = "0x41" } diff --git a/framework/src/test/resources/config-test-storagetest.conf b/framework/src/test/resources/config-test-storagetest.conf index 25127cdab9..0540a3dfbb 100644 --- a/framework/src/test/resources/config-test-storagetest.conf +++ b/framework/src/test/resources/config-test-storagetest.conf @@ -1,6 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - // type = mainnet - type = testnet + # type = testnet + addressPrefix = "0xa0" } diff --git a/framework/src/test/resources/config-test.conf b/framework/src/test/resources/config-test.conf index eb4f605ab9..42784e899b 100644 --- a/framework/src/test/resources/config-test.conf +++ b/framework/src/test/resources/config-test.conf @@ -1,6 +1,10 @@ +# Deprecated: type has no effect, kept for reference only. +# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). +# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. +# For normal mainnet deployment, the net section can be omitted entirely. net { - // type = mainnet - type = testnet + # type = testnet + addressPrefix = "0xa0" } From a9f0ed36b618d77a5ef6bd0ba41757317ddc091e Mon Sep 17 00:00:00 2001 From: vividcoder Date: Mon, 2 Mar 2026 12:29:15 +0800 Subject: [PATCH 4/8] refactor: extract HOCON config keys from Constant.java into ConfigKey.java Move ~232 HOCON configuration key string constants from Constant.java to a new package-private ConfigKey.java in org.tron.core.config.args. This separates config-file keys (used only by Args/DynamicArgs/WitnessInitializer) from business constants, reducing Constant.java from ~420 lines to ~65 lines. --- .../src/main/java/org/tron/core/Constant.java | 398 +------- .../java/org/tron/core/config/args/Args.java | 900 +++++++++--------- .../org/tron/core/config/args/ConfigKey.java | 332 +++++++ .../tron/core/config/args/DynamicArgs.java | 5 +- .../core/config/args/WitnessInitializer.java | 15 +- .../org/tron/core/config/args/ArgsTest.java | 3 +- .../config/args/WitnessInitializerTest.java | 13 +- .../tron/core/exception/TronErrorTest.java | 3 +- 8 files changed, 821 insertions(+), 848 deletions(-) create mode 100644 framework/src/main/java/org/tron/core/config/args/ConfigKey.java diff --git a/common/src/main/java/org/tron/core/Constant.java b/common/src/main/java/org/tron/core/Constant.java index c639addfe7..1437d31934 100644 --- a/common/src/main/java/org/tron/core/Constant.java +++ b/common/src/main/java/org/tron/core/Constant.java @@ -2,419 +2,65 @@ public class Constant { - - // locate in storageDbDirectory, store the db infos, - // now only has the split block number - public static final String INFO_FILE_NAME = "info.properties"; - // the block number that split between the snapshot and history - public static final String SPLIT_BLOCK_NUM = "split_block_num"; - - public static final byte ADD_PRE_FIX_BYTE_MAINNET = (byte) 0x41; //41 + address + // Address + public static final byte ADD_PRE_FIX_BYTE_MAINNET = (byte) 0x41; public static final String ADD_PRE_FIX_STRING_MAINNET = "41"; public static final int STANDARD_ADDRESS_SIZE = 20; public static final int TRON_ADDRESS_SIZE = 21; + // Node type public static final int NODE_TYPE_FULL_NODE = 0; public static final int NODE_TYPE_LIGHT_NODE = 1; - // DB NAME - public static final String MARKET_PAIR_PRICE_TO_ORDER = "market_pair_price_to_order"; - // DB NAME - - // config for transaction + // 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 - // config for smart contract + public static final long PER_SIGN_LENGTH = 65L; + public static final long MAX_CONTRACT_RESULT_SIZE = 2L; + + // Smart contract / Energy 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; + + // Proposal public static final long MIN_PROPOSAL_EXPIRE_TIME = 0L; // 0 ms public static final long MAX_PROPOSAL_EXPIRE_TIME = 31536003000L; // ms of 365 days + 3000 ms public static final long DEFAULT_PROPOSAL_EXPIRE_TIME = 259200000L; // ms of 3 days + // Dynamic energy + public static final long DYNAMIC_ENERGY_FACTOR_DECIMAL = 10_000L; + public static final long DYNAMIC_ENERGY_INCREASE_FACTOR_RANGE = 10_000L; + public static final long DYNAMIC_ENERGY_MAX_FACTOR_RANGE = 100_000L; + public static final int DYNAMIC_ENERGY_DECREASE_DIVISION = 4; // Numbers public static final int ONE_HUNDRED = 100; public static final int ONE_THOUSAND = 1000; + // Crypto public static final byte[] ZTRON_EXPANDSEED_PERSONALIZATION = {'Z', 't', 'r', 'o', 'n', '_', 'E', 'x', 'p', 'a', 'n', 'd', 'S', 'e', 'e', 'd'}; public static final int ZC_DIVERSIFIER_SIZE = 11; public static final int ZC_OUTPUT_DESC_MAX_SIZE = 10; - - /** - * normal transaction is 0 representing normal transaction unexecuted deferred transaction is 1 - * representing unexecuted deferred transaction executing deferred transaction is 2 representing - * executing deferred transaction - */ - public static final int NORMALTRANSACTION = 0; - public static final int UNEXECUTEDDEFERREDTRANSACTION = 1; - public static final int EXECUTINGDEFERREDTRANSACTION = 2; - - - // Configuration items - public static final String NET_ADDRESS_PREFIX = "net.addressPrefix"; - public static final String TESTNET = "testnet"; - public static final String LOCAL_WITNESS = "localwitness"; - public static final String LOCAL_WITNESS_ACCOUNT_ADDRESS = "localWitnessAccountAddress"; - public static final String LOCAL_WITNESS_KEYSTORE = "localwitnesskeystore"; - public static final String VM_SUPPORT_CONSTANT = "vm.supportConstant"; - public static final String VM_MAX_ENERGY_LIMIT_FOR_CONSTANT = "vm.maxEnergyLimitForConstant"; - public static final String VM_LRU_CACHE_SIZE = "vm.lruCacheSize"; - public static final String VM_MIN_TIME_RATIO = "vm.minTimeRatio"; - public static final String VM_MAX_TIME_RATIO = "vm.maxTimeRatio"; - public static final String VM_LONG_RUNNING_TIME = "vm.longRunningTime"; - public static final String VM_ESTIMATE_ENERGY = "vm.estimateEnergy"; - - public static final String VM_ESTIMATE_ENERGY_MAX_RETRY = "vm.estimateEnergyMaxRetry"; - + // DB + public static final String INFO_FILE_NAME = "info.properties"; + public static final String SPLIT_BLOCK_NUM = "split_block_num"; + public static final String MARKET_PAIR_PRICE_TO_ORDER = "market_pair_price_to_order"; public static final String ROCKSDB = "ROCKSDB"; - public static final String GENESIS_BLOCK = "genesis.block"; - public static final String GENESIS_BLOCK_TIMESTAMP = "genesis.block.timestamp"; - public static final String GENESIS_BLOCK_PARENTHASH = "genesis.block.parentHash"; - public static final String GENESIS_BLOCK_ASSETS = "genesis.block.assets"; - public static final String GENESIS_BLOCK_WITNESSES = "genesis.block.witnesses"; - - public static final String BLOCK_NEED_SYNC_CHECK = "block.needSyncCheck"; - public static final String NODE_DISCOVERY_ENABLE = "node.discovery.enable"; - public static final String NODE_DISCOVERY_PERSIST = "node.discovery.persist"; - public static final String NODE_EFFECTIVE_CHECK_ENABLE = "node.effectiveCheckEnable"; - public static final String NODE_CONNECTION_TIMEOUT = "node.connection.timeout"; - public static final String NODE_FETCH_BLOCK_TIMEOUT = "node.fetchBlock.timeout"; - public static final String NODE_CHANNEL_READ_TIMEOUT = "node.channel.read.timeout"; - public static final String NODE_MAX_CONNECTIONS = "node.maxConnections"; - public static final String NODE_MIN_CONNECTIONS = "node.minConnections"; - public static final String NODE_MIN_ACTIVE_CONNECTIONS = "node.minActiveConnections"; - public static final String NODE_SYNC_FETCH_BATCH_NUM = "node.syncFetchBatchNum"; - - public static final String NODE_MAX_ACTIVE_NODES = "node.maxActiveNodes"; - public static final String NODE_MAX_ACTIVE_NODES_WITH_SAME_IP = "node.maxActiveNodesWithSameIp"; - public static final String NODE_MAX_TPS = "node.maxTps"; - public static final String NODE_CONNECT_FACTOR = "node.connectFactor"; - public static final String NODE_ACTIVE_CONNECT_FACTOR = "node.activeConnectFactor"; - - public static final String NODE_MAX_CONNECTIONS_WITH_SAME_IP = "node.maxConnectionsWithSameIp"; - public static final String NODE_MIN_PARTICIPATION_RATE = "node.minParticipationRate"; - public static final String NODE_LISTEN_PORT = "node.listen.port"; - public static final String NODE_P2P_VERSION = "node.p2p.version"; - public static final String NODE_ENABLE_IPV6 = "node.enableIpv6"; - public static final String NODE_DNS_TREE_URLS = "node.dns.treeUrls"; - public static final String NODE_DNS_PUBLISH = "node.dns.publish"; - public static final String NODE_DNS_DOMAIN = "node.dns.dnsDomain"; - public static final String NODE_DNS_CHANGE_THRESHOLD = "node.dns.changeThreshold"; - public static final String NODE_DNS_MAX_MERGE_SIZE = "node.dns.maxMergeSize"; - public static final String NODE_DNS_PRIVATE = "node.dns.dnsPrivate"; - public static final String NODE_DNS_KNOWN_URLS = "node.dns.knownUrls"; - public static final String NODE_DNS_STATIC_NODES = "node.dns.staticNodes"; - public static final String NODE_DNS_SERVER_TYPE = "node.dns.serverType"; - public static final String NODE_DNS_ACCESS_KEY_ID = "node.dns.accessKeyId"; - public static final String NODE_DNS_ACCESS_KEY_SECRET = "node.dns.accessKeySecret"; - public static final String NODE_DNS_ALIYUN_ENDPOINT = "node.dns.aliyunDnsEndpoint"; - 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_JSONRPC_MAX_BLOCK_FILTER_NUM = "node.jsonrpc.maxBlockFilterNum"; - - public static final String NODE_DISABLED_API_LIST = "node.disabledApi"; - - public static final String NODE_RPC_THREAD = "node.rpc.thread"; - public static final String NODE_SOLIDITY_THREADS = "node.solidity.threads"; - - public static final String NODE_RPC_MAX_CONCURRENT_CALLS_PER_CONNECTION = "node.rpc.maxConcurrentCallsPerConnection"; - public static final String NODE_RPC_FLOW_CONTROL_WINDOW = "node.rpc.flowControlWindow"; - public static final String NODE_RPC_MAX_CONNECTION_IDLE_IN_MILLIS = "node.rpc.maxConnectionIdleInMillis"; - public static final String NODE_RPC_MAX_RST_STREAM = "node.rpc.maxRstStream"; - public static final String NODE_RPC_SECONDS_PER_WINDOW = "node.rpc.secondsPerWindow"; - public static final String NODE_PRODUCED_TIMEOUT = "node.blockProducedTimeOut"; - public static final String NODE_MAX_HTTP_CONNECT_NUMBER = "node.maxHttpConnectNumber"; - - public static final String NODE_NET_MAX_TRX_PER_SECOND = "node.netMaxTrxPerSecond"; - public static final String NODE_RPC_MAX_CONNECTION_AGE_IN_MILLIS = "node.rpc.maxConnectionAgeInMillis"; - public static final String NODE_RPC_MAX_MESSAGE_SIZE = "node.rpc.maxMessageSize"; - - 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"; - public static final String BLOCK_PROPOSAL_EXPIRE_TIME = "block.proposalExpireTime"; - - public static final String BLOCK_CHECK_FROZEN_TIME = "block.checkFrozenTime"; - - public static final String COMMITTEE_ALLOW_CREATION_OF_CONTRACTS = "committee.allowCreationOfContracts"; - - public static final String COMMITTEE_ALLOW_MULTI_SIGN = "committee.allowMultiSign"; - - public static final String COMMITTEE_ALLOW_ADAPTIVE_ENERGY = "committee.allowAdaptiveEnergy"; - - public static final String COMMITTEE_ALLOW_DELEGATE_RESOURCE = "committee.allowDelegateResource"; - - public static final String COMMITTEE_ALLOW_SAME_TOKEN_NAME = "committee.allowSameTokenName"; - - public static final String COMMITTEE_ALLOW_TVM_TRANSFER_TRC10 = "committee.allowTvmTransferTrc10"; - - public static final String COMMITTEE_ALLOW_TVM_CONSTANTINOPLE = "committee.allowTvmConstantinople"; - - public static final String COMMITTEE_ALLOW_TVM_SOLIDITY059 = "committee.allowTvmSolidity059"; - - public static final String COMMITTEE_FORBID_TRANSFER_TO_CONTRACT = "committee.forbidTransferToContract"; - - public static final String NODE_TCP_NETTY_WORK_THREAD_NUM = "node.tcpNettyWorkThreadNum"; - - public static final String NODE_UDP_NETTY_WORK_THREAD_NUM = "node.udpNettyWorkThreadNum"; - - public static final String NODE_TRUST_NODE = "node.trustNode"; - - public static final String NODE_VALIDATE_SIGN_THREAD_NUM = "node.validateSignThreadNum"; - - public static final String NODE_WALLET_EXTENSION_API = "node.walletExtensionApi"; - - public static final String NODE_RECEIVE_TCP_MIN_DATA_LENGTH = "node.receiveTcpMinDataLength"; - - 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"; - - public static final String NODE_PENDING_TRANSACTION_TIMEOUT = "node.pendingTransactionTimeout"; - - public static final String STORAGE_NEEDTO_UPDATE_ASSET = "storage.needToUpdateAsset"; - - public static final String TRX_REFERENCE_BLOCK = "trx.reference.block"; - - public static final String TRX_EXPIRATION_TIME_IN_MILLIS_SECONDS = "trx.expiration.timeInMilliseconds"; - - public static final String NODE_RPC_MIN_EFFECTIVE_CONNECTION = "node.rpc.minEffectiveConnection"; - - public static final String NODE_RPC_TRX_CACHE_ENABLE = "node.rpc.trxCacheEnable"; - - public static final String ENERGY_LIMIT_BLOCK_NUM = "enery.limit.block.num"; - - public static final String VM_TRACE = "vm.vmTrace"; - - 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"; - - public static final String COMMITTEE_ALLOW_SHIELDED_TRC20_TRANSACTION = "committee" - + ".allowShieldedTRC20Transaction"; - - public static final String COMMITTEE_ALLOW_TVM_ISTANBUL = "committee" - + ".allowTvmIstanbul"; - - public static final String COMMITTEE_ALLOW_MARKET_TRANSACTION = - "committee.allowMarketTransaction"; - - public static final String EVENT_SUBSCRIBE = "event.subscribe"; - - public static final String EVENT_SUBSCRIBE_FILTER = "event.subscribe.filter"; - - public static final String NODE_FULLNODE_ALLOW_SHIELDED_TRANSACTION = "node" - + ".fullNodeAllowShieldedTransaction"; - - public static final String ALLOW_SHIELDED_TRANSACTION_API = "node" - + ".allowShieldedTransactionApi"; - - public static final String NODE_ZEN_TOKENID = "node.zenTokenId"; - - public static final String COMMITTEE_ALLOW_PROTO_FILTER_NUM = "committee.allowProtoFilterNum"; - - public static final String COMMITTEE_ALLOW_ACCOUNT_STATE_ROOT = "committee.allowAccountStateRoot"; - - public static final String NODE_VALID_CONTRACT_PROTO_THREADS = "node.validContractProto.threads"; - - public static final String NODE_ACTIVE = "node.active"; - - public static final String NODE_PASSIVE = "node.passive"; - - public static final String NODE_FAST_FORWARD = "node.fastForward"; - - public static final String NODE_MAX_FAST_FORWARD_NUM = "node.maxFastForwardNum"; - - public static final String NODE_SHIELDED_TRANS_IN_PENDING_MAX_COUNTS = "node.shieldedTransInPendingMaxCounts"; - - public static final String RATE_LIMITER = "rate.limiter"; - - public static final String RATE_LIMITER_GLOBAL_QPS = "rate.limiter.global.qps"; - - public static final String RATE_LIMITER_GLOBAL_IP_QPS = "rate.limiter.global.ip.qps"; - - public static final String RATE_LIMITER_GLOBAL_API_QPS = "rate.limiter.global.api.qps"; - - public static final String COMMITTEE_CHANGED_DELEGATION = "committee.changedDelegation"; - - public static final String CRYPTO_ENGINE = "crypto.engine"; - + // Crypto engine public static final String ECKey_ENGINE = "ECKey"; - public static final String USE_NATIVE_QUEUE = "event.subscribe.native.useNativeQueue"; - - public static final String NATIVE_QUEUE_BIND_PORT = "event.subscribe.native.bindport"; - - 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"; - public static final String EVENT_SUBSCRIBE_TOPICS = "event.subscribe.topics"; - public static final String EVENT_SUBSCRIBE_FROM_BLOCK = "event.subscribe.filter.fromblock"; - public static final String EVENT_SUBSCRIBE_TO_BLOCK = "event.subscribe.filter.toblock"; - 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_EXTERNAL_IP = "node.discovery.external.ip"; - - public static final String NODE_BACKUP_PRIORITY = "node.backup.priority"; - public static final String NODE_BACKUP_PORT = "node.backup.port"; - public static final String NODE_BACKUP_KEEPALIVEINTERVAL = "node.backup.keepAliveInterval"; - public static final String NODE_BACKUP_MEMBERS = "node.backup.members"; - - public static final String STORAGE_BACKUP_ENABLE = "storage.backup.enable"; - public static final String STORAGE_BACKUP_PROP_PATH = "storage.backup.propPath"; - public static final String STORAGE_BACKUP_BAK1PATH = "storage.backup.bak1path"; - public static final String STORAGE_BACKUP_BAK2PATH = "storage.backup.bak2path"; - public static final String STORAGE_BACKUP_FREQUENCY = "storage.backup.frequency"; - public static final String STORAGE_DB_SETTING = "storage.dbSettings."; - - public static final String ACTUATOR_WHITELIST = "actuator.whitelist"; - - public static final String RATE_LIMITER_HTTP = "rate.limiter.http"; - public static final String RATE_LIMITER_RPC = "rate.limiter.rpc"; - public static final String RATE_LIMITER_P2P_SYNC_BLOCK_CHAIN = "rate.limiter.p2p.syncBlockChain"; - public static final String RATE_LIMITER_P2P_FETCH_INV_DATA = "rate.limiter.p2p.fetchInvData"; - public static final String RATE_LIMITER_P2P_DISCONNECT = "rate.limiter.p2p.disconnect"; - - public static final String SEED_NODE_IP_LIST = "seed.node.ip.list"; - public static final String NODE_METRICS_ENABLE = "node.metricsEnable"; - public static final String COMMITTEE_ALLOW_PBFT = "committee.allowPBFT"; - public static final String COMMITTEE_PBFT_EXPIRE_NUM = "committee.pBFTExpireNum"; - public static final String NODE_AGREE_NODE_COUNT = "node.agreeNodeCount"; - - public static final String COMMITTEE_ALLOW_TRANSACTION_FEE_POOL = "committee.allowTransactionFeePool"; - public static final String COMMITTEE_ALLOW_BLACK_HOLE_OPTIMIZATION = "committee.allowBlackHoleOptimization"; - public static final String COMMITTEE_ALLOW_NEW_RESOURCE_MODEL = "committee.allowNewResourceModel"; - public static final String COMMITTEE_ALLOW_RECEIPTS_MERKLE_ROOT = "committee.allowReceiptsMerkleRoot"; - - public static final String COMMITTEE_ALLOW_TVM_FREEZE = "committee.allowTvmFreeze"; - public static final String COMMITTEE_ALLOW_TVM_VOTE = "committee.allowTvmVote"; - public static final String COMMITTEE_UNFREEZE_DELAY_DAYS = "committee.unfreezeDelayDays"; - - public static final String COMMITTEE_ALLOW_TVM_LONDON = "committee.allowTvmLondon"; - public static final String COMMITTEE_ALLOW_TVM_COMPATIBLE_EVM = "committee.allowTvmCompatibleEvm"; - public static final String COMMITTEE_ALLOW_HIGHER_LIMIT_FOR_MAX_CPU_TIME_OF_ONE_TX = - "committee.allowHigherLimitForMaxCpuTimeOfOneTx"; - public static final String COMMITTEE_ALLOW_NEW_REWARD_ALGORITHM = "committee.allowNewRewardAlgorithm"; - public static final String COMMITTEE_ALLOW_OPTIMIZED_RETURN_VALUE_OF_CHAIN_ID = - "committee.allowOptimizedReturnValueOfChainId"; - - - public static final String METRICS_STORAGE_ENABLE = "node.metrics.storageEnable"; - public static final String METRICS_INFLUXDB_IP = "node.metrics.influxdb.ip"; - public static final String METRICS_INFLUXDB_PORT = "node.metrics.influxdb.port"; - public static final String METRICS_INFLUXDB_DATABASE = "node.metrics.influxdb.database"; - public static final String METRICS_REPORT_INTERVAL = "node.metrics.influxdb.metricsReportInterval"; - public static final String METRICS_PROMETHEUS_ENABLE = "node.metrics.prometheus.enable"; - public static final String METRICS_PROMETHEUS_PORT = "node.metrics.prometheus.port"; - - public static final String HISTORY_BALANCE_LOOKUP = "storage.balance.history.lookup"; - public static final String OPEN_PRINT_LOG = "node.openPrintLog"; - public static final String OPEN_TRANSACTION_SORT = "node.openTransactionSort"; - - public static final String ALLOW_ACCOUNT_ASSET_OPTIMIZATION = "committee.allowAccountAssetOptimization"; - public static final String ALLOW_ASSET_OPTIMIZATION = "committee.allowAssetOptimization"; - public static final String ALLOW_NEW_REWARD = "committee.allowNewReward"; - public static final String MEMO_FEE = "committee.memoFee"; - public static final String ALLOW_DELEGATE_OPTIMIZATION = "committee.allowDelegateOptimization"; - - public static final String ALLOW_DYNAMIC_ENERGY = "committee.allowDynamicEnergy"; - - public static final String DYNAMIC_ENERGY_THRESHOLD = "committee.dynamicEnergyThreshold"; - - public static final String DYNAMIC_ENERGY_INCREASE_FACTOR - = "committee.dynamicEnergyIncreaseFactor"; - - public static final String DYNAMIC_ENERGY_MAX_FACTOR = "committee.dynamicEnergyMaxFactor"; - - public static final long DYNAMIC_ENERGY_FACTOR_DECIMAL = 10_000L; - - public static final long DYNAMIC_ENERGY_INCREASE_FACTOR_RANGE = 10_000L; - - public static final long DYNAMIC_ENERGY_MAX_FACTOR_RANGE = 100_000L; - - public static final int DYNAMIC_ENERGY_DECREASE_DIVISION = 4; - + // Network public static final String LOCAL_HOST = "127.0.0.1"; - public static final String NODE_SHUTDOWN_BLOCK_TIME = "node.shutdown.BlockTime"; - public static final String NODE_SHUTDOWN_BLOCK_HEIGHT = "node.shutdown.BlockHeight"; - public static final String NODE_SHUTDOWN_BLOCK_COUNT = "node.shutdown.BlockCount"; - - public static final String BLOCK_CACHE_TIMEOUT = "node.blockCacheTimeout"; - - public static final String DYNAMIC_CONFIG_ENABLE = "node.dynamicConfig.enable"; - 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"; - - public static final String COMMITTEE_PROPOSAL_EXPIRE_TIME = "committee.proposalExpireTime"; - } diff --git a/framework/src/main/java/org/tron/core/config/args/Args.java b/framework/src/main/java/org/tron/core/config/args/Args.java index ac7d0a44ac..ea49638fd4 100644 --- a/framework/src/main/java/org/tron/core/config/args/Args.java +++ b/framework/src/main/java/org/tron/core/config/args/Args.java @@ -415,8 +415,8 @@ public static void setParam(final String[] args, final String confFileName) { */ public static void setParam(final Config config) { - if (config.hasPath(Constant.NET_ADDRESS_PREFIX)) { - String prefix = config.getString(Constant.NET_ADDRESS_PREFIX) + if (config.hasPath(ConfigKey.NET_ADDRESS_PREFIX)) { + String prefix = config.getString(ConfigKey.NET_ADDRESS_PREFIX) .replace("'", "").replace("\"", "").trim(); byte prefixByte; if (prefix.startsWith("0x") || prefix.startsWith("0X")) { @@ -431,8 +431,8 @@ public static void setParam(final Config config) { Wallet.setAddressPreFixString(Constant.ADD_PRE_FIX_STRING_MAINNET); } - PARAMETER.cryptoEngine = config.hasPath(Constant.CRYPTO_ENGINE) ? config - .getString(Constant.CRYPTO_ENGINE) : Constant.ECKey_ENGINE; + PARAMETER.cryptoEngine = config.hasPath(ConfigKey.CRYPTO_ENGINE) ? config + .getString(ConfigKey.CRYPTO_ENGINE) : Constant.ECKey_ENGINE; localWitnesses = new WitnessInitializer(config).initLocalWitnesses(); if (PARAMETER.isWitness() @@ -441,83 +441,83 @@ public static void setParam(final Config config) { TronError.ErrCode.WITNESS_INIT); } - if (config.hasPath(Constant.VM_SUPPORT_CONSTANT)) { - PARAMETER.supportConstant = config.getBoolean(Constant.VM_SUPPORT_CONSTANT); + if (config.hasPath(ConfigKey.VM_SUPPORT_CONSTANT)) { + PARAMETER.supportConstant = config.getBoolean(ConfigKey.VM_SUPPORT_CONSTANT); } - if (config.hasPath(Constant.VM_MAX_ENERGY_LIMIT_FOR_CONSTANT)) { - long configLimit = config.getLong(Constant.VM_MAX_ENERGY_LIMIT_FOR_CONSTANT); + if (config.hasPath(ConfigKey.VM_MAX_ENERGY_LIMIT_FOR_CONSTANT)) { + long configLimit = config.getLong(ConfigKey.VM_MAX_ENERGY_LIMIT_FOR_CONSTANT); PARAMETER.maxEnergyLimitForConstant = max(3_000_000L, configLimit, true); } - if (config.hasPath(Constant.VM_LRU_CACHE_SIZE)) { - PARAMETER.lruCacheSize = config.getInt(Constant.VM_LRU_CACHE_SIZE); + if (config.hasPath(ConfigKey.VM_LRU_CACHE_SIZE)) { + PARAMETER.lruCacheSize = config.getInt(ConfigKey.VM_LRU_CACHE_SIZE); } - if (config.hasPath(Constant.NODE_RPC_ENABLE)) { - PARAMETER.rpcEnable = config.getBoolean(Constant.NODE_RPC_ENABLE); + if (config.hasPath(ConfigKey.NODE_RPC_ENABLE)) { + PARAMETER.rpcEnable = config.getBoolean(ConfigKey.NODE_RPC_ENABLE); } - if (config.hasPath(Constant.NODE_RPC_SOLIDITY_ENABLE)) { - PARAMETER.rpcSolidityEnable = config.getBoolean(Constant.NODE_RPC_SOLIDITY_ENABLE); + if (config.hasPath(ConfigKey.NODE_RPC_SOLIDITY_ENABLE)) { + PARAMETER.rpcSolidityEnable = config.getBoolean(ConfigKey.NODE_RPC_SOLIDITY_ENABLE); } - if (config.hasPath(Constant.NODE_RPC_PBFT_ENABLE)) { - PARAMETER.rpcPBFTEnable = config.getBoolean(Constant.NODE_RPC_PBFT_ENABLE); + if (config.hasPath(ConfigKey.NODE_RPC_PBFT_ENABLE)) { + PARAMETER.rpcPBFTEnable = config.getBoolean(ConfigKey.NODE_RPC_PBFT_ENABLE); } - if (config.hasPath(Constant.NODE_HTTP_FULLNODE_ENABLE)) { - PARAMETER.fullNodeHttpEnable = config.getBoolean(Constant.NODE_HTTP_FULLNODE_ENABLE); + if (config.hasPath(ConfigKey.NODE_HTTP_FULLNODE_ENABLE)) { + PARAMETER.fullNodeHttpEnable = config.getBoolean(ConfigKey.NODE_HTTP_FULLNODE_ENABLE); } - if (config.hasPath(Constant.NODE_HTTP_SOLIDITY_ENABLE)) { - PARAMETER.solidityNodeHttpEnable = config.getBoolean(Constant.NODE_HTTP_SOLIDITY_ENABLE); + if (config.hasPath(ConfigKey.NODE_HTTP_SOLIDITY_ENABLE)) { + PARAMETER.solidityNodeHttpEnable = config.getBoolean(ConfigKey.NODE_HTTP_SOLIDITY_ENABLE); } - if (config.hasPath(Constant.NODE_HTTP_PBFT_ENABLE)) { - PARAMETER.pBFTHttpEnable = config.getBoolean(Constant.NODE_HTTP_PBFT_ENABLE); + if (config.hasPath(ConfigKey.NODE_HTTP_PBFT_ENABLE)) { + PARAMETER.pBFTHttpEnable = config.getBoolean(ConfigKey.NODE_HTTP_PBFT_ENABLE); } - if (config.hasPath(Constant.NODE_JSONRPC_HTTP_FULLNODE_ENABLE)) { + if (config.hasPath(ConfigKey.NODE_JSONRPC_HTTP_FULLNODE_ENABLE)) { PARAMETER.jsonRpcHttpFullNodeEnable = - config.getBoolean(Constant.NODE_JSONRPC_HTTP_FULLNODE_ENABLE); + config.getBoolean(ConfigKey.NODE_JSONRPC_HTTP_FULLNODE_ENABLE); } - if (config.hasPath(Constant.NODE_JSONRPC_HTTP_SOLIDITY_ENABLE)) { + if (config.hasPath(ConfigKey.NODE_JSONRPC_HTTP_SOLIDITY_ENABLE)) { PARAMETER.jsonRpcHttpSolidityNodeEnable = - config.getBoolean(Constant.NODE_JSONRPC_HTTP_SOLIDITY_ENABLE); + config.getBoolean(ConfigKey.NODE_JSONRPC_HTTP_SOLIDITY_ENABLE); } - if (config.hasPath(Constant.NODE_JSONRPC_HTTP_PBFT_ENABLE)) { + if (config.hasPath(ConfigKey.NODE_JSONRPC_HTTP_PBFT_ENABLE)) { PARAMETER.jsonRpcHttpPBFTNodeEnable = - config.getBoolean(Constant.NODE_JSONRPC_HTTP_PBFT_ENABLE); + config.getBoolean(ConfigKey.NODE_JSONRPC_HTTP_PBFT_ENABLE); } - if (config.hasPath(Constant.NODE_JSONRPC_MAX_BLOCK_RANGE)) { + if (config.hasPath(ConfigKey.NODE_JSONRPC_MAX_BLOCK_RANGE)) { PARAMETER.jsonRpcMaxBlockRange = - config.getInt(Constant.NODE_JSONRPC_MAX_BLOCK_RANGE); + config.getInt(ConfigKey.NODE_JSONRPC_MAX_BLOCK_RANGE); } - if (config.hasPath(Constant.NODE_JSONRPC_MAX_SUB_TOPICS)) { + if (config.hasPath(ConfigKey.NODE_JSONRPC_MAX_SUB_TOPICS)) { PARAMETER.jsonRpcMaxSubTopics = - config.getInt(Constant.NODE_JSONRPC_MAX_SUB_TOPICS); + config.getInt(ConfigKey.NODE_JSONRPC_MAX_SUB_TOPICS); } - if (config.hasPath(Constant.NODE_JSONRPC_MAX_BLOCK_FILTER_NUM)) { + if (config.hasPath(ConfigKey.NODE_JSONRPC_MAX_BLOCK_FILTER_NUM)) { PARAMETER.jsonRpcMaxBlockFilterNum = - config.getInt(Constant.NODE_JSONRPC_MAX_BLOCK_FILTER_NUM); + config.getInt(ConfigKey.NODE_JSONRPC_MAX_BLOCK_FILTER_NUM); } - if (config.hasPath(Constant.VM_MIN_TIME_RATIO)) { - PARAMETER.minTimeRatio = config.getDouble(Constant.VM_MIN_TIME_RATIO); + if (config.hasPath(ConfigKey.VM_MIN_TIME_RATIO)) { + PARAMETER.minTimeRatio = config.getDouble(ConfigKey.VM_MIN_TIME_RATIO); } - if (config.hasPath(Constant.VM_MAX_TIME_RATIO)) { - PARAMETER.maxTimeRatio = config.getDouble(Constant.VM_MAX_TIME_RATIO); + if (config.hasPath(ConfigKey.VM_MAX_TIME_RATIO)) { + PARAMETER.maxTimeRatio = config.getDouble(ConfigKey.VM_MAX_TIME_RATIO); } - if (config.hasPath(Constant.VM_LONG_RUNNING_TIME)) { - PARAMETER.longRunningTime = config.getInt(Constant.VM_LONG_RUNNING_TIME); + if (config.hasPath(ConfigKey.VM_LONG_RUNNING_TIME)) { + PARAMETER.longRunningTime = config.getInt(ConfigKey.VM_LONG_RUNNING_TIME); } PARAMETER.storage = new Storage(); @@ -573,17 +573,17 @@ public static void setParam(final Config config) { PARAMETER.seedNode = new SeedNode(); PARAMETER.seedNode.setAddressList(loadSeeds(config)); - if (config.hasPath(Constant.GENESIS_BLOCK)) { + if (config.hasPath(ConfigKey.GENESIS_BLOCK)) { PARAMETER.genesisBlock = new GenesisBlock(); - PARAMETER.genesisBlock.setTimestamp(config.getString(Constant.GENESIS_BLOCK_TIMESTAMP)); - PARAMETER.genesisBlock.setParentHash(config.getString(Constant.GENESIS_BLOCK_PARENTHASH)); + PARAMETER.genesisBlock.setTimestamp(config.getString(ConfigKey.GENESIS_BLOCK_TIMESTAMP)); + PARAMETER.genesisBlock.setParentHash(config.getString(ConfigKey.GENESIS_BLOCK_PARENTHASH)); - if (config.hasPath(Constant.GENESIS_BLOCK_ASSETS)) { + if (config.hasPath(ConfigKey.GENESIS_BLOCK_ASSETS)) { PARAMETER.genesisBlock.setAssets(getAccountsFromConfig(config)); AccountStore.setAccount(config); } - if (config.hasPath(Constant.GENESIS_BLOCK_WITNESSES)) { + if (config.hasPath(ConfigKey.GENESIS_BLOCK_WITNESSES)) { PARAMETER.genesisBlock.setWitnesses(getWitnessesFromConfig(config)); } } else { @@ -591,108 +591,108 @@ public static void setParam(final Config config) { } PARAMETER.needSyncCheck = - config.hasPath(Constant.BLOCK_NEED_SYNC_CHECK) - && config.getBoolean(Constant.BLOCK_NEED_SYNC_CHECK); + config.hasPath(ConfigKey.BLOCK_NEED_SYNC_CHECK) + && config.getBoolean(ConfigKey.BLOCK_NEED_SYNC_CHECK); PARAMETER.nodeDiscoveryEnable = - config.hasPath(Constant.NODE_DISCOVERY_ENABLE) - && config.getBoolean(Constant.NODE_DISCOVERY_ENABLE); + config.hasPath(ConfigKey.NODE_DISCOVERY_ENABLE) + && config.getBoolean(ConfigKey.NODE_DISCOVERY_ENABLE); PARAMETER.nodeDiscoveryPersist = - config.hasPath(Constant.NODE_DISCOVERY_PERSIST) - && config.getBoolean(Constant.NODE_DISCOVERY_PERSIST); + config.hasPath(ConfigKey.NODE_DISCOVERY_PERSIST) + && config.getBoolean(ConfigKey.NODE_DISCOVERY_PERSIST); PARAMETER.nodeEffectiveCheckEnable = - config.hasPath(Constant.NODE_EFFECTIVE_CHECK_ENABLE) - && config.getBoolean(Constant.NODE_EFFECTIVE_CHECK_ENABLE); + config.hasPath(ConfigKey.NODE_EFFECTIVE_CHECK_ENABLE) + && config.getBoolean(ConfigKey.NODE_EFFECTIVE_CHECK_ENABLE); PARAMETER.nodeConnectionTimeout = - config.hasPath(Constant.NODE_CONNECTION_TIMEOUT) - ? config.getInt(Constant.NODE_CONNECTION_TIMEOUT) * 1000 + config.hasPath(ConfigKey.NODE_CONNECTION_TIMEOUT) + ? config.getInt(ConfigKey.NODE_CONNECTION_TIMEOUT) * 1000 : 2000; - if (!config.hasPath(Constant.NODE_FETCH_BLOCK_TIMEOUT)) { + if (!config.hasPath(ConfigKey.NODE_FETCH_BLOCK_TIMEOUT)) { PARAMETER.fetchBlockTimeout = 500; - } else if (config.getInt(Constant.NODE_FETCH_BLOCK_TIMEOUT) > 1000) { + } else if (config.getInt(ConfigKey.NODE_FETCH_BLOCK_TIMEOUT) > 1000) { PARAMETER.fetchBlockTimeout = 1000; - } else if (config.getInt(Constant.NODE_FETCH_BLOCK_TIMEOUT) < 100) { + } else if (config.getInt(ConfigKey.NODE_FETCH_BLOCK_TIMEOUT) < 100) { PARAMETER.fetchBlockTimeout = 100; } else { - PARAMETER.fetchBlockTimeout = config.getInt(Constant.NODE_FETCH_BLOCK_TIMEOUT); + PARAMETER.fetchBlockTimeout = config.getInt(ConfigKey.NODE_FETCH_BLOCK_TIMEOUT); } PARAMETER.nodeChannelReadTimeout = - config.hasPath(Constant.NODE_CHANNEL_READ_TIMEOUT) - ? config.getInt(Constant.NODE_CHANNEL_READ_TIMEOUT) + config.hasPath(ConfigKey.NODE_CHANNEL_READ_TIMEOUT) + ? config.getInt(ConfigKey.NODE_CHANNEL_READ_TIMEOUT) : 0; - if (config.hasPath(Constant.NODE_MAX_ACTIVE_NODES)) { - PARAMETER.maxConnections = config.getInt(Constant.NODE_MAX_ACTIVE_NODES); + if (config.hasPath(ConfigKey.NODE_MAX_ACTIVE_NODES)) { + PARAMETER.maxConnections = config.getInt(ConfigKey.NODE_MAX_ACTIVE_NODES); } else { PARAMETER.maxConnections = - config.hasPath(Constant.NODE_MAX_CONNECTIONS) - ? config.getInt(Constant.NODE_MAX_CONNECTIONS) : 30; + config.hasPath(ConfigKey.NODE_MAX_CONNECTIONS) + ? config.getInt(ConfigKey.NODE_MAX_CONNECTIONS) : 30; } - if (config.hasPath(Constant.NODE_MAX_ACTIVE_NODES) - && config.hasPath(Constant.NODE_CONNECT_FACTOR)) { + if (config.hasPath(ConfigKey.NODE_MAX_ACTIVE_NODES) + && config.hasPath(ConfigKey.NODE_CONNECT_FACTOR)) { PARAMETER.minConnections = (int) (PARAMETER.maxConnections - * config.getDouble(Constant.NODE_CONNECT_FACTOR)); + * config.getDouble(ConfigKey.NODE_CONNECT_FACTOR)); } else { PARAMETER.minConnections = - config.hasPath(Constant.NODE_MIN_CONNECTIONS) - ? config.getInt(Constant.NODE_MIN_CONNECTIONS) : 8; + config.hasPath(ConfigKey.NODE_MIN_CONNECTIONS) + ? config.getInt(ConfigKey.NODE_MIN_CONNECTIONS) : 8; } - if (config.hasPath(Constant.NODE_MAX_ACTIVE_NODES) - && config.hasPath(Constant.NODE_ACTIVE_CONNECT_FACTOR)) { + if (config.hasPath(ConfigKey.NODE_MAX_ACTIVE_NODES) + && config.hasPath(ConfigKey.NODE_ACTIVE_CONNECT_FACTOR)) { PARAMETER.minActiveConnections = (int) (PARAMETER.maxConnections - * config.getDouble(Constant.NODE_ACTIVE_CONNECT_FACTOR)); + * config.getDouble(ConfigKey.NODE_ACTIVE_CONNECT_FACTOR)); } else { PARAMETER.minActiveConnections = - config.hasPath(Constant.NODE_MIN_ACTIVE_CONNECTIONS) - ? config.getInt(Constant.NODE_MIN_ACTIVE_CONNECTIONS) : 3; + config.hasPath(ConfigKey.NODE_MIN_ACTIVE_CONNECTIONS) + ? config.getInt(ConfigKey.NODE_MIN_ACTIVE_CONNECTIONS) : 3; } - if (config.hasPath(Constant.NODE_MAX_ACTIVE_NODES_WITH_SAME_IP)) { + if (config.hasPath(ConfigKey.NODE_MAX_ACTIVE_NODES_WITH_SAME_IP)) { PARAMETER.maxConnectionsWithSameIp = - config.getInt(Constant.NODE_MAX_ACTIVE_NODES_WITH_SAME_IP); + config.getInt(ConfigKey.NODE_MAX_ACTIVE_NODES_WITH_SAME_IP); } else { PARAMETER.maxConnectionsWithSameIp = - config.hasPath(Constant.NODE_MAX_CONNECTIONS_WITH_SAME_IP) ? config - .getInt(Constant.NODE_MAX_CONNECTIONS_WITH_SAME_IP) : 2; + config.hasPath(ConfigKey.NODE_MAX_CONNECTIONS_WITH_SAME_IP) ? config + .getInt(ConfigKey.NODE_MAX_CONNECTIONS_WITH_SAME_IP) : 2; } - PARAMETER.maxTps = config.hasPath(Constant.NODE_MAX_TPS) - ? config.getInt(Constant.NODE_MAX_TPS) : 1000; + PARAMETER.maxTps = config.hasPath(ConfigKey.NODE_MAX_TPS) + ? config.getInt(ConfigKey.NODE_MAX_TPS) : 1000; PARAMETER.minParticipationRate = - config.hasPath(Constant.NODE_MIN_PARTICIPATION_RATE) - ? config.getInt(Constant.NODE_MIN_PARTICIPATION_RATE) + config.hasPath(ConfigKey.NODE_MIN_PARTICIPATION_RATE) + ? config.getInt(ConfigKey.NODE_MIN_PARTICIPATION_RATE) : 0; PARAMETER.p2pConfig = new P2pConfig(); PARAMETER.nodeListenPort = - config.hasPath(Constant.NODE_LISTEN_PORT) - ? config.getInt(Constant.NODE_LISTEN_PORT) : 0; + config.hasPath(ConfigKey.NODE_LISTEN_PORT) + ? config.getInt(ConfigKey.NODE_LISTEN_PORT) : 0; PARAMETER.nodeLanIp = PARAMETER.p2pConfig.getLanIp(); externalIp(config); PARAMETER.nodeP2pVersion = - config.hasPath(Constant.NODE_P2P_VERSION) - ? config.getInt(Constant.NODE_P2P_VERSION) : 0; + config.hasPath(ConfigKey.NODE_P2P_VERSION) + ? config.getInt(ConfigKey.NODE_P2P_VERSION) : 0; PARAMETER.nodeEnableIpv6 = - config.hasPath(Constant.NODE_ENABLE_IPV6) && config.getBoolean(Constant.NODE_ENABLE_IPV6); + config.hasPath(ConfigKey.NODE_ENABLE_IPV6) && config.getBoolean(ConfigKey.NODE_ENABLE_IPV6); - PARAMETER.dnsTreeUrls = config.hasPath(Constant.NODE_DNS_TREE_URLS) ? config.getStringList( - Constant.NODE_DNS_TREE_URLS) : new ArrayList<>(); + PARAMETER.dnsTreeUrls = config.hasPath(ConfigKey.NODE_DNS_TREE_URLS) ? config.getStringList( + ConfigKey.NODE_DNS_TREE_URLS) : new ArrayList<>(); PARAMETER.dnsPublishConfig = loadDnsPublishConfig(config); - PARAMETER.syncFetchBatchNum = config.hasPath(Constant.NODE_SYNC_FETCH_BATCH_NUM) ? config - .getInt(Constant.NODE_SYNC_FETCH_BATCH_NUM) : 2000; + PARAMETER.syncFetchBatchNum = config.hasPath(ConfigKey.NODE_SYNC_FETCH_BATCH_NUM) ? config + .getInt(ConfigKey.NODE_SYNC_FETCH_BATCH_NUM) : 2000; if (PARAMETER.syncFetchBatchNum > 2000) { PARAMETER.syncFetchBatchNum = 2000; } @@ -701,75 +701,75 @@ public static void setParam(final Config config) { } PARAMETER.rpcPort = - config.hasPath(Constant.NODE_RPC_PORT) - ? config.getInt(Constant.NODE_RPC_PORT) : 50051; + config.hasPath(ConfigKey.NODE_RPC_PORT) + ? config.getInt(ConfigKey.NODE_RPC_PORT) : 50051; PARAMETER.rpcOnSolidityPort = - config.hasPath(Constant.NODE_RPC_SOLIDITY_PORT) - ? config.getInt(Constant.NODE_RPC_SOLIDITY_PORT) : 50061; + config.hasPath(ConfigKey.NODE_RPC_SOLIDITY_PORT) + ? config.getInt(ConfigKey.NODE_RPC_SOLIDITY_PORT) : 50061; PARAMETER.rpcOnPBFTPort = - config.hasPath(Constant.NODE_RPC_PBFT_PORT) - ? config.getInt(Constant.NODE_RPC_PBFT_PORT) : 50071; + config.hasPath(ConfigKey.NODE_RPC_PBFT_PORT) + ? config.getInt(ConfigKey.NODE_RPC_PBFT_PORT) : 50071; PARAMETER.fullNodeHttpPort = - config.hasPath(Constant.NODE_HTTP_FULLNODE_PORT) - ? config.getInt(Constant.NODE_HTTP_FULLNODE_PORT) : 8090; + config.hasPath(ConfigKey.NODE_HTTP_FULLNODE_PORT) + ? config.getInt(ConfigKey.NODE_HTTP_FULLNODE_PORT) : 8090; PARAMETER.solidityHttpPort = - config.hasPath(Constant.NODE_HTTP_SOLIDITY_PORT) - ? config.getInt(Constant.NODE_HTTP_SOLIDITY_PORT) : 8091; + config.hasPath(ConfigKey.NODE_HTTP_SOLIDITY_PORT) + ? config.getInt(ConfigKey.NODE_HTTP_SOLIDITY_PORT) : 8091; PARAMETER.pBFTHttpPort = - config.hasPath(Constant.NODE_HTTP_PBFT_PORT) - ? config.getInt(Constant.NODE_HTTP_PBFT_PORT) : 8092; + config.hasPath(ConfigKey.NODE_HTTP_PBFT_PORT) + ? config.getInt(ConfigKey.NODE_HTTP_PBFT_PORT) : 8092; PARAMETER.jsonRpcHttpFullNodePort = - config.hasPath(Constant.NODE_JSONRPC_HTTP_FULLNODE_PORT) - ? config.getInt(Constant.NODE_JSONRPC_HTTP_FULLNODE_PORT) : 8545; + config.hasPath(ConfigKey.NODE_JSONRPC_HTTP_FULLNODE_PORT) + ? config.getInt(ConfigKey.NODE_JSONRPC_HTTP_FULLNODE_PORT) : 8545; PARAMETER.jsonRpcHttpSolidityPort = - config.hasPath(Constant.NODE_JSONRPC_HTTP_SOLIDITY_PORT) - ? config.getInt(Constant.NODE_JSONRPC_HTTP_SOLIDITY_PORT) : 8555; + config.hasPath(ConfigKey.NODE_JSONRPC_HTTP_SOLIDITY_PORT) + ? config.getInt(ConfigKey.NODE_JSONRPC_HTTP_SOLIDITY_PORT) : 8555; PARAMETER.jsonRpcHttpPBFTPort = - config.hasPath(Constant.NODE_JSONRPC_HTTP_PBFT_PORT) - ? config.getInt(Constant.NODE_JSONRPC_HTTP_PBFT_PORT) : 8565; + config.hasPath(ConfigKey.NODE_JSONRPC_HTTP_PBFT_PORT) + ? config.getInt(ConfigKey.NODE_JSONRPC_HTTP_PBFT_PORT) : 8565; PARAMETER.rpcThreadNum = - config.hasPath(Constant.NODE_RPC_THREAD) ? config.getInt(Constant.NODE_RPC_THREAD) + config.hasPath(ConfigKey.NODE_RPC_THREAD) ? config.getInt(ConfigKey.NODE_RPC_THREAD) : (Runtime.getRuntime().availableProcessors() + 1) / 2; PARAMETER.solidityThreads = - config.hasPath(Constant.NODE_SOLIDITY_THREADS) - ? config.getInt(Constant.NODE_SOLIDITY_THREADS) + config.hasPath(ConfigKey.NODE_SOLIDITY_THREADS) + ? config.getInt(ConfigKey.NODE_SOLIDITY_THREADS) : Runtime.getRuntime().availableProcessors(); PARAMETER.maxConcurrentCallsPerConnection = - config.hasPath(Constant.NODE_RPC_MAX_CONCURRENT_CALLS_PER_CONNECTION) - ? config.getInt(Constant.NODE_RPC_MAX_CONCURRENT_CALLS_PER_CONNECTION) + config.hasPath(ConfigKey.NODE_RPC_MAX_CONCURRENT_CALLS_PER_CONNECTION) + ? config.getInt(ConfigKey.NODE_RPC_MAX_CONCURRENT_CALLS_PER_CONNECTION) : Integer.MAX_VALUE; - PARAMETER.flowControlWindow = config.hasPath(Constant.NODE_RPC_FLOW_CONTROL_WINDOW) - ? config.getInt(Constant.NODE_RPC_FLOW_CONTROL_WINDOW) + PARAMETER.flowControlWindow = config.hasPath(ConfigKey.NODE_RPC_FLOW_CONTROL_WINDOW) + ? config.getInt(ConfigKey.NODE_RPC_FLOW_CONTROL_WINDOW) : NettyServerBuilder.DEFAULT_FLOW_CONTROL_WINDOW; - if (config.hasPath(Constant.NODE_RPC_MAX_RST_STREAM)) { - PARAMETER.rpcMaxRstStream = config.getInt(Constant.NODE_RPC_MAX_RST_STREAM); + if (config.hasPath(ConfigKey.NODE_RPC_MAX_RST_STREAM)) { + PARAMETER.rpcMaxRstStream = config.getInt(ConfigKey.NODE_RPC_MAX_RST_STREAM); } - if (config.hasPath(Constant.NODE_RPC_SECONDS_PER_WINDOW)) { - PARAMETER.rpcSecondsPerWindow = config.getInt(Constant.NODE_RPC_SECONDS_PER_WINDOW); + if (config.hasPath(ConfigKey.NODE_RPC_SECONDS_PER_WINDOW)) { + PARAMETER.rpcSecondsPerWindow = config.getInt(ConfigKey.NODE_RPC_SECONDS_PER_WINDOW); } PARAMETER.maxConnectionIdleInMillis = - config.hasPath(Constant.NODE_RPC_MAX_CONNECTION_IDLE_IN_MILLIS) - ? config.getLong(Constant.NODE_RPC_MAX_CONNECTION_IDLE_IN_MILLIS) + config.hasPath(ConfigKey.NODE_RPC_MAX_CONNECTION_IDLE_IN_MILLIS) + ? config.getLong(ConfigKey.NODE_RPC_MAX_CONNECTION_IDLE_IN_MILLIS) : Long.MAX_VALUE; - PARAMETER.blockProducedTimeOut = config.hasPath(Constant.NODE_PRODUCED_TIMEOUT) - ? config.getInt(Constant.NODE_PRODUCED_TIMEOUT) : BLOCK_PRODUCE_TIMEOUT_PERCENT; + PARAMETER.blockProducedTimeOut = config.hasPath(ConfigKey.NODE_PRODUCED_TIMEOUT) + ? config.getInt(ConfigKey.NODE_PRODUCED_TIMEOUT) : BLOCK_PRODUCE_TIMEOUT_PERCENT; - PARAMETER.maxHttpConnectNumber = config.hasPath(Constant.NODE_MAX_HTTP_CONNECT_NUMBER) - ? config.getInt(Constant.NODE_MAX_HTTP_CONNECT_NUMBER) + PARAMETER.maxHttpConnectNumber = config.hasPath(ConfigKey.NODE_MAX_HTTP_CONNECT_NUMBER) + ? config.getInt(ConfigKey.NODE_MAX_HTTP_CONNECT_NUMBER) : NodeConstant.MAX_HTTP_CONNECT_NUMBER; if (PARAMETER.blockProducedTimeOut < 30) { @@ -779,97 +779,97 @@ public static void setParam(final Config config) { PARAMETER.blockProducedTimeOut = 100; } - PARAMETER.netMaxTrxPerSecond = config.hasPath(Constant.NODE_NET_MAX_TRX_PER_SECOND) - ? config.getInt(Constant.NODE_NET_MAX_TRX_PER_SECOND) + PARAMETER.netMaxTrxPerSecond = config.hasPath(ConfigKey.NODE_NET_MAX_TRX_PER_SECOND) + ? config.getInt(ConfigKey.NODE_NET_MAX_TRX_PER_SECOND) : NetConstants.NET_MAX_TRX_PER_SECOND; PARAMETER.maxConnectionAgeInMillis = - config.hasPath(Constant.NODE_RPC_MAX_CONNECTION_AGE_IN_MILLIS) - ? config.getLong(Constant.NODE_RPC_MAX_CONNECTION_AGE_IN_MILLIS) + config.hasPath(ConfigKey.NODE_RPC_MAX_CONNECTION_AGE_IN_MILLIS) + ? config.getLong(ConfigKey.NODE_RPC_MAX_CONNECTION_AGE_IN_MILLIS) : Long.MAX_VALUE; - PARAMETER.maxMessageSize = config.hasPath(Constant.NODE_RPC_MAX_MESSAGE_SIZE) - ? config.getInt(Constant.NODE_RPC_MAX_MESSAGE_SIZE) : GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE; + PARAMETER.maxMessageSize = config.hasPath(ConfigKey.NODE_RPC_MAX_MESSAGE_SIZE) + ? config.getInt(ConfigKey.NODE_RPC_MAX_MESSAGE_SIZE) : GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE; - PARAMETER.maxHeaderListSize = config.hasPath(Constant.NODE_RPC_MAX_HEADER_LIST_SIZE) - ? config.getInt(Constant.NODE_RPC_MAX_HEADER_LIST_SIZE) + PARAMETER.maxHeaderListSize = config.hasPath(ConfigKey.NODE_RPC_MAX_HEADER_LIST_SIZE) + ? config.getInt(ConfigKey.NODE_RPC_MAX_HEADER_LIST_SIZE) : GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE; PARAMETER.isRpcReflectionServiceEnable = - config.hasPath(Constant.NODE_RPC_REFLECTION_SERVICE) - && config.getBoolean(Constant.NODE_RPC_REFLECTION_SERVICE); + config.hasPath(ConfigKey.NODE_RPC_REFLECTION_SERVICE) + && config.getBoolean(ConfigKey.NODE_RPC_REFLECTION_SERVICE); PARAMETER.maintenanceTimeInterval = - config.hasPath(Constant.BLOCK_MAINTENANCE_TIME_INTERVAL) ? config - .getInt(Constant.BLOCK_MAINTENANCE_TIME_INTERVAL) : 21600000L; + config.hasPath(ConfigKey.BLOCK_MAINTENANCE_TIME_INTERVAL) ? config + .getInt(ConfigKey.BLOCK_MAINTENANCE_TIME_INTERVAL) : 21600000L; PARAMETER.proposalExpireTime = getProposalExpirationTime(config); PARAMETER.checkFrozenTime = - config.hasPath(Constant.BLOCK_CHECK_FROZEN_TIME) ? config - .getInt(Constant.BLOCK_CHECK_FROZEN_TIME) : 1; + config.hasPath(ConfigKey.BLOCK_CHECK_FROZEN_TIME) ? config + .getInt(ConfigKey.BLOCK_CHECK_FROZEN_TIME) : 1; PARAMETER.allowCreationOfContracts = - config.hasPath(Constant.COMMITTEE_ALLOW_CREATION_OF_CONTRACTS) ? config - .getInt(Constant.COMMITTEE_ALLOW_CREATION_OF_CONTRACTS) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_CREATION_OF_CONTRACTS) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_CREATION_OF_CONTRACTS) : 0; PARAMETER.allowMultiSign = - config.hasPath(Constant.COMMITTEE_ALLOW_MULTI_SIGN) ? config - .getInt(Constant.COMMITTEE_ALLOW_MULTI_SIGN) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_MULTI_SIGN) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_MULTI_SIGN) : 0; PARAMETER.allowAdaptiveEnergy = - config.hasPath(Constant.COMMITTEE_ALLOW_ADAPTIVE_ENERGY) ? config - .getInt(Constant.COMMITTEE_ALLOW_ADAPTIVE_ENERGY) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_ADAPTIVE_ENERGY) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_ADAPTIVE_ENERGY) : 0; PARAMETER.allowDelegateResource = - config.hasPath(Constant.COMMITTEE_ALLOW_DELEGATE_RESOURCE) ? config - .getInt(Constant.COMMITTEE_ALLOW_DELEGATE_RESOURCE) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_DELEGATE_RESOURCE) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_DELEGATE_RESOURCE) : 0; PARAMETER.allowSameTokenName = - config.hasPath(Constant.COMMITTEE_ALLOW_SAME_TOKEN_NAME) ? config - .getInt(Constant.COMMITTEE_ALLOW_SAME_TOKEN_NAME) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_SAME_TOKEN_NAME) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_SAME_TOKEN_NAME) : 0; PARAMETER.allowTvmTransferTrc10 = - config.hasPath(Constant.COMMITTEE_ALLOW_TVM_TRANSFER_TRC10) ? config - .getInt(Constant.COMMITTEE_ALLOW_TVM_TRANSFER_TRC10) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TVM_TRANSFER_TRC10) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TVM_TRANSFER_TRC10) : 0; PARAMETER.allowTvmConstantinople = - config.hasPath(Constant.COMMITTEE_ALLOW_TVM_CONSTANTINOPLE) ? config - .getInt(Constant.COMMITTEE_ALLOW_TVM_CONSTANTINOPLE) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TVM_CONSTANTINOPLE) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TVM_CONSTANTINOPLE) : 0; PARAMETER.allowTvmSolidity059 = - config.hasPath(Constant.COMMITTEE_ALLOW_TVM_SOLIDITY059) ? config - .getInt(Constant.COMMITTEE_ALLOW_TVM_SOLIDITY059) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TVM_SOLIDITY059) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TVM_SOLIDITY059) : 0; PARAMETER.forbidTransferToContract = - config.hasPath(Constant.COMMITTEE_FORBID_TRANSFER_TO_CONTRACT) ? config - .getInt(Constant.COMMITTEE_FORBID_TRANSFER_TO_CONTRACT) : 0; + config.hasPath(ConfigKey.COMMITTEE_FORBID_TRANSFER_TO_CONTRACT) ? config + .getInt(ConfigKey.COMMITTEE_FORBID_TRANSFER_TO_CONTRACT) : 0; - PARAMETER.tcpNettyWorkThreadNum = config.hasPath(Constant.NODE_TCP_NETTY_WORK_THREAD_NUM) - ? config.getInt(Constant.NODE_TCP_NETTY_WORK_THREAD_NUM) : 0; + PARAMETER.tcpNettyWorkThreadNum = config.hasPath(ConfigKey.NODE_TCP_NETTY_WORK_THREAD_NUM) + ? config.getInt(ConfigKey.NODE_TCP_NETTY_WORK_THREAD_NUM) : 0; - PARAMETER.udpNettyWorkThreadNum = config.hasPath(Constant.NODE_UDP_NETTY_WORK_THREAD_NUM) - ? config.getInt(Constant.NODE_UDP_NETTY_WORK_THREAD_NUM) : 1; + PARAMETER.udpNettyWorkThreadNum = config.hasPath(ConfigKey.NODE_UDP_NETTY_WORK_THREAD_NUM) + ? config.getInt(ConfigKey.NODE_UDP_NETTY_WORK_THREAD_NUM) : 1; if (StringUtils.isEmpty(PARAMETER.trustNodeAddr)) { PARAMETER.trustNodeAddr = - config.hasPath(Constant.NODE_TRUST_NODE) - ? config.getString(Constant.NODE_TRUST_NODE) : null; + config.hasPath(ConfigKey.NODE_TRUST_NODE) + ? config.getString(ConfigKey.NODE_TRUST_NODE) : null; } PARAMETER.validateSignThreadNum = - config.hasPath(Constant.NODE_VALIDATE_SIGN_THREAD_NUM) ? config - .getInt(Constant.NODE_VALIDATE_SIGN_THREAD_NUM) + config.hasPath(ConfigKey.NODE_VALIDATE_SIGN_THREAD_NUM) ? config + .getInt(ConfigKey.NODE_VALIDATE_SIGN_THREAD_NUM) : Runtime.getRuntime().availableProcessors(); PARAMETER.walletExtensionApi = - config.hasPath(Constant.NODE_WALLET_EXTENSION_API) - && config.getBoolean(Constant.NODE_WALLET_EXTENSION_API); + config.hasPath(ConfigKey.NODE_WALLET_EXTENSION_API) + && config.getBoolean(ConfigKey.NODE_WALLET_EXTENSION_API); PARAMETER.estimateEnergy = - config.hasPath(Constant.VM_ESTIMATE_ENERGY) - && config.getBoolean(Constant.VM_ESTIMATE_ENERGY); - PARAMETER.estimateEnergyMaxRetry = config.hasPath(Constant.VM_ESTIMATE_ENERGY_MAX_RETRY) - ? config.getInt(Constant.VM_ESTIMATE_ENERGY_MAX_RETRY) : 3; + config.hasPath(ConfigKey.VM_ESTIMATE_ENERGY) + && config.getBoolean(ConfigKey.VM_ESTIMATE_ENERGY); + PARAMETER.estimateEnergyMaxRetry = config.hasPath(ConfigKey.VM_ESTIMATE_ENERGY_MAX_RETRY) + ? config.getInt(ConfigKey.VM_ESTIMATE_ENERGY_MAX_RETRY) : 3; if (PARAMETER.estimateEnergyMaxRetry < 0) { PARAMETER.estimateEnergyMaxRetry = 0; } @@ -877,63 +877,63 @@ public static void setParam(final Config config) { PARAMETER.estimateEnergyMaxRetry = 10; } - PARAMETER.receiveTcpMinDataLength = config.hasPath(Constant.NODE_RECEIVE_TCP_MIN_DATA_LENGTH) - ? config.getLong(Constant.NODE_RECEIVE_TCP_MIN_DATA_LENGTH) : 2048; + PARAMETER.receiveTcpMinDataLength = config.hasPath(ConfigKey.NODE_RECEIVE_TCP_MIN_DATA_LENGTH) + ? config.getLong(ConfigKey.NODE_RECEIVE_TCP_MIN_DATA_LENGTH) : 2048; - PARAMETER.isOpenFullTcpDisconnect = config.hasPath(Constant.NODE_IS_OPEN_FULL_TCP_DISCONNECT) - && config.getBoolean(Constant.NODE_IS_OPEN_FULL_TCP_DISCONNECT); + PARAMETER.isOpenFullTcpDisconnect = config.hasPath(ConfigKey.NODE_IS_OPEN_FULL_TCP_DISCONNECT) + && config.getBoolean(ConfigKey.NODE_IS_OPEN_FULL_TCP_DISCONNECT); - PARAMETER.nodeDetectEnable = config.hasPath(Constant.NODE_DETECT_ENABLE) - && config.getBoolean(Constant.NODE_DETECT_ENABLE); + PARAMETER.nodeDetectEnable = config.hasPath(ConfigKey.NODE_DETECT_ENABLE) + && config.getBoolean(ConfigKey.NODE_DETECT_ENABLE); - PARAMETER.inactiveThreshold = config.hasPath(Constant.NODE_INACTIVE_THRESHOLD) - ? config.getInt(Constant.NODE_INACTIVE_THRESHOLD) : 600; + PARAMETER.inactiveThreshold = config.hasPath(ConfigKey.NODE_INACTIVE_THRESHOLD) + ? config.getInt(ConfigKey.NODE_INACTIVE_THRESHOLD) : 600; if (PARAMETER.inactiveThreshold < 1) { PARAMETER.inactiveThreshold = 1; } - PARAMETER.maxTransactionPendingSize = config.hasPath(Constant.NODE_MAX_TRANSACTION_PENDING_SIZE) - ? config.getInt(Constant.NODE_MAX_TRANSACTION_PENDING_SIZE) : 2000; + PARAMETER.maxTransactionPendingSize = config.hasPath(ConfigKey.NODE_MAX_TRANSACTION_PENDING_SIZE) + ? config.getInt(ConfigKey.NODE_MAX_TRANSACTION_PENDING_SIZE) : 2000; - PARAMETER.pendingTransactionTimeout = config.hasPath(Constant.NODE_PENDING_TRANSACTION_TIMEOUT) - ? config.getLong(Constant.NODE_PENDING_TRANSACTION_TIMEOUT) : 60_000; + PARAMETER.pendingTransactionTimeout = config.hasPath(ConfigKey.NODE_PENDING_TRANSACTION_TIMEOUT) + ? config.getLong(ConfigKey.NODE_PENDING_TRANSACTION_TIMEOUT) : 60_000; PARAMETER.needToUpdateAsset = - !config.hasPath(Constant.STORAGE_NEEDTO_UPDATE_ASSET) || config - .getBoolean(Constant.STORAGE_NEEDTO_UPDATE_ASSET); - PARAMETER.trxReferenceBlock = config.hasPath(Constant.TRX_REFERENCE_BLOCK) - ? config.getString(Constant.TRX_REFERENCE_BLOCK) : "solid"; + !config.hasPath(ConfigKey.STORAGE_NEEDTO_UPDATE_ASSET) || config + .getBoolean(ConfigKey.STORAGE_NEEDTO_UPDATE_ASSET); + PARAMETER.trxReferenceBlock = config.hasPath(ConfigKey.TRX_REFERENCE_BLOCK) + ? config.getString(ConfigKey.TRX_REFERENCE_BLOCK) : "solid"; PARAMETER.trxExpirationTimeInMilliseconds = - config.hasPath(Constant.TRX_EXPIRATION_TIME_IN_MILLIS_SECONDS) - && config.getLong(Constant.TRX_EXPIRATION_TIME_IN_MILLIS_SECONDS) > 0 - ? config.getLong(Constant.TRX_EXPIRATION_TIME_IN_MILLIS_SECONDS) + config.hasPath(ConfigKey.TRX_EXPIRATION_TIME_IN_MILLIS_SECONDS) + && config.getLong(ConfigKey.TRX_EXPIRATION_TIME_IN_MILLIS_SECONDS) > 0 + ? config.getLong(ConfigKey.TRX_EXPIRATION_TIME_IN_MILLIS_SECONDS) : Constant.TRANSACTION_DEFAULT_EXPIRATION_TIME; - PARAMETER.minEffectiveConnection = config.hasPath(Constant.NODE_RPC_MIN_EFFECTIVE_CONNECTION) - ? config.getInt(Constant.NODE_RPC_MIN_EFFECTIVE_CONNECTION) : 1; + PARAMETER.minEffectiveConnection = config.hasPath(ConfigKey.NODE_RPC_MIN_EFFECTIVE_CONNECTION) + ? config.getInt(ConfigKey.NODE_RPC_MIN_EFFECTIVE_CONNECTION) : 1; - PARAMETER.trxCacheEnable = config.hasPath(Constant.NODE_RPC_TRX_CACHE_ENABLE) - && config.getBoolean(Constant.NODE_RPC_TRX_CACHE_ENABLE); + PARAMETER.trxCacheEnable = config.hasPath(ConfigKey.NODE_RPC_TRX_CACHE_ENABLE) + && config.getBoolean(ConfigKey.NODE_RPC_TRX_CACHE_ENABLE); - PARAMETER.blockNumForEnergyLimit = config.hasPath(Constant.ENERGY_LIMIT_BLOCK_NUM) - ? config.getInt(Constant.ENERGY_LIMIT_BLOCK_NUM) : 4727890L; + PARAMETER.blockNumForEnergyLimit = config.hasPath(ConfigKey.ENERGY_LIMIT_BLOCK_NUM) + ? config.getInt(ConfigKey.ENERGY_LIMIT_BLOCK_NUM) : 4727890L; PARAMETER.vmTrace = - config.hasPath(Constant.VM_TRACE) && config.getBoolean(Constant.VM_TRACE); + config.hasPath(ConfigKey.VM_TRACE) && config.getBoolean(ConfigKey.VM_TRACE); PARAMETER.saveInternalTx = - config.hasPath(Constant.VM_SAVE_INTERNAL_TX) - && config.getBoolean(Constant.VM_SAVE_INTERNAL_TX); + config.hasPath(ConfigKey.VM_SAVE_INTERNAL_TX) + && config.getBoolean(ConfigKey.VM_SAVE_INTERNAL_TX); PARAMETER.saveFeaturedInternalTx = - config.hasPath(Constant.VM_SAVE_FEATURED_INTERNAL_TX) - && config.getBoolean(Constant.VM_SAVE_FEATURED_INTERNAL_TX); + config.hasPath(ConfigKey.VM_SAVE_FEATURED_INTERNAL_TX) + && config.getBoolean(ConfigKey.VM_SAVE_FEATURED_INTERNAL_TX); if (!PARAMETER.saveCancelAllUnfreezeV2Details - && config.hasPath(Constant.VM_SAVE_CANCEL_ALL_UNFREEZE_V2_DETAILS)) { + && config.hasPath(ConfigKey.VM_SAVE_CANCEL_ALL_UNFREEZE_V2_DETAILS)) { PARAMETER.saveCancelAllUnfreezeV2Details = - config.getBoolean(Constant.VM_SAVE_CANCEL_ALL_UNFREEZE_V2_DETAILS); + config.getBoolean(ConfigKey.VM_SAVE_CANCEL_ALL_UNFREEZE_V2_DETAILS); } if (PARAMETER.saveCancelAllUnfreezeV2Details @@ -947,73 +947,73 @@ public static void setParam(final Config config) { // .getInt(Constant.COMMITTEE_ALLOW_SHIELDED_TRANSACTION) : 0; PARAMETER.allowShieldedTRC20Transaction = - config.hasPath(Constant.COMMITTEE_ALLOW_SHIELDED_TRC20_TRANSACTION) ? config - .getInt(Constant.COMMITTEE_ALLOW_SHIELDED_TRC20_TRANSACTION) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_SHIELDED_TRC20_TRANSACTION) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_SHIELDED_TRC20_TRANSACTION) : 0; PARAMETER.allowMarketTransaction = - config.hasPath(Constant.COMMITTEE_ALLOW_MARKET_TRANSACTION) ? config - .getInt(Constant.COMMITTEE_ALLOW_MARKET_TRANSACTION) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_MARKET_TRANSACTION) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_MARKET_TRANSACTION) : 0; PARAMETER.allowTransactionFeePool = - config.hasPath(Constant.COMMITTEE_ALLOW_TRANSACTION_FEE_POOL) ? config - .getInt(Constant.COMMITTEE_ALLOW_TRANSACTION_FEE_POOL) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TRANSACTION_FEE_POOL) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TRANSACTION_FEE_POOL) : 0; PARAMETER.allowBlackHoleOptimization = - config.hasPath(Constant.COMMITTEE_ALLOW_BLACK_HOLE_OPTIMIZATION) ? config - .getInt(Constant.COMMITTEE_ALLOW_BLACK_HOLE_OPTIMIZATION) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_BLACK_HOLE_OPTIMIZATION) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_BLACK_HOLE_OPTIMIZATION) : 0; PARAMETER.allowNewResourceModel = - config.hasPath(Constant.COMMITTEE_ALLOW_NEW_RESOURCE_MODEL) ? config - .getInt(Constant.COMMITTEE_ALLOW_NEW_RESOURCE_MODEL) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_NEW_RESOURCE_MODEL) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_NEW_RESOURCE_MODEL) : 0; PARAMETER.allowTvmIstanbul = - config.hasPath(Constant.COMMITTEE_ALLOW_TVM_ISTANBUL) ? config - .getInt(Constant.COMMITTEE_ALLOW_TVM_ISTANBUL) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TVM_ISTANBUL) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TVM_ISTANBUL) : 0; PARAMETER.eventPluginConfig = - config.hasPath(Constant.EVENT_SUBSCRIBE) + config.hasPath(ConfigKey.EVENT_SUBSCRIBE) ? getEventPluginConfig(config) : null; PARAMETER.eventFilter = - config.hasPath(Constant.EVENT_SUBSCRIBE_FILTER) ? getEventFilter(config) : null; + config.hasPath(ConfigKey.EVENT_SUBSCRIBE_FILTER) ? getEventFilter(config) : null; - if (config.hasPath(Constant.ALLOW_SHIELDED_TRANSACTION_API)) { + if (config.hasPath(ConfigKey.ALLOW_SHIELDED_TRANSACTION_API)) { PARAMETER.allowShieldedTransactionApi = - config.getBoolean(Constant.ALLOW_SHIELDED_TRANSACTION_API); - } else if (config.hasPath(Constant.NODE_FULLNODE_ALLOW_SHIELDED_TRANSACTION)) { + config.getBoolean(ConfigKey.ALLOW_SHIELDED_TRANSACTION_API); + } else if (config.hasPath(ConfigKey.NODE_FULLNODE_ALLOW_SHIELDED_TRANSACTION)) { // for compatibility with previous configuration PARAMETER.allowShieldedTransactionApi = - config.getBoolean(Constant.NODE_FULLNODE_ALLOW_SHIELDED_TRANSACTION); + config.getBoolean(ConfigKey.NODE_FULLNODE_ALLOW_SHIELDED_TRANSACTION); logger.warn("Configuring [node.fullNodeAllowShieldedTransaction] will be deprecated. " + "Please use [node.allowShieldedTransactionApi] instead."); } else { PARAMETER.allowShieldedTransactionApi = true; } - PARAMETER.zenTokenId = config.hasPath(Constant.NODE_ZEN_TOKENID) - ? config.getString(Constant.NODE_ZEN_TOKENID) : "000000"; + PARAMETER.zenTokenId = config.hasPath(ConfigKey.NODE_ZEN_TOKENID) + ? config.getString(ConfigKey.NODE_ZEN_TOKENID) : "000000"; PARAMETER.allowProtoFilterNum = - config.hasPath(Constant.COMMITTEE_ALLOW_PROTO_FILTER_NUM) ? config - .getInt(Constant.COMMITTEE_ALLOW_PROTO_FILTER_NUM) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_PROTO_FILTER_NUM) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_PROTO_FILTER_NUM) : 0; PARAMETER.allowAccountStateRoot = - config.hasPath(Constant.COMMITTEE_ALLOW_ACCOUNT_STATE_ROOT) ? config - .getInt(Constant.COMMITTEE_ALLOW_ACCOUNT_STATE_ROOT) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_ACCOUNT_STATE_ROOT) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_ACCOUNT_STATE_ROOT) : 0; PARAMETER.validContractProtoThreadNum = - config.hasPath(Constant.NODE_VALID_CONTRACT_PROTO_THREADS) ? config - .getInt(Constant.NODE_VALID_CONTRACT_PROTO_THREADS) + config.hasPath(ConfigKey.NODE_VALID_CONTRACT_PROTO_THREADS) ? config + .getInt(ConfigKey.NODE_VALID_CONTRACT_PROTO_THREADS) : Runtime.getRuntime().availableProcessors(); - PARAMETER.activeNodes = getInetSocketAddress(config, Constant.NODE_ACTIVE, true); + PARAMETER.activeNodes = getInetSocketAddress(config, ConfigKey.NODE_ACTIVE, true); - PARAMETER.passiveNodes = getInetAddress(config, Constant.NODE_PASSIVE); + PARAMETER.passiveNodes = getInetAddress(config, ConfigKey.NODE_PASSIVE); - PARAMETER.fastForwardNodes = getInetSocketAddress(config, Constant.NODE_FAST_FORWARD, true); + PARAMETER.fastForwardNodes = getInetSocketAddress(config, ConfigKey.NODE_FAST_FORWARD, true); - PARAMETER.maxFastForwardNum = config.hasPath(Constant.NODE_MAX_FAST_FORWARD_NUM) ? config - .getInt(Constant.NODE_MAX_FAST_FORWARD_NUM) : 4; + PARAMETER.maxFastForwardNum = config.hasPath(ConfigKey.NODE_MAX_FAST_FORWARD_NUM) ? config + .getInt(ConfigKey.NODE_MAX_FAST_FORWARD_NUM) : 4; if (PARAMETER.maxFastForwardNum > MAX_ACTIVE_WITNESS_NUM) { PARAMETER.maxFastForwardNum = MAX_ACTIVE_WITNESS_NUM; } @@ -1022,49 +1022,49 @@ public static void setParam(final Config config) { } PARAMETER.shieldedTransInPendingMaxCounts = - config.hasPath(Constant.NODE_SHIELDED_TRANS_IN_PENDING_MAX_COUNTS) ? config - .getInt(Constant.NODE_SHIELDED_TRANS_IN_PENDING_MAX_COUNTS) : 10; + config.hasPath(ConfigKey.NODE_SHIELDED_TRANS_IN_PENDING_MAX_COUNTS) ? config + .getInt(ConfigKey.NODE_SHIELDED_TRANS_IN_PENDING_MAX_COUNTS) : 10; PARAMETER.rateLimiterGlobalQps = - config.hasPath(Constant.RATE_LIMITER_GLOBAL_QPS) ? config - .getInt(Constant.RATE_LIMITER_GLOBAL_QPS) : 50000; + config.hasPath(ConfigKey.RATE_LIMITER_GLOBAL_QPS) ? config + .getInt(ConfigKey.RATE_LIMITER_GLOBAL_QPS) : 50000; PARAMETER.rateLimiterGlobalIpQps = - config.hasPath(Constant.RATE_LIMITER_GLOBAL_IP_QPS) ? config - .getInt(Constant.RATE_LIMITER_GLOBAL_IP_QPS) : 10000; + config.hasPath(ConfigKey.RATE_LIMITER_GLOBAL_IP_QPS) ? config + .getInt(ConfigKey.RATE_LIMITER_GLOBAL_IP_QPS) : 10000; PARAMETER.rateLimiterGlobalApiQps = - config.hasPath(Constant.RATE_LIMITER_GLOBAL_API_QPS) ? config - .getInt(Constant.RATE_LIMITER_GLOBAL_API_QPS) : 1000; + config.hasPath(ConfigKey.RATE_LIMITER_GLOBAL_API_QPS) ? config + .getInt(ConfigKey.RATE_LIMITER_GLOBAL_API_QPS) : 1000; PARAMETER.rateLimiterInitialization = getRateLimiterFromConfig(config); PARAMETER.rateLimiterSyncBlockChain = - config.hasPath(Constant.RATE_LIMITER_P2P_SYNC_BLOCK_CHAIN) ? config - .getDouble(Constant.RATE_LIMITER_P2P_SYNC_BLOCK_CHAIN) : 3.0; + config.hasPath(ConfigKey.RATE_LIMITER_P2P_SYNC_BLOCK_CHAIN) ? config + .getDouble(ConfigKey.RATE_LIMITER_P2P_SYNC_BLOCK_CHAIN) : 3.0; PARAMETER.rateLimiterFetchInvData = - config.hasPath(Constant.RATE_LIMITER_P2P_FETCH_INV_DATA) ? config - .getDouble(Constant.RATE_LIMITER_P2P_FETCH_INV_DATA) : 3.0; + config.hasPath(ConfigKey.RATE_LIMITER_P2P_FETCH_INV_DATA) ? config + .getDouble(ConfigKey.RATE_LIMITER_P2P_FETCH_INV_DATA) : 3.0; PARAMETER.rateLimiterDisconnect = - config.hasPath(Constant.RATE_LIMITER_P2P_DISCONNECT) ? config - .getDouble(Constant.RATE_LIMITER_P2P_DISCONNECT) : 1.0; + config.hasPath(ConfigKey.RATE_LIMITER_P2P_DISCONNECT) ? config + .getDouble(ConfigKey.RATE_LIMITER_P2P_DISCONNECT) : 1.0; PARAMETER.changedDelegation = - config.hasPath(Constant.COMMITTEE_CHANGED_DELEGATION) ? config - .getInt(Constant.COMMITTEE_CHANGED_DELEGATION) : 0; + config.hasPath(ConfigKey.COMMITTEE_CHANGED_DELEGATION) ? config + .getInt(ConfigKey.COMMITTEE_CHANGED_DELEGATION) : 0; PARAMETER.allowPBFT = - config.hasPath(Constant.COMMITTEE_ALLOW_PBFT) ? config - .getLong(Constant.COMMITTEE_ALLOW_PBFT) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_PBFT) ? config + .getLong(ConfigKey.COMMITTEE_ALLOW_PBFT) : 0; PARAMETER.pBFTExpireNum = - config.hasPath(Constant.COMMITTEE_PBFT_EXPIRE_NUM) ? config - .getLong(Constant.COMMITTEE_PBFT_EXPIRE_NUM) : 20; + config.hasPath(ConfigKey.COMMITTEE_PBFT_EXPIRE_NUM) ? config + .getLong(ConfigKey.COMMITTEE_PBFT_EXPIRE_NUM) : 20; - PARAMETER.agreeNodeCount = config.hasPath(Constant.NODE_AGREE_NODE_COUNT) ? config - .getInt(Constant.NODE_AGREE_NODE_COUNT) : MAX_ACTIVE_WITNESS_NUM * 2 / 3 + 1; + PARAMETER.agreeNodeCount = config.hasPath(ConfigKey.NODE_AGREE_NODE_COUNT) ? config + .getInt(ConfigKey.NODE_AGREE_NODE_COUNT) : MAX_ACTIVE_WITNESS_NUM * 2 / 3 + 1; PARAMETER.agreeNodeCount = PARAMETER.agreeNodeCount > MAX_ACTIVE_WITNESS_NUM ? MAX_ACTIVE_WITNESS_NUM : PARAMETER.agreeNodeCount; if (PARAMETER.isWitness()) { @@ -1072,32 +1072,32 @@ public static void setParam(final Config config) { } PARAMETER.allowTvmFreeze = - config.hasPath(Constant.COMMITTEE_ALLOW_TVM_FREEZE) ? config - .getInt(Constant.COMMITTEE_ALLOW_TVM_FREEZE) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TVM_FREEZE) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TVM_FREEZE) : 0; PARAMETER.allowTvmVote = - config.hasPath(Constant.COMMITTEE_ALLOW_TVM_VOTE) ? config - .getInt(Constant.COMMITTEE_ALLOW_TVM_VOTE) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TVM_VOTE) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TVM_VOTE) : 0; PARAMETER.allowTvmLondon = - config.hasPath(Constant.COMMITTEE_ALLOW_TVM_LONDON) ? config - .getInt(Constant.COMMITTEE_ALLOW_TVM_LONDON) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TVM_LONDON) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TVM_LONDON) : 0; PARAMETER.allowTvmCompatibleEvm = - config.hasPath(Constant.COMMITTEE_ALLOW_TVM_COMPATIBLE_EVM) ? config - .getInt(Constant.COMMITTEE_ALLOW_TVM_COMPATIBLE_EVM) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TVM_COMPATIBLE_EVM) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TVM_COMPATIBLE_EVM) : 0; PARAMETER.allowHigherLimitForMaxCpuTimeOfOneTx = - config.hasPath(Constant.COMMITTEE_ALLOW_HIGHER_LIMIT_FOR_MAX_CPU_TIME_OF_ONE_TX) ? config - .getInt(Constant.COMMITTEE_ALLOW_HIGHER_LIMIT_FOR_MAX_CPU_TIME_OF_ONE_TX) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_HIGHER_LIMIT_FOR_MAX_CPU_TIME_OF_ONE_TX) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_HIGHER_LIMIT_FOR_MAX_CPU_TIME_OF_ONE_TX) : 0; PARAMETER.allowNewRewardAlgorithm = - config.hasPath(Constant.COMMITTEE_ALLOW_NEW_REWARD_ALGORITHM) ? config - .getInt(Constant.COMMITTEE_ALLOW_NEW_REWARD_ALGORITHM) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_NEW_REWARD_ALGORITHM) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_NEW_REWARD_ALGORITHM) : 0; PARAMETER.allowOptimizedReturnValueOfChainId = - config.hasPath(Constant.COMMITTEE_ALLOW_OPTIMIZED_RETURN_VALUE_OF_CHAIN_ID) ? config - .getInt(Constant.COMMITTEE_ALLOW_OPTIMIZED_RETURN_VALUE_OF_CHAIN_ID) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_OPTIMIZED_RETURN_VALUE_OF_CHAIN_ID) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_OPTIMIZED_RETURN_VALUE_OF_CHAIN_ID) : 0; initBackupProperty(config); if (Constant.ROCKSDB.equalsIgnoreCase(CommonParameter @@ -1107,80 +1107,80 @@ public static void setParam(final Config config) { } PARAMETER.actuatorSet = - config.hasPath(Constant.ACTUATOR_WHITELIST) - ? new HashSet<>(config.getStringList(Constant.ACTUATOR_WHITELIST)) + config.hasPath(ConfigKey.ACTUATOR_WHITELIST) + ? new HashSet<>(config.getStringList(ConfigKey.ACTUATOR_WHITELIST)) : Collections.emptySet(); - if (config.hasPath(Constant.NODE_METRICS_ENABLE)) { - PARAMETER.nodeMetricsEnable = config.getBoolean(Constant.NODE_METRICS_ENABLE); - } - - PARAMETER.metricsStorageEnable = config.hasPath(Constant.METRICS_STORAGE_ENABLE) && config - .getBoolean(Constant.METRICS_STORAGE_ENABLE); - PARAMETER.influxDbIp = config.hasPath(Constant.METRICS_INFLUXDB_IP) ? config - .getString(Constant.METRICS_INFLUXDB_IP) : Constant.LOCAL_HOST; - PARAMETER.influxDbPort = config.hasPath(Constant.METRICS_INFLUXDB_PORT) ? config - .getInt(Constant.METRICS_INFLUXDB_PORT) : 8086; - PARAMETER.influxDbDatabase = config.hasPath(Constant.METRICS_INFLUXDB_DATABASE) ? config - .getString(Constant.METRICS_INFLUXDB_DATABASE) : "metrics"; - PARAMETER.metricsReportInterval = config.hasPath(Constant.METRICS_REPORT_INTERVAL) ? config - .getInt(Constant.METRICS_REPORT_INTERVAL) : 10; - - PARAMETER.metricsPrometheusEnable = config.hasPath(Constant.METRICS_PROMETHEUS_ENABLE) && config - .getBoolean(Constant.METRICS_PROMETHEUS_ENABLE); - PARAMETER.metricsPrometheusPort = config.hasPath(Constant.METRICS_PROMETHEUS_PORT) ? config - .getInt(Constant.METRICS_PROMETHEUS_PORT) : 9527; + if (config.hasPath(ConfigKey.NODE_METRICS_ENABLE)) { + PARAMETER.nodeMetricsEnable = config.getBoolean(ConfigKey.NODE_METRICS_ENABLE); + } + + PARAMETER.metricsStorageEnable = config.hasPath(ConfigKey.METRICS_STORAGE_ENABLE) && config + .getBoolean(ConfigKey.METRICS_STORAGE_ENABLE); + PARAMETER.influxDbIp = config.hasPath(ConfigKey.METRICS_INFLUXDB_IP) ? config + .getString(ConfigKey.METRICS_INFLUXDB_IP) : Constant.LOCAL_HOST; + PARAMETER.influxDbPort = config.hasPath(ConfigKey.METRICS_INFLUXDB_PORT) ? config + .getInt(ConfigKey.METRICS_INFLUXDB_PORT) : 8086; + PARAMETER.influxDbDatabase = config.hasPath(ConfigKey.METRICS_INFLUXDB_DATABASE) ? config + .getString(ConfigKey.METRICS_INFLUXDB_DATABASE) : "metrics"; + PARAMETER.metricsReportInterval = config.hasPath(ConfigKey.METRICS_REPORT_INTERVAL) ? config + .getInt(ConfigKey.METRICS_REPORT_INTERVAL) : 10; + + PARAMETER.metricsPrometheusEnable = config.hasPath(ConfigKey.METRICS_PROMETHEUS_ENABLE) && config + .getBoolean(ConfigKey.METRICS_PROMETHEUS_ENABLE); + PARAMETER.metricsPrometheusPort = config.hasPath(ConfigKey.METRICS_PROMETHEUS_PORT) ? config + .getInt(ConfigKey.METRICS_PROMETHEUS_PORT) : 9527; PARAMETER.setOpenHistoryQueryWhenLiteFN( - config.hasPath(Constant.NODE_OPEN_HISTORY_QUERY_WHEN_LITEFN) - && config.getBoolean(Constant.NODE_OPEN_HISTORY_QUERY_WHEN_LITEFN)); + config.hasPath(ConfigKey.NODE_OPEN_HISTORY_QUERY_WHEN_LITEFN) + && config.getBoolean(ConfigKey.NODE_OPEN_HISTORY_QUERY_WHEN_LITEFN)); - PARAMETER.historyBalanceLookup = config.hasPath(Constant.HISTORY_BALANCE_LOOKUP) && config - .getBoolean(Constant.HISTORY_BALANCE_LOOKUP); + PARAMETER.historyBalanceLookup = config.hasPath(ConfigKey.HISTORY_BALANCE_LOOKUP) && config + .getBoolean(ConfigKey.HISTORY_BALANCE_LOOKUP); - if (config.hasPath(Constant.OPEN_PRINT_LOG)) { - PARAMETER.openPrintLog = config.getBoolean(Constant.OPEN_PRINT_LOG); + if (config.hasPath(ConfigKey.OPEN_PRINT_LOG)) { + PARAMETER.openPrintLog = config.getBoolean(ConfigKey.OPEN_PRINT_LOG); } - PARAMETER.openTransactionSort = config.hasPath(Constant.OPEN_TRANSACTION_SORT) && config - .getBoolean(Constant.OPEN_TRANSACTION_SORT); + PARAMETER.openTransactionSort = config.hasPath(ConfigKey.OPEN_TRANSACTION_SORT) && config + .getBoolean(ConfigKey.OPEN_TRANSACTION_SORT); PARAMETER.allowAccountAssetOptimization = config - .hasPath(Constant.ALLOW_ACCOUNT_ASSET_OPTIMIZATION) ? config - .getInt(Constant.ALLOW_ACCOUNT_ASSET_OPTIMIZATION) : 0; + .hasPath(ConfigKey.ALLOW_ACCOUNT_ASSET_OPTIMIZATION) ? config + .getInt(ConfigKey.ALLOW_ACCOUNT_ASSET_OPTIMIZATION) : 0; PARAMETER.allowAssetOptimization = config - .hasPath(Constant.ALLOW_ASSET_OPTIMIZATION) ? config - .getInt(Constant.ALLOW_ASSET_OPTIMIZATION) : 0; + .hasPath(ConfigKey.ALLOW_ASSET_OPTIMIZATION) ? config + .getInt(ConfigKey.ALLOW_ASSET_OPTIMIZATION) : 0; PARAMETER.disabledApiList = - config.hasPath(Constant.NODE_DISABLED_API_LIST) - ? config.getStringList(Constant.NODE_DISABLED_API_LIST) + config.hasPath(ConfigKey.NODE_DISABLED_API_LIST) + ? config.getStringList(ConfigKey.NODE_DISABLED_API_LIST) .stream().map(String::toLowerCase).collect(Collectors.toList()) : Collections.emptyList(); - if (config.hasPath(Constant.NODE_SHUTDOWN_BLOCK_TIME)) { + if (config.hasPath(ConfigKey.NODE_SHUTDOWN_BLOCK_TIME)) { try { PARAMETER.shutdownBlockTime = new CronExpression(config.getString( - Constant.NODE_SHUTDOWN_BLOCK_TIME)); + ConfigKey.NODE_SHUTDOWN_BLOCK_TIME)); } catch (ParseException e) { throw new TronError(e, TronError.ErrCode.AUTO_STOP_PARAMS); } } - if (config.hasPath(Constant.NODE_SHUTDOWN_BLOCK_HEIGHT)) { - PARAMETER.shutdownBlockHeight = config.getLong(Constant.NODE_SHUTDOWN_BLOCK_HEIGHT); + if (config.hasPath(ConfigKey.NODE_SHUTDOWN_BLOCK_HEIGHT)) { + PARAMETER.shutdownBlockHeight = config.getLong(ConfigKey.NODE_SHUTDOWN_BLOCK_HEIGHT); } - if (config.hasPath(Constant.NODE_SHUTDOWN_BLOCK_COUNT)) { - PARAMETER.shutdownBlockCount = config.getLong(Constant.NODE_SHUTDOWN_BLOCK_COUNT); + if (config.hasPath(ConfigKey.NODE_SHUTDOWN_BLOCK_COUNT)) { + PARAMETER.shutdownBlockCount = config.getLong(ConfigKey.NODE_SHUTDOWN_BLOCK_COUNT); } - if (config.hasPath(Constant.BLOCK_CACHE_TIMEOUT)) { - PARAMETER.blockCacheTimeout = config.getLong(Constant.BLOCK_CACHE_TIMEOUT); + if (config.hasPath(ConfigKey.BLOCK_CACHE_TIMEOUT)) { + PARAMETER.blockCacheTimeout = config.getLong(ConfigKey.BLOCK_CACHE_TIMEOUT); } - if (config.hasPath(Constant.ALLOW_NEW_REWARD)) { - PARAMETER.allowNewReward = config.getLong(Constant.ALLOW_NEW_REWARD); + if (config.hasPath(ConfigKey.ALLOW_NEW_REWARD)) { + PARAMETER.allowNewReward = config.getLong(ConfigKey.ALLOW_NEW_REWARD); if (PARAMETER.allowNewReward > 1) { PARAMETER.allowNewReward = 1; } @@ -1189,8 +1189,8 @@ public static void setParam(final Config config) { } } - if (config.hasPath(Constant.MEMO_FEE)) { - PARAMETER.memoFee = config.getLong(Constant.MEMO_FEE); + if (config.hasPath(ConfigKey.MEMO_FEE)) { + PARAMETER.memoFee = config.getLong(ConfigKey.MEMO_FEE); if (PARAMETER.memoFee > 1_000_000_000) { PARAMETER.memoFee = 1_000_000_000; } @@ -1199,14 +1199,14 @@ public static void setParam(final Config config) { } } - if (config.hasPath(Constant.ALLOW_DELEGATE_OPTIMIZATION)) { - PARAMETER.allowDelegateOptimization = config.getLong(Constant.ALLOW_DELEGATE_OPTIMIZATION); + if (config.hasPath(ConfigKey.ALLOW_DELEGATE_OPTIMIZATION)) { + PARAMETER.allowDelegateOptimization = config.getLong(ConfigKey.ALLOW_DELEGATE_OPTIMIZATION); PARAMETER.allowDelegateOptimization = min(PARAMETER.allowDelegateOptimization, 1, true); PARAMETER.allowDelegateOptimization = max(PARAMETER.allowDelegateOptimization, 0, true); } - if (config.hasPath(Constant.COMMITTEE_UNFREEZE_DELAY_DAYS)) { - PARAMETER.unfreezeDelayDays = config.getLong(Constant.COMMITTEE_UNFREEZE_DELAY_DAYS); + if (config.hasPath(ConfigKey.COMMITTEE_UNFREEZE_DELAY_DAYS)) { + PARAMETER.unfreezeDelayDays = config.getLong(ConfigKey.COMMITTEE_UNFREEZE_DELAY_DAYS); if (PARAMETER.unfreezeDelayDays > 365) { PARAMETER.unfreezeDelayDays = 365; } @@ -1215,40 +1215,40 @@ public static void setParam(final Config config) { } } - if (config.hasPath(Constant.ALLOW_DYNAMIC_ENERGY)) { - PARAMETER.allowDynamicEnergy = config.getLong(Constant.ALLOW_DYNAMIC_ENERGY); + if (config.hasPath(ConfigKey.ALLOW_DYNAMIC_ENERGY)) { + PARAMETER.allowDynamicEnergy = config.getLong(ConfigKey.ALLOW_DYNAMIC_ENERGY); PARAMETER.allowDynamicEnergy = min(PARAMETER.allowDynamicEnergy, 1, true); PARAMETER.allowDynamicEnergy = max(PARAMETER.allowDynamicEnergy, 0, true); } - if (config.hasPath(Constant.DYNAMIC_ENERGY_THRESHOLD)) { - PARAMETER.dynamicEnergyThreshold = config.getLong(Constant.DYNAMIC_ENERGY_THRESHOLD); + if (config.hasPath(ConfigKey.DYNAMIC_ENERGY_THRESHOLD)) { + PARAMETER.dynamicEnergyThreshold = config.getLong(ConfigKey.DYNAMIC_ENERGY_THRESHOLD); PARAMETER.dynamicEnergyThreshold = min(PARAMETER.dynamicEnergyThreshold, 100_000_000_000_000_000L, true); PARAMETER.dynamicEnergyThreshold = max(PARAMETER.dynamicEnergyThreshold, 0, true); } - if (config.hasPath(Constant.DYNAMIC_ENERGY_INCREASE_FACTOR)) { + if (config.hasPath(ConfigKey.DYNAMIC_ENERGY_INCREASE_FACTOR)) { PARAMETER.dynamicEnergyIncreaseFactor - = config.getLong(Constant.DYNAMIC_ENERGY_INCREASE_FACTOR); + = config.getLong(ConfigKey.DYNAMIC_ENERGY_INCREASE_FACTOR); PARAMETER.dynamicEnergyIncreaseFactor = min(PARAMETER.dynamicEnergyIncreaseFactor, DYNAMIC_ENERGY_INCREASE_FACTOR_RANGE, true); PARAMETER.dynamicEnergyIncreaseFactor = max(PARAMETER.dynamicEnergyIncreaseFactor, 0, true); } - if (config.hasPath(Constant.DYNAMIC_ENERGY_MAX_FACTOR)) { + if (config.hasPath(ConfigKey.DYNAMIC_ENERGY_MAX_FACTOR)) { PARAMETER.dynamicEnergyMaxFactor - = config.getLong(Constant.DYNAMIC_ENERGY_MAX_FACTOR); + = config.getLong(ConfigKey.DYNAMIC_ENERGY_MAX_FACTOR); PARAMETER.dynamicEnergyMaxFactor = min(PARAMETER.dynamicEnergyMaxFactor, DYNAMIC_ENERGY_MAX_FACTOR_RANGE, true); PARAMETER.dynamicEnergyMaxFactor = max(PARAMETER.dynamicEnergyMaxFactor, 0, true); } - PARAMETER.dynamicConfigEnable = config.hasPath(Constant.DYNAMIC_CONFIG_ENABLE) - && config.getBoolean(Constant.DYNAMIC_CONFIG_ENABLE); - if (config.hasPath(Constant.DYNAMIC_CONFIG_CHECK_INTERVAL)) { + PARAMETER.dynamicConfigEnable = config.hasPath(ConfigKey.DYNAMIC_CONFIG_ENABLE) + && config.getBoolean(ConfigKey.DYNAMIC_CONFIG_ENABLE); + if (config.hasPath(ConfigKey.DYNAMIC_CONFIG_CHECK_INTERVAL)) { PARAMETER.dynamicConfigCheckInterval - = config.getLong(Constant.DYNAMIC_CONFIG_CHECK_INTERVAL); + = config.getLong(ConfigKey.DYNAMIC_CONFIG_CHECK_INTERVAL); if (PARAMETER.dynamicConfigCheckInterval <= 0) { PARAMETER.dynamicConfigCheckInterval = 600; } @@ -1257,19 +1257,19 @@ public static void setParam(final Config config) { } PARAMETER.allowTvmShangHai = - config.hasPath(Constant.COMMITTEE_ALLOW_TVM_SHANGHAI) ? config - .getInt(Constant.COMMITTEE_ALLOW_TVM_SHANGHAI) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TVM_SHANGHAI) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TVM_SHANGHAI) : 0; PARAMETER.unsolidifiedBlockCheck = - config.hasPath(Constant.UNSOLIDIFIED_BLOCK_CHECK) - && config.getBoolean(Constant.UNSOLIDIFIED_BLOCK_CHECK); + config.hasPath(ConfigKey.UNSOLIDIFIED_BLOCK_CHECK) + && config.getBoolean(ConfigKey.UNSOLIDIFIED_BLOCK_CHECK); PARAMETER.maxUnsolidifiedBlocks = - config.hasPath(Constant.MAX_UNSOLIDIFIED_BLOCKS) ? config - .getInt(Constant.MAX_UNSOLIDIFIED_BLOCKS) : 54; + config.hasPath(ConfigKey.MAX_UNSOLIDIFIED_BLOCKS) ? config + .getInt(ConfigKey.MAX_UNSOLIDIFIED_BLOCKS) : 54; - long allowOldRewardOpt = config.hasPath(Constant.COMMITTEE_ALLOW_OLD_REWARD_OPT) ? config - .getInt(Constant.COMMITTEE_ALLOW_OLD_REWARD_OPT) : 0; + long allowOldRewardOpt = config.hasPath(ConfigKey.COMMITTEE_ALLOW_OLD_REWARD_OPT) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_OLD_REWARD_OPT) : 0; if (allowOldRewardOpt == 1 && PARAMETER.allowNewRewardAlgorithm != 1 && PARAMETER.allowNewReward != 1 && PARAMETER.allowTvmVote != 1) { throw new IllegalArgumentException( @@ -1281,35 +1281,35 @@ public static void setParam(final Config config) { PARAMETER.allowOldRewardOpt = allowOldRewardOpt; PARAMETER.allowEnergyAdjustment = - config.hasPath(Constant.COMMITTEE_ALLOW_ENERGY_ADJUSTMENT) ? config - .getInt(Constant.COMMITTEE_ALLOW_ENERGY_ADJUSTMENT) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_ENERGY_ADJUSTMENT) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_ENERGY_ADJUSTMENT) : 0; PARAMETER.allowStrictMath = - config.hasPath(Constant.COMMITTEE_ALLOW_STRICT_MATH) ? config - .getInt(Constant.COMMITTEE_ALLOW_STRICT_MATH) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_STRICT_MATH) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_STRICT_MATH) : 0; PARAMETER.consensusLogicOptimization = - config.hasPath(Constant.COMMITTEE_CONSENSUS_LOGIC_OPTIMIZATION) ? config - .getInt(Constant.COMMITTEE_CONSENSUS_LOGIC_OPTIMIZATION) : 0; + config.hasPath(ConfigKey.COMMITTEE_CONSENSUS_LOGIC_OPTIMIZATION) ? config + .getInt(ConfigKey.COMMITTEE_CONSENSUS_LOGIC_OPTIMIZATION) : 0; PARAMETER.allowTvmCancun = - config.hasPath(Constant.COMMITTEE_ALLOW_TVM_CANCUN) ? config - .getInt(Constant.COMMITTEE_ALLOW_TVM_CANCUN) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TVM_CANCUN) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TVM_CANCUN) : 0; PARAMETER.allowTvmBlob = - config.hasPath(Constant.COMMITTEE_ALLOW_TVM_BLOB) ? config - .getInt(Constant.COMMITTEE_ALLOW_TVM_BLOB) : 0; + config.hasPath(ConfigKey.COMMITTEE_ALLOW_TVM_BLOB) ? config + .getInt(ConfigKey.COMMITTEE_ALLOW_TVM_BLOB) : 0; logConfig(); } private static long getProposalExpirationTime(final Config config) { - if (config.hasPath(Constant.COMMITTEE_PROPOSAL_EXPIRE_TIME)) { + if (config.hasPath(ConfigKey.COMMITTEE_PROPOSAL_EXPIRE_TIME)) { throw new TronError("It is not allowed to configure committee.proposalExpireTime in " + "config.conf, please set the value in block.proposalExpireTime.", PARAMETER_INIT); } - if (config.hasPath(Constant.BLOCK_PROPOSAL_EXPIRE_TIME)) { - long proposalExpireTime = config.getLong(Constant.BLOCK_PROPOSAL_EXPIRE_TIME); + if (config.hasPath(ConfigKey.BLOCK_PROPOSAL_EXPIRE_TIME)) { + long proposalExpireTime = config.getLong(ConfigKey.BLOCK_PROPOSAL_EXPIRE_TIME); if (proposalExpireTime <= MIN_PROPOSAL_EXPIRE_TIME || proposalExpireTime >= MAX_PROPOSAL_EXPIRE_TIME) { throw new TronError("The value[block.proposalExpireTime] is only allowed to " @@ -1323,7 +1323,7 @@ private static long getProposalExpirationTime(final Config config) { } private static List getWitnessesFromConfig(final com.typesafe.config.Config config) { - return config.getObjectList(Constant.GENESIS_BLOCK_WITNESSES).stream() + return config.getObjectList(ConfigKey.GENESIS_BLOCK_WITNESSES).stream() .map(Args::createWitness) .collect(Collectors.toCollection(ArrayList::new)); } @@ -1338,7 +1338,7 @@ private static Witness createWitness(final ConfigObject witnessAccount) { } private static List getAccountsFromConfig(final com.typesafe.config.Config config) { - return config.getObjectList(Constant.GENESIS_BLOCK_ASSETS).stream() + return config.getObjectList(ConfigKey.GENESIS_BLOCK_ASSETS).stream() .map(Args::createAccount) .collect(Collectors.toCollection(ArrayList::new)); } @@ -1355,16 +1355,16 @@ private static Account createAccount(final ConfigObject asset) { private static RateLimiterInitialization getRateLimiterFromConfig( final com.typesafe.config.Config config) { RateLimiterInitialization initialization = new RateLimiterInitialization(); - if (config.hasPath(Constant.RATE_LIMITER_HTTP)) { + if (config.hasPath(ConfigKey.RATE_LIMITER_HTTP)) { ArrayList list1 = config - .getObjectList(Constant.RATE_LIMITER_HTTP).stream() + .getObjectList(ConfigKey.RATE_LIMITER_HTTP).stream() .map(RateLimiterInitialization::createHttpItem) .collect(Collectors.toCollection(ArrayList::new)); initialization.setHttpMap(list1); } - if (config.hasPath(Constant.RATE_LIMITER_RPC)) { + if (config.hasPath(ConfigKey.RATE_LIMITER_RPC)) { ArrayList list2 = config - .getObjectList(Constant.RATE_LIMITER_RPC).stream() + .getObjectList(ConfigKey.RATE_LIMITER_RPC).stream() .map(RateLimiterInitialization::createRpcItem) .collect(Collectors.toCollection(ArrayList::new)); initialization.setRpcMap(list2); @@ -1415,27 +1415,27 @@ private static EventPluginConfig getEventPluginConfig( final com.typesafe.config.Config config) { EventPluginConfig eventPluginConfig = new EventPluginConfig(); - if (config.hasPath(Constant.EVENT_SUBSCRIBE_VERSION)) { - eventPluginConfig.setVersion(config.getInt(Constant.EVENT_SUBSCRIBE_VERSION)); + if (config.hasPath(ConfigKey.EVENT_SUBSCRIBE_VERSION)) { + eventPluginConfig.setVersion(config.getInt(ConfigKey.EVENT_SUBSCRIBE_VERSION)); } - if (config.hasPath(Constant.EVENT_SUBSCRIBE_START_SYNC_BLOCK_NUM)) { + if (config.hasPath(ConfigKey.EVENT_SUBSCRIBE_START_SYNC_BLOCK_NUM)) { eventPluginConfig.setStartSyncBlockNum(config - .getLong(Constant.EVENT_SUBSCRIBE_START_SYNC_BLOCK_NUM)); + .getLong(ConfigKey.EVENT_SUBSCRIBE_START_SYNC_BLOCK_NUM)); } boolean useNativeQueue = false; int bindPort = 0; int sendQueueLength = 0; - if (config.hasPath(Constant.USE_NATIVE_QUEUE)) { - useNativeQueue = config.getBoolean(Constant.USE_NATIVE_QUEUE); + if (config.hasPath(ConfigKey.USE_NATIVE_QUEUE)) { + useNativeQueue = config.getBoolean(ConfigKey.USE_NATIVE_QUEUE); - if (config.hasPath(Constant.NATIVE_QUEUE_BIND_PORT)) { - bindPort = config.getInt(Constant.NATIVE_QUEUE_BIND_PORT); + if (config.hasPath(ConfigKey.NATIVE_QUEUE_BIND_PORT)) { + bindPort = config.getInt(ConfigKey.NATIVE_QUEUE_BIND_PORT); } - if (config.hasPath(Constant.NATIVE_QUEUE_SEND_LENGTH)) { - sendQueueLength = config.getInt(Constant.NATIVE_QUEUE_SEND_LENGTH); + if (config.hasPath(ConfigKey.NATIVE_QUEUE_SEND_LENGTH)) { + sendQueueLength = config.getInt(ConfigKey.NATIVE_QUEUE_SEND_LENGTH); } eventPluginConfig.setUseNativeQueue(useNativeQueue); @@ -1445,30 +1445,30 @@ private static EventPluginConfig getEventPluginConfig( // use event plugin if (!useNativeQueue) { - if (config.hasPath(Constant.EVENT_SUBSCRIBE_PATH)) { - String pluginPath = config.getString(Constant.EVENT_SUBSCRIBE_PATH); + if (config.hasPath(ConfigKey.EVENT_SUBSCRIBE_PATH)) { + String pluginPath = config.getString(ConfigKey.EVENT_SUBSCRIBE_PATH); if (StringUtils.isNotEmpty(pluginPath)) { eventPluginConfig.setPluginPath(pluginPath.trim()); } } - if (config.hasPath(Constant.EVENT_SUBSCRIBE_SERVER)) { - String serverAddress = config.getString(Constant.EVENT_SUBSCRIBE_SERVER); + if (config.hasPath(ConfigKey.EVENT_SUBSCRIBE_SERVER)) { + String serverAddress = config.getString(ConfigKey.EVENT_SUBSCRIBE_SERVER); if (StringUtils.isNotEmpty(serverAddress)) { eventPluginConfig.setServerAddress(serverAddress.trim()); } } - if (config.hasPath(Constant.EVENT_SUBSCRIBE_DB_CONFIG)) { - String dbConfig = config.getString(Constant.EVENT_SUBSCRIBE_DB_CONFIG); + if (config.hasPath(ConfigKey.EVENT_SUBSCRIBE_DB_CONFIG)) { + String dbConfig = config.getString(ConfigKey.EVENT_SUBSCRIBE_DB_CONFIG); if (StringUtils.isNotEmpty(dbConfig)) { eventPluginConfig.setDbConfig(dbConfig.trim()); } } } - if (config.hasPath(Constant.EVENT_SUBSCRIBE_TOPICS)) { - List triggerConfigList = config.getObjectList(Constant.EVENT_SUBSCRIBE_TOPICS) + if (config.hasPath(ConfigKey.EVENT_SUBSCRIBE_TOPICS)) { + List triggerConfigList = config.getObjectList(ConfigKey.EVENT_SUBSCRIBE_TOPICS) .stream() .map(Args::createTriggerConfig) .collect(Collectors.toCollection(ArrayList::new)); @@ -1487,7 +1487,7 @@ private static List loadSeeds(final com.typesafe.config.Confi inetSocketAddressList.add(inetSocketAddress); } } else { - inetSocketAddressList = getInetSocketAddress(config, Constant.SEED_NODE_IP_LIST, false); + inetSocketAddressList = getInetSocketAddress(config, ConfigKey.SEED_NODE_IP_LIST, false); } return inetSocketAddressList; @@ -1495,8 +1495,8 @@ private static List loadSeeds(final com.typesafe.config.Confi public static PublishConfig loadDnsPublishConfig(final com.typesafe.config.Config config) { PublishConfig publishConfig = new PublishConfig(); - if (config.hasPath(Constant.NODE_DNS_PUBLISH)) { - publishConfig.setDnsPublishEnable(config.getBoolean(Constant.NODE_DNS_PUBLISH)); + if (config.hasPath(ConfigKey.NODE_DNS_PUBLISH)) { + publishConfig.setDnsPublishEnable(config.getBoolean(ConfigKey.NODE_DNS_PUBLISH)); } loadDnsPublishParameters(config, publishConfig); return publishConfig; @@ -1505,54 +1505,54 @@ public static PublishConfig loadDnsPublishConfig(final com.typesafe.config.Confi public static void loadDnsPublishParameters(final com.typesafe.config.Config config, PublishConfig publishConfig) { if (publishConfig.isDnsPublishEnable()) { - if (config.hasPath(Constant.NODE_DNS_DOMAIN) && StringUtils.isNotEmpty( - config.getString(Constant.NODE_DNS_DOMAIN))) { - publishConfig.setDnsDomain(config.getString(Constant.NODE_DNS_DOMAIN)); + if (config.hasPath(ConfigKey.NODE_DNS_DOMAIN) && StringUtils.isNotEmpty( + config.getString(ConfigKey.NODE_DNS_DOMAIN))) { + publishConfig.setDnsDomain(config.getString(ConfigKey.NODE_DNS_DOMAIN)); } else { - logEmptyError(Constant.NODE_DNS_DOMAIN); + logEmptyError(ConfigKey.NODE_DNS_DOMAIN); } - if (config.hasPath(Constant.NODE_DNS_CHANGE_THRESHOLD)) { - double changeThreshold = config.getDouble(Constant.NODE_DNS_CHANGE_THRESHOLD); + if (config.hasPath(ConfigKey.NODE_DNS_CHANGE_THRESHOLD)) { + double changeThreshold = config.getDouble(ConfigKey.NODE_DNS_CHANGE_THRESHOLD); if (changeThreshold > 0) { publishConfig.setChangeThreshold(changeThreshold); } else { logger.error("Check {}, should be bigger than 0, default 0.1", - Constant.NODE_DNS_CHANGE_THRESHOLD); + ConfigKey.NODE_DNS_CHANGE_THRESHOLD); } } - if (config.hasPath(Constant.NODE_DNS_MAX_MERGE_SIZE)) { - int maxMergeSize = config.getInt(Constant.NODE_DNS_MAX_MERGE_SIZE); + if (config.hasPath(ConfigKey.NODE_DNS_MAX_MERGE_SIZE)) { + int maxMergeSize = config.getInt(ConfigKey.NODE_DNS_MAX_MERGE_SIZE); if (maxMergeSize >= 1 && maxMergeSize <= 5) { publishConfig.setMaxMergeSize(maxMergeSize); } else { - logger.error("Check {}, should be [1~5], default 5", Constant.NODE_DNS_MAX_MERGE_SIZE); + logger.error("Check {}, should be [1~5], default 5", ConfigKey.NODE_DNS_MAX_MERGE_SIZE); } } - if (config.hasPath(Constant.NODE_DNS_PRIVATE) && StringUtils.isNotEmpty( - config.getString(Constant.NODE_DNS_PRIVATE))) { - publishConfig.setDnsPrivate(config.getString(Constant.NODE_DNS_PRIVATE)); + if (config.hasPath(ConfigKey.NODE_DNS_PRIVATE) && StringUtils.isNotEmpty( + config.getString(ConfigKey.NODE_DNS_PRIVATE))) { + publishConfig.setDnsPrivate(config.getString(ConfigKey.NODE_DNS_PRIVATE)); } else { - logEmptyError(Constant.NODE_DNS_PRIVATE); + logEmptyError(ConfigKey.NODE_DNS_PRIVATE); } - if (config.hasPath(Constant.NODE_DNS_KNOWN_URLS)) { - publishConfig.setKnownTreeUrls(config.getStringList(Constant.NODE_DNS_KNOWN_URLS)); + if (config.hasPath(ConfigKey.NODE_DNS_KNOWN_URLS)) { + publishConfig.setKnownTreeUrls(config.getStringList(ConfigKey.NODE_DNS_KNOWN_URLS)); } - if (config.hasPath(Constant.NODE_DNS_STATIC_NODES)) { + if (config.hasPath(ConfigKey.NODE_DNS_STATIC_NODES)) { publishConfig.setStaticNodes( - getInetSocketAddress(config, Constant.NODE_DNS_STATIC_NODES, false)); + getInetSocketAddress(config, ConfigKey.NODE_DNS_STATIC_NODES, false)); } - if (config.hasPath(Constant.NODE_DNS_SERVER_TYPE) && StringUtils.isNotEmpty( - config.getString(Constant.NODE_DNS_SERVER_TYPE))) { - String serverType = config.getString(Constant.NODE_DNS_SERVER_TYPE); + if (config.hasPath(ConfigKey.NODE_DNS_SERVER_TYPE) && StringUtils.isNotEmpty( + config.getString(ConfigKey.NODE_DNS_SERVER_TYPE))) { + String serverType = config.getString(ConfigKey.NODE_DNS_SERVER_TYPE); if (!"aws".equalsIgnoreCase(serverType) && !"aliyun".equalsIgnoreCase(serverType)) { throw new IllegalArgumentException( - String.format("Check %s, must be aws or aliyun", Constant.NODE_DNS_SERVER_TYPE)); + String.format("Check %s, must be aws or aliyun", ConfigKey.NODE_DNS_SERVER_TYPE)); } if ("aws".equalsIgnoreCase(serverType)) { publishConfig.setDnsType(DnsType.AwsRoute53); @@ -1560,38 +1560,38 @@ public static void loadDnsPublishParameters(final com.typesafe.config.Config con publishConfig.setDnsType(DnsType.AliYun); } } else { - logEmptyError(Constant.NODE_DNS_SERVER_TYPE); + logEmptyError(ConfigKey.NODE_DNS_SERVER_TYPE); } - if (config.hasPath(Constant.NODE_DNS_ACCESS_KEY_ID) && StringUtils.isNotEmpty( - config.getString(Constant.NODE_DNS_ACCESS_KEY_ID))) { - publishConfig.setAccessKeyId(config.getString(Constant.NODE_DNS_ACCESS_KEY_ID)); + if (config.hasPath(ConfigKey.NODE_DNS_ACCESS_KEY_ID) && StringUtils.isNotEmpty( + config.getString(ConfigKey.NODE_DNS_ACCESS_KEY_ID))) { + publishConfig.setAccessKeyId(config.getString(ConfigKey.NODE_DNS_ACCESS_KEY_ID)); } else { - logEmptyError(Constant.NODE_DNS_ACCESS_KEY_ID); + logEmptyError(ConfigKey.NODE_DNS_ACCESS_KEY_ID); } - if (config.hasPath(Constant.NODE_DNS_ACCESS_KEY_SECRET) && StringUtils.isNotEmpty( - config.getString(Constant.NODE_DNS_ACCESS_KEY_SECRET))) { - publishConfig.setAccessKeySecret(config.getString(Constant.NODE_DNS_ACCESS_KEY_SECRET)); + if (config.hasPath(ConfigKey.NODE_DNS_ACCESS_KEY_SECRET) && StringUtils.isNotEmpty( + config.getString(ConfigKey.NODE_DNS_ACCESS_KEY_SECRET))) { + publishConfig.setAccessKeySecret(config.getString(ConfigKey.NODE_DNS_ACCESS_KEY_SECRET)); } else { - logEmptyError(Constant.NODE_DNS_ACCESS_KEY_SECRET); + logEmptyError(ConfigKey.NODE_DNS_ACCESS_KEY_SECRET); } if (publishConfig.getDnsType() == DnsType.AwsRoute53) { - if (config.hasPath(Constant.NODE_DNS_AWS_REGION) && StringUtils.isNotEmpty( - config.getString(Constant.NODE_DNS_AWS_REGION))) { - publishConfig.setAwsRegion(config.getString(Constant.NODE_DNS_AWS_REGION)); + if (config.hasPath(ConfigKey.NODE_DNS_AWS_REGION) && StringUtils.isNotEmpty( + config.getString(ConfigKey.NODE_DNS_AWS_REGION))) { + publishConfig.setAwsRegion(config.getString(ConfigKey.NODE_DNS_AWS_REGION)); } else { - logEmptyError(Constant.NODE_DNS_AWS_REGION); + logEmptyError(ConfigKey.NODE_DNS_AWS_REGION); } - if (config.hasPath(Constant.NODE_DNS_AWS_HOST_ZONE_ID)) { - publishConfig.setAwsHostZoneId(config.getString(Constant.NODE_DNS_AWS_HOST_ZONE_ID)); + if (config.hasPath(ConfigKey.NODE_DNS_AWS_HOST_ZONE_ID)) { + publishConfig.setAwsHostZoneId(config.getString(ConfigKey.NODE_DNS_AWS_HOST_ZONE_ID)); } } else { - if (config.hasPath(Constant.NODE_DNS_ALIYUN_ENDPOINT) && StringUtils.isNotEmpty( - config.getString(Constant.NODE_DNS_ALIYUN_ENDPOINT))) { - publishConfig.setAliDnsEndpoint(config.getString(Constant.NODE_DNS_ALIYUN_ENDPOINT)); + if (config.hasPath(ConfigKey.NODE_DNS_ALIYUN_ENDPOINT) && StringUtils.isNotEmpty( + config.getString(ConfigKey.NODE_DNS_ALIYUN_ENDPOINT))) { + publishConfig.setAliDnsEndpoint(config.getString(ConfigKey.NODE_DNS_ALIYUN_ENDPOINT)); } else { - logEmptyError(Constant.NODE_DNS_ALIYUN_ENDPOINT); + logEmptyError(ConfigKey.NODE_DNS_ALIYUN_ENDPOINT); } } } @@ -1640,7 +1640,7 @@ private static FilterQuery getEventFilter(final com.typesafe.config.Config confi long fromBlockLong = 0; long toBlockLong = 0; - String fromBlock = config.getString(Constant.EVENT_SUBSCRIBE_FROM_BLOCK).trim(); + String fromBlock = config.getString(ConfigKey.EVENT_SUBSCRIBE_FROM_BLOCK).trim(); try { fromBlockLong = FilterQuery.parseFromBlockNumber(fromBlock); } catch (Exception e) { @@ -1649,7 +1649,7 @@ private static FilterQuery getEventFilter(final com.typesafe.config.Config confi } filter.setFromBlock(fromBlockLong); - String toBlock = config.getString(Constant.EVENT_SUBSCRIBE_TO_BLOCK).trim(); + String toBlock = config.getString(ConfigKey.EVENT_SUBSCRIBE_TO_BLOCK).trim(); try { toBlockLong = FilterQuery.parseToBlockNumber(toBlock); } catch (Exception e) { @@ -1658,12 +1658,12 @@ private static FilterQuery getEventFilter(final com.typesafe.config.Config confi } filter.setToBlock(toBlockLong); - List addressList = config.getStringList(Constant.EVENT_SUBSCRIBE_CONTRACT_ADDRESS); + List addressList = config.getStringList(ConfigKey.EVENT_SUBSCRIBE_CONTRACT_ADDRESS); addressList = addressList.stream().filter(address -> StringUtils.isNotEmpty(address)).collect( Collectors.toList()); filter.setContractAddressList(addressList); - List topicList = config.getStringList(Constant.EVENT_SUBSCRIBE_CONTRACT_TOPIC); + List topicList = config.getStringList(ConfigKey.EVENT_SUBSCRIBE_CONTRACT_TOPIC); topicList = topicList.stream().filter(top -> StringUtils.isNotEmpty(top)).collect( Collectors.toList()); filter.setContractTopicList(topicList); @@ -1672,8 +1672,8 @@ private static FilterQuery getEventFilter(final com.typesafe.config.Config confi } private static void externalIp(final com.typesafe.config.Config config) { - if (!config.hasPath(Constant.NODE_DISCOVERY_EXTERNAL_IP) || config - .getString(Constant.NODE_DISCOVERY_EXTERNAL_IP).trim().isEmpty()) { + if (!config.hasPath(ConfigKey.NODE_DISCOVERY_EXTERNAL_IP) || config + .getString(ConfigKey.NODE_DISCOVERY_EXTERNAL_IP).trim().isEmpty()) { if (PARAMETER.nodeExternalIp == null) { logger.info("External IP wasn't set, using ipv4 from libp2p"); PARAMETER.nodeExternalIp = PARAMETER.p2pConfig.getIp(); @@ -1682,12 +1682,12 @@ private static void externalIp(final com.typesafe.config.Config config) { } } } else { - PARAMETER.nodeExternalIp = config.getString(Constant.NODE_DISCOVERY_EXTERNAL_IP).trim(); + PARAMETER.nodeExternalIp = config.getString(ConfigKey.NODE_DISCOVERY_EXTERNAL_IP).trim(); } } private static void initRocksDbSettings(Config config) { - String prefix = Constant.STORAGE_DB_SETTING; + String prefix = ConfigKey.STORAGE_DB_SETTING; int levelNumber = config.hasPath(prefix + "levelNumber") ? config.getInt(prefix + "levelNumber") : 7; int compactThreads = config.hasPath(prefix + "compactThreads") @@ -1718,32 +1718,32 @@ private static void initRocksDbSettings(Config config) { private static void initRocksDbBackupProperty(Config config) { boolean enable = - config.hasPath(Constant.STORAGE_BACKUP_ENABLE) - && config.getBoolean(Constant.STORAGE_BACKUP_ENABLE); - String propPath = config.hasPath(Constant.STORAGE_BACKUP_PROP_PATH) - ? config.getString(Constant.STORAGE_BACKUP_PROP_PATH) : "prop.properties"; - String bak1path = config.hasPath(Constant.STORAGE_BACKUP_BAK1PATH) - ? config.getString(Constant.STORAGE_BACKUP_BAK1PATH) : "bak1/database/"; - String bak2path = config.hasPath(Constant.STORAGE_BACKUP_BAK2PATH) - ? config.getString(Constant.STORAGE_BACKUP_BAK2PATH) : "bak2/database/"; - int frequency = config.hasPath(Constant.STORAGE_BACKUP_FREQUENCY) - ? config.getInt(Constant.STORAGE_BACKUP_FREQUENCY) : 10000; + config.hasPath(ConfigKey.STORAGE_BACKUP_ENABLE) + && config.getBoolean(ConfigKey.STORAGE_BACKUP_ENABLE); + String propPath = config.hasPath(ConfigKey.STORAGE_BACKUP_PROP_PATH) + ? config.getString(ConfigKey.STORAGE_BACKUP_PROP_PATH) : "prop.properties"; + String bak1path = config.hasPath(ConfigKey.STORAGE_BACKUP_BAK1PATH) + ? config.getString(ConfigKey.STORAGE_BACKUP_BAK1PATH) : "bak1/database/"; + String bak2path = config.hasPath(ConfigKey.STORAGE_BACKUP_BAK2PATH) + ? config.getString(ConfigKey.STORAGE_BACKUP_BAK2PATH) : "bak2/database/"; + int frequency = config.hasPath(ConfigKey.STORAGE_BACKUP_FREQUENCY) + ? config.getInt(ConfigKey.STORAGE_BACKUP_FREQUENCY) : 10000; PARAMETER.dbBackupConfig = DbBackupConfig.getInstance() .initArgs(enable, propPath, bak1path, bak2path, frequency); } private static void initBackupProperty(Config config) { - PARAMETER.backupPriority = config.hasPath(Constant.NODE_BACKUP_PRIORITY) - ? config.getInt(Constant.NODE_BACKUP_PRIORITY) : 0; + PARAMETER.backupPriority = config.hasPath(ConfigKey.NODE_BACKUP_PRIORITY) + ? config.getInt(ConfigKey.NODE_BACKUP_PRIORITY) : 0; - PARAMETER.backupPort = config.hasPath(Constant.NODE_BACKUP_PORT) - ? config.getInt(Constant.NODE_BACKUP_PORT) : 10001; + PARAMETER.backupPort = config.hasPath(ConfigKey.NODE_BACKUP_PORT) + ? config.getInt(ConfigKey.NODE_BACKUP_PORT) : 10001; - PARAMETER.keepAliveInterval = config.hasPath(Constant.NODE_BACKUP_KEEPALIVEINTERVAL) - ? config.getInt(Constant.NODE_BACKUP_KEEPALIVEINTERVAL) : 3000; + PARAMETER.keepAliveInterval = config.hasPath(ConfigKey.NODE_BACKUP_KEEPALIVEINTERVAL) + ? config.getInt(ConfigKey.NODE_BACKUP_KEEPALIVEINTERVAL) : 3000; - PARAMETER.backupMembers = config.hasPath(Constant.NODE_BACKUP_MEMBERS) - ? config.getStringList(Constant.NODE_BACKUP_MEMBERS) : new ArrayList<>(); + PARAMETER.backupMembers = config.hasPath(ConfigKey.NODE_BACKUP_MEMBERS) + ? config.getStringList(ConfigKey.NODE_BACKUP_MEMBERS) : new ArrayList<>(); } public static void logConfig() { diff --git a/framework/src/main/java/org/tron/core/config/args/ConfigKey.java b/framework/src/main/java/org/tron/core/config/args/ConfigKey.java new file mode 100644 index 0000000000..403154a9bf --- /dev/null +++ b/framework/src/main/java/org/tron/core/config/args/ConfigKey.java @@ -0,0 +1,332 @@ +package org.tron.core.config.args; + +/** + * HOCON configuration key constants. + * These map to paths in config files (e.g. config.conf) and are read by Args.setParam(). + */ +final class ConfigKey { + + private ConfigKey() { + } + + // net + public static final String NET_ADDRESS_PREFIX = "net.addressPrefix"; + + // local witness + public static final String LOCAL_WITNESS = "localwitness"; + public static final String LOCAL_WITNESS_ACCOUNT_ADDRESS = "localWitnessAccountAddress"; + public static final String LOCAL_WITNESS_KEYSTORE = "localwitnesskeystore"; + + // crypto + public static final String CRYPTO_ENGINE = "crypto.engine"; + + // vm + public static final String VM_SUPPORT_CONSTANT = "vm.supportConstant"; + public static final String VM_MAX_ENERGY_LIMIT_FOR_CONSTANT = "vm.maxEnergyLimitForConstant"; + public static final String VM_LRU_CACHE_SIZE = "vm.lruCacheSize"; + public static final String VM_MIN_TIME_RATIO = "vm.minTimeRatio"; + public static final String VM_MAX_TIME_RATIO = "vm.maxTimeRatio"; + public static final String VM_LONG_RUNNING_TIME = "vm.longRunningTime"; + public static final String VM_ESTIMATE_ENERGY = "vm.estimateEnergy"; + public static final String VM_ESTIMATE_ENERGY_MAX_RETRY = "vm.estimateEnergyMaxRetry"; + public static final String VM_TRACE = "vm.vmTrace"; + 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"; + + // genesis + public static final String GENESIS_BLOCK = "genesis.block"; + public static final String GENESIS_BLOCK_TIMESTAMP = "genesis.block.timestamp"; + public static final String GENESIS_BLOCK_PARENTHASH = "genesis.block.parentHash"; + public static final String GENESIS_BLOCK_ASSETS = "genesis.block.assets"; + public static final String GENESIS_BLOCK_WITNESSES = "genesis.block.witnesses"; + + // block + public static final String BLOCK_NEED_SYNC_CHECK = "block.needSyncCheck"; + public static final String BLOCK_MAINTENANCE_TIME_INTERVAL = "block.maintenanceTimeInterval"; + public static final String BLOCK_PROPOSAL_EXPIRE_TIME = "block.proposalExpireTime"; + public static final String BLOCK_CHECK_FROZEN_TIME = "block.checkFrozenTime"; + public static final String BLOCK_CACHE_TIMEOUT = "node.blockCacheTimeout"; + + // node - discovery + public static final String NODE_DISCOVERY_ENABLE = "node.discovery.enable"; + public static final String NODE_DISCOVERY_PERSIST = "node.discovery.persist"; + public static final String NODE_DISCOVERY_EXTERNAL_IP = "node.discovery.external.ip"; + + // node - connection + public static final String NODE_EFFECTIVE_CHECK_ENABLE = "node.effectiveCheckEnable"; + public static final String NODE_CONNECTION_TIMEOUT = "node.connection.timeout"; + public static final String NODE_FETCH_BLOCK_TIMEOUT = "node.fetchBlock.timeout"; + public static final String NODE_CHANNEL_READ_TIMEOUT = "node.channel.read.timeout"; + public static final String NODE_MAX_CONNECTIONS = "node.maxConnections"; + public static final String NODE_MIN_CONNECTIONS = "node.minConnections"; + public static final String NODE_MIN_ACTIVE_CONNECTIONS = "node.minActiveConnections"; + public static final String NODE_MAX_CONNECTIONS_WITH_SAME_IP = "node.maxConnectionsWithSameIp"; + public static final String NODE_MIN_PARTICIPATION_RATE = "node.minParticipationRate"; + public static final String NODE_MAX_ACTIVE_NODES = "node.maxActiveNodes"; + public static final String NODE_MAX_ACTIVE_NODES_WITH_SAME_IP = "node.maxActiveNodesWithSameIp"; + public static final String NODE_CONNECT_FACTOR = "node.connectFactor"; + public static final String NODE_ACTIVE_CONNECT_FACTOR = "node.activeConnectFactor"; + 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_HTTP_CONNECT_NUMBER = "node.maxHttpConnectNumber"; + + // node - p2p + public static final String NODE_LISTEN_PORT = "node.listen.port"; + public static final String NODE_P2P_VERSION = "node.p2p.version"; + public static final String NODE_ENABLE_IPV6 = "node.enableIpv6"; + public static final String NODE_SYNC_FETCH_BATCH_NUM = "node.syncFetchBatchNum"; + public static final String NODE_MAX_TPS = "node.maxTps"; + public static final String NODE_NET_MAX_TRX_PER_SECOND = "node.netMaxTrxPerSecond"; + public static final String NODE_TCP_NETTY_WORK_THREAD_NUM = "node.tcpNettyWorkThreadNum"; + public static final String NODE_UDP_NETTY_WORK_THREAD_NUM = "node.udpNettyWorkThreadNum"; + public static final String NODE_VALIDATE_SIGN_THREAD_NUM = "node.validateSignThreadNum"; + public static final String NODE_RECEIVE_TCP_MIN_DATA_LENGTH = "node.receiveTcpMinDataLength"; + public static final String NODE_PRODUCED_TIMEOUT = "node.blockProducedTimeOut"; + public static final String NODE_MAX_TRANSACTION_PENDING_SIZE = "node.maxTransactionPendingSize"; + public static final String NODE_PENDING_TRANSACTION_TIMEOUT = "node.pendingTransactionTimeout"; + public static final String NODE_ACTIVE = "node.active"; + public static final String NODE_PASSIVE = "node.passive"; + public static final String NODE_FAST_FORWARD = "node.fastForward"; + public static final String NODE_MAX_FAST_FORWARD_NUM = "node.maxFastForwardNum"; + public static final String NODE_AGREE_NODE_COUNT = "node.agreeNodeCount"; + public static final String NODE_SOLIDITY_THREADS = "node.solidity.threads"; + public static final String NODE_TRUST_NODE = "node.trustNode"; + public static final String NODE_WALLET_EXTENSION_API = "node.walletExtensionApi"; + public static final String NODE_VALID_CONTRACT_PROTO_THREADS = "node.validContractProto.threads"; + public static final String NODE_SHIELDED_TRANS_IN_PENDING_MAX_COUNTS = + "node.shieldedTransInPendingMaxCounts"; + public static final String NODE_FULLNODE_ALLOW_SHIELDED_TRANSACTION = + "node.fullNodeAllowShieldedTransaction"; + public static final String ALLOW_SHIELDED_TRANSACTION_API = + "node.allowShieldedTransactionApi"; + public static final String NODE_ZEN_TOKENID = "node.zenTokenId"; + public static final String NODE_OPEN_HISTORY_QUERY_WHEN_LITEFN = + "node.openHistoryQueryWhenLiteFN"; + public static final String NODE_METRICS_ENABLE = "node.metricsEnable"; + public static final String NODE_DISABLED_API_LIST = "node.disabledApi"; + + // node - 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"; + public static final String NODE_RPC_THREAD = "node.rpc.thread"; + public static final String NODE_RPC_MAX_CONCURRENT_CALLS_PER_CONNECTION = + "node.rpc.maxConcurrentCallsPerConnection"; + public static final String NODE_RPC_FLOW_CONTROL_WINDOW = "node.rpc.flowControlWindow"; + public static final String NODE_RPC_MAX_CONNECTION_IDLE_IN_MILLIS = + "node.rpc.maxConnectionIdleInMillis"; + public static final String NODE_RPC_MAX_RST_STREAM = "node.rpc.maxRstStream"; + public static final String NODE_RPC_SECONDS_PER_WINDOW = "node.rpc.secondsPerWindow"; + public static final String NODE_RPC_MAX_CONNECTION_AGE_IN_MILLIS = + "node.rpc.maxConnectionAgeInMillis"; + public static final String NODE_RPC_MAX_MESSAGE_SIZE = "node.rpc.maxMessageSize"; + 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_RPC_MIN_EFFECTIVE_CONNECTION = + "node.rpc.minEffectiveConnection"; + public static final String NODE_RPC_TRX_CACHE_ENABLE = "node.rpc.trxCacheEnable"; + + // node - 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"; + + // node - 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_JSONRPC_MAX_BLOCK_FILTER_NUM = + "node.jsonrpc.maxBlockFilterNum"; + + // node - dns + public static final String NODE_DNS_TREE_URLS = "node.dns.treeUrls"; + public static final String NODE_DNS_PUBLISH = "node.dns.publish"; + public static final String NODE_DNS_DOMAIN = "node.dns.dnsDomain"; + public static final String NODE_DNS_CHANGE_THRESHOLD = "node.dns.changeThreshold"; + public static final String NODE_DNS_MAX_MERGE_SIZE = "node.dns.maxMergeSize"; + public static final String NODE_DNS_PRIVATE = "node.dns.dnsPrivate"; + public static final String NODE_DNS_KNOWN_URLS = "node.dns.knownUrls"; + public static final String NODE_DNS_STATIC_NODES = "node.dns.staticNodes"; + public static final String NODE_DNS_SERVER_TYPE = "node.dns.serverType"; + public static final String NODE_DNS_ACCESS_KEY_ID = "node.dns.accessKeyId"; + public static final String NODE_DNS_ACCESS_KEY_SECRET = "node.dns.accessKeySecret"; + public static final String NODE_DNS_ALIYUN_ENDPOINT = "node.dns.aliyunDnsEndpoint"; + public static final String NODE_DNS_AWS_REGION = "node.dns.awsRegion"; + public static final String NODE_DNS_AWS_HOST_ZONE_ID = "node.dns.awsHostZoneId"; + + // node - backup + public static final String NODE_BACKUP_PRIORITY = "node.backup.priority"; + public static final String NODE_BACKUP_PORT = "node.backup.port"; + public static final String NODE_BACKUP_KEEPALIVEINTERVAL = "node.backup.keepAliveInterval"; + public static final String NODE_BACKUP_MEMBERS = "node.backup.members"; + + // node - shutdown + public static final String NODE_SHUTDOWN_BLOCK_TIME = "node.shutdown.BlockTime"; + public static final String NODE_SHUTDOWN_BLOCK_HEIGHT = "node.shutdown.BlockHeight"; + public static final String NODE_SHUTDOWN_BLOCK_COUNT = "node.shutdown.BlockCount"; + + // node - dynamic config + public static final String DYNAMIC_CONFIG_ENABLE = "node.dynamicConfig.enable"; + public static final String DYNAMIC_CONFIG_CHECK_INTERVAL = "node.dynamicConfig.checkInterval"; + + // node - unsolidified + public static final String UNSOLIDIFIED_BLOCK_CHECK = "node.unsolidifiedBlockCheck"; + public static final String MAX_UNSOLIDIFIED_BLOCKS = "node.maxUnsolidifiedBlocks"; + + // node - misc + public static final String OPEN_PRINT_LOG = "node.openPrintLog"; + public static final String OPEN_TRANSACTION_SORT = "node.openTransactionSort"; + + // committee + public static final String COMMITTEE_ALLOW_CREATION_OF_CONTRACTS = + "committee.allowCreationOfContracts"; + public static final String COMMITTEE_ALLOW_MULTI_SIGN = "committee.allowMultiSign"; + public static final String COMMITTEE_ALLOW_ADAPTIVE_ENERGY = "committee.allowAdaptiveEnergy"; + public static final String COMMITTEE_ALLOW_DELEGATE_RESOURCE = + "committee.allowDelegateResource"; + public static final String COMMITTEE_ALLOW_SAME_TOKEN_NAME = "committee.allowSameTokenName"; + public static final String COMMITTEE_ALLOW_TVM_TRANSFER_TRC10 = + "committee.allowTvmTransferTrc10"; + public static final String COMMITTEE_ALLOW_TVM_CONSTANTINOPLE = + "committee.allowTvmConstantinople"; + public static final String COMMITTEE_ALLOW_TVM_SOLIDITY059 = "committee.allowTvmSolidity059"; + public static final String COMMITTEE_FORBID_TRANSFER_TO_CONTRACT = + "committee.forbidTransferToContract"; + public static final String COMMITTEE_ALLOW_SHIELDED_TRC20_TRANSACTION = + "committee.allowShieldedTRC20Transaction"; + public static final String COMMITTEE_ALLOW_TVM_ISTANBUL = "committee.allowTvmIstanbul"; + public static final String COMMITTEE_ALLOW_MARKET_TRANSACTION = + "committee.allowMarketTransaction"; + public static final String COMMITTEE_ALLOW_PROTO_FILTER_NUM = + "committee.allowProtoFilterNum"; + public static final String COMMITTEE_ALLOW_ACCOUNT_STATE_ROOT = + "committee.allowAccountStateRoot"; + public static final String COMMITTEE_ALLOW_PBFT = "committee.allowPBFT"; + public static final String COMMITTEE_PBFT_EXPIRE_NUM = "committee.pBFTExpireNum"; + public static final String COMMITTEE_ALLOW_TRANSACTION_FEE_POOL = + "committee.allowTransactionFeePool"; + public static final String COMMITTEE_ALLOW_BLACK_HOLE_OPTIMIZATION = + "committee.allowBlackHoleOptimization"; + public static final String COMMITTEE_ALLOW_NEW_RESOURCE_MODEL = + "committee.allowNewResourceModel"; + public static final String COMMITTEE_ALLOW_RECEIPTS_MERKLE_ROOT = + "committee.allowReceiptsMerkleRoot"; + public static final String COMMITTEE_ALLOW_TVM_FREEZE = "committee.allowTvmFreeze"; + public static final String COMMITTEE_ALLOW_TVM_VOTE = "committee.allowTvmVote"; + public static final String COMMITTEE_UNFREEZE_DELAY_DAYS = "committee.unfreezeDelayDays"; + public static final String COMMITTEE_ALLOW_TVM_LONDON = "committee.allowTvmLondon"; + public static final String COMMITTEE_ALLOW_TVM_COMPATIBLE_EVM = + "committee.allowTvmCompatibleEvm"; + public static final String COMMITTEE_ALLOW_HIGHER_LIMIT_FOR_MAX_CPU_TIME_OF_ONE_TX = + "committee.allowHigherLimitForMaxCpuTimeOfOneTx"; + public static final String COMMITTEE_ALLOW_NEW_REWARD_ALGORITHM = + "committee.allowNewRewardAlgorithm"; + public static final String COMMITTEE_ALLOW_OPTIMIZED_RETURN_VALUE_OF_CHAIN_ID = + "committee.allowOptimizedReturnValueOfChainId"; + public static final String COMMITTEE_CHANGED_DELEGATION = "committee.changedDelegation"; + public static final String COMMITTEE_ALLOW_TVM_SHANGHAI = "committee.allowTvmShangHai"; + 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"; + public static final String COMMITTEE_PROPOSAL_EXPIRE_TIME = "committee.proposalExpireTime"; + public static final String ALLOW_ACCOUNT_ASSET_OPTIMIZATION = + "committee.allowAccountAssetOptimization"; + public static final String ALLOW_ASSET_OPTIMIZATION = "committee.allowAssetOptimization"; + public static final String ALLOW_NEW_REWARD = "committee.allowNewReward"; + public static final String MEMO_FEE = "committee.memoFee"; + public static final String ALLOW_DELEGATE_OPTIMIZATION = + "committee.allowDelegateOptimization"; + public static final String ALLOW_DYNAMIC_ENERGY = "committee.allowDynamicEnergy"; + public static final String DYNAMIC_ENERGY_THRESHOLD = "committee.dynamicEnergyThreshold"; + public static final String DYNAMIC_ENERGY_INCREASE_FACTOR = + "committee.dynamicEnergyIncreaseFactor"; + public static final String DYNAMIC_ENERGY_MAX_FACTOR = "committee.dynamicEnergyMaxFactor"; + + // storage + public static final String STORAGE_NEEDTO_UPDATE_ASSET = "storage.needToUpdateAsset"; + public static final String STORAGE_BACKUP_ENABLE = "storage.backup.enable"; + public static final String STORAGE_BACKUP_PROP_PATH = "storage.backup.propPath"; + public static final String STORAGE_BACKUP_BAK1PATH = "storage.backup.bak1path"; + public static final String STORAGE_BACKUP_BAK2PATH = "storage.backup.bak2path"; + public static final String STORAGE_BACKUP_FREQUENCY = "storage.backup.frequency"; + public static final String STORAGE_DB_SETTING = "storage.dbSettings."; + public static final String HISTORY_BALANCE_LOOKUP = "storage.balance.history.lookup"; + + // event + public static final String EVENT_SUBSCRIBE = "event.subscribe"; + public static final String EVENT_SUBSCRIBE_FILTER = "event.subscribe.filter"; + 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"; + public static final String EVENT_SUBSCRIBE_TOPICS = "event.subscribe.topics"; + public static final String EVENT_SUBSCRIBE_FROM_BLOCK = "event.subscribe.filter.fromblock"; + public static final String EVENT_SUBSCRIBE_TO_BLOCK = "event.subscribe.filter.toblock"; + 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 USE_NATIVE_QUEUE = "event.subscribe.native.useNativeQueue"; + public static final String NATIVE_QUEUE_BIND_PORT = "event.subscribe.native.bindport"; + public static final String NATIVE_QUEUE_SEND_LENGTH = + "event.subscribe.native.sendqueuelength"; + + // rate limiter + public static final String RATE_LIMITER = "rate.limiter"; + public static final String RATE_LIMITER_GLOBAL_QPS = "rate.limiter.global.qps"; + public static final String RATE_LIMITER_GLOBAL_IP_QPS = "rate.limiter.global.ip.qps"; + public static final String RATE_LIMITER_GLOBAL_API_QPS = "rate.limiter.global.api.qps"; + public static final String RATE_LIMITER_HTTP = "rate.limiter.http"; + public static final String RATE_LIMITER_RPC = "rate.limiter.rpc"; + public static final String RATE_LIMITER_P2P_SYNC_BLOCK_CHAIN = + "rate.limiter.p2p.syncBlockChain"; + public static final String RATE_LIMITER_P2P_FETCH_INV_DATA = "rate.limiter.p2p.fetchInvData"; + public static final String RATE_LIMITER_P2P_DISCONNECT = "rate.limiter.p2p.disconnect"; + + // metrics + public static final String METRICS_STORAGE_ENABLE = "node.metrics.storageEnable"; + public static final String METRICS_INFLUXDB_IP = "node.metrics.influxdb.ip"; + public static final String METRICS_INFLUXDB_PORT = "node.metrics.influxdb.port"; + public static final String METRICS_INFLUXDB_DATABASE = "node.metrics.influxdb.database"; + public static final String METRICS_REPORT_INTERVAL = + "node.metrics.influxdb.metricsReportInterval"; + public static final String METRICS_PROMETHEUS_ENABLE = "node.metrics.prometheus.enable"; + public static final String METRICS_PROMETHEUS_PORT = "node.metrics.prometheus.port"; + + // seed + public static final String SEED_NODE_IP_LIST = "seed.node.ip.list"; + + // transaction + public static final String TRX_REFERENCE_BLOCK = "trx.reference.block"; + public static final String TRX_EXPIRATION_TIME_IN_MILLIS_SECONDS = + "trx.expiration.timeInMilliseconds"; + + // energy + public static final String ENERGY_LIMIT_BLOCK_NUM = "enery.limit.block.num"; + + // actuator + public static final String ACTUATOR_WHITELIST = "actuator.whitelist"; +} diff --git a/framework/src/main/java/org/tron/core/config/args/DynamicArgs.java b/framework/src/main/java/org/tron/core/config/args/DynamicArgs.java index 371b7736e2..9963ac1f41 100644 --- a/framework/src/main/java/org/tron/core/config/args/DynamicArgs.java +++ b/framework/src/main/java/org/tron/core/config/args/DynamicArgs.java @@ -13,7 +13,6 @@ import org.springframework.stereotype.Component; import org.tron.common.es.ExecutorServiceManager; import org.tron.common.parameter.CommonParameter; -import org.tron.core.Constant; import org.tron.core.config.Configuration; import org.tron.core.net.TronNetService; @@ -70,7 +69,7 @@ public void reload() { private void updateActiveNodes(Config config) { List newActiveNodes = - Args.getInetSocketAddress(config, Constant.NODE_ACTIVE, true); + Args.getInetSocketAddress(config, ConfigKey.NODE_ACTIVE, true); parameter.setActiveNodes(newActiveNodes); List activeNodes = TronNetService.getP2pConfig().getActiveNodes(); activeNodes.clear(); @@ -80,7 +79,7 @@ private void updateActiveNodes(Config config) { } private void updateTrustNodes(Config config) { - List newPassiveNodes = Args.getInetAddress(config, Constant.NODE_PASSIVE); + List newPassiveNodes = Args.getInetAddress(config, ConfigKey.NODE_PASSIVE); parameter.setPassiveNodes(newPassiveNodes); List trustNodes = TronNetService.getP2pConfig().getTrustNodes(); trustNodes.clear(); diff --git a/framework/src/main/java/org/tron/core/config/args/WitnessInitializer.java b/framework/src/main/java/org/tron/core/config/args/WitnessInitializer.java index 2ea3a449ef..2a97b6ab63 100644 --- a/framework/src/main/java/org/tron/core/config/args/WitnessInitializer.java +++ b/framework/src/main/java/org/tron/core/config/args/WitnessInitializer.java @@ -11,7 +11,6 @@ import org.tron.common.utils.ByteArray; import org.tron.common.utils.Commons; import org.tron.common.utils.LocalWitnesses; -import org.tron.core.Constant; import org.tron.core.exception.CipherException; import org.tron.core.exception.TronError; import org.tron.keystore.Credentials; @@ -70,12 +69,12 @@ private boolean tryInitFromCommandLine() { } private boolean tryInitFromConfig() { - if (!config.hasPath(Constant.LOCAL_WITNESS) || config.getStringList(Constant.LOCAL_WITNESS) + if (!config.hasPath(ConfigKey.LOCAL_WITNESS) || config.getStringList(ConfigKey.LOCAL_WITNESS) .isEmpty()) { return false; } - List localWitness = config.getStringList(Constant.LOCAL_WITNESS); + List localWitness = config.getStringList(ConfigKey.LOCAL_WITNESS); this.localWitnesses.setPrivateKeys(localWitness); logger.debug("Got privateKey from config.conf"); byte[] witnessAddress = getWitnessAddress(); @@ -85,12 +84,12 @@ private boolean tryInitFromConfig() { } private void tryInitFromKeystore() { - if (!config.hasPath(Constant.LOCAL_WITNESS_KEYSTORE) - || config.getStringList(Constant.LOCAL_WITNESS_KEYSTORE).isEmpty()) { + if (!config.hasPath(ConfigKey.LOCAL_WITNESS_KEYSTORE) + || config.getStringList(ConfigKey.LOCAL_WITNESS_KEYSTORE).isEmpty()) { return; } - List localWitness = config.getStringList(Constant.LOCAL_WITNESS_KEYSTORE); + List localWitness = config.getStringList(ConfigKey.LOCAL_WITNESS_KEYSTORE); if (localWitness.size() > 1) { logger.warn( "Multiple keystores detected. Only the first keystore will be used as witness, all " @@ -127,7 +126,7 @@ private void tryInitFromKeystore() { } private byte[] getWitnessAddress() { - if (!config.hasPath(Constant.LOCAL_WITNESS_ACCOUNT_ADDRESS)) { + if (!config.hasPath(ConfigKey.LOCAL_WITNESS_ACCOUNT_ADDRESS)) { return null; } @@ -137,7 +136,7 @@ private byte[] getWitnessAddress() { TronError.ErrCode.WITNESS_INIT); } byte[] witnessAddress = Commons - .decodeFromBase58Check(config.getString(Constant.LOCAL_WITNESS_ACCOUNT_ADDRESS)); + .decodeFromBase58Check(config.getString(ConfigKey.LOCAL_WITNESS_ACCOUNT_ADDRESS)); if (witnessAddress != null) { logger.debug("Got localWitnessAccountAddress from config.conf"); } else { 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 b88e2680cc..41aa32b297 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 @@ -38,7 +38,6 @@ import org.tron.common.utils.DecodeUtil; import org.tron.common.utils.LocalWitnesses; import org.tron.common.utils.PublicMethod; -import org.tron.core.Constant; import org.tron.core.config.Configuration; @Slf4j @@ -147,7 +146,7 @@ public void testIpFromLibP2p() Assert.assertEquals("46.168.1.1", configuredExternalIp); Config config = Configuration.getByFileName(null, TestConstants.TEST_CONF); - Config config3 = config.withoutPath(Constant.NODE_DISCOVERY_EXTERNAL_IP); + Config config3 = config.withoutPath(ConfigKey.NODE_DISCOVERY_EXTERNAL_IP); CommonParameter.getInstance().setNodeExternalIp(null); diff --git a/framework/src/test/java/org/tron/core/config/args/WitnessInitializerTest.java b/framework/src/test/java/org/tron/core/config/args/WitnessInitializerTest.java index 7364b1f9b3..b38286ca84 100644 --- a/framework/src/test/java/org/tron/core/config/args/WitnessInitializerTest.java +++ b/framework/src/test/java/org/tron/core/config/args/WitnessInitializerTest.java @@ -34,7 +34,6 @@ import org.tron.common.utils.LocalWitnesses; import org.tron.common.utils.PublicMethod; import org.tron.common.utils.client.utils.Base58; -import org.tron.core.Constant; import org.tron.core.exception.TronError; import org.tron.core.exception.TronError.ErrCode; import org.tron.keystore.Credentials; @@ -194,22 +193,22 @@ public void testTryInitFromKeyStore2() throws NoSuchFieldException, IllegalAccessException { Args.PARAMETER.setWitness(true); Config mockConfig = mock(Config.class); - when(mockConfig.hasPath(Constant.LOCAL_WITNESS_KEYSTORE)).thenReturn(false); + when(mockConfig.hasPath(ConfigKey.LOCAL_WITNESS_KEYSTORE)).thenReturn(false); witnessInitializer = new WitnessInitializer(mockConfig); witnessInitializer.initLocalWitnesses(); verify(mockConfig, never()).getStringList(anyString()); - when(mockConfig.hasPath(Constant.LOCAL_WITNESS_KEYSTORE)).thenReturn(true); - when(mockConfig.getStringList(Constant.LOCAL_WITNESS_KEYSTORE)).thenReturn(new ArrayList<>()); + when(mockConfig.hasPath(ConfigKey.LOCAL_WITNESS_KEYSTORE)).thenReturn(true); + when(mockConfig.getStringList(ConfigKey.LOCAL_WITNESS_KEYSTORE)).thenReturn(new ArrayList<>()); witnessInitializer = new WitnessInitializer(mockConfig); witnessInitializer.initLocalWitnesses(); - verify(mockConfig, times(1)).getStringList(Constant.LOCAL_WITNESS_KEYSTORE); + verify(mockConfig, times(1)).getStringList(ConfigKey.LOCAL_WITNESS_KEYSTORE); List keystores = new ArrayList<>(); keystores.add("keystore1.json"); keystores.add("keystore2.json"); - when(mockConfig.hasPath(Constant.LOCAL_WITNESS_KEYSTORE)).thenReturn(true); - when(mockConfig.getStringList(Constant.LOCAL_WITNESS_KEYSTORE)).thenReturn(keystores); + when(mockConfig.hasPath(ConfigKey.LOCAL_WITNESS_KEYSTORE)).thenReturn(true); + when(mockConfig.getStringList(ConfigKey.LOCAL_WITNESS_KEYSTORE)).thenReturn(keystores); Field password = CommonParameter.class.getDeclaredField("password"); password.setAccessible(true); diff --git a/framework/src/test/java/org/tron/core/exception/TronErrorTest.java b/framework/src/test/java/org/tron/core/exception/TronErrorTest.java index b620ad7d47..3b238f50ed 100644 --- a/framework/src/test/java/org/tron/core/exception/TronErrorTest.java +++ b/framework/src/test/java/org/tron/core/exception/TronErrorTest.java @@ -37,7 +37,6 @@ 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; @@ -138,7 +137,7 @@ public void rateLimiterServletInitTest() { @Test public void shutdownBlockTimeInitTest() { Map params = new HashMap<>(); - params.put(Constant.NODE_SHUTDOWN_BLOCK_TIME, "0"); + params.put("node.shutdown.BlockTime", "0"); params.put("storage.db.directory", "database"); Config config = ConfigFactory.defaultOverrides().withFallback( ConfigFactory.parseMap(params)); From 51594c7c7094b255d09b54e8300ccdb5d362ea4d Mon Sep 17 00:00:00 2001 From: vividcoder Date: Mon, 2 Mar 2026 15:29:53 +0800 Subject: [PATCH 5/8] refactor: remove addressPrefix config - Remove net.addressPrefix from all 11 config files, keep net block with commented-out type field and deprecation note - Remove ConfigKey.NET_ADDRESS_PREFIX constant and Args.java parsing logic, always use mainnet prefix 0x41 - Fix test addresses: convert 27-prefix Base58 to T-prefix, a0/A0 hex to 41 across actuator/servlet/relay/vm tests - Fix hardcoded hashes: update merkle root in BlockCapsuleTest, chainId in AllowTvmCompatibleEvmTest and IstanbulTest - Fix FreezeTest CREATE2: change FACTORY_CODE bytecode magic byte from 0xa0 to 0x41 (PUSH1 60a0 -> 6041) to match new runtime prefix --- .../java/org/tron/core/config/args/Args.java | 17 +------- .../org/tron/core/config/args/ConfigKey.java | 3 -- .../src/main/resources/config-backup.conf | 6 +-- framework/src/main/resources/config-beta.conf | 8 +--- .../src/main/resources/config-localtest.conf | 6 +-- .../src/main/resources/config-test-net.conf | 6 +-- framework/src/main/resources/config.conf | 6 +-- .../runtime/vm/AllowTvmCompatibleEvmTest.java | 2 +- .../common/runtime/vm/ExtCodeHashTest.java | 4 +- .../tron/common/runtime/vm/FreezeTest.java | 8 ++-- .../tron/common/runtime/vm/FreezeV2Test.java | 6 +-- .../common/runtime/vm/IsContractTest.java | 2 +- .../common/runtime/vm/IsSRCandidateTest.java | 6 +-- .../tron/common/runtime/vm/IstanbulTest.java | 2 +- .../runtime/vm/PrecompiledContractsTest.java | 4 +- .../common/runtime/vm/RewardBalanceTest.java | 4 +- .../runtime/vm/TransferFailedEnergyTest.java | 2 +- .../common/runtime/vm/VMContractTestBase.java | 2 +- .../org/tron/common/runtime/vm/VoteTest.java | 12 +++--- .../core/actuator/AssetIssueActuatorTest.java | 2 +- .../actuator/ExchangeInjectActuatorTest.java | 4 +- .../ExchangeWithdrawActuatorTest.java | 4 +- .../actuator/UnfreezeBalanceActuatorTest.java | 4 +- .../core/actuator/utils/ProposalUtilTest.java | 2 +- .../tron/core/capsule/BlockCapsuleTest.java | 2 +- .../org/tron/core/config/args/ArgsTest.java | 2 +- .../core/net/services/RelayServiceTest.java | 32 +++++++-------- .../services/http/ClearABIServletTest.java | 8 ++-- .../http/CreateAccountServletTest.java | 6 +-- .../http/CreateAssetIssueServletTest.java | 4 +- .../http/GetBrokerageServletTest.java | 6 +-- .../services/http/GetRewardServletTest.java | 8 ++-- .../core/witness/WitnessControllerTest.java | 14 +++---- framework/src/test/resources/args-test.conf | 8 +--- .../src/test/resources/config-localtest.conf | 6 +-- .../test/resources/config-test-dbbackup.conf | 6 +-- .../src/test/resources/config-test-index.conf | 8 +--- .../test/resources/config-test-mainnet.conf | 6 +-- .../resources/config-test-storagetest.conf | 8 +--- framework/src/test/resources/config-test.conf | 40 +++++++++---------- 40 files changed, 111 insertions(+), 175 deletions(-) diff --git a/framework/src/main/java/org/tron/core/config/args/Args.java b/framework/src/main/java/org/tron/core/config/args/Args.java index ea49638fd4..b4cbc316e1 100644 --- a/framework/src/main/java/org/tron/core/config/args/Args.java +++ b/framework/src/main/java/org/tron/core/config/args/Args.java @@ -415,21 +415,8 @@ public static void setParam(final String[] args, final String confFileName) { */ public static void setParam(final Config config) { - if (config.hasPath(ConfigKey.NET_ADDRESS_PREFIX)) { - String prefix = config.getString(ConfigKey.NET_ADDRESS_PREFIX) - .replace("'", "").replace("\"", "").trim(); - byte prefixByte; - if (prefix.startsWith("0x") || prefix.startsWith("0X")) { - prefixByte = (byte) Integer.parseInt(prefix.substring(2), 16); - } else { - prefixByte = (byte) Integer.parseInt(prefix, 16); - } - Wallet.setAddressPreFixByte(prefixByte); - Wallet.setAddressPreFixString(String.format("%02x", prefixByte)); - } else { - Wallet.setAddressPreFixByte(ADD_PRE_FIX_BYTE_MAINNET); - Wallet.setAddressPreFixString(Constant.ADD_PRE_FIX_STRING_MAINNET); - } + Wallet.setAddressPreFixByte(ADD_PRE_FIX_BYTE_MAINNET); + Wallet.setAddressPreFixString(Constant.ADD_PRE_FIX_STRING_MAINNET); PARAMETER.cryptoEngine = config.hasPath(ConfigKey.CRYPTO_ENGINE) ? config .getString(ConfigKey.CRYPTO_ENGINE) : Constant.ECKey_ENGINE; diff --git a/framework/src/main/java/org/tron/core/config/args/ConfigKey.java b/framework/src/main/java/org/tron/core/config/args/ConfigKey.java index 403154a9bf..e160eb7a34 100644 --- a/framework/src/main/java/org/tron/core/config/args/ConfigKey.java +++ b/framework/src/main/java/org/tron/core/config/args/ConfigKey.java @@ -9,9 +9,6 @@ final class ConfigKey { private ConfigKey() { } - // net - public static final String NET_ADDRESS_PREFIX = "net.addressPrefix"; - // local witness public static final String LOCAL_WITNESS = "localwitness"; public static final String LOCAL_WITNESS_ACCOUNT_ADDRESS = "localWitnessAccountAddress"; diff --git a/framework/src/main/resources/config-backup.conf b/framework/src/main/resources/config-backup.conf index ecf14c3024..bf4bab4403 100644 --- a/framework/src/main/resources/config-backup.conf +++ b/framework/src/main/resources/config-backup.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { + # type is deprecated and has no effect. # type = mainnet - addressPrefix = "0x41" } storage { diff --git a/framework/src/main/resources/config-beta.conf b/framework/src/main/resources/config-beta.conf index b756aed686..d925c264d3 100644 --- a/framework/src/main/resources/config-beta.conf +++ b/framework/src/main/resources/config-beta.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { - # type = testnet - addressPrefix = "0xa0" + # type is deprecated and has no effect. + # type = mainnet } storage { diff --git a/framework/src/main/resources/config-localtest.conf b/framework/src/main/resources/config-localtest.conf index f5661edd92..38a9708bec 100644 --- a/framework/src/main/resources/config-localtest.conf +++ b/framework/src/main/resources/config-localtest.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { + # type is deprecated and has no effect. # type = mainnet - addressPrefix = "0x41" } storage { diff --git a/framework/src/main/resources/config-test-net.conf b/framework/src/main/resources/config-test-net.conf index b894bb5bab..58b0905d49 100644 --- a/framework/src/main/resources/config-test-net.conf +++ b/framework/src/main/resources/config-test-net.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { + # type is deprecated and has no effect. # type = mainnet - # addressPrefix = "0x41" } storage { diff --git a/framework/src/main/resources/config.conf b/framework/src/main/resources/config.conf index bdc3479c8d..661a592e43 100644 --- a/framework/src/main/resources/config.conf +++ b/framework/src/main/resources/config.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { + # type is deprecated and has no effect. # type = mainnet - addressPrefix = "0x41" } storage { diff --git a/framework/src/test/java/org/tron/common/runtime/vm/AllowTvmCompatibleEvmTest.java b/framework/src/test/java/org/tron/common/runtime/vm/AllowTvmCompatibleEvmTest.java index ded7bb01af..74d44dfca7 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/AllowTvmCompatibleEvmTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/AllowTvmCompatibleEvmTest.java @@ -294,7 +294,7 @@ public void testChainId() throws ContractExeException, ReceiptCheckErrException, byte[] returnValue = result.getRuntime().getResult().getHReturn(); Assert.assertNull(result.getRuntime().getRuntimeError()); Assert.assertEquals(Hex.toHexString(returnValue), - "0000000000000000000000000000000000000000000000000000000028c12d1e"); + "000000000000000000000000000000000000000000000000000000000d953577"); VMConfig.initAllowTvmCompatibleEvm(0); } diff --git a/framework/src/test/java/org/tron/common/runtime/vm/ExtCodeHashTest.java b/framework/src/test/java/org/tron/common/runtime/vm/ExtCodeHashTest.java index d2ad875e4b..aa8588a642 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/ExtCodeHashTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/ExtCodeHashTest.java @@ -55,7 +55,7 @@ public void testExtCodeHash() // Trigger contract method: getCodeHashByAddr(address) String methodByAddr = "getCodeHashByAddr(address)"; - String nonexistentAccount = "27k66nycZATHzBasFT9782nTsYWqVtxdtAc"; + String nonexistentAccount = "TWyoFfJBiKGkVQd28HTqxsc8kbMtQUmqgi"; String hexInput = AbiUtil.parseMethod(methodByAddr, Arrays.asList(nonexistentAccount)); TVMTestResult result = TvmTestUtils .triggerContractAndReturnTvmTestResult(Hex.decode(OWNER_ADDRESS), @@ -68,7 +68,7 @@ public void testExtCodeHash() "0000000000000000000000000000000000000000000000000000000000000000"); // trigger deployed contract - String existentAccount = "27WtBq2KoSy5v8VnVZBZHHJcDuWNiSgjbE3"; + String existentAccount = "THmtHi1Rzq4gSKYGEKv1DPkV7au6xU1AUB"; hexInput = AbiUtil.parseMethod(methodByAddr, Arrays.asList(existentAccount)); result = TvmTestUtils .triggerContractAndReturnTvmTestResult(Hex.decode(OWNER_ADDRESS), diff --git a/framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.java b/framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.java index 01e602ac81..11908dde78 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.java @@ -82,7 +82,7 @@ public class FreezeTest { + "020019092919050505061017d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673fff" + "fffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600080606060405" + "1806020016101469061026e565b6020820181038252601f19601f82011660405250905083815160208301600" - + "0f59150813b61017357600080fd5b8192505050919050565b60008060a060f81b30846040518060200161019" + + "0f59150813b61017357600080fd5b8192505050919050565b600080604160f81b30846040518060200161019" + "79061026e565b6020820181038252601f19601f820116604052508051906020012060405160200180857efff" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167efffffffffffffffffffffff" + "fffffffffffffffffffffffffffffffffffffff191681526001018473fffffffffffffffffffffffffffffff" @@ -114,11 +114,11 @@ public class FreezeTest { private static final long value = 100_000_000_000_000_000L; private static final long fee = 1_000_000_000; - private static final String userAStr = "27k66nycZATHzBasFT9782nTsYWqVtxdtAc"; + private static final String userAStr = "TWyoFfJBiKGkVQd28HTqxsc8kbMtQUmqgi"; private static final byte[] userA = Commons.decode58Check(userAStr); - private static final String userBStr = "27jzp7nVEkH4Hf3H1PHPp4VDY7DxTy5eydL"; + private static final String userBStr = "TWtWaUAsJ933xs2n4RkXzaMoKJUrQmctBH"; private static final byte[] userB = Commons.decode58Check(userBStr); - private static final String userCStr = "27juXSbMvL6pb8VgmKRgW6ByCfw5RqZjUuo"; + private static final String userCStr = "TWoDuH3YsxoMSKSXza3E2H7Tt1bpK5QZgm"; private static final byte[] userC = Commons.decode58Check(userCStr); @Rule 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 b9212b1b97..5f6d402aad 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 @@ -151,11 +151,11 @@ public class FreezeV2Test { private static final long value = 100_000_000_000_000_000L; private static final long fee = 1_000_000_000; - private static final String userAStr = "27k66nycZATHzBasFT9782nTsYWqVtxdtAc"; + private static final String userAStr = "TWyoFfJBiKGkVQd28HTqxsc8kbMtQUmqgi"; private static final byte[] userA = Commons.decode58Check(userAStr); - private static final String userBStr = "27jzp7nVEkH4Hf3H1PHPp4VDY7DxTy5eydL"; + private static final String userBStr = "TWtWaUAsJ933xs2n4RkXzaMoKJUrQmctBH"; private static final byte[] userB = Commons.decode58Check(userBStr); - private static final String userCStr = "27juXSbMvL6pb8VgmKRgW6ByCfw5RqZjUuo"; + private static final String userCStr = "TWoDuH3YsxoMSKSXza3E2H7Tt1bpK5QZgm"; private static final byte[] userC = Commons.decode58Check(userCStr); @Rule diff --git a/framework/src/test/java/org/tron/common/runtime/vm/IsContractTest.java b/framework/src/test/java/org/tron/common/runtime/vm/IsContractTest.java index 94561e856f..2067159eed 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/IsContractTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/IsContractTest.java @@ -183,7 +183,7 @@ public void testIsContract() // Trigger contract method: isTest(address) String methodByAddr = "isTest(address)"; - String nonexistentAccount = "27k66nycZATHzBasFT9782nTsYWqVtxdtAc"; + String nonexistentAccount = "TWyoFfJBiKGkVQd28HTqxsc8kbMtQUmqgi"; String hexInput = AbiUtil.parseMethod(methodByAddr, Arrays.asList(nonexistentAccount)); TVMTestResult result = TvmTestUtils .triggerContractAndReturnTvmTestResult(Hex.decode(OWNER_ADDRESS), diff --git a/framework/src/test/java/org/tron/common/runtime/vm/IsSRCandidateTest.java b/framework/src/test/java/org/tron/common/runtime/vm/IsSRCandidateTest.java index f6116dbe97..c4b58923a2 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/IsSRCandidateTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/IsSRCandidateTest.java @@ -151,7 +151,7 @@ public void testIsSRCandidate() // Trigger contract method: isSRCandidateTest(address) String methodByAddr = "isSRCandidateTest(address)"; - String nonexistentAccount = "27k66nycZATHzBasFT9782nTsYWqVtxdtAc"; + String nonexistentAccount = "TWyoFfJBiKGkVQd28HTqxsc8kbMtQUmqgi"; byte[] nonexistentAddr = Hex.decode("A0E6773BBF60F97D22AA3BF73D2FE235E816A1964F"); String hexInput = AbiUtil.parseMethod(methodByAddr, Collections.singletonList(nonexistentAccount)); @@ -209,8 +209,8 @@ public void testIsSRCandidate() repository.commit(); // trigger deployed contract - String witnessAccount = "27Ssb1WE8FArwJVRRb8Dwy3ssVGuLY8L3S1"; - byte[] witnessAddr = Hex.decode("a0299f3db80a24b20a254b89ce639d59132f157f13"); + String witnessAccount = "TDmHUBuko2qhcKBCGGafu928hMRj1tX2RW"; + byte[] witnessAddr = Hex.decode("41299f3db80a24b20a254b89ce639d59132f157f13"); hexInput = AbiUtil.parseMethod(methodByAddr, Collections.singletonList(witnessAccount)); trx = TvmTestUtils.generateTriggerSmartContractAndGetTransaction( diff --git a/framework/src/test/java/org/tron/common/runtime/vm/IstanbulTest.java b/framework/src/test/java/org/tron/common/runtime/vm/IstanbulTest.java index 1613eab53c..df3333539a 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/IstanbulTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/IstanbulTest.java @@ -94,7 +94,7 @@ public void istanbulSelfBalanceChainIdTest() 0, fee, manager, null); Assert.assertNull(result.getRuntime().getRuntimeError()); Assert.assertEquals(Hex.toHexString(result.getRuntime().getResult().getHReturn()), - "00000000000000007adbf8dc20423f587a5f3f8ea83e2877e2129c5128c12d1e"); + "0000000000000000c56977ebd315874c5c3c0de6b05738117462db120d953577"); //genesis block hash } diff --git a/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsTest.java b/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsTest.java index 4d3ad0cc2a..d5a50ea4f9 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsTest.java @@ -874,10 +874,10 @@ public void resourceV2Test() { Repository tempRepository = RepositoryImpl.createRoot(StoreFactory.getInstance()); resourceV2Pcc.setRepository(tempRepository); - String targetStr = "27k66nycZATHzBasFT9782nTsYWqVtxdtAc"; + String targetStr = "TWyoFfJBiKGkVQd28HTqxsc8kbMtQUmqgi"; byte[] targetAddr = Commons.decode58Check(targetStr); byte[] target = new DataWord(targetAddr).getData(); - String fromStr = "27jzp7nVEkH4Hf3H1PHPp4VDY7DxTy5eydL"; + String fromStr = "TWtWaUAsJ933xs2n4RkXzaMoKJUrQmctBH"; byte[] fromAddr = Commons.decode58Check(fromStr); byte[] from = new DataWord(fromAddr).getData(); byte[] type = ByteUtil.longTo32Bytes(0); diff --git a/framework/src/test/java/org/tron/common/runtime/vm/RewardBalanceTest.java b/framework/src/test/java/org/tron/common/runtime/vm/RewardBalanceTest.java index af95952ebf..58ce6459ae 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/RewardBalanceTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/RewardBalanceTest.java @@ -154,7 +154,7 @@ public void testRewardBalance() // Trigger contract method: rewardBalanceTest(address) String methodByAddr = "rewardBalanceTest(address)"; - String nonexistentAccount = "27k66nycZATHzBasFT9782nTsYWqVtxdtAc"; + String nonexistentAccount = "TWyoFfJBiKGkVQd28HTqxsc8kbMtQUmqgi"; String hexInput = AbiUtil.parseMethod(methodByAddr, Collections.singletonList(nonexistentAccount)); BlockCapsule blockCap = new BlockCapsule(Protocol.Block.newBuilder().build()); @@ -195,7 +195,7 @@ public void testRewardBalance() repository.commit(); // trigger deployed contract - String witnessAccount = "27Ssb1WE8FArwJVRRb8Dwy3ssVGuLY8L3S1"; + String witnessAccount = "TDmHUBuko2qhcKBCGGafu928hMRj1tX2RW"; hexInput = AbiUtil.parseMethod(methodByAddr, Collections.singletonList(witnessAccount)); trx = TvmTestUtils.generateTriggerSmartContractAndGetTransaction(Hex.decode(OWNER_ADDRESS), factoryAddress, Hex.decode(hexInput), 0, feeLimit); diff --git a/framework/src/test/java/org/tron/common/runtime/vm/TransferFailedEnergyTest.java b/framework/src/test/java/org/tron/common/runtime/vm/TransferFailedEnergyTest.java index dbc9147de7..4c822df40e 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/TransferFailedEnergyTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/TransferFailedEnergyTest.java @@ -178,7 +178,7 @@ function test() payable public {} } */ - private static final String nonExistAddress = "27k66nycZATHzBasFT9782nTsYWqVtxdtAc"; // 21 char + private static final String nonExistAddress = "TWyoFfJBiKGkVQd28HTqxsc8kbMtQUmqgi"; // 21 char TestCase[] testCasesAfterAllowTvmConstantinop = { new TestCase("testTransferTrxSelf()", Collections.emptyList(), false, contractResult.TRANSFER_FAILED), diff --git a/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java b/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java index 63cbce5b30..0a1e53ab96 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java @@ -46,7 +46,7 @@ public class VMContractTestBase { MortgageService mortgageService; static { - // 27Ssb1WE8FArwJVRRb8Dwy3ssVGuLY8L3S1 (test.config) + // TDmHUBuko2qhcKBCGGafu928hMRj1tX2RW (test.config) WITNESS_SR1_ADDRESS = "a0" + "299F3DB80A24B20A254B89CE639D59132F157F13"; } 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 1615cdf8b8..f747d5551b 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 @@ -201,17 +201,17 @@ public class VoteTest { private static final long fee = 1_000_000_000L; private static final long freezeUnit = 1_000_000_000_000L; private static final long trx_precision = 1_000_000L; - private static final String userAStr = "27k66nycZATHzBasFT9782nTsYWqVtxdtAc"; + private static final String userAStr = "TWyoFfJBiKGkVQd28HTqxsc8kbMtQUmqgi"; private static final byte[] userA = Commons.decode58Check(userAStr); - private static final String userBStr = "27jzp7nVEkH4Hf3H1PHPp4VDY7DxTy5eydL"; + private static final String userBStr = "TWtWaUAsJ933xs2n4RkXzaMoKJUrQmctBH"; private static final byte[] userB = Commons.decode58Check(userBStr); - private static final String userCStr = "27juXSbMvL6pb8VgmKRgW6ByCfw5RqZjUuo"; + private static final String userCStr = "TWoDuH3YsxoMSKSXza3E2H7Tt1bpK5QZgm"; private static final byte[] userC = Commons.decode58Check(userCStr); - private static final String witnessAStr = "27Ssb1WE8FArwJVRRb8Dwy3ssVGuLY8L3S1"; + private static final String witnessAStr = "TDmHUBuko2qhcKBCGGafu928hMRj1tX2RW"; private static final byte[] witnessA = Commons.decode58Check(witnessAStr); - private static final String witnessBStr = "27anh4TDZJGYpsn4BjXzb7uEArNALxwiZZW"; + private static final String witnessBStr = "TMgPX8uBr8XbBboxQgMK3zNS4SgjUa3eiP"; private static final byte[] witnessB = Commons.decode58Check(witnessBStr); - private static final String witnessCStr = "27Wkfa5iEJtsKAKdDzSmF1b2gDm5s49kvdZ"; + private static final String witnessCStr = "THeN2mPrrkr5U9Nzfb7xwgAwRqcFWcL7pR"; private static final byte[] witnessC = Commons.decode58Check(witnessCStr); private static final String freezeMethod = "freeze(address,uint256,uint256)"; private static final String unfreezeMethod = "unfreeze(address,uint256)"; diff --git a/framework/src/test/java/org/tron/core/actuator/AssetIssueActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/AssetIssueActuatorTest.java index cfa54a6365..b5114d842e 100755 --- a/framework/src/test/java/org/tron/core/actuator/AssetIssueActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/AssetIssueActuatorTest.java @@ -1700,7 +1700,7 @@ public void SameTokenNameCloseInvalidAddr() { @Test public void IssueSameTokenNameAssert() { dbManager.getDynamicPropertiesStore().saveAllowSameTokenName(0); - String ownerAddress = "a08beaa1a8e2d45367af7bae7c49009876a4fa4301"; + String ownerAddress = "418beaa1a8e2d45367af7bae7c49009876a4fa4301"; long id = dbManager.getDynamicPropertiesStore().getTokenIdNum() + 1; dbManager.getDynamicPropertiesStore().saveTokenIdNum(id); 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 cdc7d37832..c693348519 100644 --- a/framework/src/test/java/org/tron/core/actuator/ExchangeInjectActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/ExchangeInjectActuatorTest.java @@ -836,7 +836,7 @@ public void SameTokenNameCloseAccountIsNotCreator() { fail(); } catch (ContractValidateException e) { Assert.assertTrue(e instanceof ContractValidateException); - Assert.assertEquals("account[a0548794500882809695a8a687866e76d4271a1abc]" + Assert.assertEquals("account[41548794500882809695a8a687866e76d4271a1abc]" + " is not creator", e.getMessage()); } catch (ContractExeException e) { @@ -884,7 +884,7 @@ public void SameTokenNameOpenAccountIsNotCreator() { fail(); } catch (ContractValidateException e) { Assert.assertTrue(e instanceof ContractValidateException); - Assert.assertEquals("account[a0548794500882809695a8a687866e76d4271a1abc]" + Assert.assertEquals("account[41548794500882809695a8a687866e76d4271a1abc]" + " is not creator", e.getMessage()); } catch (ContractExeException e) { 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 e7c08eaef6..74d6ca1dac 100644 --- a/framework/src/test/java/org/tron/core/actuator/ExchangeWithdrawActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/ExchangeWithdrawActuatorTest.java @@ -868,7 +868,7 @@ public void SameTokenNameCloseAccountIsNotCreator() { fail(); } catch (ContractValidateException e) { Assert.assertTrue(e instanceof ContractValidateException); - Assert.assertEquals("account[a0548794500882809695a8a687866e76d4271a1abc]" + Assert.assertEquals("account[41548794500882809695a8a687866e76d4271a1abc]" + " is not creator", e.getMessage()); } catch (ContractExeException e) { @@ -915,7 +915,7 @@ public void SameTokenNameOpenAccountIsNotCreator() { fail(); } catch (ContractValidateException e) { Assert.assertTrue(e instanceof ContractValidateException); - Assert.assertEquals("account[a0548794500882809695a8a687866e76d4271a1abc]" + Assert.assertEquals("account[41548794500882809695a8a687866e76d4271a1abc]" + " is not creator", e.getMessage()); } catch (ContractExeException e) { diff --git a/framework/src/test/java/org/tron/core/actuator/UnfreezeBalanceActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/UnfreezeBalanceActuatorTest.java index 6caf861e7c..f5c65bf381 100644 --- a/framework/src/test/java/org/tron/core/actuator/UnfreezeBalanceActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/UnfreezeBalanceActuatorTest.java @@ -411,7 +411,7 @@ public void testUnfreezeDelegatedBalanceForBandwidthWithDeletedReceiver() { Assert.fail(); } catch (ContractValidateException e) { Assert.assertEquals( - "Receiver Account[a0abd4b9367799eaa3197fecb144eb71de1e049150] does not exist", + "Receiver Account[41abd4b9367799eaa3197fecb144eb71de1e049150] does not exist", e.getMessage()); } catch (ContractExeException e) { Assert.fail(); @@ -721,7 +721,7 @@ public void testUnfreezeDelegatedBalanceForCpuWithDeletedReceiver() { Assert.fail(); } catch (ContractValidateException e) { Assert.assertEquals( - "Receiver Account[a0abd4b9367799eaa3197fecb144eb71de1e049150] does not exist", + "Receiver Account[41abd4b9367799eaa3197fecb144eb71de1e049150] does not exist", e.getMessage()); } catch (ContractExeException e) { Assert.fail(); 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 15bcf7ce81..f8d8e6bdd9 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 @@ -304,7 +304,7 @@ public void validateCheck() { forkUtils.getManager().getDynamicPropertiesStore() .statsByVersion(ForkBlockVersionEnum.VERSION_4_0_1.getValue(), stats); ByteString address = ByteString - .copyFrom(ByteArray.fromHexString("a0ec6525979a351a54fa09fea64beb4cce33ffbb7a")); + .copyFrom(ByteArray.fromHexString("41ec6525979a351a54fa09fea64beb4cce33ffbb7a")); List w = new ArrayList<>(); w.add(address); forkUtils.getManager().getWitnessScheduleStore().saveActiveWitnesses(w); 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 0482bdffae..61790849b4 100644 --- a/framework/src/test/java/org/tron/core/capsule/BlockCapsuleTest.java +++ b/framework/src/test/java/org/tron/core/capsule/BlockCapsuleTest.java @@ -79,7 +79,7 @@ public void testCalcMerkleRoot() throws Exception { blockCapsule0.setMerkleRoot(); Assert.assertEquals( - "53421c1f1bcbbba67a4184cc3dbc1a59f90af7e2b0644dcfc8dc738fe30deffc", + "5bc862243292e6aa1d5e21a60bb6a673e4c2544709f6363d4a2f85ec29bcfe00", blockCapsule0.getMerkleRoot().toString()); logger.info("Transaction[O] Merkle Root : {}", blockCapsule0.getMerkleRoot().toString()); 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 41aa32b297..bdca1f02af 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 @@ -70,7 +70,7 @@ public void get() { Args.setLocalWitnesses(localWitnesses); address = ByteArray.toHexString(Args.getLocalWitnesses() .getWitnessAccountAddress()); - Assert.assertEquals("a0", DecodeUtil.addressPreFixString); + Assert.assertEquals("41", DecodeUtil.addressPreFixString); // configFilePath should be set to shellConfFileName when -c is specified Assert.assertEquals(TestConstants.TEST_CONF, parameter.getConfigFilePath()); Assert.assertEquals(0, parameter.getBackupPriority()); 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 88b0527f36..6f34288939 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 @@ -85,9 +85,9 @@ public void test() throws Exception { private void initWitness() { // key: 0154435f065a57fec6af1e12eaa2fa600030639448d7809f4c65bdcf8baed7e5 - // Hex: A08A8D690BF36806C36A7DAE3AF796643C1AA9CC01 - // Base58: 27bi7CD8d94AgXY3XFS9A9vx78Si5MqrECz - byte[] key = Hex.decode("A08A8D690BF36806C36A7DAE3AF796643C1AA9CC01");//exist already + // Hex: 418A8D690BF36806C36A7DAE3AF796643C1AA9CC01 + // Base58: TNboetpFgv9SqMoHvaVt626NLXETnbdW1K + byte[] key = Hex.decode("418A8D690BF36806C36A7DAE3AF796643C1AA9CC01");//exist already WitnessCapsule witnessCapsule = chainBaseManager.getWitnessStore().get(key); System.out.println(witnessCapsule.getInstance()); witnessCapsule.setVoteCount(1000); @@ -104,23 +104,23 @@ public void testGetNextWitnesses() throws Exception { "getNextWitnesses", ByteString.class, Integer.class); method.setAccessible(true); Set s1 = (Set) method.invoke( - service, getFromHexString("A08A8D690BF36806C36A7DAE3AF796643C1AA9CC01"), 3); + service, getFromHexString("418A8D690BF36806C36A7DAE3AF796643C1AA9CC01"), 3); Assert.assertEquals(3, s1.size()); - assertContains(s1, "A0299F3DB80A24B20A254B89CE639D59132F157F13"); - assertContains(s1, "A0807337F180B62A77576377C1D0C9C24DF5C0DD62"); - assertContains(s1, "A05430A3F089154E9E182DDD6FE136A62321AF22A7"); + assertContains(s1, "41299F3DB80A24B20A254B89CE639D59132F157F13"); + assertContains(s1, "41807337F180B62A77576377C1D0C9C24DF5C0DD62"); + assertContains(s1, "415430A3F089154E9E182DDD6FE136A62321AF22A7"); Set s2 = (Set) method.invoke( - service, getFromHexString("A0FAB5FBF6AFB681E4E37E9D33BDDB7E923D6132E5"), 3); + service, getFromHexString("41FAB5FBF6AFB681E4E37E9D33BDDB7E923D6132E5"), 3); Assert.assertEquals(3, s2.size()); - assertContains(s2, "A014EEBE4D30A6ACB505C8B00B218BDC4733433C68"); - assertContains(s2, "A08A8D690BF36806C36A7DAE3AF796643C1AA9CC01"); - assertContains(s2, "A0299F3DB80A24B20A254B89CE639D59132F157F13"); + assertContains(s2, "4114EEBE4D30A6ACB505C8B00B218BDC4733433C68"); + assertContains(s2, "418A8D690BF36806C36A7DAE3AF796643C1AA9CC01"); + assertContains(s2, "41299F3DB80A24B20A254B89CE639D59132F157F13"); Set s3 = (Set) method.invoke( - service, getFromHexString("A08A8D690BF36806C36A7DAE3AF796643C1AA9CC01"), 1); + service, getFromHexString("418A8D690BF36806C36A7DAE3AF796643C1AA9CC01"), 1); Assert.assertEquals(1, s3.size()); - assertContains(s3, "A0299F3DB80A24B20A254B89CE639D59132F157F13"); + assertContains(s3, "41299F3DB80A24B20A254B89CE639D59132F157F13"); } private void testBroadcast() { @@ -133,7 +133,7 @@ private void testBroadcast() { doNothing().when(c1).send((byte[]) any()); peer.setChannel(c1); - peer.setAddress(getFromHexString("A0299F3DB80A24B20A254B89CE639D59132F157F13")); + peer.setAddress(getFromHexString("41299F3DB80A24B20A254B89CE639D59132F157F13")); peer.setNeedSyncFromPeer(false); peer.setNeedSyncFromUs(false); @@ -149,7 +149,7 @@ private void testBroadcast() { BlockCapsule blockCapsule = new BlockCapsule(chainBaseManager.getHeadBlockNum() + 1, chainBaseManager.getHeadBlockId(), - 0, getFromHexString("A08A8D690BF36806C36A7DAE3AF796643C1AA9CC01")); + 0, getFromHexString("418A8D690BF36806C36A7DAE3AF796643C1AA9CC01")); BlockMessage msg = new BlockMessage(blockCapsule); service.broadcast(msg); Item item = new Item(blockCapsule.getBlockId(), Protocol.Inventory.InventoryType.BLOCK); @@ -173,7 +173,7 @@ private ByteString getFromHexString(String s) { private void testCheckHelloMessage() { String key = "0154435f065a57fec6af1e12eaa2fa600030639448d7809f4c65bdcf8baed7e5"; - ByteString address = getFromHexString("A08A8D690BF36806C36A7DAE3AF796643C1AA9CC01"); + ByteString address = getFromHexString("418A8D690BF36806C36A7DAE3AF796643C1AA9CC01"); InetSocketAddress a1 = new InetSocketAddress("127.0.0.1", 10001); Node node = new Node(NetUtil.getNodeId(), a1.getAddress().getHostAddress(), null, a1.getPort()); 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 index b3dbbced55..48b538380c 100644 --- a/framework/src/test/java/org/tron/core/services/http/ClearABIServletTest.java +++ b/framework/src/test/java/org/tron/core/services/http/ClearABIServletTest.java @@ -38,7 +38,7 @@ public class ClearABIServletTest extends BaseTest { private ClearABIServlet clearABIServlet; private static final String SMART_CONTRACT_NAME = "smart_contract_test"; - private static String CONTRACT_ADDRESS = "A0B4750E2CD76E19DCA331BF5D089B71C3C2798548"; + private static String CONTRACT_ADDRESS = "41B4750E2CD76E19DCA331BF5D089B71C3C2798548"; private static String OWNER_ADDRESS; private static final long SOURCE_ENERGY_LIMIT = 10L; @@ -47,7 +47,7 @@ public class ClearABIServletTest extends BaseTest { private SmartContractOuterClass.SmartContract.Builder createContract( String contractAddress, String contractName) { OWNER_ADDRESS = - "A099357684BC659F5166046B56C95A0E99F1265CBD"; + "4199357684BC659F5166046B56C95A0E99F1265CBD"; SmartContractOuterClass.SmartContract.Builder builder = SmartContractOuterClass.SmartContract.newBuilder(); builder.setName(contractName); @@ -68,8 +68,8 @@ public void testClearABI() { new ContractCapsule(contract.build())); String jsonParam = "{" - + " \"owner_address\": \"A099357684BC659F5166046B56C95A0E99F1265CBD\"," - + " \"contract_address\": \"A0B4750E2CD76E19DCA331BF5D089B71C3C2798548\"" + + " \"owner_address\": \"4199357684BC659F5166046B56C95A0E99F1265CBD\"," + + " \"contract_address\": \"41B4750E2CD76E19DCA331BF5D089B71C3C2798548\"" + "}"; MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); request.setContentType("application/json"); 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 index 5fa6a77868..1c34d7b8a9 100644 --- a/framework/src/test/java/org/tron/core/services/http/CreateAccountServletTest.java +++ b/framework/src/test/java/org/tron/core/services/http/CreateAccountServletTest.java @@ -41,7 +41,7 @@ public class CreateAccountServletTest extends BaseTest { public void init() { AccountCapsule accountCapsule = new AccountCapsule( ByteString.copyFrom(ByteArray - .fromHexString("A099357684BC659F5166046B56C95A0E99F1265CD1")), + .fromHexString("4199357684BC659F5166046B56C95A0E99F1265CD1")), ByteString.copyFromUtf8("owner"), Protocol.AccountType.forNumber(1)); @@ -52,8 +52,8 @@ public void init() { @Test public void testCreate() { String jsonParam = "{" - + "\"owner_address\": \"A099357684BC659F5166046B56C95A0E99F1265CD1\"," - + "\"account_address\": \"A0B4750E2CD76E19DCA331BF5D089B71C3C2798541\"" + + "\"owner_address\": \"4199357684BC659F5166046B56C95A0E99F1265CD1\"," + + "\"account_address\": \"41B4750E2CD76E19DCA331BF5D089B71C3C2798541\"" + "}"; MockHttpServletRequest request = createRequest(HttpPost.METHOD_NAME); request.setContentType("application/json"); 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 index d2e6b83104..52ada9dd0d 100644 --- a/framework/src/test/java/org/tron/core/services/http/CreateAssetIssueServletTest.java +++ b/framework/src/test/java/org/tron/core/services/http/CreateAssetIssueServletTest.java @@ -40,7 +40,7 @@ public class CreateAssetIssueServletTest extends BaseTest { public void init() { AccountCapsule accountCapsule = new AccountCapsule( ByteString.copyFrom(ByteArray - .fromHexString("A099357684BC659F5166046B56C95A0E99F1265CD1")), + .fromHexString("4199357684BC659F5166046B56C95A0E99F1265CD1")), ByteString.copyFromUtf8("owner"), Protocol.AccountType.forNumber(1)); accountCapsule.setBalance(10000000000L); @@ -52,7 +52,7 @@ public void init() { @Test public void testCreate() { String jsonParam = "{" - + " \"owner_address\": \"A099357684BC659F5166046B56C95A0E99F1265CD1\"," + + " \"owner_address\": \"4199357684BC659F5166046B56C95A0E99F1265CD1\"," + " \"name\": \"0x6173736574497373756531353330383934333132313538\"," + " \"abbr\": \"0x6162627231353330383934333132313538\"," + " \"total_supply\": 4321," diff --git a/framework/src/test/java/org/tron/core/services/http/GetBrokerageServletTest.java b/framework/src/test/java/org/tron/core/services/http/GetBrokerageServletTest.java index 7588283b4b..b5fa191454 100644 --- a/framework/src/test/java/org/tron/core/services/http/GetBrokerageServletTest.java +++ b/framework/src/test/java/org/tron/core/services/http/GetBrokerageServletTest.java @@ -37,7 +37,7 @@ public MockHttpServletRequest createRequest(String contentType) { @Test public void getBrokerageValueByJsonTest() { int expect = 20; - String jsonParam = "{\"address\": \"27VZHn9PFZwNh7o2EporxmLkpe157iWZVkh\"}"; + String jsonParam = "{\"address\": \"TGSzEq4t7oMTRcn1VxDghRu5r5bWAE5D1W\"}"; MockHttpServletRequest request = createRequest("application/json"); request.setContent(jsonParam.getBytes()); MockHttpServletResponse response = new MockHttpServletResponse(); @@ -56,7 +56,7 @@ public void getBrokerageValueByJsonTest() { @Test public void getBrokerageByJsonUTF8Test() { int expect = 20; - String jsonParam = "{\"address\": \"27VZHn9PFZwNh7o2EporxmLkpe157iWZVkh\"}"; + String jsonParam = "{\"address\": \"TGSzEq4t7oMTRcn1VxDghRu5r5bWAE5D1W\"}"; MockHttpServletRequest request = createRequest("application/json; charset=utf-8"); request.setContent(jsonParam.getBytes()); MockHttpServletResponse response = new MockHttpServletResponse(); @@ -75,7 +75,7 @@ public void getBrokerageByJsonUTF8Test() { public void getBrokerageValueTest() { int expect = 20; MockHttpServletRequest request = createRequest("application/x-www-form-urlencoded"); - request.addParameter("address", "27VZHn9PFZwNh7o2EporxmLkpe157iWZVkh"); + request.addParameter("address", "TGSzEq4t7oMTRcn1VxDghRu5r5bWAE5D1W"); MockHttpServletResponse response = new MockHttpServletResponse(); getBrokerageServlet.doPost(request, response); try { diff --git a/framework/src/test/java/org/tron/core/services/http/GetRewardServletTest.java b/framework/src/test/java/org/tron/core/services/http/GetRewardServletTest.java index 29c44c171e..3de72eb3d4 100644 --- a/framework/src/test/java/org/tron/core/services/http/GetRewardServletTest.java +++ b/framework/src/test/java/org/tron/core/services/http/GetRewardServletTest.java @@ -58,7 +58,7 @@ public MockHttpServletRequest createRequest(String contentType) { @Before public void init() { manager.getDynamicPropertiesStore().saveChangeDelegation(1); - byte[] sr = decodeFromBase58Check("27bi7CD8d94AgXY3XFS9A9vx78Si5MqrECz"); + byte[] sr = decodeFromBase58Check("TNboetpFgv9SqMoHvaVt626NLXETnbdW1K"); delegationStore.setBrokerage(0, sr, 10); delegationStore.setWitnessVote(0, sr, 100000000); } @@ -66,7 +66,7 @@ public void init() { @Test public void getRewardValueByJsonTest() { int expect = 138181; - String jsonParam = "{\"address\": \"27bi7CD8d94AgXY3XFS9A9vx78Si5MqrECz\"}"; + String jsonParam = "{\"address\": \"TNboetpFgv9SqMoHvaVt626NLXETnbdW1K\"}"; MockHttpServletRequest request = createRequest("application/json"); MockHttpServletResponse response = new MockHttpServletResponse(); request.setContent(jsonParam.getBytes()); @@ -84,7 +84,7 @@ public void getRewardValueByJsonTest() { @Test public void getRewardByJsonUTF8Test() { int expect = 138181; - String jsonParam = "{\"address\": \"27bi7CD8d94AgXY3XFS9A9vx78Si5MqrECz\"}"; + String jsonParam = "{\"address\": \"TNboetpFgv9SqMoHvaVt626NLXETnbdW1K\"}"; MockHttpServletRequest request = createRequest("application/json; charset=utf-8"); MockHttpServletResponse response = new MockHttpServletResponse(); request.setContent(jsonParam.getBytes()); @@ -105,7 +105,7 @@ public void getRewardValueTest() { MockHttpServletRequest request = createRequest("application/x-www-form-urlencoded"); MockHttpServletResponse response = new MockHttpServletResponse(); mortgageService.payStandbyWitness(); - request.addParameter("address", "27bi7CD8d94AgXY3XFS9A9vx78Si5MqrECz"); + request.addParameter("address", "TNboetpFgv9SqMoHvaVt626NLXETnbdW1K"); getRewardServlet.doPost(request, response); try { String contentAsString = response.getContentAsString(); diff --git a/framework/src/test/java/org/tron/core/witness/WitnessControllerTest.java b/framework/src/test/java/org/tron/core/witness/WitnessControllerTest.java index 3830e631cc..c07775907d 100644 --- a/framework/src/test/java/org/tron/core/witness/WitnessControllerTest.java +++ b/framework/src/test/java/org/tron/core/witness/WitnessControllerTest.java @@ -39,31 +39,31 @@ public void testWitnessSchedule() { // test witnesses in genesis block assertEquals( - "a0904fe896536f4bebc64c95326b5054a2c3d27df6", // first(current witness) + "41904fe896536f4bebc64c95326b5054a2c3d27df6", // first(current witness) ByteArray.toHexString( (dposSlot.getScheduledWitness(0).toByteArray()))); assertEquals( - "a0904fe896536f4bebc64c95326b5054a2c3d27df6", + "41904fe896536f4bebc64c95326b5054a2c3d27df6", ByteArray.toHexString( (dposSlot.getScheduledWitness(5).toByteArray()))); assertEquals( - "a0807337f180b62a77576377c1d0c9c24df5c0dd62", // second(next witness) + "41807337f180b62a77576377c1d0c9c24df5c0dd62", // second(next witness) ByteArray.toHexString( (dposSlot.getScheduledWitness(6).toByteArray()))); assertEquals( - "a0807337f180b62a77576377c1d0c9c24df5c0dd62", + "41807337f180b62a77576377c1d0c9c24df5c0dd62", ByteArray.toHexString( (dposSlot.getScheduledWitness(11).toByteArray()))); assertEquals( - "a05430a3f089154e9e182ddd6fe136a62321af22a7", // third + "415430a3f089154e9e182ddd6fe136a62321af22a7", // third ByteArray.toHexString( (dposSlot.getScheduledWitness(12).toByteArray()))); // test maintenance ByteString a = - ByteString.copyFrom(ByteArray.fromHexString("a0ec6525979a351a54fa09fea64beb4cce33ffbb7a")); + ByteString.copyFrom(ByteArray.fromHexString("41ec6525979a351a54fa09fea64beb4cce33ffbb7a")); ByteString b = - ByteString.copyFrom(ByteArray.fromHexString("a0fab5fbf6afb681e4e37e9d33bddb7e923d6132e5")); + ByteString.copyFrom(ByteArray.fromHexString("41fab5fbf6afb681e4e37e9d33bddb7e923d6132e5")); // system.out.print("a address:" + ByteArray.toHexString(a.toByteArray()) + "\n"); // System.out.print("b address:" + ByteArray.toHexString(b.toByteArray())); List w = new ArrayList<>(); diff --git a/framework/src/test/resources/args-test.conf b/framework/src/test/resources/args-test.conf index 360e751b5d..13289949a5 100644 --- a/framework/src/test/resources/args-test.conf +++ b/framework/src/test/resources/args-test.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { - # type = testnet - addressPrefix = "0xa0" + # type is deprecated and has no effect. + # type = mainnet } diff --git a/framework/src/test/resources/config-localtest.conf b/framework/src/test/resources/config-localtest.conf index 90df46fff0..f1f40dead7 100644 --- a/framework/src/test/resources/config-localtest.conf +++ b/framework/src/test/resources/config-localtest.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { + # type is deprecated and has no effect. # type = mainnet - addressPrefix = "0x41" } storage { diff --git a/framework/src/test/resources/config-test-dbbackup.conf b/framework/src/test/resources/config-test-dbbackup.conf index 9668a784ce..44dd0164b2 100644 --- a/framework/src/test/resources/config-test-dbbackup.conf +++ b/framework/src/test/resources/config-test-dbbackup.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { + # type is deprecated and has no effect. # type = mainnet - addressPrefix = "0x41" } storage { diff --git a/framework/src/test/resources/config-test-index.conf b/framework/src/test/resources/config-test-index.conf index 400986b18e..4a60e7a499 100644 --- a/framework/src/test/resources/config-test-index.conf +++ b/framework/src/test/resources/config-test-index.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { - # type = testnet - addressPrefix = "0xa0" + # type is deprecated and has no effect. + # type = mainnet } diff --git a/framework/src/test/resources/config-test-mainnet.conf b/framework/src/test/resources/config-test-mainnet.conf index 277747fb73..d39f432ac3 100644 --- a/framework/src/test/resources/config-test-mainnet.conf +++ b/framework/src/test/resources/config-test-mainnet.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { + # type is deprecated and has no effect. # type = mainnet - addressPrefix = "0x41" } diff --git a/framework/src/test/resources/config-test-storagetest.conf b/framework/src/test/resources/config-test-storagetest.conf index 0540a3dfbb..59edf683c0 100644 --- a/framework/src/test/resources/config-test-storagetest.conf +++ b/framework/src/test/resources/config-test-storagetest.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { - # type = testnet - addressPrefix = "0xa0" + # type is deprecated and has no effect. + # type = mainnet } diff --git a/framework/src/test/resources/config-test.conf b/framework/src/test/resources/config-test.conf index 42784e899b..41c1e9a55d 100644 --- a/framework/src/test/resources/config-test.conf +++ b/framework/src/test/resources/config-test.conf @@ -1,10 +1,6 @@ -# Deprecated: type has no effect, kept for reference only. -# addressPrefix = "0x41" is the mainnet address prefix (hex addresses start with 41). -# addressPrefix = "0xa0" is a legacy test prefix, retained for backward compatibility with test cases. -# For normal mainnet deployment, the net section can be omitted entirely. net { - # type = testnet - addressPrefix = "0xa0" + # type is deprecated and has no effect. + # type = mainnet } @@ -253,88 +249,88 @@ genesis.block = { # { # accountName = "tron" # accountType = "AssetIssue" # Normal/AssetIssue/Contract - # address = "27V2x39zmmJeVGBGSheAk1281z8svbWgn6C" + # address = "TFveVqgQKAdFa12DNnXTw7GHCDQK7fUVen" # balance = "10" # } { accountName = "Devaccount" accountType = "AssetIssue" - address = "27d3byPxZXKQWfXX7sJvemJJuv5M65F3vjS" + address = "TPwJS5eC5BPGyMGtYTHNhPTB89sUWjDSSu" balance = "10000000000000000" }, { accountName = "Zion" accountType = "AssetIssue" - address = "27fXgQ46DcjEsZ444tjZPKULcxiUfDrDjqj" + address = "TSRNrjmrAbDdrsoqZsv7FZUtAo13fwoCzv" balance = "15000000000000000" }, { accountName = "Sun" accountType = "AssetIssue" - address = "27SWXcHuQgFf9uv49FknBBBYBaH3DUk4JPx" + address = "TDQE4yb3E7dvDjouvu8u7GgSnMZbxAEumV" balance = "10000000000000000" }, { accountName = "Blackhole" accountType = "AssetIssue" - address = "27WtBq2KoSy5v8VnVZBZHHJcDuWNiSgjbE3" + address = "THmtHi1Rzq4gSKYGEKv1DPkV7au6xU1AUB" balance = "-9223372036854775808" } ] witnesses = [ { - address: 27Ssb1WE8FArwJVRRb8Dwy3ssVGuLY8L3S1 + address: TDmHUBuko2qhcKBCGGafu928hMRj1tX2RW url = "http://Mercury.org", voteCount = 105 }, { - address: 27anh4TDZJGYpsn4BjXzb7uEArNALxwiZZW + address: TMgPX8uBr8XbBboxQgMK3zNS4SgjUa3eiP url = "http://Venus.org", voteCount = 104 }, { - address: 27Wkfa5iEJtsKAKdDzSmF1b2gDm5s49kvdZ + address: THeN2mPrrkr5U9Nzfb7xwgAwRqcFWcL7pR url = "http://Earth.org", voteCount = 103 }, { - address: 27bqKYX9Bgv7dgTY7xBw5SUHZ8EGaPSikjx + address: TNj21CppEn6PzHHtdLHoNZRpLJnxogNnAX url = "http://Mars.org", voteCount = 102 }, { - address: 27fASUY6qKtsaAEPz6QxhZac2KYVz2ZRTXW + address: TS48wDnTskrLU49kmZKRVfkHXd2NQ3dZP4 url = "http://Jupiter.org", voteCount = 101 }, { - address: 27Q3RSbiqm59VXcF8shQWHKbyztfso5FwvP + address: TAw7uHQUJw8FqRzuYqmEDQkFCyCGE4JcsW url = "http://Saturn.org", voteCount = 100 }, { - address: 27YkUVSuvCK3K84DbnFnxYUxozpi793PTqZ + address: TKeAx8bYkB25RsyNTQ9gUa75CuEVfFbF6N url = "http://Uranus.org", voteCount = 99 }, { - address: 27kdTBTDJ16hK3Xqr8PpCuQJmje1b94CDJU + address: TXX9e8tvYxg5MMbcoYAvqVT2wiXyacjs65 url = "http://Neptune.org", voteCount = 98 }, { - address: 27mw9UpRy7inTMQ5kUzsdTc2QZ6KvtCX4uB + address: TYpqwW7bfamDfDqXA9EMPhAfmArKMicxp9 url = "http://Pluto.org", voteCount = 97 }, { - address: 27QzC4PeQZJ2kFMUXiCo4S8dx3VWN5U9xcg + address: TBstX5L37A1WZBEJPM9nNDnDFa2kcTVSmc url = "http://Altair.org", voteCount = 96 }, { - address: 27bi7CD8d94AgXY3XFS9A9vx78Si5MqrECz + address: TNboetpFgv9SqMoHvaVt626NLXETnbdW1K url = "http://AlphaLyrae.org", voteCount = 95 } From a2e6af192b9866b52ad308892b49db4863202e67 Mon Sep 17 00:00:00 2001 From: vividcoder Date: Mon, 2 Mar 2026 16:30:39 +0800 Subject: [PATCH 6/8] fix: fix remaining a0-prefix addresses missed in previous migration - VMContractTestBase: WITNESS_SR1_ADDRESS "a0" -> "41" - IsSRCandidateTest: nonexistentAddr hex "A0" -> "41" - config-test-storagetest.conf: convert 16 genesis 27-prefix addresses to T-prefix - config-test-index.conf: convert genesis 27-prefix address to T-prefix - .gitignore: broaden bin/ pattern to **/bin/, add *.class --- .../common/runtime/vm/IsSRCandidateTest.java | 2 +- .../common/runtime/vm/VMContractTestBase.java | 2 +- .../src/test/resources/config-test-index.conf | 2 +- .../resources/config-test-storagetest.conf | 32 +++++++++---------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/framework/src/test/java/org/tron/common/runtime/vm/IsSRCandidateTest.java b/framework/src/test/java/org/tron/common/runtime/vm/IsSRCandidateTest.java index c4b58923a2..30726cbcc9 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/IsSRCandidateTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/IsSRCandidateTest.java @@ -152,7 +152,7 @@ public void testIsSRCandidate() // Trigger contract method: isSRCandidateTest(address) String methodByAddr = "isSRCandidateTest(address)"; String nonexistentAccount = "TWyoFfJBiKGkVQd28HTqxsc8kbMtQUmqgi"; - byte[] nonexistentAddr = Hex.decode("A0E6773BBF60F97D22AA3BF73D2FE235E816A1964F"); + byte[] nonexistentAddr = Hex.decode("41E6773BBF60F97D22AA3BF73D2FE235E816A1964F"); String hexInput = AbiUtil.parseMethod(methodByAddr, Collections.singletonList(nonexistentAccount)); diff --git a/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java b/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java index 0a1e53ab96..cf9dfe2199 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/VMContractTestBase.java @@ -47,7 +47,7 @@ public class VMContractTestBase { static { // TDmHUBuko2qhcKBCGGafu928hMRj1tX2RW (test.config) - WITNESS_SR1_ADDRESS = "a0" + "299F3DB80A24B20A254B89CE639D59132F157F13"; + WITNESS_SR1_ADDRESS = "41" + "299F3DB80A24B20A254B89CE639D59132F157F13"; } @Before diff --git a/framework/src/test/resources/config-test-index.conf b/framework/src/test/resources/config-test-index.conf index 4a60e7a499..b41fdfe850 100644 --- a/framework/src/test/resources/config-test-index.conf +++ b/framework/src/test/resources/config-test-index.conf @@ -153,7 +153,7 @@ genesis.block = { { accountName = "Blackhole" accountType = "AssetIssue" - address = "27WtBq2KoSy5v8VnVZBZHHJcDuWNiSgjbE3" + address = "THmtHi1Rzq4gSKYGEKv1DPkV7au6xU1AUB" balance = "-9223372036854775808" } ] diff --git a/framework/src/test/resources/config-test-storagetest.conf b/framework/src/test/resources/config-test-storagetest.conf index 59edf683c0..39da9109cb 100644 --- a/framework/src/test/resources/config-test-storagetest.conf +++ b/framework/src/test/resources/config-test-storagetest.conf @@ -165,88 +165,88 @@ genesis.block = { # { # accountName = "tron" # accountType = "AssetIssue" # Normal/AssetIssue/Contract - # address = "27V2x39zmmJeVGBGSheAk1281z8svbWgn6C" + # address = "TFveVqgQKAdFa12DNnXTw7GHCDQK7fUVen" # balance = "10" # } { accountName = "Devaccount" accountType = "AssetIssue" - address = "27d3byPxZXKQWfXX7sJvemJJuv5M65F3vjS" + address = "TPwJS5eC5BPGyMGtYTHNhPTB89sUWjDSSu" balance = "10000000000000000" }, { accountName = "Zion" accountType = "AssetIssue" - address = "27fXgQ46DcjEsZ444tjZPKULcxiUfDrDjqj" + address = "TSRNrjmrAbDdrsoqZsv7FZUtAo13fwoCzv" balance = "15000000000000000" }, { accountName = "Sun" accountType = "AssetIssue" - address = "27SWXcHuQgFf9uv49FknBBBYBaH3DUk4JPx" + address = "TDQE4yb3E7dvDjouvu8u7GgSnMZbxAEumV" balance = "10000000000000000" }, { accountName = "Blackhole" accountType = "AssetIssue" - address = "27WtBq2KoSy5v8VnVZBZHHJcDuWNiSgjbE3" + address = "THmtHi1Rzq4gSKYGEKv1DPkV7au6xU1AUB" balance = "-9223372036854775808" } ] witnesses = [ { - address: 27Ssb1WE8FArwJVRRb8Dwy3ssVGuLY8L3S1 + address: TDmHUBuko2qhcKBCGGafu928hMRj1tX2RW url = "http://Mercury.org", voteCount = 105 }, { - address: 27anh4TDZJGYpsn4BjXzb7uEArNALxwiZZW + address: TMgPX8uBr8XbBboxQgMK3zNS4SgjUa3eiP url = "http://Venus.org", voteCount = 104 }, { - address: 27Wkfa5iEJtsKAKdDzSmF1b2gDm5s49kvdZ + address: THeN2mPrrkr5U9Nzfb7xwgAwRqcFWcL7pR url = "http://Earth.org", voteCount = 103 }, { - address: 27bqKYX9Bgv7dgTY7xBw5SUHZ8EGaPSikjx + address: TNj21CppEn6PzHHtdLHoNZRpLJnxogNnAX url = "http://Mars.org", voteCount = 102 }, { - address: 27fASUY6qKtsaAEPz6QxhZac2KYVz2ZRTXW + address: TS48wDnTskrLU49kmZKRVfkHXd2NQ3dZP4 url = "http://Jupiter.org", voteCount = 101 }, { - address: 27Q3RSbiqm59VXcF8shQWHKbyztfso5FwvP + address: TAw7uHQUJw8FqRzuYqmEDQkFCyCGE4JcsW url = "http://Saturn.org", voteCount = 100 }, { - address: 27YkUVSuvCK3K84DbnFnxYUxozpi793PTqZ + address: TKeAx8bYkB25RsyNTQ9gUa75CuEVfFbF6N url = "http://Uranus.org", voteCount = 99 }, { - address: 27kdTBTDJ16hK3Xqr8PpCuQJmje1b94CDJU + address: TXX9e8tvYxg5MMbcoYAvqVT2wiXyacjs65 url = "http://Neptune.org", voteCount = 98 }, { - address: 27mw9UpRy7inTMQ5kUzsdTc2QZ6KvtCX4uB + address: TYpqwW7bfamDfDqXA9EMPhAfmArKMicxp9 url = "http://Pluto.org", voteCount = 97 }, { - address: 27QzC4PeQZJ2kFMUXiCo4S8dx3VWN5U9xcg + address: TBstX5L37A1WZBEJPM9nNDnDFa2kcTVSmc url = "http://Altair.org", voteCount = 96 }, { - address: 27VZHn9PFZwNh7o2EporxmLkpe157iWZVkh + address: TGSzEq4t7oMTRcn1VxDghRu5r5bWAE5D1W url = "http://AlphaLyrae.org", voteCount = 95 } From 808fa997cd3c99a2225600acf552f706adbdc476 Mon Sep 17 00:00:00 2001 From: vividcoder Date: Mon, 2 Mar 2026 17:35:25 +0800 Subject: [PATCH 7/8] style: fix checkstyle line length warnings in Args.java --- .../src/main/java/org/tron/core/config/args/Args.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/org/tron/core/config/args/Args.java b/framework/src/main/java/org/tron/core/config/args/Args.java index b4cbc316e1..38f1fe4f95 100644 --- a/framework/src/main/java/org/tron/core/config/args/Args.java +++ b/framework/src/main/java/org/tron/core/config/args/Args.java @@ -879,8 +879,9 @@ public static void setParam(final Config config) { PARAMETER.inactiveThreshold = 1; } - PARAMETER.maxTransactionPendingSize = config.hasPath(ConfigKey.NODE_MAX_TRANSACTION_PENDING_SIZE) - ? config.getInt(ConfigKey.NODE_MAX_TRANSACTION_PENDING_SIZE) : 2000; + PARAMETER.maxTransactionPendingSize = + config.hasPath(ConfigKey.NODE_MAX_TRANSACTION_PENDING_SIZE) + ? config.getInt(ConfigKey.NODE_MAX_TRANSACTION_PENDING_SIZE) : 2000; PARAMETER.pendingTransactionTimeout = config.hasPath(ConfigKey.NODE_PENDING_TRANSACTION_TIMEOUT) ? config.getLong(ConfigKey.NODE_PENDING_TRANSACTION_TIMEOUT) : 60_000; @@ -1113,8 +1114,9 @@ public static void setParam(final Config config) { PARAMETER.metricsReportInterval = config.hasPath(ConfigKey.METRICS_REPORT_INTERVAL) ? config .getInt(ConfigKey.METRICS_REPORT_INTERVAL) : 10; - PARAMETER.metricsPrometheusEnable = config.hasPath(ConfigKey.METRICS_PROMETHEUS_ENABLE) && config - .getBoolean(ConfigKey.METRICS_PROMETHEUS_ENABLE); + PARAMETER.metricsPrometheusEnable = + config.hasPath(ConfigKey.METRICS_PROMETHEUS_ENABLE) + && config.getBoolean(ConfigKey.METRICS_PROMETHEUS_ENABLE); PARAMETER.metricsPrometheusPort = config.hasPath(ConfigKey.METRICS_PROMETHEUS_PORT) ? config .getInt(ConfigKey.METRICS_PROMETHEUS_PORT) : 9527; PARAMETER.setOpenHistoryQueryWhenLiteFN( From 037be811614b192dfb62ab948628361c972e9c15 Mon Sep 17 00:00:00 2001 From: vividcoder Date: Mon, 2 Mar 2026 23:20:57 +0800 Subject: [PATCH 8/8] test: add FreezeTest.sol and bytecode comments Reverse-engineered the Solidity source from CONTRACT_CODE and FACTORY_CODE bytecode in FreezeTest.java. Added selector and opcode comments above each bytecode constant. Also removed accidental blank lines in pr-check.yml. --- .github/workflows/pr-check.yml | 2 - .../tron/common/runtime/vm/FreezeTest.java | 13 +++ .../org/tron/common/runtime/vm/FreezeTest.sol | 87 +++++++++++++++++++ 3 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.sol diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 094b0c314d..f4593f64d4 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -41,9 +41,7 @@ jobs: } // 2. Conventional format check - const conventionalRegex = /^(feat|fix|refactor|docs|style|test|chore|ci|perf|build|revert)(\([^)]+\))?:\s\S.*/; - if (title && !conventionalRegex.test(title)) { errors.push( 'PR title must follow conventional format: `type(scope): description`\n' + diff --git a/framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.java b/framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.java index 11908dde78..9aa7de7aab 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.java @@ -51,6 +51,12 @@ @Slf4j public class FreezeTest { + // Compiled from FreezeTest.sol (tron-solc ^0.5.16). + // FreezeContract — inner contract with TRON freeze/unfreeze opcodes: + // destroy(address) [0x00f55d9d] selfdestruct + // freeze(address,uint256,uint256) [0x30e1e4e5] opcode 0xd5 FREEZE + // unfreeze(address,uint256) [0x7b46b80b] opcode 0xd6 UNFREEZE + // getExpireTime(address,uint256) [0xe7aa4e0b] opcode 0xd7 FREEZEEXPIRETIME private static final String CONTRACT_CODE = "608060405261037e806100136000396000f3fe6080604052" + "34801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506004361061" + "00655760003560e01c8062f55d9d1461006a57806330e1e4e5146100ae5780637b46b80b1461011a578063e7" @@ -73,6 +79,13 @@ public class FreezeTest { + "506001905092915050565b60008273ffffffffffffffffffffffffffffffffffffffff1682d7905092915050" + "56fea26474726f6e58200fd975eab4a8c8afe73bf3841efe4da7832d5a0d09f07115bb695c7260ea64216473" + "6f6c63430005100031"; + // Compiled from FreezeTest.sol (tron-solc ^0.5.16). + // Factory — deploys FreezeContract and predicts CREATE2 addresses: + // deployCreate2Contract(uint256) [0x41aa9014] CREATE deploy + // getCreate2Addr(uint256) [0xbb63e785] CREATE2 address prediction + // Note: getCreate2Addr uses bytes1(0x41) as the TRON mainnet prefix + // in keccak256(abi.encodePacked(0x41, address(this), salt, codeHash)). + // This value is hardcoded at compile time by tron-solc. private static final String FACTORY_CODE = "6080604052610640806100136000396000f3fe60806040523" + "4801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b5060043610610" + "0505760003560e01c806341aa901414610055578063bb63e785146100c3575b600080fd5b610081600480360" diff --git a/framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.sol b/framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.sol new file mode 100644 index 0000000000..a4265e2563 --- /dev/null +++ b/framework/src/test/java/org/tron/common/runtime/vm/FreezeTest.sol @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: UNLICENSED +// Reconstructed from FACTORY_CODE bytecode in FreezeTest.java +// Compiler: tron-solc ^0.5.16 +// +// FACTORY_CODE contains two nested contracts: +// Factory (outer) — deploys FreezeContract via CREATE / CREATE2 +// FreezeContract (inner) — freeze/unfreeze operations with TRON-specific opcodes + +pragma solidity ^0.5.16; + +// ============================================================ +// Inner contract — deployed by Factory via CREATE / CREATE2 +// ============================================================ +contract FreezeContract { + + // selector: 0x00f55d9d + function destroy(address payable target) external { + selfdestruct(target); + } + + // selector: 0x30e1e4e5 + // Freeze TRX for target, then return time remaining until expiry + function freeze(address payable target, uint256 amount, uint256 res) + external returns (uint256) + { + target.freeze(amount, res); // TRON opcode 0xd5 (FREEZE) + // STATICCALL to this.getExpireTime(target, res), then subtract + return block.timestamp + - address(this).getExpireTime(target, res); + } + + // selector: 0x7b46b80b + function unfreeze(address payable target, uint256 res) + external returns (uint256) + { + target.unfreeze(res); // TRON opcode 0xd6 (UNFREEZE) + return 1; + } + + // selector: 0xe7aa4e0b + function getExpireTime(address payable target, uint256 res) + external view returns (uint256) + { + return target.freezeExpireTime(res); // TRON opcode 0xd7 (FREEZEEXPIRETIME) + } +} + +// ============================================================ +// Factory contract — outer layer +// ============================================================ +contract Factory { + + // selector: 0x41aa9014 + // Deploy FreezeContract using CREATE (salt is unused, CREATE ignores it) + function deployCreate2Contract(uint256 salt) public returns (address) { + bytes memory bytecode = type(FreezeContract).creationCode; + address addr; + assembly { + addr := create(0, add(bytecode, 0x20), mload(bytecode)) + } + require(extcodesize(addr) > 0); + return addr; + } + + // selector: 0xbb63e785 + // Predict CREATE2 address without deploying + // + // TRON CREATE2 formula (differs from standard EVM): + // address = keccak256(prefix ++ sender[20] ++ salt[32] ++ keccak256(code)[32])[12:] + // + // - Standard EVM uses 0xff as prefix (magic byte) + // - TRON replaces it with the address prefix byte (0x41 for mainnet, 0xa0 for testnet) + // - This value is hardcoded at compile time by tron-solc + // + function getCreate2Addr(uint256 salt) public view returns (address) { + bytes memory bytecode = type(FreezeContract).creationCode; + bytes32 hash = keccak256( + abi.encodePacked( + bytes1(0x41), // TRON mainnet address prefix + address(this), // 20-byte factory address + salt, // 32-byte salt + keccak256(bytecode) // 32-byte code hash + ) + ); + return address(uint160(uint256(hash))); + } +}