-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Protocol: DS: Verkle Tree intro added (#110) * Protocol: DS: Verkle Tree intro added * Protocol: DS: typo * Update info on verkles --------- Co-authored-by: Mário Havel <[email protected]> * add week 6 to sidebar * Update week6-dev.md (#116) * add week 6 research * 📜 Adds History section (#52) * ➕ Adding The Merge to History section * 👷 Added post-merge block proposal steps * Lean changes --------- Co-authored-by: Mário Havel <[email protected]> * ✨ feat(EL): precompiled contracts (#106) * ✨ feat(EL): precompiled contracts * 🥢 nit(EL): clarity * 🥢 nit(EL): precompile vs opcode, proposed precompiles * add a resource --------- Co-authored-by: rahul <[email protected]> Co-authored-by: Mário Havel <[email protected]> --------- Co-authored-by: Abhimanyu <[email protected]> Co-authored-by: Hsiao-Wei Wang <[email protected]> Co-authored-by: GianfrancoBazzani <[email protected]> Co-authored-by: rahul <[email protected]> Co-authored-by: rahul <[email protected]>
- Loading branch information
1 parent
7c13e28
commit 61c71c5
Showing
10 changed files
with
1,841 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Study Group Week 6 | Sharding and DAS | ||
|
||
Week 6 research track is going to be a dive into data availability sampling and danksharding. | ||
|
||
Join the presentation by [Dankrad](https://twitter.com/dankrad) on [Wednesday, March 27, 4PM UTC](https://savvytime.com/converter/utc-to-germany-berlin-united-kingdom-london-ny-new-york-city-ca-san-francisco-china-shanghai-japan-tokyo-australia-sydney/mar--2024/4pm). (Note it's 2 hour earlier than our regular calls!) | ||
|
||
The talk will be streamed live on [StreamEth](https://streameth.org/65cf97e702e803dbd57d823f/epf_study_group) and Youtube, links will be provided before the call in the [Discord server](https://discord.gg/addwpQbhpq). Discord also serves for the discussion and questions during the stream. | ||
|
||
## Pre-reading | ||
|
||
Before starting with the week 6 content, make yourself familiar with resources in introductory weeks. | ||
|
||
Additionally, you can read and get ready by studying the following resources: | ||
|
||
- [Data availability problem](https://www.youtube.com/watch?v=OJT_fR7wexw) | ||
- [Danksharding by Dankrad, 2022](https://www.youtube.com/watch?v=1Cg2iu4C4sU) | ||
- [Sharding and DAS proposal](https://hackmd.io/@vbuterin/sharding_proposal) | ||
|
||
## Outline | ||
|
||
- | ||
|
||
## Additional reading and exercises | ||
|
||
- [Foundations of Data Availability Sampling](https://www.youtube.com/watch?v=KUNE3kR1kwU) | ||
- [Desing choices in DAS](https://www.youtube.com/watch?v=Al7Jns8bCO4) | ||
- [Danksharding workshop, Devcon Bogota](https://www.youtube.com/watch?v=8L2C6RDMV9Q) | ||
- [Fraud and DA proofs paper](https://arxiv.org/abs/1809.09044) | ||
- [WIP DAS proposal](https://hackmd.io/@vbuterin/das) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Precompiled contracts | ||
|
||
Precompiled contracts are a set of special accounts, each containing a built-in function with a determined gas cost, often related to complex cryptographic computations. Currently, they are defined at addresses ranging from `0x01` to `0x0a`. | ||
|
||
Unlike contract accounts, precompiles are part of the Ethereum protocol and implemented by [execution clients](/wiki/EL/el-clients.md). This presents an interesting caveat - their `EXTCODESIZE` within EVM is 0. Nonetheless, they function like contract accounts with code when executed. | ||
|
||
Precompiles are included in the initial `"accessed_addresses"` of a transaction as defined by [EIP-2929](https://eips.ethereum.org/EIPS/eip-2929) to save gas costs. | ||
|
||
## Precompiles vs. opcodes | ||
|
||
Both precompiles and opcodes have the same goal of performing arbitrary computations. Following considerations are made when choosing between them: | ||
|
||
- **Limited opcode space**: The EVM opcode space of 1-byte is inherently constrained (256 opcodes, `0x00`-`0xFF`). This necessitates judicious allocation for essential operations. | ||
- **Efficiency**: Precompiled contracts are natively executed outside the EVM, enabling efficient implementations for complex cryptographic computations that power many cross-chain interactions. | ||
|
||
Quoting ["A Prehistory of the Ethereum Protocol"](https://vitalik.eth.limo/general/2017/09/14/prehistory.html) by Vitalik: | ||
|
||
> The second was the idea of "precompiles", solving the problem of allowing complex cryptographic computations to be usable in the EVM without having to deal with EVM overhead. We had also gone through many more ambitious ideas about "native contracts", where if miners have an optimized implementation of some contracts they could "vote" the gasprice of those contracts down, so contracts that most miners could execute much more quickly would naturally have a lower gas price; however, all of these ideas were rejected because we could not come up with a cryptoeconomically safe way to implement such a thing. An attacker could always create a contract which executes some trapdoored cryptographic operation, distribute the trapdoor to themselves and their friends to allow them to execute this contract much faster, then vote the gasprice down and use this to DoS the network. Instead we opted for the much less ambitious approach of having a smaller number of precompiles that are simply specified in the protocol, for common operations such as hashes and signature schemes. | ||
|
||
## List of precompiles | ||
|
||
| Address | Name | Description | Since | | ||
| ------- | -------------------- | ------------------------------------------ | ------------------------------------------------------------- | | ||
| 0x01 | ECRECOVER | Elliptic curve public key recover | Frontier | | ||
| 0x02 | SHA2-256 | SHA2 256-bit hash scheme | Frontier | | ||
| 0x03 | RIPEMD-160 | RIPEMD 160-bit hash scheme | Frontier | | ||
| 0x04 | IDENTITY | Identity function | Frontier | | ||
| 0x05 | MODEXP | Arbitrary precision modular exponentiation | Byzantium ([EIP-198](https://eips.ethereum.org/EIPS/eip-198)) | | ||
| 0x06 | ECADD | Elliptic curve addition | Byzantium ([EIP-196](https://eips.ethereum.org/EIPS/eip-196)) | | ||
| 0x07 | ECMUL | Elliptic curve scalar multiplication | Byzantium ([EIP-196](https://eips.ethereum.org/EIPS/eip-196)) | | ||
| 0x08 | ECPAIRING | Elliptic curve pairing check | Byzantium ([EIP-197](https://eips.ethereum.org/EIPS/eip-197)) | | ||
| 0x09 | BLAKE2 | BLAKE2 compression function | Istanbul ([EIP-152](https://eips.ethereum.org/EIPS/eip-152)) | | ||
| 0x0a | KZG POINT EVALUATION | Verifies a KZG proof | Cancun ([EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)) | | ||
|
||
## Proposed precompiles | ||
|
||
[EIPs](https://eips.ethereum.org/) can introduce new precompiles as part of hard forks. Following precompiles are currently proposed: | ||
|
||
- [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) | ||
- [EIP-7212: Precompile for secp256r1 Curve Support](https://eips.ethereum.org/EIPS/eip-7212) | ||
- [EIP-7545: Verkle proof verification precompile](https://eips.ethereum.org/EIPS/eip-7545) | ||
|
||
The introduction of new precompiles requires careful consideration of their network effects. A precompile with miscalculated gas cost could potentially cause denial of service by consuming more resources than anticipated. Additionally, a growing number of precompiles can lead to code bloat within the EVM clients, increasing the burden on validators. | ||
|
||
## Calling precompiles | ||
|
||
Like contract account, precompiles can be called using `*CALL` family of opcodes. The following assembly code example shows usage of `SHA-256` precompile to hash the string "Hello": | ||
|
||
```js | ||
// First place the parameters in memory | ||
PUSH5 0x48656C6C6F // Hello in UTF-8 | ||
PUSH1 0 | ||
MSTORE | ||
|
||
// Call SHA-256 precompile (0x02) | ||
PUSH1 0x20 // retSize | ||
PUSH1 0x20 // retOffset | ||
PUSH1 5 // argsSize | ||
PUSH1 0x1B // argsOffset | ||
PUSH1 2 // address | ||
PUSH4 0xFFFFFFFF // gas | ||
STATICCALL | ||
|
||
POP // Pop the result of the STATICCALL | ||
|
||
// LOAD the result from memory to stack | ||
PUSH1 0x20 | ||
MLOAD | ||
``` | ||
|
||
which yields the hash: | ||
|
||
``` | ||
185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969 | ||
``` | ||
|
||
> ▶️ [Try it in the EVM playground!](https://www.evm.codes/playground?fork=cancun&unit=Wei&codeType=Mnemonic&code='~FirsKplaceqparameters%20inYZ5948656C6C6FjHello%20in%20UTF-8w0vMSTOREvv~Call%20SHA-256%20precompilJ%7BV02%7DNSizeNW5QSizewV1BQW2jaddressZ49FFFFFFFFjgasvbPOPjPop_ofqb~LOAD_fromYGo%20stackXvMLOAD'~%2F%2F%20wZ1%20v%5CnqGhJj%20~bSTATICCALLvv_qresulKZvPUSHY%20memoryXwV20WOffsetwV0xQjargsNXjretKt%20Je%20G%20t9%20V%019GJKNQVWXYZ_bjqvw~_) | ||
Refer the wiki on [EVM](/wiki/EL/evm.md) to understand how assembly code works. | ||
|
||
## Resources | ||
|
||
- [Appendix E: Ethereum Yellow Paper.](https://ethereum.github.io/yellowpaper/paper.pdf) | ||
- [Go Ethereum Precompile Implementation.](https://github.com/ethereum/go-ethereum/blob/master/core/vm/contracts.go) | ||
- [A Prehistory of the Ethereum Protocol](https://vitalik.eth.limo/general/2017/09/14/prehistory.html) | ||
- ["Stack Exchange: What's a precompiled contract and how are they different from native opcodes?"](https://ethereum.stackexchange.com/questions/440/whats-a-precompiled-contract-and-how-are-they-different-from-native-opcodes) | ||
- ["Stack Exchange: Why aren't more common algorithms done as precompiles?"](https://ethereum.stackexchange.com/questions/155787/why-arent-more-common-algorithms-done-as-precompiles) | ||
- [A call, a precompile and a compiler walk into a bar](https://blog.theredguild.org/a-call-a-precompile-and-a-compiler-walk-into-a-bar/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# History | ||
|
||
This page highlights important technical changes in the history of Ethereum protocol. [Overview from Ethereum.org](https://ethereum.org/en/history). | ||
|
||
## Homestead | ||
|
||
TODO | ||
|
||
## The Merge. | ||
|
||
On September 15, 2022, Ethereum activated [EIP-3675](https://eips.ethereum.org/EIPS/eip-3675) and upgraded the consensus mechanism to proof-of-stake through an event known as The Merge. The Merge has resulted in the deprecation of the proof-of-work consensus, which was previously implemented in the same logic layer as execution. Instead, it has been replaced by a more complex and sophisticated proof-of-stake consensus that eliminates the need for energy-intensive mining. New proof-of-stake consensus has been implemented in its own layer with a separate p2p networka and logic, also know as Beacon Chain. The Beacon Chain has been running and achieving consensus since December 1st, 2020. After a prolonged period of consistent performance without any failures, it was deemed ready to become Ethereum's consensus provider. The Merge gets its name from the union of the two networks. | ||
|
||
Learn more about The Merge in following resources and reading on Consensus layer. | ||
|
||
- [EIP-3675: Upgrade consensus to Proof-of-Stake](https://eips.ethereum.org/EIPS/eip-3675), [archived](https://web.archive.org/web/20240213102133/https://eips.ethereum.org/EIPS/eip-3675) | ||
- [Gasper](https://ethereum.org/developers/docs/consensus-mechanisms/pos/gasper), [archived](https://web.archive.org/web/20240214225630/https://ethereum.org/developers/docs/consensus-mechanisms/pos/gasper) | ||
- [Mega Merge Resources List](https://notes.ethereum.org/@MarioHavel/merge-resources), [archived](https://web.archive.org/web/20240302082121/https://notes.ethereum.org/@MarioHavel/merge-resources) |
Oops, something went wrong.