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

refactor(multisig)!: move from triggers to custom instructions #5217

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

s8sato
Copy link
Contributor

@s8sato s8sato commented Nov 2, 2024

Context

  1. Calling a trigger with args as a multisig operation was not a clear interface
  2. The multisig implementation as triggers introduced validation exceptions for registering and executing triggers to bridge the authority gap between the caller and the executor: feat: improve multisig utility and usability #5027

Solution

  1. Assign dedicated custom instructions to the multisig operations
  2. Switch to the executor context and package validation and execution logics as the custom instructions
  • As a side benefit of removing triggers i.e. no event pools, recursive approvals immediately propagate without ticking time

Migration Guide

  • Introduces MultisigRegister MultisigPropose MultisigApprove custom instructions that replace MultisigAccountArgs MultisigTransactionsArgs
  • Removes CanRegisterAnyTrigger CanUnregisterAnyTrigger permissions that become useless and are unlikely to be used
  • Though it becomes useless for multisig, retains the capability to register wasm triggers in genesis

Future Work


Checklist

  • I've read CONTRIBUTING.md.
  • All review comments have been resolved.
  • All CI checks pass.

@github-actions github-actions bot added api-changes Changes in the API for client libraries config-changes Changes in configuration and start up of the Iroha labels Nov 2, 2024
Copy link

github-actions bot commented Nov 2, 2024

@BAStos525

@s8sato s8sato force-pushed the refactor/4930/custom_instructions branch from e8e1316 to a6b0dce Compare November 2, 2024 21:39
wasm/libs/default_executor/src/lib.rs Outdated Show resolved Hide resolved
wasm/libs/default_executor/src/multisig/account.rs Outdated Show resolved Hide resolved
@s8sato s8sato self-assigned this Nov 2, 2024
@s8sato s8sato marked this pull request as ready for review November 2, 2024 22:11
@s8sato s8sato enabled auto-merge (squash) November 2, 2024 22:13
Copy link
Contributor

@mversic mversic left a comment

Choose a reason for hiding this comment

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

amazing stuff, so much better

crates/iroha_executor/src/default.rs Outdated Show resolved Hide resolved
crates/iroha_executor/src/lib.rs Outdated Show resolved Hide resolved
crates/iroha_multisig_data_model/src/lib.rs Outdated Show resolved Hide resolved
crates/iroha_multisig_data_model/src/lib.rs Outdated Show resolved Hide resolved
crates/iroha_multisig_data_model/src/lib.rs Outdated Show resolved Hide resolved
crates/iroha_telemetry_derive/Cargo.toml Outdated Show resolved Hide resolved
defaults/genesis.json Outdated Show resolved Hide resolved
crates/iroha_multisig_data_model/src/lib.rs Outdated Show resolved Hide resolved
crates/iroha/tests/multisig.rs Outdated Show resolved Hide resolved
crates/iroha_multisig_data_model/src/lib.rs Outdated Show resolved Hide resolved
@s8sato s8sato force-pushed the refactor/4930/custom_instructions branch from 5b0dbeb to 4e4a6b9 Compare November 4, 2024 07:14
@s8sato
Copy link
Contributor Author

s8sato commented Nov 4, 2024

Self-reviewed and made fixes 4e4a6b9 0e4fc3a for now. I'm going to address your comments tomorrow @mversic

@s8sato s8sato force-pushed the refactor/4930/custom_instructions branch 2 times, most recently from 48753cb to 0e4fc3a Compare November 4, 2024 10:42
BREAKING CHANGES:

- (api-changes) `MultisigRegister` `MultisigPropose` `MultisigApprove` custom instructions

Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
…ssions

Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
…ions

Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
@s8sato s8sato force-pushed the refactor/4930/custom_instructions branch from e0390e9 to f3eae2c Compare November 8, 2024 14:12
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
@s8sato s8sato force-pushed the refactor/4930/custom_instructions branch from f3eae2c to bd20861 Compare November 8, 2024 14:49
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
…ecution"

This reverts commit 17287d3.

Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
@s8sato
Copy link
Contributor Author

s8sato commented Nov 11, 2024

Updates:

  • (partially) dedup and delegate MultisigApprove validation to execution

Left to next PR #4930 (comment):

  • suspect every metadata existence and format

@s8sato s8sato force-pushed the refactor/4930/custom_instructions branch from 8ff9018 to 35b3865 Compare November 11, 2024 17:57
@DCNick3 DCNick3 self-assigned this Nov 12, 2024
@s8sato s8sato mentioned this pull request Nov 13, 2024
mversic
mversic previously approved these changes Nov 14, 2024
@s8sato
Copy link
Contributor Author

s8sato commented Nov 15, 2024

Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
This reverts commit 9108bb7.

Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
@s8sato s8sato force-pushed the refactor/4930/custom_instructions branch from 0306c05 to 6eac0f6 Compare November 15, 2024 04:24
@mversic mversic self-requested a review November 15, 2024 07:17
Copy link
Contributor

@DCNick3 DCNick3 left a comment

Choose a reason for hiding this comment

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

Only minor comments, otherwise LGTM

let approver = approvers.next().unwrap();
let res = alt_client(approver, &test_client).submit_blocking(approve.clone());
match (&transaction_ttl_ms_opt, &unauthorized_target_opt) {
(None, None) => assert!(res.is_ok()),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: (here and below) res.unwrap() and res.unwrap_err() provide better diagnostics than plain assert!(res.is_ok()), since they would print the error message

}

if role.id().name().as_ref().starts_with(MULTISIG_SIGNATORY) {
if let Some(multisig_account) = multisig_account_from(role.id()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would

let Some(multisig_account) = multisig_account_from(role.id()) else { 
    deny!(executor, "violates multisig role name format")
}

work here? I find it when the shorter case of the if-else comes first it's easier to read.

);

if is_expired {
// TODO Notify that the proposal has expired, while returning Ok for the entry deletion to take effect
Copy link
Contributor

Choose a reason for hiding this comment

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

Would using Log instruction work here? Or do you have some kind of client-retrievable notification?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Reflected every feedback in another PR #5240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-changes Changes in the API for client libraries config-changes Changes in configuration and start up of the Iroha
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants