aptos-labs / aptos-core

Aptos is a layer 1 blockchain built to support the widespread use of blockchain through better technology and user experience.
https://aptosfoundation.org
Other
6.19k stars 3.66k forks source link

[Bug] Failing to simulate publish_package_txn, but sending tx works. #14871

Open KodamaXYZ opened 1 month ago

KodamaXYZ commented 1 month ago

🐛 Bug

Hi team, I am trying to build a platform for contract deployment allowing users to easily deploy contracts. while developing I noticed that when publishing a contract without simulation it works, but when I prompt my user's wallets they automatically simulate the tx offered resulting in failed a simulation preventing them to deploy the package from my frontend.

To reproduce

I kinda followed the steps suggested in your repo: https://github.com/aptos-labs/aptos-ts-sdk/blob/1ceef3449781d56cbefa8d4350808cfc385d233b/examples/typescript/utils.ts#L42

const { metadataBytes, byteCode } = getPackageBytesToPublish(
        package_json_name,
      );

// building a publish package tx.
 const transaction = await aptos.publishPackageTransaction({
        account: acc.accountAddress,
        metadataBytes,
        moduleBytecode: byteCode,
      });

let simm = await aptos.transaction.simulate.simple({signerPublicKey: acc.publicKey, transaction: transaction})

https://api.mainnet.aptoslabs.com/v1/transactions/simulate (trace_id:d86821f11ad105c53d01fb9554404edb) failed with:

{"message":"Failed to convert transaction data from storage: Module ModuleId { address: b5e06093d4af611328f9db6c00df4724a44d123404e1595118fe64e564c55054, name: Identifier(\"Test\") } can't be found","error_code":"internal_error","vm_error_code":null}

Expected Behavior

Should pass, as sending this tx works. (even if simualtion fails)

System information

all latest, aptos cli - latest, working with mainnet. etc..

Please complete the following information:

Additional Context: It seems to me like the Simulation is not going through the same flow as actually performing the tx. There must be a way to publish transactions with simulation. let me know if you need additional information.

georgemitenkov commented 5 days ago

A few questions:

But this definitely seems off, thanks for reporting!