@smartledger/bsv 9.6.0 → 9.7.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,87 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [9.7.0] - 2026-09-05
11
+
12
+ ### Fixed — the stack limits diverged from the node in both directions
13
+
14
+ The last of the pre-Genesis caps still applied as a literal, and the only one
15
+ left that `useGenesisLimits()` could not reach:
16
+
17
+ ```js
18
+ // after the whole script had run:
19
+ if (this.stack.length + this.altstack.length > 1000) {
20
+ ```
21
+
22
+ Two divergences in five lines.
23
+
24
+ **It was checked once, at the end of the script.** The node checks after every
25
+ opcode. A script that piles up 1,001 elements and drops back to one before it
26
+ finishes passed here and is rejected by the network — a false accept, in the
27
+ direction that costs money:
28
+
29
+ ```
30
+ pre-Genesis, 1001 pushes then 500 OP_2DROPs
31
+ before: accepted
32
+ node: SCRIPT_ERR_STACK_SIZE
33
+ ```
34
+
35
+ No vector in the corpus catches it: every `STACK_SIZE` vector *ends* over the
36
+ cap, which is exactly the case an end-of-script check does see. The regression
37
+ test uses `OP_2DROP` deliberately — it clears two elements per opcode and so
38
+ lands inside the pre-Genesis 500-opcode budget, where 1,001 `OP_DROP`s would
39
+ trip `SCRIPT_ERR_OP_COUNT` and pass the assertion for the wrong reason.
40
+
41
+ **And it was applied after Genesis, which removed it.** Genesis replaced the
42
+ element COUNT with a bound on the memory the two stacks occupy, so that a script
43
+ is limited by what it uses rather than by how it is divided up. Carrying 1000
44
+ unconditionally rejected post-Genesis scripts the network accepts:
45
+
46
+ ```
47
+ post-Genesis, 1001 elements before: SCRIPT_ERR_STACK_SIZE after: accepted
48
+ post-Genesis, 5000 elements before: SCRIPT_ERR_STACK_SIZE after: accepted
49
+ ```
50
+
51
+ The shape that finds it in practice is a 256-step elliptic-curve ladder, which
52
+ needs a witness value per step: over seven hundred elements for one scalar
53
+ multiplication, and two of those in an ECDSA verification.
54
+
55
+ Same shape as 9.4.0, 9.5.0 and 9.6.0 — a limit that was correct when it was
56
+ written, left static while the rest became era-derived. Now:
57
+
58
+ ```js
59
+ Interpreter.prototype.maxStackSize() // 1000 before Genesis, UNLIMITED after
60
+ Interpreter.prototype.maxStackMemoryUsage() // UNLIMITED before, 100 MB policy after
61
+ Interpreter.prototype.stackMemoryUsage() // bytes + per-element container overhead
62
+ Interpreter.prototype.checkStackLimits() // called after every opcode
63
+ ```
64
+
65
+ `MAX_STACK_MEMORY_USAGE_AFTER_GENESIS` is **`UNLIMITED`**, because post-Genesis
66
+ consensus is unbounded. The node's 100 MB figure is `-maxstackmemoryusagepolicy`,
67
+ a RELAY setting, and defaulting to it would have refused scripts the network
68
+ accepts — the same mistake as carrying the 1000-element cap past Genesis, in the
69
+ same function. It is kept as `STACK_MEMORY_USAGE_POLICY` for anyone who wants it:
70
+
71
+ ```js
72
+ Interpreter.MAX_STACK_MEMORY_USAGE_AFTER_GENESIS =
73
+ Interpreter.STACK_MEMORY_USAGE_POLICY
74
+ ```
75
+
76
+ Unbounded means a hostile script can allocate until the process runs out of
77
+ memory — the same trade `useGenesisLimits(max)` already documents for element
78
+ size. A validator taking scripts from strangers should set a ceiling matched to
79
+ its workload.
80
+
81
+ `STACK_ELEMENT_OVERHEAD` is 32 bytes, charged per element on top of its contents
82
+ because the container is not free either. It is only consulted once a caller has
83
+ set a ceiling, and 32 is deliberately conservative: a bare `std::vector<uint8_t>`
84
+ is 24 bytes on the common 64-bit ABIs.
85
+
86
+ Keeping the default unbounded also keeps the new per-opcode check O(1): with no
87
+ ceiling to test against, the O(n) memory scan is skipped. A post-Genesis script
88
+ holding 900 elements across 40,000 opcodes measures 42.6 ms, against 42.8 ms
89
+ before this change.
90
+
10
91
  ## [9.6.0] - 2026-09-02
11
92
 
12
93
  ### Fixed — a post-Genesis `OP_CHECKMULTISIG` was refused by a cap the era removed
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Bitcoin SV library with an interpreter-verified script engine.
4
4
 
5
- [![Version](https://img.shields.io/badge/version-9.6.0-blue.svg)](https://www.npmjs.com/package/@smartledger/bsv)
5
+ [![Version](https://img.shields.io/badge/version-9.7.0-blue.svg)](https://www.npmjs.com/package/@smartledger/bsv)
6
6
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
7
7
  [![Stability](https://img.shields.io/badge/9.x%20stable%20until-2027--09--01-brightgreen.svg)](STABILITY.md)
8
8
 
@@ -155,44 +155,44 @@ const bsv = require('@smartledger/bsv') // 128 modules
155
155
  ### **Core Modules**
156
156
  | Module | Size | Use Case | CDN |
157
157
  |--------|------|----------|-----|
158
- | **bsv.min.js** | 1045KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.6.0/bsv.min.js` |
159
- | **bsv.bundle.js** | 1045KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.6.0/bsv.bundle.js` |
158
+ | **bsv.min.js** | 1046KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.7.0/bsv.min.js` |
159
+ | **bsv.bundle.js** | 1046KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.7.0/bsv.bundle.js` |
160
160
 
161
161
  ### **W3C Verifiable Credentials**
162
162
  | Module | Size | Use Case | CDN |
163
163
  |--------|------|----------|-----|
164
- | **🟢 bsv-didweb.min.js** | 166KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@9.6.0/bsv-didweb.min.js` |
165
- | **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.6.0/bsv-vcjwt.min.js` |
166
- | **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.6.0/bsv-statuslist.min.js` |
167
- | **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.6.0/bsv-anchor.min.js` |
164
+ | **🟢 bsv-didweb.min.js** | 166KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@9.7.0/bsv-didweb.min.js` |
165
+ | **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.7.0/bsv-vcjwt.min.js` |
166
+ | **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.7.0/bsv-statuslist.min.js` |
167
+ | **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.7.0/bsv-anchor.min.js` |
168
168
 
169
169
  ### **Smart Contract & Development**
170
170
  | Module | Size | Use Case | CDN |
171
171
  |--------|------|----------|-----|
172
- | **bsv-smartcontract.min.js** | 141KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.6.0/bsv-smartcontract.min.js` |
173
- | **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.6.0/bsv-covenant.min.js` |
174
- | **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.6.0/bsv-script-helper.min.js` |
175
- | **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.6.0/bsv-security.min.js` |
172
+ | **bsv-smartcontract.min.js** | 141KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.7.0/bsv-smartcontract.min.js` |
173
+ | **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.7.0/bsv-covenant.min.js` |
174
+ | **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.7.0/bsv-script-helper.min.js` |
175
+ | **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.7.0/bsv-security.min.js` |
176
176
 
177
177
  ### **Legal & Compliance**
178
178
  | Module | Size | Use Case | CDN |
179
179
  |--------|------|----------|-----|
180
- | **bsv-ltp.min.js** | 539KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.6.0/bsv-ltp.min.js` |
181
- | **bsv-gdaf.min.js** | 1045KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.6.0/bsv-gdaf.min.js` |
180
+ | **bsv-ltp.min.js** | 540KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.7.0/bsv-ltp.min.js` |
181
+ | **bsv-gdaf.min.js** | 1046KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.7.0/bsv-gdaf.min.js` |
182
182
 
183
183
  ### **Advanced Cryptography**
184
184
  | Module | Size | Use Case | CDN |
185
185
  |--------|------|----------|-----|
186
- | **bsv-shamir.min.js** | 177KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@9.6.0/bsv-shamir.min.js` |
186
+ | **bsv-shamir.min.js** | 177KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@9.7.0/bsv-shamir.min.js` |
187
187
 
188
188
  ### **Utilities**
189
189
  | Module | Size | Use Case | CDN |
190
190
  |--------|------|----------|-----|
191
- | **bsv-ecies.min.js** | 137KB | Encryption | `unpkg.com/@smartledger/bsv@9.6.0/bsv-ecies.min.js` |
192
- | **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.6.0/bsv-message.min.js` |
193
- | **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.6.0/bsv-mnemonic.min.js` |
191
+ | **bsv-ecies.min.js** | 137KB | Encryption | `unpkg.com/@smartledger/bsv@9.7.0/bsv-ecies.min.js` |
192
+ | **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.7.0/bsv-message.min.js` |
193
+ | **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.7.0/bsv-mnemonic.min.js` |
194
194
  ```html
195
- <script src="https://unpkg.com/@smartledger/bsv@9.6.0/bsv.min.js"></script>
195
+ <script src="https://unpkg.com/@smartledger/bsv@9.7.0/bsv.min.js"></script>
196
196
  <script>
197
197
  const key = bsv.PrivateKey.fromRandom()
198
198
  </script>
@@ -240,4 +240,4 @@ MIT
240
240
 
241
241
  ---
242
242
 
243
- **SmartLedger-BSV v9.6.0**
243
+ **SmartLedger-BSV v9.7.0**