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

Increase the Nonce in account contract #82

Closed
ltdai010 opened this issue Nov 26, 2021 · 7 comments
Closed

Increase the Nonce in account contract #82

ltdai010 opened this issue Nov 26, 2021 · 7 comments

Comments

@ltdai010
Copy link

ltdai010 commented Nov 26, 2021

When I try sending execute method in Account contract, if the transaction is failed, the nonce is not update and I can't transfer again

  • Problem
    I tried creating a transaction and sent it. It's failed then I can't call the transaction anymore, unless I call another transaction to increase the nonce, then come back again
  • Solution
    So I think we can create an increase nonce method, to pass in the current nonce and update the nonce to the next nonce? So I can increase the nonce and call execute again.
@martriay
Copy link
Contributor

martriay commented Nov 26, 2021

If the transaction fails the nonce should not change. Adding an increase_nonce method wouldn't make sense since it has to be called through execute, which already increases the nonce anyway. Also note that the whole issue is not being able to call execute, no way to call increase_nonce through it.

I think you are having another issue, can you share code and steps to reproduce the issue?

@ltdai010
Copy link
Author

You can reproduce this by this way:

  • sending a transaction with payload. But wrong signature.
  • sending it again with the right signature, but it will not work. Because the payload is same lead to tx hash same(idk if StarkNet will change this), no way to recall the transaction then. Unless increase the nonce by calling another transaction.

@agolajko
Copy link

agolajko commented Dec 1, 2021

I bumped into the same problem today, and thought a bit about what is causing the issue. The issue seems to be that the execute command does not take a nonce from the user (there is a nonce argument but it's only used between the Account and the called contract, and has to take the value of _current_nonce). So there is no nonce between the "wallet" and the account. Perhaps adding an extra nonce between the wallet and the account might fix this?

@ltdai010
Copy link
Author

ltdai010 commented Dec 2, 2021

I think this problem should be fix by StarkNet itself. Adding timestamp or something when compute the hash to solve it.
Now, I just added increase nonce function in case anything go wrong.

@agolajko
Copy link

agolajko commented Dec 2, 2021

Yeah agree this seems to be on the plate of StarkNet to solve. Maybe doing what Ethereum mainnet is doing with the built in nonces would work. My current workaround (without changing the code) is passing different nonce values as inputs to the execute call and to the signature inside the call.

@bbrandtom
Copy link

Hi all,
I agree it's currently a problem. Solving the problem consist of two parts - ensuring transaction unicity on the protocol level, and splitting between transaction validation and transaction execution.
We are working atm on a new account abstraction model where those two topics are being handled and I think it will solve the issue you are describing here.

@martriay
Copy link
Contributor

Considering this is being solved by the upcoming validation/execution transaction split, I'm closing this issue.

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

4 participants