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

fix: set access key nonce on implicit account creation #5482

Merged
merged 25 commits into from
Nov 29, 2021

Conversation

Longarithm
Copy link
Member

@Longarithm Longarithm commented Nov 26, 2021

Fix access key nonce for implicit accounts to fully address the issue #3779.

The change is straightforward - formula for nonce should be the same as for explicit accounts, as here -

access_key.nonce = (apply_state.block_index - 1)
* near_primitives::account::AccessKey::ACCESS_KEY_NONCE_RANGE_MULTIPLIER;

Test plan

  • test_transaction_hash_collision_for_implicit_account_[ok|fail] - check that tx is applied or rejected depending on the protocol version.

@Longarithm Longarithm marked this pull request as ready for review November 26, 2021 15:29
@Longarithm Longarithm self-assigned this Nov 26, 2021
@Longarithm Longarithm added the A-transaction-runtime Area: transaction runtime (transaction and receipts processing, state transition, etc) label Nov 26, 2021
integration-tests/tests/client/process_blocks.rs Outdated Show resolved Hide resolved
integration-tests/tests/client/process_blocks.rs Outdated Show resolved Hide resolved
runtime/runtime/src/actions.rs Outdated Show resolved Hide resolved
chain/chain/Cargo.toml Show resolved Hide resolved
runtime/runtime/src/actions.rs Show resolved Hide resolved
core/primitives-core/src/account.rs Outdated Show resolved Hide resolved
integration-tests/tests/client/process_blocks.rs Outdated Show resolved Hide resolved
@near-bulldozer near-bulldozer bot merged commit d4b583e into master Nov 29, 2021
@near-bulldozer near-bulldozer bot deleted the fix-access-key branch November 29, 2021 23:57
near-bulldozer bot pushed a commit that referenced this pull request Dec 14, 2021
Stabilize #5482. Also, update changelog for 1.23.0 release.

## Reasoning

Previously, we changed formulas for tx nonce computation to avoid tx hash collisions: #3779 
Later we figured out that it was not enabled for implicit accounts - on its creation, we simply created new access key with nonce 0.
So we need this to make formula consistent among all accounts, and to get rid of tx hash collisions completely. The fix itself is straightforward.

## Testing 

Existing tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-transaction-runtime Area: transaction runtime (transaction and receipts processing, state transition, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants