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

VM refactor: builtin functions #1149

Merged
merged 4 commits into from
Jul 11, 2023
Merged

Conversation

andrei-marinica
Copy link
Contributor

@andrei-marinica andrei-marinica commented Jul 6, 2023

The builtin functions were previously kept as a list of polymorphic trait objects (Vec<dyn BuiltinFunction>). This was not allowing us to have the execute_lambda method accept a closure as generic argument, and had us wrap it in a trait object itself (Box<dyn FnOnce() + 'static>).

The problem is that this was imposing us the 'static lifetime bound, which was hurting the usability of the whitebox testing framework.

The solution was to ditch the dynamic dispatch and go for a simple match on the builtin function name. This way we only use static dispatch and handle closures much easier.

@github-actions
Copy link

github-actions bot commented Jul 6, 2023

Contract comparison - from 9ece45e to 0b0a251

Path                                                                                             size                  has-allocator                     has-format
mx-sdk-rs/contracts/benchmarks
- send-tx-repeat/send-tx-repeat.wasm 905 No No
- str-repeat/str-repeat.wasm 2125 No No
mx-sdk-rs/contracts/benchmarks/mappers
- linked-list-repeat/linked-list-repeat.wasm 7397 No No
- map-repeat/map-repeat.wasm 8345 No No
- queue-repeat/queue-repeat.wasm 6674 No No
- set-repeat/set-repeat.wasm 8108 No No
- single-value-repeat/single-value-repeat.wasm 5139 No No
- vec-repeat/vec-repeat.wasm 5943 No No
mx-sdk-rs/contracts/core
- price-aggregator/multiversx-price-aggregator-sc.wasm 20385 No No
- wegld-swap/multiversx-wegld-swap-sc.wasm 4436 No No
mx-sdk-rs/contracts/examples
- adder/adder.wasm 687 No No
- bonding-curve-contract/bonding-curve-contract.wasm 15624 No No
- crowdfunding-esdt/crowdfunding-esdt.wasm 3612 No No
- crypto-bubbles/crypto-bubbles.wasm 2364 No No
- crypto-zombies/cryptozombies.wasm 11185 No No
- digital-cash/digital-cash.wasm 10034 No No
- empty/empty.wasm 232 No No
- esdt-transfer-with-fee/esdt-transfer-with-fee.wasm 9117 No No
- factorial/factorial.wasm 567 No No
- fractional-nfts/fractional-nfts.wasm 8537 No No
- lottery-esdt/lottery-esdt.wasm 11411 No No
- multisig
- - multisig.wasm 15416 No No
- - multisig-full.wasm 17428 No No
- - multisig-view.wasm 7779 No No
- nft-minter/nft-minter.wasm 10094 No No
- nft-storage-prepay/nft-storage-prepay.wasm 2293 No No
- ping-pong-egld/ping-pong-egld.wasm 6750 No No
- proxy-pause/proxy-pause.wasm 5757 No No
- rewards-distribution/rewards-distribution.wasm 11312 No No
- seed-nft-minter/seed-nft-minter.wasm 15039 No No
- token-release/token-release.wasm 8513 No No
mx-sdk-rs/contracts/examples/crypto-kitties
- kitty-auction/kitty-auction.wasm 11004 No No
- kitty-genetic-alg/kitty-genetic-alg.wasm 3584 No No
- kitty-ownership/kitty-ownership.wasm 14067 No No
mx-sdk-rs/contracts/examples/order-book
- factory/order-book-factory.wasm 5050 No No
- pair/order-book-pair.wasm 16454 No No
mx-sdk-rs/contracts/feature-tests
- abi-tester
- - abi-tester.wasm 7741 No No
- - abi-tester-ev.wasm 758 No No
- alloc-features/alloc-features.wasm 19676 No Yes
- basic-features
- - basic-features.wasm 57314 No No
- - basic-features-storage-bytes.wasm 539 No No
- big-float-features/big-float-features.wasm 5170 No No
- esdt-system-sc-mock/esdt-system-sc-mock.wasm 4488 No No
- formatted-message-features/formatted-message-features.wasm 4352 No No
- managed-map-features/managed-map-features.wasm 1231 No No
- multi-contract-features
- - multi-contract-alt-impl.wasm 361 No No
- - multi-contract-example-feature.wasm 678 No No
- - multi-contract-features.wasm 679 No No
- - multi-contract-features-view.wasm 1116 No No
- panic-message-features/panic-message-features.wasm 3594 No Yes
- payable-features/payable-features.wasm 5163 No No
- rust-snippets-generator-test/rust-snippets-generator-test.wasm 5799 No No
- rust-testing-framework-tester/rust-testing-framework-tester.wasm 8393 No No
- use-module
- - use-module.wasm 33726 No Yes
- - use-module-view.wasm 734 No No
mx-sdk-rs/contracts/feature-tests/composability
- forwarder/forwarder.wasm 29106 No No
- forwarder-queue
- - forwarder-queue.wasm 11391 No No
- - forwarder-queue-promises.wasm 12693 No No
- forwarder-raw
- - forwarder-raw.wasm 14519 No No
- - forwarder-raw-init-async-call.wasm 4592 No No
- - forwarder-raw-init-sync-call.wasm 4450 No No
- local-esdt-and-nft/local-esdt-and-nft.wasm 11997 No No
- promises-features/promises-features.wasm 10450 No No
- proxy-test-first/proxy-test-first.wasm 6788 No No
- proxy-test-second/proxy-test-second.wasm 1952 No No
- recursive-caller/recursive-caller.wasm 5850 No No
- transfer-role-features/transfer-role-features.wasm 8753 No No
- vault
- - vault.wasm 7433 No No
- - vault-promises.wasm 8156 No No
mx-sdk-rs/contracts/feature-tests/composability/esdt-contract-pair
- first-contract/first-contract.wasm 2711 No No
- second-contract/second-contract.wasm 1342 No No
mx-sdk-rs/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback
- child/child.wasm 4972 No No
- parent/parent.wasm 1852 No No
mx-sdk-rs/contracts/feature-tests/erc-style-contracts
- crowdfunding-erc20/crowdfunding-erc20.wasm 6260 No No
- erc1155/erc1155.wasm 12854 No No
- erc1155-marketplace/erc1155-marketplace.wasm 12136 No No
- erc1155-user-mock/erc1155-user-mock.wasm 1448 No No
- erc20/erc20.wasm 2130 No No
- erc721/erc721.wasm 2485 No No
- lottery-erc20/lottery-erc20.wasm 13474 No No

Base automatically changed from blockchainmock-refactor-4 to feat/whitebox July 10, 2023 09:51
@andrei-marinica andrei-marinica marked this pull request as ready for review July 10, 2023 15:39
@andrei-marinica andrei-marinica merged commit 56c0538 into feat/whitebox Jul 11, 2023
5 checks passed
@andrei-marinica andrei-marinica deleted the builtin-func-refactor branch July 11, 2023 06:52
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.

3 participants