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

[Feature Request] Add ability to simulate a transaction as if proposed to a multisig account #582

Open
mshakeg opened this issue Nov 15, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@mshakeg
Copy link

mshakeg commented Nov 15, 2024

🚀 Feature Request Description

Add the ability to simulate a transaction that would be proposed to a multisig account without requiring the transaction to be actually proposed first.

Motivation

Is your feature request related to a problem? Please describe you use case.

When working with multisig accounts, it's currently not possible to simulate what would happen if a proposed transaction were to be executed by the multisig account without first creating the proposal transaction. This means developers have to:

  1. Create and submit a proposal transaction (costing gas)
  2. Wait for proposal transaction to be committed
  3. Try to execute the transaction to see if it would succeed
  4. If the execution would fail, create another transaction to cleanup/remove the failed proposal

Having the ability to simulate before proposal would:

  • Save gas costs from failed proposals
  • Save time in development/testing
  • Improve UX by catching errors before proposals are made
  • Allow better estimation of gas costs for multisig executions

Pitch

Describe the solution you would like

Add a new simulation method specifically for multisig transactions that:

  1. Takes a would-be proposal's payload
  2. Simulates it as if it were being executed by the multisig account
  3. Returns simulation results without requiring an actual proposal to exist

Example API:

const [response] = await aptos.transaction.simulate.multisig({
  multisigAddress,
  payload: {
    function: "0x1::coin::transfer",
    functionArguments: [recipient, amount],
    typeArguments: ["0x1::aptos_coin::AptosCoin"]
  }
});

This would simulate the transaction as if it were being executed by the multisig account without requiring a proposal to exist first.

Describe alternatives you've considered

  1. Current approach of simulating with multisig payload - fails with MULTISIG_TRANSACTION_NOT_FOUND because it expects a proposal to exist
  2. Simulating as direct execution from multisig account - fails with INVALID_AUTH_KEY because auth validation can't be bypassed
  3. Creating temporary proposals for simulation - works but costly and requires cleanup

Are you willing to open a pull request?

I suspect this will require changes to Aptos core, and I don't have much familiarity with rust and that codebase so I wouldn't be as effective as a core dev.

Additional context

This is particularly important for dApps that use multisig accounts for protocol operations. Being able to simulate transactions before proposal would significantly improve the development experience and reduce costs from failed proposals.

Related code showing current limitations:

// Currently fails with MULTISIG_TRANSACTION_NOT_FOUND
const tx = await aptosClient.transaction.build.simple({
  sender: deployer.accountAddress,
  data: {
    multisigAddress,
    ...entryPayload
  }
});

const [response] = await aptosClient.transaction.simulate.simple({
  signerPublicKey: deployer.publicKey,
  transaction: tx
});
@mshakeg mshakeg added the enhancement New feature or request label Nov 15, 2024
@gregnazario
Copy link
Collaborator

Thanks for the request @mshakeg

Check out this example https://github.com/aptos-labs/aptos-ts-sdk/blob/main/examples/typescript-esm/multisig_v2.ts#L144-L162 it was updated a week ago, and the feature flag for mainnet was turned on I think today. It allows you to simulate as other accounts, without necessarily having the public key / transactions.

Let us know if you have any feedback or it doesn't solve your problem cc @junkil-park

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants