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

Cannot send message payloads that are not multiple of 32 bytes [RESEARCH NEEDED] #158

Open
DefiCake opened this issue Apr 5, 2024 · 0 comments
Assignees

Comments

@DefiCake
Copy link
Member

DefiCake commented Apr 5, 2024

Branch to track issue https://github.com/FuelLabs/fuel-bridge/tree/deficake/issue-158

Trying to pack a payload that is not multiple of 32 bytes (like in the picture) seems to conflict with fuel-core.

At relayCommonMessage.ts:

// Relay commonly used messages with predicates spendable by anyone
export async function relayCommonMessage(
  relayer: FuelWallet,
  message: Message,
  txParams?: Pick<
    ScriptTransactionRequestLike,
    'gasLimit' | 'gasPrice' | 'maturity'
  >
): Promise<TransactionResponse> {
  // find the relay details for the specified message
  let messageRelayDetails: CommonMessageDetails = null;
  const predicateRoot = message.recipient.toHexString();

  for (const details of getCommonRelayableMessages(relayer.provider)) {
    if (details.predicateRoot == predicateRoot) {
      messageRelayDetails = details;
      break;
    }
  }
  if (messageRelayDetails == null)
    throw new Error('message is not a common relayable message');

  // build and send transaction
  const transaction = await messageRelayDetails.buildTx(
    relayer,
    message,
    messageRelayDetails,
    txParams || {}
  );

  console.log(transaction);
  console.log(hexlify((transaction.inputs[0] as any).data!));
  console.log((transaction.inputs[0] as any).predicate.length);

 // This fails!!!
  return relayer.sendTransaction(transaction);
}

fuel-core will return the error:

NotInsertedIoMessageMismatch,
    #[error(
        "Transaction is not inserted. Input output mismatch. Expected coin but output is contract"
    )]

At dependency.rs:

// verify message id integrity
if !db_message
    .matches_input(input)
    .expect("Input is a message above")
{
    return Err(Error::NotInsertedIoMessageMismatch)
}
image
@DefiCake DefiCake self-assigned this Apr 11, 2024
@luizstacio luizstacio assigned luizstacio and DefiCake and unassigned DefiCake and luizstacio Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants