-
Notifications
You must be signed in to change notification settings - Fork 690
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
refactor: Reintroduce strictly typed AccountId #4621
Conversation
…ear#4440) This PR introduces a strictly typed structure - `AccountId` that enforces account ID validation. This way, we can ensure validity and thereby fail fast before an invalid account name is used. This also, optionally, ensures validation on {,de}serialization so, yeah.. The structure is defined within its own self-contained crate `near-account-id` to allow for easy publishing. The extra dependencies - `borsh`, `serde` are made optional to allow the crate to be lightweight enough to be depended upon. Within `nearcore`, the structure is reexported via `near_primitives::AccountId` and the crate via `near_primitives{,_core}::account::id` with default features (`borsh`, `serde`) but you can opt-out of those by depending on it directly. Resolves near#2074, supersedes near#2831. * [x] Existing unit tests pass with minor updates * [x] Nayduck tests pass without modifications * [x] Manually ensured that the protocol is not changed
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.
@miraclx the PR is very large. Could you point to where exactly the fix is?
@miraclx Please, provide more context about the issue with the Access Keys in the genesis file (it is even better if you provide the specific examples with the invalid account ids we have there) @bowenwang1996 I asked @miraclx to prepare the PR in such a way that the first commit is a squash-commit from the previous PR, and the second commit is the patch on top of that, so see the second commit. |
We have invalid AccountId-s in
With the previous behavior not doing any validation, this is an impediment to our initiative of using strictly typed AccountId's everywhere. To remedy this, we retain the previous behavior and strictly define this field as a String. |
This PR introduces a strictly typed structure - `AccountId` that enforces account ID validation. This way, we can ensure validity and thereby fail fast before an invalid account name is used. This also, optionally, ensures validation on {,de}serialization so, yeah.. The structure is defined within its own self-contained crate `near-account-id` to allow for easy publishing. The extra dependencies - `borsh`, `serde` are made optional to allow the crate to be lightweight enough to be depended upon. Within `nearcore`, the structure is reexported via `near_primitives::AccountId` and the crate via `near_primitives{,_core}::account::id` with default features (`borsh`, `serde`) but you can opt-out of those by depending on it directly. Resolves #2074, supersedes #2831. * [x] Existing unit tests pass with minor updates * [x] Nayduck tests pass without modifications * [x] Manually ensured that the protocol is not changed * [x] Manually booted a testnet node to ensure genesis loads properly and that no further AccountId-related issues occur. * [x] Ensured unit tests pass with no further updates * [x] Nayduck tests pass without modifications
…_id != AccountId (#4773) Resolves #4739: documents why the `receiver_id` field in `FunctionCallPermission` isn't an `AccountId` despite recently refactoring the whole workspace to using strict `AccountId`-s. See #4621 (comment) for more context
Resolves #4600
Reintroduces refactor: Introduce strictly typed and assuredly validated AccountId #4440 (reverted in Revert "refactor: Introduce strictly typed and assuredly validated Ac… #4601)
Fixes issue of loading genesis with records of invalid AcountId-s in AccessKey-s
Nayduck
http://nayduck.eastus.cloudapp.azure.com:3000/#/run/1943
Testing Plan