Skip to content

feat(simulate): Aptos chain family for cre workflow simulate#392

Open
Fletch153 wants to merge 5 commits intomainfrom
plex-2751
Open

feat(simulate): Aptos chain family for cre workflow simulate#392
Fletch153 wants to merge 5 commits intomainfrom
plex-2751

Conversation

@Fletch153
Copy link
Copy Markdown

Summary

Adds an Aptos chain type to cre workflow simulate, so workflows targeting aptos:ChainSelector:N@1.0.0 can run locally against a testnet RPC + a user-published mock forwarder. Paired with PLEX-2751 chainlink-aptos PR that ships the FakeAptosChain fake.

What's added

chain/aptos/ plugin — parallels chain/evm/:

  • chaintype.go — registers aptos; implements chain.ChainType (Name / SupportedChains / ResolveClients / ResolveKey / RegisterCapabilities / RunHealthCheck / ParseTriggerChainSelector / …). No trigger surface on Aptos.
  • capabilities.goAptosChainCapabilities wires FakeAptosChain per selector and registers with the capability registry.
  • limited_capabilities.goLimitedAptosChain enforces chain-write size + MaxGasAmount via caperrors.ResourceExhausted.
  • supported_chains.go — mainnet + testnet selectors.
  • health.goRunRPCHealthCheck probing GetChainId per client.

chain/evm/ refactor — extracts EVM-specific pieces out of simulate.go so the command delegates per-chain work through a chain-type registry. Trigger handling, registry, types, utils moved to chain/*; evm/trigger.go carries the manual-log-trigger glue.

Settings + limits

  • CRE_APTOS_PRIVATE_KEY plumbing (Ed25519 hex seed); sentinel seed allowed non-broadcast with ui.Warning; hard-fail under --broadcast for unparseable or sentinel key.
  • ChainWriteAptosMaxGasAmount in SimulationLimits.

Tests

  • go test ./cmd/workflow/simulate/chain/aptos/... -race — unit.
  • 30-scenario CLI e2e suite (simulator_scenarios_test.go).
  • test/aptos_cli_scenarios_test.go integration.
  • test_project/aptos_smoke/ example workflow for manual smoke.

Wires an Aptos chain type into `cre workflow simulate` so workflows
targeting `aptos:ChainSelector:N@1.0.0` can be exercised locally
against testnet RPCs + a user-published mock forwarder.

chain/aptos plugin:
- chaintype.go — registers `aptos` via chain.Register; implements
  ChainType (Name, SupportedChains, ResolveClients, ResolveKey,
  RegisterCapabilities, RunHealthCheck, ParseTriggerChainSelector,
  etc.). No trigger surface on Aptos.
- capabilities.go — AptosChainCapabilities wires FakeAptosChain per
  selector and registers with the capability registry.
- limited_capabilities.go — LimitedAptosChain enforces chain-write
  size + Aptos MaxGasAmount via caperrors.ResourceExhausted.
- supported_chains.go — mainnet + testnet selectors.
- health.go — RunRPCHealthCheck probes GetChainId per client.

chain/evm refactor: extracts the EVM-specific pieces out of simulate.go
so the simulate command delegates per-chain work through a chain-type
registry (EVM + Aptos siblings). Trigger handling, registry, types,
utils moved to chain/*. evm/trigger.go carries manual-log-trigger glue.

Settings + limits:
- CRE_APTOS_PRIVATE_KEY plumbing (Ed25519 hex seed); sentinel seed
  allowed non-broadcast with ui.Warning; hard-fail under --broadcast
  for unparseable or sentinel key.
- ChainWriteAptosMaxGasAmount in SimulationLimits.

Tests:
- Unit: chaintype / capabilities / limited / supported_chains / health.
- 30-scenario CLI end-to-end suite (simulator_scenarios_test.go).
- test/aptos_cli_scenarios_test.go integration.
- test_project/aptos_smoke/ example workflow for manual smoke.

PLEX-2751
@Fletch153 Fletch153 requested a review from a team as a code owner April 21, 2026 13:01
@github-actions
Copy link
Copy Markdown

👋 Fletch153, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

Broadens TestSimulatorScenarios_100 to cover the full behavioural
surface of the Aptos chain plugin + FakeAptosChain:

- 31-45: AptosChainType surface (Name, SupportedChains, HasSelector,
  ParseTriggerChainSelector, ExecuteTrigger/ResolveTriggerData stubs,
  ResolveKey hex/0x/uppercase/whitespace/short-seed rejections).
- 46-52: RegisterCapabilities rejects wrong client, key, and limits
  types; accepts unknown (experimental) selectors; skips selectors
  without forwarders; surfaces bad forwarder hex; interface assert.
- 53-62: View TypeTag coverage — BOOL, U8, U16, U32, U64, U128, U256,
  ADDRESS round-trips; SIGNER and VECTOR rejected.
- 63-72: read-path edges — all-zero/all-ones addresses, empty result,
  multi-return, integer return, SDK timeout, nil pagination, nil-entry
  drop, nil request validation.
- 73-82: WriteReport broadcast paths — SUCCESS, VM failure, nil pending,
  forwarder error, WaitForTransaction error, nil-final fallback,
  multi-sig, empty sigs, 64KiB report, zero gas accepted.
- 83-90: LimitedAptosChain — exact/over/under size and gas limits,
  zero-limit disables check, View/TransactionByHash delegation.
- 91-100: lifecycle + info — ChainSelector, Description, Info ID format,
  Name embedding, Initialise/Register/Unregister/Execute no-ops,
  HealthReport shape, AptosChainCapabilities Start/Close, constructor
  nil guards.

PLEX-2751
Drops the local `replace ../chainlink-aptos` directive (breaks CI
sibling-dir lookup) and pins chainlink-aptos to the PLEX-2751
feature-branch pseudo-version v0.0.0-20260421125752-47d9d126c005
so unit, tidy, gendoc, and e2e jobs can resolve the `fakes` import.

Will be re-pinned to the merged SHA once smartcontractkit/chainlink-aptos#442
lands on develop.

PLEX-2751
Broadens the e2e cre-binary suite (gated by CRE_APTOS_CLI_E2E=1) with
70 additional scenarios covering:

- 31-40: balance fan-out across address shapes (high bit, low bit,
  max_u256, fan-out lanes).
- 41-50: view coin::balance edges (all-zero, all-0x01, all-0xff,
  canonical aligned-byte addresses).
- 51-60: tx-by-hash randomised nonexistent hashes (routing proof).
- 61-70: account-transactions fan-out.
- 71-80: wrong selector / experimental-chain rejection (EVM mainnet,
  Solana, 0, 1, max uint64, Aptos mainnet without wiring, experimental
  99999999 for each read op, baseline testnet selector unchanged).
- 81-90: UI + flag variations (--limits none/default, --help global and
  workflow simulate scoped, missing wasm/config error messages, invalid
  --trigger-index, empty CRE_TARGET env).
- 91-100: broadcast + key edge cases (--broadcast with sentinel /
  unparseable / short-hex keys — all must hard-fail with
  CRE_APTOS_PRIVATE_KEY in the error message, dry-run sentinel warning,
  dry-run with valid key success, follow-up routing regression cases).

Runner rewritten to handle three scenario shapes:
- standard simulator dry-run (config + args),
- help/no-config invocations (skip simulator markers),
- mustFail scenarios (process exit non-zero, expect substring in
  combined output).

Scenario padding widened to %03d to fit 100 cases.

PLEX-2751
- ResolveKey: split hex-decode vs length-mismatch errors; align wording
  with EVM's CRE_*_PRIVATE_KEY message.
- ParseTriggerChainSelector: strict prefix+suffix+ParseUint, rejects
  trailing garbage after @1.0.0.
- --broadcast flag help: chain-agnostic wording (no longer EVM-only).
- LimitsSummary: include Aptos gas limit alongside EVM; test updated.
- aptos_cli_scenarios_test: use t.TempDir() for per-subtest config
  paths instead of /tmp/apcfg_%03d.json.
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.

1 participant