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

Feature/resource movements static analysis #1909

Merged
merged 28 commits into from
Oct 3, 2024

Conversation

0xOmarA
Copy link
Member

@0xOmarA 0xOmarA commented Sep 8, 2024

Summary

This PR adds an analyzer for the resource movements in the manifest.

Copy link

github-actions bot commented Sep 8, 2024

Phylum Report Link

Copy link

github-actions bot commented Sep 8, 2024

Docker tags
docker.io/radixdlt/private-scrypto-builder:e275fc764d

Copy link

github-actions bot commented Sep 8, 2024

Benchmark for e275fc7

Click to view benchmark
Test Base PR %
costing::bench_prepare_wasm 46.3±0.23ms 44.5±0.15ms -3.89%
costing::decode_encoded_i8_array_to_manifest_raw_value 18.9±0.05ms 19.1±0.07ms +1.06%
costing::decode_encoded_i8_array_to_manifest_value 42.3±0.05ms 41.3±0.06ms -2.36%
costing::decode_encoded_tuple_array_to_manifest_raw_value 71.0±0.13ms 68.8±0.11ms -3.10%
costing::decode_encoded_tuple_array_to_manifest_value 98.8±0.21ms 98.9±0.21ms +0.10%
costing::decode_encoded_u8_array_to_manifest_raw_value 32.2±0.08µs 25.6±0.05µs -20.50%
costing::decode_encoded_u8_array_to_manifest_value 42.4±0.06ms 41.1±0.07ms -3.07%
costing::decode_rpd_to_manifest_raw_value 14.2±0.02µs 14.6±0.04µs +2.82%
costing::decode_rpd_to_manifest_value 11.0±0.05µs 10.8±0.02µs -1.82%
costing::deserialize_wasm 1262.1±5.33µs 1266.5±3.52µs +0.35%
costing::execute_transaction_creating_big_vec_substates 693.1±8.89ms 699.2±8.21ms +0.88%
costing::execute_transaction_reading_big_vec_substates 581.0±1.62ms 595.9±0.70ms +2.56%
costing::instantiate_flash_loan 886.9±360.17µs 1031.5±1359.82µs +16.30%
costing::instantiate_radiswap 931.9±743.10µs 919.9±527.65µs -1.29%
costing::spin_loop 20.7±0.03ms 20.4±0.07ms -1.45%
costing::validate_sbor_payload 33.5±0.13µs 31.9±0.05µs -4.78%
costing::validate_sbor_payload_bytes 253.5±0.87ns 258.5±0.62ns +1.97%
costing::validate_secp256k1 76.7±0.07µs 76.7±0.06µs 0.00%
costing::validate_wasm 33.8±0.04ms 33.4±0.04ms -1.18%
decimal::add/0 8.4±0.00ns 8.4±0.00ns 0.00%
decimal::add/rust-native 9.9±0.01ns 9.9±0.01ns 0.00%
decimal::add/wasmi 219.1±0.21ns 224.2±0.31ns +2.33%
decimal::add/wasmi-call-native 2.1±0.00µs 2.1±0.01µs 0.00%
decimal::div/0 186.9±0.22ns 185.1±0.10ns -0.96%
decimal::from_string/0 156.2±0.20ns 155.3±0.17ns -0.58%
decimal::mul/0 149.9±0.14ns 149.1±0.26ns -0.53%
decimal::mul/rust-native 146.8±0.16ns 147.5±0.11ns +0.48%
decimal::mul/wasmi 11.9±0.11µs 12.0±0.02µs +0.84%
decimal::mul/wasmi-call-native 2.3±0.00µs 2.3±0.00µs 0.00%
decimal::pow/0 703.2±0.65ns 701.8±1.38ns -0.20%
decimal::pow/rust-native 666.6±0.32ns 676.7±0.27ns +1.52%
decimal::pow/wasmi 57.5±0.17µs 58.4±0.38µs +1.57%
decimal::pow/wasmi-call-native 2.5±0.00µs 2.5±0.00µs 0.00%
decimal::root/0 7.8±0.01µs 8.1±0.00µs +3.85%
decimal::sub/0 8.2±0.00ns 8.2±0.01ns 0.00%
decimal::to_string/0 444.6±0.61ns 450.4±2.26ns +1.30%
large_transaction_processing::prepare 2.6±0.00ms 2.6±0.00ms 0.00%
large_transaction_processing::prepare_and_decompile 7.0±0.02ms 6.8±0.02ms -2.86%
large_transaction_processing::prepare_and_decompile_and_recompile 32.8±0.34ms 27.5±2.33ms -16.16%
precise_decimal::add/0 9.0±0.04ns 8.8±0.00ns -2.22%
precise_decimal::add/rust-native 10.7±0.04ns 10.7±0.04ns 0.00%
precise_decimal::add/wasmi 311.0±1.06ns 278.9±1.13ns -10.32%
precise_decimal::add/wasmi-call-native 2.8±0.00µs 2.8±0.01µs 0.00%
precise_decimal::div/0 316.7±0.53ns 323.8±0.51ns +2.24%
precise_decimal::from_string/0 203.5±0.22ns 205.5±0.47ns +0.98%
precise_decimal::mul/0 362.3±0.65ns 364.0±0.47ns +0.47%
precise_decimal::mul/rust-native 318.3±0.24ns 329.6±1.41ns +3.55%
precise_decimal::mul/wasmi 33.8±0.13µs 34.3±0.16µs +1.48%
precise_decimal::mul/wasmi-call-native 3.2±0.00µs 3.1±0.00µs -3.13%
precise_decimal::pow/0 1928.7±2.32ns 1951.0±2.71ns +1.16%
precise_decimal::pow/rust-native 1540.2±1.85ns 1589.3±2.19ns +3.19%
precise_decimal::pow/wasmi 164.6±0.44µs 164.4±0.29µs -0.12%
precise_decimal::pow/wasmi-call-native 5.8±0.01µs 5.8±0.01µs 0.00%
precise_decimal::root/0 61.5±0.13µs 58.7±0.03µs -4.55%
precise_decimal::sub/0 9.7±0.26ns 9.0±0.11ns -7.22%
precise_decimal::to_string/0 691.1±0.57ns 699.5±3.25ns +1.22%
schema::validate_payload 366.0±0.64µs 364.3±0.56µs -0.46%
transaction::radiswap 5.1±0.02ms 5.1±0.01ms 0.00%
transaction::transfer 1928.0±9.63µs 1890.2±4.38µs -1.96%
transaction_validation::validate_manifest 43.3±0.07µs 43.2±0.10µs -0.23%
transaction_validation::verify_bls_2KB 1013.9±34.53µs 1001.6±6.63µs -1.21%
transaction_validation::verify_bls_32B 1059.0±14.34µs 1001.6±5.16µs -5.42%
transaction_validation::verify_ecdsa 74.6±0.05µs 74.7±0.11µs +0.13%
transaction_validation::verify_ed25519 55.9±0.16µs 55.4±0.07µs -0.89%

@0xOmarA 0xOmarA changed the base branch from feature/subintent-validation to develop September 15, 2024 20:20
Copy link
Contributor

@dhedey dhedey left a comment

Choose a reason for hiding this comment

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

Really nice work! Have left a few comments. Haven't looked through it with a fine tooth-comb.

I suggest when you're back you can rebase on develop and we can have a chat and possibly do some markups I can review it properly when I get your thumbs up that it's good to go :)

Copy link
Contributor

@dhedey dhedey left a comment

Choose a reason for hiding this comment

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

Really nice work. The separation across different files has made it a lot easier to review 💯.

My comments are quite numerous, and spread across a few areas:

  • Comments on code style
  • Incorrect native invocation matching, inaccurate typings, and incomplete invocation listing
  • Incorrect bound adjustment logic, including a number of places where we attempt to recover instead of error when impossible bounds are discovered.
  • Suggestions for remodelling to reduce possibility of errors (essentially introducing simpler abstractions, separated into very thin layers, where each layer can be handled / validated separately)

Possibly it's worth us pairing on this tomorrow and we can bash out the tweaks to the models together in an hour or two?

0xOmarA and others added 2 commits October 1, 2024 14:04
…tic-analysis-rework

rework: Rework the manifest resource interpreter
Copy link
Contributor

@dhedey dhedey left a comment

Choose a reason for hiding this comment

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

I'm happy to get this merged (not least to unblock my new manifest instruction PR) and to do the follow ups in a separate PR :)

The follow-ups I think are detailed in:

And notably:

  • Complete defining the packages
  • Possibly move the type native invocations to the interfaces crate
  • Add a test which iterates over every blueprint definition in post-latest DB, and:
    • Ensures Completeness: Checks that resolving a native invocation with () results in either a success or a "CantDecode" error.
    • Ensures Schema Accuracy: Checks that resolving a schema for the native invocation aligns with the type from the Database.

@0xOmarA 0xOmarA merged commit acfcbd5 into develop Oct 3, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants