Skip to content

Conversation

@rahxephon89
Copy link
Contributor

@rahxephon89 rahxephon89 commented Nov 14, 2025

Description

This PR:

  1. adds new attributes for struct apis;
  2. introduces bytecode version 10 (which introduces base line changes in this PR);
  3. adds new logic in the bytecode verifier to special case the borrow field mut API to avoid bytecode verification error;
  4. adds new logic in the runtime reference check to special case the borrow field mut API to avoid invariant violation error generated by the check.

TODO: adds wellformedness check for struct apis to bytecode verifier;

close #18199

How Has This Been Tested?

update of existing test cases for struct APIs.

Key Areas to Review

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)

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

Note

High Risk
Touches Move bytecode format (new function-attribute encodings + version gating) and alters reference-safety verification behavior for mutable borrow-field wrappers, which are correctness- and safety-critical paths.

Overview
Adds new FunctionAttribute variants (pack/unpack/test_variant plus variant- and field-offset forms, including BorrowField*) and extends bytecode serialization/deserialization to encode/decode them, gated to VERSION_10 with clearer malformed/version error messages.

Updates compiler v2 bytecode generation to attach these attributes to generated struct/enum API wrappers and adjusts compatibility checks to treat these attributes as non-removable.

Modifies reference-safety verification to special-case calls to functions marked BorrowFieldMutable (treating them as direct field-borrow effects) and updates/extends serializer tests and .exp fixtures to reflect the new attributes and the now-successful cross-module borrow-field scenario.

Written by Cursor Bugbot for commit 6bc992e. This will update automatically on new commits. Configure here.

Copy link
Contributor Author

rahxephon89 commented Nov 14, 2025

@rahxephon89 rahxephon89 changed the title add attributes for struct api [WIP][compiler] add attributes for struct api Nov 14, 2025
@rahxephon89 rahxephon89 changed the title [WIP][compiler] add attributes for struct api [WIP][compiler] add visibility modifier to structs/enums: step 3 Nov 14, 2025
@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch from 7f7d90f to eac9a1d Compare November 14, 2025 22:42
@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch from eac9a1d to b720555 Compare November 15, 2025 01:03
@rahxephon89 rahxephon89 force-pushed the teng/file-format-gen branch 2 times, most recently from 6eb2d64 to e1a1542 Compare November 15, 2025 04:00
@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch 3 times, most recently from f96cb3a to ca5c372 Compare November 15, 2025 09:18
@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch from ca5c372 to 44b76a4 Compare November 15, 2025 11:30
@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch 2 times, most recently from 0c3accf to caa8cd8 Compare November 16, 2025 17:45
@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch 4 times, most recently from 2de180d to b0ec601 Compare November 17, 2025 09:43
@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch from b0ec601 to d20a6b1 Compare November 17, 2025 18:05
@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch 2 times, most recently from e040fa8 to d554746 Compare November 18, 2025 07:59
@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch from d554746 to bc41710 Compare November 18, 2025 09:08
@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch from b855709 to 394fb58 Compare February 10, 2026 23:52
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

return Ok(true);
}
}
Ok(false)
Copy link

Choose a reason for hiding this comment

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

Reference safety bypass lacks wellformedness validation for attributes

Medium Severity

handle_borrow_field_mutable bypasses the normal call reference safety analysis (which checks CALL_BORROWED_MUTABLE_REFERENCE_ERROR) based solely on the presence of a BorrowFieldMutable attribute, without any bytecode verifier pass validating that the attribute is correctly placed. A crafted module could attach BorrowFieldMutable to an arbitrary function to bypass mutable reference safety checks, potentially enabling aliased mutable references. The TODO for the wellformedness check needs to land before or atomically with this change.

Additional Locations (1)

Fix in Cursor Fix in Web

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch from 394fb58 to 80b711e Compare February 11, 2026 09:18
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch from 80b711e to b5ecc41 Compare February 11, 2026 22:52
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@rahxephon89 rahxephon89 force-pushed the teng/struct-api-attributes branch from b5ecc41 to 6bc992e Compare February 12, 2026 09:18
@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
Contributor

✅ Forge suite compat success on 3d74b598d151879ab419e0c4377370b39b5c491f ==> 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a

Compatibility test results for 3d74b598d151879ab419e0c4377370b39b5c491f ==> 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a (PR)
1. Check liveness of validators at old version: 3d74b598d151879ab419e0c4377370b39b5c491f
compatibility::simple-validator-upgrade::liveness-check : committed: 13580.34 txn/s, latency: 2558.70 ms, (p50: 2700 ms, p70: 2800, p90: 3300 ms, p99: 3700 ms), latency samples: 444940
2. Upgrading first Validator to new version: 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 5840.32 txn/s, latency: 5805.07 ms, (p50: 6500 ms, p70: 6600, p90: 6700 ms, p99: 6800 ms), latency samples: 201620
3. Upgrading rest of first batch to new version: 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 5952.57 txn/s, latency: 5724.68 ms, (p50: 6200 ms, p70: 6400, p90: 6500 ms, p99: 6700 ms), latency samples: 204680
4. upgrading second batch to new version: 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 9932.80 txn/s, latency: 3273.73 ms, (p50: 3300 ms, p70: 3700, p90: 4600 ms, p99: 4900 ms), latency samples: 329860
5. check swarm health
Compatibility test for 3d74b598d151879ab419e0c4377370b39b5c491f ==> 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a passed
Test Ok

@github-actions
Copy link
Contributor

✅ Forge suite realistic_env_max_load success on 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a

two traffics test: inner traffic : committed: 13715.70 txn/s, submitted: 13716.02 txn/s, expired: 0.32 txn/s, latency: 2745.88 ms, (p50: 2700 ms, p70: 2900, p90: 3000 ms, p99: 3600 ms), latency samples: 5103340
two traffics test : committed: 100.01 txn/s, latency: 786.24 ms, (p50: 700 ms, p70: 800, p90: 900 ms, p99: 1200 ms), latency samples: 1660
Latency breakdown for phase 0: ["MempoolToBlockCreation: max: 2.190, avg: 2.121", "ConsensusProposalToOrdered: max: 0.168, avg: 0.165", "ConsensusOrderedToCommit: max: 0.071, avg: 0.069", "ConsensusProposalToCommit: max: 0.239, avg: 0.234"]
Max non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.46s no progress at version 4860018 (avg 0.07s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.49s no progress at version 2430142 (avg 0.49s) [limit 16].
Test Ok

@github-actions
Copy link
Contributor

✅ Forge suite framework_upgrade success on 3d74b598d151879ab419e0c4377370b39b5c491f ==> 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a

Compatibility test results for 3d74b598d151879ab419e0c4377370b39b5c491f ==> 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a (PR)
Upgrade the nodes to version: 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 2517.16 txn/s, submitted: 2525.79 txn/s, failed submission: 8.63 txn/s, expired: 8.63 txn/s, latency: 1155.76 ms, (p50: 1200 ms, p70: 1200, p90: 1500 ms, p99: 2100 ms), latency samples: 227622
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 2344.35 txn/s, submitted: 2350.03 txn/s, failed submission: 5.68 txn/s, expired: 5.68 txn/s, latency: 1242.96 ms, (p50: 1200 ms, p70: 1400, p90: 1600 ms, p99: 1900 ms), latency samples: 214680
5. check swarm health
Compatibility test for 3d74b598d151879ab419e0c4377370b39b5c491f ==> 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a passed
Upgrade the remaining nodes to version: 6bc992ebef67d83e6d9c5cbcc21f93005d13c16a
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1515.56 txn/s, submitted: 1520.19 txn/s, failed submission: 4.63 txn/s, expired: 4.63 txn/s, latency: 1945.00 ms, (p50: 1200 ms, p70: 1500, p90: 2100 ms, p99: 11800 ms), latency samples: 137342
Test Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD:run-e2e-tests when this label is present github actions will run all land-blocking e2e tests from the PR CICD:run-framework-upgrade-test stale-exempt Prevents issues from being automatically marked and closed as stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] tracking CALL_BORROWED_MUTABLE_REFERENCE_ERROR for public APIs

5 participants