Added Reference to Wiki from Docker quickstart (#158)

MadelineMurray 6 years ago committed by Adrian Sutton
parent 3881f19335
commit 6c7a256b0b
  1. 202
      docs/DocsArchive0.8.0.html

@ -887,207 +887,7 @@ KeyPairUtil | Generated new key <key> and stored it to ~/pantheon/build/di
<p>After you&#39;re finished running the demo, you can stop the Pantheon client by returning to the terminal window that runs the node and entering <code>Ctrl+c</code>.</p> <p>After you&#39;re finished running the demo, you can stop the Pantheon client by returning to the terminal window that runs the node and entering <code>Ctrl+c</code>.</p>
<p class="page" id="Docker-Quickstart"></p><h1>Docker Quickstart</h1> <p class="page" id="Docker-Quickstart"></p><h1>Docker Quickstart</h1>
<h1 id="docker-quickstart-tutorial">Docker Quickstart Tutorial</h1> <h1 id="docker-quickstart-tutorial">Docker Quickstart Tutorial</h1>
<p>This tutorial describes how to use Pantheon to run a private network of Pantheon nodes in a Docker container.</p> <p>Refer to the <a href="https://github.com/PegaSysEng/pantheon/wiki/Docker-Quickstart">Pantheon Wiki</a> for the Docker Quickstart Tutorial. </p>
<blockquote>
<p><strong>Note</strong> To run the Docker Quickstart, you must install Pantheon by <a href="https://github.com/PegaSysEng/pantheon/wiki/Installation">cloning and building</a>. </p>
<p>If you have installed Pantheon from the <a href="https://pegasys.tech/">packaged binaries</a> or are running the <a href="https://hub.docker.com/u/pegasyseng/">Docker image</a>, continue with <a href="#Quickstart">Basic Quickstart</a> or <a href="#Starting-Pantheon">Starting Pantheon</a>.</p>
</blockquote>
<h2 id="prerequisites">Prerequisites</h2>
<p>To run this tutorial, you must have the following installed:</p>
<ul>
<li><p>Linux or Mac OS</p>
</li>
<li><p><a href="https://docs.docker.com/compose/install/">Docker and Docker-compose</a> </p>
</li>
<li><p><a href="https://git-scm.com/">Git command line</a></p>
</li>
<li><p><a href="https://curl.haxx.se/download.html">Curl command line</a> </p>
</li>
<li><p>A web browser that supports <a href="https://metamask.io/">Metamask</a> (currently Chrome, Firefox, Opera, and Brave), and has the MetaMask plug-in installed. This tutorial uses screenshots from Brave.</p>
</li>
</ul>
<h2 id="clone-pantheon-source-code">Clone Pantheon Source Code</h2>
<p>As indicated in <a href="#Installationclone-the-pantheon-repository">the installation section</a>,
clone the repository.</p>
<h2 id="build-docker-images-and-start-services-and-network">Build Docker Images and Start Services and Network</h2>
<p>This tutorial uses <a href="https://docs.docker.com/compose/">Docker Compose</a> to simplify assembling images and
running in a private network. To run the containers, go to the <code>pantheon</code> directory and run the following shell command:</p>
<pre class="hljs">quickstart/runPantheonPrivateNetwork.sh</pre><p>This script builds Pantheon, builds the images and runs the containers. It will also scale the regular node container to four containers to simulate a network with enough peers to synchronize.</p>
<p>When the <code>quickstart/runPantheonPrivateNetwork.sh</code> script ends, it lists the running services:</p>
<pre class="hljs"> Name Command State Ports
-----------------------------------------------------------------------------------------------------------------------
quickstart_bootnode_1 /opt/pantheon/bootnode_sta ... Up <span class="hljs-number">30303</span>/tcp, <span class="hljs-number">30303</span>/udp, <span class="hljs-number">8084</span>/tcp, <span class="hljs-number">8545</span>/tcp
quickstart_explorer_1 /bin/sh -c npm start Up <span class="hljs-number">0.0</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>:<span class="hljs-number">32770</span>-&gt;<span class="hljs-number">3000</span>/tcp
quickstart_minernode_1 /opt/pantheon/node_start.s ... Up <span class="hljs-number">30303</span>/tcp, <span class="hljs-number">30303</span>/udp, <span class="hljs-number">8084</span>/tcp, <span class="hljs-number">8545</span>/tcp
quickstart_node_1 /opt/pantheon/node_start.s ... Up <span class="hljs-number">30303</span>/tcp, <span class="hljs-number">30303</span>/udp, <span class="hljs-number">8084</span>/tcp, <span class="hljs-number">8545</span>/tcp
quickstart_node_2 /opt/pantheon/node_start.s ... Up <span class="hljs-number">30303</span>/tcp, <span class="hljs-number">30303</span>/udp, <span class="hljs-number">8084</span>/tcp, <span class="hljs-number">8545</span>/tcp
quickstart_node_3 /opt/pantheon/node_start.s ... Up <span class="hljs-number">30303</span>/tcp, <span class="hljs-number">30303</span>/udp, <span class="hljs-number">8084</span>/tcp, <span class="hljs-number">8545</span>/tcp
quickstart_node_4 /opt/pantheon/node_start.s ... Up <span class="hljs-number">30303</span>/tcp, <span class="hljs-number">30303</span>/udp, <span class="hljs-number">8084</span>/tcp, <span class="hljs-number">8545</span>/tcp
quickstart_rpcnode_1 /opt/pantheon/node_start.s ... Up <span class="hljs-number">30303</span>/tcp, <span class="hljs-number">30303</span>/udp, <span class="hljs-number">8084</span>/tcp,
<span class="hljs-number">0.0</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>:<span class="hljs-number">32769</span>-&gt;<span class="hljs-number">8545</span>/tcp, <span class="hljs-number">0.0</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>:<span class="hljs-number">32768</span>-&gt;<span class="hljs-number">8546</span>/tcp</pre><p>And a friendly recap of the entrypoints :</p>
<pre class="hljs"><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-emphasis">***</span>*
JSON-RPC HTTP service endpoint : http://localhost:32769 *
JSON-RPC WebSocket service endpoint : http://localhost:32768 *
Web block explorer address : http://localhost:32770 *
<span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-strong">*****</span><span class="hljs-emphasis">***</span>*</pre><ul>
<li>Use the <strong>JSON-RPC HTTP service endpoint</strong> to access the RPC node service from your Dapp or from cryptocurrency wallets such as Metamask.</li>
<li>Use the <strong>JSON-RPC WebSocket service endpoint</strong> to access the web socket node service from your Dapp.</li>
<li>Use the <strong>Web block explorer address</strong> to display the block explorer web application. You can invoke the block explorer by clicking on the endpoint link or by entering the URL in your web browser.</li>
</ul>
<p>To display this list at any time, run:</p>
<pre class="hljs">quickstart/listQuickstartServices.sh</pre><h2 id="block-explorer">Block Explorer</h2>
<p>This tutorial uses a block explorer based on <a href="https://github.com/mix-blockchain/block-explorer.git">the MIX project explorer</a>.</p>
<blockquote>
<p><strong>Note:</strong> As Yarn is an Apache 2.0 licensed tool, it has been patched to fit this tutorial&#39;s needs. (You can view the patches in the quickstart/explorer folder.)</p>
</blockquote>
<h3 id="using-the-block-explorer-with-metamask">Using the Block Explorer with MetaMask</h3>
<p>Log in to MetaMask if you don&#39;t already have it running. The block explorer displays the network to which MetaMask is connected. If you see a <strong>Peer Count</strong> of 100 in the block explorer, it&#39;s likely MetaMask is connected to mainnet or one of the testnets such as Ropsten.</p>
<p>To display the private network in the block explorer, you have to configure a custom RPC network.</p>
<p>After you sign in to MetaMask, connect to the private network RPC endpoint by:</p>
<ol>
<li>In the MetaMask network list, select <strong>Custom RPC</strong>.</li>
<li>In the <strong>New RPC URL</strong> field, enter the <code>JSON-RPC HTTP service endpoint</code> displayed when you started the private network.</li>
</ol>
<p>Save the configuration and return to the MetaMask main screen. Your current network is now set to the private network RPC node.</p>
<h3 id="using-the-block-explorer-without-metamask">Using the Block Explorer without MetaMask</h3>
<p>If you don&#39;t have Metamask running, the block explorer works directly without configuration. The block explorer integrates its own web3 version and knows the RPC node endpoint.</p>
<h3 id="run-the-block-explorer">Run the Block Explorer</h3>
<p>Access the explorer using the <code>Web block explorer address</code> displayed when starting the private network.</p>
<p><img src="https://raw.githubusercontent.com/wiki/PegaSysEng/pantheon/explorer_screenshot.png?token=ApWTImDXVwGvabPJmntnI3F_deENUeguks5b0l1_wA%3D%3D" /></p>
<p>You will see the already mined blocks on the right, and some stats about the RPC node we are connected to on the left.</p>
<p>Notice the explorer indicates 6 peers: the 4 regular nodes, the mining node and the bootnode.</p>
<p>Now lets play with some requests.</p>
<h2 id="run-curl-json-rpc-requests">Run cURL JSON-RPC requests</h2>
<p>You can run RPC requests on <code>rpcnode</code>, the node that is exposed to the host in order to listen for requests.</p>
<p>In this tutorial, note that the <code>http://localhost:http-rpc-port</code> placeholder is <code>http://localhost: 32769</code>.</p>
<blockquote>
<p><strong>Note:</strong> Make sure to replace <code>port</code> with the one provided in the <code>quickstart/listQuickstartServices.sh</code> command <code>JSON-RPC HTTP service endpoint</code>.
The dynamic docker port mapping changes each time you run the network.</p>
</blockquote>
<h3 id="requesting-the-node-version">Requesting the Node Version</h3>
<p>Run the following command from the host shell :</p>
<pre class="hljs">curl -X POST --data <span class="hljs-string">'{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}'</span> http://localhost:http-rpc-port</pre><p>The result should be as follows: </p>
<pre class="hljs">{
<span class="hljs-attr">"jsonrpc"</span> : <span class="hljs-string">"2.0"</span>,
<span class="hljs-attr">"id"</span> : <span class="hljs-number">1</span>,
<span class="hljs-attr">"result"</span> : <span class="hljs-string">"pantheon/0.8.0-SNAPSHOT"</span>
}</pre><p>Here we simply query the version of the Pantheon node, which confirms the node is running.</p>
<p>Now if this works, let&#39;s see some more interesting requests.</p>
<h3 id="counting-peers">Counting Peers</h3>
<p>Peers are the number of other nodes connected to the RPC node.</p>
<p>Poll the peer count using <code>net_peerCount</code>:</p>
<pre class="hljs">curl -X POST --data <span class="hljs-string">'{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}'</span> http://localhost:http-rpc-port</pre><p>The result should be the following response, indicating that there are 6 peers:</p>
<pre class="hljs">{
<span class="hljs-attr">"jsonrpc"</span> : <span class="hljs-string">"2.0"</span>,
<span class="hljs-attr">"id"</span> : <span class="hljs-number">1</span>,
<span class="hljs-attr">"result"</span> : <span class="hljs-string">"0x6"</span>
}</pre><h3 id="requesting-the-most-recent-mined-block-number">Requesting the Most Recent Mined Block Number</h3>
<p>This provides the count of blocks already mined.</p>
<p>To do so, call <code>eth_blockNumber</code> to retrieve the number of the most recent block:</p>
<pre class="hljs">curl -X POST --data <span class="hljs-string">'{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'</span> http://localhost:http-rpc-port</pre><p>The result of this call should be:</p>
<pre class="hljs">{
<span class="hljs-attr">"jsonrpc"</span> : <span class="hljs-string">"2.0"</span>,
<span class="hljs-attr">"id"</span> : <span class="hljs-number">1</span>,
<span class="hljs-attr">"result"</span> : <span class="hljs-string">"0x8b8"</span>
}</pre><p>Here the hexadecimal value <code>0x8b8</code> translates to <code>2232</code> in decimal; that many blocks have already been mined.</p>
<h3 id="checking-the-miner-account-balance-coinbase-">Checking the Miner Account Balance (Coinbase)</h3>
<p>Then call <code>eth_getBalance</code> to retrieve the balance of the mining address defined in the miner node:</p>
<pre class="hljs">curl -X POST --data <span class="hljs-string">'{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","latest"],"id":1}'</span> http://localhost:http-rpc-port</pre><p>The result of this call should be something like :</p>
<pre class="hljs">{
<span class="hljs-attr">"jsonrpc"</span> : <span class="hljs-string">"2.0"</span>,
<span class="hljs-attr">"id"</span> : <span class="hljs-number">1</span>,
<span class="hljs-attr">"result"</span> : <span class="hljs-string">"0x79f905c6fd34e80000"</span>
}</pre><p><em>0x79f905c6fd34e80000 = 2250000000000000000000 Wei (2250 Ether)</em> (you can use a unit <a href="https://etherconverter.online/">converter</a> )</p>
<p>Wait a few seconds until new blocks are mined and make this call again. The balance should increase,
meaning that the miner address successfully received the mining reward.</p>
<p><em>Also you can see this information in the block explorer. It does exactly the same thing as we
did manually, connecting to the rpc node using http JSON-RPC, but displays information on a web page.</em></p>
<h3 id="additional-requests">Additional Requests</h3>
<p>Now that you are familiar with basic RPC requests you can run JSON-RPC commands to send transactions.
In order to send transactions, you will first need to create an account or use one of the 3 accounts
created during the genesis of this test network.</p>
<h4 id="account-1">Account 1</h4>
<p>This is the mining node codebase account:</p>
<ul>
<li>Address: 0xfe3b557e8fb62b89f4916b721be55ceb828dbd73</li>
<li>Private key : 0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63</li>
<li><p>Initial balance : 0xad78ebc5ac6200000 (200000000000000000000 in decimal) </p>
<h4 id="account-2">Account 2</h4>
</li>
<li><p>Address: 0x627306090abaB3A6e1400e9345bC60c78a8BEf57</p>
</li>
<li>Private key : 0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3</li>
<li><p>Initial balance : 0x90000000000000000000000 (2785365088392105618523029504 in decimal)</p>
<h4 id="account-3">Account 3</h4>
</li>
<li><p>Address: 0xf17f52151EbEF6C7334FAD080c5704D77216b732</p>
</li>
<li>Private key : 0xae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f</li>
<li>Initial balance : 0x90000000000000000000000 (2785365088392105618523029504 in decimal)</li>
</ul>
<blockquote>
<p><strong>Note:</strong> Pantheon does not provide an accounts management system, so if you want to create your own account, you will have to use a third party tool like Metamask.</p>
</blockquote>
<h3 id="creating-a-transaction-using-metamask">Creating a Transaction Using MetaMask</h3>
<p>Once you have <a href="#configure-a-custom-rpc-network-in-metamask">Configured a custom RPC network</a>, <a href="https://consensys.zendesk.com/hc/en-us/articles/360004176551-Importing-an-Account-New-UI-">import one of the existing accounts above into
metamask</a>
using the corresponding private key. </p>
<p><strong>NOTE that here we don&#39;t really care about securing the keys as it&#39;s just a tutorial, but be sure
to secure your accounts when you run into a real usecase. This will be discussed in a more advanced
chapter.</strong></p>
<p>Once this is done, try to <a href="https://consensys.zendesk.com/hc/en-us/articles/360004774951-Creating-Additional-MetaMask-Wallets-New-UI-">create another account from scratch</a>
to send some ether to.</p>
<p><em>Of course remember that here we are dealing with valueless ether as we are not
on the main network but on a local private network.</em></p>
<p><a href="https://consensys.zendesk.com/hc/en-us/articles/360005055472-Sending-Ether-New-UI-">Send some ether</a>
from the first account (containing some ether) to the new one (that have a zero balance)
and go to the explorer to check that your transaction is validated.</p>
<p>You should see a block in the list with one transaction, and you can look at the detail of the block
and of the transactions.</p>
<p><img src="https://raw.githubusercontent.com/wiki/PegaSysEng/pantheon/explorer_confirmed_tx_screenshot.png?token=ApWTIom75kWS_llh5vhaAErX6k5Xm0NPks5b0l23wA%3D%3D" /></p>
<h3 id="playing-with-the-truffle-pet-shop-tutorial">Playing with the Truffle Pet Shop Tutorial</h3>
<p>This step is inspired by <a href="https://truffleframework.com/tutorials/pet-shop">the PetShop tutorial on Truffle website</a>.</p>
<p>Use the following instructions to run it with the quick-start Pantheon Docker network and a wallet to manage keys.</p>
<h4 id="prerequisites">Prerequisites</h4>
<ul>
<li>Install Truffle :</li>
</ul>
<pre class="hljs">npm install -g truffle</pre><ul>
<li>Grab the tutorial <a href="https://truffleframework.com/tutorials/pet-shop#creating-a-truffle-project-using-a-truffle-box">as indicated in the Truffle site</a>:</li>
</ul>
<pre class="hljs">mkdir pet-shop-tutorial
<span class="hljs-built_in">cd</span> pet-shop-tutorial
truffle unbox pet-shop</pre><ul>
<li>Install the <a href="https://www.npmjs.com/package/truffle-privatekey-provider">Wallet</a> by running the following command:</li>
</ul>
<pre class="hljs">npm install truffle-privatekey-provider</pre><h4 id="modify-the-pet-shop-example">Modify the Pet Shop Example</h4>
<p>We are going to modify the <code>truffle.js</code> file to add our wallet provider.
So modify the file to look like the following :</p>
<pre class="hljs"><span class="hljs-keyword">const</span> PrivateKeyProvider = <span class="hljs-built_in">require</span>(<span class="hljs-string">"truffle-privatekey-provider"</span>);
<span class="hljs-keyword">const</span> privateKey = <span class="hljs-string">"8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63"</span>;
<span class="hljs-keyword">const</span> privateKeyProvider = <span class="hljs-keyword">new</span> PrivateKeyProvider(privateKey, <span class="hljs-string">"[YOUR HTTP RPC NODE ENDPOINT]"</span>);
<span class="hljs-built_in">module</span>.exports = {
<span class="hljs-comment">// See &lt;http://truffleframework.com/docs/advanced/configuration&gt;</span>
<span class="hljs-comment">// for more about customizing your Truffle configuration!</span>
networks: {
<span class="hljs-attr">development</span>: {
<span class="hljs-attr">host</span>: <span class="hljs-string">"127.0.0.1"</span>,
<span class="hljs-attr">port</span>: <span class="hljs-number">7545</span>,
<span class="hljs-attr">network_id</span>: <span class="hljs-string">"*"</span> <span class="hljs-comment">// Match any network id</span>
},
<span class="hljs-attr">quickstartWallet</span>: {
<span class="hljs-attr">provider</span>: privateKeyProvider,
<span class="hljs-attr">network_id</span>: <span class="hljs-string">"*"</span>
},
}
};</pre><p>Then replace the <code>[YOUR HTTP RPC NODE ENDPOINT]</code> placeholder with your HTTP RPC node endpoint. <code>http://localhost:32769</code> in this case.</p>
<p>The private address indicated in the file is the miner address so we know we will have funds in it. You don&#39;t need to change it.</p>
<p>Once this is done, you can go through the regular tutorial steps.</p>
<p>When you have to run a truffle command, you only have to indicate the right network to use, as in the following command using the <code>--network quickstartWallet</code> option :</p>
<pre class="hljs">truffle migrate --network quickstartWallet</pre><p>Your are then able to see the transactions and contracts deployed on your local docker network if you have a look in the block explorer.</p>
<h2 id="shut-down-the-network-and-remove-the-nodes">Shut Down the Network and Remove the Nodes</h2>
<p>To shut down the network, you can use the script <code>quickstart/removePantheonPrivateNetwork.sh</code>; this will stop and destroy all containers.</p>
<p class="page" id="Starting-Pantheon"></p><h1>Starting Pantheon</h1> <p class="page" id="Starting-Pantheon"></p><h1>Starting Pantheon</h1>
<h1 id="starting-pantheon">Starting Pantheon</h1> <h1 id="starting-pantheon">Starting Pantheon</h1>
<p>Pantheon nodes can be used for varying purposes as described in the <a href="#Overview">Overview</a>. Nodes can connect to the Ethereum mainnet, public testnets such as Ropsten, or private networks.</p> <p>Pantheon nodes can be used for varying purposes as described in the <a href="#Overview">Overview</a>. Nodes can connect to the Ethereum mainnet, public testnets such as Ropsten, or private networks.</p>

Loading…
Cancel
Save