fix(staking): network-aware, fail-open resource-code validation#943
Open
gummy789j wants to merge 2 commits into
Open
fix(staking): network-aware, fail-open resource-code validation#943gummy789j wants to merge 2 commits into
gummy789j wants to merge 2 commits into
Conversation
Align resource-code handling across REPL and standard CLI with the node's actuator behavior, per the discussion in #939: - freeze/unfreeze accept 2 (TRON_POWER) only when the chain parameter getAllowNewResourceModel is enabled; delegate/undelegate reject 2 unconditionally (BANDWIDTH/ENERGY only). - Fail-open: when chain params can't be fetched (offline/timeout), skip the client-side pre-check and defer to the node's validate() at broadcast; text mode warns on stderr, JSON/quiet stays silent. - Only query chain params when resource == 2 (0/1 short-circuit, no RPC). REPL previously had no resource-code range check (permissive pass-through); standard CLI hardcoded 0/1. Reuses the existing getChainParameters() plumbing. Docs updated for consistency. Refs: #939
c0e1966 to
1d3ff25
Compare
v1 freezeBalance/unfreezeBalance with a receiver is a delegated freeze, where TRON_POWER is not delegatable. Both the standard CLI and the REPL previously passed freezeContext=true unconditionally, so resource=2 could be let through to the node when getAllowNewResourceModel was on. Derive the context from the receiver instead (freezeContext = receiver == null); v2 self-stake and delegate/undelegate paths are unchanged. Add StakingResourceGuardTest covering the tri-state getAllowNewResourceModel behavior (enabled / disabled / unknown fail-open), unconditional TRON_POWER rejection for delegation, and the receiver-aware v1 semantics. Docs: fix stale "1 CPU" to "1 ENERGY" and drop TRON_POWER from the delegate-resource section (not delegatable). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Align resource-code handling across REPL and standard CLI with the node's actuator behavior, per the discussion in #939:
REPL previously did no validation at all; standard CLI hardcoded 0/1. Reuses the existing getChainParameters() plumbing. Docs updated for consistency.