From 9fc146f0260b9913f799bfe777b480ea4be8c65e Mon Sep 17 00:00:00 2001
From: 0xfps
Date: Sun, 9 Jun 2024 16:52:13 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Finalize=20first=20review.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 90 +++++--------------
.../book/1-introduction/1-1-introduction.html | 2 +-
book/book/1-introduction/1-2-what-is-yul.html | 2 +-
.../1-3-why-is-yul-important.html | 4 +-
.../1-introduction/1-4-yul's-advantages.html | 2 +-
book/book/1-introduction/1-6-code-layout.html | 2 +-
...-solidity's-storage-and-memory-layout.html | 11 ++-
...1-starting-yul-in-a-solidity-contract.html | 2 +-
.../4-2-0-variable-storage-in-storage.html | 2 +-
.../4-2-1-uint8-uint128-uint256.html | 2 +-
.../4-2-2-int8-int128-int256.html | 2 +-
.../4-2-3-bytes1-bytes16-bytes32.html | 1 +
.../4-2-4-bytes.html | 3 +-
.../4-2-7-struct.html | 2 +-
.../4-4-yul-actions/4-4-17-staticcall.html | 2 +-
.../4-4-yul-actions/4-4-18-delegatecall.html | 2 +-
.../4-4-yul-actions/4-4-5-bitwise.html | 4 +-
.../4-4-yul-actions/4-4-8-loops.html | 2 +-
book/book/index.html | 2 +-
book/book/print.html | 47 +++++-----
book/book/searchindex.js | 2 +-
book/book/searchindex.json | 2 +-
22 files changed, 72 insertions(+), 118 deletions(-)
diff --git a/README.md b/README.md
index 4ff1373..041c30a 100644
--- a/README.md
+++ b/README.md
@@ -1,79 +1,35 @@
-## Yul By Example
+# Yul By Example
-Basically, we made [Solidity by example](https://solidity-by-example.org/) but for Yul :)
-**Required Solidity Version**: v0.8.17.
-**Required SPDX-License-Identifier**: MIT
+---
+```solidity
+// SPDX-License-Identifier: GPL-3.0
+pragma solidity ^0.8.0;
-To see the book change live run:
-
-```sh
-mdbook serve
+contract Yul {
+ function yulFunction() public {
+ assembly {
+ mstore(0x40, "Yul By Example.")
+ }
+ }
+}
```
-To run the book with docker, run:
+## Source Code
+book/src
+
+## Book URL
+🔗 https://yul-by-example.vercel.app/
+
+## Run Book Locally
+To run a copy of this book locally on your device, clone the repo and install `mdbook` via cargo (that comes with Rust). If you don't have Rust installed in your PC, you can download and setup Rust [here](https://www.rust-lang.org/).
-### Contracts Implemented so far
-- [Array](/src/Array.sol)
-- [Bitwise](/src/Bitwise.sol)
-- [Call](/src/Call.sol)
-- [Calldata](/src/Calldata.sol)
-- [Conditionals](/src/Conditionals.sol)
-- [Counter](/src/Counter.sol)
-- [Enums](/src/Enums.sol)
-- [Errors](/src/Errors.sol)
-- [Ether Wallet](/src/EtherWallet.sol)
-- [Events](/src/Events.sol)
-- [FallBack](/src/Fallback.sol)
-- [For Loop](src/ForLoop.sol)
-- [Functions](src/Functions.sol)
-- [Hash](src/Hash.sol)
-- [Hello World](/src/HelloWorld.sol)
-- [IsContract](/src/IsContract.sol)
-- [Mapping](/src/Mapping.sol)
-- [Send Ether](/src/SendEther.sol)
-- [Signature Verification](/src/SignatureVerification.sol)
-- [Simple Storage](/src/SimpleStorage.sol)
-- [Structs](/src/Structs.sol)
-- [Types](/src/Types.sol)
-- [Unchecked](/src/Unchecked.sol)
-- [ERC20](/src/YulERC20.sol)
+To install `mdbook`, you can refer to [this](https://rust-lang.github.io/mdBook/guide/installation.html).
-### Docs
-- [Array](/book/src/Array.md)
-- [Bitwise](/book/src/Bitwise.md)
-- [Call](/book/src/Call.md)
-- [Calldata](/book/src/Calldata.md)
-- [Conditionals](/book/src/Conditionals.md)
-- [Counter](/book/src/Counter.md)
-- [Enums](/book/src/Enums.md)
-- [Errors](/book/src/Errors.md)
-- [Ether Wallet](/book/src/EtherWallet.md)
-- [Events](/book/src/Events.md)
-- [Fallback](/book/src/Fallback.md)
-- [For Loop](/book/src/ForLoop.md)
-- [Functions](/book/src/Functions.md)
-- [Hash](/book/src/Hash.md)
-- [Hello World](/book/src/HelloWorld.md)
-- [Is Contract](/book/src/IsContract.md)
-- [Mapping](/book/src/Mapping.md)
-- [Safe Operations](/book/src/SafeOperations.md)
-- [Send Ether](/book/src/SendEther.md)
-- [Signature Verification](/book/src/SignarureVerification.md)
-- [Simple Storage](/book/src/SimpleStorage.md)
-- [Structs](/book/src/Structs.md)
-- [Types](/book/src/Types.md)
-- [Unchecked](/book/src/Unchecked.md)
-- [Yul ERC20](/book/src/YulERC20.md)
+To display the book on your browser, run `mdbook serve book/ -o` from the base directory.
## Contributors ✨
-
-
-### Acknowledgements
-
-These contracts were inspired by or directly modified from many sources, primarily:
-- [RareSkills](https://github.com/RareSkills/Udemy-Yul-Code)
-- [Solidity By Example](https://solidity-by-example.org/)
\ No newline at end of file
+
\ No newline at end of file
diff --git a/book/book/1-introduction/1-1-introduction.html b/book/book/1-introduction/1-1-introduction.html
index 2b7a77e..baa38d4 100644
--- a/book/book/1-introduction/1-1-introduction.html
+++ b/book/book/1-introduction/1-1-introduction.html
@@ -178,7 +178,7 @@ Hello there!
This is a book about Yul, a low-level, intermediate language written alongside Solidity that can be compiled to bytecode for different backends [1].
Over the course of this book, we are going to go through what Yul is, why it is important, its advantage and disadvantage over Solidity and its implementations in a smart contract.
-Also, we will see how storage and memory are laid out in Solidity and how we would harness the power of Yul to infiltrate and modify to our taste.
+Also, we will see how storage and memory are laid out in Solidity and how we would harness the power of Yul to infiltrate and modify these to our taste.
Enjoy!
diff --git a/book/book/1-introduction/1-2-what-is-yul.html b/book/book/1-introduction/1-2-what-is-yul.html
index bfeba35..876f621 100644
--- a/book/book/1-introduction/1-2-what-is-yul.html
+++ b/book/book/1-introduction/1-2-what-is-yul.html
@@ -179,7 +179,7 @@
low-level language that gives developers a high degree of control over the execution of their smart contracts. It is
similar in many ways to Assembly but with higher-level features that make it easier to work with [2].
Yul was previously called Julia or Iulia.
-Within the context of smart contract development, Yul is usually referred to as Inline Assembly. As it is very
+
Within the context of smart contract development, Yul is usually referred to as Inline Assembly, as it is very
similar to Assembly and is written within functions in smart contract code.
diff --git a/book/book/1-introduction/1-3-why-is-yul-important.html b/book/book/1-introduction/1-3-why-is-yul-important.html
index 38d70e9..18464bc 100644
--- a/book/book/1-introduction/1-3-why-is-yul-important.html
+++ b/book/book/1-introduction/1-3-why-is-yul-important.html
@@ -175,9 +175,9 @@
-During smart contract development process, there are actions, or manipulations which are not feasible for the
+
During the smart contract development process, there are actions, or manipulations which are not feasible for the
programmer from the high-level Solidity code. Using Yul, the programmer is given much more fine-grained control over
-the storage, memory and in some cases calldata layout of the EVM. This control also allows for much more gas efficient code to be written.
+the storage, memory and in some cases calldata
layout of the EVM. This control also allows for much more gas efficient code to be written.
The flexibility and gas optimization of Yul are what makes it important.
diff --git a/book/book/1-introduction/1-4-yul's-advantages.html b/book/book/1-introduction/1-4-yul's-advantages.html
index 9cad2c2..3b5edb2 100644
--- a/book/book/1-introduction/1-4-yul's-advantages.html
+++ b/book/book/1-introduction/1-4-yul's-advantages.html
@@ -175,7 +175,7 @@
-As stated in the previous chapter, the ability to manipulate the storage, memory or calldata layout to the programmer's taste with an extra benefit of much more gas optimized code is Yul's major advantage over Solidity.
+As stated in the previous chapter, the ability to manipulate the storage, memory or calldata
layout to the programmer's taste with an extra benefit of much more gas optimized code is Yul's major advantage over high-level Solidity.
diff --git a/book/book/1-introduction/1-6-code-layout.html b/book/book/1-introduction/1-6-code-layout.html
index b28461c..509d42b 100644
--- a/book/book/1-introduction/1-6-code-layout.html
+++ b/book/book/1-introduction/1-6-code-layout.html
@@ -177,7 +177,7 @@
Every piece of Yul code written here can be rerun on Remix.
Remix is an online smart contract development suite. It also offers a way of observing the process of EVM layouts and storage. It will be used over the course of this book, and you can replicate whatever we have done here on the suite.
-It is also recommended that you keep evm.codes handy over your course of learning and practising Yul, and even after you've understood. It is a magnificent resource.
+It is also recommended that you keep evm.codes handy over your course of learning and practising Yul, and even after you've understood the language. It is a magnificent resource.
diff --git a/book/book/3-solidity's-storage-and-memory/3-2-solidity's-storage-and-memory-layout.html b/book/book/3-solidity's-storage-and-memory/3-2-solidity's-storage-and-memory-layout.html
index bbc727f..3a37d01 100644
--- a/book/book/3-solidity's-storage-and-memory/3-2-solidity's-storage-and-memory-layout.html
+++ b/book/book/3-solidity's-storage-and-memory/3-2-solidity's-storage-and-memory-layout.html
@@ -177,7 +177,7 @@
-
Solidity's storage layout has a finite amount of space, which is broken down into 32-byte groups called slots
, and each slot can hold a 256-bit value. These slots start from index 0 and can stretch to a theoretical index limit of somewhere around (2^256) - 1
. It is safe to say that the storage can never get full. Cool, isn't it?
+Solidity's storage layout has a finite amount of space, which is broken down into 32-byte groups called slots
, and each slot can hold a 256-bit value. These slots start from index 0 and can stretch to an index limit of (2^256) - 1
. It is safe to say that the storage can never get full. Cool, isn't it?
Values stored in storage slots are stored as bytes32
values, and sometimes, can be packed, as we will see later on in this book. To retrieve the value of a Solidity storage variable, the 32-byte value stored in the corresponding slot is retrieved. In some cases - when the value in the slot has been packed -, the value retrieved is worked on by methods of shifting or masking to retrieve the desired value.
💡 Remember when we said one should know how the EVM works before moving on with Yul? Yeah, that's one of the reasons why. You cannot retrieve what you do not know how it was stored.
@@ -185,7 +185,7 @@
Solidity's memory layout, unlike the storage layout is quite tricky. While the storage has a defined maximum slot
index of
-(2 **256) - 1
that can hold 32-byte values, the memory is a large group of 32-byte slots that their data can not
+(2^256) - 1
that can hold 32-byte values, the memory is a large group of 32-byte slots that their data can not
be retrieved by passing a slot index. But instead, data stored in the memory are retrieved by picking
a particular location and returning a specific number of bytes from that point in the memory.
"Why?", you may ask, it is because the default number of bytes returned from any point in memory is 32
and in
@@ -193,7 +193,7 @@
You can imagine memory slots as laid out end to end, in a way that data retrieval can be started from any point and
stopped at any point. Unlike storage that returns only the 32-bytes stored at an index, nothing more, nothing less.
If you do not understand that, do not
-sweat it. You will get a better grasp of it when we talk about variable storage in memory.
+sweat it. You will get a better grasp of it when we talk about variable storage in memory section.
These positions in memory start from 0x00
and are in groups of 32-bytes, meaning that the slots are in th is way:
0x00
- 0x1f
0x20
- 0x3f
@@ -216,9 +216,8 @@
storing in a memory location with existing data overwrites that location.
-💡 The positions we will use over the course of this book to access memory points will be written in hexadecimals
-(0x**
)
-as it's easier to read, since the EVM already deals in hexadecimals.
+💡 The positions and values in memory that we will use over the course of this book to access memory points will be written in hexadecimals
+(0x**
) as they are easier to read, since the EVM already deals in hexadecimals.
diff --git a/book/book/4-yul-implementations/4-1-starting-yul-in-a-solidity-contract.html b/book/book/4-yul-implementations/4-1-starting-yul-in-a-solidity-contract.html
index 85398fe..27c7ec1 100644
--- a/book/book/4-yul-implementations/4-1-starting-yul-in-a-solidity-contract.html
+++ b/book/book/4-yul-implementations/4-1-starting-yul-in-a-solidity-contract.html
@@ -223,7 +223,7 @@
-Solidity stores variables declared globally in storage. The storage is made up of slots, as we've discussed earlier. In this section we will look at how different data types are stored in Solidity's storage. Some are packed and some are greedy enough to take up a full slot without sharing.
+Solidity stores variables declared globally, otherwise known as state variables in storage. The storage is made up of slots, as we have discussed earlier. In this section we will look at how different data types are stored in Solidity's storage. Some are packed and some are greedy enough to take up a full slot without sharing.
You can head into the start of the section at uint8, uint128, uint256.
diff --git a/book/book/4-yul-implementations/4-2-variable-storage-in-storage/4-2-1-uint8-uint128-uint256.html b/book/book/4-yul-implementations/4-2-variable-storage-in-storage/4-2-1-uint8-uint128-uint256.html
index 0bdf9a4..11528a1 100644
--- a/book/book/4-yul-implementations/4-2-variable-storage-in-storage/4-2-1-uint8-uint128-uint256.html
+++ b/book/book/4-yul-implementations/4-2-variable-storage-in-storage/4-2-1-uint8-uint128-uint256.html
@@ -222,7 +222,7 @@