solana-labs / solana

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
https://solanalabs.com
Apache License 2.0
13.19k stars 4.3k forks source link

@solana/web3.js: Transaction message mutated after being populated from Message #25084

Closed gabrielhicks closed 2 years ago

gabrielhicks commented 2 years ago

Problem

When creating a transaction specifically using Firefox, the transaction is terminated early with error Transaction message mutated after being populated from Message

I was originally using 1.20.0, and after reading #24462 I upgraded to 1.38.0 and then 1.41.4.

Code example:

    async (address: PublicKey) => {
      if (!publicKey) return;
      await sendAndConfirmTransaction(
        await createWithdrawRewardTransaction(connection, publicKey, address)
      );
    },
    [connection, publicKey, sendAndConfirmTransaction]
  );`
...
const sendAndConfirmTransaction = React.useCallback(
    async (transaction) => {
      let { blockhash } = await connection.getLatestBlockhash("singleGossip");
      transaction.feePayer = publicKey!;
      transaction.recentBlockhash = blockhash;

      let signature = await sendTransaction(transaction, connection);
      await connection.confirmTransaction(signature, "confirmed");
      toast({
        title: 'Transaction Successful',
        description: 'Tx: ${signature}',
        status: "success",
        duration: 3000,
        isClosable: true,
      });
      console.log(signature);

      if (onChange) onChange();

      forceRefresh();
      return signature;
    },
    [connection, publicKey, sendTransaction, onChange, toast]
  );
  ...
 let transaction = new Transaction();

  transaction.add(
    await createWithdrawRewardInstruction(owner, token, candyMachine)
  );
  return transaction;

createWithdrawRewardInstruction then populates the instructions and accounts being sent back. Im unaware exactly of what might be causing this issue but found it very interesting that it was predominantly reported by Firefox users. I am able to recreate this error using a combination of Firefox + Phantom wallet. Firefox + Sollet throws the error but completes the transaction. Wallets on Chrome seem to be fine and I was unable to recreate using Chrome.

m30m commented 2 years ago

We also had multiple reports of this with firefox users.

snowplowtach commented 2 years ago

I have the same error since I updated phantom extension. (chrome)

javmeister commented 2 years ago

This is happening to us on Chrome+Phantom today out of nowhere, even with the most basic transaction SystemProgram.transfer() to send x tokens from our wallet A to somebody else wallet B.

I am assuming Phantom got updated in the last 24 hours, all of the sudden developing on the devnet worked smoothly this morning after all the headaches of the past couple of weeks.. but obviously until we starting clicking on 'Approve' and :boom:

Also I haven't checked on the mainnet yet, only devnet so far today.

I am opening a support request for Phantom, will post here if/when they reply.

gabrielhicks commented 2 years ago

Update: After upgrading Chrome and Brave I am now experiencing this error on both.

gabrielhicks commented 2 years ago

Update: Phantom has publicly acknowledged this issue on Twitter today and is pushing changes, please see this link: https://twitter.com/bfriel_/status/1524128093585117184