Skip to content

[framework] Make Option public#20236

Merged
rahxephon89 merged 2 commits into
mainfrom
teng/make-option-public
Jul 21, 2026
Merged

[framework] Make Option public#20236
rahxephon89 merged 2 commits into
mainfrom
teng/make-option-public

Conversation

@rahxephon89

@rahxephon89 rahxephon89 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Description

Makes std::option::Option a public enum, using the struct/enum visibility feature introduced in Move 2.4.

Today, code outside std must go through the option::some() / option::none() / option::borrow() API. With this change, any module can use Option directly as an enum:

  • construct variants: Option::Some { e: x }, Option::None
  • test variants with is: o is Option::Some
  • pattern-match: match (o) { Option::Some { e } => ..., Option::None => ... }
  • select and mutate the variant field: o.e

aptos-move/framework/cached-packages/src/head.mrb is regenerated (via scripts/cargo_build_aptos_cached_packages.sh) so the released std::option bytecode carries the public visibility and the compiler-generated cross-module accessor functions.

How Has This Been Tested?

  • New e2e test test_public_option_cross_module (aptos-move/e2e-move-tests/src/tests/public_option.rs): publishes an inline Move package at 0xcafe (compiled with language version 2.4+) whose entry functions exercise, from outside std:
    • direct Some/None construction and equality with option::some() / option::none()
    • the is operator on both variants
    • match by value and by reference
    • variant field selection and mutation (s.e)
    • interop of directly-constructed options with the std::option API (is_some, extract, fill, is_none) over a user-defined struct element type
  • Regression: the existing public_struct_args suite (10 tests) passes against the regenerated head.mrb, confirming the special vector-based transaction-argument handling of Option is unaffected.

Key Areas to Review

  • One-way door: public visibility can never be narrowed on upgrade. This permanently freezes the variant names (Some, None) and the field name (e) as part of the public API surface of std::option.
  • head.mrb must ship together with the source change: cross-module enum operations compile into calls to accessor functions generated in the defining module, so the on-chain std::option bytecode must include them.

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

🤖 Generated with Claude Code


Note

Medium Risk
Public enum visibility is irreversible on upgrade and locks variant/field names as framework API; impact is limited to Move stdlib surface and new direct enum usage patterns.

Overview
Makes std::option::Option a public enum (Move 2.4+), so modules outside std can use Option directly instead of only the option::some() / none() helpers.

Callers can construct Option::Some { e } / Option::None, use is, match, and read or mutate the e field on Some. Cross-module field access on None still fails at runtime with STRUCT_VARIANT_MISMATCH (failure attributed to 0x1::option).

Adds e2e coverage test_public_option_cross_module that publishes a package at 0xcafe and exercises construction, matching, field access, std API interop, and the unhappy paths above.

Reviewed by Cursor Bugbot for commit f6b681a. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@rahxephon89
rahxephon89 force-pushed the teng/make-option-public branch from 2a2cbac to 4fba53e Compare July 17, 2026 17:43
@rahxephon89
rahxephon89 marked this pull request as ready for review July 17, 2026 17:45
@rahxephon89
rahxephon89 requested a review from a team as a code owner July 17, 2026 17:45
@rahxephon89
rahxephon89 force-pushed the teng/make-option-public branch from 4fba53e to b9af700 Compare July 17, 2026 19:21

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aptos Security Bugbot has reviewed your changes and found 1 potential issue(s).

Open in Web View Automation 

Sent by Cursor Automation: Security Review Bot

Comment thread aptos-move/framework/move-stdlib/sources/option.move
@rahxephon89
rahxephon89 force-pushed the teng/make-option-public branch from b9af700 to 2cb4ff9 Compare July 17, 2026 19:54

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aptos Security Bugbot has reviewed your changes and found no new issue.

Open in Web View Automation 

Sent by Cursor Automation: Security Review Bot

@rahxephon89
rahxephon89 force-pushed the teng/make-option-public branch from 2cb4ff9 to c254b68 Compare July 20, 2026 17:51

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aptos Security Bugbot has reviewed your changes and found no new issue.

Open in Web View Automation 

Sent by Cursor Automation: Security Review Bot

Comment thread aptos-move/framework/move-stdlib/sources/option.move
@rahxephon89
rahxephon89 enabled auto-merge (squash) July 21, 2026 14:03

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aptos Security Bugbot has reviewed your changes and found no new issue.

Open in Web View Automation 

Sent by Cursor Automation: Security Review Bot

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Forge suite compat success on d409a7017a5f270d45b4da5301fc2c689fcc363c ==> f6b681afe12ec13dea52c06ae8af9364e0471f0d

Compatibility test results for d409a7017a5f270d45b4da5301fc2c689fcc363c ==> f6b681afe12ec13dea52c06ae8af9364e0471f0d (PR)
1. Check liveness of validators at old version: d409a7017a5f270d45b4da5301fc2c689fcc363c
compatibility::simple-validator-upgrade::liveness-check : committed: 15281.31 txn/s, latency: 2213.48 ms, (p50: 2200 ms, p70: 2400, p90: 3000 ms, p99: 3600 ms), latency samples: 507160
2. Upgrading first Validator to new version: f6b681afe12ec13dea52c06ae8af9364e0471f0d
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 6088.73 txn/s, latency: 5527.93 ms, (p50: 6100 ms, p70: 6200, p90: 6300 ms, p99: 6500 ms), latency samples: 209220
3. Upgrading rest of first batch to new version: f6b681afe12ec13dea52c06ae8af9364e0471f0d
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 6144.59 txn/s, latency: 5500.35 ms, (p50: 6000 ms, p70: 6200, p90: 6300 ms, p99: 6500 ms), latency samples: 211580
4. upgrading second batch to new version: f6b681afe12ec13dea52c06ae8af9364e0471f0d
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 9952.72 txn/s, latency: 3389.50 ms, (p50: 3600 ms, p70: 3700, p90: 3800 ms, p99: 4000 ms), latency samples: 334000
5. check swarm health
Compatibility test for d409a7017a5f270d45b4da5301fc2c689fcc363c ==> f6b681afe12ec13dea52c06ae8af9364e0471f0d passed
Test Ok

@github-actions

Copy link
Copy Markdown
Contributor

✅ Forge suite realistic_env_max_load success on f6b681afe12ec13dea52c06ae8af9364e0471f0d

two traffics test: inner traffic : committed: 14279.35 txn/s, latency: 1255.78 ms, (p50: 1200 ms, p70: 1300, p90: 1500 ms, p99: 1900 ms), latency samples: 5333360
two traffics test : committed: 100.00 txn/s, latency: 711.18 ms, (p50: 600 ms, p70: 700, p90: 900 ms, p99: 1100 ms), latency samples: 1700
Latency breakdown for phase 0: ["MempoolToBlockCreation: max: 0.448, avg: 0.415", "ConsensusProposalToOrdered: max: 0.119, avg: 0.112", "ConsensusOrderedToCommit: max: 0.197, avg: 0.174", "ConsensusProposalToCommit: max: 0.306, avg: 0.285"]
Max non-epoch-change gap was: 1 rounds at version 1906718 (avg 0.00) [limit 4], 0.58s no progress at version 1906718 (avg 0.06s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.61s no progress at version 2345265 (avg 0.61s) [limit 16].
Test Ok

@github-actions

Copy link
Copy Markdown
Contributor

✅ Forge suite framework_upgrade success on d409a7017a5f270d45b4da5301fc2c689fcc363c ==> f6b681afe12ec13dea52c06ae8af9364e0471f0d

Compatibility test results for d409a7017a5f270d45b4da5301fc2c689fcc363c ==> f6b681afe12ec13dea52c06ae8af9364e0471f0d (PR)
Upgrade the nodes to version: f6b681afe12ec13dea52c06ae8af9364e0471f0d
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 2252.57 txn/s, submitted: 2259.20 txn/s, failed submission: 6.63 txn/s, expired: 6.63 txn/s, latency: 1273.15 ms, (p50: 1200 ms, p70: 1400, p90: 1800 ms, p99: 2500 ms), latency samples: 203861
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 2372.82 txn/s, submitted: 2378.75 txn/s, failed submission: 5.93 txn/s, expired: 5.93 txn/s, latency: 1223.99 ms, (p50: 1200 ms, p70: 1200, p90: 1800 ms, p99: 2400 ms), latency samples: 216221
5. check swarm health
Compatibility test for d409a7017a5f270d45b4da5301fc2c689fcc363c ==> f6b681afe12ec13dea52c06ae8af9364e0471f0d passed
Upgrade the remaining nodes to version: f6b681afe12ec13dea52c06ae8af9364e0471f0d
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 2386.06 txn/s, submitted: 2394.31 txn/s, failed submission: 8.25 txn/s, expired: 8.25 txn/s, latency: 1274.27 ms, (p50: 1100 ms, p70: 1200, p90: 1800 ms, p99: 10900 ms), latency samples: 214101
Test Ok

@rahxephon89
rahxephon89 merged commit 7f54b89 into main Jul 21, 2026
99 of 109 checks passed
@rahxephon89
rahxephon89 deleted the teng/make-option-public branch July 21, 2026 14:49
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.

4 participants