Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 2025 and 2026 proposed VMs, add VM benchmarks #134

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/curvy-pandas-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@bitauth/libauth': patch
---

Update `isStandardOutputBytecode` to allow P2SH32

Fixes #133. Thanks for the report @rkalis!
5 changes: 5 additions & 0 deletions .changeset/famous-spies-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': patch
---

Fix OP_TXVERSION VMB tests, reduce 2025 nonstandard hashing density limit
7 changes: 7 additions & 0 deletions .changeset/great-ducks-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@bitauth/libauth': minor
---

Deprecate `BCH_2022_05` VM, add `BCH_2023_05`, `BCH_2025_05`, and `BCH_SPEC` VMs, update vmb_tests

Additionally, all exports have been renamed to more consistently adhere to the `camelCase` capitalization style, without exceptions for abbreviations. For example `assembleBytecodeBCH` is now `assembleBytecodeBch`. To ensure backwards-compatibility, aliases (marked with `@deprecated` TSdoc tags) are also exported using the old capitalization. These aliases will be removed in a future major version.
5 changes: 5 additions & 0 deletions .changeset/happy-insects-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': patch
---

Add BCH_2026_05, add VM benchmarking
5 changes: 5 additions & 0 deletions .changeset/nervous-carrots-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': patch
---

Run VMB benchmarks in CI
5 changes: 5 additions & 0 deletions .changeset/orange-suits-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': patch
---

clarify `generateDeterministicEntropy` usage examples
9 changes: 9 additions & 0 deletions .changeset/sour-ties-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@bitauth/libauth': patch
---

Begin implementation of BCH_2025_05 and BCH_SPEC

- Revised `AuthenticationVirtualMachine` to remove `clone` (obviated by wide availability of `structuredClone`) and add `initialize`, allowing VM proposals to add to the program state of an existing VM (in a type-safe way) without duplicating its unchanged logic.
- Clarified documentation around contributing upgrade proposals to Libauth VMs
- Allow usage of any `BCH_SPEC` opcodes in `assembleBytecodeBch`/`disassembleBytecodeBch`
4 changes: 3 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"authchain",
"authchains",
"authhead",
"BCHCHIPs",
"bchn",
"bchreg",
"bchtest",
Expand All @@ -40,6 +39,7 @@
"cashaddr",
"CASHTOKENS",
"Chaingraph",
"checkbits",
"CHECKDATASIG",
"CHECKDATASIGVERIFY",
"CHECKLOCKTIMEVERIFY",
Expand Down Expand Up @@ -149,6 +149,7 @@
"regtest",
"reversebytes",
"ripemd",
"rkalis",
"RSHIFT",
"rustup",
"satoshi",
Expand All @@ -173,6 +174,7 @@
"substack",
"templating",
"testnet",
"tinybench",
"TOALTSTACK",
"tprv",
"tpub",
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,32 @@ jobs:
CI_NODE_INDEX: ${{ matrix.runner_index }}
CI_NODE_TOTAL: ${{ matrix.runners_per_version }}
- run: yarn cov:lcov
if: ${{ matrix.node-version }} == 20
if: ${{ matrix.node-version == 20 }}
- name: Upload test coverage
if: ${{ matrix.node-version }} == 20
if: ${{ matrix.node-version == 20 }}
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

vmb-benchmarks:
runs-on: ubuntu-latest
strategy:
fail-fast: false
name: Run VMB Benchmarks
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- run: yarn install --immutable --immutable-cache
- run: yarn build
- run: yarn bench:vmb_tests

check-policies:
runs-on: ubuntu-latest
name: Check Policies
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ coverage
report.*.json
scratch
gitignore.*
*.cpuprofile

src/lib/bin/**/*.html
src/lib/bin/**/*.js
Expand Down
11 changes: 11 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 74 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,81 @@
"runtimeExecutable": "yarn",
"runtimeArgs": ["run", "ava"],
"args": ["${file}"],
// "args": ["--serial", "${file}"],
"outputCapture": "std",
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"]
},
{
"type": "node",
"request": "launch",
"name": "Debug VMB Test",
"runtimeExecutable": "yarn",
"runtimeArgs": ["run", "test:unit:vmb_test"],
"args": ["${input:vmVersion}", "${input:vmbTestShortId}"],
// "args": ["${input:vmVersion}", "${input:vmbTestShortId}", "-v"],
"outputCapture": "std",
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"],
"preLaunchTask": "npm: build"
},
{
"type": "node",
"request": "launch",
"name": "Debug VMB Benchmark",
"runtimeExecutable": "yarn",
"runtimeArgs": ["run", "bench:vmb_tests"],
"env": {
"BENCH_DEBUG_VM": "${input:vmVersion}",
"BENCH_DEBUG_TEST": "${input:vmbTestShortId}",
"BENCH_DEBUG_PROFILE": "${input:collectProfile}"
},
"outputCapture": "std",
"skipFiles": ["<node_internals>/**", "**/node_modules/**"]
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"],
"preLaunchTask": "npm: build"
},
{
"type": "node",
"request": "launch",
"name": "Debug VMB Test Generation",
"runtimeExecutable": "yarn",
"runtimeArgs": ["run", "gen:vmb_tests"],
"outputCapture": "std",
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"],
"preLaunchTask": "npm: build"
}
],
"inputs": [
{
"id": "vmbTestShortId",
"description": "Please enter a VMB test ID",
"default": "vdqk6",
"type": "promptString"
},
{
"id": "vmVersion",
"description": "Please choose a VM version",
"type": "pickString",
"options": [
"bch_2023_standard",
"bch_2023_nonstandard",
"bch_2025_standard",
"bch_2025_nonstandard",
"bch_2026_standard",
"bch_2026_nonstandard",
"bch_spec_standard",
"bch_spec_nonstandard"
],
"default": "bch_spec_standard"
},
{
"id": "collectProfile",
"description": "Collect a CPU profile?",
"type": "pickString",
"options": ["Yes", "No"],
"default": "Yes"
}
]
}
2 changes: 1 addition & 1 deletion .yarn
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ High-level utilities are composed from lower-level utilities which are also expo
- [`isArbitraryDataOutput`](https://libauth.org/functions/isArbitraryDataOutput.html)
- [`isSimpleMultisig`](https://libauth.org/functions/isSimpleMultisig.html)
- [`isStandardOutputBytecode`](https://libauth.org/functions/isStandardOutputBytecode.html)
- [`isStandardOutputBytecode2023`](https://libauth.org/functions/isStandardOutputBytecode2023.html)
- [`isStandardOutputBytecodePre2023`](https://libauth.org/functions/isStandardOutputBytecodePre2023.html)
- [`isStandardMultisig`](https://libauth.org/functions/isStandardMultisig.html)
- [`isWitnessProgram`](https://libauth.org/functions/isWitnessProgram.html)

Expand All @@ -333,26 +333,26 @@ High-level utilities are composed from lower-level utilities which are also expo

#### Built-In VMs

- [`createInstructionSetBCH`](https://libauth.org/functions/createInstructionSetBCH.html)
- [`createInstructionSetBCH2022`](https://libauth.org/functions/createInstructionSetBCH2022.html)
- [`createInstructionSetBCH2023`](https://libauth.org/functions/createInstructionSetBCH2023.html)
- [`createInstructionSetBCHCHIPs`](https://libauth.org/functions/createInstructionSetBCHCHIPs.html)
- [`createInstructionSetXEC`](https://libauth.org/functions/createInstructionSetXEC.html)
- [`createInstructionSetBch`](https://libauth.org/functions/createInstructionSetBch.html)
- [`createInstructionSetBch2023`](https://libauth.org/functions/createInstructionSetBch2023.html)
- [`createInstructionSetBch2025`](https://libauth.org/functions/createInstructionSetBch2025.html)
- [`createInstructionSetBchSpec`](https://libauth.org/functions/createInstructionSetBchSpec.html)
- [`createInstructionSetXec`](https://libauth.org/functions/createInstructionSetXec.html)
- [`createVirtualMachine`](https://libauth.org/functions/createVirtualMachine.html)
- [`createVirtualMachineBCH`](https://libauth.org/functions/createVirtualMachineBCH.html)
- [`createVirtualMachineBCH2022`](https://libauth.org/functions/createVirtualMachineBCH2022.html)
- [`createVirtualMachineBCH2023`](https://libauth.org/functions/createVirtualMachineBCH2023.html)
- [`createVirtualMachineBCHCHIPs`](https://libauth.org/functions/createVirtualMachineBCHCHIPs.html)
- [`createVirtualMachineXEC`](https://libauth.org/functions/createVirtualMachineXEC.html)
- [`createVirtualMachineBch`](https://libauth.org/functions/createVirtualMachineBch.html)
- [`createVirtualMachineBch2023`](https://libauth.org/functions/createVirtualMachineBch2023.html)
- [`createVirtualMachineBch2025`](https://libauth.org/functions/createVirtualMachineBch2025.html)
- [`createVirtualMachineBchSpec`](https://libauth.org/functions/createVirtualMachineBchSpec.html)
- [`createVirtualMachineXec`](https://libauth.org/functions/createVirtualMachineXec.html)

#### Debugging

- [`assembleBytecode`](https://libauth.org/functions/assembleBytecode.html)
- [`assembleBytecodeBCH`](https://libauth.org/functions/assembleBytecodeBCH.html)
- [`assembleBytecodeBTC`](https://libauth.org/functions/assembleBytecodeBTC.html)
- [`disassembleBytecode`](https://libauth.org/functions/disassembleBytecodeBCH.html)
- [`disassembleBytecodeBCH`](https://libauth.org/functions/disassembleBytecodeBCH.html)
- [`disassembleBytecodeBTC`](https://libauth.org/functions/disassembleBytecodeBTC.html)
- [`assembleBytecodeBch`](https://libauth.org/functions/assembleBytecodeBch.html)
- [`assembleBytecodeBtc`](https://libauth.org/functions/assembleBytecodeBtc.html)
- [`disassembleBytecode`](https://libauth.org/functions/disassembleBytecode.html)
- [`disassembleBytecodeBch`](https://libauth.org/functions/disassembleBytecodeBch.html)
- [`disassembleBytecodeBtc`](https://libauth.org/functions/disassembleBytecodeBtc.html)
- [`generateBytecodeMap`](https://libauth.org/functions/generateBytecodeMap.html)
- [`summarizeDebugTrace`](https://libauth.org/functions/summarizeDebugTrace.html)
- [`stringifyDebugTraceSummary`](https://libauth.org/functions/stringifyDebugTraceSummary.html)
Expand Down Expand Up @@ -399,7 +399,7 @@ High-level utilities are composed from lower-level utilities which are also expo
- [`stringifyErrors`](https://libauth.org/functions/stringifyErrors.html)
- [`verifyCashAssemblyEvaluationState`](https://libauth.org/functions/verifyCashAssemblyEvaluationState.html)
- [`walletTemplateToCompilerConfiguration`](https://libauth.org/functions/walletTemplateToCompilerConfiguration.html)
- [`walletTemplateToCompilerBCH`](https://libauth.org/functions/walletTemplateToCompilerBCH.html)
- [`walletTemplateToCompilerBch`](https://libauth.org/functions/walletTemplateToCompilerBch.html)

#### Multi-Party Compilation

Expand Down
1 change: 0 additions & 1 deletion .ava.bench.config.js → config/.ava.bench.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export default {
files: ['build/**/*.bench.js'],
workerThreads: false,
verbose: true,
};
9 changes: 9 additions & 0 deletions config/.ava.vmb_bench.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
files: ['src/lib/vmb-tests/benchmark-bch-vmb-tests.spec.ts'],
typescript: {
compile: false,
rewritePaths: {
'src/': 'build/',
},
},
};
14 changes: 8 additions & 6 deletions docs/keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ const flip128 =

const faces = 2;
const events = splitEvery(flip128, 1).map(parseInt);
// `assertSuccess` simply throws any errors
/* `assertSuccess` simply throws any errors */
const entropy = assertSuccess(generateDeterministicEntropy(faces, events));

const { phrase } = assertSuccess(encodeBip39Mnemonic(entropy));
/* Slice produced entropy at 16 bytes (128 bits) for 12 words: */
const { phrase } = assertSuccess(encodeBip39Mnemonic(entropy.slice(0, 16)));
console.log(phrase);
// => "crawl actual tool rally crazy lab work paper fragile favorite draft initial amount lawsuit task pupil clean crater genre rotate shoulder plate prevent bone"
// => "crawl actual tool rally crazy lab work paper fragile favorite draft income"
```

Note that `generateDeterministicEntropy` will return an error if the provided events do not include sufficient entropy for safe key generation (configurable via [`requiredEntropyBits`](https://libauth.org/functions/generateDeterministicEntropy.html)):
Expand Down Expand Up @@ -164,9 +164,11 @@ const faces = 6;
const entropy = assertSuccess(generateDeterministicEntropy(faces, events));
console.log(binToHex(entropy));
// => "8d270d32340c28d8708023a5becf5dd8d55da45808c2ba97cfb7c2b0dcfefad1"
const { phrase } = assertSuccess(encodeBip39Mnemonic(entropy));

/* Slice produced entropy at 16 bytes (128 bits) for 12 words: */
const { phrase } = assertSuccess(encodeBip39Mnemonic(entropy.slice(0, 16)));
console.log(phrase);
// => "minor debris erode gym secret history search afford pizza wait student random fiction split gasp blue ritual salmon unknown lyrics assist legal twice cactus"
// => "minor debris erode gym secret history search afford pizza wait student ranch"
```

#### BIP39 Mnemonic Phrase to BCH Wallet
Expand Down
Loading
Loading