Skip to content

Conversation

@arvidn
Copy link

@arvidn arvidn commented Sep 11, 2017

and towards re-enabling rpc tests. This patch introduces CProof, CTxOutValue, CTxOutAsset and CTxOutNonce to mininode.py. It also adds some debug output to the main node that was helpful in trouble-shooting the interaction between mininode.py and the main node.

This patch is a step in the direction of having mininode be compatible with elements. it does not bring it nor the tests all the way there to pass.

Copy link
Author

Choose a reason for hiding this comment

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

previously this function would not produce the canonical encoding for values [1, 16]

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a script expert, but these values correspond to opcodes, not the resulting value pushed on the stack.

The code as-is matches the C++ code quite well.

Copy link
Author

Choose a reason for hiding this comment

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

this function is used in exactly one place (line 69 to the left). Its result is passed to ser_string() and passed in as a script. Perhaps I'm missing something, but it's not clear to me how that could possibly generate a valid script (apart from the special case of 0 and possibly some others). This check was failing in the test.

Copy link
Author

Choose a reason for hiding this comment

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

that said, it's probably better to leave this function as-is, and instead wrap it in CScript() where it's used instead

Copy link
Author

Choose a reason for hiding this comment

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

it also would not include the length-prefix

Copy link
Contributor

Choose a reason for hiding this comment

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

Again, I don't think is required. If someone is pushing the number onto the stack, they will append this value.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure what the most reasonable default value for asset is. Should it be another parameter?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's likely going the be whatever policyAsset is set to, in most cases "bitcoin"'s asset type.

Copy link
Author

Choose a reason for hiding this comment

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

this comment refers to this condition. Come to think of it, perhaps that check is incorrect. It seems to assume that the height at the start of the script must use a two-byte encoding (which is only true for values > 16)

Copy link
Contributor

Choose a reason for hiding this comment

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

is this upstreamable?

Copy link
Author

Choose a reason for hiding this comment

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

you mean the comment or the patch to make the scriptsig at least 2 bytes? I have a feeling that this requirement of the scriptsig being at least 2 bytes is a mistake. But I can't say I understand the motivation of it well enough to be confident. I imagine it's not a problem in the wild, as the block height most likely will get encoded as at least two bytes in the script. But in tests where the height < 16, it is.

Copy link
Author

Choose a reason for hiding this comment

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

this comment refers to this condition.

Copy link
Author

Choose a reason for hiding this comment

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

the C++ version of these 3 classes are a single template. Perhaps these should be merged as well and use variables instead of template parameters.

Copy link
Author

Choose a reason for hiding this comment

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

the serialize_with_witness function was duplicated. This removes the second copy as the first one matched the C++ code better

@arvidn arvidn force-pushed the mininode-test-update branch from ba52323 to ab722bb Compare September 11, 2017 12:55
@instagibbs
Copy link
Contributor

seems you left some random net_processing.cpp changes, please remove.

Copy link
Contributor

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

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

thanks for working on this!

A large part missing here is how the witness structure itself is serialized, and issuances.

Copy link
Contributor

Choose a reason for hiding this comment

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

Put a TODO to check block header sigs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nonce class only has a 33-byte commitment, not a rangeproof or other witness data.

Copy link
Contributor

Choose a reason for hiding this comment

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

rangeproof no longer resides in the output. It resides in the CTxWitness based field wit in CTransaction

Copy link
Contributor

Choose a reason for hiding this comment

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

It's likely going the be whatever policyAsset is set to, in most cases "bitcoin"'s asset type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a script expert, but these values correspond to opcodes, not the resulting value pushed on the stack.

The code as-is matches the C++ code quite well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Again, I don't think is required. If someone is pushing the number onto the stack, they will append this value.

Copy link
Contributor

Choose a reason for hiding this comment

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

is this upstreamable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Rangeproof is in witness structure.

Copy link
Author

Choose a reason for hiding this comment

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

will fix

Copy link
Contributor

Choose a reason for hiding this comment

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

it's not a nonce, just an asset commitment

Copy link
Contributor

Choose a reason for hiding this comment

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

value, not a nonce

Copy link
Contributor

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

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

Feel free to squash liberally

Copy link
Contributor

Choose a reason for hiding this comment

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

copy and paste error, these should be range/surj proofs

Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor

Choose a reason for hiding this comment

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

scriptWitness is for inputs

Copy link
Contributor

Choose a reason for hiding this comment

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

scriptWitness is for inputs

Copy link
Contributor

Choose a reason for hiding this comment

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

scriptWitness is for inputs (below as well)

@arvidn arvidn force-pushed the mininode-test-update branch from fd81ec6 to 3c21411 Compare September 19, 2017 10:19
@instagibbs
Copy link
Contributor

did some work on top: https://github.com/instagibbs/elements/commits/mininode

re-activated a test that uses mininode transaction serialization(without any witness data).

@instagibbs
Copy link
Contributor

tACK 3c21411, got the entire test working.

@instagibbs instagibbs merged commit 3c21411 into ElementsProject:elements-0.14.1 Sep 21, 2017
instagibbs added a commit that referenced this pull request Sep 21, 2017
…n node

3c21411 work towards bringing mininode.py up to date with the main node and towards re-enabling rpc tests (Arvid Norberg)
@jtimon jtimon added the 0.14.1 label Oct 10, 2017
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