Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating main to get tutorial updates out #336

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions docs/developing/information.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Getting information about the blockchain
authors: Tim McMackin
last_update:
date: 8 February 2024
---

Developers and dApps can get information about the Tezos blockchain, such as account balances, from these sources:

## The Octez client

The [The Octez client](./octez-client) provides information about accounts, addresses, and many other things.
For example, you can get the balance of an account with this command:

```bash
octez-client get balance for tz1QCVQinE8iVj1H2fckqx6oiM85CNJSK9Sx
```

## The RPC protocol

The [RPC](../architecture/rpc) protocol provides information about the blockchain that nodes use to communicate with each other.
This data is not always in the format that developers and dApps need.
For example, the RPC interface does not provide a way to get information about a specific operation by its hash.

You can get some information about accounts, contracts, and other things from RPC requests.
For example, this RPC request gets the current balance of an account:

```bash
curl -X GET https://rpc.ghostnet.teztnets.com/chains/main/blocks/head/context/contracts/tz1QCVQinE8iVj1H2fckqx6oiM85CNJSK9Sx/balance
```

## Indexers

Indexers are off-chain applications that retrieve blockchain data, process it, and store it in a way that makes it easier to search and use.
For example, you can use the [TZKT API](https://api.tzkt.io/) to get the recent operations an account made with this request:

```bash
curl -X GET https://api.ghostnet.tzkt.io/v1/accounts/tz1QCVQinE8iVj1H2fckqx6oiM85CNJSK9Sx/operations
```

For more information, see [Indexers](./information/indexers).

## Block explorers

Block explorers use data from indexers to show information in a human-friendly interface.
For example, this link shows information about a contract, including its current storage, entrypoints, and transaction history: https://better-call.dev/ghostnet/KT1R4i4qEaxF7v3zg1M8nTeyrqk8JFmdGLuu/operations

For more information about block explorers, see [Block explorers](./information/block-explorers).
4 changes: 2 additions & 2 deletions docs/developing/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ The following SmartPy test code snippet is for a Tezos smart contract that acts
```bash
if "templates" not in __name__:

@sp.add_test(name="Calculator")
@sp.add_test()
def test():
c1 = main.Calculator()
scenario = sp.test_scenario(main)
scenario = sp.test_scenario("Calculator")
scenario.h1("Calculator")
scenario += c1
c1.multiply(x=2, y=5)
Expand Down
4 changes: 2 additions & 2 deletions docs/smart-contracts/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def main():

if "templates" not in __name__:

@sp.add_test(name="Events")
@sp.add_test()
def test():
c1 = main.Events(12)
scenario = sp.test_scenario(main)
scenario = sp.test_scenario("Events", main)
scenario.h1("Add")
scenario += c1
c1.add(2).run(
Expand Down
29 changes: 9 additions & 20 deletions docs/smart-contracts/languages/smartpy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@ sp.verify(self.data.x > 2)

Here, `sp.verify()` checks that the field `x` is larger than `2` and raises an error if it is not. This is performed at run time, i.e., in the blockchain, once translated into Michelson.

Since Python does not allow its control statements to be overloaded, certain language constructs are desugared by a pre-processor: `sp.if`, `sp.else`, `sp.for`, `sp.while` are SmartPy commands.

For example, we will use:

```python
sp.if self.data.x > 2:
self.data.x += 1
```

If we would have used the `if` native to Python it would not be interpreted and compiled in Michelson.

## About the raffle contract
A raffle is a game of chance that distributes a winning prize.

Expand Down Expand Up @@ -108,10 +97,10 @@ class Raffle(sp.Contract):
def open_raffle(self):
pass

@sp.add_test(name = "Raffle")
@sp.add_test()
def test():
r = Raffle()
scenario = sp.test_scenario()
scenario = sp.test_scenario("Raffle")
scenario.h1("Raffle")
scenario += r
```
Expand Down Expand Up @@ -199,7 +188,7 @@ class Raffle(sp.Contract):
alice = sp.test_account("Alice")
admin = sp.test_account("Administrator")
r = Raffle(admin.address)
scenario = sp.test_scenario()
scenario = sp.test_scenario("Raffle")
scenario.h1("Raffle")
scenario += r

Expand Down Expand Up @@ -346,12 +335,12 @@ On _SmartPy_, a test is a method of the contract class, preceded by `@sp.add_tes
Inside this method, you need to instantiate your contract class and your scenarios, to which you will add the contract instance and all the related calls that you want to test. For instance:

```python
@sp.add_test(name="Raffle")
@sp.add_test()
def test():
alice = sp.test_account("Alice")
admin = sp.test_account("Administrator")
r = Raffle(admin.address)
scenario = sp.test_scenario()
scenario = sp.test_scenario("Raffle")
scenario.h1("Raffle")
scenario += r
```
Expand Down Expand Up @@ -560,14 +549,14 @@ class Raffle(sp.Contract):
self.data.sold_tickets[ticket_id] = current_player


@sp.add_test(name="Raffle")
@sp.add_test()
def test():
alice = sp.test_account("Alice")
jack = sp.test_account("Jack")
admin = sp.test_account("Administrator")

r = Raffle(admin.address)
scenario = sp.test_scenario()
scenario = sp.test_scenario("Raffle")
scenario.h1("Raffle")
scenario += r

Expand Down Expand Up @@ -774,13 +763,13 @@ class Raffle(sp.Contract):
self.data.sold_tickets = sp.map()
self.data.raffle_is_open = False

@sp.add_test(name="Raffle")
@sp.add_test()
def test():
alice = sp.test_account("Alice")
jack = sp.test_account("Jack")
admin = sp.test_account("Administrator")
r = Raffle(admin.address)
scenario = sp.test_scenario()
scenario = sp.test_scenario("Raffle")
scenario.h1("Raffle")
scenario += r

Expand Down
15 changes: 11 additions & 4 deletions docs/tutorials/build-files-archive-with-dal/get-dal-params.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Part 2: Getting the DAL parameters"
authors: 'Tezos Core Developers'
last_update:
date: 9 February 2024
date: 14 February 2024
---

The Data Availability Layer stores information about the available data in layer 1 blocks.
Expand Down Expand Up @@ -55,6 +55,8 @@ To get the DAL parameters, you can use built-in functions in the Tezos [Rust SDK
As a reminder, the kernel of a Smart Rollup is a WASM program.
The `proto-alpha` feature is necessary to get access to the functions specific to the DAL because they are not yet released in the main version of the Smart Rollup toolkit.

If you need a text editor inside the Docker container, you can run `sudo apk add nano` to install the [Nano text editor](https://www.nano-editor.org/).

1. Create a file named `src/lib.rs` to be the kernel.

1. In the `src/lib.rs` file, add this code:
Expand Down Expand Up @@ -117,7 +119,11 @@ Follow these steps to deploy the Smart Rollup to Weeklynet and start a node:

For simplicity, this command runs the Smart Rollup in observer mode, which does not require a stake of 10,000 tez to publish commitments.

1. Open a new terminal window and run this command to watch the node's log:
1. Open a new terminal window in the same environment.
If you are using a Docker container, you can enter the container with the `docker exec` command, as in `docker exec -it my-image /bin/sh`.
To get the name of the Docker container, you run the `docker ps` command.

1. Run this command to watch the node's log:

```bash
tail -F _rollup_node/kernel.log
Expand Down Expand Up @@ -178,7 +184,8 @@ Then you can run it any tme you update the `lib.rs` or `Cargo.toml` files to dep
```

If you run this script and see an error that says that the file was not found, update the first line of the script (the shebang) to the path to your shell interpreter.
For example, if you are using the Tezos Docker image, the path is `/bin/sh`.
For example, if you are using the Tezos Docker image, the path is `/bin/sh`, so the first line becomes `#!/bin/sh`.
Then try the command `./deploy_smart_rollup.sh $MY_ACCOUNT` again.

In the next section, you will get information about the state of slots in the DAL.
See [Part 2: Getting slot information](./get-slot-info).
See [Part 3: Getting slot information](./get-slot-info).
12 changes: 10 additions & 2 deletions docs/tutorials/build-files-archive-with-dal/get-slot-info.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Part 2: Getting slot information"
title: "Part 3: Getting slot information"
authors: 'Tezos Core Developers'
last_update:
date: 7 February 2024
date: 14 February 2024
---

When clients send data to the DAL, they must choose which slot to put it in.
Expand Down Expand Up @@ -114,6 +114,14 @@ Follow these steps to update the Smart Rollup to access information about slot 0
tezos-smart-rollup-host = { version = "0.2.2", features = [ "proto-alpha" ] }
```

The end of the file looks like this:

```toml
[dependencies]
tezos-smart-rollup = { version = "0.2.2", features = [ "proto-alpha" ] }
tezos-smart-rollup-host = { version = "0.2.2", features = [ "proto-alpha" ] }
```

1. Stop the Smart Rollup process.

1. Run the commands to build and deploy the Smart Rollup and start the node.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Part 1: Setting up an environment"
authors: 'Tim McMackin'
last_update:
date: 9 February 2024
date: 14 February 2024
---

Because Weeklynet requires a specific version of the Octez suite, you can't use most wallet applications and installations of the Octez suite with it.
Expand All @@ -29,6 +29,18 @@ To set up an environment and account in a Docker container, follow these steps:

The image tag in this command changes each time the network is reset.

:::tip
If you're not used to working inside Docker containers, you can map a folder on your computer to a folder in the container to create a [Docker volume](https://docs.docker.com/storage/volumes/).
This way, you can edit files on your computer and the changes will appear on the files inside the container.
For example, to start a container and map the current folder to the `/home/tezos` folder in the container, run this command:

```bash
docker run -it --entrypoint=/bin/sh -v .:/home/tezos tezos/tezos:master_7f3bfc90_20240116181914
```

You can map a folder like this only when you create a container; you cannot add it later.
:::

1. Copy the URL of the public RPC endpoint for Weeklynet, such as `https://rpc.weeklynet-2024-01-17.teztnets.com`.
This endpoint also changes each time the network is reset.

Expand All @@ -47,6 +59,14 @@ The parts of the Octez suite don't use this environment variable directly, but y
octez-client -E $ENDPOINT config init
```

1. Optional: Hide the network warning message by running this command:

```bash
export TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER=y
```

This command suppresses the message that your instance of the Octez client is not using Mainnet.

1. Create an account with the command `octez-client gen keys $MY_ACCOUNT`, where `$MY_ACCOUNT` is an alias for your account.

1. Get the public key hash of the new account by running the command `octez-client show address $MY_ACCOUNT`.
Expand Down
10 changes: 9 additions & 1 deletion docs/tutorials/join-dal-baker/get-octez.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Step 1: Get a Weeklynet-compatible Octez version"
authors: Tezos core developers
last_update:
date: 23 January 2024
date: 14 February 2024
---

The Weeklynet test network restarts every Wednesday at 0h UTC, and for most of its lifetime (from level 512) it runs a development version of the Tezos protocol, called Alpha, which is not part of any released version of Octez.
Expand Down Expand Up @@ -40,5 +40,13 @@ This endpoint also changes each time the network is reset.
octez-client -E https://rpc.weeklynet-2024-01-17.teztnets.com config init
```

1. Optional: Hide the network warning message by running this command:

```bash
export TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER=y
```

This command suppresses the message that your instance of the Octez client is not using Mainnet.

Now you have the Octez client and node configured to work with Weeklynet.
The next step is to start an Octez node; continue to [Step 2: Run an Octez node on Weeklynet](./run-node).
Loading
Loading