التوثيق الفني لـ Optimism
У Optimism нет традиционного вайтпейпера. Будучи оптимистичным роллапом Layer 2 для Ethereum, его устройство и спецификации задокументированы в технической документации, спецификации OP Stack и исследовательских публикациях, а не в едином формальном академическом документе.
Abstract
Abstract
The paper addresses the problem of scalability in decentralized blockchains by analyzing the trade-off between transaction throughput and hardware requirements to run a node. Rollups, i.e. technologies for on-chain verification of blocks executed off-chain, are presented in the form of fault or validity proofs. We compare Optimistic Rollups and Validity Rollups with respect to withdrawal time, transaction costs, optimization techniques, and compatibility with the Ethereum ecosystem. Our analysis reveals that Optimism Bedrock currently has a gas compression rate of approximately 20:1, while StarkNet achieves a storage write cost compression rate of around 24:1. We also discuss techniques to further optimize these rates, such as the use of cache contracts and Bloom filters. Ultimately, our conclusions highlight the trade-offs between complexity and agility in the choice between Optimistic and Validity Rollups. Keywords Blockchain, Scalability, Rollup 1. Introduction Blockchain technology has gained significant attention due to its potential to revolutionize various industries. However, scalability remains a major challenge, as most blockchains face a trade-off between scalability, decentralization, and security, commonly referred to as the Scalability Trilemma [1, 2]. To increase the throughput of a blockchain, a trivial solution is to increase its block size. In the context of Ethereum, this means increasing the maximum amount of gas a block can hold. As each full node must validate every transaction of every block, as the throughput increases, the hardware requirements also increase, leading to a greater centralization of the network. Some blockchains, such as Bitcoin and Ethereum, optimize their design to maximize their architectural decentralization, while others, such as the Binance Smart Chain and Solana, are designed to be as fast and cheap as possible. Decentralized networks artificially limit the throughput of the blockchain to lower the hardware requirements to participate in the network. Over the years, attempts have been made to find a solution to the Trilemma, such as state channels [3] and Plasma [4, 5]. These solutions have the characteristic of moving some activity off-chain, linking on-chain activity to off-chain activity using smart contracts, and verifying DLT 2023: 5th Distributed Ledger Technology Workshop, May 25-26, 2023, Bologna, Italy $ [email protected] (L. Donno) https://lucadonnoh.github.io/ (L. Donno) 0000-0001-9221-3529 (L. Donno) © 2023 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). CEUR Workshop Proceedings http://ceur-ws.org ISSN 1613-0073 CEUR Workshop Proceedings (CEUR-WS.org) on-chain what is happening off-chain. However, both Plasma and state channels are limited in their support of general smart contracts. Rollups are blockchains (called Layer 2 or L2) that publish their blocks on another blockchain (Layer 1 or L1) and therefore inherit its consensus, data availability and security properties. They, unlike other solutions, support arbitrary computation. Rollups have three main components: • Sequencers: nodes that receive Rollup transactions from users and combine them into a block that is sent to Layer 1. The block consists of at least the state root (e.g. a Merkle root) and the data needed to reconstruct and validate the state. The Layer 1 defines the...
خلاصة
تتناول هذه الورقة مشكلة قابلية التوسع في blockchains اللامركزية من خلال تحليل المفاضلة بين إنتاجية المعاملات ومتطلبات الأجهزة لتشغيل العقدة. يتم تقديم عمليات التجميع، أي تقنيات التحقق من الكتل المنفذة خارج السلسلة على السلسلة، في شكل أدلة خطأ أو صحة. نحن نقارن بين مجموعات متفائلة ومجموعات صلاحية فيما يتعلق بوقت السحب، وتكاليف المعاملات، وتقنيات التحسين، والتوافق مع النظام البيئي Ethereum. يكشف تحليلنا أن Optimism Bedrock لديه حاليًا معدل ضغط غاز يبلغ حوالي 20:1، بينما يحقق StarkNet معدل ضغط تكلفة كتابة تخزين يبلغ حوالي 24:1. نناقش أيضًا تقنيات تحسين هذه الأسعار بشكل أكبر، مثل استخدام عقود التخزين المؤقت ومرشحات Bloom. في نهاية المطاف، تسلط استنتاجاتنا الضوء على المفاضلات بين التعقيد وخفة الحركة في الاختيار بين مجموعة التفاؤل والصلاحية. الكلمات الرئيسية Blockchain، قابلية التوسع، التجميعية 1. مقدمة اكتسبت تقنية Blockchain اهتمامًا كبيرًا نظرًا لقدرتها على إحداث ثورة في مختلف الصناعات. ومع ذلك، لا تزال قابلية التوسع تمثل تحديًا كبيرًا، حيث تواجه معظم blockchain مقايضة بين قابلية التوسع واللامركزية والأمن، والتي يشار إليها عادةً باسم ثلاثية قابلية التوسع [1، 2]. لزيادة إنتاجية blockchain، الحل البسيط هو زيادة حجم الكتلة الخاصة بها. في سياق Ethereum، هذا يعني زيادة الحد الأقصى لكمية الغاز التي يمكن أن تحتويها الكتلة. نظرًا لأن كل عقدة كاملة يجب أن تتحقق من صحة كل معاملة لكل كتلة، ومع زيادة الإنتاجية، تزداد أيضًا متطلبات الأجهزة، مما يؤدي إلى مركزية أكبر للشبكة. تعمل بعض blockchain، مثل Bitcoin وEthereum، على تحسين تصميمها لتحقيق أقصى قدر من اللامركزية المعمارية، في حين تم تصميم البعض الآخر، مثل Binance Smart Chain وSolana، لتكون سريعة ورخيصة قدر الإمكان. تعمل الشبكات اللامركزية على الحد بشكل مصطنع من إنتاجية blockchain لتقليل متطلبات الأجهزة للمشاركة في الشبكة. على مر السنين، جرت محاولات لإيجاد حل للثلاثية، مثل القنوات الحكومية [3] والبلازما [4، 5]. تتميز هذه الحلول بخاصية نقل بعض الأنشطة خارج السلسلة، وربط النشاط الموجود على السلسلة بالنشاط خارج السلسلة باستخدام smart contracts، والتحقق من DLT 2023: ورشة العمل الخامسة لتكنولوجيا دفتر الأستاذ الموزع، 25-26 مايو 2023، بولونيا، إيطاليا $ [email protected] (L. Donno) https://lucadonnoh.github.io/ (L. Donno) 0000-0001-9221-3529 (L. Donno) © 2023 حقوق الطبع والنشر لهذه الورقة من قبل مؤلفيها. الاستخدام مسموح به بموجب ترخيص Creative Commons Attribution 4.0 International (CC BY 4.0). إجراءات ورشة عمل CEUR http://ceur-ws.org ISSN 1613-0073 إجراءات ورشة عمل CEUR (CEUR-WS.org) على السلسلة ما يحدث خارج السلسلة. ومع ذلك، فإن قنوات البلازما والقنوات الحكومية محدودة في دعمها للقنوات العامة smart contract. المجموعات المجمعة هي blockchains (تسمى Layer 2 أو L2) تنشر كتلها على blockchain أخرى (Layer 1 أو L1) وبالتالي ترث خصائص الإجماع وتوافر البيانات والأمان. وهي، على عكس الحلول الأخرى، تدعم الحساب التعسفي. تحتوي المجموعات المجمعة على ثلاثة مكونات رئيسية: • أجهزة التسلسل: العقد التي تتلقى معاملات التجميع من المستخدمين ودمجها في كتلة يتم إرسالها إلى Layer 1. تتكون الكتلة على الأقل من جذر الحالة (على سبيل المثال، جذر Merkle) والبيانات اللازمة لإعادة بناء الحالة والتحقق من صحتها. يحدد Layer 1...
Introduction
Introduction
- Introduction Blockchain technology has gained significant attention due to its potential to revolutionize various industries. However, scalability remains a major challenge, as most blockchains face a trade-off between scalability, decentralization, and security, commonly referred to as the Scalability Trilemma [1, 2]. To increase the throughput of a blockchain, a trivial solution is to increase its block size. In the context of Ethereum, this means increasing the maximum amount of gas a block can hold. As each full node must validate every transaction of every block, as the throughput increases, the hardware requirements also increase, leading to a greater centralization of the network. Some blockchains, such as Bitcoin and Ethereum, optimize their design to maximize their architectural decentralization, while others, such as the Binance Smart Chain and Solana, are designed to be as fast and cheap as possible. Decentralized networks artificially limit the throughput of the blockchain to lower the hardware requirements to participate in the network. Over the years, attempts have been made to find a solution to the Trilemma, such as state channels [3] and Plasma [4, 5]. These solutions have the characteristic of moving some activity off-chain, linking on-chain activity to off-chain activity using smart contracts, and verifying DLT 2023: 5th Distributed Ledger Technology Workshop, May 25-26, 2023, Bologna, Italy $ [email protected] (L. Donno) https://lucadonnoh.github.io/ (L. Donno) 0000-0001-9221-3529 (L. Donno) © 2023 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). CEUR Workshop Proceedings http://ceur-ws.org ISSN 1613-0073 CEUR Workshop Proceedings (CEUR-WS.org)
on-chain what is happening off-chain. However, both Plasma and state channels are limited in their support of general smart contracts. Rollups are blockchains (called Layer 2 or L2) that publish their blocks on another blockchain (Layer 1 or L1) and therefore inherit its consensus, data availability and security properties. They, unlike other solutions, support arbitrary computation. Rollups have three main components: • Sequencers: nodes that receive Rollup transactions from users and combine them into a block that is sent to Layer 1. The block consists of at least the state root (e.g. a Merkle root) and the data needed to reconstruct and validate the state. The Layer 1 defines the canonical blockchain of the L2 by establishing the ordering of the published data. • Rollup full nodes: nodes that obtain, process and validate Rollup blocks from Layer 1 by verifying that the root is correct. If a block contains invalid transactions it is then discarded, which prevents Sequencers from creating valid blocks that include invalid transactions. • Rollup light nodes: nodes that obtain Rollup blocks from Layer 1 but do not compute the new state themselves. They verify that the new state root is valid using techniques such as fault or validity proofs. Rollups achieve scalability by decreasing the amortized cost of transactions as the number of users increases. This is because the cost of ensuring blockchain validity grows sub-linearly with respect to the cost of verifying transactions individually. Rollups differ according to the mechanism by which they ensure the validity of transaction execution at light nodes: in Optimistic Rollups it is ensured by an economic model and by fault proofs, while in Validity Rollups it is cryptographically ensured using validity proofs. Light nodes can be implemented as smart contracts on Layer 1. They accept the root of the new state and verify validity or fault proofs: these Rollup are therefore called Smart Contract Rollups. If light nodes are independent, they are called Sovereign Rollups [6]. The advantage of using a Smart Contract Rollup is to be able to build a trust-minimized bridge between the two blockchains: since the validity of the L2 state is proven to L1, a system of transactions from L2 to L1 can be implemented, allowing withdrawals. The disadvantage is that the cost of the transactions depends on the cost of verifying the state on L1: if the base layer is saturated by other activities, the cost of transactions on the Rollup also increases. The data and consensus layers are the ones that determine the security of the system as they define the ordering of transactions, prevent attacks and make data available to prove state validity. Paper contribution In this paper, we study Optimistic and Validity Rollups, two innovative solutions to the Scalability Trilemma, with a focus on notable implementations, such as Optimism Bedrock and StarkNet. Our contributions include a comprehensive comparison of these solutions, an analysis of withdrawal times, and a discussion of a possible attack on Optimism Bedrock. Additionally, we calculate their gas compression ratios, provide application-specific optimizations, and present the advantages and disadvantages of moving away from the Ethereum Virtual Machine (EVM).
Paper structure The paper is organized as follows. In section 2 Optimistic Rollups are introduced by analyzing Optimism Bedrock. In section 3 Validity Rollups are introduced by analyzing StarkNet. In section 4 we compare the two solutions. Finally, in section 5 we draw some conclusions.
مقدمة
- مقدمة لقد اكتسبت تقنية Blockchain اهتمامًا كبيرًا نظرًا لقدرتها على إحداث ثورة الصناعات المختلفة. ومع ذلك، تظل قابلية التوسع تحديًا كبيرًا، كما يواجه معظم blockchains وهي مقايضة بين قابلية التوسع واللامركزية والأمن، والتي يشار إليها عادة باسم معضلة قابلية التوسع [1، 2]. لزيادة إنتاجية blockchain، الحل التافه هو لزيادة حجم الكتلة الخاصة به. في سياق Ethereum، هذا يعني زيادة الحد الأقصى كمية الغاز التي يمكن أن تحتويها الكتلة. حيث يجب على كل عقدة كاملة التحقق من صحة كل معاملة لكل عقدة كتلة، مع زيادة الإنتاجية، تزداد أيضًا متطلبات الأجهزة، مما يؤدي إلى زيادة مركزية الشبكة. تعمل بعض blockchains، مثل Bitcoin وEthereum على تحسين التصميم لتحقيق أقصى قدر من اللامركزية المعمارية، في حين أن البعض الآخر، مثل Binance Smart تم تصميم Chain وSolana ليكونا سريعين ورخيصين قدر الإمكان. الشبكات اللامركزية الحد بشكل مصطنع من إنتاجية blockchain لخفض متطلبات الأجهزة المشاركة في الشبكة. على مر السنين، جرت محاولات لإيجاد حل للثلاثية، مثل الدولة القنوات [3] والبلازما [4، 5]. وتتميز هذه الحلول بخاصية تحريك بعض النشاط خارج السلسلة، وربط النشاط الموجود على السلسلة بالنشاط خارج السلسلة باستخدام smart contracts، والتحقق DLT 2023: ورشة العمل الخامسة لتكنولوجيا دفتر الأستاذ الموزع، 25-26 مايو 2023، بولونيا، إيطاليا $ [email protected] (L. Donno) https://lucadonnoh.github.io/ (ل. دونو) 0000-0001-9221-3529 (ل. دونو) © 2023 حقوق الطبع والنشر لهذه الورقة من قبل مؤلفيها. الاستخدام مسموح به بموجب ترخيص Creative Commons Attribution 4.0 International (CC BY 4.0). CEUR ورشة عمل الإجراءات http://ceur-ws.org ISSN 1613-0073 وقائع ورشة عمل CEUR (CEUR-WS.org)على السلسلة ما يحدث خارج السلسلة. ومع ذلك، فإن قنوات البلازما وقنوات الدولة محدودة دعمهم لـ smart contracts العامة. المجموعات المجمعة هي blockchains (تسمى Layer 2 أو L2) تنشر كتلها على blockchain آخر (Layer 1 أو L1) وبالتالي ترث خصائص الإجماع وتوافر البيانات والأمان الخاصة بها. هم، على عكس الحلول الأخرى، دعم الحساب التعسفي. تحتوي المجموعات المجمعة على ثلاثة مكونات رئيسية: • التسلسل: العقد التي تتلقى المعاملات المجمعة من المستخدمين ودمجها في ملف الكتلة التي يتم إرسالها إلى Layer 1. تتكون الكتلة من جذر الحالة على الأقل (على سبيل المثال Merkle root) والبيانات اللازمة لإعادة بناء الحالة والتحقق من صحتها. يحدد Layer 1 الكنسي blockchain للL2 من خلال تحديد ترتيب البيانات المنشورة. • العقد المجمعة الكاملة: العقد التي تحصل على الكتل المجمعة وتعالجها وتتحقق من صحتها من الطبقة 1 عن طريق التحقق من صحة الجذر. إذا كانت الكتلة تحتوي على معاملات غير صالحة، فهذا هو الحال تم تجاهلها، مما يمنع أجهزة التسلسل من إنشاء كتل صالحة تتضمن غير صالحة المعاملات. • العقد الخفيفة التراكمية: العقد التي تحصل على الكتل التراكمية من Layer 1 ولكنها لا تقوم بالحساب الدولة الجديدة نفسها. يتحققون من أن جذر الحالة الجديد صالح باستخدام التقنيات مثل إثبات الخطأ أو الصحة. تحقق المجموعات المجمعة قابلية التوسع من خلال تقليل التكلفة المطفأة للمعاملات كعدد من المستخدمين يزيد. وذلك لأن تكلفة ضمان صلاحية blockchain تنمو بشكل خطي فرعي فيما يتعلق بتكلفة التحقق من المعاملات بشكل فردي. تختلف المجموعات حسب الآلية التي يتم من خلالها التأكد من صحة تنفيذ المعاملة في العقد الخفيفة: في يتم ضمان التراكمات المتفائلة من خلال النموذج الاقتصادي وإثباتات الخطأ، أثناء الصلاحية يتم ضمان المجموعات المجمعة بشكل مشفر باستخدام أدلة الصلاحية. يمكن تنفيذ العقد الخفيفة كـ smart contracts على Layer 1. يقبلون جذر حالة جديدة والتحقق من الصلاحية أو إثبات الأخطاء: لذلك تسمى هذه التحديثات بالعقد الذكي مجموعات. إذا كانت العقد الضوئية مستقلة، فإنها تسمى مجموعة Sovereign Rollups [6]. ميزة إن استخدام مجموعة العقود الذكية هو القدرة على بناء جسر ثقة بين الاثنين blockchains: بما أنه تم إثبات صحة حالة L2 إلى L1، فإن نظام المعاملات من يمكن تنفيذ L2 إلى L1، مما يسمح بالسحب. العيب هو أن تكلفة تعتمد المعاملات على تكلفة التحقق من الحالة على L1: إذا كانت الطبقة الأساسية مشبعة والأنشطة الأخرى، فإن تكلفة المعاملات في مجموعة التحديثات تزيد أيضًا. طبقات البيانات والإجماع هي التي تحدد أمان النظام فهي تحدد ترتيب المعاملات، وتمنع الهجمات، وتتيح البيانات لإثبات الحالة صلاحية. المساهمة الورقية في هذا البحث، قمنا بدراسة مجموعتي التفاؤل والصدق، وهما مبتكران حلول ثلاثية قابلية التوسع، مع التركيز على التطبيقات البارزة، مثل Optimism Bedrock وStarkNet. تتضمن مساهماتنا مقارنة شاملة لهذه الحلول وتحليل أوقات السحب ومناقشة الهجوم المحتمل على Optimism حجر الأساس. بالإضافة إلى ذلك، نقوم بحساب نسب ضغط الغاز الخاصة بها، وتوفير تحسينات خاصة بالتطبيقات، وتقديم مزايا وعيوب الابتعاد عن Ethereum الجهاز الظاهري (EVM).
هيكل الورق يتم تنظيم الورقة على النحو التالي. في القسم 2 التراكمية المتفائلة هي تم تقديمه من خلال تحليل Optimism حجر الأساس. في القسم 3، يتم تقديم مجموعات الصلاحية بواسطة تحليل StarkNet. في القسم 4 نقارن بين الحلين. وأخيرا، في القسم 5 نرسم بعض الاستنتاجات.
Optimistic Rollups
Optimistic Rollups
- Optimistic Rollups The idea of accepting optimistically the output of blocks without verifying their execution is already present in the Bitcoin whitepaper [7], discussing light nodes. These nodes only follow the header chain by verifying the consensus rule, making them vulnerable to accept blocks containing invalid transactions in the event of a 51% attack. Nakamoto proposes to solve this problem by using an “alert" system to warn light nodes that a block contains invalid transactions. This mechanism is first implemented by Al-Bassam, Sonnino and Buterin [8] in which a fault proof system based on error correction codes [9] is used. In order to enable the creation of fault proofs, it is necessary that the data from all blocks, including invalid blocks, is available to the network: this is the Data Availability Problem, which is solved using a probabilistic data sampling mechanism. The first Optimistic Rollup design was presented by John Adler and Mikerah Quintyne-Collins in 2019 [10], in which blocks are published on another blockchain that defines their consensus on ordering. 2.1. Optimism Bedrock Bedrock [11] is the latest version of Optimism, a Smart Contract Rollup. The previous version, the Optimistic Virtual Machine (OVM) required an ad hoc compiler to compile Solidity into its own bytecode: in contrast, Bedrock is fully equivalent to the EVM in that the execution engine follows the Ethereum Yellow Paper specification [12]. 2.1.1. Deposits Users can deposit transactions through a contract on Ethereum, the Optimism Portal, by calling the depositTransaction function. When a transaction is executed, a TransactionDeposited event is emitted, which each node in the Rollup listens for to process deposits. A deposited transaction is a L2 transaction that is derived from L1. If the caller of the function is a contract, the address is transformed by adding a constant value to it: this prevents attacks in which a contract on L1 has the same address as a contract on L2 but a different code. The inclusion on L2 of a deposited transaction is ensured by specification within a sequencing window. Deposited transactions are a new EIP-2718 compatible transaction type [13] with prefix 0x7E, where the rlp-encoded fields are: • bytes32 sourceHash: hash that uniquely identifies the source of the transaction. • address from: the address of the sender. • address to: the receiver address, or the zero address if the deposited transaction is a contract creation.
• uint256 mint: the value to be created on L2. • uint256 value: the value to be sent to the recipient. • bytes data: the input data. • bytes gasLimit: the gas limit of the transaction. The sourceHash is computed as the keccak256 hash of the L1 block hash and the L1 log index, uniquely identifying an event in a block. Since deposited transactions are initiated on L1 but executed on L2, the system needs a mechanism to pay on L1 for the gas spent on L2. One solution is to send ETH through the Portal, but this implies that every caller (even indirect callers) must be marked as payable, and this is not possible for many existing projects. The alternative is to burn the corresponding gas on L1. The gas 𝑔allocated to deposited transaction is called guaranteed gas. The L2 gas price on L1 is not automatically synchronized but is estimated using a mechanism similar to EIP-1559 [14]. The maximum amount of gas guaranteed per Ethereum block is 8 million, with a target of 2 million. The quantity 𝑐of ETH required to pay for gas on L2 is 𝑐= 𝑔𝑏L2 where 𝑏L2 is the basefee on L2. The contract on L1 burns an amount of gas equal to 𝑐/𝑏L2. The gas spent to call depositTransaction is reimbursed on L2: if this amount is greater than the guaranteed gas, no gas is burned. The first transaction of a rollup block is a L1 attributes deposited transaction, used to register on a L2 predeploy the attributes of Ethereum blocks. The attributes that the predeploy gives access to are the block number, the timestamp, the basefee, the block hash and the sequence number, which is the block number of L2 relative to the associated L1 block (also called epoch); this number is reset when a new epoch starts. 2.1.2. Sequencing The Rollup nodes derive the Optimism chain entirely from Ethereum. This chain is extended each time new transactions are published on L1, and its blocks are reorganized each time Ethereum blocks are reorganized. The Rollup blockchain is divided into epochs. For each 𝑛 block number of Ethereum, there is a corresponding 𝑛epoch. Each epoch contains at least one block, and each block in an epoch contains a L1 attributes deposited transaction. The first block in an epoch contains all transactions deposited through the Portal. Layer 2 blocks may also contained sequenced transactions, i.e. transactions sent directly to the Sequencer. The Sequencer accepts transactions from users and builds blocks. For each block, it constructs a batch to be published on Ethereum. Several batches can be published in a compressed manner, taking the name channel. A channel can be divided into several frames, in case it is too large for a single transaction. A channel is defined as the compression with ZLIB [15] of rlp-encoded batches. The fields of a batch are the epoch number, the epoch hash, the parent hash, the timestamp and the transaction list. A sequencing window, identified by an epoch, contains a fixed number 𝑤of consecutive L1 blocks that a derivation step takes as input to construct a variable number of L2 blocks. For epoch 𝑛, the sequencing window 𝑛includes the blocks [𝑛, 𝑛+𝑤). This implies that the ordering of L2 transactions and blocks within a sequencing window is not fixed until the window ends. A rollup transaction is called safe if the batch containing it has been confirmed on L1. Frames
are read from L1 blocks to reconstruct batches. The current implementation does not allow the decompression of a channel to begin until all corresponding frames have been received. Invalid batches are ignored. Individual block transactions are obtained from the batches, which are used by the execution engine to apply state transitions and obtain the Rollup state. 2.1.3. Withdrawals In order to process withdrawals, an L2-to-L1 messaging system is implemented. Ethereum needs to know the state of L2 in order to accept withdrawals, and this is done by publishing on the L2 Output Oracle smart contract on L1 the state root of each L2 block. These roots are optimistically accepted as valid (or finalized) if no fault proof is performed during the dispute period. Only addresses designated as Proposers can publish output roots. The validity of output roots is incentivized by having Proposers deposit a stake that is slashed if they are shown to have proposed an invalid root. Transactions are initiated by calling the function initiateWithdrawal on a predeploy on L2 and then finalized on L1 by calling the function finalizeWithdrawalTransaction on the previously mentioned Optimism Portal. The output root corresponding to the L2 block is obtained from the L2 Output Oracle; it is verified that it is finalized, i.e. that the dispute period has passed; it is verified that the Output Root Proof matches the Oracle Proof; it is verified that the hash of the withdrawal is included in it using a Withdrawal Proof; that the withdrawal has not already been finalized; and then the call to the target address is executed, with the specified gas limit, amount of Ether and data. 2.1.4. Cannon: the fault proof system If a Rollup Full Node, by locally executing batches and deposited transactions, discovers that the Layer 2 state does not match the state root published on-chain by a Proposer, it can execute a fault proof on L1 to prove that the result of the block transition is incorrect. Because of the overhead, processing an entire Rollup block on L1 is too expensive. The solution implemented by Bedrock is to execute on-chain only the first instruction of disagreement of minigeth, compiling it into a MIPS architecture that is executed on an on-chain interpreter and published on L1. minigeth is a simplified version of geth 1 in which the consensus, RPC and database have been removed. To find the first instruction of disagreement, an interactive binary search is conducted between the one who initiated the fault proof and the one who published the output root. When the proof starts, both parties publish the root of the MIPS memory state halfway through the execution of the block on the Challenge contract: if the hash matches it means that both parties agree on the first half of the execution thus publishing the root of half of the second half, otherwise the half of the first half is published and so on. Doing so achieves the first instruction of disagreement in a logarithmic number of steps compared to the original execution. If one of the two stops interacting, at the end of the dispute period the other participant automatically wins. To process the instruction, the MIPS interpreter needs access to its memory: since the root is available, the necessary memory cells can be published by proving their inclusion. To access the state of the EVM, use is made of the Preimage Oracle: given the hash of a block it returns 1https://geth.ethereum.org/docs
the block header, from which one can get the hash of the previous block and go back in the chain, or get the hash of the state and logs from which one can get the preimage. The oracle is implemented by minigeth and replaces the database. Queries are made to other nodes to obtain the preimages.
التراكمات المتفائلة
- مجموعات متفائلة إن فكرة القبول المتفائل لمخرجات الكتل دون التحقق من تنفيذها هي موجودة بالفعل في Bitcoin المستند التقني [7]، الذي يناقش العقد الضوئية. هذه العقد تتبع فقط سلسلة الرأس عن طريق التحقق من قاعدة الإجماع، مما يجعلها عرضة لقبول الكتل تحتوي على معاملات غير صالحة في حالة حدوث هجوم بنسبة 51%. يقترح ناكاموتو حل هذه المشكلة حل المشكلة باستخدام نظام "تنبيه" لتحذير العقد الخفيفة من أن الكتلة تحتوي على معاملات غير صالحة. هذه الآلية يطبقها لأول مرة البسام وسونينو وبوتيرين [8] فيها خطأ يتم استخدام نظام إثبات يعتمد على رموز تصحيح الأخطاء [9]. من أجل تمكين إنشاء إثباتات الأخطاء، من الضروري أن تكون البيانات من جميع الكتل، بما في ذلك الكتل غير الصالحة، متاحة لـ الشبكة: وهي مشكلة توفر البيانات، والتي يتم حلها باستخدام البيانات الاحتمالية آلية أخذ العينات. أول تصميم متفائل تم تقديمه بواسطة جون أدلر و Mikerah Quintyne-Collins في عام 2019 [10]، حيث يتم نشر الكتل على blockchain آخر الذي يحدد إجماعهم على الطلب. 2.1. Optimism حجر الأساس Bedrock [11] هو أحدث إصدار من Optimism، مجموعة العقود الذكية. الإصدار السابق، تتطلب الآلة الافتراضية المتفائلة (OVM) مترجمًا مخصصًا لتجميع Solidity في نظامها رمز البايت الخاص: في المقابل، فإن Bedrock يعادل تمامًا EVM من حيث محرك التنفيذ يتبع Ethereum مواصفات الورق الأصفر [12]. 2.1.1. الودائع يمكن للمستخدمين إيداع المعاملات من خلال عقد على Ethereum، بوابة Optimism، عن طريق استدعاء وظيفة الإيداع. عند تنفيذ المعاملة، أ يتم إطلاق حدث TransactionDeposited، والذي تستمع إليه كل عقدة في مجموعة التحديثات لمعالجته الودائع. المعاملة المودعة هي معاملة L2 مشتقة من L1. إذا كان المتصل الوظيفة عقد، يتم تحويل العنوان بإضافة قيمة ثابتة إليه: وهذا يمنع الهجمات التي يكون فيها العقد الموجود على L1 له نفس عنوان العقد الموجود على L2 ولكن برمز مختلف. يتم ضمان التضمين في L2 للمعاملة المودعة من خلال المواصفات ضمن التسلسل نافذة. المعاملات المودعة هي نوع معاملة جديد متوافق مع EIP-2718 [13] مع البادئة 0x7E، حيث تكون الحقول المشفرة بـ rlp: • bytes32 sourceHash: hash الذي يحدد مصدر المعاملة بشكل فريد. • العنوان من : عنوان المرسل . • العنوان إلى: عنوان المستلم، أو العنوان الصفري إذا كانت المعاملة المودعة هي a إنشاء العقد.• uint256 mint: القيمة التي سيتم إنشاؤها على L2. • قيمة uint256: القيمة التي سيتم إرسالها إلى المستلم. • بايتات البيانات: بيانات الإدخال. • BytesgasLimit: حد الغاز للمعاملة. يتم حساب sourceHash باعتباره keccak256 hash للكتلة L1 hash وسجل L1 مؤشر، يحدد بشكل فريد حدثًا في الكتلة. نظرًا لأن المعاملات المودعة تبدأ على L1 ويتم تنفيذها على L2، فإن النظام يحتاج إلى آلية الدفع على L1 مقابل الغاز الذي يتم إنفاقه على L2. أحد الحلول هو إرسال ETH عبر البوابة، ولكن هذا يعني أنه يجب وضع علامة على كل متصل (حتى المتصلين غير المباشرين) على أنه مستحق الدفع، وهذا هو الحال غير ممكن للعديد من المشاريع القائمة. البديل هو حرق الغاز المقابل على L1. يسمى الغاز 𝑔المخصص للمعاملة المودعة بالغاز المضمون. سعر الغاز L2 لا تتم مزامنة L1 تلقائيًا ولكن يتم تقديره باستخدام آلية مشابهة لـ EIP-1559 [14]. الحد الأقصى لكمية الغاز المضمونة لكل كتلة Ethereum هي 8 ملايين، مع وجود هدف من 2 مليون. الكمية 𝑐 من ETH المطلوبة لدفع ثمن الغاز على L2 هي 𝑐= 𝑔𝑏L2 حيث 𝑏L2 هو رسوم الأساس على L2. العقد على L1 يحرق كمية من الغاز تساوي 𝑐/𝑏L2. قضى الغاز للاتصال يتم تعويض معاملة الإيداع على L2: إذا كان هذا المبلغ أكبر من الغاز المضمون، لا يتم حرق الغاز. المعاملة الأولى لكتلة rollup هي معاملة مودعة لسمات L1، تُستخدم للتسجيل على L2، قم بالنشر المسبق لسمات الكتل Ethereum. السمات التي يوفرها النشر المسبق الوصول إليها هو رقم الكتلة والطابع الزمني والرسوم الأساسية والكتلة hash والتسلسل الرقم، وهو رقم كتلة L2 بالنسبة إلى كتلة L1 المرتبطة (وتسمى أيضًا العصر)؛ تتم إعادة تعيين هذا الرقم عند بدء حقبة جديدة. 2.1.2. التسلسل تستمد العقد المجمعة سلسلة Optimism بالكامل من Ethereum. هذه السلسلة ممتدة في كل مرة يتم نشر معاملات جديدة على L1، ويتم إعادة تنظيم كتلها في كل مرة تمت إعادة تنظيم كتل Ethereum. يتم تقسيم مجموعة التحديثات blockchain إلى فترات. لكل 𝑛 رقم الكتلة Ethereum، هناك 𝑛epoch مناظر. كل عصر يحتوي على واحد على الأقل كتلة، وكل كتلة في حقبة تحتوي على معاملة L1 المودعة. الكتلة الأولى في عصر ما يحتوي على جميع المعاملات المودعة من خلال البوابة. قد يتم أيضًا حظر Layer 2 تحتوي على معاملات متسلسلة، أي المعاملات المرسلة مباشرة إلى جهاز التسلسل. يقبل جهاز التسلسل المعاملات من المستخدمين ويبني الكتل. لكل كتلة، فإنه يبني دفعة سيتم نشرها في Ethereum. يمكن نشر عدة دفعات بشكل مضغوط، أخذ اسم القناة. يمكن تقسيم القناة إلى عدة إطارات، إذا كانت كبيرة جدًا معاملة واحدة. يتم تعريف القناة على أنها الضغط باستخدام ZLIB [15] لـ rlp المشفر دفعات. حقول الدُفعة هي رقم العصر، العصر hash، الأصل hash، الطابع الزمني وقائمة المعاملات. تحتوي نافذة التسلسل، التي يتم تحديدها بواسطة عصر ما، على رقم ثابت 𝑤من L1 المتتالي الكتل التي تأخذها خطوة الاشتقاق كمدخل لإنشاء عدد متغير من كتل L2. ل في العصر 𝑛، تتضمن نافذة التسلسل 𝑛 الكتل [𝑛، 𝑛+𝑤). وهذا يعني أن الترتيب لا يتم إصلاح معاملات L2 والكتل داخل نافذة التسلسل حتى تنتهي النافذة. تُسمى المعاملة rollup بأنها آمنة إذا تم تأكيد الدفعة التي تحتوي عليها على L1. إطاراتتتم قراءتها من كتل L1 لإعادة بناء الدُفعات. التنفيذ الحالي لا يسمح يبدأ ضغط القناة حتى يتم استقبال جميع الإطارات المقابلة. غير صالح يتم تجاهل الدفعات. يتم الحصول على معاملات الكتلة الفردية من الدُفعات يستخدمه محرك التنفيذ لتطبيق انتقالات الحالة والحصول على حالة الإظهار. 2.1.3. عمليات السحب من أجل معالجة عمليات السحب، يتم تطبيق نظام المراسلة من L2 إلى L1. Ethereum يحتاج إلى معرفة حالة L2 لقبول عمليات السحب، ويتم ذلك عن طريق النشر في Oracle Output L2 smart contract على L1 جذر الحالة لكل كتلة L2. هذه الجذور يتم قبولها بشكل متفائل على أنها صالحة (أو نهائية) إذا لم يتم إجراء إثبات خطأ أثناء فترة النزاع. يمكن فقط للعناوين المعينة كمقترحين نشر جذور المخرجات. الصلاحية يتم تحفيز جذور الإنتاج من خلال مطالبة مقدمي العروض بإيداع حصة يتم قطعها إذا قاموا بذلك تبين أنه اقترح جذرًا غير صالح. تبدأ المعاملات عن طريق استدعاء الدالة قم ببدء السحب عند النشر المسبق على L2 ثم تم الانتهاء منه على L1 عن طريق استدعاء الوظيفة FinalizeWithdrawalTransaction على بوابة Optimism المذكورة سابقًا. يتم الحصول على جذر الإخراج المقابل لكتلة L2 من L2 Output Oracle؛ إنه كذلك التحقق من أنه تم الانتهاء منه، أي أن فترة النزاع قد انقضت؛ تم التحقق من أن الإخراج يتطابق إثبات الجذر مع Oracle Proof؛ تم التحقق من تضمين hash الخاص بالسحب فيه باستخدام إثبات السحب؛ وأن الانسحاب لم يتم الانتهاء منه بالفعل؛ ومن ثم يتم تنفيذ الاتصال بالعنوان المستهدف، مع حد الغاز المحدد وكمية الأثير والبيانات. 2.1.4. المدفع: نظام إثبات الخطأ إذا اكتشفت عقدة التجميع الكاملة ذلك، من خلال تنفيذ الدفعات والمعاملات المودعة محليًا الحالة Layer 2 لا تتطابق مع جذر الحالة المنشور على السلسلة بواسطة مقدم العرض، ويمكن تنفيذها دليل خطأ على L1 لإثبات أن نتيجة انتقال الكتلة غير صحيحة. بسبب بشكل عام، تعد معالجة كتلة القيمة المحتسبة بالكامل على L1 مكلفة للغاية. تم تنفيذ الحل بواسطة Bedrock هو تنفيذ التعليمات الأولى للخلاف في minigeth على السلسلة فقط، تجميعها في بنية MIPS التي يتم تنفيذها على مترجم على السلسلة ونشرها على L1. minigeth هو نسخة مبسطة من geth 1 حيث يتم تضمين الإجماع وRPC وقاعدة البيانات تمت إزالتها. للعثور على تعليمات الخلاف الأولى، يتم إجراء بحث ثنائي تفاعلي بين الشخص الذي بدأ إثبات الخطأ والذي نشر جذر الإخراج. عندما يكون الدليل يبدأ كلا الطرفين بنشر جذر حالة الذاكرة MIPS في منتصف عملية التنفيذ الحظر في عقد التحدي: إذا كان hash يتطابق فهذا يعني أن الطرفين يتفقان على النصف الأول من التنفيذ وبذلك ينشر جذر نصف النصف الثاني، وإلا النصف يتم نشر النصف الأول وهكذا. إن القيام بذلك يحقق التعليمات الأولى للخلاف في عدد لوغاريتمي من الخطوات مقارنة بالتنفيذ الأصلي. فإذا توقف أحد الأمرين التفاعل، في نهاية فترة النزاع، يفوز المشارك الآخر تلقائيًا. لمعالجة التعليمات، يحتاج المترجم MIPS إلى الوصول إلى ذاكرته: نظرًا لأن الجذر هو المتاحة، يمكن نشر خلايا الذاكرة اللازمة عن طريق إثبات إدراجها. للوصول حالة EVM، يتم استخدام Preimage Oracle: بالنظر إلى hash للكتلة التي يتم إرجاعها 1https://geth.ethereum.org/docs
رأس الكتلة، والذي يمكن من خلاله الحصول على hash من الكتلة السابقة والعودة إلى chain، أو احصل على hash للحالة والسجلات التي يمكن من خلالها الحصول على الصورة الأولية. oracle يتم تنفيذه بواسطة Minigeth ويحل محل قاعدة البيانات. يتم إجراء الاستعلامات إلى العقد الأخرى ل الحصول على الصور الأولية.
Validity Rollups
Validity Rollups
- Validity Rollups The goal of a Validity Rollup is to cryptographically prove the validity of the state transition given the sequence of transactions with a short proof that can be verified sub-linearly compared to the time of the original computations. These kind of certificates are called computational integrity proofs and are practically implemented with SNARKs (Succint Non-interactive ARgument of Knowledge), which use arithmetic circuits as their computational model. Different SNARK implementations differ in proving time, verification time, the need of a trusted setup and quantum resistance [16, 17]. STARKs (Scalable Transparent ARgument of Knowledge) [18] are a type of SNARKs that does not require a trusted setup and are quantum resistant, while giving up some efficiency on proving and verification compared to other solutions. 3.1. StarkNet StarkNet is a Smart Contract Validity Rollup developed by StarkWare that uses the STARK proof system to validate its state to Ethereum. To facilitate the construction of validity proofs, a virtual machine different than the EVM is used, whose high-level language is Cairo. 3.1.1. Deposits Users can deposit transactions via a contract on Ethereum by calling the sendMessageToL2 function. The message is recorded by computing its hash and increasing a counter. Sequencers listen for the LogMessageToL2 event and encode the information in a StarkNet transaction that calls a function of a contract that has the l1_handler decorator. At the end of execution, when the proof of state transition is produced, the consumption of the message is attached to it and it is deleted by decreasing its counter. The inclusion of deposited transactions is not required by the StarkNet specification, so a gas market is needed to incentivize Sequencers to publish them on L2. In the current version, because the Sequencer is centralized and managed by StarkWare, the cost of deposited transactions is only determined by the cost of executing the deposit. This cost is paid by sending ETH to sendMessageToL2. These Ethers remain locked on L1 and are transferred to the Sequencer on L1, when the deposited transaction is included in a state transition. The amount of ETH sent, if the deposited transaction is included, is fully spent, regardless of the amount of gas consumed on L2. StarkNet does not have a system that makes L1 block attributes available automatically. Alternatively, Fossil is a protocol developed by Oiler Network 2 that allows, given a hash of a block, any information to be obtained from Ethereum by publishing preimages. 2https://www.oiler.network/
3.1.2. Sequencing The current state of StarkNet can be derived entirely from Ethereum. Any state difference between transitions is published on L1 as calldata. Differences are published for each contract and are saved as uint256[] with the following encoding: • Number of field concerning contract deployments. • For each published contract: – The address of the published contract. – The hash of the published contract. – The number of arguments of the contract constructor. – The list of constructor arguments • Number of contract whose storage has been modified. • For each contract that has been modified: – The address of the modified contract. – The number of storage updates. – The key-value pairs of the storage addresses with the new values. The state differences are published in order, so it is sufficient to read them sequentially to reconstruct the state. 3.1.3. Withdrawals To send a message from L2 to L1, the syscall send_message_to_L1 is used. The message is published to L1 by increasing its hash counter along with the proof and finalized by calling the function consumeMessageFromL2 on the StarkGate smart contract on L1, which decrements the counter. Anyone can finalize any withdrawal. 3.1.4. Validity proofs The Cairo Virtual Machine [19] is designed to facilitate the construction of STARK proofs. The Cairo language allows the computation to be described with a high-level programming language, and not directly as a circuit. This is accomplished by a system of polynomial equations 3 representing a single computation: the FDE cycle of a von Neumann architecture. The number of constraints is thus fixed and independent of the type of computation, allowing for only one Verifier program for every program whose computation needs to be proved. StarkNet aggregates multiple transactions into a single STARK proof using a shared prover named SHARP. The proofs are sent to a smart contract on Ethereum, which verifies their validity and updates the Merkle root corresponding to the new state. The sub-linear cost of verifying a validity proof allows its cost to be amortized over multiple transactions. 3called Algebraic Intermediate Representation (AIR)
تراكمات الصلاحية
- مجموعات الصلاحية الهدف من مجموعة الصلاحية هو إثبات صحة انتقال الحالة بشكل مشفر نظرا لتسلسل المعاملات مع برهان قصير يمكن التحقق منه خطيا مقارنة إلى وقت الحسابات الأصلية. يُطلق على هذا النوع من الشهادات اسم إثباتات التكامل الحسابي ويتم تنفيذها عمليًا باستخدام SNARKs (وسيطة المعرفة غير التفاعلية المختصرة)، والتي تستخدم العمليات الحسابية الدوائر كنموذج حسابي لها. تختلف تطبيقات SNARK المختلفة في وقت الإثبات، وقت التحقق، والحاجة إلى إعداد موثوق به ومقاومة كمية [16، 17]. ستاركس (قابلة للتطوير حجة المعرفة الشفافة) [18] هي نوع من SNARKs التي لا تتطلب وسيطًا موثوقًا به الإعداد ومقاومة الكم، مع التخلي عن بعض الكفاءة في الإثبات والتحقق مقارنة بالحلول الأخرى. 3.1. StarkNet StarkNet عبارة عن مجموعة من صلاحية العقد الذكي تم تطويرها بواسطة StarkWare والتي تستخدم STARK نظام إثبات للتحقق من صحة حالته إلى Ethereum. لتسهيل بناء أدلة الصحة، أ يتم استخدام جهاز افتراضي مختلف عن EVM، ولغته عالية المستوى هي القاهرة. 3.1.1. الودائع يمكن للمستخدمين إيداع المعاملات عبر عقد على Ethereum عن طريق الاتصال بـ sendMessageToL2 وظيفة. يتم تسجيل الرسالة عن طريق حساب hash وزيادة العداد. التسلسل استمع إلى حدث LogMessageToL2 وقم بتشفير المعلومات في معاملة StarkNet يستدعي وظيفة العقد الذي يحتوي على ديكور l1_handler. وفي نهاية التنفيذ، عندما يتم إنتاج إثبات انتقال الحالة، يتم إرفاق استهلاك الرسالة به ويتم حذفه بتقليل عداده. إن إدراج المعاملات المودعة ليس مطلوبًا بموجب مواصفات StarkNet، لذا فهو غاز هناك حاجة إلى السوق لتحفيز التسلسلات لنشرها على L2. في الإصدار الحالي، لأن يتم التحكم في جهاز التسلسل بشكل مركزي وإدارته بواسطة StarkWare، وهي تكلفة المعاملات المودعة يتم تحديده فقط من خلال تكلفة تنفيذ الإيداع. يتم دفع هذه التكلفة عن طريق إرسال ETH إلى sendMessageToL2. تظل هذه الإثيرات مقفلة على L1 ويتم نقلها إلى جهاز التسلسل L1، عندما يتم تضمين المعاملة المودعة في انتقال الحالة. مبلغ ETH المرسل، إذا يتم تضمين المعاملة المودعة، وإنفاقها بالكامل، بغض النظر عن كمية الغاز المستهلكة على L2. لا يحتوي StarkNet على نظام يجعل سمات كتلة L1 متاحة تلقائيًا. وبدلاً من ذلك، فإن Fossil هو بروتوكول تم تطويره بواسطة Oiler Network 2 والذي يسمح، بالنظر إلى hash من منع أي معلومات يمكن الحصول عليها من Ethereum عن طريق نشر الصور الأولية. 2https://www.oiler.network/3.1.2. التسلسل يمكن اشتقاق الحالة الحالية لـ StarkNet بالكامل من Ethereum. أي اختلاف الدولة يتم نشر بين التحولات على L1 كبيانات الاتصال. يتم نشر الاختلافات لكل عقد ويتم حفظها كـ uint256[] بالتشفير التالي: • عدد الحقول المتعلقة بعمليات نشر العقد. • لكل عقد منشور: – عنوان العقد المنشور. – hash للعقد المنشور. – عدد حجج منشئ العقد.
- قائمة وسيطات المنشئ • عدد العقود التي تم تعديل تخزينها. • لكل عقد تم تعديله: – عنوان العقد المعدل. – عدد تحديثات التخزين.
- أزواج القيمة الرئيسية لعناوين التخزين مع القيم الجديدة. يتم نشر اختلافات الحالة بالترتيب، لذلك يكفي قراءتها بالتسلسل إعادة بناء الدولة. 3.1.3. عمليات السحب لإرسال رسالة من L2 إلى L1، يتم استخدام syscall send_message_to_L1. الرسالة هي تم نشره إلى L1 عن طريق زيادة عداد hash مع الدليل وتم الانتهاء منه عن طريق استدعاء الدالة ConsumerMessageFromL2 على StarkGate smart contract على L1، مما يتناقص العداد. يمكن لأي شخص وضع اللمسات الأخيرة على أي انسحاب. 3.1.4. إثباتات الصلاحية تم تصميم جهاز القاهرة الافتراضي [19] لتسهيل إنشاء براهين ستارك. تسمح لغة القاهرة بوصف العمليات الحسابية ببرمجة عالية المستوى اللغة، وليس مباشرة كدائرة. يتم تحقيق ذلك من خلال نظام المعادلات متعددة الحدود 3 يمثل حسابًا واحدًا: دورة FDE لهندسة فون نيومان. الرقم وبالتالي فإن القيود ثابتة ومستقلة عن نوع الحساب، مما يسمح بواحد فقط برنامج التحقق لكل برنامج يحتاج إلى إثبات حسابه. يقوم StarkNet بتجميع معاملات متعددة في دليل STARK واحد باستخدام مُثبت مشترك اسمه شارب. يتم إرسال البراهين إلى smart contract على Ethereum، والذي يتحقق من صحتها ويقوم بتحديث جذر Merkle المطابق للحالة الجديدة. التكلفة الخطية الفرعية للتحقق أ يسمح إثبات الصلاحية بإطفاء تكلفته على معاملات متعددة. 3 يسمى التمثيل الجبري المتوسط (AIR)
Comparison
Comparison
- Comparison 4.1. Withdrawal time The most important aspect that distinguishes Optimistic Rollups from Validity Rollups is the time that elapses between the initialization of a withdrawal and its finalization. In both cases, withdrawals are initialized on L2 and finalized on L1. On StarkNet, finalization is possible as soon as the validity proof of the new state root is accepted on Ethereum: theoretically, it is possible to withdraw funds in the first block of L1 following initialization. In practice, the frequency of sending validity proofs on Ethereum is a trade-off between the speed of block finalization and proof aggregation. Currently StarkNet provides validity proofs for verification every 10 hours 4, but it is intended to be decreased as transaction activity increases. On Optimism Bedrock it is possible to finalize a withdrawal only at the end of the dispute period (currently 7 days), after which a root is automatically considered valid. The length of this period is mainly determined by the fact that fault proofs can be censored on Ethereum until its end. The success probability of this type of attack decreases exponentially as time increases: E[subtracted value] = 𝑉𝑝𝑛 where 𝑛is the number of blocks in an interval, 𝑉is the amount of funds that can be subtracted by publishing an invalid root, and 𝑝is the probability of successfully performing a censorship attack in a single block. Suppose that this probability is 99%, that the value locked in the Rollup is one million Ether, and that the blocks in an interval are 1800 (6 hours of blocks with a 12 seconds interval): the expected value is about 0.01391 Ether. The system is made secure by asking Proposers to stake a much larger amount of Ether than the expected value. Winzer et al. showed how to carry out a censorship attack using a simple smart contract that ensures that certain areas of memory in the state do not change [20]. Modeling the attack as a Markov game, the paper shows that censoring is the dominant strategy for a rational block producer if they receive more compensation than including the transaction that changes the memory. The 𝑝value discussed above can be viewed as the percentage of rational block producers in the network, where “rational” does not take into account possibly penalizing externalities, such as less trust in the blockchain that decreases its cryptocurrency value. The following code presents a smart contract that can be used to perform a censorship attack on Bedrock. The attack exploits the incentives of block producers by offering them a bribe to censor the transactions that would modify specific parts of the state. The contract’s main function, claimBribe, allows block producers to claim the bribe if they successfully censor the targeted transaction by checking that the invalid output root is not touched. function claimBribe(bytes memory storageProof) external { require(!claimed[block.number], "bribe already claimed"); OutputProposal memory current = storageOracle.getStorage(L2_ORACLE, block.number, SLOT, storageProof); require(invalidOutputRoot == current.outputRoot, "attack failed"); claimed[block.number] = true; (bool sent, ) = block.coinbase.call{value: bribeAmount}(""); 4https://etherscan.io/address/0xc662c410c0ecf747543f5ba90660f6abebd9c8c4
require(sent, "failed to send ether"); } Listing 1: Example of a contract that incentivizes a censorship attack on Bedrock. The length of the dispute period must also take into account the fact that the fault proof is an interactive proof and therefore enough time must be provided for participants to interact and that any interaction could be censored. If the last move occurs at a time very close to the end of the dispute period, the cost of censoring is significantly less. Although censoring is the dominant strategy, the likelihood of success is lower because censoring nodes are vulnerable to Denial of Service attacks: an attacker can generate very complex transactions that end with the publication of a fault proof at no cost, as no fees would be paid. In extreme cases, a long dispute period allows coordination in the event of a successful censorship attack to organize a fork and exclude the attacking block producers. Another possible attack consists in publishing more state root proposals than disputants can verify, which can be avoided using a frequency limit. 4.1.1. Fast optimistic withdrawals Since the validity of an Optimistic Rollup can be verified at any time by any Full Node, a trusted oracle can be used to know on L1 whether the withdrawal can be finalized safely. This mechanism was first proposed by Maker [21]: an oracle verifies the withdrawal, publishes the result on L1 on which an interest-bearing loan is assigned to the user, which is automatically closed at the end of 7 days, i.e. when the withdrawal can actually be finalized. This solution introduces a trust assumption, but in the case of Maker it is minimized since the oracle operator is managed by the same organization that assumes the risk by providing the loan. 4.2. Transaction costs The cost of L2 transactions is mostly determined by the interaction with the L1. In both solutions the computational cost of transactions is very cheap as it is executed entirely off-chain. Optimism publishes L2 transactions calldata as calldata and rarely (or never) executes fault proofs, therefore calldata is the most expensive resource. On January 12, 2022 a Bedrock network has been launched on the Ethereum’s Goerli testnet. A gas compression rate can be calculated by tracking the amount of gas used on Bedrock in a certain period and by comparing it to the amount of gas spent on L1 for the corresponding blocks. Using this method a gas compression rate of ∼20 : 1 is found, but this figure may differ with real activity on mainnet. StarkNet publishes on Ethereum every change in L2 state as calldata, therefore storage is the most expensive resource. Since the network does not use the EVM, the transaction cost compression cannot be trivially estimated. By assuming the cost of execution and calldata to be negligible, it is possible to calculate the compression ratio of storage writes compared to L1. Assuming no contract is deployed and 10 cells not previously accessed on StarkNet are modified, a storage write cost compression rate of ∼24 : 1 is found. If a cell is overwritten 𝑛times between data publications, the cost of each write will be 1/𝑛compared to the cost of a single write, since only the last one is published. The cost can be further minimized by
compressing frequently used values. The cost of validity proof verification is divided among the transactions it refers to: for example, StarkNet block 4779 contains 200 transactions and its validity proof consumes 267830 units of gas, or 1339.15 gas for each transaction. 4.2.1. Optimizing calldata: cache contract Presented below is a smart contract that implements an address cache for frequently used addresses by taking advantage of the fact that storage and execution are much less expensive resources, along with a Friends contract that demonstrates its use. The latter keeps track of the “friends” of an address that can be registered by calling the addFriend function. If an address has already been used at least once, it can be added by calling the addFriendWithCache function: the cache indices are 4-byte integers while the addresses are represented by 20 bytes, so there is a 5:1 saving on the function argument. The same logic can be used for other data types such as integers or more generally bytes. contract AddressCache { mapping(address => uint32) public address2key; address[] public key2address; function cacheWrite(address _address) internal returns (uint32) { require(key2address.length < type(uint32).max, "AddressCache: cache is full"); require(address2key[_address] == 0, "AddressCache: address already cached"); // keys must start from 1 because 0 means "not found" uint32 key = uint32(key2address.length + 1); address2key[_address] = key; key2address.push(_address); return key; } function cacheRead(uint32 _key) public view returns (address) { require(_key <= key2address.length && _key > 0, "AddressCache: key not found"); return key2address[_key - 1]; } } Listing 2: Address cache contract. contract Friends is AddressCache { mapping(address => address[]) public friends; function addFriend(address _friend) public { friends[msg.sender].push(_friend); cacheWrite(_friend); } function addFriendWithCache(uint32 _friendKey) public { friends[msg.sender].push(cacheRead(_friendKey)); } function getFriends() public view returns (address[] memory) { return friends[msg.sender];
} } Listing 3: Example of a contract that inherits the address cache. The contract supports in cache about 4 billion (232) addresses, and adding one byte gives about 1 trillion (240). 4.2.2. Optimizing storage: Bloom’s filters On StarkNet there are several techniques for minimizing storage usage. If it is not necessary to guarantee the availability of the original data then it is sufficient to save on-chain its hash: this is the mechanism used to save data for an ERC-721 (NFT) [22], i.e., an IPFS link that resolves the hash of the data if available. For data that is stored multiple times, it is possible to use a look-up table similar to the caching system introduced for Optimism, requiring all values to be saved at least once. For some applications, saving all the values can be avoided by using a Bloom filter [23, 24, 25], i.e., a probabilistic data structure that allows one to know with certainty whether an element does not belong to a set but admits a small but non-negligible probability of false positives. A Bloom filter is initialized as an array of 𝑚bits at zero. To add an element, 𝑘hash functions with a uniform random distribution are used, each one mapping to a bit of the array that is set to 1. To check whether an element belongs to the set we run the 𝑘hash functions and verify that the 𝑘bits are set to 1. In a simple Bloom’s filter there is no way to distinguish whether an element actually belongs to the set or is a false positive, a probability that grows as the number of entries increases. After inserting 𝑛elements: P[false positive] = (︃ 1 − [︂ 1 −1 𝑚 ]︂𝑘𝑛)︃𝑘 ≈ (︁ 1 −𝑒−𝑘𝑛/𝑚)︁𝑘 assuming independence of the probability of each bit set. If 𝑛elements (of arbitrary size!) are expected to be included and the probability of a false positive tolerated is 𝑝, the size of the array can be calculated as: 𝑚= −𝑛ln 𝑝 (ln 2)2 While the optimal number of hash functions is: 𝑘= 𝑚 𝑛ln 2 If we assume to insert 1000 elements with a tolerance of 1%, the size of the array is 9585 bits with 𝑘= 6, while for a tolerance of 0.1% it becomes 14377 bits with 𝑘= 9. If a million elements are expected to be inserted, the size of the array becomes about 1170 kB for 1% and 1775 kB for 0.1%, with the same values of 𝑘, since it depends only on 𝑝[26]. In a game where players must not be assigned to an opponent they have already challenged, instead of saving in storage for each player the list of past opponents one can use a Bloom filter. The risk of not challenging some players is often acceptable, and the filter can be reset periodically.
4.3. Ethereum compatibility The main advantage of being compatible with EVM and Ethereum is the reuse of all the available tools. Ethereum smart contracts can be published on Optimism without any modification nor new audits. Wallets remain compatible, development and static analysis tools, general analysis tools, indexing tools and oracles. Ethereum and Solidity have a long history of well-studied vulnerabilities, such as reentrancy attacks, overflows and underflows, flash loans, and oracle manipulations. Because of this, Optimism was able to capture a large amount of value in a short time. Choosing to adopt a different virtual machine implies having to rebuild an entire ecosystem, with the advantage of a greater implementation freedom. StarkNet natively implements account abstraction, which is a mechanism whereby each account is a smart contract that can implement arbitrary logic as long as it complies with an interface (hence the term abstraction): this allows the use of different digital signature schemes, the ability to change the private key using the same address, or use a multisig. The Ethereum community proposed the introduction of this mechanism with EIP-2938 in 2020, but the proposal has remained stale for more than a year as other updates have been given more priority [27]. Another important benefit gained from compatibility is the reuse of existing clients: Optimism uses a version of geth for its own node with only ∼800 lines of difference, which has been developed, tested, and maintained since 2014. Having a robust client is crucial as it defines what is accepted as valid or not in the network. A bug in the implementation of the fault proof system could cause an incorrect proof to be accepted as correct or a correct proof for an invalid block to be accepted as incorrect, compromising the system. The likelihood of this type of attack can be limited with a wider client diversity: Optimism can reuse in addition to geth the other Ethereum clients already maintained, and development of another Erigon-based client is already underway. In 2016 a problem in the memory management of geth was exploited for a DoS attack and the first line of defense was to recommend the use of Parity, the second most used client at the time 5. StarkNet faces the same problem with validity proofs, but the clients have to be written from scratch and the proof system is much more complex, and consequently it is also much more complex to ensure correctness.
مقارنة
- المقارنة 4.1. وقت الانسحاب الجانب الأكثر أهمية الذي يميز مجموعات التفاؤل عن مجموعات الصلاحية هو الوقت المنقضي بين بدء عملية الانسحاب ووضع اللمسات النهائية عليها. في كلتا الحالتين، تتم تهيئة عمليات السحب على L2 والانتهاء منها على L1. في StarkNet، يمكن الانتهاء من ذلك بمجرد قبول إثبات صحة جذر الحالة الجديد في Ethereum: من الناحية النظرية، فهو كذلك من الممكن سحب الأموال في المجموعة الأولى من L1 بعد التهيئة. في الممارسة العملية، تردد إرسال إثباتات الصلاحية على Ethereum عبارة عن مفاضلة بين سرعة البلوك وضع اللمسات النهائية وتجميع الأدلة. يوفر StarkNet حاليًا أدلة صحة للتحقق كل 10 ساعات 4، ولكن المقصود أن تنخفض مع زيادة نشاط المعاملات. في Optimism Bedrock من الممكن إنهاء الانسحاب فقط في نهاية النزاع (حاليًا 7 أيام)، وبعدها يعتبر الجذر صالحًا تلقائيًا. طول يتم تحديد هذه الفترة بشكل أساسي من خلال حقيقة أنه يمكن فرض الرقابة على أدلة الأخطاء على Ethereum حتى نهايتها. تتناقص احتمالية نجاح هذا النوع من الهجمات بشكل كبير مع مرور الوقت: ه[القيمة المطروحة] = 𝑉𝑝𝑛 حيث 𝑛 هو عدد الكتل في الفترة، و𝑉 هو مقدار الأموال التي يمكن طرحها عن طريق نشر جذر غير صالح، و𝑝 هو احتمال إجراء الرقابة بنجاح الهجوم في كتلة واحدة. لنفترض أن هذا الاحتمال هو 99%، أن القيمة مؤمنة في التراكمي هو مليون إيثر، وأن الكتل في فترة زمنية هي 1800 (6 ساعات من الكتل مع 12 الفاصل الزمني للثواني): القيمة المتوقعة هي حوالي 0.01391 إيثر. أصبح النظام آمنًا بواسطة مطالبة مقدمي العروض بالحصول على كمية أكبر بكثير من الأثير من القيمة المتوقعة. وينزر وآخرون. أظهر كيفية تنفيذ هجوم الرقابة باستخدام smart contract بسيط يضمن عدم تغيير مناطق معينة من الذاكرة في الحالة [20]. نمذجة الهجوم باعتبارها لعبة ماركوف، توضح الورقة أن الرقابة هي الإستراتيجية السائدة للعقلانية منتج الكتلة إذا حصل على تعويض أكبر من تضمين المعاملة التي تتغير الذاكرة. يمكن اعتبار قيمة 𝑝 التي تمت مناقشتها أعلاه كنسبة مئوية من الكتلة النسبية المنتجين في الشبكة، حيث "العقلاني" لا يأخذ بعين الاعتبار احتمال معاقبة العوامل الخارجية، مثل انخفاض الثقة في blockchain مما يقلل من قيمة العملة المشفرة الخاصة بها. يقدم الكود التالي smart contract الذي يمكن استخدامه لتنفيذ هجوم الرقابة على حجر الأساس. يستغل الهجوم حوافز منتجي الكتل من خلال تقديم رشوة لهم فرض رقابة على المعاملات التي من شأنها تعديل أجزاء معينة من الدولة. العقد الرئيسي تسمح وظيفة "المطالبة بالرشوة" لمنتجي الكتل بالمطالبة بالرشوة إذا نجحوا في فرض الرقابة المعاملة المستهدفة عن طريق التحقق من عدم لمس جذر الإخراج غير الصالح. وظيفة المطالبةBribe (بايت تخزين الذاكرة) خارجي { require(!claimed[block.number], "تم المطالبة بالرشوة بالفعل"); تيار الذاكرة OutputProposal = StorageOracle.getStorage(L2_ORACLE, block.number, SLOT, إثبات التخزين)؛ يتطلب (invalidOutputRoot == current.outputRoot، "فشل الهجوم")؛ ادعى[block.number] = صحيح؛ (تم إرسال المنطق،) = block.coinbase.call{value: bribeAmount}(""); 4https://etherscan.io/address/0xc662c410c0ecf747543f5ba90660f6abebd9c8c4يتطلب (أرسل، "فشل في إرسال الأثير")؛ } القائمة 1: مثال على عقد يحفز هجوم الرقابة على Bedrock. يجب أن يأخذ طول فترة النزاع أيضًا في الاعتبار حقيقة وجود دليل على الخطأ دليل تفاعلي وبالتالي يجب توفير الوقت الكافي للمشاركين للتفاعل وأن أي تفاعل يمكن أن يخضع للرقابة. إذا حدثت الخطوة الأخيرة في وقت قريب جدًا من وفي نهاية فترة النزاع، تكون تكلفة الرقابة أقل بكثير. على الرغم من أن الرقابة هي الإستراتيجية المهيمنة، فإن احتمالية النجاح أقل لأن عقد الرقابة معرضة للخطر هجمات رفض الخدمة: يمكن للمهاجم إنشاء معاملات معقدة للغاية تنتهي بـ نشر إثبات الخطأ دون أي تكلفة، حيث لن يتم دفع أي رسوم. وفي الحالات القصوى، تسمح فترة النزاع الطويلة بالتنسيق في حالة نجاحه هجوم الرقابة لتنظيم شوكة واستبعاد منتجي الكتلة المهاجمين. آخر يتمثل الهجوم المحتمل في نشر مقترحات لجذر الدولة أكثر مما يستطيع المتنازعون التحقق منه، والتي يمكن تجنبها باستخدام حد التردد. 4.1.1. انسحابات متفائلة سريعة نظرًا لأنه يمكن التحقق من صحة مجموعة التحديثات المتفائلة في أي وقت بواسطة أي عقدة كاملة، أ يمكن استخدام oracle الموثوق به لمعرفة ما إذا كان من الممكن إنهاء السحب بأمان على L1. هذا تم اقتراح الآلية لأول مرة بواسطة Maker [21]: يتحقق oracle من السحب، وينشر النتيجة على L1 حيث يتم تعيين قرض بفائدة للمستخدم، والذي يتم تلقائيًا يتم إغلاقه في نهاية 7 أيام، أي عندما يمكن الانتهاء من السحب فعليًا. هذا الحل يقدم افتراض الثقة، ولكن في حالة Maker يتم تصغيره نظرًا لأن عامل التشغيل oracle تتم إدارته من قبل نفس المنظمة التي تتحمل المخاطر من خلال تقديم القرض. 4.2. تكاليف المعاملات يتم تحديد تكلفة معاملات المستوى الثاني في الغالب من خلال التفاعل مع المستوى الأول. في كلا الحلين التكلفة الحسابية للمعاملات رخيصة جدًا حيث يتم تنفيذها بالكامل خارج السلسلة. Optimism ينشر بيانات استدعاء معاملات L2 كبيانات استدعاء ونادرًا (أو لا ينفذ أبدًا) الخطأ البراهين، وبالتالي فإن بيانات الاتصال هي المورد الأكثر تكلفة. في 12 يناير 2022 شبكة بيدروك تم إطلاقه على شبكة اختبار Goerli الخاصة بـ Ethereum. يمكن حساب معدل ضغط الغاز من خلال تتبع كمية الغاز المستخدمة في حجر الأساس في فترة معينة ومقارنتها مع كمية الغاز المستهلكة على L1 للكتل المقابلة. باستخدام هذه الطريقة ضغط الغاز تم العثور على معدل ∼20 : 1، ولكن هذا الرقم قد يختلف مع النشاط الحقيقي على الشبكة الرئيسية. StarkNet ينشر في Ethereum كل تغيير في حالة L2 كبيانات اتصال، وبالتالي فإن التخزين أغلى الموارد. نظرًا لأن الشبكة لا تستخدم EVM، فستكون تكلفة المعاملة لا يمكن تقدير الضغط بشكل تافه. من خلال افتراض تكلفة التنفيذ وبيانات الاتصال تكون ضئيلة، فمن الممكن لحساب نسبة ضغط الكتابة التخزين مقارنة L1. بافتراض عدم نشر أي عقد و10 خلايا لم يتم الوصول إليها مسبقًا على StarkNet تم تعديله، وتم العثور على معدل ضغط تكلفة كتابة التخزين يبلغ ∼ 24: 1. إذا تم الكتابة فوق الخلية 𝑛مرات بين عمليات نشر البيانات، ستكون تكلفة كل عملية كتابة 1/𝑛مقارنة بالتكلفة من كتابة واحدة، حيث يتم نشر آخر واحد فقط. يمكن تقليل التكلفة بشكل أكبر من خلالضغط القيم المستخدمة بشكل متكرر. وتنقسم تكلفة التحقق من صحة إثبات بين المعاملات التي يشير إليها: على سبيل المثال، StarkNet الكتلة 4779 تحتوي على 200 معاملة و إثبات الصلاحية يستهلك 267830 وحدة غاز، أو 1339.15 غاز لكل معاملة. 4.2.1. تحسين بيانات الاتصال: عقد ذاكرة التخزين المؤقت الموضح أدناه هو smart contract الذي يقوم بتنفيذ ذاكرة تخزين مؤقت للعناوين للاستخدام المتكرر العناوين من خلال الاستفادة من حقيقة أن التخزين والتنفيذ أقل تكلفة بكثير الموارد، إلى جانب عقد الأصدقاء الذي يوضح استخدامه. هذا الأخير يتتبع "أصدقاء" لعنوان يمكن تسجيله عن طريق استدعاء وظيفة addFriend. إذا كان عنوان تم استخدامه بالفعل مرة واحدة على الأقل، ويمكن إضافته عن طريق استدعاء addFriendWithCache الوظيفة: مؤشرات ذاكرة التخزين المؤقت هي أعداد صحيحة مكونة من 4 بايت بينما يتم تمثيل العناوين بـ 20 بايت، لذلك هناك توفير بنسبة 5:1 في وسيطة الوظيفة. يمكن استخدام نفس المنطق للبيانات الأخرى أنواع مثل الأعداد الصحيحة أو البايتات بشكل عام. العقد AddressCache { تعيين (عنوان => uint32) عنوان عام 2key؛ العنوان[] المفتاح العام2عنوان; وظيفة ذاكرة التخزين المؤقت (العنوان _address) العوائد الداخلية (uint32) { require(key2address.length < type(uint32).max, "AddressCache: ذاكرة التخزين المؤقت ممتلئة"); require(address2key[_address] == 0, "AddressCache: العنوان مخبأ بالفعل"); // يجب أن تبدأ المفاتيح من 1 لأن 0 يعني "لم يتم العثور عليها" مفتاح uint32 = uint32(key2address.length + 1); Address2key[_address] = key; key2address.push(_address); مفتاح العودة؛ } وظيفة ذاكرة التخزين المؤقت قراءة (uint32 _key) إرجاع العرض العام (العنوان) { require(_key <= key2address. length && _key > 0, "AddressCache: لم يتم العثور على المفتاح"); إرجاع عنوان المفتاح2[_key - 1]; } } القائمة 2: عنوان عقد التخزين المؤقت. أصدقاء العقد هو AddressCache { تعيين (العنوان => العنوان []) الأصدقاء العامين؛ وظيفة addFriend(address _friend) عامة { friends[msg.sender].push(_friend); ذاكرة التخزين المؤقت(_friend); } وظيفة addFriendWithCache(uint32 _friendKey) عامة { friends[msg.sender].push(cacheRead(_friendKey)); } وظيفة getFriends () إرجاع العرض العام (العنوان [] الذاكرة) { عودة الأصدقاء[msg.sender]؛} } القائمة 3: مثال على عقد يرث ذاكرة التخزين المؤقت للعنوان. يدعم العقد في ذاكرة التخزين المؤقت حوالي 4 مليارات (232) عنوانًا، ويعطي إضافة بايت واحد حوالي 1 تريليون (240). 4.2.2. تحسين التخزين: مرشحات بلوم يوجد في StarkNet العديد من الأساليب لتقليل استخدام مساحة التخزين. إذا لم يكن من الضروري أن ضمان توافر البيانات الأصلية، فيكفي حفظها على السلسلة hash: هذا هي الآلية المستخدمة لحفظ البيانات لـ ERC-721 (NFT) [22]، أي رابط IPFS الذي يحل المشكلة hash من البيانات إذا كانت متوفرة. بالنسبة للبيانات التي يتم تخزينها عدة مرات، فمن الممكن استخدام البحث جدول مشابه لنظام التخزين المؤقت المقدم لـ Optimism، والذي يتطلب حفظ جميع القيم فيه مرة واحدة على الأقل. بالنسبة لبعض التطبيقات، يمكن تجنب حفظ كافة القيم باستخدام مرشح بلوم [23، 24، 25]، أي بنية بيانات احتمالية تسمح للمرء أن يعرف على وجه اليقين ما إذا كان لا ينتمي العنصر إلى مجموعة ولكنه يعترف باحتمالية خطأ صغيرة ولكن لا يمكن إهمالها إيجابيات. تتم تهيئة مرشح Bloom كمصفوفة مكونة من 𝑚bits عند الصفر. لإضافة عنصر، استخدم الدالة 𝑘hash مع توزيع عشوائي موحد، يتم تعيين كل منها إلى جزء صغير من المصفوفة التي تم تعيينها إلى 1. للتحقق مما إذا كان العنصر ينتمي إلى المجموعة نقوم بتشغيل الوظائف 𝑘hash والتحقق أن قيمة 𝑘bits مضبوطة على 1. في مرشح بلوم البسيط، لا توجد طريقة للتمييز ما إذا كان ينتمي العنصر فعليًا إلى المجموعة أو يكون نتيجة إيجابية كاذبة، وهو احتمال ينمو كرقم من الإدخالات يزيد. بعد إدخال 𝑛العناصر: ف[إيجابية كاذبة] = (︃ 1 - [︂ 1 −1 𝑚 ]︂𝑘𝑛)︃𝑘 ≈ (︁ 1 −𝑒−𝑘𝑛/𝑚)︁𝑘 بافتراض استقلالية احتمالية كل مجموعة بت. إذا كان عدد 𝑛 من العناصر (ذات حجم عشوائي!) موجودًا من المتوقع أن يتم تضمينها، واحتمال وجود نتيجة إيجابية كاذبة مسموح بها هو 𝑝، وهو حجم المصفوفة يمكن حسابها على النحو التالي: 𝑚= −𝑛ln 𝑝 (في 2)2 بينما العدد الأمثل لوظائف hash هو: 𝑘= 𝑚 𝑛ln 2 إذا افترضنا إدراج 1000 عنصر بتفاوت 1% فإن حجم المصفوفة هو 9585 بت مع 𝑘= 6، بينما في حالة التسامح بنسبة 0.1% يصبح 14377 بت مع 𝑘= 9. إذا كان مليون عنصر ومن المتوقع إدراجها، يصبح حجم المصفوفة حوالي 1170 كيلو بايت لـ 1% و1775 كيلو بايت لـ 0.1%، بنفس قيم 𝑘، لأنها تعتمد فقط على 𝑝[26]. في لعبة لا يجب فيها تعيين اللاعبين إلى خصم سبق لهم تحديه، بدلاً من حفظ قائمة الخصوم السابقين في مساحة التخزين لكل لاعب، يمكن للمرء استخدام بلوم مرشح. غالبًا ما تكون مخاطرة عدم تحدي بعض اللاعبين مقبولة، ويمكن إعادة ضبط عامل التصفية بشكل دوري.4.3. Ethereum التوافق الميزة الرئيسية للتوافق مع EVM وEthereum هي إعادة استخدام كل ما هو متاح أدوات. Ethereum smart contracts يمكن نشرها على Optimism دون أي تعديل أو عمليات التدقيق الجديدة. تظل المحافظ متوافقة وأدوات التطوير والتحليل الثابت والتحليل العام الأدوات وأدوات الفهرسة وoracles. Ethereum و Solidity لها تاريخ طويل من الدراسة الجيدة الثغرات الأمنية، مثل هجمات إعادة الدخول، والتجاوزات والتجاوزات، والقروض السريعة، وoracle التلاعب. ولهذا السبب، تمكن Optimism من الحصول على قدر كبير من القيمة في وقت قصير الوقت. إن اختيار استخدام جهاز افتراضي مختلف يعني الحاجة إلى إعادة بناء النظام البيئي بأكمله، مع ميزة حرية تنفيذ أكبر. StarkNet ينفذ الحساب أصلاً التجريد، وهو آلية حيث يكون كل حساب smart contract يمكن تنفيذه المنطق التعسفي طالما أنه يتوافق مع واجهة (ومن هنا جاء مصطلح التجريد): وهذا يسمح استخدام أنظمة التوقيع الرقمي المختلفة، والقدرة على تغيير المفتاح الخاص باستخدام نفس العنوان، أو استخدم multisig. اقترح مجتمع Ethereum تقديم هذا آلية مع EIP-2938 في عام 2020، لكن الاقتراح ظل قديمًا لأكثر من عام تم إعطاء التحديثات الأخرى أولوية أكبر [27]. هناك فائدة أخرى مهمة يتم اكتسابها من التوافق وهي إعادة استخدام العملاء الحاليين: Optimism يستخدم نسخة من geth للعقدة الخاصة به مع اختلاف ∼ 800 سطر فقط، وهو ما كان تم تطويره واختباره وصيانته منذ عام 2014. إن وجود عميل قوي أمر بالغ الأهمية كما هو محدد ما هو مقبول على أنه صالح أم لا في الشبكة. خطأ في تنفيذ دليل على الخطأ قد يتسبب النظام في قبول دليل غير صحيح على أنه صحيح أو دليل صحيح على غير صالح ليتم قبول الكتلة على أنها غير صحيحة، مما يعرض النظام للخطر. احتمالية هذا النوع من يمكن أن يقتصر الهجوم على نطاق أوسع من العملاء: Optimism يمكن إعادة استخدامه بالإضافة إلى الحصول على عملاء Ethereum الآخرين الذين تمت صيانتهم بالفعل، ويتم تطوير عميل آخر قائم على Erigon جارية بالفعل. في عام 2016، تم استغلال مشكلة في إدارة الذاكرة في برنامج geth كان هجوم DoS وخط الدفاع الأول هو التوصية باستخدام التكافؤ، والثاني أكثر العميل المستخدم في ذلك الوقت 5. StarkNet يواجه نفس المشكلة مع إثباتات الصلاحية، لكن العملاء يجب كتابتها من الصفر، ونظام الإثبات أكثر تعقيدًا، وبالتالي بل هو أيضًا أكثر تعقيدًا لضمان الصحة.
Conclusion
Conclusion
- Conclusion Rollups are the most promising solution available today to solve the scalability problem in decentralized blockchains, paving the way for the era of modular blockchains as opposed to monolithic blockchains. The choice of developing either an Optimistic Rollup or a Validity Rollup is mainly shown as a trade-off between complexity and agility. StarkNet has numerous advantages such as fast withdrawals, structural inability to have invalid state transitions, lower transaction cost at the expense of a longer development period and incompatibility with EVM, while Optimism has leveraged the network economy to quickly gain a major share of the market. Optimism Bedrock, however, possesses a modular design that allows it to become a Validity 5https://blog.ethereum.org/2016/09/22/ethereum-network-currently-undergoing-dos-attack
Rollup in the future: Cannon currently uses minigeth compiled to MIPS for its fault proof system, but the same architecture can be used to obtain a circuit and produce validity proofs. Compiling a complex machine such as the EVM for a microarchitecture results in a simpler circuit that does not need to be modified and re-verified in case of upgrades. RISC Zero is a verifiable microarchitecture with STARK proofs already in development based on RISC-V that can be used for this purpose as an alternative to MIPS [28]. One aspect that should not be underestimated is the complexity in understanding how the technology works. A strength of traditional blockchains is to be able to verify the state of the blockchain without trusting any third party entity. However, in the case of StarkNet, it is necessary to trust the implementation when it is not possible to verify the various components based on cryptography and advanced mathematics. This may initially create friction for the adoption of the technology, but as the tools and the usage of integrity proofs advance even outside the blockchain field this problem will be hopefully solved.
خاتمة
- الاستنتاج تعد المجموعات المجمعة هي الحل الواعد المتاح اليوم لحل مشكلة قابلية التوسع في اللامركزية blockchains، مما يمهد الطريق لعصر blockchains المعيارية بدلاً من متجانسة blockchains. يظهر بشكل أساسي اختيار تطوير مجموعة متفائلة أو مجموعة صلاحية كمفاضلة بين التعقيد وخفة الحركة. يتمتع StarkNet بالعديد من المزايا مثل السرعة عمليات السحب، وعدم القدرة الهيكلية على التحولات غير الصالحة للحالة، وانخفاض تكلفة المعاملات في حساب فترة تطوير أطول وعدم التوافق مع EVM، بينما Optimism لديه استفادت من اقتصاد الشبكة للحصول بسرعة على حصة كبيرة من السوق. Optimism ومع ذلك، يمتلك Bedrock تصميمًا معياريًا يسمح له بأن يصبح صالحًا 5https://blog.ethereum.org/2016/09/22/ethereum-network-currently-undergoing-dos-attack
مجموعة التحديثات في المستقبل: يستخدم Cannon حاليًا برنامج minigeth المترجم إلى MIPS لإثبات الأخطاء النظام، ولكن يمكن استخدام نفس البنية للحصول على دائرة وإنتاج إثباتات الصلاحية. يؤدي تجميع جهاز معقد مثل EVM للهندسة المعمارية الدقيقة إلى عملية أبسط الدائرة التي لا تحتاج إلى تعديل وإعادة التحقق منها في حالة الترقية. RISC صفر هو بنية دقيقة يمكن التحقق منها مع أدلة STARK قيد التطوير بالفعل بناءً على RISC-V ذلك يمكن استخدامه لهذا الغرض كبديل لـ MIPS [28]. أحد الجوانب التي لا ينبغي الاستهانة بها هو التعقيد في فهم كيفية تعمل التكنولوجيا. تتمثل قوة blockchains التقليدية في القدرة على التحقق من حالة blockchain دون الثقة في أي كيان خارجي. ومع ذلك، في حالة StarkNet، فهو كذلك من الضروري الثقة في التنفيذ عندما لا يكون من الممكن التحقق من المكونات المختلفة على أساس التشفير والرياضيات المتقدمة. قد يؤدي هذا في البداية إلى خلق احتكاك لـ اعتماد التكنولوجيا، ولكن مع تقدم الأدوات واستخدام البراهين النزاهة خارج الحقل blockchain نأمل أن يتم حل هذه المشكلة.