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

Fix: Use Interpreter without building Tx or Output #60

Merged
merged 5 commits into from
Oct 4, 2021

Conversation

tigh-latte
Copy link
Contributor

Currently the user is expected to build a full tx and output in order to use the interpreter, even if the script doesn't check sigs.

To address this I've added:

  • LockingScript and UnlockingScript to the execution params
  • A new error condition
  • Additional validation
  • A fail-fast flag for the parser

@tigh-latte tigh-latte changed the title Fix: Execute without building Tx or Output Fix: Use Interpreter without building Tx or Output Oct 1, 2021
@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2021

Codecov Report

Merging #60 (e82e9dd) into master (c744a96) will increase coverage by 0.22%.
The diff coverage is 91.26%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #60      +/-   ##
==========================================
+ Coverage   84.53%   84.76%   +0.22%     
==========================================
  Files          27       28       +1     
  Lines        2943     3012      +69     
==========================================
+ Hits         2488     2553      +65     
- Misses        320      325       +5     
+ Partials      135      134       -1     
Impacted Files Coverage Δ
bscript/interpreter/errs/error.go 50.00% <ø> (ø)
bscript/script.go 59.34% <50.00%> (-0.66%) ⬇️
bscript/interpreter/options.go 66.66% <66.66%> (ø)
bscript/interpreter/engine.go 100.00% <100.00%> (ø)
bscript/interpreter/opcodeparser.go 81.38% <100.00%> (+0.82%) ⬆️
bscript/interpreter/operations.go 96.16% <100.00%> (-0.01%) ⬇️
bscript/interpreter/thread.go 93.50% <100.00%> (+2.76%) ⬆️
tx.go 79.37% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c744a96...e82e9dd. Read the comment docs.

@mergify mergify bot added the bug-P3 label Oct 1, 2021
@tigh-latte tigh-latte marked this pull request as draft October 4, 2021 08:41
@tigh-latte tigh-latte marked this pull request as ready for review October 4, 2021 10:16
@@ -22,13 +22,29 @@ func NewEngine() Engine {

// Execute will execute all scripts in the script engine and return either nil
// for successful validation or an error if one occurred.
//
// Execute with tx example:
// if err := engine.Execute(interpreter.ExecutionParams{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be better using something like this engine.Execute(WithTx(tx, previousOutput,...)) and engine.Execute(WithScripts(lockingScript, unlockingScript,...)).

My thought is with the single struct as shown, could be confusing and a user may see all options and think they may all be required ie tx AND script.

I would propose the With func would not be variadic but a single function accepted by the executor, so they also don't do WithTx AND WithScript.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aw good idea

Copy link
Contributor

@theflyingcodr theflyingcodr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@mergify mergify bot merged commit 7440322 into master Oct 4, 2021
@mergify mergify bot deleted the fix/exec-without-tx branch October 4, 2021 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants