SevenX Ventures:模块化智能合约账户架构和挑战

币圈资讯 阅读:48 2024-04-22 12:45:15 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
原文作者:SevenX Ventures 编译:BlockBeats

从外部拥有账户(EOA)向智能合约账户(SCA)的转变势头强劲,并已经得到了包括 Vitalik 等许多核心创业者的支持。尽管如此,SCA 的采用却并不像 EOA 那样广泛。这其中的主要问题包括熊市带来的影响、eoa 到 sca 的迁移难度、签名问题、Gas 成本过高以及最为关键的开发难题。

账户抽象(AA)的最显著优势是能够使用代码自定义功能。然而,AA 功能的非互操作性带来了主要挑战,这种分散性会阻碍 AA 集成,并且加强了供应商锁定。除此之外,在可升级与可组合同时保障安全性也是重要挑战。

模块化账户抽象的出现是 AA 发展趋势中的一个细分领域,这种创新的方法可以将智能账户与其自定义功能分离。其目标是创建一个模块化结构,来开发具有多样功能、安全、无缝集成的钱包。未来,模块化账户抽象可以实现一个自由的智能合约账户「应用商店」,使钱包和 dApp 专注于改进用户体验,而不必在构建功能上花费太多精力。

简述账户抽象(AA)

在人们接触区块链的过程中,传统的 EOA 带来了许多挑战,如助记词、Gas 费用、跨链操作和多发交易等。

账户抽象利用智能合约账户,允许可编程验证(validation)和执行(execution)。这意味着用户将能够一次性批准一系列交易,而不再需要对每个交易都签名和广播。账户抽象还可以实现更多功能,如改进用户体验(如 Gas 抽象和会话密钥)、降低成本(如批量交易)和提高安全性(如社交恢复、多重签名)。目前,有两种实现账户抽象的方式:

· 协议层:一些协议本身提供了本地账户抽象支持,ZKSync 交易使用单个内存池和交易流程来支持 AA;无论是来自 EOA 还是 SCA 都遵循相同的流程,而 Starknet 已经移除了 EOA,所有账户都是 SCA,并且他们有像 Argent 这样的本地智能合约钱包。

· 合约层:对于以太坊及类似的 L2,ERC4337 引入了一个单独的 mempool,以在不改变共识层的情况下支持 AA。像 Stackup、Alchemy、Etherspot、Biconomy、Candide 和 Plimico 正在构建 bundler 基础设施,而像 Safe、Zerodev、Etherspot 和 Biconomy 正在构建 bundler 和 SDK。

采用 SCA 面临的困境

自 2015 年以来,账户抽象(AA)的话题一直被讨论,并在今年由 ERC 4337 进一步将其推进人们的视线中。然而,已部署的智能合约账户数量仍然远远不及 EOA。

让我们深入研究这个困境:

1、熊市的影响

尽管 AA 拥有了诸如无缝登录和 Gas 抽象等优势,在当下的熊市,所有用户都是已被教育的 EOA 用户,而没有太多新用户,因此 dApp 和钱包并没有动力去采用 SCA。即便如此,一些领先的 dApp 在逐步采用 AA,例如 Cyberconnect 通过引入他们的 AA 系统和无 Gas 解决方案,仅一个月就带动了约 36 万次 UserOps(AA 交易)。

2、迁移障碍

对于已经积累了用户和资产的钱包和应用程序来说,安全、便捷地迁移资产仍然是一个挑战。不过,像 EIP-7377 这样的方案可允许 EOA 发起一次性迁移交易。

3、签名问题

智能合约本身无法签署消息,因为它没有像 EOA 那样的私钥。类似 ERC1271 的尝试使之成为可能,但消息签名在第一笔交易之前不起作用的,这又对于使用反事实部署的钱包提出了挑战。由 Ambire 提出的 ERC-6492 是 ERC-1271 向后兼容的继任者,也许能够解决之前的问题。

4、Gas 成本

与标准 EOA 相比,部署、模拟和执行 SCA 会产生更高的成本,这也成为了采用障碍之一。不过,目前已经进行了一些测试,例如将账户创建与用户操作分离、消除与某个账户相关的 "salt" 等。

5、工程难题

ERC-4337 团队已经建立了 eth-infinitism repo,为开发人员提供了基础实现。然而,随着开发者针对不同的用例扩展到更细致和具体的功能时,集成和解码会面临更多挑战。在本文中,我们将深入探讨工程难题。

通过模块化智能合约账户来解决工程难题

工程难题可进一步阐述为碎片化、安全性和可升级性三个方面。

· 碎片化:现在可以通过多种方式启用功能,无论是通过特定的 SCA 还是通过独立的插件系统。每个平台和服务商都遵循自己的标准,促使开发者决定支持哪些平台和服务商。这可能导致潜在的平台(供应商)锁定或冗余工作。

· 安全性:虽然账户和功能解耦带来了灵活性的优势,但也可能使安全问题更严重。因为所有功能可能会被一同审核,而缺乏独立评估可能会增加账户漏洞的风险。

· 可升级性:随着账户的发展,保持添加、替换或删除功能的能力非常重要,重新部署现有功能的每次更新都会引入复杂性。

为了应对这些问题,我们需要可升级的合约以确保安全高效的升级、可复用的核心以提高整体开发效率、以及标准化的接口来确保合约账户能够在不同的前端之间平稳过渡。

这些术语汇聚于一个共同的概念:构建模块化账户抽象架构(模块化 AA)。

模块化账户抽象是广泛的 AA 发展中的一个细分领域,它设想将智能账户模块化,以定制化地为用户提供服务,并使开发者能够在最小限制下无缝增强功能。

然而,在任何行业中建立和推广新的标准都是一个巨大的挑战。在大家都接受同一标准之前,初始阶段可能会出现许多不同的解决方案。令人鼓舞的是看到那些致力于完善和推广账户抽象的人们,无论是 4337 SDK、钱包、基础设施团队还是协议层设计师,他们都在共同努力加快这一进程。

模块化结构:主账户和模块

账户如何调用模块实现功能

委托调用(Delegate call)和代理合约(proxy contract)

外部调用和委托调用:

关于委托调用

虽然「委托调用」与「调用」类似,但它不是在目标合约的 context 中执行,而是在调用合约的当前状态的 context 执行它。这意味着目标合约所做的任何状态更改都会更改调用合约的存储。

代理合约和委托调用

要实现可组合、可升级的结构,需要引入一个基础概念「代理合约」。

代理合约:普通合约存储其逻辑和状态,部署后无法更新。而代理合约使用委托调用(delegate call)部署到另一个合约。通过引用实现函数,在代理合约的当前状态下执行它。

使用案例:虽然代理合约保持不变,但您可以在代理后面部署新的实现。代理合约实现了可升级性,且在公共区块链上的部署和维护成本更低。

Safe 架构

Safe 架构

什么是 Safe :Safe 是领先的模块化智能账户基础设施,旨在提供经过实战考验的安全性和灵活性,它使开发人员能够创建多样化的应用程序和钱包。许多团队正在 Safe 基础上(或受 Safe 启发)构建应用。例如,Biconomy 在推出其智能合约账户时,使用原生 4337 和 1/1 多重签名来拓展 Safe。Safe 见证了超过 164,000 份合约的部署并锁定了超过 307 亿美元的价值,毫无疑问是该领域的佼佼者。

Safe 的结构包括安全账户合约、单例合约、模块合约。

安全账户合约(proxy contract):主代理合约(Stateful)

安全账户是一个代理合约,这是因为委托调用是一个单例合约。安全帐户包含所有者、阈值和实现地址都设置为代理的变量,基于这些定义其状态。

单例合约(singleton contract):Integration Hub(无状态)

单例合约服务于 Safe 账户,并定义了不同的模块合约集成,包括 Plugin、Hook、Function Handler 和 Signature Validator。

模块合约(modules):自定义逻辑和功能

模块合约功能强大。插件作为模块化类型可以定义不同的功能,例如支付流、恢复机制和会话密钥,并且可以通过获取链外数据作为 Web2 和 Web3 之间的桥梁。其他模块如作为安全防护的 Hook 和 Function Handler 可响应任何指令。

采用 Safe 后带来的改变:

可升级合约:每当引入新插件时都需要部署新的单例。用户保留将 Safe 升级到所需单例版本的自主权。

可组合、可重用的模块:插件的模块化特性使开发人员能够独立地开发功能。他们可以根据自己的用例自由选择和组合这些插件,从而形成高度可定制的方法。

ERC-2535 Diamond 代理

关于 ERC2535、 Diamond 代理:

ERC2535 标准化的 Diamond 模型,这是一种模块化智能合约系统,可以在部署后升级/扩展,且几乎没有大小限制。目前,很多团队如 Zerodev 的 Kernel、Soul Wallet 的实验都受到了 Diamond 结构的启发。

什么是 Diamond 结构:

Diamond 合约:主要代理合约(有状态)Diamond 是一种代理合约,它使用 委托调用方法从其实现中调用函数。

模块/插件/ Facet 合约:自定义逻辑和功能(无状态)模块或所谓的 Facet 是一种无状态合约,可以将其功能部署到一个或多个 Diamond。它们是单独的、独立的合约,可以共享内部函数、库和状态变量。

采用 Diamond 后带来的改变:

可升级合约:Diamond 提供了一种系统的方法来隔离不同的插件并将它们连接在一起,在它们之间共享数据,还可以使用 diamondCut 功能直接添加/替换/删除任何插件。随着时间的推移,可以添加到 Diamond 的插件数量将没有限制。

模块化且可复用的插件:已部署的插件可以被任意数量的 Diamond 使用,从而极大地降低部署成本。

Safe 智能账户与 Diamond 方式的区别:

Safe 和 Diamond 架构之间存在很多相似之处,两者都依赖于其核心的代理合约并引用逻辑合约来实现可升级性和模块化。

两者的主要区别在于逻辑契约的处理。具体来说:

· 灵活性:在启用新插件的情况下,Safe 需要重新部署其单例合约(Singleton)以实现其代理中的更改。相比之下,Diamond 直接通过其代理合约中的 diamondCut 函数来实现这一点。这种方法上的差异意味着 Safe 保留了更高程度的控制,而 Diamond 则引入了增强的灵活性和模块化。

· 安全:目前在两种结构中使用的,可以允许外部代码操纵主合约的存储。在 Safe 架构中,委托调用指向单个逻辑合约,而 Diamond 则在多个模块合约-插件中使用委托调用。因此,恶意插件有可能覆盖另一个插件,从而引入存储冲突的风险,损害代理的完整性。

· 成本:Diamond 方法中,灵活性与安全隐患同时存在。这增加了成本,每次添加新插件都需要进行全面审核。关键是要确保这些插件不会干扰彼此的功能,这一目的具有挑战性,特别是对于努力维持高安全标准的中小型企业而言。

「Safe 智能账户方法」和「Diamond 方法」是涉及代理和模块的不同结构的示例。如何平衡灵活性和安全性至关重要,这两种方法未来也将会不断演变、相互补充。

模块顺序:验证器(Validator)、执行器 (Executor) 和挂钩 (Hook)

让我们通过介绍 ERC6900 来进一步讨论,这是 Alchemy 团队提出的、受 Diamond 启发、专门为 ERC-4337 量身定制的标准。它通过提供通用接口来解决智能账户模块化的挑战,并协调插件和钱包开发人员之间的工作。

说到 AA 的交易流程,主要有三个流程:验证、执行、挂钩。正如我们前面所讨论的,这些步骤都可以通过使用代理帐户调用模块来管理。虽然不同的项目可能使用不同的名称,但掌握相似的底层逻辑很重要。

不同设计中的函数名称

验证 (Validator):确保帐户调用者的真实性和权限。

执行 (Executor):执行帐户允许的任何自定义逻辑。

挂钩 (Hook):充当在另一个函数之前或之后运行的模块。它可以修改状态或撤销整个调用。

根据不同的逻辑来分离模块至关重要。标准化方法应该规定如何编写智能合约帐户的验证、执行和挂钩函数。无论是 Safe 还是 ERC6900,标准化都有助于减少特定于某些实施或生态系统的独特开发工作的需求,并防止供应商锁定。

模块发现和安全

如何以开放的方式查找和验证模块:一个正在推进的解决方案涉及创建一个允许用户发现可验证模块的区域,可以将其称为「注册表」。该注册表的功能类似于「应用程序商店」,旨在培育一个简化但蓬勃发展的模块化市场。

Safe{Core} 协议

Safe{Core} 协议是一种针对智能合约账户的开源、可互操作的协议,旨在增强各种供应商和开发人员的可访问性,同时通过明确定义的标准和规则来保持强大的安全性。

· 账户:在 Safe{Core} 协议中,账户的概念是灵活的,不受特定实现的约束。这使得不同的账户服务提供商能够参与其中。

· 管理器:管理器充当帐户、注册表和模块之间的协调员。它还作为许可层负责安全性。

· 注册中心:注册中心定义安全属性并执行 ERC6900 等模块标准,旨在创建一个开放的「应用程序商店」环境,以实现可发现性和安全性。

· 模块:模块处理功能并具有各种初始类型,包括插件、挂钩、签名验证器和函数处理程序。只要符合既定标准,开发人员就可以参与其中。

Rhinestone 设计

该过程展开如下:

· 创建架构定义(schema):架构提供预定义数据结构。人们可以对其进行定制,以符合其特定的用例。

· 基于架构创建模块(modules):注册为模块的智能合约获取字节码并选择架构 ID,数据就会被存储在注册表中。

· 获得模块的证明(attestation):证明者/审核员可以基于架构为模块提供证明。这些证明可包括唯一标识符 (UID) 以及对用于链接的其他证明的引用。它们可以跨链传播并验证目标链是否满足特定阈值。

· 使用解析器(resolver)实现复杂逻辑:解析器(可选设置)开始发挥作用。它们可以在模块创建、证明建立和撤销期间被调用。这些解析器允许开发人员整合复杂且多样化的逻辑,同时维护证明结构。

用户友好的查询访问(query):查询为用户提供了一种从前端访问安全信息的方法。

虽然该模式还处于早期阶段,但它具有以分散和协作的方式建立标准的潜力。注册表使开发人员能够注册他们的模块,审计员能够验证其安全性,钱包能够进行集成,并使用户能够轻松找到模块并验证其证明信息。未来的几种用途可能是:

· 证明者(attestor):像 Safe 这样值得信赖的实体可以与 Rhinestone 合作,共同作为内部模块的证明者。同时,独立证明者也可以加入。

· 模块开发人员(module developer):随着开放市场的形成,模块开发人员有可能通过注册表将他们的工作货币化。

· 用户:通过用户友好的界面(例如钱包或 dApp)进行参与,用户可以检查模块信息并将信任委托给不同的证明者。

「模块注册表」的概念为插件和模块开发人员开辟了盈利途径。它可以进一步为「模块市场」铺平道路。某些方面可能由 Safe 团队监督,而其他方面可能表现为去中心化市场,邀请所有人做出贡献并提供透明的审计记录。整合这一点可以避免供应商锁定,并通过添加能够吸引更广泛受众的增强用户体验来支持 EVM 的扩展。

虽然这些方法能保证单个模块的安全,但在更广泛的安全性方面,智能合约账户并不是万无一失的。与合规模块结合并证明它们没有存储冲突可能是一个挑战,这凸显了钱包或 AA 基础设施在解决此类问题方面的重要性。

总结

通过利用模块化智能合约账户堆栈,钱包提供商和 dApp 可以从技术维护的复杂性中解放出来。同时,外部模块开发人员有机会提供个性化的专业服务。然而,需要解决的挑战包括在灵活性和安全性之间取得平衡,推动模块化标准,以及实施标准化接口,使用户能够轻松升级和修改其智能帐户。

此外,模块化智能合约账户(SCA)只是采用难题的一小部分。为了充分发挥 SCA 的潜力,需要 Layer 2 解决方案提供额外的协议层支持,例如强壮的 bundler 基础设施和点对点内存池、更具成本效益和可行的 SCA 签名机制、跨链 SCA 同步和管理机制,以及开发用户友好的界面。

未来,将会有更多人采用 SCA,但也会引发一些有趣的问题:一旦 SCA 订单流变得有足够利益可图,传统的矿工可提取价值 (MEV) 机制将如何进入该领域构建捆绑器并获取价值?当基础设施成熟后,账户抽象(AA)如何作为「基于意图」交易的基础层?让我们拭目以待。


The transformation from externally owned accounts to smart contract accounts has a strong momentum and has been supported by many core entrepreneurs, including others. However, the adoption is not as extensive as that. The main problems include the difficulty of migration caused by the bear market, the high cost of signature and the most critical development problem. The most obvious advantage of account abstraction is that it can use code customization functions, but the non-interoperability of functions brings major challenges, which will hinder the collection. In addition, it is also an important challenge to ensure security while being scalable and composable. The emergence of modular account abstraction is a subdivision in the development trend. This innovative method can separate smart accounts from their custom functions, and its goal is to create a modular structure to develop wallets with diverse functions, security and seamless integration. In the future, modular account abstraction can realize a free smart contract account application store to make wallets and focus on improvement. User experience does not need to spend too much energy on building functions. In the process of people's contact with blockchain, the traditional account abstraction has brought many challenges, such as mnemonic fees, cross-chain operations and multiple transactions. The use of smart contract accounts allows programmable verification and execution, which means that users will be able to approve a series of transactions at one time without signing and broadcasting each transaction. Account abstraction can also achieve more functions, such as improving user experience, abstraction and session keys to reduce costs. Such as batch transactions and improving security such as social recovery, there are two ways to achieve account abstraction. At present, some protocols themselves provide local account abstraction support. Transactions are supported by a single memory pool and transaction process, and all accounts have been removed, and they have local smart contracts like this. The wallet contract layer has introduced a separate one for Ethereum and the like to support things like peace without changing the consensus layer. The dilemma of building infrastructure and being built and adopted, the topic of account abstraction has been discussed since, and it has been further promoted to people's attention this year. However, the number of deployed smart contract accounts is still far less than that for us to deeply study the impact of this dilemma bear market. Despite the advantages such as seamless login and abstraction, in the current bear market, all users are educated users and there are not many new users, so there is no incentive to adopt wallets. In this way, some leading companies are gradually adopting, for example, by introducing their systems and no solutions, which has driven about 10 thousand transactions in just one month. For wallets and applications that have accumulated users and assets, it is still a challenge to migrate assets safely and conveniently, but a scheme like this can allow a one-time migration transaction signature problem. The smart contract itself cannot sign the message because it has no similar attempt as that private key, but the message signature is in the first place. This transaction didn't work before, which challenges the use of counterfactual deployment wallet. The successor who is backward-compatible may be able to solve the previous problems. Compared with the standard, the deployment of simulation and execution will produce higher costs, which has also become one of the obstacles to adoption. However, some tests have been carried out, such as separating account creation from user operation to eliminate engineering problems related to an account. The team has established a basic implementation for developers. However, with Developers will face more challenges when they expand to more detailed and specific functions for different use cases. In this paper, we will discuss the engineering problems in depth, and solve the engineering problems through modular intelligent contract accounts. The engineering problems can be further elaborated in three aspects: fragmentation, security and scalability. Fragmentation can now enable functions in many ways, whether through specific or independent plug-in systems. Every platform and service provider will follow their own standards to urge developers. Deciding which platforms and service providers to support may lead to potential platform vendor lock-in or redundant work security. Although the decoupling of accounts and functions brings flexibility advantages, it may also make security problems more serious, because all functions may be audited together and lack of independent evaluation may increase the risk of account vulnerabilities. Scalability is very important to maintain the ability to add, replace or delete functions with the development of accounts. Every update of existing functions will introduce complexity in order to cope with it. To solve these problems, we need scalable contracts to ensure the safe and efficient upgrading of reusable cores, to improve the overall development efficiency and standardized interfaces to ensure the smooth transition of contract accounts between different front-ends. These terms converge on a common concept and build a modular account abstraction architecture. Modular account abstraction is a subdivision of extensive development. It envisages modularization of smart accounts to provide customized services to users and enable developers to minimize. However, it is a great challenge to establish and promote new standards in any industry. Before everyone accepts the same standard, there may be many different solutions in the initial stage. It is encouraging to see those people who are committed to improving and promoting account abstraction, whether they are wallet infrastructure teams or protocol layer designers, who are working together to speed up this process. Modular structure, how to call modules for master accounts and modular accounts, and how to realize function delegation and generation. Manage contract external call and delegate call. Although delegate call is similar to call, it is not executed in the target contract but in the current state of the calling contract. This means that any state change made by the target contract will change the storage agent contract and delegate call of the calling contract. To realize the combinable and scalable structure, it is necessary to introduce a basic concept: agent contract, agent contract, whose logic and state can not be updated after deployment, but the agent contract can be used. Delegated call is deployed to another contract, and it is executed in the current state of the proxy contract by referencing the implementation function. Use case Although the proxy contract remains unchanged, you can deploy a new implementation behind the proxy contract, which is scalable and has lower deployment and maintenance costs on the public blockchain. Architecture What is the leading modular smart account infrastructure? It aims to provide security and flexibility that has been tested in actual combat. It enables developers to create diverse applications and wallets. Many teams are building applications based on or inspired by it, for example, using native and when launching their smart contract accounts. 比特币今日价格行情网_okx交易所app_永续合约_比特币怎么买卖交易_虚拟币交易所平台

文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明 网址:https://netpsp.com/?id=63202

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
关注我们

若遇到问题,加微信客服---清歌

搜索
排行榜
扫一扫,加我为微信好友加我为微信好友