chopsticks icon indicating copy to clipboard operation
chopsticks copied to clipboard

signFakeWithApi not working for Moonbeam

Open albertov19 opened this issue 1 year ago • 1 comments

Is the issue related to Moonbeam using ECDSA?

But when I try to use the signFakeWithApi utility of Chopsticks against Moonriver (in this case), I get:

RPC-CORE: submitExtrinsic(extrinsic: Extrinsic): Hash:: 1010: {"invalid":{"badProof":null}}

The code:

import { ApiPromise, WsProvider } from '@polkadot/api';
import { signFakeWithApi } from '@acala-network/chopsticks-utils';

import yargs from 'yargs';

// Get input arguments
const args = yargs.options({
  endpoint: { type: 'string', demandOption: true, default: 'ws://127.0.0.1:8000', alias: 'e' },
  sender: { type: 'string', demandOption: true, alias: 's' },
}).argv;

const main = async () => {
  console.log('--- Chopsticks Test Started ---');

  const chopsticksProvider = new WsProvider(args['endpoint']);
  const chopsticksAPI = await ApiPromise.create({
    provider: chopsticksProvider,
    noInitWarn: true,
  });

  // Call
  const tx = await chopsticksAPI.tx.system.remark('Test');

  // Test
  console.log(tx.method.toHex());
  await signFakeWithApi(chopsticksAPI, tx, args['sender']);
  await tx.send();

  console.log('--- Chopsticks Test Done ---');
  await chopsticksAPI.disconnect();
};

main();

Call Moonriver-Chopsticks (Fails):

ts-node ./chopsticks_fakeTx.ts --sender '0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac'

Call Polkadot-Chopsticks(OK):

ts-node ./chopsticks_fakeTx.ts --sender '15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5'

albertov19 avatar Oct 24 '24 11:10 albertov19

I did a quick check of the code and the way mocking works should support all signing algorithms but we never tested it with ECDSA so maybe there is an issue somewhere. Also is there any chance that Moonbeam verifies the signature in runtime instead of using host functions?

xlc avatar Oct 24 '24 21:10 xlc