From 650b881eb70cb9a3a096cebc931356351d234425 Mon Sep 17 00:00:00 2001 From: Anton Puhach Date: Tue, 11 Feb 2025 16:38:43 +0100 Subject: [PATCH] impl --- README.md | 1 + neps/nep-0591.md | 113 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 neps/nep-0591.md diff --git a/README.md b/README.md index dfb1ff58b..54f1bb671 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Changes to the protocol specification and standards are called NEAR Enhancement | [0519](https://github.com/near/NEPs/blob/master/neps/nep-0519.md) | Yield Execution | @akhi3030 @saketh-are | Final | | [0536](https://github.com/near/NEPs/blob/master/neps/nep-0536.md) | Reduce the number of gas refunds | @evgenykuzyakov @bowenwang1996 | Final | | [0539](https://github.com/near/NEPs/blob/master/neps/nep-0539.md) | Cross-Shard Congestion Control | @wacban @jakmeier | Final | +| [0539](https://github.com/near/NEPs/blob/master/neps/nep-0591.md) | Global Contracts | @bowenwang1996 @pugachag | Final | ## Specification diff --git a/neps/nep-0591.md b/neps/nep-0591.md new file mode 100644 index 000000000..40a7f9696 --- /dev/null +++ b/neps/nep-0591.md @@ -0,0 +1,113 @@ +--- +NEP: 591 +Title: Global Contracts +Authors: Bowen Wang , Anton Puhach +Status: Draft +DiscussionsTo: https://github.com/nearprotocol/neps/pull/591 +Type: Protocol +Version: 1.0.0 +Created: 2025-02-11 +LastUpdated: 2025-02-11 +--- + +## Summary + +This proposal introduces Global Contracts, a new mechanism that allows smart contracts to be deployed once and reused by any account without incurring high storage costs. + +Currently, deploying the same contract multiple times on different accounts leads to significant storage fees. +Global Contracts solve this by making contract code available globally, allowing multiple accounts to reference it instead of storing their own copies. + +Rather than requiring full storage costs for each deployment, accounts can simply link to an existing Global Contract, reducing redundancy and improving scalability. This approach optimizes storage, lowers costs, and ensures efficient contract distribution across the network. + +## Motivation + +A common use case on NEAR is to deploy the same smart contract many times on many different accounts. For example, a multisig contract is a frequently deployed contract. +However, today each time such a contract is deployed, a user has to pay for its storage and the cost is quite high. For a 300kb contract the cost is 3N. + +With the advent of chain signatures, the smart contract wallet use case will become more ubiquitous. +As a result, it is very desirable to be able to reuse already deployed contract without having to pay for the storage cost again. + +## Specification + +[Explain the proposal as if you were teaching it to another developer. This generally means describing the syntax and semantics, naming new concepts, and providing clear examples. The specification needs to include sufficient detail to allow interoperable implementations getting built by following only the provided specification. In cases where it is infeasible to specify all implementation details upfront, broadly describe what they are.] + +## Reference Implementation + +[This technical section is required for Protocol proposals but optional for other categories. A draft implementation should demonstrate a minimal implementation that assists in understanding or implementing this proposal. Explain the design in sufficient detail that: + +* Its interaction with other features is clear. +* Where possible, include a Minimum Viable Interface subsection expressing the required behavior and types in a target programming language. (ie. traits and structs for rust, interfaces and classes for javascript, function signatures and structs for c, etc.) +* It is reasonably clear how the feature would be implemented. +* Corner cases are dissected by example. +* For protocol changes: A link to a draft PR on nearcore that shows how it can be integrated in the current code. It should at least solve the key technical challenges. + +The section should return to the examples given in the previous section, and explain more fully how the detailed proposal makes those examples work.] + +## Security Implications + +[Explicitly outline any security concerns in relation to the NEP, and potential ways to resolve or mitigate them. At the very least, well-known relevant threats must be covered, e.g. person-in-the-middle, double-spend, XSS, CSRF, etc.] + +## Alternatives + +[Explain any alternative designs that were considered and the rationale for not choosing them. Why your design is superior?] + +## Future possibilities + +[Describe any natural extensions and evolutions to the NEP proposal, and how they would impact the project. Use this section as a tool to help fully consider all possible interactions with the project in your proposal. This is also a good place to "dump ideas"; if they are out of scope for the NEP but otherwise related. Note that having something written down in the future-possibilities section is not a reason to accept the current or a future NEP. Such notes should be in the section on motivation or rationale in this or subsequent NEPs. The section merely provides additional information.] + +## Consequences + +[This section describes the consequences, after applying the decision. All consequences should be summarized here, not just the "positive" ones. Record any concerns raised throughout the NEP discussion.] + +### Positive + +* p1 + +### Neutral + +* n1 + +### Negative + +* n1 + +### Backwards Compatibility + +[All NEPs that introduce backwards incompatibilities must include a section describing these incompatibilities and their severity. Author must explain a proposes to deal with these incompatibilities. Submissions without a sufficient backwards compatibility treatise may be rejected outright.] + +## Unresolved Issues (Optional) + +[Explain any issues that warrant further discussion. Considerations + +* What parts of the design do you expect to resolve through the NEP process before this gets merged? +* What parts of the design do you expect to resolve through the implementation of this feature before stabilization? +* What related issues do you consider out of scope for this NEP that could be addressed in the future independently of the solution that comes out of this NEP?] + +## Changelog + +[The changelog section provides historical context for how the NEP developed over time. Initial NEP submission should start with version 1.0.0, and all subsequent NEP extensions must follow [Semantic Versioning](https://semver.org/). Every version should have the benefits and concerns raised during the review. The author does not need to fill out this section for the initial draft. Instead, the assigned reviewers (Subject Matter Experts) should create the first version during the first technical review. After the final public call, the author should then finalize the last version of the decision context.] + +### 1.0.0 - Initial Version + +> Placeholder for the context about when and who approved this NEP version. + +#### Benefits + +> List of benefits filled by the Subject Matter Experts while reviewing this version: + +* Benefit 1 +* Benefit 2 + +#### Concerns + +> Template for Subject Matter Experts review for this version: +> Status: New | Ongoing | Resolved + +| # | Concern | Resolution | Status | +| --: | :------ | :--------- | -----: | +| 1 | | | | +| 2 | | | | + +## Copyright + +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).