AcalaNetwork / chopsticks

Create parallel reality of your Substrate network.
Apache License 2.0
135 stars 81 forks source link

signFakeWithApi not working for Moonbeam #845

Open albertov19 opened 1 week ago

albertov19 commented 1 week ago

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'
xlc commented 1 week ago

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?