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

When using :testnet network the app crashes after trying to store block 542 #2

Open
RadekMolenda opened this issue Jan 10, 2018 · 3 comments

Comments

@RadekMolenda
Copy link

RadekMolenda commented Jan 10, 2018

I have the following issue when trying to start the node using :testnet network

10:36:33.653 [info]  Storing block 542 {{:error, {:sig_script, "c5d4b73af6eed28798473b05d2b227edd4f285069629843e899b52c2d1c165b7", 10}}, 0} | 0000000083c1f82cf72c6724f7a31732
5806384b06408bce7a4327f418dfd5ad| vt: 0.04s st: 0.0s tx: 4                                                                                                                    
                                                                                                                                                                              
10:36:33.657 [error] GenServer Bitcoin.Node.Inventory terminating                                                                                                             
** (CaseClauseError) no case clause matching: {{:error, {:sig_script, "c5d4b73af6eed28798473b05d2b227edd4f285069629843e899b52c2d1c165b7", 10}}, 0}                            
    (bitcoin) lib/bitcoin/node/inventory.ex:136: Bitcoin.Node.Inventory.handle_cast/2    

Was trying to debug this but I'm afraid my bitcoin foo is still to low to tackle this issue. Any help would be much appreciated.

The app is configured to use postgres as a Storage

@comboy
Copy link
Owner

comboy commented Jan 11, 2018

It's due to unfinished script engine. I haven't touched the project in a while so I don't remember how far it was syncing on testnet (it's full of edge cases, which is nice). I plan to get back to it soon to try to implement segwit, so I'll make sure to keep info about sync progress in the README.

If you are not using libsecp256k1, then definitely try with it. Although if all tests are passing then it's "just" another script bug that needs to be fixed.

Script compatibility is crucial and very hard. I'm too busy to currently dive into this issue right away, sorry. If you feel like poking around then I'm happy to answer any questions. If not I'll update the ticket when I get back to the project.

@RadekMolenda
Copy link
Author

Okay - the issue was in the Interperter.ex file here: https://github.com/comboy/bitcoin-elixir/blob/develop/lib/bitcoin/script/interpreter.ex#L169
and here: https://github.com/comboy/bitcoin-elixir/blob/develop/lib/bitcoin/script/interpreter.ex#L175

opts is a Map not a Keyword thus - the script was failing. I would like to provide a PR for fixing the issue, but I don't know how to write a proper test case for that. Any guides where I could find a crash course on how to write proper Bitcoin scripts?

@comboy
Copy link
Owner

comboy commented Jan 13, 2018

Wow, great job! Sorry about the late answer. I'll definitely dive back a bit into the project this week.

Yeah, I couldn't decide between Keyword and Map. I settled on Map eventually because function matching works with it unlike Keyword.

Check this setting: https://github.com/comboy/bitcoin-elixir/blob/develop/config/dev.exs#L7

When you run test node in dev env, and this is set to true, test/data/auto/testnet directory will appear and you should have a ready test case with the failing transaction there. It should be enough to add it to test/data/tx_valid.json

If you feel like diving into script I mostly used bitcoin wiki, there is now newer developer guide but I still trust wiki more.

Awesome that you've spent time on finding that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants