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

Consensus: DIP-0020: Dash opcode updates - OP_CAT and OP_SPLIT. #3824

Merged
merged 14 commits into from
Dec 11, 2020

Conversation

tomlaigna
Copy link

This PR is intended as a partial implementation of https://github.com/dashpay/dips/blob/master/dip-0020.md
Enable and implement OP_CAT.
Rename OP_SUBSTR to OP_SPLIT and implement it.
Copied from https://reviews.bitcoinabc.org/D1097 mentioned in the document.

Idea is to receive feedback on this PR and if positive, proceed with the rest of the disabled opcodes.

@UdjinM6
Copy link

UdjinM6 commented Nov 21, 2020

Opcodes themselves look good but pls note that develop branch should be kept backwards compatible. You can't just (re)implement opcodes like that, you need to use some activation mechanism (could re-use DEPLOYMENT_V17 (#3808) for this) and implement corresponding tests i.e. (at least) smth like Bitcoin-ABC/bitcoin-abc@7ad4d79 + Bitcoin-ABC/bitcoin-abc@f103591.

@tomlaigna
Copy link
Author

@UdjinM6 Thanks for the quick reaction!

If you can, please confirm my understanding that the following should be done here:

  1. Add DEPLOYMENT_DIP0020 to src/chainparams.cpp or just reuse DEPLOYMENT_V17.
  2. Add a script verification flag (maybe ENABLE_DIP0020_OPDCODES) that enables these opcodes and is automatically enabled if the DEPLOYMENT_DIP0020 or DEPLOYMENT_V17 criteria is active.
  3. Implement test that checks this flag is activated properly.
  4. Also fix the script tests to accommodate the enable flag.

@UdjinM6
Copy link

UdjinM6 commented Nov 22, 2020

Correct. Also, pls rebase this PR on top of the latest develop to fix simplepose test failures.

@tomlaigna tomlaigna force-pushed the enable-splice-ops branch 2 times, most recently from 8e9a933 to 09404de Compare November 28, 2020 21:16
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

There are few things that need to be fixed:

But in general, we are moving in the right direction I think :)

src/test/data/script_tests.json Show resolved Hide resolved
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

LGTM, utACK 👍

EDIT: re-indexed on testnet with --assumevalid=0 with no issues.

@UdjinM6 UdjinM6 added this to the 17 milestone Nov 30, 2020
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

Found one tiny issue UdjinM6@38b8127

UdjinM6
UdjinM6 previously approved these changes Dec 1, 2020
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

re-utACK

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

So far so good, one maybe typo?

src/policy/policy.h Outdated Show resolved Hide resolved
@PastaPastaPasta
Copy link
Member

Also, be aware of the timeline found here #3775, feature freeze on Dec. 7 is approaching quickly. Although that date may get pushed back.

@tomlaigna
Copy link
Author

In the implementation this pr is based on, the mempool is cleared once the new opcodes are enabled. Same with replay protection. See Bitcoin-ABC/bitcoin-abc@f103591#diff-97c3a52bc5fad452d82670a7fd291800bae20c7bc35bb82686c2c0a4ea7b5b98R2610
Is this necessary? It's missing here.

UdjinM6
UdjinM6 previously approved these changes Dec 1, 2020
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

one maybe typo?

oh, wow 🙈 typos are fine though, I make them all the time 😄

re-utACK

Copy link

@xdustinface xdustinface left a comment

Choose a reason for hiding this comment

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

Looks good 👍 Just two nits, see the comments.

src/test/script_tests.cpp Outdated Show resolved Hide resolved
test/functional/feature_dip0020_activation.py Outdated Show resolved Hide resolved
UdjinM6
UdjinM6 previously approved these changes Dec 2, 2020
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

re-re-utACK :D

re

... the mempool is cleared once the new opcodes are enabled. ... It's missing here.

This code is in DisconnectTip, so it's once the new opcodes are disabled because of a reorg actually. Anyway, dropping the whole mempool sounds like a pretty bad idea imo. Even if a reorg would happen (which is quite rare in Dash btw) the block that would cause it would still activate the proposal, there is no option to not activate it. Reorging 2+ blocks is practically impossible thanks to a combination of a) Dash being the major X11 chain and b) ChainLocks. I think it's safe to avoid nuking the mempool in our case. For BCH it's different for obvious reasons (2% of the dsha256 and no 51% attack protection).

xdustinface
xdustinface previously approved these changes Dec 2, 2020
Copy link

@xdustinface xdustinface left a comment

Choose a reason for hiding this comment

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

utACK

@PastaPastaPasta
Copy link
Member

Does it really make sense to break this up into a number of PRs? because really, all of this needs to be merged for v0.17, or none of it.

@UdjinM6
Copy link

UdjinM6 commented Dec 3, 2020

all of this needs to be merged for v0.17, or none of it.

Why? I mean, ideally yes, it would be nice to have all of them activated at once but technically speaking, none of them require another one to function correctly, there is no atomicity requirement for DIP0020.

@tomlaigna
Copy link
Author

Either way is fine by me. The main reason I only added two opcodes in this pr was that I was unsure how this will be received, so I didn't want to spend too much time adding all the opcodes. In any case I will be adding the rest of the opcodes soon.

@UdjinM6
Copy link

UdjinM6 commented Dec 3, 2020

I'd say let's merge this one and then work on other opcodes in following PR(s).

@PastaPastaPasta ?

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

can you explain why src/test/monolith_opcodes_string.cpp isn't / shouldn't be included?

src/script/interpreter.cpp Show resolved Hide resolved
@@ -95,6 +95,9 @@ enum
// Signature(s) must be empty vector if a CHECK(MULTI)SIG operation failed
//
SCRIPT_VERIFY_NULLFAIL = (1U << 14),

// Enable the opcodes listed in DIP0020 (CAT, SPLIT, etc).
Copy link
Member

Choose a reason for hiding this comment

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

I would maybe list all opcodes here, no need to open the dip to see them

src/script/script.cpp Show resolved Hide resolved
@@ -34,6 +34,7 @@ typedef enum ScriptError_t
SCRIPT_ERR_INVALID_STACK_OPERATION,
SCRIPT_ERR_INVALID_ALTSTACK_OPERATION,
SCRIPT_ERR_UNBALANCED_CONDITIONAL,
SCRIPT_ERR_INVALID_SPLIT_RANGE,
Copy link
Member

Choose a reason for hiding this comment

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

Add the comment like upstream?

@PastaPastaPasta
Copy link
Member

bump

@tomlaigna
Copy link
Author

@PastaPastaPasta About the src/test/monolith_opcodes_string.cpp, we agreed with @UdjinM6 that they were basically doing the same thing the script_tests.cpp are doing so kind of redundant. I think it's fine.

@tomlaigna tomlaigna dismissed stale reviews from xdustinface and UdjinM6 via ee355dc December 7, 2020 08:23
@PastaPastaPasta
Copy link
Member

PastaPastaPasta commented Dec 9, 2020

I'm not sure why not you couldn't have src/test/monolith_opcodes_string.cpp... / why that wouldn't make sense. A bit of test redundancy wouldn't be the end of the world

EDIT: okay, I think @UdjinM6 resolved my concerns in slack. Basically, should treat these opcodes as all other opcodes, and other opcodes are only tested in script_tests(.cpp/.json)

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

@UdjinM6 what do you think of below?

src/script/interpreter.cpp Show resolved Hide resolved
src/test/script_tests.cpp Show resolved Hide resolved
src/validation.cpp Show resolved Hide resolved
src/validation.cpp Outdated Show resolved Hide resolved
@UdjinM6
Copy link

UdjinM6 commented Dec 9, 2020

@PastaPastaPasta not a big fan of the new naming scheme personally tbh, so I'm fine either way

@PastaPastaPasta
Copy link
Member

@PastaPastaPasta not a big fan of the new naming scheme personally tbh, so I'm fin either way

I don't have a strong prefernce, but I'd like to figure out what style we want to do and follow that

@UdjinM6
Copy link

UdjinM6 commented Dec 9, 2020

I don't have a strong prefernce, but I'd like to figure out what style we want to do and follow that

I don't think a backport PR like this is a good place to apply/enforce these rules. We could maybe start doing this in our own PRs introducing new features though...

@PastaPastaPasta
Copy link
Member

I don't have a strong prefernce, but I'd like to figure out what style we want to do and follow that

Sounds good, please disregard formatting changes. Imo, please change the negative boolean

@PastaPastaPasta
Copy link
Member

bump :D negative boolean

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK

Copy link

@xdustinface xdustinface left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK

@PastaPastaPasta PastaPastaPasta merged commit 5a026be into dashpay:develop Dec 11, 2020
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 16, 2022
…pay#3824)

* DIP-0020: Dash opcode updates - enable OP_CAT and OP_SPLIT (renamed from OP_SUBSTR)

* DIP-0020: Dash opcode updates - DEPLOYMENT_V17 activates dip0020 opcodes

* Add/tweak MAX_SCRIPT_ELEMENT_SIZE tests for OP_CAT and OP_SPLIT

* Check nDefaultMaxNumSize in OP_SPLIT tests

* Purify DISABLED_OPCODE tests for OP_CAT and OP_SPLIT, fix DoTest to actually preserve the DIP0020 flag

* Fix `warning: '&' within '|' [-Wbitwise-op-parentheses]`

* Rework/simplify feature_dip0020_activation.py

* DIP-0020: Remove functionally redundant tests.

* Fix file permissions for feature_dip0020_activation.py

* DIP-0020: fix typo

* Update src/test/script_tests.cpp

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

* Update test/functional/feature_dip0020_activation.py

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

* DIP-0020: improve comments

* DIP-0020: dont use negative booleans

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

4 participants