Skip to content

Commit

Permalink
Submodule and test against BCHN, expand VMB test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bitjson committed Nov 15, 2024
1 parent 9c35e3e commit ad67e46
Show file tree
Hide file tree
Showing 1,624 changed files with 378,826 additions and 133,687 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-tables-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': patch
---

Fix operation cost in OP_SIZE
5 changes: 5 additions & 0 deletions .changeset/clean-adults-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': minor
---

Extend AuthenticationErrorCommon with all transaction verification errors
5 changes: 5 additions & 0 deletions .changeset/eight-mirrors-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': minor
---

Add support for warnings in VMB test generation
5 changes: 5 additions & 0 deletions .changeset/fair-zoos-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': minor
---

Add support for verifying VMB tests against BCHN metrics and fail reasons
5 changes: 5 additions & 0 deletions .changeset/fast-ghosts-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': patch
---

Move VMB test duplication checking to start of generation
5 changes: 5 additions & 0 deletions .changeset/modern-cobras-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': minor
---

Prevent excessive hashing in null-signature CHECKMULTISIG
5 changes: 5 additions & 0 deletions .changeset/nice-flies-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': patch
---

Fix operation cost in OP_NIP
5 changes: 5 additions & 0 deletions .changeset/quiet-ducks-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': patch
---

Fix operation cost in OP_ROLL
5 changes: 5 additions & 0 deletions .changeset/shaggy-monkeys-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': minor
---

Submodule BCHN and extend package scripts to verify VMB tests
5 changes: 5 additions & 0 deletions .changeset/short-cars-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': minor
---

Expand VMB test coverage
5 changes: 5 additions & 0 deletions .changeset/wet-pans-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bitauth/libauth': patch
---

Fix bug in isMinimalDataPush for OP_PUSHBYTES_1
7 changes: 6 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"PUBKEYS",
"PUSHBYTES",
"PUSHDATA",
"pushonly",
"rebranded",
"rebranding",
"redenominated",
Expand All @@ -156,6 +157,8 @@
"satoshis",
"Sats",
"schnorr",
"scriptonly",
"scriptsig",
"seckey",
"secp",
"secp256k1",
Expand Down Expand Up @@ -183,6 +186,7 @@
"txid",
"TXINPUTCOUNT",
"TXLOCKTIME",
"txns",
"TXOUTPUTCOUNT",
"TXVERSION",
"typeof",
Expand Down Expand Up @@ -223,7 +227,8 @@
"node_modules/**",
"src/**/*.base64.ts",
"src/**/script_tests.json",
"src/lib/vmb-tests/generated"
"src/lib/vmb-tests/generated",
"src/lib/vmb-tests/bchn/*.json"
],
"patterns": [
{
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
path = config/eslint-config-bitauth
url = https://github.com/bitauth/eslint-config-bitauth/
shallow = true
[submodule "wasm/bitcoin-cash-node"]
path = wasm/bitcoin-cash-node
url = https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node.git
shallow = true
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ wasm
package.json
src/lib/address/fixtures/key_io_*.json
src/lib/vm/instruction-sets/xec/fixtures/satoshi-client/*.json
src/lib/vmb-tests/generated
src/lib/vmb-tests/generated
src/lib/vmb-tests/bchn/*.json
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@
"build:wasm": "cpy --flat src/lib/bin/secp256k1/secp256k1.wasm build/lib/bin/secp256k1 && cpy --flat src/lib/bin/sha1/sha1.wasm build/lib/bin/sha1 && cpy --flat src/lib/bin/sha256/sha256.wasm build/lib/bin/sha256 && cpy --flat src/lib/bin/sha512/sha512.wasm build/lib/bin/sha512 && cpy --flat src/lib/bin/ripemd160/ripemd160.wasm build/lib/bin/ripemd160",
"compile:debug:secp256k1": "docker run -it libauth-secp256k1 bash",
"compile:debug:hashes": "docker run -it libauth-hashes bash",
"bchn:cmake": "cd wasm/bitcoin-cash-node/build && cmake -GNinja .. -DBUILD_BITCOIN_WALLET=OFF -DBUILD_BITCOIN_QT=OFF -DENABLE_NATPMP=OFF -DENABLE_MAN=OFF -DCMAKE_BUILD_TYPE=Release",
"bchn:build": "cd wasm/bitcoin-cash-node/build && ninja",
"bchn:setup": "cd wasm/bitcoin-cash-node && mkdir build && yarn bchn:cmake && yarn bchn:build",
"bchn:remove-old-vmb-tests": "rm -r wasm/bitcoin-cash-node/src/test/data/vmb_tests/bch_{2023,2025}_{invalid,nonstandard,standard} && echo 'Removed old VMB tests from: wasm/bitcoin-cash-node/src/test/data/vmb_tests'",
"bchn:add-new-vmb-tests": "cp -r src/lib/vmb-tests/generated/* wasm/bitcoin-cash-node/src/test/data/vmb_tests && echo 'Added new VMB tests.'",
"bchn:replace-vmb-tests": "yarn bchn:remove-old-vmb-tests && yarn bchn:add-new-vmb-tests",
"bchn:run-tests": "cd wasm/bitcoin-cash-node/build && echo 'Building BCHN tests...' && ninja test_bitcoin && echo 'Running VMB tests in BCHN...' && src/test/test_bitcoin -t libauth_tests",
"bchn:check-vmb-tests": "yarn bchn:cmake && yarn bchn:build && yarn bchn:run-tests",
"bchn:copy-vmb-test-results": "cp wasm/bitcoin-cash-node/build/libauth_expected_test_fail_reasons.json src/lib/vmb-tests/bchn/libauth_expected_test_fail_reasons.json && cp wasm/bitcoin-cash-node/build/libauth_expected_test_metrics.json src/lib/vmb-tests/bchn/libauth_expected_test_metrics.json && echo 'Replaced BCHN files at: src/lib/vmb-tests/bchn'",
"bchn:update-vmb-tests": "yarn bchn:replace-vmb-tests && yarn bchn:cmake && yarn bchn:run-tests && yarn bchn:copy-vmb-test-results",
"fix": "yarn fix:eslint && yarn fix:prettier",
"fix:prettier": "prettier . --write",
"fix:eslint": "yarn test:eslint --fix",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/language/reduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
ScriptReductionTraceChildNode,
ScriptReductionTraceScriptNode,
} from '../lib.js';
import { AuthenticationErrorCommon, encodeDataPush } from '../vm/vm.js';
import { encodeDataPush } from '../vm/vm.js';

import { mergeRanges } from './language-utils.js';

Expand Down Expand Up @@ -47,10 +47,10 @@ export const verifyCashAssemblyEvaluationState = <
return state.error;
}
if (state.controlStack.length !== 0) {
return AuthenticationErrorCommon.nonEmptyControlStack;
return `The CashAssembly internal evaluation completed with a non-empty control stack.`;

Check warning on line 50 in src/lib/language/reduce.ts

View check run for this annotation

Codecov / codecov/patch

src/lib/language/reduce.ts#L50

Added line #L50 was not covered by tests
}
if (state.stack.length !== 1) {
return AuthenticationErrorCommon.requiresCleanStack;
return `The CashAssembly internal evaluation completed with an unexpected number of items on the stack (must be exactly 1).`;

Check warning on line 53 in src/lib/language/reduce.ts

View check run for this annotation

Codecov / codecov/patch

src/lib/language/reduce.ts#L53

Added line #L53 was not covered by tests
}
return true;
};
Expand Down
6 changes: 3 additions & 3 deletions src/lib/vm/instruction-sets/bch/2023/bch-2023-descriptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum OpcodeDescriptionsBch2023 {
OP_0 = 'Push the VM Number 0 onto the stack.',
OP_0 = 'Push the VM Number 0 onto the stack. (A.K.A. OP_FALSE or OP_PUSHBYTES_0)',
OP_PUSHBYTES_1 = 'Push the next byte onto the stack.',
OP_PUSHBYTES_2 = 'Push the next 2 bytes onto the stack.',
OP_PUSHBYTES_3 = 'Push the next 3 bytes onto the stack.',
Expand Down Expand Up @@ -80,7 +80,7 @@ export enum OpcodeDescriptionsBch2023 {
OP_PUSHDATA_4 = 'Read the next little-endian Uint32 and push that number of bytes onto the stack.',
OP_1NEGATE = 'Push the VM Number -1 onto the stack.',
OP_RESERVED = 'Error unless found in an unexecuted conditional branch. Note: OP_RESERVED does not count toward the opcode limit.',
OP_1 = 'Push a 1 (VM Number) onto the stack.',
OP_1 = 'Push a 1 (VM Number) onto the stack. (A.K.A. OP_TRUE)',
OP_2 = 'Push a 2 (VM Number) onto the stack.',
OP_3 = 'Push a 3 (VM Number) onto the stack.',
OP_4 = 'Push a 4 (VM Number) onto the stack.',
Expand Down Expand Up @@ -144,7 +144,7 @@ export enum OpcodeDescriptionsBch2023 {
OP_2DIV = 'Error, even when found in an unexecuted conditional branch. (Historically, this divided a VM Number by 2.)',
OP_NEGATE = 'Pop the top item from the stack as a VM Number, negate it, then push the result.',
OP_ABS = 'Pop the top item from the stack as a VM Number, take its absolute value, then push the result.',
OP_NOT = 'Pop the top item from the stack as a VM Number. If its value is 0, push a 1 (VM Number), otherwise, push a 0 (VM Number).',
OP_NOT = 'Pop the top item from the stack as a VM Number. If its value is 0, push a 1 (VM Number), otherwise, push a 0 (VM Number). (A.K.A. OP_0EQUAL)',
OP_0NOTEQUAL = 'Pop the top item from the stack as a VM Number. If its value is not 0, push a 1 (VM Number), otherwise, push a 0 (VM Number).',
OP_ADD = 'Pop the top two items from the stack as VM Numbers. Add them, then push the result.',
OP_SUB = 'Pop the top two items from the stack as VM Numbers. Subtract the top item from the second item, then push the result.',
Expand Down
Loading

0 comments on commit ad67e46

Please sign in to comment.