Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[copybara] Sync recent changes from aptos-core #3

Open
wants to merge 230 commits into
base: main
Choose a base branch
from

Conversation

georgemitenkov
Copy link
Collaborator

This PR syncs this repo with third-party/move in aptos-core. Commits include bug fixes, code refactoring, new features such as enums and new code caches, compiler V2 changes.

runtian-zhou and others added 30 commits December 3, 2024 11:41
GitOrigin-RevId: f2658206d81e7a08aa2b1976cb54bfbcca3b5ffd
* enable paranoid mode for VM in transactional tests
* tested by triggering paranoid-mode failure on all transactional test frameworks

GitOrigin-RevId: 1af48e9d029903b90e6058df65af20b8c76c9369
…on >= 2 (#12936)

GitOrigin-RevId: 66d9efb7d30b7c6916f79b6ef65f0bdcbe9c6acb
GitOrigin-RevId: 17937e7ea06d3fc52fda1e891bc14575733f2451
GitOrigin-RevId: 8aa625d5b275e7ea8f5fd1146d20571e12ec7766
Distinguish between "target" (to be compiled) and "primary_target" (to
be tested/analyzed/etc.) in move-model/move-compiler-v2, so that
tests/etc. can be run on just the primary source inputs.  Primary
targets are distinguished by keeping sources separate on their way to
the move model through various interfaces.  In move-model internals
(model.rs), the `is_dep` property is negated as `is_target` (to be
compiled), while the root packages (to be tested or whatever) are
identified as `is_prime_target`.

GitOrigin-RevId: 5422dc17a873fa13faa15762cb7a7e22a5372ad5
Signed-off-by: findnature <[email protected]>
GitOrigin-RevId: 387de66af429b3bf0eda2095a503547a027f4da9
…instead (#13205)

* Check `LdConst` in bytecode generation to make sure we don't try to load a constant
  containing an empty vector, as the type will be unknown; instead, use `VecPack`.
* Do it recursively to deal with constant vectors containing empty vectors.

GitOrigin-RevId: a1822a4fa0912166069822fb1080a006f32d7b0b
* attach type info for cons_to_idx

* retain vecpack for empty vectors

GitOrigin-RevId: e85aeb23d3acf8d9aa2d57701a2b1e72faeffccc
* [move-unit-test] Add detailed error msg to test failure.

* Fix error msg for non-existent modules

* Fix PFS mint

* Fix error msg

* make sure dispatchable api checks for freeze bit

* Fix permission check

* Add comments

* fixup! Add comments

* Create check logic

* Add check for non-existant token metadata

* fix test failure

* Add tests from FA/PFS

* update error msg

* fixup! update error msg

* fixup! fixup! update error msg

* fixup! fixup! fixup! update error msg

* fixup! fixup! fixup! fixup! update error msg

* fixup! Merge branch 'main' into runtianz/dispatchable_token_fix

* fixup! fixup! Merge branch 'main' into runtianz/dispatchable_token_fix

* fixup! fixup! fixup! Merge branch 'main' into runtianz/dispatchable_token_fix

GitOrigin-RevId: 42ea82254eea341ef603f36f9901c1c35277a46b
GitOrigin-RevId: 173010a980307e7473b820d5f7997979fce41fa4
Rename VM types to correctly differentiate between arguments, parameters and types.

GitOrigin-RevId: 6cdd4c27275f355774e55d346738f346b629289e
Previously, `MoveResolver`s have been used to access storage bytes by
the VM, Move APIs, indexer, etc. As a result, this created an unnecessary
coupling between the VM and the rest of the system, making code
maintainability harder, error-prone and hard to evolve (e.g., implementing
a new loader).

This refactors code so that a separate trait is used by indexers/APIs.

GitOrigin-RevId: 9806be87a913124363b62721ff9a9e04d2c5c029
GitOrigin-RevId: 8c6963dd70be05cb0f4a1cdd29e71c60c86a00b6
Run extended_checks as part of the aptos-transactional-test-harness.  Fixes #13297.

GitOrigin-RevId: 327fc170914032a831ab30b09d984432ff028c80
GitOrigin-RevId: 33921f87ae3c1ca12ad8ba4a90a9a5bb2372d055
…les (#13254)

Run more tests with MOVE_COMPILER_V2=true, modifying drivers to put outputs in this case in .v2_exp files to allow slight variations from V1 outputs.  Filed separate issues for variations found.

GitOrigin-RevId: db482a4e89ae987e1ddc32d6698cf256803a9a40
GitOrigin-RevId: 4da21b944eb3300ab3466c0ff48b62c9c13fcff7
Fixes #12781

This also refactors and simplifies the releasing of references before write operations. I initially thought this was the problem but it wasn't, anyway the refactoring simplifies the code a bit.

GitOrigin-RevId: e93cd69e296c84b7f0fb11b025cc73ef91dd6bc1
* use  aptos production configs in one place and share them in the codebase

GitOrigin-RevId: 6582ad5efe9eb250b79c61473f89417881070b57
…resent (#13380)

Fix dependency path in a move-abigen test so it still works with a built
move-stdlib, while adding comments and
some Debug implementations to make it easier to sort out what paths
are present where in the code.

This PR also adds somewhat unnecessary dependences between stdlib
builds and tests using them, not because they use the built libs (they
should be reading the sources, not the built packages), but because
this leads to more deterministic output when paths are not specified
correctly.

GitOrigin-RevId: d57183418ba38281a144e62c1fe6752ef07e9727
GitOrigin-RevId: db53d9e0cd073d3377a552e2e2f7e1205e867cfa
* [extended checker] Add checks for safe randomness usage

This adds checks to the extended checker for safe usage of randomness.

- Public functions which directly or indirectly call into the `randomness` module are flagged as an error. Exempted functions are those which have the `#[lint_allow_unsafe_randomness]` attribute or which are in the framework at address 0x1.
- Private or friend entry functions which do not have the `#[randomness]` attribute are flagged as an error.

We do not need to check dynamic dispatch here since only public functions are allowed to be registered for dispatch, and those are already checked via above logic.

* Addressing reviewer comments, enabling `#[attribute_area::attribute_name]` syntax and using this for lint attributes.

GitOrigin-RevId: 92ba8946ae6ad4658d219a596b9fdccb0b514f5c
* fix address on scripts added by `run_spec_checker` so it is compatible with `is_script` function.
* update docgen test outputs with corrected contents

GitOrigin-RevId: ded3c0e921be176139d480e944796bf6366f6a46
…ecursively (#13442)

* fix recursive

* update v2 test

* refactor

GitOrigin-RevId: 11033f4dd27144908ad9832dd49dc86fe261561f
…ions (#13438)

* Graph output change

* [compiler-v2] Fixes bug in reference safety regards weak borrow relations

Fixes #12904

A weak borrow results from branching like `let r = if (cond) &mut r.f else &mut r.g`. The resulting reference `r` can be derived from either of the two borrows. The borrow safety check until now did not correctly deal with weak borrows when constructing hyper edges. This PR fixes the issue by grouping edges which target the same node into one hyper edge.

The 1st commit is only a change in annotation output, the 2nd is the relevant one for the change.

* Removing unnecessary complication in `group_children_into_hyper_edges`, addressing reviewer comments

GitOrigin-RevId: 15b5a55b1da3bf2e02119cfccb473457a3997422
This updates the `move_pr.sh` script to run the tests also covered by #13446 as integration tests, namely all kind of tests depending on the MOVE_COMPILER_V2 env var.

With `move_pr.sh -i2` both integration tests without the MOVE_COMPILER_V2 flag are run (the `-i` option) as with the flag set (`-2`). This mechanism was already before there, only the crate lists have been updated.

There are some `.v2_exp` files which did not exists or where out-of-date which are also updated with this PR.

We currently need a workaround to avoid `aptos-cached-packages` is build when MOVE_COMPILER_V2 is set, as this will generate new .md files for the framework based on some bug fixes the v2 compiler has, that appear as changes in the client. The script ensures that this crate is build before switching the env var to on.

As a sideffect, this also removes the 2nd dependency from RUST_BACKTRAC in exp files, in `move-compiler/src/diagnoses`. The same mechanism as already in place in `model.rs` is used: in order to get backtrace into error output, one must set both `RUST_BACKTRACE` and `MVC_BACKTRACE`.

GitOrigin-RevId: 7cb1e69c9432ad172eb052ab1fed94dac6a09c0f
Closes #13146

Adds a check that a global resource is not borrowed when it is declared in the access specifier list of a function.

This implements the full semantics of Move 2.0 access specifiers. However, if the 2.0 language is not enabled, access specifiers other then `acquires` will be rejected by the context checker, and for that special case the behavior is equivalent.

In order to test the extended access specifier semantics, we need to disable the existing acquires checker, which is not yet implemented for general access specifiers.

GitOrigin-RevId: 562cc9429de9625ed3d3ed551f0956946f4e6f9b
* [compiler-v2] Bytecode verification failure error message

This close #12709 and mitigates #12817.

If we had a bytecode verification failure post file format verification, until now we gave a cryptical error. We also have some weird corner cases where the verifier fails while reference safety is clearly maintained.

This improves the error message on bv failure, as well as prints out a special tailored message for the corner cases, which we will be hopefully able to fix with a new bytecode verifier. The full VMError detail
is omitted unless the env var MVC_BACKTRACE is set to true.

* Addressing reviewer comments

GitOrigin-RevId: 1d9cd70677a2fa76e993d5ad5a281d046dec6a19
* support mdx

* handle comments

GitOrigin-RevId: 6cad0ac954656bb7017e6c24e9b979f19c58024f
rahxephon89 and others added 22 commits December 3, 2024 12:27
* fix field selection after indexing

* add test case

* handle index directly

* add more test cases

GitOrigin-RevId: 6641f4345cb6830ef30531be36f10d3309d96f5c
This adds support for cross-block environment and module caches

GitOrigin-RevId: cb4dd963c6810b5094569723d10180631641ce5c
…15256)

GitOrigin-RevId: 817bf701519715094a4845f741a11fa954f29163
## Description
If we have a field that contains non-copyable type, it is impossible to change it, and get the old value back.

Adding two methods:
* native mem::swap, that implements swap of contents of two mutable references
* mem::replace, as a simple wrapper based on mem::swap

## How Has This Been Tested?
provided unit tests

## Type of Change
- [x] New feature

## Which Components or Systems Does This Change Impact?
- [x] Move/Aptos Virtual Machine

GitOrigin-RevId: 6255194b9b8f3e8629f78ee1743d6ce1151d5156
Enables V2 loader feature & updates calibration TPS for single node.

GitOrigin-RevId: ba4c827b922a96cb5cce6178f889f7605351ac6d
- Improve merging spans in the coverage tool:
  - The old solution failed to merge neighbouring spans
    e.g. `[3, 5]` and `[5, 7]` into `[3, 7]`
- Also, make the `merge_spans()` function public so it could be used by the
  `move-mutation-test` tool which also parses the coverage output file.

Co-authored-by: Vineeth Kashyap <[email protected]>
GitOrigin-RevId: 5770aa4c1c7117fab55f98b63ed46a51ab15baef
GitOrigin-RevId: b3098303ab7937cc9889bfefe8da12b61b665ba5
GitOrigin-RevId: afd596eeb8e504271bb33d1e86bef177b3816b31
…2 (#15312)

* fix plan_builder of compiler v2

* fix

GitOrigin-RevId: c9c6d6473178131f05d7afe1ec5428049f3bd378
Co-authored-by: Sherry Xiao <[email protected]>
GitOrigin-RevId: 0ff50da04da51cd33b960c302c29da8779790ccb
- Fixed naming for global module cache.
- Added more counters, moved some old ones.
- Added unit tests for TransactionSliceMetadata + renaming.

GitOrigin-RevId: 47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3
- Switching from undefined to script location
- Keeping error remapping because the status code exists on-chain.
   It is probably fine t keep it as is.
- Removed useless TODO for alerts on concurrent manager uses.
- Changed errors.rs TODO into a note, as it is not a P0/P1/P2 to fix.

GitOrigin-RevId: dbdb613b467aa67fb620d8416ec8b3c19db46271
…… (#15301)

* Same limit for serializing and deserializing type tags when in release mode

* Updated usages of MAX_TYPE_TAG_NESTING constant

* addressing review comments

GitOrigin-RevId: 9fa7baec6c442e5a858b601d236c49d1cad32a0d
…ton implementation (#15354)

GitOrigin-RevId: e757e2600a402d4d6952e83fb334ff7368bdc2be
* add ability check on number constraints

* add tests and comments

GitOrigin-RevId: 04109e7db19d6386b8acc31e15182816c2842ee4
…for optimization (#15338)

GitOrigin-RevId: 93874282e989c0d2dda6b307461d27a4b9e57a73
GitOrigin-RevId: e2a90419f34137edfbf1deca6b0eb17aeeec2f4a
…(#15384)

GitOrigin-RevId: ac0447c9c2bbb343c68c95db73371158293dfe69
GitOrigin-RevId: 0029300cc400551433b5f77b0663cdc13b405b2c
…… (#15350)

* Refactoring interpreter and paranoid mode, introducing traits to allow generic interpreter as well as compile time switch for the runtime type checks (formerly called paranoid mode)

* lint

* addressing comments

* addressed other

* missed null->no

* missed null->no

GitOrigin-RevId: 46bd0e909b522960ec44f7d912c54a4d65d0342e
Add parser code for function values and non-inline lambdas

 Extend syntax
 - for lambda: `move |args| body with copy+store`
- Add function types: `|T1, T2| T3 with copy+store`
- curry construction:
    - from lambda: `|a, b| f(x, 3, a, b)`
    - `EarlyBind` operation takes a function value and values for any number of leading parameters.
- arbitrary function calls:
    - `(|x, y| x + y)(2, 3)`
- suppress printing common abilities (all functions have drop)

Modify exp_builder and lambda_lifter to generate function values, model to track "used" functions in addition to "called" functions.

Attaches an `AbilitySet` to `Type::Fun` and `Exp::Lambda` based on
source.  Adds a new `ExpCall` operation in parser/expansion ASTs to be
able to carry more generalized function calls through to move-model,
which already can support this through `Invoke`, which previously was
underutilized.  Added basic type checking for function abilities.

Added more lambda tests under `move-compiler-v2/tests/lambda/` which
are run "with" and "without" lambda features enabled.  Currently, many
things pass through to hit "not yet implemented" errors in bytecode
gen, etc.

Tricky features are:
- In some cases, abilities may not be inferred well yet, so examples may need to be over-annotated with abilities.
- in `ty.rs`: unification checks `Fun` abilities as well as other things.
- in `lambda_lifter.rs`, we (1) reject lambdas without `move` free-var handling, (2) try to reduce lambda to curry, by checking for a simple function call with simple args, the last of which are identical to the lambda parameters.

GitOrigin-RevId: 5d87d94cba896628ac75e979c6e66a2d65347642
…(#15437)

* further redesign

* fixed a typo

GitOrigin-RevId: 94e548cb320511c6b8d3c5eef3bf697bcd2db882
@georgemitenkov georgemitenkov changed the title [copybara] Sync recent chnages from aptos-core [copybara] Sync recent changes from aptos-core Dec 3, 2024
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.