-
Notifications
You must be signed in to change notification settings - Fork 383
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
feat: remove traces of account number from the account object #3213
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
There is a minor security benefit that may seem negligible. For example, similar to Having different I need a bit more time to consider the impact. Edit: I remember considering a similar approach. My idea was not to remove it but to make it optional, allowing you to choose between explicitness and implicitness. I wanted to extend this option to both the account number and the sequence number. However, the sequence number has a greater impact on security. |
go.uber.org/zap v1.27.0 | ||
golang.org/x/time v0.5.0 | ||
) | ||
|
||
replace github.com/gnolang/gno => ../.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be kept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This replace
was originally removed, not sure when it was added back in 🙁
The gnofaucet
cannot have a replace, because gnolang/faucet
(imported by gnofaucet
) imports gnolang/gno
, and it's going to cause a build error since the API changed in this version of gnolang/gno
-- we want gnofaucet
to use an old version of gnolang/gno
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thinking gnolang/faucet
should be moved into the monorepo or gnofaucet
out of it; in any case fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move it in the monorepo.
The only reasoning I can think of for keeping the The benefits of dropping it are we can minimize the amount of chain queries we do for regular transaction signing (ex. in Adena, or any signing client), and that we can now return values for uninitialized accounts (zero balance, zero sequence). It makes the signing logic cleaner and simpler |
return GetSignaturePayload(SignDoc{ | ||
ChainID: chainID, | ||
AccountNumber: accountNumber, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm considering whether it makes sense to replace AccountNumber with the pubkey here. However, since we're signing with the corresponding privkey and appending the pubkey to the tx, it may be unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still lack some context and a deep knowledge of the codebase, but after some live discussions, reading the PR on Cosmos, and considering the arguments presented in the other comments, I feel that it's safe to remove this value. In fact, if it is truly unnecessary, it is important to eliminate it for the sake of clarity, especially when it comes to data related to security.
About adding a pub key field, there is no point in doing it IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added several reviewers.
Blocking progress until Jae has a chance to review it. However, we shouldn't wait for Jae to continue the review.
@zivkovicmilos As mentioned in the issue #661, why not return an error if the account doesn't exist ? This is what the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall lgtm and agree to remove it
@tbruyelle I am actually totally fine with the uninitialized accounts erroring out like they do now, we handle this in all of our clients |
I see OK. It is likely that the presence of the account number in gno is a simple port from the SDK codebase, and interestingly I was able to find the origin of the account number : cosmos/cosmos-sdk#1077 As noted in the PR, the account number was added as a security measure, actually a replay protection, but in the context of account pruning (account removed from state when balance is 0). However, I don't know much about state pruning so I can't say if this is still relevant. Maybe someone else can jump in and explain if this is still relevant. |
Following up after doing some digging and talking with people: Accounts are never pruned from the SDK / Cosmos state, only blocks. So we should be safe to remove Account Numbers 🫡 |
I'm a bot that assists the Gno Core team in maintaining this repository. My role is to ensure that contributors understand and follow our guidelines, helping to streamline the development process. The following requirements must be fulfilled before a pull request can be merged. These requirements are defined in this configuration file. Automated Checks🔴 Maintainers must be able to edit this pull request Manual ChecksNo manual checks match this pull request. Debug
|
Note about potentially related topics:
For these topics, using an account number may optimize storage and computing in some cases while allowing the I am still considering the impact of this change. There is currently no strict blocker, and I prefer to make it optional or remove it altogether. |
Thinking about #1499 I think having an account number would actually be problematic in the sense of account abstraction, since an account object is something that currently needs to be initialized in the blockchain state, across nodes.
Making it optional will most likely introduce more overhead than actually keeping the account number outright, because we'd need to juggle 2 signing implementations at all times |
I have one more line of inquiry on this topic I'm researching, and then I'll chime in here. |
After discussing with @jaekwon, we've decided to not go in the direction of removing account numbers from Gno, but instead focus on having actually working account pruning from the client, which the account information makes easier to do. I will do research on the storage impact for pruning empty accounts, and post my findings in a separate issue / PR 🙏 |
Summary of my current understanding, for the sake of posterity: In the Cosmos SDK (and later Gno via copy/paste), the code documents account numbers as providing replay protection for pruning nodes. There are a few scenarios in which replay attacks can take place:
Within the same network, the sequence number prevents replays of the same transaction. Pruning validators should not prune the current sequence number of any given account, and therefore pruning shouldn't be an issue. Account numbers shouldn't help here, either, because there is just one, consistent account number for each address. During chain splits, things get slightly more complicated; two transactions in partitioned validator sets could be identical or even different but with the same sequence number; in this case, resolving the discrepancy is a job for the consensus algorithm. Account numbers could only help here in the edge case that the split chains assign different account numbers to the same address/public key, but would only be a small potential help in de-conflicting temporary splits and doesn't relate to replay protection. @moul is correct that the account number can be a failsafe against running the same gnokey command on different networks, but I wouldn't consider this a significant enough safety measure to make a decision about account numbers way or the other. |
Description
This PR removes the
Account Number
from the account object.The account number is a sequential number generated from the internal chain state, to initialize accounts.
It serves no security benefits, given that the account object already has a
Sequence
for replay protection, and accounts are never deleted in TM2.Having it introduces a large overhead on maintaining it, and not being able to return "empty" accounts. It also introduces friction when generating transaction signatures, as the client would need to go to the chain to fetch the active account number.
Starts the process of closing #661.
Related:
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description