bsv-wasm
bsv-wasm copied to clipboard
Support Script interpreter
to speed up Bitcoin VM.
In the works :)
Will be a separate package but will leverage all of bsv-wasm
ceo of testnet approved
@xhliu You're gonna love this ;)
Can't wait, CEO/CTO.
Gents, any update on this? Would love to switch to WASM to speed up.
Hey @xhliu I'm aiming to have something usable for you in about 2 weeks time. I'll keep you posted
hello, how to use Interpreter
?
my code below:
const bsvwasm = require("bsv-wasm");
const s = bsvwasm.Script.from_hex("5b0000005754615179547a75537a537a537a0079537a75527a527a7575615279008763537952795279615179517993517a75517a75619c77777777675279518763537952795279949c7777777767006868");
const bm = bsvwasm.Interpreter.from_script(s);
try {
Loggging.log(`state: ${bm.run()}`);
} catch (error) {
Loggging.log(`wasm error: ${error}`);
}
but got a error when call bm.run()
:
wasm error: RuntimeError: unreachable
I think there is a bug with OP_PICK, I will look into it
Thanks for the issue, here's a new build for you to try out. I'll aim to get a release pipeline for 2.0 out eventually.
https://github.com/Firaenix/bsv-wasm/blob/split-modules/packages/bsv-wasm/pkg/bsv-wasm%20node%202.0.0%20alpha.zip
an other error when call bsvwasm.Script.from_hex(snark);
Error when deserialising Script: OP_IF statement requires an OP_ELSE code snark.hex.zip .
I was under the impression that any OP_IF must have an OP_ELSE followed by an OP_ENDIF, according to the BSV Wiki https://wiki.bitcoinsv.io/index.php/Opcodes_used_in_Bitcoin_Script
If this is untrue, I can change this
i can run this with js bsv.
i think OP_IF
must followed by an OP_ENDIF
, but OP_ELSE
is not must be.
![image](https://user-images.githubusercontent.com/995909/183094734-8c047682-0d6b-4092-9bcb-44d61be6e6a6.png)
I'm not 100% certain, but it's worth checking against the Bitcoin SV node interpreter so get it 100% correct
Alright I've found further documentation about OP_IF, etc.
https://wiki.bitcoinsv.io/index.php/Scripts_with_Flow_Control_(Conditional_Clauses)
I will fix up the library when I get a chance, thanks for raising this
@Firaenix any. update
@Firaenix we would like to use bsv-wasm for powchess.com but we encounter the OP_IF OP_ELSE bug. Can you give an estimate when you will be able to fix this? Thanks!
Sorry for the delay all, been very busy with Bitping work. I will have a look at getting it fixed this week
Hi all, I've pushed a change to the split-modules branch, you can find the build for that branch below. Please let me know how you get on.
I still have to do some significant changes before I can get a release out onto npm, but this zip should get you by for now
https://github.com/Firaenix/bsv-wasm/raw/split-modules/packages/bsv-wasm/pkg/node.zip
@Firaenix the types for the new version (from the above linked zip file) have changed. e.g. Transaction.toHex() is now Transaction.to_hex()
Before I completely change all the function calls in our code I wanted to check if these new function names will persist in the new version.
Yes they've changed significantly, I expect the new function signatures to be stable for the next release, which is 2.0.0
Hey @Firaenix,
I'm currently running some tests with your new version and experienced a RuntimeError: unreachable
when using Transaction.add_outputs()
.
Adding them all manually with Transaction.add_output()
works as expected.
@Firaenix we have tested the new version with our scripts and we don't reproduce the OP_IF OP_ELSE errors anymore. Looking forward to using the new release in production.
I have released this Feature to npm, deno.land and crates.io on Version 2.0.0.
https://crates.io/crates/bsv https://www.npmjs.com/package/bsv-wasm
I'm going to close this issue