Skip to content

Replace Long.valueOf with Long.parseLong - #15

Merged
sasaxie merged 1 commit into
tronprotocol:developfrom
khuezy:send-command-parse-long
Dec 29, 2017
Merged

sasaxie merged 1 commit into
tronprotocol:developfrom
khuezy:send-command-parse-long

Conversation

@khuezy

@khuezy khuezy commented Dec 28, 2017 •

Copy link
Copy Markdown
Contributor

What does this PR do?
Replaces function call to parse transaction amount from send parameters.

Why are these changes required?
To make code a little more efficient.

Long.valueOf calls parseLong and returns a new Long object.

 public static Long valueOf(String s) throws NumberFormatException {
   return new Long(parseLong(s, 10));
 }

A primitive long seems to be sufficient.

This PR has been tested by:

@sasaxie

sasaxie commented Dec 29, 2017

Copy link
Copy Markdown
Contributor

LGTM

@sasaxie
sasaxie merged commit 8224183 into tronprotocol:develop Dec 29, 2017
conglinduye pushed a commit that referenced this pull request Jan 5, 2018
zhaohong pushed a commit that referenced this pull request Feb 5, 2018
 Y7SS+OhvhTlhl711b0iLvzRPRM0NJn3+r/s/u5DZs0NSZM/QPZKJeOm9zli9tOWo
 7jBmYnswhXet8dH1tPYhIQRT35p33SuzGY6HUsCQhtolLzzBfXtasUs+2YRcAzBJ
 zJG3JgevB5Tgb9X1u3jKAiAp/hQ6zulO1wYUX9K0LsiCu8Q60emYDkMD301uLo9e
 WK8ffLmPxw6JA582/2GI0zUPxp51WgbAdWDc/+F7wVlPmY8uCR+2BRzciOiJ/GDT
 PCqyHXvZsln7ShK1ITjCZ/W8So4Gpy1N9s4og90CnI0jQtIInP5dI4nQ4NvAdgY=
 =ZNa0
 -----END PGP SIGNATURE-----
 

Merge pull request #15 from tron-network/feature/contract

Feature/contract
zhaohong pushed a commit that referenced this pull request Feb 5, 2018
 zJNi793OQQIrGC22hcPSO4FsOzwIRdKYFDFxRqzoQLK9fCM7LjcJZcxIWfVv3PYZ
 biwEagRf4VbmVwH5Fs+jheGw/9LgIPjeLkwY197l85gS6IcbIaib18BAu2TUu/Ug
 6P3XKkfqih17YLMCeNyrPq9OwkEI5jLB+uOQi/9Z1gb/7MpD5bQur1hqpdN+q6xo
 n4lSMEzP3R4/vDgQOTTut8jkcd5v8GmodXztBj2NOXwA+guek2co4p3b/OiQnoVV
 S5aLdVNv0lgs+aUHDnz0GLKCEfBaWfTp2F2B7Y9JbtG2enEyiZqDMxVlDsKgjjM=
 =ssm+
 -----END PGP SIGNATURE-----
 

Merge pull request #15 from khuezy/send-command-parse-long

:zap:perf: Replace Long.valueOf with Long.parseLong
@ybhgenius

Copy link
Copy Markdown
Contributor

Hello, I am a crew member of TRON, and now we are planning to provide an incentive for your contribution. Please leave me your email address. Thanks.

@khuezy

khuezy commented Mar 15, 2018

Copy link
Copy Markdown
Contributor Author

@ybhgenius Hi, my email is: khuelude@gmail.com

CodeNinjaEvan added a commit that referenced this pull request Mar 21, 2018
317787106 referenced this pull request in 0xbigapple/java-tron Mar 14, 2026
Little-Peony added a commit to Little-Peony/java-tron that referenced this pull request Jun 24, 2026
parent e23a628
author GrapeS <jiaoqingsunny@gmail.com> 1782274110 +0800
committer GrapeS <jiaoqingsunny@gmail.com> 1782274110 +0800

feat(proposal): add VERSION_4_8_2_PQ1 and gate PQC proposals on it

fix test checkstyle

reverse changes

reverse

reverse

delete comments, remove unused code

fix(vm): relocate pqc precompiles to 0x02000016-0x0200001a to avoid address conflicts

fix(chainbase): render pq_auth_sig safely in TransactionCapsule.toString

getBase64FromByteString parses bytes as an ECDSA r/s/v signature, so calling it
on a pq_auth_sig threw and crashed toString() for any PQ-signed transaction. The
i.get() gating also dropped the PQ output when an ECDSA signature was present and
only ever printed the first entry.

Print every pq_auth_sig at the transaction level and hex-encode the raw bytes.
Add toString format regression tests (PQ-only and hybrid ECDSA+PQ).

revers feberico change

add more test

fix format

refactor

fix(net): bound inbound HelloMessage size and pq_auth_sig fields

valid() capped legacy fields at 200B but left pq_auth_sig unbounded, so
an inbound hello was limited only by the 5MB frame. Per-field bounds are
not enough: raw bytes can still bloat via repeated pq_auth_sig (parser
merges), top-level unknown fields, or unbounded `from` sub-fields.

- Add MAX_HELLO_MESSAGE_SIZE (16KB); reject oversized hellos in
  TronMessageFactory before the body copy, and defensively in the
  HelloMessage constructors and valid() (-> BAD_MESSAGE/BAD_PROTOCOL).
- valid(): reject nested unknown fields in pq_auth_sig; bound
  public_key/signature to the scheme's max (global max for unknown).
- Add PQSchemeRegistry.getMaxPublicKeyLength()/getMaxSignatureLength().
- Tests for nested unknown field and the three raw-size bypasses.

fix(net): bound pq_auth_sig at the transaction entry points

The hello path bounded pq_auth_sig, but RPC broadcast and P2P tx ingress
length-checked only legacy ECDSA signatures, leaving pq_auth_sig
unguarded. Bounding public_key/signature alone is insufficient: PQAuthSig
retains/re-serializes unknown fields, so a large nested unknown field
passes while both known fields stay within bounds.

- Add shared PQAuthSigValidator.isLengthWithinBounds(): bounds
  public_key/signature to the scheme's max (global max for unknown
  schemes) and rejects nested unknown fields.
- Wire it into Wallet.broadcastTransaction() (SIGERROR) and
  TransactionsMsgHandler.check() (BAD_TRX); refactor HelloMessage.valid()
  to reuse it instead of its inline checks.
- Tests for the validator and both transaction ingress points.

# This is the commit message tronprotocol#15:

fix(pq): enforce pq_auth_sig field/count bounds uniformly across ingress and consensus

Harden post-quantum auth-signature validation so the same rules hold at every
layer (relay/RPC ingress and the consensus verify paths), closing asymmetries
an attacker could otherwise exploit.

- Extract hasNoUnknownFields() in PQAuthSigValidator as the single primitive
  enforcing PQAuthSig's fixed field set (scheme/public_key/signature);
  isLengthWithinBounds now delegates to it. A generated PQAuthSig retains and
  re-serializes unknown fields, so bounding only the known fields would let a
  caller smuggle a large length-delimited unknown field.
- Reject nested unknown fields on the consensus paths too, not just the ingress
  gates: TransactionCapsule#validatePQSignatureGetWeight and
  BlockCapsule#validatePQSignature, so a block-included tx is held to the same
  rule as a relayed/RPC one.
- Add a per-permission pq_auth_sig count gate in TransactionCapsule, mirroring
  legacy ECDSA checkWeight: each signature must map to a distinct permission
  key, so more entries than keys can never meet the threshold.
- Add an admission count cap (legacy + pq entries vs totalSignNum) at the
  ingress gates (Wallet#broadcastTransaction, TransactionsMsgHandler), rejecting
  a flood before the per-entry length loops. This also bounds empty/default pq
  entries, which would otherwise pass the per-entry size gate.

Tests: cover unknown-field rejection on the validator, tx and block paths; the
pq_auth_sig count-vs-key-count gate; and the totalSignNum admission cap on both
ingress gates.

# This is the commit message tronprotocol#17:

refactor(pq): tidy pq_auth_sig validation helpers and admission gates

No behavior change — readability cleanup on top of the pq_auth_sig
field/count-bound hardening.

- Rename PQAuthSigValidator.hasNoUnknownFields -> hasUnknownFields and
  invert its callers (TransactionCapsule, BlockCapsule, isLengthWithinBounds),
  so the predicate reads positively.
- Collapse the two-level admission-cap if into a single short-circuited
  condition at both ingress gates (Wallet#broadcastTransaction,
  TransactionsMsgHandler#check); totalSignNum is still skipped when the tx
  carries no signatures.
- Rewrite PQSchemeRegistry.getMax{PublicKey,Signature}Length with a stream
  and trim their javadoc.
- Update PQAuthSigValidatorTest for the renamed predicate.

# This is the commit message tronprotocol#18:

simplify comments

# This is the commit message tronprotocol#19:

Remove the `> 0` check and always read `totalSignNum`; for unregistered schemes, `isLengthWithinBounds` always returns `false`.

# This is the commit message tronprotocol#20:

refactor(pq): drop redundant hello size re-check and clarify count-limit messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants