starcoinorg / starcoin

Starcoin - A Move smart contract blockchain network that scales by layering
Apache License 2.0
1.38k stars 289 forks source link

Refactor move runtime #4166

Closed simonjiao closed 3 months ago

simonjiao commented 3 months ago

Pull request type

Please check the type of change your PR introduces:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

-

-

Other information

Summary by CodeRabbit

coderabbitai[bot] commented 3 months ago

Walkthrough

The recent updates enhance the Move programming environment by refreshing dependency management and introducing new validation mechanisms for transaction arguments. Key improvements include extended checks for module integrity and a reorganized structure for managing virtual machine interactions. This comprehensive restructuring aims to fortify the reliability and functionalities of the Starcoin framework, ensuring a robust and dynamic development experience.

Changes

Files Change Summary
Cargo.toml, vm/move-package-manager/Cargo.toml, vm/vm-runtime/Cargo.toml Updated dependency references to new revision hashes for various Move-related packages, ensuring current compatibility.
executor/tests/script_function_test.rs Added entry keyword to functions for direct blockchain calls; introduced test_transaction_arg_verify for validating transaction arguments.
vm/move-package-manager/src/extended_checks.rs, vm/move-package-manager/src/lib.rs, vm/move-package-manager/src/release.rs Added ExtendedChecker for comprehensive module validation; modified release handling to include extended checks and improved error reporting.
vm/starcoin-gas/src/gas_meter.rs Introduced charge_dependency method to manage gas charges related to dependencies.
vm/vm-runtime/src/lib.rs, vm/vm-runtime/src/parallel_executor/mod.rs, vm/vm-runtime/src/parallel_executor/vm_wrapper.rs, vm/vm-runtime/src/starcoin_vm.rs Removed adapter_common module; introduced verifier and vm_adapter modules; refactored transaction execution with new validation methods.
vm/vm-runtime/src/verifier/mod.rs, vm/vm-runtime/src/verifier/transaction_arg_validation.rs Created transaction_arg_validation module for validating transaction arguments, implementing detailed checks within the new file.
vm/vm-runtime/src/vm_adapter/... Introduced SessionAdapter to manage session interactions; modified visibility of functions for broader access.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VM
    participant ExtendedChecker
    participant SessionAdapter

    User->>VM: Submit Transaction
    VM->>ExtendedChecker: Run Extended Checks
    ExtendedChecker->>VM: Validate Entries
    VM->>SessionAdapter: Check Arguments
    SessionAdapter-->>VM: Arguments Validated
    VM-->>User: Transaction Processed Successfully

🐰 In the code, I hop and play,
With branches new, I find my way.
From fixed to flexible, I leap with glee,
Validations strong, as bright as can be!
In the world of Move, I dance and twirl,
Celebrating changes, oh what a whirl! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
github-actions[bot] commented 3 months ago

Benchmark for 6bf5dd5

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | accumulator_append | 797.0±166.09µs | 804.1±135.76µs | +0.89% | | block_apply/block_apply_10 | **368.5±9.78ms** | 389.5±35.04ms | **+5.70%** | | block_apply/block_apply_1000 | 41.1±1.33s | **38.9±1.00s** | **-5.35%** | | get_with_proof/db_store | 52.5±8.96µs | 49.3±6.29µs | -6.10% | | get_with_proof/mem_store | 39.1±4.90µs | 38.1±2.52µs | -2.56% | | put_and_commit/db_store/1 | 120.6±5.33µs | 115.6±8.59µs | -4.15% | | put_and_commit/db_store/10 | 1094.2±70.14µs | 1095.6±97.07µs | +0.13% | | put_and_commit/db_store/100 | 9.6±0.83ms | 9.8±0.39ms | +2.08% | | put_and_commit/db_store/5 | 600.9±77.71µs | **529.8±19.32µs** | **-11.83%** | | put_and_commit/db_store/50 | 5.1±0.55ms | 5.2±0.34ms | +1.96% | | put_and_commit/mem_store/1 | 85.3±14.74µs | **72.5±6.37µs** | **-15.01%** | | put_and_commit/mem_store/10 | 678.0±55.72µs | 681.3±56.66µs | +0.49% | | put_and_commit/mem_store/100 | **6.5±0.32ms** | 6.9±1.00ms | **+6.15%** | | put_and_commit/mem_store/5 | 346.7±40.48µs | 350.0±52.91µs | +0.95% | | put_and_commit/mem_store/50 | 3.4±0.41ms | 3.3±0.15ms | -2.94% | | query_block/query_block_in(10)_times(100) | 4.7±0.37ms | 4.6±0.23ms | -2.13% | | query_block/query_block_in(10)_times(1000) | 46.2±1.50ms | 46.4±3.67ms | +0.43% | | query_block/query_block_in(10)_times(10000) | 460.8±17.18ms | 460.6±10.81ms | -0.04% | | query_block/query_block_in(1000)_times(100) | 1212.6±37.33µs | **1147.1±25.83µs** | **-5.40%** | | query_block/query_block_in(1000)_times(1000) | 12.3±0.84ms | 12.2±1.72ms | -0.81% | | query_block/query_block_in(1000)_times(10000) | 124.3±4.69ms | **114.6±3.09ms** | **-7.80%** | | storage_transaction | 1129.4±584.62µs | 1222.6±540.03µs | +8.25% | | vm/transaction_execution/1 | **412.8±10.51ms** | 423.6±25.09ms | **+2.62%** | | vm/transaction_execution/10 | 139.2±9.95ms | 145.6±15.84ms | +4.60% | | vm/transaction_execution/20 | 128.4±11.92ms | **119.5±6.32ms** | **-6.93%** | | vm/transaction_execution/5 | 170.5±9.24ms | 176.0±21.86ms | +3.23% | | vm/transaction_execution/50 | 144.4±7.39ms | 143.3±11.23ms | -0.76% |
github-actions[bot] commented 3 months ago

Benchmark for dddebf6

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | accumulator_append | 778.9±76.74µs | 828.7±148.95µs | +6.39% | | block_apply/block_apply_10 | 371.4±11.57ms | **361.0±6.04ms** | **-2.80%** | | block_apply/block_apply_1000 | 38.9±0.99s | **38.8±0.81s** | **-0.26%** | | get_with_proof/db_store | 46.2±1.43µs | 46.1±0.97µs | -0.22% | | get_with_proof/mem_store | 40.4±6.98µs | **37.0±1.12µs** | **-8.42%** | | put_and_commit/db_store/1 | 115.5±7.42µs | 119.2±13.67µs | +3.20% | | put_and_commit/db_store/10 | 1016.8±54.29µs | 1028.8±61.18µs | +1.18% | | put_and_commit/db_store/100 | 9.7±0.73ms | 9.4±1.04ms | -3.09% | | put_and_commit/db_store/5 | 549.8±61.63µs | 525.5±42.76µs | -4.42% | | put_and_commit/db_store/50 | 5.3±0.76ms | **4.8±0.47ms** | **-9.43%** | | put_and_commit/mem_store/1 | 72.9±8.52µs | 74.2±9.71µs | +1.78% | | put_and_commit/mem_store/10 | 670.2±49.81µs | 669.2±47.67µs | -0.15% | | put_and_commit/mem_store/100 | 6.6±0.36ms | 6.5±0.32ms | -1.52% | | put_and_commit/mem_store/5 | 367.8±92.88µs | 340.4±32.05µs | -7.45% | | put_and_commit/mem_store/50 | 3.5±0.54ms | 3.3±0.26ms | -5.71% | | query_block/query_block_in(10)_times(100) | **4.8±0.28ms** | 6.4±2.11ms | **+33.33%** | | query_block/query_block_in(10)_times(1000) | 47.5±2.45ms | 46.3±1.63ms | -2.53% | | query_block/query_block_in(10)_times(10000) | 473.5±17.10ms | **454.7±11.65ms** | **-3.97%** | | query_block/query_block_in(1000)_times(100) | 1180.9±87.60µs | 1199.2±34.36µs | +1.55% | | query_block/query_block_in(1000)_times(1000) | **11.2±0.24ms** | 11.6±0.08ms | **+3.57%** | | query_block/query_block_in(1000)_times(10000) | **111.9±1.86ms** | 116.0±1.08ms | **+3.66%** | | storage_transaction | 1113.4±441.97µs | 1192.9±418.28µs | +7.14% | | vm/transaction_execution/1 | 415.3±17.34ms | 415.3±13.13ms | 0.00% | | vm/transaction_execution/10 | 134.2±5.96ms | 137.6±7.73ms | +2.53% | | vm/transaction_execution/20 | 121.2±7.37ms | 125.7±6.88ms | +3.71% | | vm/transaction_execution/5 | **155.8±1.76ms** | 163.3±8.52ms | **+4.81%** | | vm/transaction_execution/50 | 142.1±5.69ms | 141.5±5.65ms | -0.42% |
github-actions[bot] commented 3 months ago

Benchmark for 51533d6

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | accumulator_append | 1099.7±275.50µs | **872.3±210.78µs** | **-20.68%** | | block_apply/block_apply_10 | 398.2±43.27ms | 388.2±58.76ms | -2.51% | | block_apply/block_apply_1000 | 43.9±2.70s | **43.6±2.30s** | **-0.68%** | | get_with_proof/db_store | 55.3±12.60µs | **48.1±5.98µs** | **-13.02%** | | get_with_proof/mem_store | 43.8±10.44µs | 41.7±8.04µs | -4.79% | | put_and_commit/db_store/1 | 127.9±23.77µs | 120.8±9.13µs | -5.55% | | put_and_commit/db_store/10 | 1623.2±328.32µs | **1207.7±233.03µs** | **-25.60%** | | put_and_commit/db_store/100 | 12.8±2.74ms | 12.0±3.12ms | -6.25% | | put_and_commit/db_store/5 | 575.6±83.76µs | 591.1±106.08µs | +2.69% | | put_and_commit/db_store/50 | 6.6±1.45ms | **5.6±0.75ms** | **-15.15%** | | put_and_commit/mem_store/1 | 91.4±22.11µs | **72.0±6.09µs** | **-21.23%** | | put_and_commit/mem_store/10 | 703.8±113.40µs | 686.8±75.05µs | -2.42% | | put_and_commit/mem_store/100 | 8.2±1.84ms | 7.2±1.66ms | -12.20% | | put_and_commit/mem_store/5 | 346.3±34.97µs | 376.4±66.01µs | +8.69% | | put_and_commit/mem_store/50 | 4.1±1.06ms | **3.4±0.43ms** | **-17.07%** | | query_block/query_block_in(10)_times(100) | **4.6±0.16ms** | 5.6±0.96ms | **+21.74%** | | query_block/query_block_in(10)_times(1000) | 46.8±2.65ms | 48.5±5.16ms | +3.63% | | query_block/query_block_in(10)_times(10000) | **496.9±44.94ms** | 542.9±100.55ms | **+9.26%** | | query_block/query_block_in(1000)_times(100) | 1293.6±102.85µs | 1373.1±348.18µs | +6.15% | | query_block/query_block_in(1000)_times(1000) | 13.7±1.78ms | 12.7±2.31ms | -7.30% | | query_block/query_block_in(1000)_times(10000) | 156.3±32.27ms | 142.2±30.97ms | -9.02% | | storage_transaction | 1385.5±539.99µs | 1350.0±566.23µs | -2.56% | | vm/transaction_execution/1 | 528.2±75.08ms | **469.2±32.74ms** | **-11.17%** | | vm/transaction_execution/10 | 158.8±9.97ms | 151.8±23.58ms | -4.41% | | vm/transaction_execution/20 | 154.0±12.28ms | **135.3±6.14ms** | **-12.14%** | | vm/transaction_execution/5 | 182.0±16.45ms | 187.9±12.57ms | +3.24% | | vm/transaction_execution/50 | 175.5±13.44ms | **166.0±8.06ms** | **-5.41%** |
github-actions[bot] commented 3 months ago

Benchmark for aa6e231

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | accumulator_append | 741.2±49.16µs | 736.5±49.85µs | -0.63% | | block_apply/block_apply_10 | 362.4±15.94ms | 359.4±4.47ms | -0.83% | | block_apply/block_apply_1000 | **38.2±0.93s** | 38.3±0.87s | **+0.26%** | | get_with_proof/db_store | **44.8±1.08µs** | 46.0±2.91µs | **+2.68%** | | get_with_proof/mem_store | 37.1±1.31µs | 37.3±1.97µs | +0.54% | | put_and_commit/db_store/1 | 115.6±11.12µs | 115.5±5.02µs | -0.09% | | put_and_commit/db_store/10 | 1009.0±47.19µs | 1046.0±130.80µs | +3.67% | | put_and_commit/db_store/100 | 9.3±0.75ms | 9.6±1.06ms | +3.23% | | put_and_commit/db_store/5 | 522.6±35.50µs | 528.3±23.72µs | +1.09% | | put_and_commit/db_store/50 | 4.9±0.34ms | 4.8±0.30ms | -2.04% | | put_and_commit/mem_store/1 | 72.0±6.52µs | 71.2±6.04µs | -1.11% | | put_and_commit/mem_store/10 | 666.4±52.92µs | 669.0±47.56µs | +0.39% | | put_and_commit/mem_store/100 | 6.5±0.48ms | 6.5±0.28ms | 0.00% | | put_and_commit/mem_store/5 | 334.8±27.64µs | 338.9±27.86µs | +1.22% | | put_and_commit/mem_store/50 | 3.3±0.49ms | 3.2±0.15ms | -3.03% | | query_block/query_block_in(10)_times(100) | **4.4±0.17ms** | 4.7±0.25ms | **+6.82%** | | query_block/query_block_in(10)_times(1000) | 46.1±2.71ms | 45.0±1.54ms | -2.39% | | query_block/query_block_in(10)_times(10000) | **460.8±23.54ms** | 547.6±126.87ms | **+18.84%** | | query_block/query_block_in(1000)_times(100) | 1164.1±76.94µs | 1161.2±12.55µs | -0.25% | | query_block/query_block_in(1000)_times(1000) | **10.7±0.11ms** | 11.9±0.59ms | **+11.21%** | | query_block/query_block_in(1000)_times(10000) | **108.3±1.87ms** | 117.3±2.17ms | **+8.31%** | | storage_transaction | 1121.0±433.95µs | 1114.2±444.64µs | -0.61% | | vm/transaction_execution/1 | 416.2±23.87ms | 434.7±34.96ms | +4.44% | | vm/transaction_execution/10 | **131.1±5.02ms** | 141.0±7.87ms | **+7.55%** | | vm/transaction_execution/20 | 128.9±10.12ms | 127.6±12.49ms | -1.01% | | vm/transaction_execution/5 | 163.7±10.24ms | 168.8±5.76ms | +3.12% | | vm/transaction_execution/50 | **138.2±6.40ms** | 146.2±8.48ms | **+5.79%** |
github-actions[bot] commented 3 months ago

Benchmark for f69fccc

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | accumulator_append | 744.9±63.95µs | 769.6±134.86µs | +3.32% | | block_apply/block_apply_10 | 363.4±7.37ms | 360.6±7.29ms | -0.77% | | block_apply/block_apply_1000 | **38.8±1.38s** | 39.2±1.04s | **+1.03%** | | get_with_proof/db_store | 45.7±1.87µs | 46.1±4.70µs | +0.88% | | get_with_proof/mem_store | 38.1±3.58µs | 37.9±5.22µs | -0.52% | | put_and_commit/db_store/1 | **119.0±10.65µs** | 147.1±43.17µs | **+23.61%** | | put_and_commit/db_store/10 | 1018.5±71.22µs | 1001.5±40.98µs | -1.67% | | put_and_commit/db_store/100 | 9.5±0.41ms | 9.5±0.51ms | 0.00% | | put_and_commit/db_store/5 | 523.9±20.64µs | 511.3±28.78µs | -2.41% | | put_and_commit/db_store/50 | 4.8±0.33ms | 5.0±0.58ms | +4.17% | | put_and_commit/mem_store/1 | 71.3±6.34µs | 71.0±5.93µs | -0.42% | | put_and_commit/mem_store/10 | 665.9±51.29µs | 673.2±61.98µs | +1.10% | | put_and_commit/mem_store/100 | 6.5±0.28ms | 6.5±0.60ms | 0.00% | | put_and_commit/mem_store/5 | 351.2±46.42µs | 342.0±32.19µs | -2.62% | | put_and_commit/mem_store/50 | 3.3±0.19ms | 3.3±0.22ms | 0.00% | | query_block/query_block_in(10)_times(100) | 4.6±0.17ms | 4.6±0.24ms | 0.00% | | query_block/query_block_in(10)_times(1000) | 45.0±2.77ms | 45.2±1.49ms | +0.44% | | query_block/query_block_in(10)_times(10000) | 458.1±11.40ms | 457.2±13.34ms | -0.20% | | query_block/query_block_in(1000)_times(100) | **1119.5±16.96µs** | 1225.6±135.77µs | **+9.48%** | | query_block/query_block_in(1000)_times(1000) | **11.4±0.85ms** | 11.8±0.23ms | **+3.51%** | | query_block/query_block_in(1000)_times(10000) | **112.1±3.08ms** | 120.3±7.75ms | **+7.31%** | | storage_transaction | 1083.1±443.64µs | 1122.3±443.77µs | +3.62% | | vm/transaction_execution/1 | **410.5±8.72ms** | 421.5±19.30ms | **+2.68%** | | vm/transaction_execution/10 | **135.1±8.36ms** | 146.2±12.65ms | **+8.22%** | | vm/transaction_execution/20 | **124.9±6.64ms** | 134.2±13.62ms | **+7.45%** | | vm/transaction_execution/5 | 173.0±22.94ms | **164.9±7.18ms** | **-4.68%** | | vm/transaction_execution/50 | 139.8±7.08ms | 139.3±5.15ms | -0.36% |
nkysg commented 3 months ago

partly closes https://github.com/starcoinorg/starcoin/issues/4157