Skip to main content

CPython-NEAR WASM optimizer tool

Project description

CPython-NEAR WASM optimizer tool

Allows packaging arbitray Python modules together with the contract source files into a self-contained WASM file ready for running on the NEAR blockchain.

Inputs: python.wasm -- pre-compiled CPython-NEAR WASM python-stdlib.zip -- pre-compiled CPython-NEAR stdlib .pyc files lib/ -- directory with contract source files and arbitrary Python modules to package into the WASM file

Optimizations: Optimizer runs the supplied contract with default arguments (or ones specified via @near.optimizer_inputs() decorator) and traces which Python modules and WASM functions get loaded/called during the runtime, removing unreferenced ones according to the optimization settings specified via -Ox, --module-tracing=1/0, --function-tracing=off/safe/aggressive cmdline arguments.

--function-tracing=safe (-O2 and lower) tries to only remove WASM functions which belong to non-referenced builtin Python modules, which is safer than --function-tracing=aggressive (-O3 and higher), which removes all unreferenced WASM functions except those pinned via DEFAULT_PINNED_FUNCTIONS or --pinned-functions=,,...

Optimized out WASM functions are replaced with a panic handler, which will, in case such a function has still been called during the contract runtime, print a message including the missing function name, which then can be added to the pinned function name list to ensure it is retained.

Additionally, LZ4 compression can be applied to WASM data initializer, which allows up to 500KiB WASM size reduction while consuming ~20Tgas for decompression.

Typical WASM sizes after optimization with json module included (-O4/3/2): 530/560/1363KiB.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cpython_near_wasm_opt-0.8.10-py3-none-win_amd64.whl (13.1 MB view details)

Uploaded Python 3Windows x86-64

cpython_near_wasm_opt-0.8.10-py3-none-macosx_11_0_arm64.whl (7.9 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

cpython_near_wasm_opt-0.8.10-py3-none-macosx_10_9_x86_64.whl (9.0 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file cpython_near_wasm_opt-0.8.10-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.10-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 98464d7ad4373ea93cdf0c874541fb7b35bb8d088f56e74955e8a991758b6b56
MD5 1ce64b1d9f1b83a98b80766f1e1fe685
BLAKE2b-256 71c95daa75b31ed322c8b836ceee0fee5232f61a39d9743a120ed5bfecc69c81

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.10-py3-none-win_amd64.whl:

Publisher: build.yml on past-hypothesis/cpython-near-wasm-opt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpython_near_wasm_opt-0.8.10-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.10-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 85afea74146dfca346aff925160418b9be7d1e77fa8ea22e260664588a9a0b11
MD5 8e52988a3cbc99e00144b824c58f3921
BLAKE2b-256 a70a9f9b79110205e2f920071133d47775999388c6577f4374b9213b5eb55443

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.10-py3-none-manylinux1_x86_64.whl:

Publisher: build.yml on past-hypothesis/cpython-near-wasm-opt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpython_near_wasm_opt-0.8.10-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.10-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7fa971ff13966919af5a8fe3a848d9f03a7006c85d241ddfb8df70bfd3e99001
MD5 c0589d5fd18cf95719f9d17f2592d1d8
BLAKE2b-256 3832464608f29c8e2e3809b3f692570828155b9b18010adb22388d1856ab60ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.10-py3-none-macosx_11_0_arm64.whl:

Publisher: build.yml on past-hypothesis/cpython-near-wasm-opt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpython_near_wasm_opt-0.8.10-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.10-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a129b42c049aec6f3f00b154dd298cb1b57ea88eba25b3b0ced31a9068491a6b
MD5 ff31c801e16e22162f40092fad8acda6
BLAKE2b-256 a570c0bc71ed61501cd98ca2ab74ae87d6d2170f01eaeb964583887d7b60b98a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.10-py3-none-macosx_10_9_x86_64.whl:

Publisher: build.yml on past-hypothesis/cpython-near-wasm-opt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page