zexus 1.7.2 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -6
- package/package.json +2 -1
- package/rust_core/Cargo.lock +603 -0
- package/rust_core/Cargo.toml +26 -0
- package/rust_core/README.md +15 -0
- package/rust_core/pyproject.toml +25 -0
- package/rust_core/src/binary_bytecode.rs +543 -0
- package/rust_core/src/contract_vm.rs +643 -0
- package/rust_core/src/executor.rs +847 -0
- package/rust_core/src/hasher.rs +90 -0
- package/rust_core/src/lib.rs +71 -0
- package/rust_core/src/merkle.rs +128 -0
- package/rust_core/src/rust_vm.rs +2313 -0
- package/rust_core/src/signature.rs +79 -0
- package/rust_core/src/state_adapter.rs +281 -0
- package/rust_core/src/validator.rs +116 -0
- package/scripts/postinstall.js +34 -2
- package/src/zexus/__init__.py +1 -1
- package/src/zexus/blockchain/accelerator.py +27 -0
- package/src/zexus/blockchain/contract_vm.py +409 -3
- package/src/zexus/blockchain/rust_bridge.py +64 -0
- package/src/zexus/cli/main.py +1 -1
- package/src/zexus/cli/zpm.py +1 -1
- package/src/zexus/evaluator/bytecode_compiler.py +150 -52
- package/src/zexus/evaluator/core.py +151 -809
- package/src/zexus/evaluator/expressions.py +27 -22
- package/src/zexus/evaluator/functions.py +171 -126
- package/src/zexus/evaluator/statements.py +55 -112
- package/src/zexus/module_cache.py +20 -9
- package/src/zexus/object.py +330 -38
- package/src/zexus/parser/parser.py +69 -14
- package/src/zexus/parser/strategy_context.py +228 -5
- package/src/zexus/parser/strategy_structural.py +2 -2
- package/src/zexus/persistence.py +46 -17
- package/src/zexus/security.py +140 -234
- package/src/zexus/type_checker.py +44 -5
- package/src/zexus/vm/binary_bytecode.py +7 -3
- package/src/zexus/vm/bytecode.py +6 -0
- package/src/zexus/vm/cache.py +24 -46
- package/src/zexus/vm/compiler.py +80 -20
- package/src/zexus/vm/fastops.c +1093 -2975
- package/src/zexus/vm/gas_metering.py +2 -2
- package/src/zexus/vm/memory_pool.py +21 -9
- package/src/zexus/vm/vm.py +527 -67
- package/src/zexus/zpm/package_manager.py +1 -1
- package/src/zexus.egg-info/PKG-INFO +79 -12
- package/src/zexus.egg-info/SOURCES.txt +23 -1
- package/src/zexus.egg-info/requires.txt +26 -0
- package/src/zexus.egg-info/entry_points.txt +0 -4
|
@@ -59,7 +59,7 @@ class GasCost(IntEnum):
|
|
|
59
59
|
CALL_TOP = 10
|
|
60
60
|
CALL_METHOD = 10
|
|
61
61
|
CALL_BUILTIN = 8
|
|
62
|
-
STORE_FUNC =
|
|
62
|
+
STORE_FUNC = 3 # Aligned with Rust — function storage is a cheap memory op
|
|
63
63
|
BUILD_LAMBDA = 5
|
|
64
64
|
|
|
65
65
|
# Async operations
|
|
@@ -71,7 +71,7 @@ class GasCost(IntEnum):
|
|
|
71
71
|
VERIFY_SIGNATURE = 100
|
|
72
72
|
MERKLE_ROOT = 30 # Base cost, + per leaf
|
|
73
73
|
STATE_READ = 20
|
|
74
|
-
STATE_WRITE =
|
|
74
|
+
STATE_WRITE = 30 # Reduced: RustStateAdapter caching makes writes memory-local
|
|
75
75
|
TX_BEGIN = 20
|
|
76
76
|
TX_COMMIT = 30
|
|
77
77
|
TX_REVERT = 20
|
|
@@ -315,20 +315,32 @@ class ListPool:
|
|
|
315
315
|
return [None] * size
|
|
316
316
|
|
|
317
317
|
pool = self.pools[size]
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
318
|
+
hits_before = pool.stats.hits
|
|
319
|
+
misses_before = pool.stats.misses
|
|
320
|
+
|
|
321
|
+
# IMPORTANT: Do not allocate a new list as a "default" argument here.
|
|
322
|
+
# The pool already has a list factory; allocating on every call defeats pooling.
|
|
323
|
+
lst = pool.acquire()
|
|
324
|
+
|
|
325
|
+
# Update aggregate stats (per-call)
|
|
326
|
+
was_hit = pool.stats.hits != hits_before
|
|
327
|
+
was_miss = pool.stats.misses != misses_before
|
|
328
|
+
if was_hit:
|
|
322
329
|
self.stats.hits += 1
|
|
323
330
|
self.stats.reuses += 1
|
|
324
|
-
|
|
331
|
+
elif was_miss:
|
|
325
332
|
self.stats.misses += 1
|
|
326
333
|
self.stats.total_created += 1
|
|
327
|
-
|
|
334
|
+
|
|
328
335
|
# Ensure list is the right size and cleared
|
|
329
|
-
if
|
|
330
|
-
lst
|
|
331
|
-
|
|
336
|
+
if size == 0:
|
|
337
|
+
if lst:
|
|
338
|
+
lst.clear()
|
|
339
|
+
elif len(lst) != size:
|
|
340
|
+
lst[:] = [None] * size
|
|
341
|
+
else:
|
|
342
|
+
# Fast reset for correct-size lists
|
|
343
|
+
lst[:] = [None] * size
|
|
332
344
|
|
|
333
345
|
return lst
|
|
334
346
|
|