Getting error: ECDSA: invalid signature length

  1. I am using openzeppelin minimal forwarder, autotask and relayer to perform meta txns in dapp. But am getting invalid signature length. I am using this repo https://github.com/OpenZeppelin/workshops/tree/master/01-defender-meta-txs to simulate meta txns in dapp. Referred @spalladino demo video on meta txns. Please help.

Adding transaction details:

  1. Also all the meta txns reverted from contract are not showing error messages in the explorer. The above transaction got reverted from contract but showing success message instead if showing error message. This is making difficult to revert the txn in frontend as txn is success.

@spalladino can you help here

@spalladino @MartinVerzilli please help here, we are testing this in avalanche mainnet

I guess we should have require condition on success before function ends to check txn is success or not.

What will be the value of returndata here ?

not able to return any data from autotask to frontend. I am using fetch to call autotask webhook, when autotask is run, am returning data but the data is not present in fetch response.

documentation says I will get return values in result field, but I dont see any result field in response.
screenshot from documentation :


screenshot of autotask reponse

@dan_oz @ernestognw please look into this

Is the support for meta txns using MinimalForwarder stopped? I dont see any response from team.

Hey @kbhargav5, sorry for taking this long to answer. The Defender team is monitoring everything in the Defender category of the forum, so I'm moving it there.

The execution reverted is related to this question (the details are there):

Regarding the invalid signature length, I'd ask you for the contract code or a minimal reproducible script so I can take a look. The contract is not verified so I don't know what's happening under the hood

thanks @ernestognw , I have changed Minimal Forwarder contract to revert the txn with error message by including the require condition on success. Now transaction is getting failed in autotask. I need to send this txn hash or txn status from autotask to frontend. But am not able to send, as the response does not contain any result field.

documentation says response will get return values in result field, but I dont see any result field in response. Attached screenshots in the above conversation

@kbhargav5
If autotask end with failed status it means that error has been thrown and it was not cached by business logic. In order to return something as result in that case we would need to wrap our logic with try-catch block and return some value from catch block or later.

Hope that this helps.
If problem is not resolved by wrapping logic in try catch could you please share example of your autotask logic with us. Thanks

Best,
Zeljko

@zeljko ,

exports.handler = async function(event) {
  // Parse webhook payload
  if (!event.request || !event.request.body) throw new Error(`Missing payload`);
  const { request, signature } = event.request.body;
  console.log(`Relaying`, request);
  
  // Initialize Relayer provider and signer, and forwarder contract
  const credentials = { ... event };
  const provider = new DefenderRelayProvider(credentials);
  const signer = new DefenderRelaySigner(credentials, provider, { speed: 'fast' });
  const forwarder = new ethers.Contract(ForwarderAddress, ForwarderAbi, signer);
  
  // Relay transaction!
  const tx = await relay(forwarder, request, signature, signer);
  console.log("tx: ",tx);
  return tx;
}
async function relay(forwarder, request, signature, signer) {
  try{
  // Validate request on the forwarder contract
  console.log("verifying");
  console.log("request: ",request);
  console.log("signature: ",signature);
  
  const valid = await forwarder.verify(request, signature);
  if (!valid) throw new Error(`Invalid request`);
  console.log("verified");
  // Send meta-tx through relayer to the forwarder contract
  const gasLimit = (parseInt(request.gas) + 50000).toString();
  const tx = await forwarder.execute(request, signature, { gasLimit })
   await tx.wait();
    console.log("tx: ",tx)
    return tx
  }
  catch(ex){
    console.log("ex: ",ex);
    return ex
  }

  
}

am trying to return the result here as response to webhook call, but this response is not showing in result field. I dont see any result field in the response for neither success nor failed txns.

@kbhargav5
Interesting

Could you check that you receive same response when invoking webhook url when using Postman(POST request)?

@zeljko
I am getting result field in Postman request

Great!

So above posted image didn't have body in response, thats why I asked to try via Postman.
Depending on how you invoke that webhook url from your code you may be missing await operator or something else depending on what you use.

Best regards,
Zeljko

I am using the same way as in this repo

I tried adding await as well, but no result field in either cases.

Here is the code,

return await fetch(url, {
    mode: 'no-cors',
    method: 'POST',
    body: JSON.stringify(request),
    headers: {  'Accept': 'application/json','Content-Type': 'application/json' },
  });

Could you please verify that you use await higher in the chain.
If your code matches one from workshop then maybe some security policy blocks your request.

Best,
Zeljko

I got what is the issue. It is because of the header mode: 'no-cors', I have added this because I got CORS error with the request, but not getting now. I guess CORS error might get in future, any other way to resolve any issues from CORS

1 Like

@zeljko I see one more issue, sometimes fetch is returning the response with status: pending along with autotask id, instead of success, in this case there is no result field in the response

@kbhargav5
There is 25s timeout for invoking autotasks via webhooks. In case autotask is not finished response is returned with pending state.

In that case to get autotask result we could use autotask client library https://github.com/OpenZeppelin/defender-client/tree/master/packages/autotask-client and try to fetch result until status is in success or failed state.

Best,
Zeljko