Skip to content

feature(tools): add transaction generate#180

Open
Sunny6889 wants to merge 6 commits into
tronprotocol:developfrom
Sunny6889:tranx_generate
Open

feature(tools): add transaction generate#180
Sunny6889 wants to merge 6 commits into
tronprotocol:developfrom
Sunny6889:tranx_generate

Conversation

@Sunny6889

Copy link
Copy Markdown

No description provided.

Little-Peony and others added 6 commits May 22, 2026 10:19
Pure-Go alternative to tron-docker/tools/stress_test. Three subcommands
(generate / broadcast / statistic) covering TRX, TRC10, and TRC20
transfers, with the broadcast report shape matched to upstream so
existing dashboards keep working. Receiver-address generation is
inlined into `generate` (no separate `collect` step); a sidecar
receivers.csv is dropped under outputDir for db-fork pre-funding.

Factored the /wallet/broadcasttransaction HTTP client out of
tools/replay/private.go into tools/common/broadcast so both tools
share the same code path.

Signing uses github.com/decred/dcrd/dcrec/secp256k1/v4 with low-S
canonical normalization; Keccak-256 + Base58Check live alongside in
tools/txgen/address.go. Makefile gains build-txgen / install-txgen
targets mirroring the replay ones.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- main.go: validate subcommand before context setup and run dispatch in
  a helper so deferred cancel() runs before exit (gocritic exitAfterDefer)
- node.go: drop dead transfer() selector/data (gocritic appendAssign)
- sign.go: replace deprecated secp256k1.S256() with the secp256k1 group
  order constant (staticcheck SA1019)
- gofmt: reformat broadcast.go, generate.go, node.go
- go.mod: bump golang.org/x/crypto v0.49.0 -> v0.52.0 (7 ssh CVEs)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds a PQ signing path to `generate`, modeled on java-tron's post-quantum
signature support. When `generate.pq.enabled` is set, transactions are
signed with ML-DSA-44 (FIPS 204) and carry a `pq_auth_sig` envelope
({scheme, public_key, signature}) instead of the ECDSA `signature`. The
signed digest is unchanged (txID = sha256(raw_data)), so broadcast and
statistic are untouched.

- pq.go: PQSigner over cloudflare/circl ML-DSA-44; deterministic
  seed->keypair (FIPS 204 KeyGen) matching java-tron's BouncyCastle
  FixedSecureRandom(seed); address = 0x41 ‖ Keccak-256(pubkey)[12..32].
- node.go: AttachPQSignature attaches the pq_auth_sig array.
- config.go: generate.pq {enabled, scheme, seed}; in PQ mode the sender is
  derived from the seed and privateKey is not required.
- generate.go: signFunc abstraction selects ECDSA vs PQ signing.
- pq_test.go: sign/verify round-trip, deterministic address, JSON attach.
- README: PQ section + schema rows; Falcon-512 explicitly unsupported
  (BouncyCastle/EIP-8052 encoding has no Go equivalent).

Account provisioning (registering the PQ key in the sender's permission)
is out of scope and left to the operator.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CI's setup-go (go-version "1.25", GOTOOLCHAIN=auto) resolves to the
runner-cached go1.25.10, and the previous `toolchain go1.25.9` directive
doesn't force an upgrade. go1.25.10 exposes two stdlib advisories
(GO-2026-5039 net/textproto, GO-2026-5037 crypto/x509) fixed in go1.25.11,
failing the vulnerability scan. Pin the toolchain to go1.25.11 so auto
resolution pulls the patched stdlib. The golangci-lint install step pins
GOTOOLCHAIN=go1.25.9 explicitly and is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Instead of signing every tx with the post-quantum scheme, `generate.pq.ratio`
(1-100, default 100) sets the percent of txs that are PQ-signed; the rest are
ECDSA-signed. The ratio is an independent roll from the txType contract split.

- generate.go: signerSet holds an ECDSA and a PQ signer (each with its own
  sender) and picks one per tx by the ratio. Both senders are logged.
- config.go: add pq.ratio (default 100); privateKey is now required whenever
  any tx is ECDSA-signed (PQ off, or pq.ratio < 100).
- generate_test.go: signerSet.pick, buildSigners (mixed / ratio-100), and
  pq.ratio validation/defaults.
- README: document mixed signing, the two-senders requirement, and pq.ratio.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants