从 The Saudis NFT 事件浅析 EIP-2535 钻石协议

慢雾科技Publicado em 2022-07-12Última atualização em 2022-07-12

Resumo

2022 年 7 月 10 号,一个火热的 NFT 项目 TheSaudis 开启了 freemint 活动(白名单用户可以免费铸造其 NFT)。

背景信息

2022 年 7 月 10 号,一个火热的 NFT 项目 TheSaudis 开启了 freemint 活动(白名单用户可以免费铸造其 NFT)。而就在 mint 活动结束后,一位名叫 RIGHTBLOCK 的用户在市场上大量地抛售该 NFT,项目方发现后迅速锁定到了该用户并对合约进行改动以此来将该用户手里的大量 NFT 转移回来,他们之后承诺会将这些 NFT 回馈给社区用户。

那么为什么项目方可以将该用户手里的 NFT 转移呢?经过我们的分析发现该 NFT 项目的合约采用了 EIP-2535 协议也叫做钻石协议,项目方利用该协议重写了合约的功能,以此来实现这些 NFT 的转移。接下来慢雾安全团队将会为大家介绍下这个钻石协议(EIP-2535)的细节。

钻石协议介绍

EIP-2535 是以太坊上一个将合约进行代码模块化组合的提案,其目的是为了让大型的智能合约突破 24kb 大小的最大限制,并且让合约更方便地更新功能。

要理解钻石协议,首先有几个相关的概念定义需要知道:

钻石(diamond): 钻石可以理解为代理合约(Proxy),也是与用户进行交互的主合约

切面(facet): 正如真正的钻石有不同的侧面一样,一个钻石合约也有着不同的面,钻石合约的每个功能所需要调用的合约对应一个切面,所以也可以理解为实现合约 (Implementation)

钻石切割(diamondCut): 钻石协议标准扩展了一种叫钻石切割的功能,其主要作用从钻石中增加、替换或删除切面和功能,可以理解为合约的升级 (Upgrade)

放大镜(The Loupe): 钻石协议标准中的放大镜功能主要是返回关于切面的信息和钻石存在的功能,这些信息是保存在钻石合约内部的存储结构——DiamondStorage 中

整个钻石模型类似下图:

通过使用钻石标准规范去创建钻石合约,这个合约可以像使用当前合约的代码一样使用任何数量的其他切面合约的代码。

在该钻石合约中不同的函数功能需要调用对应的不同的切面合约的代码来实现,并且可以利用钻石切割的功能来对钻石合约中的函数功能进行修改(添加、替换或删除)。

这与市面上大多数使用一个代理合约和一个实现合约来实现交互与升级的方式有所区别。

事件分析

接下来回头分析下 The Saudis 这次事件中的一些细节,在该项目的 DiamondCutFacet.sol 合约中,可以看到实现了 diamondCut 功能的函数。

该函数首先会调用 LibDiamond 库的 enforceIsContractOwner 函数来判断调用者是否是合约的 owner,如果是 owner 调用的话会调用 LibDiamond 库的 diamondCut 函数来实现钻石合约的功能更新。

跟进到该函数我们发现钻石切割会根据传入的不同的 action 来判断进行添加、替换或删除功能,故接下来跟进看看项目方调用该函数的交易。

我们发现传入了新的切面合约 0x70d8ccaf6b50b051ab1e8fa238626163e45a8b03(未开源),传入的 action 设置为 1 则应该是调用了 replaceFunctions 来实现替换功能。

从 replaceFunctions 函数中可以分析出该函数首先会为传入的地址新增一个切面,接着从存储中循环读取传入的每个函数选择器对应的旧的切面进行删除,并为这些函数的切面添加为传入的新的切面地址。

至此可得知 The Saudis 项目方就是利用了钻石切割函数来重写了转账功能,以此来将用户 RIGHTBLOCK 手中的 NFT 转移回自己的账户。

相关信息

The Saudis 合约地址:

0xe21ebcd28d37a67757b9bc7b290f4c4928a430b1

用户 Rightblock 地址:

0x80266b1e3f0C2cAdAE65A4Ef5Df20f3DF3707FfB

项目方更新合约的交易:

0xbc559a72f73e6c9a53416fd13a3ebaaa76dca5855ff8b79511585f514eaf2390

Leituras Relacionadas

The Semiconductor Industry's Most Obscure Chokepoint Material: It Has Multiplied in Price Unnoticed, and China Just Banned Its Export

"Helium: The Silent Choke Point in Semiconductors" Helium, despite being the universe's second most abundant element, is critically scarce on Earth. It cannot be synthesized artificially and escapes Earth's gravity once released, making it a non-renewable resource. Yet, it is indispensable for advanced semiconductor manufacturing, requiring ultra-high purity (99.9999%) for processes like wafer etching, leak detection, and thermal management in lithography tools, with no viable substitutes. This low-profile resource, whose price has doubled unnoticed, suddenly gained attention when China imposed an export ban on July 10th. The ban is a response to a severe global shortage triggered months earlier. In March, missile attacks damaged the world's largest helium production hub in Qatar's Ras Laffan, halting a third of global supply with repairs expected to take 3-5 years. Concurrently, Russia tightened export controls, and the US sold off its federal helium reserve. Approximately 200 specialized transport containers, each worth ~$1 million, were stranded with perishable cargo. Global spot prices skyrocketed, and chipmakers like TSMC warned of potential impacts. China, which imports over 84% of its helium (primarily from Qatar and Russia), faces a severe squeeze. Despite being helium-poor, China has developed domestic extraction technology over five years, processing byproduct gases from LNG plants to produce ultra-pure helium. Domestic output, while still only covering less than 20% of demand, enabled the recent export ban aimed at securing domestic supply for its own expanding chip industry. The industry now faces "Helium Shortage 5.0." With key global sources constrained for years, this invisible gas—once wasted on party balloons—has become a critical, geopolitically charged bottleneck for chips, healthcare (MRI machines), and beyond, forcing the world to finally treat it as the finite strategic resource it is.

marsbitHá 24m

The Semiconductor Industry's Most Obscure Chokepoint Material: It Has Multiplied in Price Unnoticed, and China Just Banned Its Export

marsbitHá 24m

Early Investor of Unitree Bets on a Brain-Computer Interface Company

"Wabo Technologies, a brain-computer interface (BCI) startup, has secured new funding from Vertex Ventures (under Temasek), Hongtai Fund, Chengdu Future Industry Fund, and Huifengda Capital. Vertex Ventures is known for its early bet on Unitree Robotics. Inspired by the sci-fi film "Avatar," founder Zhang Xingzhi has pursued human-machine interaction for over a decade. He established Wabo in late 2025, coinciding with China's push for BCI as a future industry. Unlike companies focused solely on medical hardware, Wabo positions itself as a model company. Its core mission is to develop a "Human Neural Intent Model" that decodes EEG, EMG, and behavioral signals to understand a user's goals, confirmations, corrections, and stop intentions before physical action, translating them into standardized control signals for machines, robots, or smart devices. The young, full-stack team, backed by academic collaborators from Tianjin University and Fudan University, quickly attracted investors. The company had previously raised a seed round from Ceyuan Capital. Investors were impressed by Wabo's systematic capabilities in data collection, signal processing, and engineering, seeing potential beyond a single hardware product toward a reusable layer of human intent interpretation. Applications span medical rehabilitation, smart homes, embodied AI, and even space exploration, with Wabo partnering with Tianjin University on pioneering "space BCI" research. Wabo plans a dual-headquarters strategy, with Shanghai focusing on high-end R&D and model development, and Chengdu handling hardware, product development, and supply chain. The BCI sector in China is heating up, with over 30 financing deals in early 2026. Zhang believes future competition will center on who can build a sustainable data-model-scenario loop. He predicts industry consolidation within three years, with only companies that master this闭环 surviving. The vision from "Avatar" is inching closer to reality."

marsbitHá 39m

Early Investor of Unitree Bets on a Brain-Computer Interface Company

marsbitHá 39m

ChangXin Technology: A Cyclical Stock Standing Atop the Cycle Peak

Changxin Technology: A Cyclical Stock at the Peak On July 27, 2026, Changxin Technology topped the A-share market with a market capitalization of 3.28 trillion yuan, surging 465% on its first trading day. The company, which lost 16.3 billion yuan in 2023, reported an estimated net profit of 50-57 billion yuan for the first half of 2026. Its dramatic reversal mirrors the volatile DRAM (Dynamic Random Access Memory) cycle. The DRAM industry is inherently cyclical, with booms and busts every 3-4 years. This is due to product standardization and a significant time lag in supply adjustment. When prices rise, manufacturers expand capacity, but new production takes 2-3 years to come online, often leading to oversupply and price crashes when demand cools. Changxin's performance perfectly tracks this cycle. It recorded deep losses in 2023-2024 during the industry downturn, turned its first annual profit in 2025, and saw profits skyrocket in Q1 2026. This surge is primarily price-driven. The AI boom has led major players like Samsung and SK Hynix to shift 70-80% of new capacity to high-margin HBM (High Bandwidth Memory), creating a severe shortage and price explosion in general-purpose DRAM markets where Changxin competes. However, a massive global capacity expansion is underway. The top three manufacturers have announced nearly $70 billion in capital expenditure for 2026. Changxin itself plans to expand from three to seven 12-inch wafer fabs. This investment will translate into significant new supply in 2-3 years. While DRAM prices are expected to remain high through 2026-2027, price growth is already slowing, and a potential downturn is forecast for around 2028 as new capacity ramps up. A key challenge for Changxin is catching up in the critical HBM segment. While it has delivered HBM3 samples, leaders are already mass-producing more advanced HBM3E. Success in HBM is crucial for gaining true cyclical resilience. In conclusion, Changxin is a commendable company that has broken foreign monopolies in DRAM. Its long-term growth narrative—driven by import substitution and AI—is valid. Yet, its current valuation of 5-6x forward P/E, typical for a cyclical stock at its peak, suggests much future growth is already priced in. AI may extend the current cycle but cannot eliminate the industry's inherent volatility. For investors, the critical question is preparedness for the inevitable downturn when the cycle turns.

marsbitHá 44m

ChangXin Technology: A Cyclical Stock Standing Atop the Cycle Peak

marsbitHá 44m

Trading

Spot
活动图片