Skip to content

Commit c19c670

Browse files
committed
Add BCH_2026_05, add VM benchmarking
1 parent 1f34ca4 commit c19c670

File tree

81 files changed

+17709
-7635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+17709
-7635
lines changed

.changeset/happy-insects-wait.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@bitauth/libauth': patch
3+
---
4+
5+
Add BCH_2026_05, add VM benchmarking

.cspell.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
"regtest",
149149
"reversebytes",
150150
"ripemd",
151+
"rkalis",
151152
"RSHIFT",
152153
"rustup",
153154
"satoshi",
@@ -172,6 +173,7 @@
172173
"substack",
173174
"templating",
174175
"testnet",
176+
"tinybench",
175177
"TOALTSTACK",
176178
"tprv",
177179
"tpub",

.pnp.cjs

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vscode/launch.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"name": "Debug VMB Test",
3333
"runtimeExecutable": "yarn",
3434
"runtimeArgs": ["run", "test:unit:vmb_test"],
35-
"args": ["bch_spec_standard", "06ty9", "-v"],
35+
"args": ["${input:vmVersion}", "${input:vmbTestShortId}", "-v"],
3636
"outputCapture": "std",
3737
"console": "integratedTerminal",
3838
"skipFiles": ["<node_internals>/**"],
@@ -49,5 +49,29 @@
4949
"skipFiles": ["<node_internals>/**"],
5050
"preLaunchTask": "npm: build"
5151
}
52+
],
53+
"inputs": [
54+
{
55+
"id": "vmbTestShortId",
56+
"description": "Please enter a VMB test ID",
57+
"default": "vdqk6",
58+
"type": "promptString"
59+
},
60+
{
61+
"id": "vmVersion",
62+
"description": "Please choose a VM version",
63+
"type": "pickString",
64+
"options": [
65+
"bch_2023_standard",
66+
"bch_2023_nonstandard",
67+
"bch_2025_standard",
68+
"bch_2025_nonstandard",
69+
"bch_2026_standard",
70+
"bch_2026_nonstandard",
71+
"bch_spec_standard",
72+
"bch_spec_nonstandard"
73+
],
74+
"default": "bch_spec_standard"
75+
}
5276
]
5377
}
File renamed without changes.

docs/verify-transactions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,22 @@ if (typeof result === 'string') {
4343
}
4444
```
4545

46-
For examples of the kind of error messages that `vm.verify` might return, see [`bch_vmb_tests_2022_invalid_reasons.json`](../src/lib/vmb-tests/generated/bch/bch_vmb_tests_2022_invalid_reasons.json) and [`bch_vmb_tests_2022_nonstandard_reasons.json`](../src/lib/vmb-tests/generated/bch/bch_vmb_tests_2022_nonstandard_reasons.json)/.
46+
For examples of the kind of error messages that `vm.verify` might return, see [`bch_vmb_tests_2025_invalid_reasons.json`](../src/lib/vmb-tests/generated/bch_vmb_tests_2025_invalid_reasons.json) and [`bch_vmb_tests_2025_nonstandard_reasons.json`](../src/lib/vmb-tests/generated/bch_vmb_tests_2025_nonstandard_reasons.json)/.
4747

4848
## Debugging Evaluations
4949

50-
A complete example of transaction verification and evaluation debugging is available in [`bch-vmb-test.spec.helper.ts`](src/lib/vmb-tests/bch-vmb-test.spec.helper.ts), which is used by the `yarn test:unit:vmb_test` CLI command. E.g.:
50+
A complete example of transaction verification and evaluation debugging is available in [`run-bch-vmb-test.spec.helper.ts`](src/lib/vmb-tests/run-bch-vmb-test.spec.helper.ts), which is used by the `yarn test:unit:vmb_test` CLI command. E.g.:
5151

5252
```sh
53-
❯ yarn test:unit:vmb_test bch_2023_standard dv5k4
53+
❯ yarn test:unit:vmb_test bch_2025_standard dv5k4
5454

5555
VMB test ID: dv5k4
5656
Description: Basic push operations: OP_0 (A.K.A. OP_PUSHBYTES_0, OP_FALSE): zero is represented by an empty stack item (P2SH20)
57-
Test sets: 2022_standard
57+
Test sets: 2025_standard, 2025_standard
5858

5959
Unlocking ASM: OP_0
6060
Redeem (P2SH20) ASM: OP_SIZE <0> OP_EQUAL OP_NIP
61-
Result: Success
61+
Result (VM: bch_2025_standard): Transaction accepted
6262
Evaluation at index 1:
6363

6464
0. OP_0: 0x(0)
@@ -76,7 +76,7 @@ Evaluation at index 1:
7676

7777
```
7878

79-
For extended debugging information, try the `-v` flag, e.g. `yarn test:unit:vmb_test bch_2023_standard dv5k4 -v`.
79+
For extended debugging information, try the `-v` flag, e.g. `yarn test:unit:vmb_test bch_2025_standard dv5k4 -v`.
8080

8181
For a more advanced example of transaction debugging, including mapping of evaluation results to CashAssembly source positions ([`extractEvaluationSamplesRecursive`](https://libauth.org/functions/extractEvaluationSamplesRecursive.html)), see [Bitauth IDE's `editor-state.ts`](https://github.com/bitauth/bitauth-ide/blob/master/src/editor/editor-state.ts).
8282

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
"fix:eslint": "yarn test:eslint --fix",
4747
"gen:vmb_tests": "yarn build && yarn gen:vmb_tests:bch && yarn gen:vmb_tests-prettier",
4848
"gen:vmb_tests-prettier": "prettier 'src/lib/vmb-tests/generated/**/*.json' --write",
49-
"gen:vmb_tests:bch": "node --enable-source-maps 'build/lib/vmb-tests/bch-vmb-tests.spec.helper.js' 'src/lib/vmb-tests/generated/bch' && yarn run gen:vmb_tests:bch:reasons",
50-
"gen:vmb_tests:bch:reasons": "node --enable-source-maps 'build/lib/vmb-tests/bch-vmb-tests-invalid.spec.helper.js'",
51-
"wallet": "node --enable-source-maps 'build/lib/vmb-tests/bch-vmb-tests.live.spec.helper.js'",
49+
"gen:vmb_tests:bch": "node --enable-source-maps 'build/lib/vmb-tests/write-bch-vmb-tests.spec.helper.js' 'src/lib/vmb-tests/generated' && yarn run gen:vmb_tests:bch:reasons",
50+
"gen:vmb_tests:bch:reasons": "node --enable-source-maps 'build/lib/vmb-tests/write-reasons-bch-vmb-tests.spec.helper.js'",
51+
"wallet": "node --enable-source-maps 'build/lib/vmb-tests/run-live-bch-vmb-test.spec.helper.js'",
5252
"gen:schema": "yarn gen:schema:wallet-template && yarn gen:schema:bcmr",
5353
"gen:schema:wallet-template": "ts-json-schema-generator --no-ref-encode --path 'src/lib/engine/types/template-types.ts' --type 'WalletTemplate' > src/lib/schema/wallet-template.schema.json && prettier 'src/lib/schema/wallet-template.schema.json' --write && ajv compile -s src/lib/schema/wallet-template.schema.json --allowUnionTypes -o src/lib/schema/ajv/validate-wallet-template.js && prettier 'src/lib/schema/ajv/validate-wallet-template.js' --write && node -e \"const fs = require('fs'), path = 'src/lib/schema/ajv/validate-wallet-template.js'; fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace(/'use strict'[\\s\\S]*module.exports.default =/, 'export default'), 'utf8')\"",
5454
"gen:schema:bcmr": "ts-json-schema-generator --no-ref-encode --path 'src/lib/engine/types/bcmr-types.ts' --type 'MetadataRegistry' > src/lib/schema/bcmr.schema.json && prettier 'src/lib/schema/bcmr.schema.json' --write && ajv compile -s src/lib/schema/bcmr.schema.json --allowUnionTypes -o src/lib/schema/ajv/validate-bcmr.js && prettier 'src/lib/schema/ajv/validate-bcmr.js' --write && node -e \"const fs = require('fs'), path = 'src/lib/schema/ajv/validate-bcmr.js'; fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace(/'use strict'[\\s\\S]*module.exports.default =/, 'export default'), 'utf8')\"",
@@ -69,10 +69,11 @@
6969
"test:fast": "echo '\n\nUsage:\n yarn test:fast src/lib/key/bip39.spec.ts # run a single test file \n yarn test:fast --match=\"!*crypto*\" --match=\"!*vmb_tests*\" # include/exclude tests with names matching pattern(s) \n\n' && ava -v",
7070
"test:unit:script_tests": "c8 ava --match='*[script_tests]*' --serial",
7171
"test:unit:vmb_tests": "c8 ava src/lib/vmb-tests/bch-vmb-tests.spec.ts --serial",
72-
"test:unit:vmb_test": "node --enable-source-maps 'build/lib/vmb-tests/bch-vmb-test.spec.helper.js'",
72+
"test:unit:vmb_test": "node --enable-source-maps 'build/lib/vmb-tests/run-bch-vmb-test.spec.helper.js'",
7373
"dev:vmb_tests": "yarn gen:vmb_tests && yarn build:tsc && ava src/lib/vmb-tests/bch-vmb-tests.spec.ts --serial --fail-fast",
74-
"bench": "yarn build && yarn bench:browser-deps && yarn bench:test",
75-
"bench:test": "ava --config .ava.bench.config.js --serial --timeout=2m 2>&1 | tee bench.log",
74+
"bench:vmb_tests": "ava src/lib/vmb-tests/benchmark-bch-vmb-tests.spec.ts --serial",
75+
"bench": "yarn build && yarn bench:browser-deps && yarn bench:vmb_tests && yarn bench:test",
76+
"bench:test": "ava --config config/.ava.bench.config.js --serial --timeout=2m 2>&1 | tee bench.log",
7677
"bench:browser-deps": "cpy '.yarn/artifacts/*.js' build/bench",
7778
"watch": "yarn build -w",
7879
"watch:test": "echo '\n\nUsage:\n yarn watch:test src/lib/key/bip39.spec.ts # watch a single test file \n yarn watch:test --match=\"!*crypto*\" --match=\"!*vmb_tests*\" # include/exclude tests with names matching pattern(s) \n\n' && ava -v --watch",
@@ -135,6 +136,7 @@
135136
"rollup": "^4.9.4",
136137
"secp256k1": "^5.0.0",
137138
"source-map-support": "^0.5.21",
139+
"tinybench": "^2.8.0",
138140
"ts-json-schema-generator": "^1.5.0",
139141
"typedoc": "^0.25.7",
140142
"typescript": "^5.3.3"
@@ -177,7 +179,7 @@
177179
"overrides": [
178180
{
179181
"files": [
180-
"src/lib/vmb-tests/*bch-vmb-tests*.ts"
182+
"src/lib/vmb-tests/**/*bch-vmb-tests*.ts"
181183
],
182184
"options": {
183185
"printWidth": 400

src/lib/compiler/compiler-bch/compiler-bch.e2e.evaluations.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ test(
7373
errors: [
7474
{
7575
error:
76-
'Both a VM and a createState method are required to reduce evaluations.',
76+
'Both a VM and a createAuthenticationProgram method are required to reduce evaluations.',
7777
range: {
7878
endColumn: 15,
7979
endLineNumber: 1,
@@ -89,7 +89,7 @@ test(
8989
);
9090

9191
test(
92-
'[BCH compiler] evaluations - requires createState',
92+
'[BCH compiler] evaluations - requires createAuthenticationProgram',
9393
expectCompilationResult,
9494
'$( OP_1 OP_2 )',
9595
{},
@@ -98,7 +98,7 @@ test(
9898
errors: [
9999
{
100100
error:
101-
'Both a VM and a createState method are required to reduce evaluations.',
101+
'Both a VM and a createAuthenticationProgram method are required to reduce evaluations.',
102102
range: {
103103
endColumn: 15,
104104
endLineNumber: 1,

src/lib/compiler/compiler-bch/compiler-bch.e2e.p2sh.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ test(
203203
errors: [
204204
{
205205
error:
206-
'Both a VM and a createState method are required to reduce evaluations.',
206+
'Both a VM and a createAuthenticationProgram method are required to reduce evaluations.',
207207
range: {
208208
endColumn: 44,
209209
endLineNumber: 1,

0 commit comments

Comments
 (0)