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

INVALID_NODE_ACCOUNT returned when submitting a signed transaction from different client objects #1813

Closed
pathornteng opened this issue Aug 21, 2023 · 5 comments · Fixed by #1815
Assignees
Labels
bug Something isn't working
Milestone

Comments

@pathornteng
Copy link

pathornteng commented Aug 21, 2023

Description

We have got an error INVALID_NODE_ACCOUNT when the user create a transaction with one client instance and then submit a transaction with another client instance.

Steps to reproduce

Here is the code that can reproduce the problem

  const myAccountId = process.env.MY_ACCOUNT_ID;
  const myPrivateKey = PrivateKey.fromString(process.env.MY_PRIVATE_KEY);

  let client = Client.forTestnet();

  client.setOperator(myAccountId, myPrivateKey);

  let newAccount = await new AccountCreateTransaction()
    .setKey(myPrivateKey)
    .setInitialBalance(Hbar.from(10))
    .setTransactionValidDuration(30)
    .freezeWith(client);
  newAccount = await newAccount.sign(myPrivateKey);

  console.log("- Wait 20 seconds", new Date().toISOString());
  await new Promise((r) => setTimeout(r, 20000));
  console.log("- Go", new Date().toISOString());

  const newAccountBytes = newAccount.toBytes();
  const newAccountObj = Transaction.fromBytes(newAccountBytes);

  client = Client.forTestnet();
  client.setOperator(myAccountId, myPrivateKey);

  const tx = await newAccountObj.execute(client);

  // Get the new account ID
  const getReceipt = await tx.getReceipt(client);
  const newAccountId = getReceipt.accountId;

  console.log("The new account ID is: " + newAccountId);

Additional context

No response

Hedera network

mainnet, testnet, previewnet

Version

v2.29.0

Operating system

None

@pathornteng pathornteng added the bug Something isn't working label Aug 21, 2023
@petreze petreze added this to the 2.33.0 milestone Aug 21, 2023
@petreze petreze self-assigned this Aug 21, 2023
@petreze
Copy link
Contributor

petreze commented Aug 21, 2023

@pathornteng
Greetings, first of all, you are using the same client instance for the entire code example. Also the issue comes from setting .setTransactionValidDuration(30). If you remove it or increase it a bit more, it is executing successfully!

@pathornteng
Copy link
Author

Hi @petreze, thank you for taking a look. Sorry I have updated the code. I intentionally set low transaction valid duration to save the time and make it easy to reproduce for you or you can remove .setTransactionValidDuration(30) but you have to wait a bit longer to reproduce the problem. I believe that the SDK should never submit the signed transaction to a wrong node account.

@petreze
Copy link
Contributor

petreze commented Aug 21, 2023

Could you please try with the newest version of the SDK as I see you are using v2.29.0 and we did some changes throughout the versions

@pathornteng
Copy link
Author

Hi @petreze, I tried with v2.32.0 but still got the same problem.

@petreze
Copy link
Contributor

petreze commented Aug 28, 2023

Hi @pathornteng
There will be a potential fix with the newest release where we improve the node selection.
Note: I did not experience the issue you mentioned even with the previous versions. I will close this one and if you experience it with the v2.33.0 you can reopen. (I can also release a beta version for you to test if you say so?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants