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

Increase maximum signatures for OP_FEDERATION OP_CHECKMULTISIG/VERIFY #492

Draft
wants to merge 1 commit into
base: release/1.1.0.0
Choose a base branch
from

Conversation

quantumagi
Copy link
Contributor

@quantumagi quantumagi commented Mar 31, 2021

This PR increases the maximum number of signatures associated with OP_CHECKMULTISIG/VERIFY opcodes.

We may also need to give some thought to how the nodes will be affected by evaluating a large number of signatures.

if (nKeysCount < 0 || nKeysCount > 20)
return SetError(ScriptError.PubkeyCount);

nOpCount += nKeysCount;
Copy link
Contributor Author

@quantumagi quantumagi Mar 31, 2021

Choose a reason for hiding this comment

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

@zeptin , do you know why the key count is added to the opcode count? Do we need this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Basically this is a consensus rule; there can only be a maximum of 201 non-push opcodes in any given script. If this was to be changed then I think we need to look at subclassing ScriptEvaluationContext so that per-network versions can be injected.

https://bitcoin.stackexchange.com/questions/38230/maximum-number-of-op-codes-in-script

@quantumagi quantumagi requested a review from zeptin March 31, 2021 06:46
return SetError(ScriptError.OpCount);
if (this.Network.Federations != null && lastOpcode?.Code == OpcodeType.OP_FEDERATION)
{
if (nKeysCount < 0 || nKeysCount > 150)
Copy link
Contributor Author

@quantumagi quantumagi Mar 31, 2021

Choose a reason for hiding this comment

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

@zeptin, I realise that 150 signatures may have a significant impact. Perhaps we should agree on some smaller maximum number.

@quantumagi quantumagi changed the title Increase maximum signatures for OP_CHECKMULTISIG/VERIFY Increase maximum signatures for OP_FEDERATION OP_CHECKMULTISIG/VERIFY Mar 31, 2021
@quantumagi quantumagi requested a review from fassadlr March 31, 2021 07:42
@noescape00
Copy link
Contributor

This PR increases the maximum number of signatures associated with OP_CHECKMULTISIG/VERIFY opcodes.

As far as I remember we wanted to work around that with system smart contracts, so what's the motivation behind this PR?

@quantumagi
Copy link
Contributor Author

quantumagi commented Apr 1, 2021

@noescape00, @zeptin , thank you for the valuable feedback. This (draft) PR demonstrates how we can increase the number of allowed signatures. I would see this as a shorter term solution. System contracts can, for now, give us the ability to modify the list of multi-sig members without necessarily replacing the redeem script itself with a smart contract. If you are suggesting that we skip this step then we are perhaps looking at something that will take a bit longer with a more complicated switch-over. On the flip-side we have to look at how we justify that complexity (= risk).

Note that the recently added OP_FEDERATION opcode allows us to dynamically push the multisig public keys onto the OP_CHECKMULTISIG evaluation stack instead of relying on hard-coded public keys in the redeem script. Those public keys are now sourced from the current federation and can just as easily be sourced from a simple system contract instead. A more dramatic change will involve changing the redeem script and a process including transferral of funds between old and new multisig addresses.

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.

3 participants