Skip to content

Commit

Permalink
Merge pull request #836 from multiversx/chain-simulator-docs
Browse files Browse the repository at this point in the history
Chain simulator docs
  • Loading branch information
miiu96 authored Feb 27, 2024
2 parents 8251f60 + 44f5222 commit b5ef49e
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/developers/tutorials/your-first-dapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ In the end, we'll have three subfolders: wallet, contract and dapp. For convenie

![img](/developers/tutorial/folder-structure.png)

[comment]: # (mx-context-auto)

### **Create the owner wallet**

The smart contract can only be deployed on the blockchain by an owner, so let's create an owner's wallet **PEM file**. The owner can also update the contract, later on, if needed. Keep in mind we only use PEM wallets for testing and playing around with non-production code. For real applications please follow best practices, use secure wallets that can be generated [here](https://wallet.multiversx.com).
Expand Down Expand Up @@ -205,7 +207,6 @@ Then edit this instruction, and change it to the contract address that was shown

![img](/developers/tutorial/config-screenshot.png)


[comment]: # (mx-context-auto)

### **Build the dApp**
Expand Down
41 changes: 41 additions & 0 deletions docs/sdk-and-tools/chain-simulator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
id: chain-simulator
title: Chain simulator
---

[comment]: # (mx-context-auto)

## Overview

Chain simulator is a piece of software that provides all the `mx-chain-proxy-go` endpoints and includes additional endpoints
for specific operations.

Instead of setting up a local testnet with a proxy and nodes, using chain simulator is a simpler option.
It mimics the behavior of a local testnet, making it easier to test smart contracts in a simulated environment.

The chain simulator offers faster testing since it eliminates the need for consensus, allowing blocks to be generated
in milliseconds rather than the typical 6-second intervals on a local testnet.

The chain simulator provides new endpoints that allow developers to replicate the state of a contract from the mainnet to the simulator.
This enables testing with the same state as on the mainnet, facilitating more accurate and realistic development scenarios.

[comment]: # (mx-context-auto)

## Architectural Overview

![img](/technology/chainsimulator.png)

This simulator is designed to replicate the behavior of a local testnet. Unlike a traditional testnet, this simulator
operates without a consensus group, allowing for isolated testing and development.


[comment]: # (mx-context-auto)

## Features

- Implements all `mx-chain-proxy-go` endpoints.
- Extra endpoints for specific operations.
- Simulates the behavior of a local testnet without a consensus group.

The GitHub repository for the chain simulator and more information
about how to use can be found [here](https://github.com/multiversx/mx-chain-simulator-go).
11 changes: 11 additions & 0 deletions docs/sdk-and-tools/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ Events notifier is an external service that can be used to fetch block events an

[comment]: # (mx-context-auto)

### Chain simulator

Chain simulator is designed to replicate the behavior of a local testnet.
It can also be pre-initialized / initialized with blockchain state from other networks, such as mainnet or something similar.

| Name | Description |
|---------------------------------------------------|------------------------------|
| [Chain simulator](/sdk-and-tools/chain-simulator) | A service for local testing. |

[comment]: # (mx-context-auto)

### Devcontainers (for VSCode or GitHub Codespaces)

| Name | Description |
Expand Down
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ const sidebars = {
],
},
"sdk-and-tools/notifier",
"sdk-and-tools/chain-simulator",
"sdk-and-tools/google-bigquery",
"sdk-and-tools/devcontainers",
{
Expand Down
58 changes: 58 additions & 0 deletions static/technology/chainsimulator.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<mxfile host="app.diagrams.net" modified="2024-02-27T10:39:15.564Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" etag="ph4Y5ugfU1mbP7bKnenz" version="23.1.7" type="device">
<diagram name="Page-1" id="XZ3qhjXyUbHVMeMBHV_s">
<mxGraphModel dx="1728" dy="983" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="EWHMPKfBnV-rQj-S9Va0-1" value="" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="30" y="30" width="265" height="300" as="geometry" />
</mxCell>
<mxCell id="EWHMPKfBnV-rQj-S9Va0-2" value="Chain Simulator" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;strokeWidth=1;fontSize=12;fontStyle=1" vertex="1" parent="1">
<mxGeometry x="115" y="20" width="95" height="40" as="geometry" />
</mxCell>
<mxCell id="EWHMPKfBnV-rQj-S9Va0-4" value="node&lt;br&gt;shard 0" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="55" y="60" width="70" height="60" as="geometry" />
</mxCell>
<mxCell id="EWHMPKfBnV-rQj-S9Va0-5" value="node&lt;br&gt;shard 1" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="55" y="130" width="70" height="60" as="geometry" />
</mxCell>
<mxCell id="EWHMPKfBnV-rQj-S9Va0-6" value="node&amp;nbsp;&lt;br&gt;shard meta" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="55" y="250" width="70" height="60" as="geometry" />
</mxCell>
<mxCell id="EWHMPKfBnV-rQj-S9Va0-12" value="" style="endArrow=none;dashed=1;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="145" y="60" as="sourcePoint" />
<mxPoint x="145" y="320" as="targetPoint" />
<Array as="points">
<mxPoint x="145" y="60" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="EWHMPKfBnV-rQj-S9Va0-13" value="proxy endpoints" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="182.5" y="80" width="72.5" height="120" as="geometry" />
</mxCell>
<mxCell id="EWHMPKfBnV-rQj-S9Va0-14" value="new&amp;nbsp;&lt;br&gt;endpoints" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="182.5" y="230" width="72.5" height="50" as="geometry" />
</mxCell>
<mxCell id="EWHMPKfBnV-rQj-S9Va0-15" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="89.57999999999998" y="240" as="sourcePoint" />
<mxPoint x="89.57999999999998" y="210" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="EWHMPKfBnV-rQj-S9Va0-16" value="User" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="395" y="150" width="30" height="60" as="geometry" />
</mxCell>
<mxCell id="EWHMPKfBnV-rQj-S9Va0-19" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="310" y="179.57999999999998" as="sourcePoint" />
<mxPoint x="380" y="179.57999999999998" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="EWHMPKfBnV-rQj-S9Va0-20" value="REST APIS" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="306" y="150" width="80" height="30" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Binary file added static/technology/chainsimulator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions static/technology/indexer.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<mxfile host="app.diagrams.net" modified="2024-02-27T10:43:34.521Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" etag="aEpt2a9mltiY280u4Ev0" version="23.1.7" type="device">
<diagram name="Page-1" id="2CUQH800xFhHVJmL9mho">
<mxGraphModel dx="2074" dy="1180" grid="1" gridSize="20" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" background="none" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-30" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="6Ij9C6XUDUhVDzcWqF8C-1" target="6Ij9C6XUDUhVDzcWqF8C-29" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="285" y="200" as="targetPoint" />
<Array as="points">
<mxPoint x="285" y="110" />
<mxPoint x="285" y="200" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-1" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fillColor=#5EFFEF;" parent="1" vertex="1">
<mxGeometry x="175" y="80" width="60" height="60" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-31" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="6Ij9C6XUDUhVDzcWqF8C-6" target="6Ij9C6XUDUhVDzcWqF8C-29" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-6" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fillColor=#5EFFEF;" parent="1" vertex="1">
<mxGeometry x="175" y="170" width="60" height="60" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-32" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="6Ij9C6XUDUhVDzcWqF8C-7" target="6Ij9C6XUDUhVDzcWqF8C-29" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="285" y="200" as="targetPoint" />
<Array as="points">
<mxPoint x="285" y="340" />
<mxPoint x="285" y="200" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-7" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fillColor=#5EFFEF;" parent="1" vertex="1">
<mxGeometry x="175" y="310" width="60" height="60" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-13" value="Shard 0" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="105" y="95" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-14" value="Shard 1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="105" y="185" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-15" value="Metachain" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="105" y="325" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-16" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" parent="1" vertex="1">
<mxGeometry x="195" y="240" width="20" height="20" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-17" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" parent="1" vertex="1">
<mxGeometry x="195" y="260" width="20" height="20" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-18" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=none;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;" parent="1" vertex="1">
<mxGeometry x="195" y="280" width="20" height="20" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-23" value="" style="endArrow=none;dashed=1;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="375" y="370" as="sourcePoint" />
<mxPoint x="375" y="40" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-24" value="Observer Nodes" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;" parent="1" vertex="1">
<mxGeometry x="155" y="30" width="100" height="30" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-25" value="Elastic indexer service" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;" parent="1" vertex="1">
<mxGeometry x="415" y="30" width="130" height="30" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-27" value="" style="endArrow=none;dashed=1;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="575" y="370" as="sourcePoint" />
<mxPoint x="575" y="40" as="targetPoint" />
<Array as="points">
<mxPoint x="575" y="190" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-36" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.017;entryY=0.465;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" source="6Ij9C6XUDUhVDzcWqF8C-29" target="6Ij9C6XUDUhVDzcWqF8C-35" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-29" value="Elasticindexer instance" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#CCE5FF;" parent="1" vertex="1">
<mxGeometry x="420" y="170" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-33" value="WebSocket messages" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="305" y="170" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-34" value="Elasticsearch&lt;br&gt;cluster" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;" parent="1" vertex="1">
<mxGeometry x="620" y="30" width="130" height="30" as="geometry" />
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-37" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="6Ij9C6XUDUhVDzcWqF8C-35" target="6Ij9C6XUDUhVDzcWqF8C-29" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="615" y="200" />
<mxPoint x="615" y="200" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="6Ij9C6XUDUhVDzcWqF8C-35" value="Elasticsearch&amp;nbsp;&lt;br&gt;cluster" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#D5E8D4;" parent="1" vertex="1">
<mxGeometry x="625" y="120" width="120" height="170" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

0 comments on commit b5ef49e

Please sign in to comment.