-
Notifications
You must be signed in to change notification settings - Fork 1
refactor(config): improve startup errors and remove inactive assertions #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,7 +75,6 @@ private static long convertVectorToLong(List<Boolean> v) throws ZksnarkException | |
| } | ||
|
|
||
| public byte[] encode() throws ZksnarkException { | ||
| assert (authenticationPath.size() == index.size()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The deleted assertion was the only enforcement of the invariant that Prompt for AI agents |
||
| List<List<Byte>> pathByteList = Lists.newArrayList(); | ||
| long indexLong; // 64 | ||
| for (int i = 0; i < authenticationPath.size(); i++) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1045,8 +1045,9 @@ private static void loadDnsPublishParameters(NodeConfig.DnsConfig dns, | |
| String serverType = dns.getServerType(); | ||
| if (StringUtils.isNotEmpty(serverType)) { | ||
| if (!"aws".equalsIgnoreCase(serverType) && !"aliyun".equalsIgnoreCase(serverType)) { | ||
| throw new IllegalArgumentException( | ||
| "Check node.dns.serverType, must be aws or aliyun"); | ||
| throw new TronError( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: TronError extends java.lang.Error, not Exception, so these three throw sites (serverType check, logEmptyError, and the CommitteeConfig postProcess change) change the failure type from a catchable RuntimeException (IllegalArgumentException) to an Error that only the ExitManager uncaught-handler can terminate on. For FullNode startup this is the intended design and exit code 1 is preserved. However, Args.loadDnsPublishConfig/loadDnsPublishParameters are public and documented as callable by tests and external code; any caller that previously wrapped DNS/config loading in catch (Exception) or catch (RuntimeException) for graceful fallback will silently lose that edge and let an Error escape (process exit). Verify no current or future caller relies on catching these failures as Exception. Prompt for AI agents |
||
| "Check node.dns.serverType, must be aws or aliyun", | ||
| TronError.ErrCode.PARAMETER_INIT); | ||
| } | ||
| if ("aws".equalsIgnoreCase(serverType)) { | ||
| publishConfig.setDnsType(DnsType.AwsRoute53); | ||
|
|
@@ -1088,7 +1089,8 @@ private static void loadDnsPublishParameters(NodeConfig.DnsConfig dns, | |
| } | ||
|
|
||
| private static void logEmptyError(String arg) { | ||
| throw new IllegalArgumentException(String.format("Check %s, must not be null or empty", arg)); | ||
| throw new TronError(String.format("Check %s, must not be null or empty", arg), | ||
| TronError.ErrCode.PARAMETER_INIT); | ||
| } | ||
|
|
||
| // createTriggerConfig removed — logic moved to applyEventConfig() | ||
|
|
@@ -1315,4 +1317,3 @@ private static Map<String, String[]> getOptionGroup() { | |
| return optionGroupMap; | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: This assertion is not inactive/historical code — it guards division by totalEnergyWeight on the very next lines. If totalEnergyWeight is 0, the hardened path throws a bare ArithmeticException and the non-hardened path silently yields an unbounded value from
(long)(... / 0.0)(Long.MAX_VALUE). The PR limits removal to dead asserts and retains critical ones; this one is live protection in a core resource method, so keeping it (or an explicit zero check) preserves the safety net rather than deleting it.Prompt for AI agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
该断言并非测试,一般不会运行到