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

feat(runtime): restrict creation of Ethereum address on NEAR #9365

Closed
wants to merge 4 commits into from

Conversation

bowenwang1996
Copy link
Collaborator

Implements near/NEPs#492

core/account-id/src/lib.rs Outdated Show resolved Hide resolved
@bowenwang1996 bowenwang1996 force-pushed the restrict-ethereum-address branch 2 times, most recently from d0d8d4a to 280689e Compare September 6, 2023 14:05
@bowenwang1996
Copy link
Collaborator Author

The associated NEP near/NEPs#492 has been approved and this implementation is ready for review

Copy link
Contributor

@jakmeier jakmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good but I think I prefer changing min_allowed_top_level_account_length instead of hard-coding different conditions. See my in-line comment for context.

@@ -120,6 +120,8 @@ pub enum ProtocolFeature {
RejectBlocksWithOutdatedProtocolVersions,
#[cfg(feature = "protocol_feature_simple_nightshade_v2")]
SimpleNightshadeV2,
#[cfg(feature = "protocol_feature_restrict_tla")]
RestrictTLA,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with our codebase, please capitalize only the first letter of acronyms. NearVmRuntime is an example of this. This is also in line with Rust RFC 430.

Suggested change
RestrictTLA,
RestrictTla,

Comment on lines +400 to +413
let old_condition_for_error = account_id.len()
< account_creation_config.min_allowed_top_level_account_length as usize
&& predecessor_id != &account_creation_config.registrar_account_id;
let new_condition_for_error = !account_id.is_implicit()
&& predecessor_id != &account_creation_config.registrar_account_id;
let is_error = if checked_feature!(
"protocol_feature_restrict_tla",
RestrictTLA,
current_protocol_version
) {
new_condition_for_error
} else {
old_condition_for_error
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens to the now obsolete parameter min_allowed_top_level_account_length: 32?
Have you considered to instead just set min_allowed_top_level_account_length: 65 instead of this code change? Something like 139.yaml:

# Implements NEP-492, disallowing all top-level accounts.
min_allowed_top_level_account_length: { old: 32, new: 65 }

I think doing it this way would be less confusing for future development, and it also gives private shards the freedom to overwrite this setting for their purposes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @chefsale @mhalambek

Please let us know if you have an opinion on top-level account creation. If Calimero relies on top-level account creation by non-registrar accounts, it would be crucial to know before we stabilize this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens to the now obsolete parameter min_allowed_top_level_account_length: 32? Have you considered to instead just set min_allowed_top_level_account_length: 65 instead of this code change? Something like 139.yaml:

# Implements NEP-492, disallowing all top-level accounts.
min_allowed_top_level_account_length: { old: 32, new: 65 }

I think doing it this way would be less confusing for future development, and it also gives private shards the freedom to overwrite this setting for their purposes.

yeah this is a very good point. I should stop writing code :)

@bowenwang1996
Copy link
Collaborator Author

Close this one in favor of #9589 (a simpler approach, as suggested by @jakmeier)

@bowenwang1996 bowenwang1996 deleted the restrict-ethereum-address branch September 26, 2023 04:11
frol pushed a commit to near/NEPs that referenced this pull request Nov 16, 2023
Proposal to restrict the creation of Ethereum addresses on NEAR to
prevent loss of funds and enable future possibilities for Ethereum
wallets to support NEAR transactions.

Implementation: near/nearcore#9365
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

Successfully merging this pull request may close these issues.

3 participants