Skip to content

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

Merged
PastaPastaPasta merged 14 commits into
dashpay:developfrom
tomlaigna:enable-splice-ops
Dec 11, 2020
Merged

Consensus: DIP-0020: Dash opcode updates - OP_CAT and OP_SPLIT.#3824
PastaPastaPasta merged 14 commits into
dashpay:developfrom
tomlaigna:enable-splice-ops

Conversation

@tomlaigna

Copy link
Copy Markdown

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

UdjinM6 commented Nov 21, 2020

Copy link
Copy Markdown

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
Copy Markdown
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

UdjinM6 commented Nov 22, 2020

Copy link
Copy Markdown

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

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

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:

  • pls see https://github.com/UdjinM6/dash/commits/pr3824
  • do we really need a dedicated opcodes_tests.cpp? It looks like all the required tests can be implemented via script_tests.cpp+script_test_json. Or am I missing smth?
  • pls see an inline question below

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

Comment thread src/test/data/script_tests.json

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

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

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

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

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

re-utACK

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

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?

Comment thread src/policy/policy.h Outdated
@PastaPastaPasta

Copy link
Copy Markdown
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
Copy Markdown
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

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

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

@xdustinface xdustinface left a comment

Copy link
Copy Markdown

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.

Comment thread src/test/script_tests.cpp Outdated
Comment thread test/functional/feature_dip0020_activation.py Outdated
UdjinM6
UdjinM6 previously approved these changes Dec 2, 2020

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

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

@xdustinface xdustinface left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

utACK

@PastaPastaPasta

Copy link
Copy Markdown
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

UdjinM6 commented Dec 3, 2020

Copy link
Copy Markdown

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
Copy Markdown
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

UdjinM6 commented Dec 3, 2020

Copy link
Copy Markdown

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

@PastaPastaPasta ?

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

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?

Comment thread src/script/interpreter.cpp
Comment thread src/script/interpreter.h Outdated
//
SCRIPT_VERIFY_NULLFAIL = (1U << 14),

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

Copy link
Copy Markdown
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

Comment thread src/script/script.cpp
Comment thread src/script/script_error.h
SCRIPT_ERR_INVALID_STACK_OPERATION,
SCRIPT_ERR_INVALID_ALTSTACK_OPERATION,
SCRIPT_ERR_UNBALANCED_CONDITIONAL,
SCRIPT_ERR_INVALID_SPLIT_RANGE,

Copy link
Copy Markdown
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
Copy Markdown
Member

bump

@tomlaigna

Copy link
Copy Markdown
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

PastaPastaPasta commented Dec 9, 2020

Copy link
Copy Markdown
Member

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)

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

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?

Comment thread src/script/interpreter.cpp
Comment thread src/test/script_tests.cpp
Comment thread src/validation.cpp
Comment thread src/validation.cpp Outdated
@UdjinM6

UdjinM6 commented Dec 9, 2020

Copy link
Copy Markdown

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

@PastaPastaPasta

Copy link
Copy Markdown
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

UdjinM6 commented Dec 9, 2020

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Member

bump :D negative boolean

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

utACK

@xdustinface xdustinface left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

utACK

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

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