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

NEP-452 Linkdrop Standard #452

Merged
merged 29 commits into from
Jan 27, 2024
Merged

NEP-452 Linkdrop Standard #452

merged 29 commits into from
Jan 27, 2024

Conversation

BenKurrek
Copy link
Contributor

@BenKurrek BenKurrek commented Jan 24, 2023

Discussions found here.


NEP Status (Updated by NEP moderators)

SME reviews:

Contract Standards WG voting indications:

Wallet Standards WG voting indications:

@BenKurrek BenKurrek requested a review from a team as a code owner January 24, 2023 14:31
@render
Copy link

render bot commented Jan 24, 2023

@BenKurrek BenKurrek changed the title Linkdrop NEP NEP452 - Linkdrop Standard Jan 24, 2023
@BenKurrek BenKurrek changed the title NEP452 - Linkdrop Standard NEP-452 Linkdrop Standard Jan 24, 2023
Copy link
Member

@mfornet mfornet left a comment

Choose a reason for hiding this comment

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

We need to gather input from wallet developers since this interface will mostly be used from different wallets.

@near/wg-wallet-standards @near/near-wallet @near/wallet-core-contributors

neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
Co-authored-by: Marcelo Fornet <mfornet94@gmail.com>
Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

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

Thank you @BenKurrek for submitting this NEP.

As a moderator, I reviewed this NEP and it meets the proposed template guidelines. I am moving this NEP to the REVIEW stage and would like to ask the @near/wg-contract-standards and @near/wg-wallet-standards working group members to assign 2 Technical Reviewers (let's have one person with the Wallet expertise and one person with the Contracts expertise) to complete a technical review (see expectations). If you want to assign yourself, please mention that you are acting as the Technical Reviewers.

Please find some guidelines below for completing the technical review.

Technical Review Guidelines
  • First, review the proposal within one week. If you have any suggestions that could be fixed, leave them as comments to the author. It may take a couple of iterations to resolve any open comments.

  • Second, once all the suggestions are addressed, produce (example):

    • A recommendation for the working group if the NEP is ready for voting (it could be approving or rejecting recommendation)

    • A summary of benefits

    • A summary of concerns and blockers that were identified on the way and their status (some will be resolved, others dismissed, etc)

Please tag the @near/nep-moderators once you are done, so we can move this NEP to the voting stage. Thanks again.

neps/nep-0452.md Outdated Show resolved Hide resolved
@frol frol added WG-contract-standards Contract Standards Work Group should be accountable A-NEP A NEAR Enhancement Proposal (NEP). S-review/needs-wg-to-assign-sme A NEP that needs working group to assign two SMEs. labels Jan 27, 2023
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Show resolved Hide resolved
@frol
Copy link
Collaborator

frol commented Jan 27, 2023

As a contract standards working group member, I definitely see the value in defining the linkdrop standard as it is widely used and previously we hacked things together into the NEAR Wallet, but other Wallets should also be able to onboard users through linkdrops. Adding NFT and FT support is also great quality of life improvement.

neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
@Cameron-Banyan
Copy link

As a wallet working group committee member, I’d like to formally nominate @joe-rlo from Ready Layer One Tech, who builds applications that implement LinkDrops to review NEP452: Linkdrop Standard as a Subject Matter Expect.

@joe-rlo
Copy link

joe-rlo commented Feb 1, 2023

As someone actively building multiple projects using first, linkdrop directly, and now through Keypom, determining a standard is needed at this time. The linkdrop mechanism is an important and powerful onboarding tool but is underutilized.

In my experience, standardization is needed so more wallets can support this linkdrop and do it uniformly. While the mechanism is powerful, currently being limited by wallet support causes a disconnect between the goals of onboarding and decentralized choices.

We are already seeing multiple wallets start to implement their own methods which as a developer will either lead to having to "pick a winner" or a need to support multiple methods.

The clear benefits are as Ben stated:

  • Simplify the data structure for drops
  • Ability to have complex drops (which I think will become more of the norm)
  • Opens the possibility for easier KeyInfo add-ons

The only concern I have is that I'd like to see the standard for deleting keys and refunding assets in the initial standard. The strength of having complex drops needs a standardized way to reclaim the assets as well.

Overall, I think this is an important standard to begin to implement to onboard a billion users.

@BenKurrek
Copy link
Contributor Author

As an update, I'm going to add an optional required_gas field to the top level of KeyInfo. This is extremely important as claim pages need to know how much Gas to attach using the access key. The default will be 100 TGas unless this field is specified. Ken and myself have gone through a first draft of security implications, general linkdrop flow and some other information that we'll add to this standard as well.

BenKurrek and others added 2 commits February 3, 2023 12:59
Co-authored-by: Benjamin Kurrek <57506486+BenKurrek@users.noreply.github.com>
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
neps/nep-0452.md Show resolved Hide resolved
neps/nep-0452.md Show resolved Hide resolved
neps/nep-0452.md Outdated Show resolved Hide resolved
@frol frol requested review from a team and mfornet February 21, 2023 00:37
@frol
Copy link
Collaborator

frol commented Feb 22, 2023

I am self-assigning myself as an SME reviewer from the Contract Standards WG, so now we have two SMEs for this NEP.

@frol frol removed the S-review/needs-wg-to-assign-sme A NEP that needs working group to assign two SMEs. label Feb 22, 2023
neps/nep-0452.md Outdated
1. Linkdrop Creation
Linkdrop creation involves creating keypairs that, when used, have access to assets such as $NEAR, FTs, NFTs, etc. These keys should be limited access and restricted to specific functionality. For example, they should only have permission to call `claim` and `create_account_and_claim`. Since the keys allow the holder to sign transactions on behalf of the linkdrop contract, without the proper security measures, they could be used in a malicious manner (for example executing private methods or owner-only functions).

Another important security implication of linkdrop creation is to ensure that only one key is mapped to a set of assets at any given time. Externally, assets such as FTs, and NFTs belong to the overall linkdrop contract account rather than a specific access key. It is important to ensure that specific keys can only claim assets that they are mapped to.
Copy link
Contributor

@fadeevab fadeevab Apr 19, 2023

Choose a reason for hiding this comment

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

If you add indentation (3 or 4 spaces) to this paragraph then you will fix the following markdown lint errors about list item enumeration

Copy link
Contributor

Choose a reason for hiding this comment

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

@BenKurrek ☝️ finish those markdown lint errors please

Copy link
Contributor

Choose a reason for hiding this comment

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

@BenKurrek see the summary of errors in the github action (at the bottom of the conversation tab)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will fix linting errors post consensus

neps/nep-0452.md Outdated Show resolved Hide resolved
@abacabadabacaba
Copy link
Collaborator

As a Contract Standards Working Group member, I lean towards approving this NEP.

However, I would like the author to make certain small fixes should this NEP be approved. One is fixing the Markdown formatting. Another one is clarifying the potential security implications of race conditions (one claim call happening while another is in the process of transferring tokens), attempting to create a linkdrop with a key that corresponds to an already existing linkdrop (if this is not checked, an attacker could overwrite existing linkdrops without knowing their private key), and the combination of these two (attempting to create a linkdrop with a key that corresponds to an already existing linkdrop, which is in the process of transferring tokens).

@BenKurrek
Copy link
Contributor Author

As a Contract Standards Working Group member, I lean towards approving this NEP.

However, I would like the author to make certain small fixes should this NEP be approved. One is fixing the Markdown formatting. Another one is clarifying the potential security implications of race conditions (one claim call happening while another is in the process of transferring tokens), attempting to create a linkdrop with a key that corresponds to an already existing linkdrop (if this is not checked, an attacker could overwrite existing linkdrops without knowing their private key), and the combination of these two (attempting to create a linkdrop with a key that corresponds to an already existing linkdrop, which is in the process of transferring tokens).

I've addressed both the reentrancy attacks as well as key management (making sure only one key is mapped to a set of assets at a given time) in the security implications section. I will fix the markdown issues and linting post consensus.

@abacabadabacaba
Copy link
Collaborator

I've addressed both the reentrancy attacks as well as key management (making sure only one key is mapped to a set of assets at a given time) in the security implications section. I will fix the markdown issues and linting post consensus.

I don't see any mention of an attack where an attacker attempts to create a linkdrop with the same key as an existing one.

@BenKurrek
Copy link
Contributor Author

BenKurrek commented Apr 21, 2023

I've addressed both the reentrancy attacks as well as key management (making sure only one key is mapped to a set of assets at a given time) in the security implications section. I will fix the markdown issues and linting post consensus.

I don't see any mention of an attack where an attacker attempts to create a linkdrop with the same key as an existing one.

image

Another important security implication of linkdrop creation is to ensure that only one key is mapped to a set of assets at any given time. Externally, assets such as FTs, and NFTs belong to the overall linkdrop contract account rather than a specific access key. It is important to ensure that specific keys can only claim assets that they are mapped to.

@abacabadabacaba
Copy link
Collaborator

"only one key is mapped to a set of assets" != "only one set of assets is mapped to a key"

@ori-near
Copy link
Contributor

The Contract Standards Work Group met last Friday to review this NEP and reached the following consensus:

Status: Delay decision due to an unresolved concern.

Summary:
Contract Standards Work Group members were leaning towards approving this NEP. However, they decided to delay the voting decision due to the concerns around breaking change to the interface of claim function. Once the author and community alignes on the tradeoffs for the interface of claim function and selects the path forward, the work group will review the updated solution and then communicate their final decision on this NEP.

Meeting Recording:
https://youtu.be/KOIT8XDQNjM

@BenKurrek @kenobijon Thank you for authoring this NEP!

Next Steps:

  • The NEP authors (or anyone from the community) have two months to address the concerns raised above and to provide a solution. Please tag the @near/wg-contract-standards team once you are ready for their final review.
  • The @near/wg-contract-standards members to review the NEP and re-cast their final votes.

Copy link
Contributor

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

There are still few unaddressed points from the original review: #452 (review)

3. Asset Refunds & Failed Claims
Given that linkdrops could contain multiple different assets such as NFTs, or fungible tokens, sending assets might happen across multiple blocks. If the claim was unsuccessful (such as passing in an invalid account ID), it is important to ensure that all state is properly managed and assets are optionally refunded depending on the linkdrop contract's implementation.

4. Fungible Tokens & Future Data
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
4. Fungible Tokens & Future Data
4. Storage Registration & Future Data

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not specific to Fungible Tokens. Can also be related to NFTs or Multitoken... Let's just call it Storage Registration (which is a standard by it's own).

Given that linkdrops could contain multiple different assets such as NFTs, or fungible tokens, sending assets might happen across multiple blocks. If the claim was unsuccessful (such as passing in an invalid account ID), it is important to ensure that all state is properly managed and assets are optionally refunded depending on the linkdrop contract's implementation.

4. Fungible Tokens & Future Data
Fungible token contracts require that anyone receiving tokens must be registered. For this reason, it is important to ensure that storage for accounts claiming linkdrops is paid for. This concept can be extended to any future data types that may be added. You must ensure that all the pre-requisite conditions have been met for the asset that is being transferred.
Copy link
Contributor

Choose a reason for hiding this comment

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

ensure that storage for accounts claiming linkdrops is paid for

That may not be possible, because if it's a new account claiming a drop, then we don't know the new account address.

@nearbuild
Copy link

What is blocking this from moving forward?

@abacabadabacaba
Copy link
Collaborator

As a Contract Standards Group member, I approve this PR.

@robert-zaremba
Copy link
Contributor

As noted above, I would prefer that the claim methods returns object with nft_list and ft_list. Returning boolean is still better than nothing / simple panic. So not going to block this PR.

@robert-zaremba
Copy link
Contributor

robert-zaremba commented May 30, 2023

BTW, would be good to cleanup the comments, and check the description improvements before merging.

@frol
Copy link
Collaborator

frol commented Jun 2, 2023

@BenKurrek Please, address the markdown lints and remaining comments from @robert-zaremba:

@fadeevab Please, add Changelog section with the benefits and concerns mentioned in the reviews (see NEP-399 for example).

@BenKurrek
Copy link
Contributor Author

@frol I've added the final touches to the NEP as requested by you. Is it ok to move forward at this point?

@frol
Copy link
Collaborator

frol commented Jun 15, 2023

@BenKurrek All looks good except the markdown-lint. Please, fix CI, and I will add the changelog and merge this NEP!

@njelich
Copy link
Contributor

njelich commented Jan 26, 2024

The lint issues is fixed here
#529

@frol frol merged commit 1208e4c into master Jan 27, 2024
4 checks passed
@frol frol deleted the ben/linkdrop-nep branch January 27, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NEP A NEAR Enhancement Proposal (NEP). S-review/needs-author-revision A NEP in the REVIEW stage that needs an author revision. S-voting/needs-wg-voting-indication A NEP in the VOTING stage that needs the working group voting indication. WG-contract-standards Contract Standards Work Group should be accountable
Projects
Status: APPROVED NEPs
Development

Successfully merging this pull request may close these issues.