Heimdall-Industries / Heidrun

6 stars 8 forks source link

Buying resources not working #9

Open speedyconzales opened 1 year ago

speedyconzales commented 1 year ago

6 not resolved.

Got the following output:

 ### Resupplying <ship name> ###

  Not enough resources, claiming ATLAS
 ATLAS claimed successfully, buying resources
 Resources bought, resupplying

And the following error:

SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1
    at Connection.sendEncodedTransaction (/media/scripts/staratlas-automation/node_modules/@solana/web3.js/lib/index.cjs.js:6213:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Connection.sendRawTransaction (/media/scripts/staratlas-automation/node_modules/@solana/web3.js/lib/index.cjs.js:6170:20)
    at async Connection.sendTransaction (/media/scripts/staratlas-automation/node_modules/@solana/web3.js/lib/index.cjs.js:6160:12)
    at async sendTransactions (/media/scripts/staratlas-automation/start.js:124:10)
    at async refillResources (/media/scripts/staratlas-automation/start.js:298:10)
    at async /media/scripts/staratlas-automation/start.js:564:15
    at async /media/scripts/staratlas-automation/start.js:562:13
    at async Timeout.start [as _onTimeout] (/media/scripts/staratlas-automation/start.js:557:9) {
  logs: [
    'Program FLEET1qqzpexyaDpqb2DGsSzE2sDCizewCg9WjrA6DBW invoke [1]',
    'Program log: Refeeding with 10886 food',
    'Program log: Current capacity timestamp 1669269634',
    'Program log: Fuel capacity before 203015',
    'Program log: Food capacity before 0',
    'Program log: Arms capacity before 763601',
    'Program log: Health capacity before 420249',
    'Program log: Time passed: 1758',
    'Program log: Staked time 0',
    'Program log: Updating Staking Account to reflect time passed',
    'Program log: Increased TTS to 28891409',
    'Program log: Food quantity to deposit 10831',
    'Program log: Adding 349960 seconds to food capacity',
    'Program log: Transferring to Food Escrow Account',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]',
    'Program log: Instruction: TransferChecked',
    'Program log: Error: insufficient funds',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4485 of 768279 compute units',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: custom program error: 0x1',
    'Program FLEET1qqzpexyaDpqb2DGsSzE2sDCizewCg9WjrA6DBW consumed 36206 of 800000 compute units',
    'Program FLEET1qqzpexyaDpqb2DGsSzE2sDCizewCg9WjrA6DBW failed: custom program error: 0x1'
  ]
}

It still produces several transactions on the blockchain even if there is enough ATLAS to buy resources for months. It always claims new ATLAS. There is no information on the error itself. The error I get is the outcome of the missing resources but no information on the buy orders for the resources itself. As you can see in the output there is no „RESOURCE ORDER COMPLETED: “ for me. But also no indication why that is.

MartinGerritsen commented 1 year ago

After the update I have tried this and it worked fine, can you confirm that you pulled the latest version? factory has had no newer version

speedyconzales commented 1 year ago

I can't confirm that it was the latest version. In fact I did use an older version. So the output above is obsolete. My apologies for that.

Now I CAN confirm that I am on the latest version and it still fails to buy resources. The first ship was successfully refilled because the amount of resources on this account was sufficient for this type of ship. But the second ship needs more resources than I currently own, so there are those two lines indicating an error. No further error log created. The second instance of "Resources refilled successfully" is not valid because of the preceding error.

Current situation: Second ship was not successfully refilled -> Because no resources were bought

 ### Resupplying <first ship> ###

  Resources refilled successfully

 ### Resupplying <second ship> ###

 Something went wrong: undefined.
 Error message: undefined

  Resources refilled successfully

 Running Heimdall Industries Heiðrún Star Atlas Automation
 Last update: Tuesday, 06 December 2022 at 11:35:48
 Repeating process every 30 minute(s).

Sadly the error message is 'undefined', so that seems to be the next step for me. I do need a meaningful error message.

Proposal: Pleas use console.error(); for printing errors. Other programs like pm2 differentiate between information logging and error logging. e.g.: I do watch the error-log of the process, but when you use a normal print function it won't count as an error message. Although the program encounters an error the corresponding error-log is still blank.

speedyconzales commented 1 year ago

After the update I have tried this and it worked fine, can you confirm that you pulled the latest version? factory has had no newer version

Please have a look on my review of #7. I do not understand at which point this has worked for you. But I did debug the current version and it definitely wasn't working as intended. Therefore adjusting this part of the code did manage to buy the needed resources via Heidrun instead of buying them manually.