From ac799aff0e237fe0e6c4246e36c39cc1fe3c116d Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Thu, 11 Aug 2016 16:50:27 -0400 Subject: Remove trailing whitespaces --- docs/contracts.rst | 2 +- docs/installing-solidity.rst | 4 ++-- docs/security-considerations.rst | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/contracts.rst b/docs/contracts.rst index c369bfd9..b4a4b2cc 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -25,7 +25,7 @@ API, this is done as follows:: // Need to specify some source including contract name for the data param below var source = "contract CONTRACT_NAME { function CONTRACT_NAME(unit a, uint b) {} }"; - + // The json abi array generated by the compiler var abiArray = [ { diff --git a/docs/installing-solidity.rst b/docs/installing-solidity.rst index 16a02310..ba40c99f 100644 --- a/docs/installing-solidity.rst +++ b/docs/installing-solidity.rst @@ -73,7 +73,7 @@ to compile Solidity on Ubuntu 14.04 (Trusty Tahr). sudo apt-get -y install build-essential git cmake libgmp-dev libboost-all-dev \ libjsoncpp-dev - + sudo add-apt-repository -y ppa:ethereum/ethereum sudo add-apt-repository -y ppa:ethereum/ethereum-dev sudo apt-get -y update @@ -94,7 +94,7 @@ installed either by adding the Ethereum PPA (Option 1) or by backporting sudo apt-get -y install build-essential git cmake libgmp-dev libboost-all-dev \ libjsoncpp-dev - + # (Option 1) For those willing to add the Ethereum PPA: sudo add-apt-repository -y ppa:ethereum/ethereum sudo add-apt-repository -y ppa:ethereum/ethereum-dev diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index eff3c5e8..f8d099e4 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -147,7 +147,7 @@ Never use tx.origin for authorization. Let's say you have a wallet contract like :: - contract TxUserWallet { + contract TxUserWallet { address owner; function TxUserWallet() { @@ -164,7 +164,7 @@ Now someone tricks you into sending ether to the address of this attack wallet: :: - contract TxAttackWallet { + contract TxAttackWallet { address owner; function TxAttackWallet() { -- cgit From 02a72871d2200dd415fbb8c7488235495ff012c2 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Thu, 11 Aug 2016 16:50:53 -0400 Subject: Change capitalisation --- docs/layout-of-source-files.rst | 2 +- docs/miscellaneous.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index ae1e0d26..b3436576 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -61,7 +61,7 @@ It depends on the compiler (see below) how to actually resolve the paths. In general, the directory hierarchy does not need to strictly map onto your local filesystem, it can also map to resources discovered via e.g. ipfs, http or git. -Use in actual Compilers +Use in Actual Compilers ----------------------- When the compiler is invoked, it is not only possible to specify how to diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index 804d69ef..882a6002 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -66,7 +66,7 @@ Calling ``select(false, x)`` will compute ``x * x`` and ``select(true, x)`` will .. index:: optimizer, common subexpression elimination, constant propagation ************************* -Internals - the Optimizer +Internals - The Optimizer ************************* The Solidity optimizer operates on assembly, so it can be and also is used by other languages. It splits the sequence of instructions into basic blocks at JUMPs and JUMPDESTs. Inside these blocks, the instructions are analysed and every modification to the stack, to memory or storage is recorded as an expression which consists of an instruction and a list of arguments which are essentially pointers to other expressions. The main idea is now to find expressions that are always equal (on every input) and combine them into an expression class. The optimizer first tries to find each new expression in a list of already known expressions. If this does not work, the expression is simplified according to rules like ``constant + constant = sum_of_constants`` or ``X * 1 = X``. Since this is done recursively, we can also apply the latter rule if the second factor is a more complex expression where we know that it will always evaluate to one. Modifications to storage and memory locations have to erase knowledge about storage and memory locations which are not known to be different: If we first write to location x and then to location y and both are input variables, the second could overwrite the first, so we actually do not know what is stored at x after we wrote to y. On the other hand, if a simplification of the expression x - y evaluates to a non-zero constant, we know that we can keep our knowledge about what is stored at x. -- cgit From c58e460ba2aad998568168dd954a29e858d27ff2 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Thu, 11 Aug 2016 16:53:07 -0400 Subject: Change example code formatting --- docs/layout-of-source-files.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index b3436576..6ef06961 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -171,9 +171,9 @@ for the two input parameters and two returned values. * @return s The calculated surface. * @return p The calculated perimeter. */ - function rectangle(uint w, uint h) returns (uint s, uint p){ - s = w*h; - p = 2*(w+h); + function rectangle(uint w, uint h) returns (uint s, uint p) { + s = w * h; + p = 2 * (w + h); } } -- cgit From 72f27995565c25efde02826fdafa87a8ad907e78 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Fri, 12 Aug 2016 11:44:45 -0400 Subject: Fix typo --- docs/introduction-to-smart-contracts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index 0122387b..c0b596ee 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -300,7 +300,7 @@ If the target account is the zero-account (the account with the address ``0``), the transaction creates a **new contract**. As already mentioned, the address of that contract is not the zero address but an address derived from the sender and -its number of transaction sent (the "nonce"). The payload +its number of transactions sent (the "nonce"). The payload of such a contract creation transaction is taken to be EVM bytecode and executed. The output of this execution is permanently stored as the code of the contract. -- cgit From c65735fc1950a2938f7dffa1352d4bf837e11f5c Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Fri, 12 Aug 2016 11:47:48 -0400 Subject: Change XXX bit to XXX-bit --- docs/introduction-to-smart-contracts.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index c0b596ee..9fda9592 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -95,7 +95,7 @@ registering with username and password - all you need is an Ethereum keypair. This contract introduces some new concepts, let us go through them one by one. The line ``address public minter;`` declares a state variable of type address -that is publicly accessible. The ``address`` type is a 160 bit value +that is publicly accessible. The ``address`` type is a 160-bit value that does not allow any arithmetic operations. It is suitable for storing addresses of contracts or keypairs belonging to external persons. The keyword ``public`` automatically generates a function that @@ -220,7 +220,7 @@ only the person holding the keys to the account can transfer money from it. Blocks ====== -One major obstacle to overcome is what in bitcoin terms is called "double-spend attack": +One major obstacle to overcome is what in Bitcoin terms is called "double-spend attack": What happens if two transactions exist in the network that both want to empty an account, a so-called conflict? @@ -277,7 +277,7 @@ of transactions sent from that address, the so-called "nonce"). Apart from the fact whether an account stores code or not, the EVM treats the two types equally, though. -Every account has a persistent key-value store mapping 256 bit words to 256 bit +Every account has a persistent key-value store mapping 256-bit words to 256-bit words called **storage**. Furthermore, every account has a **balance** in @@ -332,7 +332,7 @@ Storage, Memory and the Stack ============================= Each account has a persistent memory area which is called **storage**. -Storage is a key-value store that maps 256 bit words to 256 bit words. +Storage is a key-value store that maps 256-bit words to 256-bit words. It is not possible to enumerate storage from within a contract and it is comparatively costly to read and even more so, to modify storage. A contract can neither read nor write to any storage apart @@ -340,7 +340,7 @@ from its own. The second memory area is called **memory**, of which a contract obtains a freshly cleared instance for each message call. Memory can be -addressed at byte level, but read and written to in 32 byte (256 bit) +addressed at byte level, but read and written to in 32 byte (256-bit) chunks. Memory is more costly the larger it grows (it scales quadratically). @@ -364,7 +364,7 @@ Instruction Set The instruction set of the EVM is kept minimal in order to avoid incorrect implementations which could cause consensus problems. -All instructions operate on the basic data type, 256 bit words. +All instructions operate on the basic data type, 256-bit words. The usual arithmetic, bit, logical and comparison operations are present. Conditional and unconditional jumps are possible. Furthermore, contracts can access relevant properties of the current block -- cgit From 4bd96d93824f15fbb8c6eafb5dd1a875b9705423 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Fri, 12 Aug 2016 11:48:47 -0400 Subject: Fix description about how blocks work --- docs/introduction-to-smart-contracts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index 9fda9592..65019e2b 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -236,7 +236,7 @@ Ethereum this is roughly every 17 seconds. As part of the "order selection mechanism" (which is called "mining") it may happen that blocks are reverted from time to time, but only at the "tip" of the chain. The more -blocks are reverted the less likely it is. So it might be that your transactions +blocks that are added on top, the less likely it is. So it might be that your transactions are reverted and even removed from the blockchain, but the longer you wait, the less likely it will be. -- cgit From 1655f3b7bf3b8594ed37c072e5fd6ab00d89d802 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Fri, 12 Aug 2016 16:29:17 -0400 Subject: Update contracts.rst --- docs/contracts.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/contracts.rst b/docs/contracts.rst index b4a4b2cc..911bfc0d 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -932,10 +932,11 @@ encoding of the address of the library contract. Restrictions for libraries in comparison to contracts: -- no state variables -- cannot inherit nor be inherited +- No state variables +- Cannot inherit nor be inherited +- Cannot recieve Ether -(these might be lifted at a later point) +(These might be lifted at a later point.) .. index:: ! using for, library -- cgit From 41ad2110c276ec78b403c0ee96a11a96407e0d1b Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Tue, 16 Aug 2016 13:48:54 -0400 Subject: Fix control-structures --- docs/control-structures.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 73b0131f..739620a2 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -520,14 +520,14 @@ The opcodes ``pushi`` and ``jumpdest`` cannot be used directly. | create(v, p, s) | | create new contract with code mem[p..(p+s)) and send v wei | | | | and return the new address | +-------------------------+------+-----------------------------------------------------------------+ -| call(g, a, v, in, | | call contract at address a with input mem[in..(in+insize)] | +| call(g, a, v, in, | | call contract at address a with input mem[in..(in+insize)) | | insize, out, outsize) | | providing g gas and v wei and output area | -| | | mem[out..(out+outsize)] returting 1 on error (out of gas) | +| | | mem[out..(out+outsize)) returning 1 on error (out of gas) | +-------------------------+------+-----------------------------------------------------------------+ -| callcode(g, a, v, in, | | identical to call but only use the code from a and stay | +| callcode(g, a, v, in, | | identical to `call` but only use the code from a and stay | | insize, out, outsize) | | in the context of the current contract otherwise | +-------------------------+------+-----------------------------------------------------------------+ -| delegatecall(g, a, in, | | identical to callcode but also keep ``caller`` | +| delegatecall(g, a, in, | | identical to `callcode` but also keep ``caller`` | | insize, out, outsize) | | and ``callvalue`` | +-------------------------+------+-----------------------------------------------------------------+ | return(p, s) | `*` | end execution, return data mem[p..(p+s)) | -- cgit From 89004edb2f4ad02fc06546d1c88f4c91b78388e5 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Tue, 16 Aug 2016 14:13:23 -0400 Subject: Add comma --- docs/introduction-to-smart-contracts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index 65019e2b..fbce4244 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -220,7 +220,7 @@ only the person holding the keys to the account can transfer money from it. Blocks ====== -One major obstacle to overcome is what in Bitcoin terms is called "double-spend attack": +One major obstacle to overcome is what, in Bitcoin terms, is called "double-spend attack": What happens if two transactions exist in the network that both want to empty an account, a so-called conflict? -- cgit From 2716d01f2cc8cb06f73d170c94d1c4c8fef172a9 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Wed, 17 Aug 2016 16:42:43 -0400 Subject: Rename "call data" to "calldata" --- docs/control-structures.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 739620a2..43a1a31e 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -503,9 +503,9 @@ The opcodes ``pushi`` and ``jumpdest`` cannot be used directly. +-------------------------+------+-----------------------------------------------------------------+ | callvalue | | wei sent together with the current call | +-------------------------+------+-----------------------------------------------------------------+ -| calldataload(p) | | call data starting from position p (32 bytes) | +| calldataload(p) | | calldata starting from position p (32 bytes) | +-------------------------+------+-----------------------------------------------------------------+ -| calldatasize | | size of call data in bytes | +| calldatasize | | size of calldata in bytes | +-------------------------+------+-----------------------------------------------------------------+ | calldatacopy(t, f, s) | `-` | copy s bytes from calldata at position f to mem at position t | +-------------------------+------+-----------------------------------------------------------------+ -- cgit From ef117c29021c31bc7f9c3e0b9797b72538591199 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Thu, 18 Aug 2016 13:03:41 -0400 Subject: Fix creating contracts section --- docs/control-structures.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 43a1a31e..b3940f72 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -127,11 +127,11 @@ Those names will still be present on the stack, but they are inaccessible. .. _creating-contracts: -Creating Contracts via new -========================== +Creating Contracts via ``new`` +============================== A contract can create a new contract using the ``new`` keyword. The full -code of the contract to be created has to be known and thus recursive +code of the contract being created has to be known and, thus, recursive creation-dependencies are now possible. :: @@ -142,6 +142,8 @@ creation-dependencies are now possible. x = a; } } + + contract C { D d = new D(4); // will be executed as part of C's constructor -- cgit