docs(examples): token-lab — TRC20 and TRC10 on a private chain - #217
Merged
Conversation
Two recipes that create a private chain, mint a token, drive transfers
through it with txgen, and assert the receivers hold exactly what was
sent. Roughly 7-16s each once the image is pulled.
They are the first real consumers of `recipe run --file` and `kind: host`,
and they exist mostly to carry four chain parameters that nothing else in
this repo documents:
vm.supportConstant read-only contract calls are refused
committee.allowTvmConstantinople
committee.allowTvmSolidity059
committee.allowTvmIstanbul the deploy returns contractRet: SUCCESS,
and then every call returns empty with no
energy used
committee.allowSameTokenName transferasset wants the token NAME, so
every tool sending the numeric id gets
"No asset!" as though nothing was issued
The shipped private template already sets allowCreationOfContracts = 1,
which is exactly what makes the TVM case confusing: deployment works,
execution does not, and it reads as a broken contract rather than a chain
missing its upgrades. All of these seed the dynamic property store at
genesis, so setting them on a running chain does nothing — the chain has
to be recreated. Between them they cost about two hours to find; the
README says so, with the getchainparameters query to check rather than
reason.
Compiled artifacts are committed so no solc is needed to run this. The
source is here too, with a note that recompiling needs evmVersion
istanbul: solc 0.8.20+ emits PUSH0, which java-tron's TVM does not
implement.
The two recipes differ in exactly two steps — mint and verify — because a
TRC20 balance sits behind a contract call while a TRC10 balance sits on
the account in assetV2. Adding a third token type is those two steps and
nothing else.
Not wired into CI: it needs Docker and node, e2e already runs two minutes,
and a flaky example is worse than none. Both recipes were run from their
committed paths immediately before this commit.
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.
Two recipes that create a private chain, mint a token, drive transfers through it with
txgen, and assert the receivers hold exactly what was sent.These are the first real consumers of
recipe run --file(#213) andkind: host(#214) — and writing them is what surfaced the two substitution bugs fixed in #216.What they actually carry
Not the token contract. Four chain parameters that nothing else in this repo documents, each of which makes a whole feature silently unusable:
vm.supportConstantcommittee.allowTvmConstantinoplecommittee.allowTvmSolidity059committee.allowTvmIstanbulcontractRet: SUCCESS, then every call returns empty with no energy usedcommittee.allowSameTokenNametransferassetwants the token name, so every tool sending the numeric id getsNo asset!— as though nothing was issuedThe shipped private template already sets
allowCreationOfContracts = 1, which is what makes the TVM case so confusing: deployment works, execution does not. It reads as a broken contract rather than a chain missing its upgrades.All of these seed the dynamic property store at genesis, so setting them on a running chain does nothing — the chain has to be recreated. Between them they cost about two hours to find. The README says so, with the
getchainparametersquery to check rather than reason.Choices
evmVersion istanbul— solc 0.8.20+ emitsPUSH0, which java-tron's TVM does not implement.tx_count × amount) rather than a literal. My first version hardcoded200000, which silently stops matching the moment someone changestx_count.How the two differ
Exactly two steps — mint and verify — because a TRC20 balance sits behind a contract call while a TRC10 balance sits on the account in
assetV2. Adding a third token type is those two steps and nothing else.Two encoding traps are documented for anyone writing their own scripts:
getaccountreturnsasset_issued_namehex-encoded butasset_issued_IDas a plain decimal string — hex-decoding the id yields bytes that still look like a value ("1000001"→0x10 0x00 0x00), so the mistake survives as plausible data instead of erroring. I made exactly that mistake.Verification
Both recipes were run from their committed paths immediately before this commit, not from the scratch directory they were developed in. That caught two things a copy would have hidden: a template still referencing its old filename, and a cleanup glob that had deleted both
.tmpl.jsonfiles.make test -race— 25 packages, 0 failures.