Repository navigation
fix(examples): run every example as shipped against Devnet, and run them daily in CI - #39
Merged
Merged
Conversation
…ithout CoinStore Nodes whose genesis enables the fungible-asset migration keep SUPRA in primary fungible stores: accounts have no CoinStore<SupraCoin>, transfers emit 0x1::fungible_asset::Deposit and Withdraw, and account_coin_transactions lists no SUPRA movement. The coin-transaction and events-by-type tests now pick their expectations by whether the account holds the CoinStore. The automation registration in the tests and in examples/automation.py used a gas price cap of 100, below the node's minimum gas price, which the node refuses at validation. The cap now comes from estimate_gas_price()'s min_configured_gas_price. The cancel and stop tests expect the V2 events the framework emits. The example no longer suggests passing a task type and priority together, and treats task index 0 as valid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he automation example The type of a SUPRA deposit event follows the receiver's layout (CoinStore or primary fungible store), not the sender's. The coin-transaction and events-by-type tests now choose it from the receiver. Where the receiver uses a primary fungible store, the test checks that the Deposit event's store is the receiver's primary store (from the primary_store_address view) and that its amount is the transferred amount, and that an empty coin-transaction listing carries no cursor. The event extraction helper is shared by the tests. examples/automation.py takes its gas price cap from the recent median price, bounded by the node's minimum and maximum, because a task is skipped in blocks priced above its cap. The comment on task type and priority states which combinations the registry accepts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The examples read the RPC node from SUPRA_RPC_NODE_URL (default Devnet, https://rpc-devnet.supra.com) and the faucet node from SUPRA_FAUCET_URL (default the RPC node). `common.fund_accounts` funds the accounts an example generates: by transfers from the account of SUPRA_EXAMPLES_PRIVATE_KEY when it is set, otherwise from one account funded by a single faucet request. No example except `faucet.py` calls the faucet more than once, and `faucet.py` makes one request. `fund_accounts` refuses Mainnet. The Move packages that `your_coin.py`, `multisig.py` and `hello_blockchain.py` publish are committed in compiled form in `examples/move/packages.json`, compiled for a placeholder address that `common.compiled_package` replaces with the publisher's. The examples no longer run `supra move tool compile` on a sibling aptos-core checkout. `hello_blockchain.py` publishes its package when no address is given. `aiofiles` is dropped: the examples read files with `pathlib`. The unreleased `examples` extra and the dev dependency are removed. Other changes: - `rotate_key.py` no longer prints part of each private key. - `simulate_transfer_coin.py` sets max gas, since the estimate's simulation fails while the receiver has no coin store. - `automation.py` registers a task of one hour, within the 7200-second cap of a localnet, sends the registration and the stop again while the registry reports a cycle transition, and uses the estimated max gas. - `main` functions are annotated, so that mypy checks their bodies, and mypy now checks `examples/` (`make typecheck` and CI). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`.github/workflows/examples.yaml` runs `make examples` against Devnet on a daily schedule and on `workflow_dispatch`, funding the examples' accounts from the repository secret SUPRA_EXAMPLES_PRIVATE_KEY. Without the secret the job runs no example and reports a notice. Runs share one concurrency group, so two runs never send from the account at once. `make examples` now runs all thirteen examples, including `faucet` and `hello_blockchain`, stops at the first failure, and refuses to run unless SUPRA_RPC_NODE_URL is set, so that the network it transacts on is explicit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The examples README lists the networks, the environment variables and how the examples fund their accounts, how to run one example or all of them, what each example shows, and how the compiled Move packages in `move/packages.json` were built. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… run every example in CI - The faucet request is sent at most five times, after pauses of 5, 10, 20 and 40 seconds, while the faucet answers "TryLater". The retry catches FaucetRequestNotAcceptedError and the AttributeError that SDK versions without "TryLater" handling raise for that answer. - Before funding, `fund_accounts` checks that the funding account holds the amount it sends plus 2,000 gas units per transfer at the node's minimum gas price, and otherwise stops with the shortfall in SUPRA. - A whitespace-only SUPRA_EXAMPLES_PRIVATE_KEY, SUPRA_RPC_NODE_URL or SUPRA_FAUCET_URL counts as unset. - `simulate_transfer_coin.py` asserts that the first simulation reports the ECOIN_STORE_NOT_PUBLISHED abort, and reads the simulation output with `.get`. - `make examples` runs every example, then fails and lists the failed ones if any failed. - The Devnet workflow installs with `uv sync --frozen` before the step that sees the key, and that step runs with UV_FROZEN=1. - uv.lock keeps lock revision 5 (written with uv 0.13.7). - The examples README names the public source tag aptosvm-v1.16_supra-v1.8.9, from which the compiled packages are byte-identical, states that the sources are Apache-2.0, and describes the faucet retry, the balance check and the sequence-number race between two runs that share a key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # examples/automation.py
…e examples workflow The faucet retry loop sends only the request (`wait_for_faucet=False`) and treats as TryLater a missing transaction hash, `FaucetRequestNotAcceptedError`, or the `AttributeError` that SDK versions without TryLater handling raise from the request. It sends at most five requests, with pauses of 5, 10, 20 and 40 seconds. After an accepted request it waits for the faucet transaction once, outside the retry, and fails if the transaction does not end in `Success`. `make examples` refuses a whitespace-only SUPRA_RPC_NODE_URL, which the examples treat as unset. The Examples workflow decides whether a funded key is present in a first step that receives the secret through `env`, strips whitespace and writes only `present=true|false`; a whitespace-only secret skips the job like a missing one. setup-uv installs uv 0.13.7, and the step that holds the key sets UV_NO_SYNC next to UV_FROZEN so nothing is resolved or installed while the key is present. The gas reserve comment states what the 2,000-unit reservation assumes, and examples/README.md states which examples retry TryLater. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
fungible_asset.py funds Alice with `fund_accounts`, so it uses the Devnet default, the optional funded key, the bounded TryLater retry and the Mainnet refusal. Bob is not funded; the fungible asset transfer creates his primary store. `make examples` runs it, and examples/README.md describes it and counts its 10 SUPRA. Co-Authored-By: Claude Sonnet 5.5 <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.
What
The examples now run as shipped:
faucet.pyfunds one account from the faucet, and retries aTryLateranswera bounded number of times. With a key, only
faucet.pycalls the faucet.aptos-corecheckout or Move toolchain.A scheduled workflow runs all of them against Devnet.
Changes
examples/common.py:SUPRA_RPC_NODE_URLdefaults tohttps://rpc-devnet.supra.com.SUPRA_FAUCET_URLdefaults to the RPC URL.SUPRA_EXAMPLES_PRIVATE_KEY(hex) is optional; an empty or whitespace-only value counts as unset.fund_accountswith a key funds each account by transfer from the key's account. It first checks that thebalance covers the amounts plus gas, and names the shortfall in SUPRA.
TryLateranswer is retried:at most 5 requests, with pauses of 5, 10, 20 and 40 s, failing after the fifth
TryLater. Only the request isretried; after the faucet accepts one, the example waits once for its transaction and fails unless it ends in
Success, so an accepted request is never repeated.Devnet today and the SDK's max gas estimate is 1.5 times that; the check is made before sending.
examples/move/packages.jsonholds the metadata and bytecode ofhello_blockchain,moon_coinandupgrade_and_govern(genesis and upgrade). They are compiled from the Apache-2.0 sources atEntropy-Foundation/aptos-coretagaptosvm-v1.16_supra-v1.8.9.compiled_packagereplaces the placeholder publisher address (32 random bytes, matched exactly) with thepublisher's address.
your_coin.py,multisig.pyandhello_blockchain.pypublish these instead of shelling out tosupra move tool compile.transfer_coin.pyfunds the second account by transfer rather than with a second faucet call.aiofilesis dropped:transfer_two_by_two.pyreads its script withpathlib.rotate_key.pyno longer prints part of the private key.simulate_transfer_coin.pysets an explicit max gas, so the estimate does not simulate a transfer that isexpected to fail. It asserts that the first simulation reports a
Failstatus whosevm_statusnamesECOIN_STORE_NOT_PUBLISHED, which is how rc7 and v11.7.2 nodes report the abort.fungible_asset.py(added by feat(client): add fungible asset balance, transfer, migration and transaction helpers #31) funds its account with the shared helper and runs inmake examples.automation.pyuses a 3600 s duration, because a v11.7.2 localnet caps task duration at 7200 s. It retriesregistration and stop on
ECYCLE_TRANSITION_IN_PROGRESS.mainis annotated, and mypy now coversexamples/.pyproject.tomlanduv.lock:aiofilesand the unreleasedexamplesextra are removed. The lock wasregenerated with uv 0.13.7, so its revision stays 5; the only change is
aiofiles.Makefile:make examplesrefuses to start whenSUPRA_RPC_NODE_URLis unset, empty or whitespace. It runsall 14 examples and fails at the end, listing the failed ones.
.github/workflows/examples.yaml:workflow_dispatchonly, so fork pull requests cannot start it.contents: read; concurrency groupexamples-devnet, so two runs never send from the same account at once.envand writes only whether it is present (whitespace counts asabsent). Without it the job skips with a notice.
uv sync --frozenruns before the secret is in the environment. The step withthe secret sets
UV_FROZEN=1andUV_NO_SYNC=1, so nothing is resolved, downloaded or installed while the keyis present.
checks.yaml.examples/README.md: networks, environment variables, funding andTryLater, how to run one or all examples,what each shows, and how
packages.jsonwas built.Maintainers: create the repository secret
SUPRA_EXAMPLES_PRIVATE_KEY, holding the hex Ed25519 private key of anaccount funded on Devnet. A full run moves about 325 SUPRA from it.
Checks
make fmt-check,make lint,make typecheck(44 files, examples included),make test-unit(332 tests, OK, 26node-backed skipped),
make test-spec(248 scenarios),make build: pass.actionlint: clean.masterand the review fixes:make examplespassed all 14 examples on a freshsupra_node_v12.0.0.rc7localnet without a key. A whitespace-onlySUPRA_RPC_NODE_URLmakesmake examplesrefuse(checked with
make -n).supra_node_v12.0.0.rc7localnet and on asupra_node_v11.7.2localnet, each withfaucet funding and with a funded key: 52 runs.
make examplespassed on rc7 without and with a key, and on v11.7.2without one. The output of the keyed runs does not contain the key.
packages.jsonis byte-identical to a fresh compile of the four packages from tagaptosvm-v1.16_supra-v1.8.9(and from the fork's later tags, whose sources are unchanged), compiled with the
supraCLI ofsupra_node_v11.7.2.🤖 Generated with Claude Code