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.12-py3-none-win_amd64.whl (13.1 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3macOS 11.0+ ARM64

cpython_near_wasm_opt-0.8.12-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.12-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.12-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9a26933c3ebdc940712be093cf427d1861c35f82b7025584f99b1b605b510cc9
MD5 74496a6282084af416b71c1f91f95079
BLAKE2b-256 1016c3d198fe22e3c97bec6a4fb9fb876dbf7e8d1fc4ea9f7dcca64da5ae2e8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.12-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.12-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.12-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7fb6424324cc28bd683ac154d5e9ad9803ef1c4301f87366c0ade4203eed61bf
MD5 7dd806ee91830a9cad0f169434f3fe7e
BLAKE2b-256 ba3b20702b3df7e4b2ff3dcb49e5f759a2d54946bfd8f06c2e6c2f362fcee405

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.12-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.12-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.12-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f0880013e68b0bb16974d6954e348a3ea405826fa1b16b7315aefdc44cffb61
MD5 28a649c5fcf2dc1686e165b81869a0c3
BLAKE2b-256 bea7d90eac28b4a88b8aac4edbc60397eeab1e3ebd3796f6f1152accd7bb4301

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.12-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.12-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.12-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f7c9c075437673925ecd2ee15f28f9f5998e9c2df8013bc525e56479620ff132
MD5 4ea9bd0a4dca8eed5f5e0b8593e679c8
BLAKE2b-256 1724e18927dbbb60178ab57db31affa6eccae79e7a9f0fa5a5eb3799364cc853

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.12-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