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

Global nonces for account initialisation #455

Closed
adrianbrink opened this issue Feb 13, 2018 · 6 comments · Fixed by #1077
Closed

Global nonces for account initialisation #455

adrianbrink opened this issue Feb 13, 2018 · 6 comments · Fixed by #1077
Assignees

Comments

@adrianbrink
Copy link
Contributor

Proposal:
The hub has two nonces, a global and a local one
A new account gets initialised with the current value of the global nonce and then the global nonce gets incremented.

Benefits:

  • replay protection
  • state pruning

State pruning:
When an account goes to 0 (or non-relevant state) we can prune it from the state. Later we can reinitialise the same account (same private key) and still have replay protection.

This system avoids the pitfall of Ethereum, where we have a lot of empty and unused state and all nodes have to store it in their database.

@adrianbrink
Copy link
Contributor Author

@zmanian
Copy link
Member

zmanian commented Feb 13, 2018

So I designed a system very much like basecoin for Fabric that used this mechanism.

So if you use int64 for the counters, it is possible but unlikely that a number would overflow. Someone might have to think about it.

If you use hashes to increment and 32 byte nonces for the counters, no one will ever have to think about the birthday bound for the rest of life of the earth

@ebuchman
Copy link
Member

So we can currently remove accounts when they're empty, which solves the state pruning issue, but this would allow us to also re-use them again later - that's kind of neat

@adrianbrink
Copy link
Contributor Author

So, currently, we can remove an account (an address that is controlled by a private key) from the state and add it?
When we add this account later, doesn't that reset the nonce and opens up the account to replay attacks?

@ebuchman
Copy link
Member

ebuchman commented Mar 10, 2018

The downside to this approach is you have to know your global account number before you can spend from it - this means in general it may not be possible to receive funds for the first time and spend some of them within a single block.

An alternative is to sign a block number greater than or equal to the block in which the account was created. The "block the account was created" would need to be saved with the account so this can be checked, but its more flexible than needing to know the exact global account number.

That said, if we don't bound this number above, then a user could accidentally introduce the replay issue as follows:

  • account is created at block 100
  • user signs with number 1000
  • user empties account at block 500
  • funds are sent to account at block 900 (re creating account)
  • someone can now rebroadcast the old transaction with number 1000

Of course, this can only happen if the user messes up and uses a number that is too large - so the number used should be as close as possible to the block the account was created in ...

Another thing to note is that the signed number must also be included in the transaction so folks know what it is and can check (unlike the previous solution, where it can only be one thing, the global account nonce for that account).

Given that blocks are pretty fast, and there's some weirdness here, and no real savings, I'd probably actually vote for the original solution, but just wanted to type up these thoughts

@cwgoes
Copy link
Contributor

cwgoes commented Jun 15, 2018

Merged.

@cwgoes cwgoes closed this as completed Jun 15, 2018
ParthDesai pushed a commit to ChorusOne/cosmos-sdk that referenced this issue Apr 19, 2021
According to ICS 7, the correct Path is `"clients/{identifier}/consensusStates/{height}"` (plural).
Neoplayer pushed a commit to Neoplayer/cosmos-sdk that referenced this issue Jul 18, 2023
* Update golang version to 1.20, update actions versions

* Fix error in golang version parsing
chillyvee pushed a commit to chillyvee/cosmos-sdk that referenced this issue Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants