@leofcoin/chain 1.10.22 → 1.11.0

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.
Files changed (28) hide show
  1. package/README.md +74 -0
  2. package/exports/browser/beacon-wire.js +2 -2
  3. package/exports/browser/{browser-CCfR9KOM-UO9mzy-j.js → browser-CCfR9KOM-CNWKLusu.js} +3 -3
  4. package/exports/browser/{browser-crypto-CH0ua22L.js → browser-crypto-B_UJguhk.js} +453 -35
  5. package/exports/browser/chain.js +1234 -885
  6. package/exports/browser/{client-DbZBfpG6-CYDyUGUC.js → client-DbZBfpG6-C1cXgvfr.js} +4 -4
  7. package/exports/browser/{connection-monitor-DMGAhcC0.js → connection-monitor-BzbeYGEt.js} +46 -26
  8. package/exports/browser/{index-dTQVgkpf-C6SJ0ZYW.js → index-dTQVgkpf-CkoAiRNX.js} +3 -3
  9. package/exports/browser/{index-dxD17Fom.js → index-phv5KvaE.js} +7 -7
  10. package/exports/browser/{messages-DZYCxoZI-D6kIiLKF.js → messages-DZYCxoZI-B472zldo.js} +3 -3
  11. package/exports/browser/{node-browser-BMfelxXV.js → node-browser-BmyPBkL5.js} +36 -8
  12. package/exports/browser/node-browser.js +3 -3
  13. package/exports/browser/workers/block-worker.js +8 -9
  14. package/exports/browser/workers/machine-worker.js +141 -1195
  15. package/exports/{workers/worker-BDTWOCzS-COrAszCt.js → browser/workers/proposal.proto-8zgMfutf-B3So_tnS.js} +910 -398
  16. package/exports/chain.js +248 -960
  17. package/exports/{connection-monitor-h2L8vsS7.js → connection-monitor-BdFLRh-J.js} +33 -3
  18. package/exports/connection-monitor.js +1 -1
  19. package/exports/{constants-Dy9i9S_o.js → constants-BQ6f-_OT.js} +1 -1
  20. package/exports/hash-format-state.js +3 -3
  21. package/exports/machine.js +550 -0
  22. package/exports/node.js +33 -2
  23. package/exports/state-checkpoint-BiQ1EXzo.js +110 -0
  24. package/exports/state-checkpoint.js +3 -0
  25. package/exports/workers/block-worker.js +8 -9
  26. package/exports/workers/machine-worker.js +141 -1195
  27. package/exports/{browser/workers/worker-BDTWOCzS-COrAszCt.js → workers/proposal.proto-8zgMfutf-B3So_tnS.js} +910 -398
  28. package/package.json +7 -5
package/README.md CHANGED
@@ -18,6 +18,12 @@ from a peer. A pending-only copy cannot act as a provider for the canonical
18
18
  transaction store. Responses must use the expected codec and advertised hash;
19
19
  the first valid response wins, and unavailable content fails explicitly.
20
20
 
21
+ Incoming chain data requests only read the requested local store. Missing,
22
+ private or concurrently removed content receives an empty data response using
23
+ the existing codec and request ID; requesters reject it and can try another
24
+ provider. A local miss never starts a recursive peer fetch, and read/send
25
+ failures are logged without rejecting the transport's detached handler.
26
+
21
27
  Historical ancestry is resolved iteratively, finishing transaction dependencies
22
28
  before requesting the next parent. Duplicate callers await the same resolution,
23
29
  completed blocks survive retries, and missing or cyclic ancestry fails explicitly.
@@ -27,6 +33,74 @@ Transaction bodies are hash-checked before entering the canonical transaction
27
33
  store. Resolving data never applies it: canonical loading still uses the
28
34
  serialized state writer and chain-link validation.
29
35
 
36
+ ## Crash recovery and checkpoints
37
+
38
+ State snapshots use two alternating, checksummed `checkpoint:0` / `checkpoint:1`
39
+ records. Each record binds the chain ID and canonical tip to the **complete**
40
+ contract state, committed account nonces and financial counters. An interrupted
41
+ write leaves the previous verified slot available. Storage I/O errors propagate;
42
+ if neither existing slot validates, startup refuses readiness rather than
43
+ inventing balances or resetting counters. Preserve that root and rebuild into a
44
+ separate data root when both checkpoints are unrecoverable.
45
+
46
+ Startup verifies the ancestry of the checkpoint and persisted recovery target,
47
+ restores derived nonces, then replays only the unapplied suffix through the same
48
+ signature, validator, economics and serialized execution path as live blocks.
49
+ A durable recovery target preserves a multi-block replay across another crash.
50
+ The tip is checkpointed before updating the chain marker or announcing success.
51
+ Local transaction bytes are not considered evidence of prior execution;
52
+ committed sender nonces prevent executing a transfer twice.
53
+
54
+ Older, split `lastBlock` / `states` / `accounts` / `info` snapshots are not trusted
55
+ as coherent checkpoints. On first startup they are rebuilt from their hash-checked
56
+ block ancestry and validated transactions, without removing ledger or identity
57
+ files. Missing historical content or invalid execution stops recovery explicitly.
58
+ No new genesis is required for this local storage change.
59
+
60
+ Build `@leofcoin/workers` before `@leofcoin/chain` and deploy matching artifacts;
61
+ the worker now exposes a serialized full-snapshot operation and no longer owns a
62
+ separate startup-replay implementation. Process-isolated LevelDB tests exercise
63
+ normal restarts, crashes before/during/after checkpoint writes and marker writes,
64
+ plus invalid producer proofs and execution failures. These tests do not establish
65
+ live multi-peer consensus correctness or protection against arbitrary disk loss.
66
+
67
+ ## Contract calls and read isolation
68
+
69
+ Public `call(transaction)` now accepts a **signed transaction object**, not the
70
+ old `(contract, method, params)` direct-execution form. `transfer(transaction)`
71
+ likewise requires a signed native-token transfer. Both use `sendTransaction()`:
72
+ admission returns a pending handle; only canonical execution changes state.
73
+ Caller-supplied `hash` metadata is ignored and recomputed from signed content.
74
+ `internalCall(sender, ...)` no longer permits public sender impersonation, and
75
+ native minting is reserved for the monetary protocol. CLI/wallet helpers that
76
+ already sign and submit transactions keep working.
77
+
78
+ `staticCall(contract, method, params = [])` queries an isolated worker restored
79
+ from the last committed snapshot, with `msg.sender = 'leofcoin:read-only'`.
80
+ It never uses the node's selected account as read authority. Mutating getters
81
+ and methods are rejected when their exported state changes; nested mutating
82
+ `msg.call()` is denied. Results are cloned, so returned references cannot alter
83
+ canonical state or cached results. Private validator snapshot bookkeeping stays
84
+ inside the canonical block writer; name-service lookup uses the read path.
85
+
86
+ Contract-to-contract `msg.staticCall()` during execution uses a separate read
87
+ worker seeded from the transaction's current in-flight state and retains the
88
+ calling contract as sender. A rejected nested mutation rejects execution; it
89
+ does not mutate the queried canonical contract. Code instrumentation is cached,
90
+ but evaluated classes and closures are reconstructed for each uncached query.
91
+
92
+ Workers are lazy and reused. Public read queues are capped at 32; queries at
93
+ 64 KiB; results and the result cache at 4 MiB (maximum 64 entries). Instrumented
94
+ code caches are bounded to 8 MiB/128 entries. Reads time out after 10 seconds;
95
+ execution metering still applies. A committed snapshot invalidates result caches.
96
+ Use `machine.close()` to release the canonical and both lazy query workers.
97
+ Nested static-call execution rules are stricter than in older runtimes: coordinate
98
+ the rollout across all validators before producing blocks; do not mix execution
99
+ policies within one active network.
100
+ This is state separation, not an OS security sandbox or a full audit of arbitrary
101
+ JavaScript host-escape resistance. Consensus quorum certificates and durable
102
+ validator vote locks remain separate follow-up work.
103
+
30
104
  ## Pending transaction propagation
31
105
 
32
106
  Transactions enter the local pending pool before canonical confirmation. Peers
@@ -1,6 +1,6 @@
1
- import { s as signTransaction, c as MultiWallet, d as createTransactionHash } from './index-dxD17Fom.js';
1
+ import { s as signTransaction, c as MultiWallet, d as createTransactionHash } from './index-phv5KvaE.js';
2
2
  import { f as fromBase58 } from './index-CvKt4UDE.js';
3
- import './browser-crypto-CH0ua22L.js';
3
+ import './browser-crypto-B_UJguhk.js';
4
4
  import './sha2-BKcEJzgd.js';
5
5
 
6
6
  const validInteger = (value, minimum = 0n) => {
@@ -1,8 +1,8 @@
1
- import { g as getDefaultExportFromCjs } from './node-browser-BMfelxXV.js';
2
- import './browser-crypto-CH0ua22L.js';
1
+ import { g as getDefaultExportFromCjs } from './node-browser-BmyPBkL5.js';
2
+ import './browser-crypto-B_UJguhk.js';
3
3
  import './index-CvKt4UDE.js';
4
4
  import './sha2-BKcEJzgd.js';
5
- import './connection-monitor-DMGAhcC0.js';
5
+ import './connection-monitor-BzbeYGEt.js';
6
6
 
7
7
  function _mergeNamespaces$1(n, m) {
8
8
  m.forEach(function (e) {